kendo-chart 中流的颜色没有改变

Color of stream does not change in kendo-chart

我在我的项目中使用 kendo-charts 作为图表,我知道每个流都有默认颜色。问题是当我为这些流设置颜色时它仍然显示默认颜色

html

<kendo-chart [categoryAxis]="{ categories: categories }" #primeChart [transitions]="transitions">

                    <kendo-chart-series>
                        <kendo-chart-series-item *ngFor="let item of series1" type="line" [data]="item.data" [name]="item.name">
                        </kendo-chart-series-item>
                    </kendo-chart-series>
                </kendo-chart>

ts 文件

 this.series1=  [{
            name: "Stream 1",
            streamId: 1,
            data: [3.907, 7.943, 7.848, 9.284, 9.263, 9.801, 3.890, 8.238, 9.552, 6.855, 1.111,2.222],
            color:"green"
        }
        , {
            name: "Stream 2",
            streamId: 2,
            data: [4.743, 7.295, 7.175, 6.376, 8.153, 8.535, 5.247, -7.832, 4.3, 4.3, 1.111,3.333],
            color:"green"
        }]

scss

@import url("~@progress/kendo-theme-default/dist/all.css");
@import "theme";
@import "material-overrides";
@import "kendo-overrides";

我自己找到的 向图表元素添加一个视图子项。(已出现在 html 中)

@ViewChild('primeChart') primeChart: any;

在数据设置方法中使用 this.primeChart

捕获 primeChart 元素
this.primeChart.theme.seriesColors=["green","red","green","red"]

这成功覆盖了默认系列颜色