# How, via python, to enable "data labels" on in bar-chart?

**URL:** <https://discourse.slicer.org/t/how-via-python-to-enable-data-labels-on-in-bar-chart/12435>\
**Category:** Feature requests\
**Tags:** extensions-manager\
**Created:** [July 8, 2020, 10:39am UTC](https://discourse.slicer.org/t/how-via-python-to-enable-data-labels-on-in-bar-chart/12435 "2020-07-08T10:39:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)\
**Post date:** [July 8, 2020, 10:39am UTC](https://discourse.slicer.org/t/how-via-python-to-enable-data-labels-on-in-bar-chart/12435/1 "2020-07-08T10:39:03Z")

</div>

Hi all,  
I am trying to have a bar chart using:  
ln = slicer.mrmlScene.GetFirstNodeByClass(‘vtkMRMLLayoutNode’)  
ln.SetViewArrangement(24)

```
# Get the first ChartView node
cvn = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLChartViewNode')
# Create another data array
dn5 = slicer.mrmlScene.AddNode(slicer.vtkMRMLDoubleArrayNode())
a = dn5.GetArray()

a.SetNumberOfTuples(4)
a.SetComponent(0, 0, 6)
a.SetComponent(0, 1, 32)
a.SetComponent(1, 0, 3)
a.SetComponent(1, 1, 12)
a.SetComponent(2, 0, 4)
a.SetComponent(2, 1, 20)
a.SetComponent(3, 0, 5)
a.SetComponent(3, 1, 6)

# Create another ChartNode
cn = slicer.mrmlScene.AddNode(slicer.vtkMRMLChartNode())

# Add data to the chart
cn.AddArray('Volumes', dn5.GetID())

# Configure properties of the Chart
cn.SetProperty('default', 'title', 'A chart with labels')
cn.SetProperty('default', 'xAxisLabel', 'structure')
cn.SetProperty('default', 'xAxisType', 'categorical')
cn.SetProperty('default', 'yAxisLabel', 'size (cm)')
cn.SetProperty('default', 'type', 'Bar');
cn.SetProperty('Volumes', 'lookupTable', slicer.util.getNode('GenericAnatomyColors').GetID() )

# Set the chart to display
cvn.SetChartNodeID(cn.GetID())
self.delayDisplay('A chart with labels')

```

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/d/6d9328e418d1078d6dcddfea43bc41dbd43410bd.png)  
So how to enable those “data labels” in the bar circled in red?  
Thanks a lot,  
Aiden

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 8, 2020, 1:09pm UTC](https://discourse.slicer.org/t/how-via-python-to-enable-data-labels-on-in-bar-chart/12435/2 "2020-07-08T13:09:53Z")

</div>

Can you show these labels using Slicer GUI?  
Can you show them using VTK API?
