I know I can sort of achieve this using the standard Bar Chart but as per this example, there is no data between 10am and 9am the next day, so the graph shows a gap, which is exactly what I want. But had I supplied the same data into the standard Bar Chart then I wouldn’t have got the gap.
I hope this makes sense. Is there a way to achieve this?
Having tried to do this using the standard bar chart it is not ideal at all, particularly when you get data that spans over a few days. I can’t set my categories to be just hours, e.g. “08:00”, “09:00”, “10:00” etc because as soon as I get into the next day then any data at the same time gets grouped with data from the previous day, i.e. all the “08:00” data gets put together.
So I have to have my labels as “Tue 08:00”, “Tue 09:00” , … , “Wed 01:00”, “Wed 02:00” etc meaning the labels are getting long, so I rotate them to 90 degrees but it still displays every single one so it’s looking very cluttered and not very user friendly.
Plus as stated previously if I didn’t have any data for a particular hour it would just be missed, I wouldn’t automatically get a gap.
Hmm… for a purely visual effect you could add a dataset to the chart to hold the “stacked” data. Basically, you’d add to the previous values:
if event.propertyName=='Data':
dataIn=event.source.parent.getComponent('Chart').Data
headers = list(dataIn.getColumnNames())
pyData=system.dataset.toPyDataSet(dataIn)
newData=[]
for row in pyData:
newRow=[row[0],row[1]]
for col in range(2,len(row)):
newRow.append(row[col]+newRow[col-1])
newData.append(newRow)
event.source.parent.getComponent('Chart').StackedBar=system.dataset.toDataSet(headers,newData)
I say purely visual, because, of course, the subsequent values get changed.