Chart not showing data with OWC11 (office2003) using arrays

E

ErikSalt

I am trying to generate a simple chart in asp.net using OWC11.

I have an aspx page that renders the chart image, and while the image
comes back correctly (I can see the chart, chartspace, and gridlines),
I do not see any data(my dataseries does not show up). Also, my
category labels do not show up.

I am using the following simple code in page_load:

string[] categories=new string []{"A","B","C"};
int[]values=new int[]{5,15,10};

ChartSpace space = new ChartSpaceClass();
space.Clear();

ChChart chart = space.Charts.Add(0);
chart.Type=ChartChartTypeEnum.chChartTypeBarClustered;

chart.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, categories);

ChSeries series = chart.SeriesCollection.Add(0);

series.Type=ChartChartTypeEnum.chChartTypeBarClustered;

series.SetData(ChartDimensionsEnum.chDimSeriesNames,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, "SeriesName");

series.SetData(ChartDimensionsEnum.chDimValues,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, values);

series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, categories);

Response.Buffer = true;
Response.ContentType = "image/gif";
Response.BinaryWrite((byte[])space.GetPicture ("gif", 500, 500));
Response.End();

Any help anyone can provide on what I am doing wrong here, I would
greatly appreciate it.
 
A

Alvin Bruney [MVP]

space.Clear();
remove this line. the space is empty on creation so you don't need it.
ChSeries series = chart.SeriesCollection.Add(0);
make this
chart.SeriesCollection.Add(0);

replace the "series." with "chart." in the subsequent lines

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
ErikSalt said:
I am trying to generate a simple chart in asp.net using OWC11.

I have an aspx page that renders the chart image, and while the image
comes back correctly (I can see the chart, chartspace, and gridlines),
I do not see any data(my dataseries does not show up). Also, my
category labels do not show up.

I am using the following simple code in page_load:

string[] categories=new string []{"A","B","C"};
int[]values=new int[]{5,15,10};

ChartSpace space = new ChartSpaceClass();
space.Clear();

ChChart chart = space.Charts.Add(0);
chart.Type=ChartChartTypeEnum.chChartTypeBarClustered;

chart.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, categories);

ChSeries series = chart.SeriesCollection.Add(0);

series.Type=ChartChartTypeEnum.chChartTypeBarClustered;

series.SetData(ChartDimensionsEnum.chDimSeriesNames,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, "SeriesName");

series.SetData(ChartDimensionsEnum.chDimValues,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, values);

series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, categories);

Response.Buffer = true;
Response.ContentType = "image/gif";
Response.BinaryWrite((byte[])space.GetPicture ("gif", 500, 500));
Response.End();

Any help anyone can provide on what I am doing wrong here, I would
greatly appreciate it.
 

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