Passing C# Array into SetData OWC Chart

L

Liam Ponder

Has anyone been able to pass an Array into the
DataReference variable of the SetData method of a
series. It comes up with a blank chart?

C# snippet in VS 2003



s.SetData(ChartDimensionsEnum.chDimCategories,(int)
ChartSpecialDataSourcesEnum.chDataLiteral,Categories);
s.SetData
(ChartDimensionsEnum.chDimValues,(int)
ChartSpecialDataSourcesEnum.chDataLiteral,Values);
 
T

Thao Moua [ms]

What did you declare Categories and Values as? In C#,
these variables must be declare as type OBJECT. Like this

object[] Data = new object[3] {1, 4, -3};
objHost.Charts[0].SeriesCollection[0].SetData
(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimV
alues, -1, Data);

Thao Moua
OWC Webchart Support

This posting is provided "AS IS" with no warranties, and
confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
L

Liam Ponder

That works great but what if I'm passed an array of ints,
it won't allow but to cast this into an array of
objects. How can I do this without looping through and
creating the object[] from scratch.

-----Original Message-----
What did you declare Categories and Values as? In C#,
these variables must be declare as type OBJECT. Like this

object[] Data = new object[3] {1, 4, -3};
objHost.Charts[0].SeriesCollection[0].SetData
(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimV
alues, -1, Data);

Thao Moua
OWC Webchart Support

This posting is provided "AS IS" with no warranties, and
confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
-----Original Message-----
Has anyone been able to pass an Array into the
DataReference variable of the SetData method of a
series. It comes up with a blank chart?

C# snippet in VS 2003



s.SetData(ChartDimensionsEnum.chDimCategories,(int)
ChartSpecialDataSourcesEnum.chDataLiteral,Categories);
s.SetData
(ChartDimensionsEnum.chDimValues,(int)
ChartSpecialDataSourcesEnum.chDataLiteral,Values);

.
.
 
L

liam Ponder

Found a close enough work around

int[] intArray = new int[] {1,2,3,4,5,6,7,8,9,10,11};
object[] objArray = new object[intArray.Length];
intArray.CopyTo(objArray,0);

s.SetData(ChartDimensionsEnum.chDimValues,(int)
ChartSpecialDataSourcesEnum.chDataLiteral,objArray);

Kind of sucks that you can't cast thing using the regular
syntax.


-----Original Message-----
That works great but what if I'm passed an array of ints,
it won't allow but to cast this into an array of
objects. How can I do this without looping through and
creating the object[] from scratch.

-----Original Message-----
What did you declare Categories and Values as? In C#,
these variables must be declare as type OBJECT. Like this

object[] Data = new object[3] {1, 4, -3};
objHost.Charts[0].SeriesCollection[0].SetData
(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimV
alues, -1, Data);

Thao Moua
OWC Webchart Support

This posting is provided "AS IS" with no warranties, and
confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

.
.
 

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