简体   繁体   English

是否可以在高位图表中添加气泡大小的图例?

[英]is it possible to add a legend for bubble size in high charts?

I'm using the latest version of high charts. 我正在使用最新版本的高位图表。 I successfully created a 3d bubble chart following http://www.highcharts.com/demo/bubble-3d 我成功地按照http://www.highcharts.com/demo/bubble-3d创建了3d气泡图

I am wondering if I can add to the legend a reference to what the size of the bubble means. 我想知道是否可以在图例中添加气泡大小的含义。 Just a simple bubble with some text next to it would be enough. 只需在其旁边带有文本的简单气泡就足够了。

Thanks in advance for your help. 在此先感谢您的帮助。

Just add an empty series and name it.Give it desired name ,See Updated fiddle here 只需添加一个空系列并将其命名即可。为它提供所需的名称,请参见此处的更新小提琴

   {
   name :"description",     
   marker: {
            fillColor: {
                radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                stops: [
                    [0, 'rgba(255,255,255,0.5)'],
                    [1, Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.5).get('rgba')]
                ]
            }
        }}

Representing bubble size in a legend is not currently a feature of Highcharts. 在图例中表示气泡大小目前不是Highcharts的功能。

You can draw one manually: 您可以手动绘制一个:

  1. Add a series for the legend 为图例添加系列
  2. Draw a rendered box around the legend 在图例周围绘制一个渲染框

JSFiddle 的jsfiddle

Add a series for the legend 为图例添加系列

series: [{
      // This series gives a legend for reference
      data: [{
        color: Highcharts.getOptions().colors[0],
        x: 86,
        y: 25,
        z: 10,
        dataLabels: {
          format: '10%',
          y: 40
        }
      }, {
        x: 90,
        y: 25,
        z: 15,
        dataLabels: {
          format: '15%',
          y: 40
        }
      }, {
        x: 94,
        y: 25,
        z: 35,
        dataLabels: {
          format: '35%',
          y: 40
        }
      }]
    }, {
      color: Highcharts.getOptions().colors[0],
      data: [{
        x: 95,
        y: 95,
        z: 13.8,
        name: 'BE',
        country: 'Belgium'
      }, {

Draw a rendered box around the legend 在图例周围绘制一个渲染框

events: {
  load: function() {

    // Draw the flow chart
    var ren = this.renderer,
      colors = Highcharts.getOptions().colors;

    // Script label
    ren.label('Obesity Rate', 410, 220)
      .attr({
        stroke: '#777',
        'stroke-width': 1,
        padding: 5,
        r: 5,
        width: 168,
        height: 73
      })
      .css({
        color: '#333',
        textAlign: 'center',
        fontSize: '1.1em'
      })
      .add();
  }
}

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

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