【问题标题】:Using a fill pattern instead of colour with HighCharts在 HighCharts 中使用填充图案而不是颜色
【发布时间】:2013-07-01 04:48:34
【问题描述】:

我一直在寻找在 web 应用程序中生成图表的各种方法,并发现 HighCharts 特别有用。该应用程序需要满足色盲的需求,因此我正在考虑使用图案而不是填充颜色 - 如 in this question 所述。

类似的内容需要在 SVG 的 <defs> 部分中:

<pattern id="triangles"  width="10" height="10" patternUnits="userSpaceOnUse">
    <polygon points="5,0 10,10 0,10"/>
</pattern>
<pattern id="diagonal-hatch" patternUnits="userSpaceOnUse" width="4" height="4">
    <path d="M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2"/>
</pattern>
<pattern id="cross-hatch" patternUnits="userSpaceOnUse" x="0" y="0" width="6" height="6">
    <g style="fill:none; stroke:#22fa23; stroke-width:1">
        <path d="M0,0 l10,10"/>
        <path d="M10,0 l-10,10"/>
    </g>
</pattern>

然后我会使用fill="url(#triangles)" 而不是fill="#0d233a"

还有其他人用 HighCharts 做过这个吗?是否有可能让 HighCharts 做到这一点而不将其分解成碎片?

【问题讨论】:

  • 你试过了吗?它看起来像普通的 SVG,它应该可以工作

标签: javascript svg highcharts


【解决方案1】:

好像有pattern fill plugin

【讨论】:

  • 谢谢 - 这就是我所追求的。
  • 我无法让它与 wkhtmltopdf 一起使用 - 有人遇到过这样的问题吗?
【解决方案2】:

您可以为此使用 Highcharts plugin。主题创建here

以系列为例:

{
    type: 'column',
    data: [148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6],
    color: {
        pattern: 'http://highcharts.com/demo/gfx/pattern2.png',
        width: 6,
        height: 6,
        // VML only:
        color1: 'red',
        color2: 'yellow'
    }
}

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2017-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-12
  • 2015-03-02
  • 1970-01-01
  • 2011-09-08
相关资源
最近更新 更多