Search code examples
linekendo-ui-angular2kendo-chart

Color of stream does not change in kendo-chart


I am using kendo-charts for the graphs in my project and, I understood it has default colors each streams .Issue is when i set a color to those streams still it shows the default color

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 file

 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";

Solution

  • Found it my self add a view child to the chart element.( as already appears in html)

    @ViewChild('primeChart') primeChart: any;
    

    in the data setting method catch the primeChart element using this.primeChart

    this.primeChart.theme.seriesColors=["green","red","green","red"]
    

    this overrides the default series colors successfully