剑道图中流的颜色不变

时间:2019-02-11 13:14:38

标签: line kendo-ui-angular2 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";

1 个答案:

答案 0 :(得分:0)

找到了我自己 将视图子项添加到图表元素。(已出现在html中)

@ViewChild('primeChart') primeChart: any;

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

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

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