score:2
In general plotBands doesn't have any tooltip or legend options, however it is possible to add some custom events to plotBand, for example mouseover. See: http://api.highcharts.com/highcharts#xAxis.plotBands.events
So you can create your own tooltip for this.
score:0
It is actually possible to make quite elegant labels for gauge plotbands by attaching text to the svg path elements that are generated by Highcharts. By doing this, you can get text that actually follows the curve of the plotband. Specifically look at the code in the annonymous function that triggers after the gauge has initialised. You'll need to get the correct plotband object, assign an id attribute to the path element and then insert text and textPath elements (using createElementNS). You then link the newly-created textPath element using the xlink namespace. In my example I am applying labels for quartiles that are displayed as plotbands around the gauge.
Example:
$(selector).highcharts({
chart: {
type: 'gauge',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false
},
title: {
//oConfig is my own config object
text: oConfig.TITLE,
style: {"color": "#333333", "fontSize": fontSize, "font-family": "Arial", "font-weight": "bold"}
},
pane: {
size: "100%",
startAngle: -150,
endAngle: 150,
background: [{
backgroundColor: '#FFF',
borderWidth: 0,
outerRadius: '100%',
innerRadius: '100%'
}]
},
/*the value axis*/
yAxis: [{
min: oConfig.MIN,
max: oConfig.MAX,
minorTickInterval: 'auto',
minorTickWidth: 0,
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickColor: '#666',
tickPixelInterval: 30,
tickWidth: 2,
tickPosition: 'inside',
tickLength: 10,
tickColor: '#666',
labels: {
step: 2,
rotation: 'auto'
},
title: {
text: null
},
plotBands: [{
from: oConfig.PB1FROM,
to: oConfig.PB1TO,
color: 'red',
outerRadius: "105%",
//innerRadius: "10%",
thickness : "5%"
}, {
from: oConfig.PB2FROM,
to: oConfig.PB2TO,
color: '#fdd01b',
outerRadius: "105%",
//innerRadius: "10%",
thickness : "5%"
}, {
from: oConfig.PB3FROM,
to: oConfig.PB3TO,
color: 'green',
outerRadius: "105%",
//innerRadius: "10%",
thickness : "5%"
}]
}],
credits: {
enabled: false
},
series: [{
name: name,
data: []/*,
tooltip: {
valuePrefix: 'Score: ',
valueSuffix: ' out of 5'
}*/
}]
},
//Add some life
function (chart) {
var svgNS = "http://www.w3.org/2000/svg";
var xlinkNS = "http://www.w3.org/1999/xlink";
//I create a random id using my own helpers.makeid() method - you'll need to roll your own
var id = helpers.makeid();
//quartile 1
var elem = chart.yAxis[0].plotLinesAndBands[1].svgElem.element;
elem.setAttribute("id", id);
var newText = document.createElementNS(svgNS,"text");
newText.setAttributeNS(null,"font-family","Verdana");
newText.setAttributeNS(null,"font-weight","bold");
newText.setAttributeNS(null,"font-size","10");
newText.setAttributeNS(null,"dy","-5");
newText.setAttributeNS(null,"fill","red");
var newTextPath = document.createElementNS(svgNS, "textPath");
newTextPath.setAttributeNS(null,"startOffset","10%");
newTextPath.setAttributeNS(xlinkNS, "xlink:href", "#"+id);
var textNode = document.createTextNode("Quartile 1 (0% to 25%)");
newTextPath.appendChild(textNode);
newText.appendChild(newTextPath);
elem.parentNode.insertBefore(newText, elem.nextSibling);
//interquartile range (middle 50)
var elem2 = chart.yAxis[0].plotLinesAndBands[2].svgElem.element;
id = helpers.makeid();
elem2.setAttribute("id", id);
var newText = document.createElementNS(svgNS,"text");
newText.setAttributeNS(null,"font-family","Verdana");
newText.setAttributeNS(null,"font-weight","bold");
newText.setAttributeNS(null,"font-size","10");
newText.setAttributeNS(null,"dy","-5");
newText.setAttributeNS(null,"fill","#fdd01b");
newText.setAttributeNS(null,"x", 5);
newText.setAttributeNS(null,"y", 5);
var newTextPath = document.createElementNS(svgNS, "textPath");
newTextPath.setAttributeNS(null,"startOffset","10%");
newTextPath.setAttributeNS(xlinkNS, "xlink:href", "#"+id);
var textNode = document.createTextNode("Middle 50 (25% to 75%)");
newTextPath.appendChild(textNode);
newText.appendChild(newTextPath);
elem.parentNode.insertBefore(newText, elem.nextSibling);
//quartile 3
var elem3 = chart.yAxis[0].plotLinesAndBands[3].svgElem.element;
id = helpers.makeid();
elem3.setAttribute("id", id);
var newText = document.createElementNS(svgNS,"text");
newText.setAttributeNS(null,"font-family","Verdana");
newText.setAttributeNS(null,"font-weight","bold");
newText.setAttributeNS(null,"font-size","10");
newText.setAttributeNS(null,"dy","-5");
newText.setAttributeNS(null,"fill","green");
newText.setAttributeNS(null,"x", 5);
newText.setAttributeNS(null,"y", 5);
var newTextPath = document.createElementNS(svgNS, "textPath");
newTextPath.setAttributeNS(null,"startOffset","10%");
newTextPath.setAttributeNS(xlinkNS, "xlink:href", "#"+id);
var textNode = document.createTextNode("Quartile 3 (75% to 100%)");
newTextPath.appendChild(textNode);
newText.appendChild(newTextPath);
elem.parentNode.insertBefore(newText, elem.nextSibling);
});
score:3
Since it's (for instance) not possible, you can place a subtitle
below the chart (in my case, a gauge). For example:
subtitle: {
text: '<span style="background-color: #55BF3B; border-radius: 2px; padding: 1px 2px;">' +
'0-10' +
'</span>' +
'<span style="background-color: #DDDF0D; border-radius: 2px; padding: 1px 2px;">' +
'10-20' +
'</span>',
useHTML: true,
verticalAlign: 'bottom'
}
Source: stackoverflow.com
Related Query
- How to display tooltips or legends on plotBands?
- how to display 2 same highcharts without duplicate the code
- How to display Highcharts legends with their corresponding chart?
- Highcharts: How to display multiple tooltips by click in multiple series with shared true
- How to display raw decimal numbers on tooltips in Highcharts.js
- How to display the value instead of percentage in a pie chart using jquery Highcharts
- How to use the tooltip formatter and still display chart color (like it does by default)?
- How to display highchart series line marker symbol from tooltip formatter?
- How to display No Data Available Message in highcharts
- Highcharts - How to display legend symbol inside the tooltip
- How to display highchart y axis with constistant data
- How can we change legends position in Highcharts?
- How to display Δ in Highcharts category labels?
- How to display highcharts in ng-repeat angularjs
- r- how to display the labels on the highcharter objects all the time
- How to display HighCharts with tables
- How do I use Highcharts to display candlestick with small values?
- How can I disable tooltips during selection?
- How to position labels for plotbands on y axis in Highcharts
- How to display a separating line in Highcharts exporting menu?
- How to display array in array on Highcharts? [JS]
- How show all tooltips split in graph with many series
- how to display the title in the middle of a donut chart with legend?(react-highcharts)
- HighCharts: How to display unique text for yAxis Label in a spline chart
- How to show Legends for all the series data in stacked column chart Highcharts?
- How do i add mouse wheel code in Angular2 highcharts in typescript
- How to display error message in Highcharts?
- How to have different cursor style for legends in Highcharts?
- Highchart how to enlarge the plotBands in a gauge?
- How to get Highcharts XAxis to Display in 2 Minute Intervals
More Query from same tag
- PhantomJS's limit for PNG generation with an Hightchart JSON document(3DOption enable)
- Highcharts : set a maximum number of ticks with a fixed interval
- Automatically zooming in on highcharts after loading
- Toggling 2nd pane data within a Multiple Series Highcharts Chart
- Implement chartit in Django 1.6 with Python 2.7 : TypeError: 'NoneType' has no attribute __getitem__ - Need more information
- Unable to create graphs using highcharts-ng in meanjs. how to create graphs from the existing table in MEANJS
- Highstock highcharts stacked column jQuery.getJSON array not working
- How to implement a gauge solid chart in JSF
- Highcharts solidgauge with green/yellow/red gradient
- How to add HighCharts bundle to BundleConfig? MVC 3
- HIghcharts, Selecting a second Point within the Point.select event
- Javascript: Adding 0 values to arrays of different sizes
- Highcharts: yAxis showing exponential values
- get highcharts data from table angularjs
- Mutually Exclusive Drag/Drop Graph Events
- syncing Highcharts horizontally that range in number of y-axis titles and also no y-axis titles
- highcharts no point markers but show single point or discontinous points
- Highcharts reversed line chart is partially hidden at min value
- unable to make plotOptions.scatter.states.hover.marker in a HighCharts scatterplot
- Algorithm for group scales
- plotOptions.series.point.events returns null point data when using a drilldown
- How to start highchart column chart from left most corner of x-axis?
- Issue With Highcharts x-axis label
- How to get next point in Highcharts tooltip
- How can i change symbol in tooltips on a chart? HIGCHARTS
- Highcharts gauge, set retrieved data after $.getJSON call
- Highcharts y-axis's max value is not what I expect it to be
- Highcharts: Is it possible to have separate plotOptions for each series?
- How do I hide an overflowing Highcharts treemap datalabel?
- Highcharts columns(min,max) colors