最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Apex Charts donut chart - padding between series items in plot - Stack Overflow

programmeradmin3浏览0评论

I am attempting to create a donut chart in apex charts similar to the one shown below (right), I have gotten pretty close, however I need to have some stroke or padding around the series items along the plot of the donut chart as shown.

current configuration

 const options = {
    chart: {
      type: 'donut',
      height: 150,
      width: '100%',
      offsetX: 50
    },
    plotOptions: {
      pie: {
        startAngle: 10,
        donut: {
          size: '90%',
          dataLabels: {
            enabled: false
          },
          labels: {
            show: true,
            name: {
              show: true,
              offsetY: 38,
              formatter: () => 'Completed'
            },
            value: {
              show: true,
              fontSize: '48px',
              fontFamily: 'Open Sans',
              fontWeight: 500,
              color: '#ffffff',
              offsetY: -10
            },
            total: {
              show: true,
              showAlways: true,
              color: '#BCC1C8',
              fontFamily: 'Open Sans',
              fontWeight: 600,
              formatter: (w) => {
                const total = w.globals.seriesTotals.reduce(
                  (a, b) => a + b,
                  0
                );
                return `${total}%`;
              }
            }
          }
        }
      },
    },
    dataLabels: {
      enabled: false
    },
    labels: ['Completed', 'Cancelled', 'Pending', 'Failed'],
    legend: {
      show: false,
      position: 'right',
      offsetX: -30,
      offsetY: 70,
      formatter: (value, opts) => {
        return value + ' - ' + opts.w.globals.series[opts.seriesIndex];
      },
      markers: {
        onClick: undefined,
        offsetX: 0,
        offsetY: 25
      }
    },
    fill: {
      type: 'solid',
      colors: ['#8BD742', '#BCC1C8', '#78AEFF', '#F74D52']
    },
    stroke: {
      width: 0
    },
    colors: ['#8BD742', '#BCC1C8', '#78AEFF', '#F74D52']
  };

I am attempting to create a donut chart in apex charts similar to the one shown below (right), I have gotten pretty close, however I need to have some stroke or padding around the series items along the plot of the donut chart as shown.

current configuration

 const options = {
    chart: {
      type: 'donut',
      height: 150,
      width: '100%',
      offsetX: 50
    },
    plotOptions: {
      pie: {
        startAngle: 10,
        donut: {
          size: '90%',
          dataLabels: {
            enabled: false
          },
          labels: {
            show: true,
            name: {
              show: true,
              offsetY: 38,
              formatter: () => 'Completed'
            },
            value: {
              show: true,
              fontSize: '48px',
              fontFamily: 'Open Sans',
              fontWeight: 500,
              color: '#ffffff',
              offsetY: -10
            },
            total: {
              show: true,
              showAlways: true,
              color: '#BCC1C8',
              fontFamily: 'Open Sans',
              fontWeight: 600,
              formatter: (w) => {
                const total = w.globals.seriesTotals.reduce(
                  (a, b) => a + b,
                  0
                );
                return `${total}%`;
              }
            }
          }
        }
      },
    },
    dataLabels: {
      enabled: false
    },
    labels: ['Completed', 'Cancelled', 'Pending', 'Failed'],
    legend: {
      show: false,
      position: 'right',
      offsetX: -30,
      offsetY: 70,
      formatter: (value, opts) => {
        return value + ' - ' + opts.w.globals.series[opts.seriesIndex];
      },
      markers: {
        onClick: undefined,
        offsetX: 0,
        offsetY: 25
      }
    },
    fill: {
      type: 'solid',
      colors: ['#8BD742', '#BCC1C8', '#78AEFF', '#F74D52']
    },
    stroke: {
      width: 0
    },
    colors: ['#8BD742', '#BCC1C8', '#78AEFF', '#F74D52']
  };

Share Improve this question asked Feb 1, 2021 at 23:35 Jeff VossJeff Voss 3,70510 gold badges49 silver badges72 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Try setting the stroke width to greater than 0 and give the stroke same color as the background.

stroke: {
  width: 4,
  colors: ['#1E252A']
}
发布评论

评论列表(0)

  1. 暂无评论