Hi,
I have a window with barchart as below in vision,
I would like to avoid the elongated bar( I know it is elongates as it has only one column value)
But is there a way to avoid this?
Hi,
I have a window with barchart as below in vision,
You could eliminate some of it by adding a blank row to your chart's dataset. Beyond that, I imagine that you could probably achieve this by manipulating your category margins with some sort of algorithm.
For example, if the catAxisUppermargin property were bound to a custom property (call it widthAdjustment). Then, the configureChart extension function could be used in the following way to manipulate this variable:
maximumBars = 10.0
minimumWidthAdjustment = .05
maximumWithAdjustment = .7
chartWidth = 1.0 - (float(self.data.rowCount)/maximumBars)
if chartWidth < minimumWidthAdjustment:
self.widthAdjustment = minimumWidthAdjustment
elif chartWidth > maximumWithAdjustment:
self.widthAdjustment = maximumWithAdjustment
else:
self.widthAdjustment = chartWidth
Note: this example algorithm is not something I've tested in any realistic way, it's just the first idea that popped into my head when I read this problem.
Edit:
After pondering this for a few minutes, I imagine that it would be much better to apply this idea to a propertyChange event script, so it the chart isn't processing this calculation excessively:
if event.propertyName == "data":
maximumBars = 10.0
minimumWidthAdjustment = .05
maximumWithAdjustment = .7
chartWidth = 1.0 - (float(event.source.data.rowCount)/maximumBars)
if chartWidth < minimumWidthAdjustment:
event.source.widthAdjustment = minimumWidthAdjustment
elif chartWidth > maximumWithAdjustment:
event.source.widthAdjustment = maximumWithAdjustment
else:
event.source.widthAdjustment = chartWidth
Another idea: you could use the renderer's .setMaximumBarWidth()
method in the configureChart extension function:
def configureChart(self, chart):
chart.getPlot().getRenderer().setMaximumBarWidth(0.20)