OWC11.ChartSpace control - faking series labels

A

AndrewJens

Hi,
I'm using the OWC11.ChartSpace control to chart data in an Access
report, and everything is working very well (so far). My problem is not
a 'how to code it', rather a 'can it be coded' strategy question.

Imagine a simple column chart that graphs percentage data (so the
vertical axis scale is 0 to 100) returned in a recordset. Say that
there are two columns on the chart (one representing 40% and the second
representing 80%). The horizontal axis could have anything (e.g. years
2004, 2005). If I use standard DataLabelsCollection code, I can easily
display the percentage as a number just above each of the columns. So
now imagine the first column to have the number 40 just vertically
above it and second column to have the number 80 just vertically above
it. So far so good, and this is all working perfectly.

My requirement is however to display something other than 40 above the
first column. So for example, if the 40% was derived by considering 500
widgets out of a total of 1250 then I would like to display the number
500 just above the first column, and 1000 above the second column.

But I would like to go even further. In some cases, I would like to
display arbitrary text above a column. For example, "500 - suspect" or
"1000 - target reached", etc. The text labels can be returned in any
data-driven way that makes a solution possible - e.g. as another field
in the original recordset, or as entries in an array.

So the question boils down to: can you fake/substitute the labels on a
chart series with the OWC11 control?

Thanks in advance for any assistance/suggestions that anyone can
provide.
 
A

Alvin Bruney - ASP.NET MVP

The appropriate term for the functionality is custom datalabels. OWC does
contain support for custom data labels. To accomplish this, you must use
custom drawing. On the render event, simple assign your specific value to
the data label. There's a link on MSDN concerning custom drawing and its
implementation. Be sure to read the licensing requirements before you dive
in.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
A

AndrewJens

Hi Alvin,
Thanks for that - I got it to work just as you suggested. In fact, it's
amazing the control you can get over a chart by cancelling the
BeforeRender event and substituting your own code.
The MSDN Article ID is numbered 290348 - "HOWTO: Use Custom Layout and
Drawing with the Office Chart Component". Just remember to set the
EnableEvents property of the ChartSpace to True (the article fails to
mention this). If you forget to do that, the BeforeRender event won't
fire (despite having also set things like AllowLayoutEvents to True),
and you could end up wasting several hours getting frustrated :)
Andrew.
 

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