Suppress / Delete zero data label value

K

Kyra

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. Thanks in advance.
 
K

Kyra

Thanks for the reply but it's not the tick labels I'm
talking about, it's the data labels. 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. Any more help please?

Thanks, Kyra

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
 
T

Thao Moua [ms]

What version of OWC9 are you using? In owc10, you can
supress any data label you don't need.

In owc10, to turn off a specific data label run the
following code

webchart.charts(0).seriescollection
(0).datalabelscollection(0)(X).visible=false

where X is the datalabel you want to show/hide. X is
based-0.

-tm
 
T

Thao Moua [ms]

The simpliest way is to call Chartspace.version It'll
say either 9.xxx or 10.xxx

If you're getting a RTE then its probably you're using
OWC9.

-tm
 
K

Kyra

Okay, I determined that I am using OWC version 9.

I tried inserting your suggestion into my code and it
didn't work -- the error is 'Object doesn't support this
property or method'. Also my help file (MSOWCVBA.CHM -
Microsoft Office Web Components Visual Basic Reference)
says that the visible property doesn't apply to the
DataLabelsCollection.

Lastly, I need to also reference the data label value and
check it to see if it is zero before I can set the visible
property -- so is that the text property?? value
property?? What's the syntax for that? Thanks.

msgbox ChartSpace.Charts(0).SeriesCollection
(0).DataLabelsCollection(0)(1).Visible
 

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