Chart does not display in C#

L

Luis

I have a windows app with one form and a reference to Microsoft Office
Chart 11.0

The form has that control in it and one button. The code is below.
The chart displays, but not the series.

Thanks,

Luis

private void button1_Click(object sender, System.EventArgs e)
{
try
{


ChChart oChart;
axChartSpace1.Clear() ;
oChart = axChartSpace1.Charts.Add(0) ;
string[] chartCategoriesArr = new string []
{"10", "20", "30", "40", "50"};

string[] chartValuesArr = new string []
{"9", "5", "7", "13", "19"};

string chartCategoriesStr = String.Join ("\t", chartCategoriesArr);
string chartValuesStr = String.Join ("\t", chartValuesArr) ;
Debug.WriteLine (chartCategoriesStr.ToString() );
Debug.WriteLine (chartValuesStr.ToString() );


Debug.WriteLine ("Axes.Count" + oChart.Axes.Count.ToString() );

//oChart.Type = ChartChartTypeEnum.chChartTypeColumn3D;
oChart.Type = ChartChartTypeEnum.chChartTypeSmoothLine ;
ChSeries oSeries;
oSeries = oChart.SeriesCollection.Add(0) ;



//oChart.Border.Color = "white";

//oChart.HasTitle = true;

//oChart.ChartDepth = 125;
//oChart.AspectRatio = 80;
//oChart.Title.Caption = "Pricing Of 2004 Hondas";
//oChart.Title.Font.Bold = true;
oSeries.SetData( ChartDimensionsEnum.chDimCategories,
Convert.ToInt32( ChartSpecialDataSourcesEnum.chDataLiteral ),
chartCategoriesArr);
oSeries.SetData( ChartDimensionsEnum.chDimValues ,
Convert.ToInt32( ChartSpecialDataSourcesEnum.chDataLiteral
),chartValuesArr);

oSeries.Name = "Luis";
oSeries.Caption ="Caption Luis";
//ChDataLables Label;
oSeries.DataLabelsCollection.Add ();

//oSeries.DataLabelsCollection.Add ("lable2");
//oSeries.DataLabelsCollection.Add ("lable3");



axChartSpace1.Refresh();

}
catch (Exception ex)
{


Debug.WriteLine("Error");
Console.WriteLine(ex.Message);
Debug.WriteLine(ex.Source);
Debug.Unindent();

}
}
 
A

Alvin Bruney [MVP - ASP.NET]

I havent examined this in any detail but your parameters should be passed as
string and not string array. The chart takes an array but it must be of type
object.

--
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