Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 12, 2012 12:32 PM by Mikesdotnetting
0 Points
1 Post
Jul 12, 2012 10:05 AM|LINK
Using the Chart Helper in webmatrix it's straight forward to create a bar chart like this:
@{ var myChart = new Chart(width: 600, height: 400) .AddTitle("Employees") .AddSeries(chartType: "column", xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" }, yValues: new[] { "2", "6", "4", "5", "3" }) .Write(); }
Which creates this:
I'd like to be able to set a custom color to each of the yvalues as seen in the image below. How would I modify the code above to accomplish this? Thanks in advance.
All-Star
15346 Points
3142 Posts
Jul 12, 2012 10:40 AM|LINK
please check
http://stackoverflow.com/questions/10450663/change-color-of-bars-depending-on-value-in-highchart-bar-chart-with-mvc3
154927 Points
19867 Posts
Moderator
MVP
Jul 12, 2012 12:32 PM|LINK
You can create your own templates for the chart helper: http://blogs.msdn.com/b/erikreitan/archive/2010/10/28/webmatrix-creating-3d-charts.aspx
Stewart75
0 Points
1 Post
How to set different colors on yvalues in Chart Helper
Jul 12, 2012 10:05 AM|LINK
Using the Chart Helper in webmatrix it's straight forward to create a bar chart like this:
@{
var myChart = new Chart(width: 600, height: 400)
.AddTitle("Employees")
.AddSeries(chartType: "column",
xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" },
yValues: new[] { "2", "6", "4", "5", "3" })
.Write();
}
Which creates this:
I'd like to be able to set a custom color to each of the yvalues as seen in the image below. How would I modify the code above to accomplish this? Thanks in advance.
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: How to set different colors on yvalues in Chart Helper
Jul 12, 2012 10:40 AM|LINK
please check
http://stackoverflow.com/questions/10450663/change-color-of-bars-depending-on-value-in-highchart-bar-chart-with-mvc3
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: How to set different colors on yvalues in Chart Helper
Jul 12, 2012 12:32 PM|LINK
You can create your own templates for the chart helper: http://blogs.msdn.com/b/erikreitan/archive/2010/10/28/webmatrix-creating-3d-charts.aspx
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter