Bar chart, selecting a specific bar

Hi there.

Does anybody knows how to select a specific bar in a “bar chart” component?. I need to display a pop-up window once the bar be selected by mouse. The vertical axis means the finish good, so when user selects that bar, I would show a report related to that product.

Hi Roberto,

Here is an example which we’ve used to drill down on a bar chart utilizing classes from the jfee chart - simply paste it in a mousePressed event script on the chart. In the chartMouseClicked method the columnKey and data can be used to pass to a report. Details on the chart object can be found at http://www.jfree.org/index.html.

# import mouse listener
from org.jfree.chart import ChartMouseListener
# define mouse listener class
class myChartMouseListener(ChartMouseListener):
	# mouse moved method
	def chartMouseMoved(self, cme):
		pass
	
	# mouse clicked method
	def chartMouseClicked(self, cme):
		# get clicked information
		chartEntity = cme.getEntity()
		# if clicked on data
		if chartEntity is not None:
			columnKey = chartEntity.getColumnKey()
			data = chartEntity.getDataset()
		# close mouse listener
		chart = event.source
		chart.removeChartMouseListener(self)
# get source of event
chart = event.source
# invoke mouse listener
chart.addChartMouseListener(myChartMouseListener())
3 Likes

Can you please help me how we can use it to get bar chart on specific bar selection. i didnt see any MouseClicked event on XY chart in ignition perspective.