score:3
To get a solid color, set the minColor
and maxColor
options to the same value. To set the color based on a value, just compare in the options:
var guageValue = 60;
var gaugeOptions = {
...
yAxis: {
minColor: guageValue >= 80 ? '#FF0000' : (guageValue >= 60 ? '#FFFF00' : '#00FF00'),
maxColor: guageValue >= 80 ? '#FF0000' : (guageValue >= 60 ? '#FFFF00' : '#00FF00'),
lineWidth: 0,
....
EDITS FOR COMMENT
Well, doing it dynamically according to the API should be as easy as:
var chart = Highcharts.charts[0];
var point = chart.series[0].points[0];
var color = newGuageValue >= 80 ? '#FF0000' : (newGuageValue >= 60 ? '#FFFF00' : '#00FF00');
chart.yAxis[0].update({minColor:color, maxColor:color});
point.update(newGuageValue);
But, this breaks the chart (and I believe it to be a bug in the library).
So the best I can come up with is to go after the internals directly:
var chart = Highcharts.charts[0];
var point = chart.series[0].points[0];
var color = newGuageValue >= 80 ? [255,0,0,1] : (newGuageValue >= 60 ? [255,255,0,1] : [0,255,0,1]);
chart.yAxis[0].stops[0].color.rgba = color;
chart.yAxis[0].stops[1].color.rgba = color;
point.update(newGuageValue);
Here's a fiddle demo.
score:0
// change your stops ,0 and 1 set the same value
var showNumber = 100; // your random data
var tickMaxNumber = 1000; // The yAxis max value
if(showNumber <= tickMaxNumber*0.2){
gaugeOptions.yAxis[0].stops = [ // red
[0, '#EE4B4B'],
[1, '#EE4B4B']
];
}else if(showNumber <= tickMaxNumber*0.8){
gaugeOptions.yAxis[0].stops = [ // yellow
[0, '#FFC063'],
[1, '#FFC063']
];
}else{
gaugeOptions.yAxis[0].stops = [ // green
[0, '#40A276'],
[1, '#40A276']
];
}
$('#container-speed').highcharts(gaugeOptions);
score:9
You can set stops, like this: http://jsfiddle.net/4zVU8/5/
stops: [
[0.0, '#55BF3B'], // green
[0.2, '#55BF3B'], // green
[0.21, '#DDDF0D'], // yellow
[0.80, '#DDDF0D'], // yellow
[0.81, '#DF5353'], // red
[1, '#DF5353'] // red
]
So aright after color ends set new color.
Source: stackoverflow.com
Related Query
- Highcharts solidgauge : How can I disable gradient fill?
- How can I disable the value tooltip on a Vaadin-Charts/Highcharts SolidGauge chart?
- How can I disable on hover marker animation in Highcharts 6.x?
- How can I get highcharts barChart bars to always fill the container?
- How can I render a highcharts solidgauge with Django?
- how can I use rangeselector and navigation in highcharts in the given code
- Highcharts gradient fill how to?
- How can I get access to a Highcharts chart through a DOM-Container?
- HighCharts - How can I turn off the points?
- How can I change the colors of my highcharts piechart?
- How can I hide series from a HighCharts legend?
- How can I hide a series from initially being displayed in Highcharts
- How can I force multiple y-axis in Highcharts to have a common zero
- How can I fix Highcharts error #13?
- Highcharts datetime axis, how to disable time part (show only dates)?
- How can i hide all the Series in highcharts at a time
- How can I remove the white border from HighCharts pie chart?
- Highcharts - how to disable color change on mouseover/hover
- Highcharts - How can I remove starting and ending padding from area chart
- How can I delete all of the points from a highcharts series
- How to enable or disable a Highcharts tooltip when a button is clicked?
- How can I force highcharts to show every x-axis label regardless of spacing constraints?
- How to output JSON in python so it can be used for Geckoboard's Highcharts plugin
- How can i change highcharts data values by selecting from a dropdown list
- How can i keep the color the same in highcharts
- How to completely disable the mouse/finger interaction for highcharts
- How can i force Highcharts to use same symbols in Legend and Series?
- Highcharts - How can I decrease space between categories?
- How can I disable tooltips during selection?
- How can I force ticks/grid lines on a Highcharts datetime X axis to arbitrarily line up with data points?
More Query from same tag
- How to add image/icon below y-axis in column highcharts
- How to customize view data table functionality in Highcharts
- Highcharts columnchart: How to separate overlapping columns
- Decrease distance between point in highchart
- How can I format the Highcharts gantt chart to be a dashed line instead of a solid line?
- Highcharts stacked column chart is missing some values?
- minimum in Highcharts not working
- Why does my Highchart look different when I transfer my code from Jsfiddle to my server?
- How to modiffy Highchart size with slide effect
- Highcharts venn diagram is missing intersections
- r - How to set xlim and ylim range in a highcharter plot?
- how to give click event in directive using angular js?
- Set tooltip in date format Highchart
- Highcharts: show data labels as relative value (percentage) on hover
- Highcharts - How can I put a 100% fix value in the X axis?
- Create Highchart from the Following Data
- Can we stack a 2 columns in a single column in basic column Highchart and let the other columns let it be?
- Unable to show Highcharts graph with in ASP.Net MVC
- Highcharts XRange Data and Label misalignment
- Highstock Shared Tooltip This Index
- Set Colors of Different Points when Clicking on Pie Slice Legend
- Highcharts errors when webpage in chrome background tab
- Converting image response, after post request, to file
- HighCharts wrong xAxis label
- Highcharts - Toggle between different data with dropdown box
- r - automatically add y axis in highchart
- Custom colors in R highcharter barplot
- Error from Jenkins when a tooltip is on a dot highchart
- How add series dynamically in Highcharts without button? (ANGULAR JS)
- R Highcharter: dynamic drilldown in Shiny on the fly