Highcharts:是否可以绘制没有数据值的旭日形图?

时间:2017-10-16 11:43:25

标签: javascript charts highcharts

我想绘制对称的多级饼图。请参阅组织层次结构示例:Here

我尝试了以下http://jsfiddle.net/amrutaJgtp/7r8eb5ms/7/

series: [{
type: "sunburst",
data: [{
  id: '0.0'
}, {
  id: '1.0',
  parent: '0.0',
  name: 'Consumer',
  color: colors[1]
}, {
  parent: '1.0',
  name: 'Furniture',
  value: 1
}, {
  parent: '1.0',
  name: 'Office Supplies',
  value: 1
}, {
  parent: '1.0',
  name: 'Technology',
  value: 1
}, {
  id: '2.0',
  name: 'Corporate',
  parent: '0.0',
  color: colors[2]
}, {
  parent: '2.0',
  name: 'Furniture',
  value: 1
}, {
  parent: '2.0',
  name: 'Office Supplies',
  value: 1
}, {
  parent: '2.0',
  name: 'Technology',
  value: 1
}, {
  id: '3.0',
  name: 'Home office',
  parent: '0.0',
  color: colors[3]
}, {
  parent: '3.0',
  name: 'Furniture',
  value: 1
}, {
  parent: '3.0',
  name: 'Office Supplies',
  value: 1
}, {
  parent: '3.0',
  name: 'Technology',
  value: 1
}, {
  id: '4.0',
  name: 'Small Business',
  parent: '0.0',
  color: colors[4]
}, {
  parent: '4.0',
  name: 'Office Supplies'
}, {
  parent: '4.0',
  name: 'Technology'
}],

观察“小企业”类别。

如果我没有定义任何数据值,则不会绘制sunburst图表。我希望所有类别的大小都是对称的。

有没有办法使用Highcharts森伯斯特图来实现对称的多层饼?

1 个答案:

答案 0 :(得分:2)

根据需要,有多种选择。这里有四个可能的选项,以及它们相应的小提琴:

<强> Fiddle 1 http://jsfiddle.net/7r8eb5ms/9/

<强> Fiddle 2 http://jsfiddle.net/65ysr826/

<强> Fiddle 3 http://jsfiddle.net/fpysybhe/

<强> Fiddle 4 http://jsfiddle.net/nab8xu33/

其中3个每个点都有一个附加参数:

tooltipIncluded: false

使用此格式化程序控制工具提示:

tooltip: {
  formatter: function() {
    if (this.point.tooltipIncluded) {
      return 'The population of <b>' + this.point.name + '</b> is <b>' + this.point.value + '</b>';
    } else {
      return false;
    }
  }
}