Menu

How do you get the color of a series?

Michael
2012-01-06
2012-07-13
  • Shawn Quinn

    Shawn Quinn - 2012-01-16

    Interesting. I just looked around a bit and I can't seem to find any way currently to dynamically ask the core Highcharts library for the color of a series in a custom tooltip formatter. (If anyone is aware of a way to do this though, please feel free to correct me!)

    So, what you may want to do is set the color of the series on your own so that you know which color each series in when you go to create the custom tool tip. E.g.

    chart.addSeries(chart.createSeries()
        .setName("My Series")
        .setPlotOptions(new SeriesPlotOptions()
            .setColor(new Color(223, 83, 83, .5))
        );
    

    Note that the default series colors which come with Highcharts are: "#4572A7", "#AA4643", "#89A54E", "#80699B", "#3D96AE", "#DB843D", "#92A8CD", "#A47D7C", and "#B5CA92"

    Hope that helps...

     
  • Shawn Quinn

    Shawn Quinn - 2012-01-20

    Internally Highcharts parses the HTML you return from the tooltip formatter and attempts to convert it to SVG. So, only a subset of HTML is supported. There is a bit of discussion about this in the JavaDoc for the ToolTipFormatter class, but the portion that is most relevant to this question is the following:

    "A subset of HTML is supported. The HTML of the tooltip is 
    parsed and converted to SVG, therefore this isn't a complete 
    HTML renderer. The following tags are supported: <b>, <strong>, 
    <i>, <em>, <br/>, and <span>. Spans can be styled with a 
    style attribute, but only text-related CSS that is shared 
    with SVG is handled."
    

    You can find some more detail about this in the core Highcharts documentation reference as well.

    Hope that helps,

    -Shawn

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.