Different background colors on line chart

M

mottebelke

I just discovered the Office Web Components to use them for plotting
charts on a web page (C# .NET). It all seems very interesting and I
definitly want to work with it. But there is one thing I want to know
before hand.

Say that I want to display the properties of an object over a certain
time period. This would be done by displaying a few lines in the chart,
where each point would be the value of that property on a certain time.

This object also has a location property. Over the time it will move
from location to location, and I want to display this by using
different background colors for each location.
Is this possible using OWC? Is there a way of setting different
background colors for different areas of the chart? Or maybe by using
bars for the location and lines for the other properties?

I hope that someone knows this, and a little 'push' in the right
direction would be appreciated.


Tom
 
A

Alvin Bruney [MVP - ASP.NET]

yup, this is easy enough. You will find that the OWC is capable of a lot.
For instance, you can color each individual series like this. [This code was
lifted out of the black book page 97]


Code-listing 3.24 sample code to customize color




C# Snippet




for (int i = 0; i <
objCSpace.Charts[0].SeriesCollection[0].Points.Count;i++)




{

object val = (object)objCSpace.Charts[0]. SeriesCollection[0].
Points.GetValue

(OWC10.ChartDimensionsEnum.chDimValues, null);




if(Int32.Parse(val.ToString()) > 40)

objCSpace.Charts[0].SeriesCollection[0].Points. Interior.Color = "red";




else if(Int32.Parse(val.ToString()) < 15)

objCSpace.Charts[0].SeriesCollection[0].Points. Interior.Color =
"limegreen";

}





--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top