0
import Plotly from "plotly.js";
import createPlotlyComponent from "react-plotly.js/factory";

export const Plot = createPlotlyComponent(Plotly);

export function PieChart() {
  return <Plot data={data} layout={layout} config={{ displaylogo: false }} useResizeHandler={true} style={{ width: '100%' }} />;
}

我想更改 Piechart 切片的颜色,我参考了 plotly 的文档并添加了

marker: {
    color: 'rgba(255,153,51,0.6)',
    width: 1
}

也是,但它不工作

4

1 回答 1

1

这是数组,

maker.color-->maker.colors

您可以按以下方式执行此操作

marker: {
   colors: ['rgb(56, 75, 126)', 'rgb(18, 36, 37)', 'rgb(34, 53, 101)'],
   width: 1
}

这是DEMO

于 2022-02-16T06:26:09.507 回答