I'm new at Highcharts. I'm trying to create a Drilldown Bubble Chart.
I took the basic column drilldown as a starting point,
http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/drilldown/basic/
chart: {
type: 'column'
},
title: {
text: 'Basic drilldown'
},
xAxis: {
type: 'category'
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true
}
}
},
series: [{
name: 'Things',
colorByPoint: true,
data: [{
name: 'Animals',
y: 5,
drilldown: 'animals'
}, {
name: 'Fruits',
y: 2,
drilldown: 'fruits'
}, {
name: 'Cars',
y: 4,
drilldown: 'cars'
}]
}],
drilldown: {
series: [{
id: 'animals',
data: [
['Cats', 4],
['Dogs', 2],
['Cows', 1],
['Sheep', 2],
['Pigs', 1]
]
}, {
id: 'fruits',
data: [
['Apples', 4],
['Oranges', 2]
]
}, {
id: 'cars',
data: [
['Toyota', 4],
['Opel', 2],
['Volkswagen', 2]
]
}]
}
and edited it a bit, to get this,
http://jsfiddle.net/Slate_Shannon/kdwa9x7v/1/
$(function() {
$('#container').highcharts({
chart: {
type: 'bubble'
},
title: {
text: 'Basic drilldown'
},
xAxis: {
type: 'linear'
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true
}
}
},
series: [{
name: 'Things',
colorByPoint: true,
data: [{
name: 'Animals',
x: 4,
y: 5,
z: 10,
drilldown: 'animals'
}, {
name: 'Fruits',
x: 14,
y: 20,
z: 20,
drilldown: 'fruits'
}, {
name: 'Cars',
x: 8,
y: 9,
z: 7,
drilldown: 'cars'
}]
}],
drilldown: {
series: [{
id: 'animals',
data: [
['Cats', x: 5, y: 9, z: 7],
['Dogs', x: 8, y: 8, z: 9],
['Cows', x: 1, y: 5, z: 2],
['Sheep', x: 4, y: 7, z: 2],
['Pigs', x: 4, y: 5, z: 7]
]
}, {
id: 'fruits',
data: [
['Apples', x: 2, y: 9, z: 6],
['Oranges', x: 6, y: 5, z: 1]
]
}, {
id: 'cars',
data: [
['Toyota', x: 2, y: 8, z: 7],
['Opel', x: 8, y: 2, z: 4],
['Volkswagen', x: 4, y: 4, z: 4]
]
}]
}
});
});
All I did was
change the chart type to "bubble",
add the x and z data,
change the xaxis to "linear"
And it doesn't work.
Can you see the problem?
Thanks much!
Good day.
The formatting of your drilldown data is incorrect, as hinted to in console. Currently you have:
data: [
['Cats', x: 5, y: 9, z:7],
['Dogs', x: 8, y: 8, z:9],
// ...
]
This is half way between an array declaration and a object declaration. I'd suggest switching to each item being an object, like this:
data: [
{ name: 'Cats', x: 5, y: 9, z:7 },
{ name: 'Dogs', x: 8, y: 8, z:9 },
// ...
]
Secondly, you haven't included the required Highcharts-more module which includes the bubble chart type. You can do that like this:
<script src="https://code.highcharts.com/highcharts-more.js"></script>
See this updated JSFiddle for a basic example of how it can work.
Related
I'm trying to implement a drill down on a bar chart.
My data series are splitted on 6 categories on the x axis and I have three different series (Social, Cognitive and Language).
I would like to be able to drill down in my series. For example, 'social' is made of 'Family' and 'Personnal'.
My problem is that highchart only wants to drill down into one data serie. In my case I would like the drill down to display serveral data series.
In the fiddle below, I would like the drill down from 'Social' to display the series 'Family' and 'Personnal'. But highchart only display the 'Personnal' serie.
Is there a standard way to do this with Highcharts?
series: [
{
name: 'Social',
type: 'bar',
data: [
{ y: 10, drilldown: 'A' },
{ y: 5, drilldown: 'A' },
{ y: 3, drilldown: 'A' },
{ y: 1, drilldown: 'A' },
{ y: 0, drilldown: 'A' },
{ y: 0, drilldown: 'A' },
],
color: '#EEAA3C',
},
{
name: 'Cognitive',
type: 'bar',
data: [6, 3, 1, 0, 1, 1],
color: '#86BD4A',
},
{
name: 'Language',
type: 'bar',
data: [4, 2, 0, 2, 0, 0],
color: '#E26E3E',
},
],
drilldown: {
series: [
{
name: 'Family',
id: 'A',
type: 'bar',
data: [1, 1, 1, 0, 0, 0],
color: '#F2B553',
},
{
name: 'Personal',
id: 'A',
type: 'bar',
data: [9, 4, 2, 1, 0, 0],
color: '#F8CC87',
},
],
},
https://jsfiddle.net/pacambi/3k4eng7w/
Thanks !
I created highcharts heatmap with drilldown. Drilldown has link on xaxis lable. Could I have link only on yaxis? And remove link on xaxis. Since my drilldown chart is associate to y not x.
Highcharts.chart('container', {
chart: {
type: 'heatmap'
},
colorAxis: {
min: 0,
stops: [
[0, '#7EAB55'],
[0.5, '#FFFE55'],
[1, '#B02418']
],
},
series: [{
data: [{
x: 0,
y: 0,
value: 0,
drilldown: 'animals'
}, {
x: 0,
y: 1,
value: 1
}, {
x: 1,
y: 0,
value: 2,
drilldown: 'animals'
}, {
x: 1,
y: 1,
value: 1
}],
dataLabels: {
enabled: true,
color: '#000000'
}
}],
drilldown: {
series: [{
id: 'animals',
data: [
[0, 3, 1],
[1, 1, 4],
[2, 4, 3]
]
}]
}
});
This is example in fiddle. Thanks.
https://jsfiddle.net/lundi/jdc4mpk2/
From Sebastian's suggestion, this is the answer.
You can use the chart.inverted feature to achieve the wanted result: jsfiddle.net/BlackLabel/82qapmoe
Is it possible to make the following chart with Highcharts library?
It's a simple line chart but with inverted triangle shaped grid. Is there any predefined type or a way to customize the grid shape? Any pointers which will guide me to a proper direction would help. Thank you!
Another method of how to create this type of chart:
Demo
Highcharts.chart('container', {
chart: {
width: 500,
},
xAxis: {
opposite: true,
title: {
text: 'Report Date'
},
gridLineWidth: 1,
type: 'datetime',
categories: ['01/01/2012', '02/01/2012', '03/01/2012', '04/01/2012', '05/01/2012', '06/01/2012', '07/01/2012', '08/01/2012', '09/01/2012', '10/01/2012'],
tickmarkPlacement: 'on',
labels: {
rotation: -90,
y: -18
},
offset: -13,
lineWidth: 0,
max: 8.6,
},
legend: {
enabled: false
},
yAxis: {
title: {
text: 'Milestones'
},
categories: ['01/01/2012', '02/01/2012', '03/01/2012', '04/01/2012', '05/01/2012', '06/01/2012', '07/01/2012', '08/01/2012', '09/01/2012', '10/01/2012'],
tickmarkPlacement: 'on',
gridLineWidth: 1,
tickPosition: 'inside',
min: 0,
minPadding: 0,
startOnTick: false
},
series: [{
data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
marker: {
enabled: false
},
color: 'grey',
enableMouseTracking: false,
animation: false
}, {
data: [6, 6, 6, 7, 8, 7, 7, 8, 8.5, 9]
}, {
data: [5, 5, 5, 6, 6.5, 6, 6.5, 7.5, 8]
}, {
data: [4, 4, 4, 5, 5.5, 5.5, 6]
}, {
data: [2, 2.5, 2.5, 3.5, 4]
}, {
data: [1, 1.5, 2]
}, {
type: 'arearange',
data: [[0, 0, -5], [9.2, 9, -5]],
color: 'white',
fillOpacity: 1,
marker: {
enabled: false
},
zIndex: -1,
enableMouseTracking: false,
animation: false
}]
});
There is no such series type. However, you can make it with fake polygon series that will hide half of the chart. Check demo and code posted below.
Code:
Highcharts.chart('container', {
chart: {
height: 500,
width: 500,
events: {
load: function() {
var chart = this,
polygon = chart.series[2].group,
x = polygon.translateX,
y = polygon.translateY;
polygon.translate(x + 3, y + 3);
}
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
opposite: true,
gridLineWidth: 1,
gridLineColor: '#ddd',
tickInterval: 1,
maxPadding: 0,
lineWidth: 0,
max: 10,
min: 0
},
yAxis: {
maxPadding: 0,
tickInterval: 1,
gridLineColor: '#ddd',
max: 10,
min: 0
},
series: [{
name: 'Installation',
data: [8, 6, 7, 8, 7, 6]
}, {
name: 'Manufacturing',
data: [3, 2, 4, 4]
}, {
type: 'polygon',
animation: false,
showInLegend: false,
enableMouseTracking: false,
color: '#fff',
lineWidth: 10,
data: [
[0, 0],
[10, 0],
[10, 10]
]
}, {
type: 'line',
showInLegend: false,
enableMouseTracking: false,
data: [
[0, 0],
[10, 10]
],
color: '#ddd',
lineWidth: 1,
marker: {
enabled: false
}
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<div id="container"></div>
Demo:
https://jsfiddle.net/BlackLabel/xL9taoym/1/
You can use Highcharts SVG Renderer to render triangle that covers half of the chart.
Check this demo: https://jsfiddle.net/BlackLabel/2boma9zs
events: {
load: function() {
var chart = this,
left = chart.plotLeft,
top = chart.plotTop,
width = chart.plotSizeX,
height = chart.plotSizeY;
chart.renderer.path([
'M', left + 1, top + height,
'L', left + width + 1, top,
left + width + 3, top,
left + width + 3, top + height + 3,
left + 1, top + height + 3,
left + 1, top + height
])
.attr({
fill: '#fff'
})
.add()
.toFront();
}
}
API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#path
https://api.highcharts.com/class-reference/Highcharts.SVGElement#toFront
https://api.highcharts.com/highcharts/chart.events.load
I need to set horizontal bubble stacking, i got four stacked columns and i need to place bubbles on top of each. I made vertical stacking, but horizontaly they stay on on each
My code: http://jsfiddle.net/Hideon/7bu2z0mk/1/
Highcharts.chart('container', {
chart: {
type: 'column'
},
xAxis: {
type: 'datetime',
},
plotOptions: {
pointWidth: 1,
column: {
stacking: 'normal',
pointRange: 1000 * 60 * 60 * 24
},
bubble: {
stacking: 'normal',
}
},
series: [
{
type: 'bubble',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9,
z: 5
},
],
stack: 0
},
{
type: 'bubble',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9,
z: 5
},
],
stack: 0
},
{
type: 'bubble',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9,
z: 5
},
],
stack: 1
},
{
type: 'bubble',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9,
z: 5
},
],
stack: 1
},
{
type: 'column',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9
},
],
stack: 0
}, {
type: 'column',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9
},
],
stack: 0
}, {
type: 'column',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9
},
],
stack: 1
}, {
type: 'column',
data: [{
x: Date.UTC(2010, 0, 1),
y: 29.9
},
],
stack: 1
}
]
});
Stacking for bubble series type is not supported, but you can implement it. Please take a look at the example below, you can calculate y value for all bubble points by using toValue method:
Highcharts.chart('container', {
chart: {
events: {
load: function() {
var bubble = this.series[0],
yAxis = this.yAxis[0],
base = yAxis.toPixels(0),
xVal = 0,
radius,
newY = 0;
Highcharts.each(bubble.points, function(p, i) {
if (p.x !== xVal) {
xVal = p.x;
newY = 0;
}
radius = p.marker.radius;
newY += yAxis.toValue(base - radius)
p.update({
y: newY
});
newY += yAxis.toValue(base - radius);
});
}
}
},
yAxis: {
min: 0,
max: 5
},
series: [{
type: 'bubble',
data: [
[0, 0, 10],
[0, 0, 20],
[0, 0, 15],
[0, 0, 12],
[0, 0, 20],
[0, 0, 15],
[1, 0, 11],
[1, 0, 12],
[1, 0, 13],
[1, 0, 14],
[1, 0, 16],
[1, 0, 15]
]
}]
});
Live demo: http://jsfiddle.net/BlackLabel/dmn63hce/
API: https://api.highcharts.com/class-reference/Highcharts.Axis#toValue
I have been pulling my hair out trying to get this highcharts irregular spline with drilldown and couldnt get the drilldown to work. I am new to highcharts and I think it may have to do with my syntax. I have referenced the API and tried a few methods with no luck.
Problem: I wanted to get a irregular spline to show counts of fruits by month. The drilldown would then show counts for types of fruits (apples and oranges). I am able to show the counts of fruits but the drilldown is not working.
The codes is below and also here: http://jsfiddle.net/bu2002/352a0zvr/2/
THanks so much everyone!!!
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
type: 'spline'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
},
title: {
text: 'Date'
}
},
yAxis: {
title: {
text: 'count'
},
min: 0
},
series: [{
name: 'Fruits',
data: [
[Date.UTC(2014, 7, 19),12],
[Date.UTC(2014, 8, 19),5],
[Date.UTC(2014, 9, 19),18]
],
drilldown: 'fruits'
},
{
name: 'Animals',
data: [
[Date.UTC(2014, 7, 29),15],
[Date.UTC(2014, 8, 11),11],
[Date.UTC(2014, 9, 22),38]
],
drilldown: 'animals'
}
],//end series
drilldown: {
series: [{
id: 'animals',
data: [[Date.UTC(2014, 7, 29),15],
[Date.UTC(2014, 8, 11),11],
[Date.UTC(2014, 9, 22),38]],
},
{
id: 'fruits',
data: [
[Date.UTC(2014, 7, 29),15],
[Date.UTC(2014, 8, 11),11],
[Date.UTC(2014, 9, 22),38]
],
}
]
}//end drilldown
};//and options
var chart = new Highcharts.Chart(options);
});
The issue is now that you are providing a drilldown.id on the series. You need to do it per point. For example:
series: [{
name: 'Things',
colorByPoint: true,
data: [{
name: 'Animals',
y: 5,
drilldown: 'animals'
}, {
name: 'Fruits',
y: 2,
drilldown: 'fruits'
}, {
name: 'Cars',
y: 4,
drilldown: 'cars'
}]
}],
It looks to me like you want to have any drilldown on a point in "Fruits" to link to the same drilldown series. This is doable:
series: [{
name: 'Fruits',
data: [{
x: Date.UTC(2014, 7, 19),
y: 12,
drilldown: 'fruits'
}, {
x: Date.UTC(2014, 8, 19),
y: 5,
drilldown: 'fruits'
}, {
x: Date.UTC(2014, 9, 19),
y: 18,
drilldown: 'fruits'
}]
},
See update fiddle.
But here also U dont get 2 splines after clicking on fruits, u just get one.
Is there any way to get that as i have the same issue
fiddle https://jsfiddle.net/surya_swami/zx9dy3uj/40/
drilldown: { series: [{id:"z1",name: "Region-1",
data: [{ name : "July",y: 10},
{ name : "Aug",y: 21},
{ name : "Sept",y: 15}]
},
{id:"z1",name: "Region-2",
data: [{ name : "July",y: 12},
{ name : "Aug",y: 9},
{ name : "Sept",y: 25}]
},
{ id:'z2',name:'Region-3',
data : [{name:'July',y:23},
{name:'Aug',y:41},
{name:'Sept',y:31}]
},
{ id:'z2',name:'Region-4',
data : [{name:'July',y:33},
{name:'Aug',y:23},
{name:'Sept',y:12}]
},
{ id:'z2',name:'Region-5',
data : [{name:'July',y:31},
{name:'Aug',y:39},
{name:'Sept',y:19}]
}
]
}