# Change each bar width in histogram chart

**URL:** <https://forum.inductiveautomation.com/t/change-each-bar-width-in-histogram-chart/66847>\
**Category:** Ignition\
**Tags:** vision, scripting\
**Created:** [November 23, 2022, 11:49am UTC](https://forum.inductiveautomation.com/t/change-each-bar-width-in-histogram-chart/66847 "2022-11-23T11:49:56Z")\
**Posts on this page:** 4\
**Page:** 3

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 8, 2023, 9:16am UTC](https://forum.inductiveautomation.com/t/change-each-bar-width-in-histogram-chart/66847/42 "2023-03-08T09:16:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 8, 2023, 9:36am UTC](https://forum.inductiveautomation.com/t/change-each-bar-width-in-histogram-chart/66847/44 "2023-03-08T09:36:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 8, 2023, 9:42am UTC](https://forum.inductiveautomation.com/t/change-each-bar-width-in-histogram-chart/66847/45 "2023-03-08T09:42:20Z")

</div>

You could also change it to this:

```auto
	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:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/c/ac3de35ac30b62cfbc0bf882a34db453db4d4ff1.png)

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [April 21, 2023, 1:17pm UTC](https://forum.inductiveautomation.com/t/change-each-bar-width-in-histogram-chart/66847/46 "2023-04-21T13:17:09Z")

</div>

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

[Previous page](https://forum.inductiveautomation.com/t/change-each-bar-width-in-histogram-chart/66847.md?page=2)
