Suppress / Delete zero data label value (revisited)

K

Kyra

I never did get a satisfactory answer on this...

I am using OWC version 9. My chart type is
chChartTypeColumnStacked and I have multiple series. I
can turn on the Data Labels just fine for each series.
However, when the series value is zero, I get a bunch of
overlapping data labels that all say zero which I want to
either suppress or delete. The chart itself looks great.

Here is a more detailed explanation of the problem:
Let's say you have a chart where you are displaying how
many of the red, blue and green cars you see in the
parking lot each day. (I've inserted a crude drawing
below and some of my code.) You would have each date on
the x-axis, and the count from 0 to whatever on the y-
axis. Then you would have a series for red cars, a series
for blue cars, and a series for green cars. And let's
make the column color the same color as the car. The
problem is when you have zero cars at any time. For
example, today you had 5 blue cars, but no reds, and no
greens. Your chart column for today is completely blue
and fills up to the y-value of 5 -- that part is correct.
On my chart I also show the value of 5 inside the column
itself using data labels and that part is correct too.
Unfortunately, it also shows a data label of 0 for the red
and similarly a data label of 0 for the green. I don't
want the data label to show when the value is zero.

6+
|
5+ +-0-+ +---+
| |///| |*1*|
4+ |///| +---+
| |///| |///|
3+ |/5/| +-0-+ |/2/| \ - Red
| |///| |///| |///| / - Blue
2+ |///| |/2/| +---+ * - Green
| |///| |///| |\\\|
1+ |///| +---+ |\2\|
| |///| |\1\| |\\\|
0+--+-0-+--+---+--+---+
8/25 8/24 8/23

I don't want the 2 data labels of 0 on 8/25 (no red or
green cars) to show, nor the data label of 0 on 8/24 (no
green cars).

The applicable code I'm using for the data labels is:

ChartSpace.Charts(0).SetData c.chDimSeriesNames, 0, "Color"
ChartSpace.Charts(0).SetData c.chDimCategories, 0, "Date"
ChartSpace.Charts(0).SetData c.chDimValues, 0, "Count"
for i = 0 to ChartSpace.Charts(0).SeriesCollection.Count-1
ChartSpace.Charts(0).SeriesCollection
(i).DataLabelsCollection.Add
ChartSpace.Charts(0).SeriesCollection
(i).DataLabelsCollection(0).HasValue = True
ChartSpace.Charts(0).SeriesCollection
(i).DataLabelsCollection(0).Position =
c.chLabelPositionCenter
next
 
M

michael weiss

I think this might be a way to get at the datalabel item
itself...
ChartSpace1.Charts(0).SeriesCollection
(0).DataLabelsCollection.Delete 0
....where the '0' at the end is the index number of the
individual datalabel item. I am assuming the default
property for the datalabel item is the value. If so, then
you could loop through and find those datalabels whose
value is zero and then use something like the statement
above to delete those individual data labels.
hth,
Michael
 
T

Thao Moua [ms]

There is no way to modify individual data labels in
OWC9. You either had data labels or you don't. Support
for individual data label formatting was added in OWC10.

Thao Moua
OWC Webchart Support
 

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