简体   繁体   中英

Array of legends for charts in highcharts-export-server

I am working on highcharts-export-server which currently does not support formatter functions as it expects the chart configuration in plain JSON format and not JavaScript object.

I need customized values for chart's legends and I couldn't find any config to supply legends as array of formatted strings.

Is it be possible to supply those legends as array of formatted strings which can be passed as plain JSON? If it can also support color of series, that would be awesome.

Thank you in advance.

I could not ask this question or raise a new issue in the node-export-server repo because it only accepts issue for a bug . And I think this could be a feature request(In that case, I will raise it to Highcharts later).

Edit: Solution for passing simple formatters(without library or called functions) -

A stringified JS Object under instr key works for simple formatter functions with allowCodeExecution flag in config, shown below. Also in sample .

{
  instr: stringifyObject(chartConfig), // https://gist.github.com/cowboy/3749767
  allowCodeExecution: true, // to support formatter functions in chart config
  ... other configs
}

You could try to add formatting in legend.labelFormat as HTML, export server accepts such a solution you can test the following config at new version of export server .

{
    "xAxis": {
        "categories": [
            "Jan",
            "Feb",
            "Mar",
            "Apr",
            "May",
            "Jun",
            "Jul",
            "Aug",
            "Sep",
            "Oct",
            "Nov",
            "Dec"
        ]
    },
    "series": [
        {
            "data": [1,3,2,4],
            "type": "line"
        },
        {
            "data": [5,3,4,2],
            "type":"line"
        }
    ],
    "legend": {
      "margin": 140,
      "useHTML": true,
      "labelFormat": "<b>test</b>"
    }
}

To feature request to add this option you can report it in the GitHub issue and it will be assigned with label enhancement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM