简体   繁体   English

highcharts-export-server 中图表的图例数组

[英]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.我在highcharts-export-server上工作,它目前不支持格式化程序功能,因为它期望图表配置为普通 JSON 格式,而不是 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?是否可以将这些图例作为格式化字符串数组提供,这些字符串可以作为普通 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 .我无法在node-export-server回购中提出这个问题或提出新问题,因为它只接受 issue for a bug And I think this could be a feature request(In that case, I will raise it to Highcharts later).而且我认为这可能是一个功能请求(在这种情况下,我稍后会把它提高到 Highcharts)。

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. instr键下的字符串化 JS Object适用于配置中带有allowCodeExecution标志的简单格式化程序函数,如下所示。 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 .您可以尝试在legend.labelFormat中添加格式为 HTML,导出服务器接受这样的解决方案,您可以在新版本的导出服务器上测试以下配置。

{
    "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.要添加此选项的功能请求,您可以在 GitHub 问题中报告它,它将分配给 label 增强。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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