Link to home
Start Free TrialLog in
Avatar of GroganJ
GroganJ

asked on

Setting X-Axis labels with a ChartSpace

I'm using an OWC11 ChartSpace object on a userform. It contains 1 chart and the x-axis is a set of dates to correspond to the y-values. The ChartType is a LineType.

How do I set the X-axis labels to my dates using VBA? I'm using Office 2003.
Avatar of werafa
werafa

start recording a macro and do it manually.
then look at the code and modify it to suit

there is no vba code to set the axis and cart labels dynamically
Avatar of Rory Archibald
Do you have a spreadsheet control that you are using for the data or is the whole thing populated in code?
Avatar of GroganJ

ASKER

rorya - the entire thing is programmed from VBA. I'm not using Excel at all.
Avatar of GroganJ

ASKER

Werafa - I had tried that, but the methods that a recorded macro picks up do not all exist in the OWC11 object. And specifically, the methods around setting the x-axis.

If vba doesn't let you change the axes, can anyone recommend a third party object that does allow me more control over graphing? Cheap is good, free is better :-)
You don't actually need to be in Excel to use a spreadsheet control! :)
I should be back in the office shortly - I'll check my OWC code samples - I'm pretty sure it is possible to do what you want. Do you have the dates in an array already?
Avatar of GroganJ

ASKER

Rorya - thanks for that, I appreciate the help. I have 2 arrays that I read from a database. One contains the dates for the x-axis and the other contains the y-values.
Assuming your chart variable is called cht and your date array is adteCategories, the code would be:

cht.SetData chDimCategories, chDataLiteral, adteCategories


I assume you know you could bind the chart to the database?
Avatar of GroganJ

ASKER

Rorya - I can't get this to work. Do you have a code sample that you could post?

I don't want to bind to a database as there is some manipulation of the data before displaying.
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GroganJ

ASKER

Thanks Rorya - my mistake was in not making the date array a variant array.