View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
ABS ABS is offline
external usenet poster
 
Posts: 6
Default Hiding 0 value data labels in chart

On Apr 15, 8:45*pm, septimus wrote:
ABS,

Hey, that's great!!

Only problem is, I need the data labels to re-appear when the values
change to something greater than 0. If I delete the labels, they're
gone when the chart repaints with new data.

I tried changing the Text property instead of deleting the label
(i.e., If 0.0 Then DataLabel.Text = ""), but same problem: when the
values become larger the wiped labels are still empty.

Then I tried changing the font to white...

* * * * * * If
c.SeriesCollection(intSeries).Points(intPoint).Dat aLabel.Text = "0.0"
Then

c.SeriesCollection(intSeries).Points(intPoint).Dat aLabel.Font.ColorIndex
= 2
* * * * * * Else

c.SeriesCollection(intSeries).Points(intPoint).Dat aLabel.Font.ColorIndex
= 0
* * * * * * End If

... and that works pretty well except that you can still glimpse some
white zeros at the bottom where they overlap with chart columns.

Any better ideas? How do I get the DataLabels back when data changes
(without closing the file)?


Septie,
Yah...woke up this morning and went 'aaaaaugh, what if the data
changes?'.
Tried some experiments and came up with this, force each column to
have a label, then if it's blank, delete it, if it's not, do nothing.
So, one line of code in addition to yesterdays effort.
Sub VanishZeroLabels()
For x = 1 To ActiveChart.SeriesCollection(1).Points.Count
ActiveChart.SeriesCollection(1).Points(x).HasDataL abel = True
If ActiveChart.SeriesCollection(1).Points(x).DataLabe l.Text =
"0" Then
ActiveChart.SeriesCollection(1).Points(x).DataLabe l.Delete
End If
Next x
End Sub
So you have to remember to run it each time...also, not sure about the
'0' versus '0.0', I'm fuzzy on that.
Also wondering if running this code is more trouble than it would be
to just delete the offending labels by hand.
Bemused,
ABS