OWC Chart: How to combine bar and line graf?

H

Hans Riis

Hi.

I'm trying to create a bar chart with another series of data
represented as a line. I get my data from MS SQL. I create the chart
Frontpage and add dropdown menus i JavaScript to control the chart
component for people with little IT understanding.

For this first chart I'm looking for a way to combine bars and lines
using the same scale (in another chart I'll need to have separate
axes). I Haven't gotten as far as the combo part yet.

I hope somebody can help me out!

This bit of JavaScript code works for just changing one measure on the
y-axis:

function Sel_Field()
{
c=ChartSpace1.Constants;
ChartSpace1.PlotAllAggregates = 1;
ChartSpace1.HasPlotDetails = true;
ChartSpace1.PlotAllAggregates = c.chPlotAggregatesSeries;

ChartSpace1.SetData(c.chDimValues, c.chDataBound, "");
ChartSpace1.SetData(c.chDimValues, c.chDataBound, "BarVar");
}

This doesn't work as a replacement of the last line above:
ChartSpace1.SetData(c.chDimValues, c.chDataBound,
Array("BarVar","LineVar"));


I also tried VBScript but that didn't help much:

<SCRIPT language=VBScript>
set c=ChartSpace1.Constants
ChartSpace1.PlotAllAggregates = 1;
ChartSpace1.HasPlotDetails = true;
ChartSpace1.PlotAllAggregates = c.chPlotAggregatesSeries

ChartSpace1.SetData c.chDimValues, c.chDataBound, ""
ChartSpace1.SetData c.chDimValues, c.chDataBound,
Array("BarVar","LineVar")
</SCRIPT>

Thanks in advance, Hans Riis (Denmark)
 
A

Alvin Bruney [MVP]

Hans,
the supported combo types are area,line and column. If you attempt to plot
an unsupported type, the net effect is equivalent to changing the type of
the chart at the chartspace level which changes all types in each series to
the same chart type.

Were you thinking possibly of a column/line type?
 
H

Hans Riis

Hi Alvin.

Yes, I'm looking for a column (bar) / line combo chart with the same
x-axis.
I need to be able to both make a combo chart with data using similar
axes and different axes. Also, I need to be able to specify colors for
the columns and line respectively (blue and yellow).

Regards, Hans Riis
 
A

Alvin Bruney [MVP]

the concept is the same, you would need two series instead of one. One
series set to column, the other set to line. Colors you can set by using the
interior object. It just depends on what exactly you want to color. Most of
the UI objects contain an interior property which allows for coloring. You
can color from borders, lines right down to invidual points. If you need
different scales, you need to first ungroup the axes and then use the
scaling object to customize the scales on the axes. One gotcha is, the axes
cannot be customized for different scales on combo charts because it would
distort the appearance for the series.
hth
 
H

Hans Riis

Hi Alvin.

I understand what you're saying but how do I code it? As for colors I
just wish to set a colour for each series.

BTW, I don't know if it can be done programatically but it is possible
to have different axis scales in a combo chart. It's a bit tricky but
it can be done.

Regards, Hans Riis
 
H

Hans Riis

Hi Alvin.

I understand what you're saying but how do I code it? As for colors I
just wish to set a colour for each series.

BTW, I don't know if it can be done programatically but it is possible
to have different axis scales in a combo chart. It's a bit tricky but
it can be done.

Regards, Hans Riis
 
H

Hans Riis

Hi, I'm sorry for the confusion. I changed the title of my response
without knowing it would start a new thread. The original question
was:


I'm trying to create a bar chart with one series of data and
another series of data represented as a line.
I get my data from MS SQL.
I create the chart in Frontpage and add dropdown menus with JavaScript
calls
to control the chart component for people with little IT
understanding.

For this first chart I'm looking for a way to combine bars and lines
using the same scale (in another chart I'll need to have separate
axes). I Haven't gotten as far as the combo part yet.

I hope somebody can help me out!

This bit of JavaScript code works for just changing one measure on the
y-axis:

function Sel_Field()
{
c=ChartSpace1.Constants;
ChartSpace1.PlotAllAggregates = 1;
ChartSpace1.HasPlotDetails = true;
ChartSpace1.PlotAllAggregates = c.chPlotAggregatesSeries;

ChartSpace1.SetData(c.chDimValues, c.chDataBound, "");
ChartSpace1.SetData(c.chDimValues, c.chDataBound, "BarVar");
}

This doesn't work as a replacement of the last line above:
ChartSpace1.SetData(c.chDimValues, c.chDataBound,
Array("BarVar","LineVar"));


I also tried VBScript but that didn't help much:

<SCRIPT language=VBScript
set c=ChartSpace1.Constants
ChartSpace1.PlotAllAggregates = 1;
ChartSpace1.HasPlotDetails = true;
ChartSpace1.PlotAllAggregates = c.chPlotAggregatesSeries

ChartSpace1.SetData c.chDimValues, c.chDataBound, ""
ChartSpace1.SetData c.chDimValues, c.chDataBound,
Array("BarVar","LineVar")
</SCRIPT

Thanks in advance, Hans Riis (Denmark)
 
G

Gary Heaven

Hans

Did you get an answer to this?
There is an extremely well written KB article on this.. pity about the
title, guaranteed to keep it obscure.
288907 INFO: Bind the Office XP Chart Component to a Data Source
http://support.microsoft.com/default.aspx?scid=kb;en-us;288907

The general approach is to ungroup each series and then set its chart type.
The ungroup method lets you specify whether to use a new scaling for that
series or to keep the scaling from the previous grou. It seems as though you
want the latter.
 

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