How to change color of timestamp and line of X-Trace in Chart

I'm not sure how you could change the background color of the crosshair label, but obviously, you already know how to add your own annotation labels, so I'll tell you how to get rid of the timestamp label at the bottom, and you can replace it with a label of your own.

# Written for the configureChart extension function 
#def configureChart(self, chart):
	from java.text import SimpleDateFormat
	from org.jfree.chart.axis import DateAxis
	pureDateFormat = SimpleDateFormat("")
	pureTimeFormat = SimpleDateFormat("")			
	dateAxis = DateAxis()
	plot = chart.getPlot()
	plot.setDomainAxis(dateAxis)
	plotField1 = plot.getClass().getDeclaredField('dateFormat')
	plotField2 = plot.getClass().getDeclaredField('timeFormat')
	plotField1.setAccessible(True)
	plotField2.setAccessible(True)
	plotField1.set(plot, pureDateFormat)
	plotField2.set(plot, pureTimeFormat)

I originally developed this script for changing the date format of the timestamp label to "yyyy/MM/dd", but I found that if you change the date and time formats to empty strings, the label disappears.

Result:
image

1 Like