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
close icon

Customize Series Color with DataSource

Hi,
I have seen that if I define the Serie data as Points in a column Chart, I can set each column with different fill color.
There is the way to do it using the DataSource?

   Thanks in advance

    Andrea Perazzolo

3 Replies

PR Praveen Syncfusion Team June 23, 2015 11:18 AM UTC

Hi Andrea,


Thanks for using Syncfusion product.


We have analyzed your reported query and there is no way to achieve this directly. We have achieved this query in workaround by using SeriesRendering event in sample. The code snippet is given below,


Code Snippet:

[MVC]


@(Html.EJ().Chart("container")

………………………

.Load("onchartload")

.SeriesRendering("getcolor")


………………………..


)


function onchartload(sender)

{

sender.model.series[0].dataSource = chartData;

sender.model.series[0].xName = "xDate";

sender.model.series[0].yName = "yValue";

}

function getcolor(sender)

{

var color=["blue","green","yellow","orange","red","pink"];

for (var i = 0; i < sender.model.series.length; i++)

{

for (var j = 0; j < sender.model.series[i].points.length; j++)

{

sender.model.series[i].points[j].fill=color[j];

}

}

}


We have prepared a sample based on the screen shot and you can find the sample in below location:


Screen Shot:





Sample: http://www.syncfusion.com/downloads/support/forum/119450/Pointfill1156257906.zip


Please let us know if you need any clarification.

Thanks,

Praveenkumar



AP Andrea Perazzolo June 24, 2015 08:09 AM UTC

Hi,
At the moment I tried this solution that seems to kork:

sr =>
{
    sr
        .Points(p =>
        {
            for (int i = 0; i < Model.Records.Count; i++)
            {
                p.X(Model.Records[i].Name).Y(Model.Records[i].Value).Fill(Model.Records[i].Color).Add();
            }
        })
        //sr.DataSource(Model.Records).XName("Name").YName("Value").Name("Value").Add();
    .Add();
 
})

I think it wold be useful a method in the SeriesBuilder to retrieve the Fill data (maybe using the default value if null



PR Praveen Syncfusion Team June 25, 2015 10:40 AM UTC

Hi Andrea,
We have analyzed this. Currently there is no support to retrieve the series point fill data from binding datasource. So we have logged a feature request for this “Retrieve the series point fill data from binding datasource”. A support incident to track the status of this feature has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let you know if you need any clarification.

Thanks,
Praveenkumar

Loader.
Live Chat Icon For mobile
Up arrow icon