Menu

sup-index and sub-index in HighChart Titles

2012-08-08
2012-09-19
  • Andrey Denikin

    Andrey Denikin - 2012-08-08

    Sorry if this topic has already been discussed here.
    I am trying to find the way to make a chart title with sup- and sub-indexies inside.
    It should be something like "12C scattering angle" in HTML format.

    Is any solution? Please, give an example...

    thanks in advance.

     
  • Philippe Lhoste

    Philippe Lhoste - 2012-09-12

    The setChartTitleText() method's JavaDoc says:

    The actual text of the chart title. It can contain basic HTML text markup like &tl;b>, &tl;i> and spans with style. Defaults to "Chart title".

    I believe Highcharts parses this text and transforms these "basic HTML text markup" to specific SVG (or equivalent) code.
    Indeed, if I call:

    .setChartTitleText("Daily visits at <b>w</b>w<i>w</i>.highcharts.com")
    

    I see the following SVG:

    <text x="500" y="25" style="font-family:[...];font-size:16px;color:#3E576F;fill:#3E576F;" text-anchor="middle" class="highcharts-title" zIndex="4">
      <tspan x="500">Daily visits at </tspan>
      <tspan style="font-weight:bold" dx="3">w</tspan>
      <tspan dx="3">w</tspan>
      <tspan style="font-style:italic" dx="3">w</tspan>
      <tspan dx="3">.highcharts.com</tspan>
    </text>
    

    So this basic HTML is interpreted and translated to SVG, VML or Canvas instructions, and it seems that more sophisticated / rare tags like sub or sup are not handled.

    Note that if all you have to display are superscript and subscript digits, you can use the corresponding Unicode characters: \u2070 is SUPERSCRIPT ZERO, \u2080 is SUBSCRIPT ZERO, and so on.

     
  • Andrey Denikin

    Andrey Denikin - 2012-09-19

    thanks a lot...

     

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.