# How to hide labels which are zero in Bar charts

**URL:** <https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [April 18, 2022, 8:44am UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540 "2022-04-18T08:44:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vengatesan\_S](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vengatesan\_S](https://forum.inductiveautomation.com/u/Vengatesan_S)\
**Post date:** [April 18, 2022, 8:44am UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540/1 "2022-04-18T08:44:00Z")

</div>

Hi,  
I am using a Stacked bar chart to show the Downtime in Hours for all days in a month, I would like to hide the labels which are zero in the chart.  
Is it possible to hide the labels which are only 0 in the bar chart?  
Did we need to do use configure chart in the Component scripting section to achieve the same?  
Any help will be appreciated!

 ![barchart](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/c/ac70904d57e888a68a83eb3db7994d60f9654dda.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 18, 2022, 12:06pm UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540/2 "2022-04-18T12:06:02Z")

</div>

If the data is coming from a binding then you just need to add a script transform to the binding to weed out the bits you don’t want. The database results will be returned as `value` and you just add some transform code like this:

```auto
# This code assumes that value format is like 
# [{"date": '2022-03-01', "hours": 0.6}, {"date": '2022-03-02", "hours": 0}, ...]
output = []
for row in value:
    if row['hours'] > 0:
        output.append({"date": value['date'], "hours": value['hours']})
return output

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 18, 2022, 12:44pm UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540/3 "2022-04-18T12:44:59Z")

</div>

Just a guess, since they didn’t actually say and there is no tag, but since the OP mentions the Component scripting section, I believe they are referencing Vision, in which case a transform is not available.

@Vengatesan_S If this is for vision, you can create a custom Label Generator in the configureChart function. Something like this:

```python
class myLabelGenerator(StandardCategoryItemLabelGenerator):
    def generateLabel(self,dataset,series, category):
        value = dataset.getValue(series,category)
        if value == 0:
            return None
        return str(value)

chart = event.source.parent.getComponent(‘Bar Chart’).getChart()
plot = chart.getPlot()
renderer = plot.getRenderer()
renderer.setItemLabelGenerator(myLabelGenerator())
renderer.setItemLabelsVisible(True)

```

---

<div class="post-metadata">

**Author:** ![Vengatesan\_S](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vengatesan\_S](https://forum.inductiveautomation.com/u/Vengatesan_S)\
**Post date:** [April 18, 2022, 2:26pm UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540/4 "2022-04-18T14:26:35Z")

</div>

Thanks @Transistor and Irose, As i am using Vision Irose’s solution worked out for me , I just used that script in property change.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 18, 2022, 3:02pm UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540/5 "2022-04-18T15:02:04Z")

</div>

> [@Vengatesan\_S](#):
>
> As i am using Vision ,,,

Please remember to use the appropriate tag when writing a question!

---

<div class="post-metadata">

**Author:** ![Dhruvil\_Patel](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@Dhruvil\_Patel](https://forum.inductiveautomation.com/u/Dhruvil_Patel)\
**Post date:** [May 5, 2023, 8:07pm UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540/6 "2023-05-05T20:07:13Z")

</div>

Thanks Irose for the solution. Is it possible to position the bar label at center with this solution?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 7, 2023, 10:42am UTC](https://forum.inductiveautomation.com/t/how-to-hide-labels-which-are-zero-in-bar-charts/58540/7 "2023-05-07T10:42:03Z")

</div>

> [@Dhruvil\_Patel](#):
>
> position the bar label at center

Adjustments to label position are certainly doable, but can you elaborate or perhaps provide a sample picture of what you mean by this?
