[Question] XYChart with Tag History

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.

1 Like