I plotted a double donut chart using Highcharts library. My requirement is when I drill down from the initial level, I should be able to plot another double donut chart.
For eg: This is the initial level. Now if I click on Email, it should drill down and show another double donut chart
This is the desired result after drill down
Following is the current code to render chart. For each series data, we have drilldown option which can take a string for eg: 'Email'. I need double donut under the drilldown but drilldown series with same id don't work and I end up getting only 1 donut chart.
Highcharts.chart('container', {
chart: {
type: 'pie',
/* backgroundColor: '#000', */
},
title: {
text: '',
},
subtitle: {
text: '',
},
accessibility: {
announceNewData: {
enabled: true,
},
point: {
valueSuffix: '%',
},
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%',
},
},
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat:
'<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>',
},
series: [
{
innerSize: 150,
size: 200,
name: 'Browsers',
colorByPoint: true,
data: [
{
name: 'Email',
y: 62.74,
drilldown: 'Email',
},
{
name: 'Social Media',
y: 10.57,
drilldown: 'Social Media',
},
{
name: 'Shopping',
y: 7.23,
drilldown: 'Shopping',
},
{
name: 'Trading',
y: 5.58,
drilldown: 'Trading',
},
{
name: 'Others',
y: 4.02,
drilldown: 'null',
},
],
},
{
showInLegend: false,
dataLabels: {
enabled: false,
},
innerSize: 100,
size: 150,
name: 'Email',
colorByPoint: true,
data: [
{
name: 'Email',
y: 52.74,
drilldown: null,
},
{
name: 'Social Media',
y: 15.57,
drilldown: null,
},
{
name: 'Shopping',
y: 12.23,
drilldown: null,
},
{
name: 'Trading',
y: 5.58,
drilldown: null,
},
{
name: 'Other',
y: 4.02,
drilldown: null,
},
],
},
],
drilldown: {
series: [
{
innerSize: 150,
size: 200,
name: 'Email',
id: 'Email',
data: [
['Gsuite', 0.1],
['office365', 1.3],
['Yahoo', 53.02],
],
},
{
innerSize: 100,
size: 150,
name: 'Email',
id: 'Email',
data: [
['user1', 0.1],
['user2', 1.3],
['user3', 53.02],
],
},
],
},
});
This is the current result
Here is the jsfiddle which I am currently working on.
Any help on this will be much appreciated.
Thanks
Related
I have a packed bubble chart that works great. I would like to add a title to each of the larger, separated bubbles. The title should always show and I would like it to be the name of the series. I'm using a split series.
The 'name' attribute shows up in the tooltip, but I would like it to always be displayed.
Here is the code to create the bubbles:
Highcharts.chart('bubble-split-chart', {
chart: {
type: 'packedbubble',
animation: false,
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
stops: [
[0, '#15191b'],
[1, '#15191b']
]
},
},
// remove hamburger button
exporting: {
enabled: false
},
// remove chart watermark (highcharts.com)
credits: {
enabled: false
},
title: {
text: '',
enabled: false
},
tooltip: {
useHTML: true,
pointFormat: '<b>{point.name}</b>'
},
plotOptions: {
packedbubble: {
minSize: '1%',
maxSize: '100%',
zMin: 1,
zMax: 400,
layoutAlgorithm: {
enableSimulation: false,
gravitationalConstant: 0.05,
splitSeries: true,
seriesInteraction: false,
dragBetweenSeries: false,
parentNodeLimit: true
}
},
legend: {
enabled: false
}
},
series: [{
name: 'Test',
data: [{
name: "Lorem",
value: 29.4,
color: 'red'
},
{
name: "Ipsum",
value: 34.1,
color: 'blue'
},
{
name: "Dolor",
value: 7.1,
color: 'green'
}],
}, {
name: 'Test 2',
data: [{
name: 'Lorem',
value: 300.1,
color: 'red'
},
{
name: 'Ipsum',
value: 20.7,
color: 'blue'
},
{
name: "Dolor",
value: 97.2,
color: 'green'
}],
}, {
name: 'Test 3',
data: [{
name: "Lorem",
value: 8.2,
color: 'red'
},
{
name: "Ipsum",
value: 9.2,
color: 'blue'
},
{
name: "Dolor",
value: 13.1,
color: 'green'
}],
}]
});
Is this possible? Also, if this is possible, how can I remove the name from the tooltip?
You can add the labels by using annotations or Highcharts.SVGRenderer class.
To remove the series name from tooltip set:
tooltip: {
headerFormat: '',
...
}
Live demo: http://jsfiddle.net/BlackLabel/6m4e8x0y/4771/
API Reference:
https://api.highcharts.com/class-reference/Highcharts.SVGRenderer
https://api.highcharts.com/highcharts/annotations
https://api.highcharts.com/highcharts/tooltip.headerFormat
I am using High charts packed bubble chart and I need to show different sizes of bubbles according to its value (negative values). It is working fine when I pass positive values but size of the circle not changing when I pass negative values. Is there any way to show chart with negative values?
js fiddle link with code example
Highcharts.chart('container', {
chart: {
type: 'packedbubble',
height: '100%'
},
title: {
text: 'TOP Countries'
},
tooltip: {
useHTML: true,
pointFormat: '<b>{point.name}:</b> {point.value}'
},
plotOptions: {
packedbubble: {
minSize: '30%',
maxSize: '80%',
zMin: 0,
zMax: 1000,
layoutAlgorithm: {
splitSeries: false,
gravitationalConstant: 0.02
},
dataLabels: {
enabled: true,
format: '{series.name}',
filter: {
property: 'y',
operator: '>',
value: 250
},
style: {
color: 'black',
textOutline: 'none',
fontWeight: 'normal'
}
}
}
},
series: [{
name: 'ASEAN',
data: [{
name: "ASEAN",
value: -88.2
}]
}, {
name: 'KOR ',
data: [{
name: "KOR",
value: -605.2
}]
}, {
name: 'CHN ',
data: [{
name: "CHN",
value: -427233.7
}]
}, {
name: 'ISA ',
data: [{
name: "ISA",
value: -355.39
}]
}, {
name: 'ANZ ',
data: [{
name: "ANZ ",
value: -3331.4
}]
}, {
name: 'JP ',
data: [{
name: "JP1",
value: -22470857.0
},{
name: "JP2",
value: -21470857.0
}]
}]
});
graph with negative values
graph with positive values
Properties zMin and zMax are not a part of official packedbubble series API, but they are internally used and work as in bubble series.
plotOptions: {
packedbubble: {
minSize: '30%',
maxSize: '80%',
//zMin: 0,
//zMax: 1000,
...
}
}
Live demo: https://jsfiddle.net/BlackLabel/vro2wzL4/
API Reference:
https://api.highcharts.com/highcharts/series.packedbubble
https://api.highcharts.com/highcharts/series.bubble.zMin
I'm using candlestick chart of HighChart-HighStock. I want to reduce the gap between candlesticks. It's not so bad when it's on a wide range zoom. But when I zoomed the chart a lot, the padding between candle makes me annoyed because they are too wide apart.
I tried setting pointPadding of plotOption&xAxis to 0, but nothing happened. How can I shrink this gap?
Zoomed chart - too wide gap between candlestick
Wide view chart - not so bad
Highcharts.stockChart('container', {
// title: { text: '---'},
rangeSelector: {
buttons: [
// { type: 'hour', count: 1, text: '1h' },
{
type: 'day',
count: 1,
text: '1d'
},
// { type: 'all', count: 1, text: 'All' }
],
selected: 1,
//inputEnabled: true
},
xAxis: [{
pointPadding: 0,
type: 'datetime',
}, {
type: 'datetime',
}],
yAxis: [{
labels: {
align: 'right',
x: -3
},
title: {
text: 'OHLC'
},
height: '70%',
lineWidth: 2,
resize: {
enabled: true
}
}, {
labels: {
align: 'right',
x: -3
},
title: {
text: 'Volume'
},
top: '75%',
height: '25%',
offset: 0,
lineWidth: 2
}],
plotOptions: {
candlestick: {
pointPadding: 0,
downColor: 'blue',
upColor: 'red',
dataGrouping: {
enabled: false,
}
},
line: {
lineWidth: 1,
states: {
hover: {
enabled: false
}
}
}
},
series: [{
name: 'ohlc',
type: 'candlestick',
data: chartData,
},
{
name: 'avg5',
type: 'line',
data: avg5Data,
color: '#FF0000',
},
{
name: 'avg10',
type: 'line',
data: avg10Data,
color: '#0C9B3A',
},
{
name: 'avg20',
type: 'line',
data: avg20Data,
color: '#FF9900',
},
{
name: 'avg60',
type: 'line',
data: avg60Data,
color: '#000000',
},
{
name: 'vol',
type: 'column',
data: moneyData,
yAxis: 1,
color: '#0944a3',
dataGrouping: {
enabled: false,
}
}
],
});
}
You need to set the series.pointPadding combined with series.groupPadding (equal to zero) to achieve the expected effect. Here is the example: https://jsfiddle.net/ahxrk5zq/
series: [{
type: 'candlestick',
name: 'AAPL Stock Price',
data: data,
groupPadding: 0,
pointPadding: 0.04,
dataGrouping: {
units: [
[
'week', // unit name
[1] // allowed multiples
], [
'month',
[1, 2, 3, 4, 6]
]
]
}
}]
API Reference:
https://api.highcharts.com/highstock/series.candlestick.pointPadding
https://api.highcharts.com/highstock/series.candlestick.groupPadding
I am trying to display the drilldown series pie chart data on click. I'm able to display the pie chart series name the user clicks on but not the drill down data.
Here is an example:
$(function () {
// Create the chart
$('#container').highcharts({
chart: {
type: 'pie'
},
title: {
text: 'Browser market shares. January, 2015 to May, 2015'
},
subtitle: {
text: 'Click the slices to view versions. Source: netmarketshare.com.'
},
plotOptions: {
series: {
events:{
click: function (event) {
alert(event.point.name)
}
},
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Microsoft Internet Explorer',
y: 56.33,
drilldown: 'Microsoft Internet Explorer'
}, {
name: 'Chrome',
y: 24.03,
drilldown: 'Chrome'
}, {
name: 'Firefox',
y: 10.38,
drilldown: 'Firefox'
}, {
name: 'Safari',
y: 4.77,
drilldown: 'Safari'
}, {
name: 'Opera',
y: 0.91,
drilldown: 'Opera'
}, {
name: 'Proprietary or Undetectable',
y: 0.2,
drilldown: null
}]
}],
drilldown: {
series: [{
name: 'Microsoft Internet Explorer',
id: 'Microsoft Internet Explorer',
data: [
['v11.0', 24.13],
['v8.0', 17.2],
['v9.0', 8.11],
['v10.0', 5.33],
['v6.0', 1.06],
['v7.0', 0.5]
]
}, {
name: 'Chrome',
id: 'Chrome',
data: [
['v40.0', 5],
['v41.0', 4.32],
['v42.0', 3.68],
['v39.0', 2.96],
['v36.0', 2.53],
['v43.0', 1.45],
['v31.0', 1.24],
['v35.0', 0.85],
['v38.0', 0.6],
['v32.0', 0.55],
['v37.0', 0.38],
['v33.0', 0.19],
['v34.0', 0.14],
['v30.0', 0.14]
]
}, {
name: 'Firefox',
id: 'Firefox',
data: [
['v35', 2.76],
['v36', 2.32],
['v37', 2.31],
['v34', 1.27],
['v38', 1.02],
['v31', 0.33],
['v33', 0.22],
['v32', 0.15]
]
}, {
name: 'Safari',
id: 'Safari',
data: [
['v8.0', 2.56],
['v7.1', 0.77],
['v5.1', 0.42],
['v5.0', 0.3],
['v6.1', 0.29],
['v7.0', 0.26],
['v6.2', 0.17]
]
}, {
name: 'Opera',
id: 'Opera',
data: [
['v12.x', 0.34],
['v28', 0.24],
['v27', 0.17],
['v29', 0.16]
]
}]
}
});
});
Instead of alert(event.point.name) I want to access the drilldown series data corresponding to the id the user clicks on.
Using the console.log I thought this would work (this.chart.series[0].data[0]) but it displays the series data and not the drilldown.
You are missing drilldown.js which is needed to drilldown the pie.
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
See the Working fiddle here
This is the answer:
this.chart.options.drilldown.series[0].data[0]
I have a pie chart(high chart) to show the work done by various employees in a department. Everything is working fine. Now I have a requirement to show the name of which slice is clicked when the drill down chart is clicked,so that after downloading the PDF report i can know the source of the drill down.Sample code is as below:
$(function () {
$('#container').highcharts({
chart: {
type: 'pie'
},
title: {
text: 'Employee Activities'
},
subtitle: {
text: 'Click the slices to view drilldown.'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: [{
name: 'Work Load',
colorByPoint: true,
data: [{
name: 'Mr.A',
y: 56.33,
drilldown: 'Mr.A'
}, {
name: 'Mr.B',
y: 24.03,
drilldown: 'Mr.B'
}, {
name: 'Mr.C',
y: 10.38,
drilldown: 'Mr.C'
}, {
name: 'Ms.D',
y: 4.77,
drilldown: 'Ms.D'
}, {
name: 'Ms.F',
y: 0.91,
drilldown: 'Ms.F'
}, {
name: 'Mr.Z',
y: 0.2,
drilldown: null
}]
}],
drilldown: {
series: [{
name: 'Mr.A',
id: 'Mr.A',
data: [
['W1', 24.13],
['W2', 17.2],
['W3', 8.11],
['W4', 5.33],
['W5', 1.06],
['W6', 0.5]
]
}, {
name: 'Mr.B',
id: 'Mr.B',
data: [
['W1', 5],
['W2', 4.32],
['W3', 3.68],
['W4', 2.96],
['W5', 2.53],
['W6', 1.45]
]
}, {
name: 'Mr.C',
id: 'Mr.C',
data: [
['W1', 2.76],
['W2', 2.32],
['W3', 2.31],
['W4', 1.27]
]
}, {
name: 'Ms.D',
id: 'Ms.D',
data: [
['W1', 2.56],
['W2', 0.77],
['W3', 0.42],
['W4', 0.3],
['W5', 0.29],
['W6', 0.26],
['W7', 0.17]
]
}, {
name: 'Ms.F',
id: 'Ms.F',
data: [
['W7', 0.34],
['W9', 0.24],
['W10', 0.17],
['W11', 0.16]
]
}]
}
});
});
Now If I download the drill down chart, the PDF does not show the name of which slice is downloaded.
Please help me with displaying the name of which drill down is downloaded in the PDF.
You can set the title in chart-> events -> drilldown/drillup events.
events: {
drilldown: function(e) {
this.setTitle({
text: e.seriesOptions.name
});
},
drillup: function(e) {
this.setTitle({
text: 'Employee Activities'
});
}
}
The working fiddle for same can be found here
So your final chart node would be something like below.
chart: {
type: 'pie',
events: {
drilldown: function(e) {
this.setTitle({
text: e.seriesOptions.name
});
},
drillup: function(e) {
this.setTitle({
text: 'Employee Activities'
});
}
},
}
try add code below code
exporting: {
filename: 'custom-file-name'
}
now you set file name according your requirement .
As I understood, you have problems with finding name of the clicked drilldown.
Here's how you can do it JSFiddle (code below). Then you can use that name in download.
This is how your plotOptions should look like:
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%'
},
cursor: 'pointer',
point: {
events: {
click: function () {
//Clicked drilldown name will be alerted here
//You can use it in naming PDF
alert(this.name);
}
}
}
}
},
...here's full code:
$(function () {
$('#container').highcharts({
chart: {
type: 'pie'
},
title: {
text: 'Employee Activities'
},
subtitle: {
text: 'Click the slices to view drilldown.'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%'
},
cursor: 'pointer',
point: {
events: {
click: function () {
//Clicked drilldown name will be alerted here
//You can use it in naming PDF
alert(this.name);
}
}
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: [{
name: 'Work Load',
colorByPoint: true,
data: [{
name: 'Mr.A',
y: 56.33,
drilldown: 'Mr.A'
}, {
name: 'Mr.B',
y: 24.03,
drilldown: 'Mr.B'
}, {
name: 'Mr.C',
y: 10.38,
drilldown: 'Mr.C'
}, {
name: 'Ms.D',
y: 4.77,
drilldown: 'Ms.D'
}, {
name: 'Ms.F',
y: 0.91,
drilldown: 'Ms.F'
}, {
name: 'Mr.Z',
y: 0.2,
drilldown: null
}]
}],
drilldown: {
series: [{
name: 'Mr.A',
id: 'Mr.A',
data: [
['W1', 24.13],
['W2', 17.2],
['W3', 8.11],
['W4', 5.33],
['W5', 1.06],
['W6', 0.5]
]
}, {
name: 'Mr.B',
id: 'Mr.B',
data: [
['W1', 5],
['W2', 4.32],
['W3', 3.68],
['W4', 2.96],
['W5', 2.53],
['W6', 1.45]
]
}, {
name: 'Mr.C',
id: 'Mr.C',
data: [
['W1', 2.76],
['W2', 2.32],
['W3', 2.31],
['W4', 1.27]
]
}, {
name: 'Ms.D',
id: 'Ms.D',
data: [
['W1', 2.56],
['W2', 0.77],
['W3', 0.42],
['W4', 0.3],
['W5', 0.29],
['W6', 0.26],
['W7', 0.17]
]
}, {
name: 'Ms.F',
id: 'Ms.F',
data: [
['W7', 0.34],
['W9', 0.24],
['W10', 0.17],
['W11', 0.16]
]
}]
}
});
});