OWC11 Multiple Axis with Scatter and Line Series

D

Dewy

Hi,

I am having a major problem with the OWC. I am trying to have multiple
series on a chart, where one series is a line series and the other a
scatter series.

The ultimate goal is to use scalings on the scatter series so that
vertical lines can be drawn on the chart at specific points. I have
achieved this result in Excel, but this was just a test harness and I
am aware that the OWC have only a subset of the functionality of the
actual office counterparts.

I am using C# and my code looks like the following


string[] chartArrLineXValues = new string [] {"Jan 2004",
"Feb 2004", "Mar 2004", "Apr 2004", "May 2004"};
string[] chartArrLineYValues = new string []{"1", "2",
"5", "4", "5"};

string chartStrLineXValues = String.Join ("\t",
chartArrLineXValues);
string chartStrLineYValues = String.Join ("\t",
chartArrLineYValues);

string[] chartArrScatterXValues = new string [] {"5",
"5"};
string[] chartArrScatterYValues = new string []{"0", "1"};

string chartStrScatterXValues = String.Join ("\t",
chartArrScatterXValues);
string chartStrScatterYValues = String.Join ("\t",
chartArrScatterYValues);

ChartSpaceClass chartSpace = new ChartSpaceClass ();

ChChart chart = chartSpace.Charts.Add(0);


ChSeries lineSeries = chart.SeriesCollection.Add(0);
lineSeries.Ungroup(true);
lineSeries.Line.Color = "green";
lineSeries.Type =
ChartChartTypeEnum.chChartTypeSmoothLine;

lineSeries.SetData (ChartDimensionsEnum.chDimValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrLineYValues);
lineSeries.SetData (ChartDimensionsEnum.chDimCategories,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrLineXValues);

ChScaling lineScalingXAxis =
lineSeries.get_Scalings(ChartDimensionsEnum.chDimCategories);
ChAxis lineXAxis = chart.Axes.Add(lineScalingXAxis);

ChScaling lineScalingYAxis =
lineSeries.get_Scalings(ChartDimensionsEnum.chDimValues);
ChAxis lineYAxis = chart.Axes.Add(lineScalingYAxis);



ChSeries scatterSeries = chart.SeriesCollection.Add(0);
scatterSeries.Ungroup(true);
scatterSeries.Line.Color = "red";
scatterSeries.Type =
ChartChartTypeEnum.chChartTypeScatterLine;

scatterSeries.SetData (ChartDimensionsEnum.chDimXValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrScatterXValues);
scatterSeries.SetData (ChartDimensionsEnum.chDimYValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrScatterYValues);

ChScaling scatterScalingXAxis =
scatterSeries.get_Scalings(ChartDimensionsEnum.chDimXValues);
ChAxis scatterXAxis = chart.Axes.Add(scatterScalingXAxis);
scatterXAxis.Position =
ChartAxisPositionEnum.chAxisPositionTop;

ChScaling scatterScalingYAxis =
scatterSeries.get_Scalings(ChartDimensionsEnum.chDimYValues);
ChAxis scatterYAxis = chart.Axes.Add(scatterScalingYAxis);
scatterYAxis.Position =
ChartAxisPositionEnum.chAxisPositionRight;


The problem that I am encountering is that I can't seem to seperate
out the axis. If I change the scalings on one axis it effects that
other series' scaling as well.

Can any one help or suggest an alternative please?
Dewy
 
T

Thao Moua [ms]

First you cannot have a chart consisting of line and scatter. The only combo
chart allowed are column, line, and area.

Second, all multiple charts inside a Chartspace control all share the same
category axis. If the charts are to have different axis, then you must use
multiple Chartspace controls.
----------------------------------------------------------------------
Thao Moua
OWC Chartspace 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
----------------------------------------------------------------------

Dewy said:
Hi,

I am having a major problem with the OWC. I am trying to have multiple
series on a chart, where one series is a line series and the other a
scatter series.

The ultimate goal is to use scalings on the scatter series so that
vertical lines can be drawn on the chart at specific points. I have
achieved this result in Excel, but this was just a test harness and I
am aware that the OWC have only a subset of the functionality of the
actual office counterparts.

I am using C# and my code looks like the following


string[] chartArrLineXValues = new string [] {"Jan 2004",
"Feb 2004", "Mar 2004", "Apr 2004", "May 2004"};
string[] chartArrLineYValues = new string []{"1", "2",
"5", "4", "5"};

string chartStrLineXValues = String.Join ("\t",
chartArrLineXValues);
string chartStrLineYValues = String.Join ("\t",
chartArrLineYValues);

string[] chartArrScatterXValues = new string [] {"5",
"5"};
string[] chartArrScatterYValues = new string []{"0", "1"};

string chartStrScatterXValues = String.Join ("\t",
chartArrScatterXValues);
string chartStrScatterYValues = String.Join ("\t",
chartArrScatterYValues);

ChartSpaceClass chartSpace = new ChartSpaceClass ();

ChChart chart = chartSpace.Charts.Add(0);


ChSeries lineSeries = chart.SeriesCollection.Add(0);
lineSeries.Ungroup(true);
lineSeries.Line.Color = "green";
lineSeries.Type =
ChartChartTypeEnum.chChartTypeSmoothLine;

lineSeries.SetData (ChartDimensionsEnum.chDimValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrLineYValues);
lineSeries.SetData (ChartDimensionsEnum.chDimCategories,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrLineXValues);

ChScaling lineScalingXAxis =
lineSeries.get_Scalings(ChartDimensionsEnum.chDimCategories);
ChAxis lineXAxis = chart.Axes.Add(lineScalingXAxis);

ChScaling lineScalingYAxis =
lineSeries.get_Scalings(ChartDimensionsEnum.chDimValues);
ChAxis lineYAxis = chart.Axes.Add(lineScalingYAxis);



ChSeries scatterSeries = chart.SeriesCollection.Add(0);
scatterSeries.Ungroup(true);
scatterSeries.Line.Color = "red";
scatterSeries.Type =
ChartChartTypeEnum.chChartTypeScatterLine;

scatterSeries.SetData (ChartDimensionsEnum.chDimXValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrScatterXValues);
scatterSeries.SetData (ChartDimensionsEnum.chDimYValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrScatterYValues);

ChScaling scatterScalingXAxis =
scatterSeries.get_Scalings(ChartDimensionsEnum.chDimXValues);
ChAxis scatterXAxis = chart.Axes.Add(scatterScalingXAxis);
scatterXAxis.Position =
ChartAxisPositionEnum.chAxisPositionTop;

ChScaling scatterScalingYAxis =
scatterSeries.get_Scalings(ChartDimensionsEnum.chDimYValues);
ChAxis scatterYAxis = chart.Axes.Add(scatterScalingYAxis);
scatterYAxis.Position =
ChartAxisPositionEnum.chAxisPositionRight;


The problem that I am encountering is that I can't seem to seperate
out the axis. If I change the scalings on one axis it effects that
other series' scaling as well.

Can any one help or suggest an alternative please?
Dewy
 
P

Pavr1

Hi I think I know what's wrong maybe it can help you out!
The properties for a Scatter Chart are always X and Y axis... but for a Line
chart doesn't need X and Y, just one property "chDimValues"

Try to do this: instead of giving x and y value to the line chart just do
this:

For Line Chart:

objChart.SeriesCollection[0].SetData
(OWC11.ChartDimensionsEnum.chDimSeriesNames,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Line Chart");

objChart.SeriesCollection[0].SetData (OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, chartArrLineXValues );

For Scatter Chart:

do the same you have and give the chDimCategories a value...

....SetData (OWC11.ChartDimensionsEnum.chDimSeriesNames,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Scatter Chart");

ChSeries scatterSeries = chart.SeriesCollection.Add(0);
scatterSeries.Ungroup(true);
scatterSeries.Line.Color = "red";
scatterSeries.Type =
ChartChartTypeEnum.chChartTypeScatterLine;

scatterSeries.SetData (ChartDimensionsEnum.chDimXValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrScatterXValues);
scatterSeries.SetData (ChartDimensionsEnum.chDimYValues,
Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
chartStrScatterYValues);

Good Luck
 

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

Similar Threads


Top