OWC ASP.Net Chart Problem

B

Ben

Hi, I have a line chart that I'm creating in asp.net c#. I'm supplying data
to the chart with a tab delimited string. The problem I'm having is that if
data is missing, it isn't displayed in the correct spot.

For example if I have a, b and c with data 1, 2, 3 some have the data some
don't. I would expect to see...

a 1 2 3
b 1 3
c 2 3
1 2 3

Instead I'm getting,
a 1 2 3
b 1 3
c 2 3
1 2 3

I realize this is hardly a line chart, but it is representative of my
problem. I've tried sending in null and a tab, but nothing seems to work.

Any help appreciated.

Thanks,
Ben
 
S

Sascha Sertel

Ben,

if I might add something, I think the problem goes even further than what
you described. When I am using Series of different lengths, I noticed that
the ChSeries.Points.Count for both series will still be the same, so somehow
the shorter Series is filled up with null data points to match the length of
the longer Series. While that doesn't seem to be a problem for most cases, I
have a function which only activates the last datalabel of a Series, and
since I cannot use Points.Count anymore to find the last data point I added
I am going backwards through the Series to find the first non-zero value.

Which brings me to your problem. From my experience with Series it doesn't
seem to be possible to have gaps in your data. Even worse, if your Category
is recognized as a DateTime type, the OWC will even automatically FILL any
gaps with interpolated data, which I so much want to deactivate, but it
seems OWC forces that onto you. The only workaround I found for that problem
is to use invisible ASCII codes in my Date-String which prevent OWC from
recognizing it as a valid date, thus only displaying the data I provide.

Okay, so finally a solution for your problem: I don't know if that does the
job for you, but you could set the gaps to some value such as zero, or if
you have valid zero data points, use -1000 or any non-existing value (if
there is one). Then you can loop through your points (and datalabels if
necessary) and hide those which have the value set to that 0 or -1000.
However, this is just a thought, I don't know if hiding a datapoint will
actually create a gap in your line. But it's worth a try I guess.

If you find another solution, please let me know, since I had similar
problems, and so far could never find real help from the OWC side other than
tweaking the objects and cycling through several collections myself.

Sascha
 
B

Ben

Here is my solution. I'm using a hashtable to store the data since there
are multiple series. I hope you're programming in c# :)

If not, I can try to decipher some of it for you.

while (dr.Read())
{
string SiteName = dr.GetString(0);

if (!Sites.Contains(SiteName))
{
Sites.Add(SiteName, new Hashtable());
}
((Hashtable)Sites[SiteName])[dr.GetString(1)] = dr.GetValue(2).ToString();
}

dr.Close();

string QuestionNames =
"Q9a\tQ9b\tQ9c\tQ9d\tQ9e\tQ9f\tQ9g\tQ9h\tQ9i\tQ9j\tQ9k\tQ9l\tQ9m\tQ9n\tQ9o\t
Q9p\tQ9q\tQ9r\tQ9s";

OWC11.ChartSpace oChartSpace = new OWC11.ChartSpaceClass();
OWC11.ChChart oChart = oChartSpace.Charts.Add(0);
oChart.Type = OWC11.ChartChartTypeEnum.chChartTypeLineMarkers;
oChart.HasTitle = true;
oChart.Title.Caption = "Core Attributes";
oChart.HasLegend = true;
oChart.Axes[1].Scaling.Minimum = 0;
oChart.Axes[1].Scaling.Maximum = 100;
oChart.Axes[1].HasTitle = true;
oChart.Axes[1].Title.Caption = "% Top-3 Box";

int SeriesCount = 0;

oChart.SeriesCollection.Add(SeriesCount);
oChart.SeriesCollection[SeriesCount].SetData(OWC11.ChartDimensionsEnum.chDim
Categories, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral,
QuestionNames);

SeriesCount++;

foreach (DictionaryEntry de in Sites)
{

oChart.SeriesCollection.Add(SeriesCount);

ArrayList SiteQuestions = new ArrayList(((Hashtable)Sites[de.Key]).Keys);
ArrayList SiteAnswers = new ArrayList(((Hashtable)Sites[de.Key]).Values);


oChart.SeriesCollection[SeriesCount].SetData(OWC11.ChartDimensionsEnum.chDim
Categories, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral,
string.Join("\t", (string[])SiteQuestions.ToArray(typeof(string))));

oChart.SeriesCollection[SeriesCount].SetData(OWC11.ChartDimensionsEnum.chDim
SeriesNames, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral,
de.Key.ToString());

oChart.SeriesCollection[SeriesCount].SetData(OWC11.ChartDimensionsEnum.chDim
Values, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral,
string.Join("\t", (string[])SiteAnswers.ToArray(typeof(string))));

SeriesCount++;
}
 
S

Sascha Sertel

Ben,

my OWC project is done with ASP, but I know C# and understand your code.
Looks good to me! I also read through the article, and thinking about it, it
(surprisingly) even makes sense! That might even be the solution for my
problems with the shorter Series, I guess if I adjust the Category Array for
the shorter Series then it will not create those blank data points and the
Points.Count value will actually reflect the right value! I will try it out
immediately and post back here if I was right.

Thanks,
Sascha
 
A

Alvin Bruney [MVP]

for your date problem you need to turn time scaling off. it is set to on by
default.
 

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