# Rotating Bar Chart Labels?

**URL:** <https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724>\
**Category:** Ignition\
**Created:** [July 19, 2019, 6:57pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724 "2019-07-19T18:57:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AIO](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aio/32/87549_2.png) [@AIO](https://forum.inductiveautomation.com/u/AIO)\
**Post date:** [July 19, 2019, 6:57pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/1 "2019-07-19T18:57:39Z")

</div>

Hey folks,

Ingition 7.9.10

I’m dealing with several bar charts with large values, but the labels are important to the client.  
As of now, the labels overlap with the bars adjacent to them.

Is there any means by which to force the label text to rotate 90 degrees and read vertical?  
I was looking for a possible scripting solution, but can’t seem to narrow it down.

Cheers,  
Andrew

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [July 19, 2019, 7:02pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/2 "2019-07-19T19:02:00Z")

</div>

I [just posted about this same problem earlier today, too](http://forum.inductiveautomation.com/t/overlapping-bar-chart-x-axis-labels/26716).

The thing is, Perspective uses the AMCharts library for charting, and while AMCharts itself DOES support text rotation in bar chart labels, Ignition’s front-end to AMCharts does not let you configure this.

So the short answer is: No, this isn’t possible with the current charting.

However, I’ve heard that they’re revamping the charting and will possibly have options for this soon.

---

<div class="post-metadata">

**Author:** ![AIO](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aio/32/87549_2.png) [@AIO](https://forum.inductiveautomation.com/u/AIO)\
**Post date:** [July 19, 2019, 7:04pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/3 "2019-07-19T19:04:40Z")

</div>

I’m assuming the same thing goes for 7.9, as well? I know perspective was a pretty significant change.

Thanks for the reply!

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [July 19, 2019, 7:05pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/4 "2019-07-19T19:05:20Z")

</div>

Oh whoops, sorry, missed the fact that you’re not using Perspective…

I can’t really answer for Vision, sorry!

---

<div class="post-metadata">

**Author:** ![AIO](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aio/32/87549_2.png) [@AIO](https://forum.inductiveautomation.com/u/AIO)\
**Post date:** [July 19, 2019, 7:26pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/5 "2019-07-19T19:26:10Z")

</div>

Via [Moving value label positions on chart bar graph?](http://forum.inductiveautomation.com/t/moving-value-label-positions-on-chart-bar-graph/16860) and [http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/ItemLabelPosition.html](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/ItemLabelPosition.html), it seems like it should be doable via the chart component. Just got to try to figure it out…

---

<div class="post-metadata">

**Author:** ![AIO](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aio/32/87549_2.png) [@AIO](https://forum.inductiveautomation.com/u/AIO)\
**Post date:** [September 6, 2019, 8:12pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/6 "2019-09-06T20:12:03Z")

</div>

Hoping someone may be able to help guide me on how to implement this properly. Having a hell of a time.

An example chart with implemented script would be huge, as I’ve never tackled chart scripting like this before.

Much appreciated.

---

<div class="post-metadata">

**Author:** ![shubham\_shekhar](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@shubham\_shekhar](https://forum.inductiveautomation.com/u/shubham_shekhar)\
**Post date:** [March 24, 2022, 1:27pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/7 "2022-03-24T13:27:35Z")

</div>

@pturmel

I’m facing the same issue pls help to get some suggestions.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 24, 2022, 1:48pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/8 "2022-03-24T13:48:57Z")

</div>

Never had to do this, sorry.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [March 24, 2022, 5:24pm UTC](https://forum.inductiveautomation.com/t/rotating-bar-chart-labels/26724/9 "2022-03-24T17:24:40Z")

</div>

You can do this with the Chart component (chart type = Category Chart), not with the Bar Chart…

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/546317eef4033371c75b185106db5b5d0068929d.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/546317eef4033371c75b185106db5b5d0068929d.mp4)

In Chart Extension Functions-\>configureChart insert this code:

```auto
	# Put your code here

	from org.jfree.chart.axis import TickUnits
	from org.jfree.chart.axis import DateTickUnit
	from java.text import SimpleDateFormat
	from org.jfree.chart.renderer.category import StandardBarPainter
	from org.jfree.chart.labels import ItemLabelPosition
	from org.jfree.chart.labels import ItemLabelAnchor
	from org.jfree.ui import TextAnchor
	from java.awt import Color
	from java.awt import Font
	from org.jfree.chart.labels import StandardCategoryItemLabelGenerator
	from java.text import NumberFormat

	class myLabelGenerator(StandardCategoryItemLabelGenerator):
		def generateLabel(self,dataset,series, category):	
			value = dataset.getValue(series,category)
			#print value	
			if value > 0.0:
				return NumberFormat.getInstance().format(int(value))
			else:
				return None

	
	plot = chart.getPlot()
	renderer = plot.getRenderer()
	renderer.setBarPainter(StandardBarPainter())
	renderer.setShadowVisible(0)

	renderer.setBaseItemLabelFont(Font("Roboto Condensed", Font.PLAIN, 12))
	renderer.setBaseLegendTextFont(Font("Roboto Condensed", Font.PLAIN, 12));

	renderer.setItemLabelGenerator(myLabelGenerator())
	
	renderer.setItemLabelsVisible(True)
	
	size = plot.getCategories().size()

    #====== THIS IS THE ROTATING LABEL PART ======================
	# 1.57 is 90 degrees in radians
	# ItemLabelPosition requires angle in Radians
	if size > 10:	#if there is more than 10 rows (for me is more than 10 days)
		renderer.setBasePositiveItemLabelPosition(ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -1.57))
	#===============================================

	plot.getDomainAxis().setMaximumCategoryLabelLines(3)
	plot.getDomainAxis().lowerMargin = 0.005
	plot.getDomainAxis().upperMargin = 0.005
	units = TickUnits()
	
	# Format definitions
	# Formats are created with default timezone and default locale
	# format.setTimezone might be used to override the timezone
	# Additional space is added to the format to prevent ticks from being
	# displayed without space (hprojectens sometimes when using anchored layout).
	formatMSec = SimpleDateFormat(" HH:mm:ss SS")
	formatSec = SimpleDateFormat(" HH:mm:ss")
	formatMin = SimpleDateFormat(" HH:mm")
	formatHour = SimpleDateFormat(" HH:mm")
	#formatDay = SimpleDateFormat(" dd. MM. HH:mm")
	formatDay = SimpleDateFormat(" dd MMM yyyy")
	formatMonth = SimpleDateFormat(" dd MMM yyyy")
	formatYear = SimpleDateFormat(" MMM yyyy")
	
	# Add the units
	#units.add(DateTickUnit(DateTickUnit.MILLISECOND, 5, formatMSec))
	#units.add(DateTickUnit(DateTickUnit.MILLISECOND, 50, DateTickUnit.MILLISECOND, 5, formatMSec))
	#units.add(DateTickUnit(DateTickUnit.MILLISECOND, 250, DateTickUnit.MILLISECOND, 50, formatMSec))
	#units.add(DateTickUnit(DateTickUnit.MILLISECOND, 500, DateTickUnit.MILLISECOND, 50, formatMSec))
	#units.add(DateTickUnit(DateTickUnit.SECOND, 1, DateTickUnit.MILLISECOND, 50, formatSec))
	#units.add(DateTickUnit(DateTickUnit.SECOND, 2, DateTickUnit.MILLISECOND, 250, formatSec))
	#units.add(DateTickUnit(DateTickUnit.SECOND, 5, DateTickUnit.MILLISECOND, 250, formatSec))
	#units.add(DateTickUnit(DateTickUnit.SECOND, 10, DateTickUnit.MILLISECOND, 500, formatSec))
	#units.add(DateTickUnit(DateTickUnit.SECOND, 30, DateTickUnit.SECOND, 2, formatSec))
	#units.add(DateTickUnit(DateTickUnit.MINUTE, 1, DateTickUnit.SECOND, 5, formatSec))
	#units.add(DateTickUnit(DateTickUnit.MINUTE, 2, DateTickUnit.SECOND, 10, formatMin))
	#units.add(DateTickUnit(DateTickUnit.MINUTE, 5, DateTickUnit.SECOND, 30, formatMin))
	#units.add(DateTickUnit(DateTickUnit.MINUTE, 10, DateTickUnit.MINUTE, 1, formatMin))
	#units.add(DateTickUnit(DateTickUnit.MINUTE, 20, DateTickUnit.MINUTE, 5, formatMin))
	#units.add(DateTickUnit(DateTickUnit.MINUTE, 30, DateTickUnit.MINUTE, 5, formatMin))
	#units.add(DateTickUnit(DateTickUnit.HOUR, 1, DateTickUnit.MINUTE, 5, formatHour))
	#units.add(DateTickUnit(DateTickUnit.HOUR, 2, DateTickUnit.MINUTE, 10, formatHour))
	#units.add(DateTickUnit(DateTickUnit.HOUR, 4, DateTickUnit.MINUTE, 30, formatHour))
	#units.add(DateTickUnit(DateTickUnit.HOUR, 6, DateTickUnit.HOUR, 1, formatDay))
	#units.add(DateTickUnit(DateTickUnit.HOUR, 12, DateTickUnit.HOUR, 2, formatDay))
	units.add(DateTickUnit(DateTickUnit.DAY, 1, DateTickUnit.HOUR, 4, formatDay))
	units.add(DateTickUnit(DateTickUnit.DAY, 2, DateTickUnit.HOUR, 4, formatDay))
	units.add(DateTickUnit(DateTickUnit.DAY, 7, DateTickUnit.DAY, 1, formatDay))
	units.add(DateTickUnit(DateTickUnit.DAY, 14, DateTickUnit.DAY, 1, formatDay))
	units.add(DateTickUnit(DateTickUnit.MONTH, 1, DateTickUnit.DAY, 1, formatDay))
	units.add(DateTickUnit(DateTickUnit.MONTH, 2, DateTickUnit.DAY, 7, formatMonth))
	units.add(DateTickUnit(DateTickUnit.MONTH, 3, DateTickUnit.DAY, 14, formatMonth))
	units.add(DateTickUnit(DateTickUnit.MONTH, 6, DateTickUnit.MONTH, 1, formatMonth))
	units.add(DateTickUnit(DateTickUnit.YEAR, 1, DateTickUnit.MONTH, 1, formatYear))
	units.add(DateTickUnit(DateTickUnit.YEAR, 2, DateTickUnit.MONTH, 3, formatYear))
	
	#chartUtils.setDateTickUnits(chart, "", units = units)	
	#chartUtils.setDateTickUnits(chart, "", units = units)
	#this chartUtils is custom script in project Script library project.chartUtils
	project.chartUtils.setDateTickUnits(chart,"", units = units)	
	

```
