简体   繁体   English

Apex Charts 的饼图中不能有超过 7 个数字

[英]Can not have more then 7 numbers in Pie Chart from Apex Charts

I have come across this strange problem and would like to know if there is a solution to it.我遇到了这个奇怪的问题,想知道是否有解决方案。 I am using ApexChart Pie Chart to show a breakdown but whenever I go above the 7 number it gives this error.我正在使用 ApexChart 饼图来显示细分,但每当我超过 7 数字时,它就会出现此错误。 The error does not appear if the series array (see code below) is 7 or less.如果系列数组(参见下面的代码)为 7 或更少,则不会出现错误。

Uncaught (in promise) TypeError: t.push is not a function

Here is my code这是我的代码

    const [series, setSeries] = useState([8, 17, 3, 3, 3, 3, 10, 34])

    const options = {
        chart: {
            width: 500,
            type: 'pie',
            foreColor: '#373d3f'
        },
        labels: ['Alpha', 'Charlie', 'Delta', 'Mike', 'NS', 'Deltaa', 'Mikee', 'er'],
        stroke: {
            show: true,
            curve: 'smooth',
            lineCap: 'butt',
            colors: "#03111E",
            width: 2,
            dashArray: 0,
        },
        responsive: [{
            breakpoint: 540,
            options: {
                chart: {
                    width: 350
                },
                legend: {
                    position: 'bottom'
                }
            }
        }]
    }

<Chart options={options} series={series} type="pie" height={360 + Math.random() * 10}
                   width={550}
                   style={{margin: "auto"}}/>

Versions版本

"apexcharts": "^3.35.3",
"react-apexcharts": "^1.4.0",

I have seen some other question related to this but sadly they do not answer the question.我看到了一些与此相关的其他问题,但遗憾的是他们没有回答这个问题。 I would like to know if there is a solution to this or is this just a limitation of ApexChart.我想知道是否有解决方案,或者这只是 ApexChart 的限制。 Thank you.谢谢你。

Work fine when you pass stroke colors as array, not string当您将笔画颜色作为数组而不是字符串传递时,工作正常

  stroke: {
    ...
    colors: ["#03111E"],
    ...
  }

https://apexcharts.com/docs/options/stroke/#colors https://apexcharts.com/docs/options/stroke/#colors

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

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