We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Set colors in line chart mvc

Hi Team,

How to set colors for the lines in line chart with multiple series? Also, please provide the code to set y axis label position on top.


Thanks in advance

1 Reply

DD Dharanidharan Dharmasivam Syncfusion Team December 17, 2018 11:59 AM UTC

Hi Jsu, 
 
Greetings from Syncfusion. 
 
Query #1: How to set colors for the lines in line chart with multiple series? 
We have analyzed your requirement. Your requirement can be achieved using the fill property of the series. You can also use the Palettes property of chart. Here you can assign array of colors and then bind to chart. Find the code snippet below to achieve this. 
 
[ChartController.cs] 
 
string[] color = new string[] { "#4286f4", "#f4b642", "#f441a9" }; 
ViewBag.seriesColors = color; 
 
[ChartFEatures.cshtml] 
@Html.EJS().Chart("container").Palettes(ViewBag.seriesColors).Render() 
 
 
 
Query #2: Also, please provide the code to set y axis label position on top. 
 
Here we have set the data labels position to the top using the Position property of series.marker.dataLabel. Also, we have moved the y axis labels to inside the axis. If your query is misunderstood at our kindly revert us with more information on your query. The sample can be found below. 
 
 
 
Thanks, 
Dharani. 
 
 
 
 
 


Loader.
Live Chat Icon For mobile
Up arrow icon