Highcharts 3.0 Bubble Chart -- Controlling bubble sizes - highcharts

With Highcharts 3.0 it is possible to create charts with type 'bubble', whereas prior to 3.0 it was necessary to use a 'scatter' chart and modify marker size to make bubble charts. The nice thing about the old way is you had complete control over the visible pixel radius of each bubble--the new bubble charts automatically resize the bubbles so they are sized relative to each other. Is there any way to turn off this behavior or set bubble radius manually?

I am having a hard time seeing how a bubble chart, where the bubbles are not sized relative to each other, would be of any use.
You should be able to use the minSize and maxSize options, however, to control them the way that you need to:
bubble: {
minSize:2,
maxSize:50
}
{{edit:
I don't see them in the docs either, actually. But you can see an example here: http://jsfiddle.net/fXzke/13/ use either number as pixel value, or string with percent of chart height
}}

I found that adding an "empty" bubble to the series helps keep the size of all bubbles in the chart relative to each other:
name: '',
data: [{x:0,y:0,z:0}],
showInLegend: false,
color: 'transparent',
enableMouseTracking: false
Here's a sample on JSFiddle: http://jsfiddle.net/9bebT/2/. The legend, color, and mouse tracking variables each help keep the item in the series but otherwise invisible to the user. If you simply remove the empty bubble or set its visibility to "false," the chart doesn't register the empty bubble's z axis (diameter) as the minSize.

Related

In a Highcharts Stacked Area chart, is there a way of highlighting the area hovered over, rather than the area belonging to the nearest point?

My issue with the Highcharts Stacked Area chart is in how it selects which series to highlight. It SEEMS to highlight the series associated with the nearest point, whereas I would like it to highlight the series the mouse is actually hovering over.
In the image below, the mouse is actually hovering over the area in light blue, but because the nearest point is in the dark blue series, it's highlighting that area.
This causes an issue when you have multiple series stacked with very small and very high values (even zero). The user hovers a series with a large area, but the point it highlights might be associated with a series with no visible area (because it has a zero data point), and it will highlight the point with a tooltip saying something like "Switzerland: 0.00" rather than "Brazil: 9.999.99", even though you're hovering over Brazil
Disable stickyTracking and enable trackByArea options:
plotOptions: {
series: {
...,
stickyTracking: false,
trackByArea: true
}
}
Live demo: http://jsfiddle.net/BlackLabel/7ens45ot/
API Reference:
https://api.highcharts.com/highcharts/series.area.stickyTracking
https://api.highcharts.com/highcharts/series.area.trackByArea

Packed Bubble Chart with Gradient Legend in Highcharts

We are using the packed bubble chart but we are using the size AND color to represent the same data dimension (e.g. money each person has)
Functionally, the color is on a gradient from low to high. And now we would like to add in a legend kindof like what you have on a heat map (https://www.highcharts.com/demo/heatmap) where you can see the low color/value with a gradient to the high color/value. Your demo on the heatmap even has a sympathetic highlight between the cell and the legend... that would be cool to bring over. Hell, it would be super cool to even use the legend to filter or refine the circles!
Anyway. The core of the quesiton is, how can we bring that heatmap style legend into the packed bubble chart? Not the bubble size, but representing the color
You need to use color axis. It is a separate module, but it is also build-in in heatmap and map.
Highcharts.chart('container', {
colorAxis: {
...
},
...
});
Live demo: https://jsfiddle.net/BlackLabel/smo3nfzj/
API Reference: https://api.highcharts.com/highcharts/colorAxis

Fixed plot height in scatter chart

I have been searching this but not able to get any solutions for this. I want my scatter chart to be of fixed height regardless of no of legends used.
Please look into below fiddle link:
http://jsfiddle.net/3o982ewu/118/
"chart": {
"type": "scatter",
"zoomType": "xy",
"plotBorderWidth": 2,
"width": 400,
"height":400,
.....
I have set chart height to be 400. If no of legends increase, then scatter chart height gets adjusted (decrease) accordingly. You can try increasing the legends and notice that chart height gets decreased. I have tried other options like setting margin top and bottom (suggested in one post) but no luck.
I see that in highcharts js, there is 'plotHeight' variable which is used to set the chart height but I find no means to set it from my code or provide into as chart options. This scatter chart will be displayed in pdf so there is no scope of adding pagination, scrolls or any other stuff which is feasible only in web browser but not in pdf.
I am answering my own question because I found a way to deal with this scenario.
We hid the legends on the chart, so this way plot height of the chart will be always fixed. (plotHeight will be equal to the height of the chart which we provide in the chart settings considering we don't supply any margins)
We stored the data points (color of the legend and legend name) in the array and printed those outside the chart to make them appear as legends.

Datalabels text overflow from plot area in highchart's pie chart

In my highchart's pie chart datalabels working properly when width and height is default (600*400),
but while change the height and width in custom manner the datalabel text (Internet Explorer some text) overflow from plot are and hide.
BTW i used the option
dataLabels: {
crop:false,
overflow:'none'
}
for avoiding overflow but can't
here my fiddle
The source of the problem here is size parameter.
From the API (https://api.highcharts.com/highcharts/series.pie.size):
The default behaviour (as of 3.0) is to scale to the plot area and
give room for data labels within the plot area.
So if you manually set it to 100% data labels can be rendered outside of the plot area - Highcharts won't try to find an optimal value for size parameter.
Your demo works fine if you preserve the default value of size: http://jsfiddle.net/BlackLabel/zjaa7y81/

Position single data label of highcharts pie chart centered below the chart

I am using Highcharts and have initialized a pie chart, but with 4 pies in it, lined up in a row. Each pie has 2 slices, the second one is always transparent and has no datalabel, so every single chart has only 1 data label to show a value.
The only thing I want is to center the data label below the pie chart.
The problem is that dependent on the size of the visible slice the data label is moving because it is kinda bound to it?
Image to show the problem and the current state:
I tried to position the labels by using x and distance:
plotOptions: {
pie: {
dataLabels: {
distance: 0,
x: -100
which is actually working; I would have to fix the position for each chart and its data label.
But since the chart data can be changed by click the filled slice will change and so the data labels would reposition themselves. So I kinda need a way to fix their position relative to the center of the chart or something like that.
Thanks to Sebastian Bochan for the comment. I ended up using the renderer:
this.renderer.label(
this.series[0].data[0].name + '<br>'
+ Highcharts.numberFormat(this.series[0].data[0].percentage, 2)+'%',
80, 320,'callout')}).add();
Just an example. The 80 and 320 here set the position of the label in the plot area. Renderer

Resources