Change each bar width in histogram chart

If you look closely, you'll see that the last bar isn't being rendered at all. This is why the label isn't there. The reason the last bar is missing, is because there is no end date. If you want the last bar to render, you will need to supply an extra row to the bar table with some arbitrary start date number. Perhaps Now()? In any case, the range will always need to be one less than the row count, or you will go out of bounds when making the x positioning calculation.

In your rendering the end date for each bar is assumed to be the start date of the next bar.

I understood. i will alter the dataset to get the output
thanks

1 Like

You could also change it to this:

	for row in range(0, labelData.rowCount):
		text = str(labelData.getValueAt(row, 1))
		startTime = float(barData.getValueAt(row, 0).getTime())
		if row != labelData.rowCount:
			endTime = float(barData.getValueAt(row + 1 , 0).getTime())
		else:
			endTime = plot.domainAxis.upperBound

This would make the upper bound of the domain axis the end date for the next bar, and then, it would render this way:

...or perhaps it would be more pythony to write it this way:

startTime = float(barData.getValueAt(row, 0).getTime())
endTime = float(barData.getValueAt(row + 1, 0).getTime()) if row != labelData.rowCount else startTime

Either way, it would put the last WO Number right at the end of the chart where it belongs.

2 Likes

I think I would duplicate the last line in data to force it to show as a workaround maybe, or create a dummy row.