change the color of particular series in line chart

Hi, I have used your library and i am very impressed but i  am facing an issue here,
Actually i created a chart dynamically with this.chart.addSeries(). I have two series in graph and i want the second series to be green can you help me with this how to add particular color in particaular serie dynamically thanks.
Regards

1 Reply

BP Baby Palanidurai Syncfusion Team March 16, 2018 10:08 AM UTC

Hi Muhammad Umer, 

Thanks for using Syncfusion products. 

We have analyzed your query. To set series fill color, we can use fill property in series. We have achieved your requirement by getting color picker colors and used that to series fill color, while adding series dynamically. As for your requirement, we have prepared sample to change the series colors dynamically. Please find the code snippet below to achieve this requirement. 

HTML: 

`<ejs-chart #chart id='chartcontainer'> 
          // 
    </ejs-chart> 
    Series: <button ejs-button class='e-flat' (click)='add()'>Add</button><br><br> 
    Series Color: <input type="color" value="#009933" id='colorpicker'>


export class AppComponent implements OnInit { 
     add() { 
                let element: HTMLInputElement = <HTMLInputElement>(document.getElementById('colorpicker')); 
                this.chart.addSeries([{ 
                type: 'Column', 
                dataSource: ChartDataService.prototype.GetData().series1, 
                xName: 'x', width: 2, fill: element.value, 
                yName: 'y' 
            }]); 
        } 

Screenshot: 

Before adding series 
 
After adding series 
 

Sample for your reference can be find from below link, 

Kindly revert us, if you have any concerns. 

Thanks, 
Baby.


Loader.
Up arrow icon