首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多量程图

问多量程图
EN

Stack Overflow用户
提问于 2021-12-21 06:17:57
回答 1查看 225关注 0票数 1

是否可以使用高图表在圆的左右绘制这类量规?基本上,左边是代表短裤的百分比年龄在左边,右边是代表短裤的百分比年龄在右边,中间是一个简单的圆圈,中点投篮的年龄是%。

​

​

EN

回答 1

Stack Overflow用户

发布于 2021-12-21 10:28:39

系列变量饼,它看起来更适合这种情况。工具提示我们构建了设置useHTML:true,在SVG呈现器呈现的中心圈。

代码语言:javascript
复制
Highcharts.chart('container', {
  chart: {
    events: {
      render() {
        const chart = this;
        if (!chart.customCenterCircle) {
          chart.customCenterCircle = chart.renderer.circle(
            chart.plotLeft + chart.plotSizeX / 2,
            chart.plotTop + chart.plotSizeY / 2,
            0
          ).add().toFront();
        }
        if (!chart.customCenterText) {
          chart.customCenterText = chart.renderer.text('50%', 0, 0).css({
            fontSize: '24px',
            color: '#d4d4d4'
          }).add().toFront();
        }
        chart.customCenterCircle.animate({
          x: chart.plotLeft + chart.plotSizeX / 2,
          y: chart.plotTop + chart.plotSizeY / 2,
          r: chart.series[0].center[3] / 2,
          fill: 'rgba(31, 112, 31, 0.5)',
          stroke: 'rgba(154, 214, 154, 1)',
          'stroke-width': 4
        });
        chart.customCenterText.attr({
          x: chart.plotLeft + chart.plotSizeX / 2 -
            chart.customCenterText.getBBox().width / 2,
          y: chart.plotTop + chart.plotSizeY / 2 -
            chart.customCenterText.getBBox().y -
            chart.customCenterText.getBBox().height / 2
        });
      }
    }
  },
  tooltip: {
    backgroundColor: '#ffffff',
    borderWidth: 0,
    useHTML: true,
    formatter: function() {
      return `<p><h1 style="color:${this.color};">${this.y}</h1></br>${this.key}</p>`
    }
  },
  series: [{
    type: 'variablepie',
    minPointSize: 0,
    innerSize: '30%',
    startAngle: 30,
    dataLabels: {
      enabled: false
    },
    borderWidth: 3,
    zMin: 0,
    data: [{
      y: 80,
      z: 100,
            name: 'other',
      color: 'black'
    }, {
      y: 30,
      z: 100,
            name: 'missed right',
      color: 'red'
    }, {
      y: 50,
      z: 0
    }, {
      y: 25,
      z: 80,
            name: 'missed right',
      color: 'red'
    }, {
      y: 75,
      z: 80,
            name: 'other',
      color: 'black'
    }, {
      y: 60,
      z: 0,
            name: 'other',
    }]
  }]
});

现场演示: https://jsfiddle.net/BlackLabel/sc9vwzjt/2/

API引用:

https://www.highcharts.com/docs/chart-and-series-types/variable-radius-pie-chart

https://api.highcharts.com/highcharts/series.variablepie

https://api.highcharts.com/class-reference/Highcharts.SVGRenderer

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70431345

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档