How am I supposed to show tag history through XYChart? Should I make a binding in dataSources property?
Thanks for your help
+1 to this question
Any documentation about?
From the demo, this page does tag history in a chart:
http://demo.inductiveautomation.com/data/perspective/client/OnlineDemo/feature/history/charts
We just posted the demo project files. Hopefully taking a look at them will provide a little guidance.
Note that we have two major things that we're working on improving in this area:
- Tag History Binding UI (you won't need to create objects like you do today)
- Improving chart components
This will mean that the examples will be obsolete before our final release. However, if you wanted to do this in the mean time, you can certainly follow what we did there for the demo.
Thanks a lot. One more question: is queryHistory function something you have defined in gateway scripts (not included in demo project files)? Copy/Paste of the function could be helpful too.
Sorry for the late response but, the queryHistory() function that is used in the demo project is located in the Project > Scripting > Script Library > history file on the project browser for the demo project. Although I will warn you, it is very complex and probably more than what a normal history binding should look like.
I’ve attached a more simple example of history binding using the XYChart. testHistory.proj (13.8 KB) This project has one view with 2 XYCharts. One using the tag history binding, and the other using a property binding that then calls the system.tag.queryTagHistory() function in a script transform for more flexibility.
This project relies on a a tag with tag path Sine0 in the default tag provider. I just grabbed the one in the Generic Simulator and threw it on the root of the tag browser. Doing just that should make the project work.
For the base case of just getting history to show, there is only two things that need to change from the defaults on the XYChart:
First, bind the “example” dataSource of the XYChart to the tag you have history on (note, as of now it does require that the tag path contain the tag provider even if it’s [default]) In the project, this is [default]Sine0
Second, on the “series” array in the XYChart, pick one and go to it’s “data” property. There, change the x to “t_stamp” and y to the tag path(in this example project it’s just Sine0). This data object is what actually defines the data points for the specific series. Notice the source says “example” which corresponds to the example dataSource. The x and y parts correspond to the column names of the dataset that makes up the example dataSource.
Those two steps will give you the very basic chart that shows historical data. After that, you can dive into the other options to see what they do, they mostly do with how the chart looks and what the labels say.
In the project provided some optional steps are also provided as an example, such as the polling object on the top chart for history binding and the ability to change the range of data viewed with the bottom chart. Check it out, it hopefully is a lot easier to navigate than the demo project to get started with tag history on the XYChart.
Is this functionality going to be simplified soon?
Should we expect the method to display historical data to be like this at Ignition 8 launch?
I’m finding the XY chart equally difficult to configure… there are just so many options and they’re all deeply nested within each other making it a slow process to configure.
I used online json editor.
Adding things to arrays in the designer gets exponentially slower with each new item. I made a chart with over 100 series (customer request) on it and then copy/pasted the json into the series. If you try to add array element in designer it takes 10 min or so. In other words, json editor is the only way to go. Also, the best way I’ve found to hide series on a chart is to dynamically adjust the axis assigned to a series. If the axis is blank the series hides.
When you copy/paste things from designer they are in your paste buffer as json code. So you can actually copy/paste json into your designer. Keep backups of your screens and test on those first. Pasting incorrect json can pretty much pave your view. Also, you can right click on views to close them without saving. Just passing that on in case you didn’t know. I discovered it in a freak notepad accident.
I’m sure there’s a good way to do all of this with python but I haven’t had time to play with it. When I started delivering Perspective stuff to a customer they have been throwing all kinds of interesting requests at me so I’ve been busy trying to figure out how to satisfy them. It’s like drinking from a fire hose but it’s been a fun adventure.