Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the color of the point dynamically in highcharts

I have been able to change the color of point in a graph dynamically, but when I hover over that point then the color of that point is changing to previous color.

I have a fiddle here: jfiddle

$(function () {
var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]        
    }]
});

// the button handler
$('#button').click(function() {

    chart.series[0].data[2].graphic.attr({ fill: '#FF0000' });        
    chart.redraw();
});

How can I change the color of the point dynamically in a graph?

like image 923
Sandeep Avatar asked Apr 29 '13 19:04

Sandeep


People also ask

Is it possible to pass multiple series in a chart in Highcharts?

Yes, you can. You could add more. If you get stack with implementing your project, please send us a minimal, verifiable demo in JSFiddle, so we could help you out with your code.

What is the default chart type in Highchart?

style: Highcharts. Defaults to {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"} .

How do I change colors in Highcharts?

To change the background color of the chart you have to set in the chart. backgroundColor property. Bar colors in the series color property. Check the example with your chart I posted below.


2 Answers

I think you are looking to update the marker color dynamically.

you can use update functionality for this

chart.series[0].data[0].update();

Here is a jsFiddle for your reference. I hope this will be useful for you.

like image 84
Strikers Avatar answered Nov 14 '22 23:11

Strikers


is this what you are looking for?

http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-marker-states-select-fillcolor/

plotOptions: {
    series: {
        allowPointSelect: true,
        marker: {
            states: {
                select: {
                    fillColor: 'red',
                    lineWidth: 0
                }
            }
        }
    }
}
like image 31
Prakash Chennupati Avatar answered Nov 14 '22 22:11

Prakash Chennupati