Hi there,
Need some guidance, I'm populating a Bar chart in the report by a SQL Query, and I tried the Script in the bar chart in the Reports to change the color of the Segments of the Bar depending on the Value, But I would like Change the color depending on the Category label:
I want the bar "Starved" to be always yellow, "Blocked" Blue, "Cycling" Green, "InFault" Red and so on.
What will be the correct script to check that??, this is the script I tried to change the colours of the bars, depending on Value:
from java.awt import Color
a = 1
#gets the underlying dataset in the chart
ds = chart.getPlot().getDataset()
print ds.columnCount
# gets the plot
plot = chart.getCategoryPlot()
#gets the Barrenderer object
renderer = plot.getRenderer()
#Loop Through dataset and check value and assign series colors
for row in range(ds.rowCount):
print row
value = float(ds.getValue(row, 0))
print value
if value >= 100.0:
print 'Row %d should be green'%row
renderer.setSeriesPaint(row, Color.GREEN)
if value <= 99.9 and value >= 88.0:
print 'Row %d should be yellow'%row
renderer.setSeriesPaint(row,Color.YELLOW)
if value <= 87.9:
print 'Row %d should be red'%row
renderer.setSeriesPaint(row,Color.RED)
else:
a = 0