如何将自定义png或svg模式填充到饼图高级图表

时间:2017-08-18 12:13:16

标签: javascript jquery charts highcharts highstock

我正在尝试使用highcharts构建饼图,并尝试将自定义模式添加到饼图中。我现在可以使用下面的代码为所有其他图表做到这一点: -

    var gfxPath = 'https://sampleproject-shivkumarganesh.c9users.io/img/';

Highcharts.chart('container', {
  chart: {
    type: 'bar'
  },
  title: {
    text: 'Stacked bar chart'
  },
  xAxis: {
    categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
  },
  yAxis: {
    min: 0,
    title: {
      text: 'Total fruit consumption'
    }
  },
  legend: {
    reversed: true
  },
  plotOptions: {
    series: {
    stacking: 'normal'
    }
  },
  series: [{
    name: 'John',
    data: [5, 3, 4, 7, 2],
    color: {
      pattern: gfxPath + 'Dots_Large.png',
      width: 10,
      height: 10
    }
  }, {
    name: 'Jane',
    data: [2, 2, 3, 2, 1],
    color: {
      pattern: gfxPath + 'Grid.png',
      width: 10,
      height: 10
    }
  }, {
    name: 'Joe',
    data: [3, 4, 4, 2, 5],
    color: {
      pattern: gfxPath + 'Bricks.png',
      width: 15,
      height: 15
    }
  }]
});

问题在于,当我为饼图执行相同操作时,它根本不起作用。此示例中提供的自定义生成SVG正在运行。我应该如何使用自定义PNG模式或SVG模式填充它?

http://jsfiddle.net/highcharts/gqg618eb/

但是当我尝试用一​​些PNG填充它或者像SVG那样的东西时,它会破坏。

注意:我使用的是最新的Highcharts和pattern-fill插件。

0 个答案:

没有答案