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.
Unfortunately, activation email could not send to your email. Please try again.

Customize Series Color with DataSource

Thread ID:

Created:

Updated:

Platform:

Replies:

119450 Jun 23,2015 05:41 AM Jun 25,2015 06:40 AM ASP.NET MVC 3
loading
Tags: Chart
Andrea Perazzolo
Asked On June 23, 2015 05:41 AM

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

Praveen [Syncfusion]
Replied On June 23, 2015 07:18 AM

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


Andrea Perazzolo
Replied On June 24, 2015 04:09 AM

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


Praveen [Syncfusion]
Replied On June 25, 2015 06:40 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;