The new Highcharts v3.0 bubble chart looks great. Is it possible to annotate and display each bubble with a name/some text? Thanks, Nigel.
Packed bubble charts are visualizations where the size and optionally the color of the bubbles are used to visualize the data. The positioning of the bubbles is not significant, but is optimized for compactness.
Highcharts is a software library for charting written in pure JavaScript, first released in 2009. The license is proprietary.
There are two things you need to do.
First, name each data point (bubble):
data: [ { name: 'Alice', x: 3.5, y: 4, z: 5}, { name: 'Eve', x: 7, y: 7, z: 3}, { name: 'Carol', x: 4, y: 8, z: 6} ]
Second, create a data label formatter:
dataLabels: { enabled: true, formatter: function() { return this.point.name; } }
You can see this in action here: http://jsfiddle.net/franzo/JuGDp/1/
Bob's your uncle.
Depending on what you want to display, it should be possible. The bubble charts will allow the same options as any other highcharts. The easiest way is to use dataLabels http://api.highcharts.com/highcharts#plotOptions.scatter.dataLabels
dataLabels:{
enabled:true
}
e.g. http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-datalabels-box/
If that isn't flexible enough for you, it is possible to draw whatever you want on the chart using the underlying renderer http://api.highcharts.com/highcharts#Renderer. This is a bit harder, but. Fairly straight forward once you get the hang of it.
I've created a small example using datalabels here :http://jsfiddle.net/4nRk6/
Datalabels can be customised with a formatter function, for example:
dataLabels: {
enabled: true,
formatter: function() {
return this.y +'mm';
}
}
The full documentation is here: http://api.highcharts.com/highcharts#plotOptions.column.dataLabels
If you want extra information on the bubbles, you may need to format your data series as follows:
[
{x:1, y:5, bubbleText:"Bubble 1"},
{x:2, y:15, bubbleText:"Bubble 2"},
{x:3, y:5, bubbleText:"Bubble 3"}
]
Inside your dataLabel, you can then reference this.point.bubbleText as well as this.x and this.y.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With