Rotating Bar Chart Labels?

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.


I just posted about this same problem earlier today, too.

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.

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

Thanks for the reply!

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

I can’t really answer for Vision, sorry!

Via Moving value label positions on chart bar graph? and, it seems like it should be doable via the chart component. Just got to try to figure it out…

1 Like

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.


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

Never had to do this, sorry.

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

In Chart Extension Functions->configureChart insert this code:

	# 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))
				return None

	plot = chart.getPlot()
	renderer = plot.getRenderer()

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

	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().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)	
1 Like