Okay, lets back up a few steps and make sure that we understand everything.
-
The error that you were originally encountering on Line 5 was saying that *
operator is not supported on NoneType
, in the context of your code, this means that CustomTrends.getMaximum()
returned a NoneType object. Can you provide the code for this method?
-
If I run system.perspective.print(type(self.props.series[0].data))
on a this, while it contains a dataset object, the output I see in the console is
class com.inductiveautomation.ignition.common.JsonDataset
So, either you're object isn't what you thought it is, or your code doesn't match what @dkhayes117 provided.
Assuming that the functions CustomTrends.getMinimum()
and CustomTrends.getMaximum()
do something like:
def getMinimum(ds):
#ds is expected to be a Dataset type object
return min(ds.getColumnAsList(ds.getColumnIndex('column')))
def getMaximum(ds):
#ds is expected to be a Dataset type object
return max(ds.getColumnAsList(ds.getColumnIndex('column')))
Then the following code properly checks that this is a true valueChange and that the dataset is not empty.
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
if all([previousValue, currentValue,currentValue.value,currentValue.value.rowCount]):
self.props.plots[0].axes[0].min = CustomTrends.getMinimum(currentValue.value)
self.props.plots[0].axes[0].max = CustomTrends.getMaximum(currentValue.value) * 1.06
However, why not just use expression bindings here:
coalesce(min({this.props.series[0].data},'ColumnName'),100)
coalesce(max({this.props.series[0].data},'ColumnName'),100) * 1.06
These expressions will return the min/max if there is data, and the provided default value otherwise.