How to trend the future

Good morning guys,

I’m searching in the old topics but I can’t find anything. I would like to know if is possibile to show in a chart future values that I’m predicting.

I think maybe I could create a dataset with values and timestamp but I have no idea how to put them in a trend or even if this is the right way to do it.

Thanks for the help.

Sure you can do this. If you are using current data to then predict future values then you would write a script to first get your current data, then run your prediction algorithm to get new values, append these to the current dataset (if you want to show current trend along side the predictions) and set the data property of the chart to your new dataset. If you have some sample data or details I can help you get started if needed.

3 Likes

Thanks for your reply!

Actually I would like to do some test to see if is possible to do it, because the data will be available not in ignition but from an external source, I should just manage them to insert in the chart with a script I guess as you say.

I spent some time to figure out how to do what you suggest, I see that using a component “Chart” I can insert the dataset in the custom property and automatically I see them in the Chart Customizer page, I would like to ask if should be possibile doing something like this with an “Easy Chart”.

Thanks again for the help.

Any ideas about how to pass custom dataset to an Easy Chart?

Thanks for the help guys

Your problem has little to do with the chart. It is all to do with the dataset. Forget about the chart and concentrate on your data.

You said you have an external source. You need to figure out how to connect to that. Go to your gateway, Config, Databases, Connections, Create new database connection and see if you can create a connection to your external database.

If you succeed with that then you need to decide if a Named Query will suit (best option) or a scripted query will suit better. Either way you need to write a query using the database connection created above.

You cannot.

Use the classic chart for this use-case.

This is not a problem for me, there is a person who care about it with REST calls. I will have the data and together we will figure out how to create the dataset to pass to the Chart (not the easy chart at this point).

I wonder is with Chart should be possibile create a trend exactly like this, with lines and dot with a number inside. Do you have any idea how should be possibile to do something like it?

Ok thanks for the help!

Hmm. Haven’t seen that one. But it should be possible with a custom renderer thanks to Ignition using the JFreeChart API in Vision.

Some topics to review for ideas:

https://forum.inductiveautomation.com/search?q=org.jfree.chart.renderer

1 Like

pturmel, thanks for the input.

In this days we’ve tried to figure out how to make the chart as I showed but we cannot find a way to do it.

For example, we have found a couple of topic that talk about this and we have made some tests with this code:

	from org.jfree.chart.labels import StandardXYItemLabelGenerator

	
	class MyLabelGenerator(StandardXYItemLabelGenerator):
		def generateLabel(self, xyds, series, item):
			return "s%dp%d" % (series, item)
	

	renderer = chart.plot.renderer
	renderer.setItemLabelGenerator(MyLabelGenerator())
	renderer.setBaseItemLabelsVisible(True)

and this

	from org.jfree.chart.renderer.xy import XYDotRenderer	
	
	plot = chart.getXYPlot()
	
	dotRenderer = XYDotRenderer()
	dotRenderer.setDotWidth(10)
	dotRenderer.setDotHeight(10)
	
	
	renderer = chart.plot.renderer
	renderer.setItemLabelGenerator(MyLabelGenerator())
	renderer.setBaseItemLabelsVisible(True)			
	plot.setRenderer(dotRenderer)	

If I put the code individually in the Extension Functions of the Chart they work, but together like this they don’t

	from org.jfree.chart.labels import StandardXYItemLabelGenerator

	
	class MyLabelGenerator(StandardXYItemLabelGenerator):
		def generateLabel(self, xyds, series, item):
			return "s%dp%d" % (series, item)
	

	renderer = chart.plot.renderer
	renderer.setItemLabelGenerator(MyLabelGenerator())
	renderer.setBaseItemLabelsVisible(True)
	
	
	
	from org.jfree.chart.renderer.xy import XYDotRenderer	
	
	plot = chart.getXYPlot()
	
	dotRenderer = XYDotRenderer()
	dotRenderer.setDotWidth(10)
	dotRenderer.setDotHeight(10)
	
	
	renderer = chart.plot.renderer
	renderer.setItemLabelGenerator(MyLabelGenerator())
	renderer.setBaseItemLabelsVisible(True)			
	plot.setRenderer(dotRenderer)	

How could be possible to make them work together?

In the case it works, I would like to ask you how to create the chart using this dataset:

  • the X axis should be the t_stamp
  • the Y axis should be the n_aut (so in this way I have a horizontal line)
  • and the label of the point should be fase

Thanks for the help!

I’m not entirely sure how the dataset you’ve given translates into the output that you are wanting.

  1. I believe that you should be sub-classing XYLineAndShapeRenderer, because you want to draw both the line and the shape.
  2. Because you will always be drawing a horizontal line, there is no need to provide the n_aut data, that is just how the renderer will work given the data that is needed for the dataset.
  3. In the image you provided there are 4 lines each with 2 data points. Will the data points always come in pairs? The dataset you provided has an odd number of entries so I am unsure.
  4. What determines if the data point is filled or not? Is this the same thing that determines if the line is dashed?