Reputation: 117
I have a bar diagram something similar to this
And I need to display a drill-down in such a way that a single column is split into multiple bars in the next page.
For example: If I click Apples column in the bar, it should drill down into the next page with 3 columns
Similar operations for the rest of the columns in the main bar diagram. Finally, I should be able to navigate back to the main page as well.
Any help from anyone would be much appreciated. Thanks in advance.
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: ( // theme
Highcharts.defaultOptions.title.style &&
Highcharts.defaultOptions.title.style.color
) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true
}
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Chart showing stacked columns for comparing quantities. Stacked charts
are often used to visualize data that accumulates to a sum. This chart
is showing data labels for each individual section of the stack.
</p>
</figure>
Upvotes: 0
Views: 772
Reputation: 11633
Your requirement is possible to achieve by config data in the proper way and adding drilldown module.
Demo: https://jsfiddle.net/BlackLabel/xz46uspb/
Series data example:
series: [{
name: 'John',
data: [{
y: 5,
name: 'Apples',
drilldown: "Apples"
}, {
y: 3,
name: 'Oranges',
drilldown: "Oranges"
}, {
y: 4,
name: 'Pears',
drilldown: "Pears"
}]
}, ...
],
And drilldown data:
drilldown: {
series: [{
name: 'Apples',
id: 'Apples',
colorByPoint: true,
data: [{
name: 'John',
y: 5
}, {
name: 'Jane',
y: 2
}, {
name: 'Joe',
y: 3
}]
}]
}
API: https://api.highcharts.com/highcharts/xAxis.type
API: https://api.highcharts.com/highcharts/series.column.colorByPoint
API: https://api.highcharts.com/highcharts/drilldown
Upvotes: 0