This WPF control was developed in order to present a line bar chart.
Presentation
The BarAndSplineCustomChart control is a custom chart designed to display history values for a given tag in column format and with a row that touches the history values on the chart.
How to use
Minimum requirements
Action.Net version 9.2.28.1 or later;
Configuration
Insert the file "SPIN. ActionNet.View.Wpf.Charts.dll" in the WpfControls folder of the installation (typically in "C:\Program Files (x86)\SPIN\Action.Net\an-x.x\WpfControls\") if it does not exist.
Open the project of the Action.Net where the control will be used;
In the "Draw" tab, choose the page where the control will be used;
In the toolbar, choose the item "Insert Component";
When you open the component selection screen, select the BarAndSplineCustomChart control;
Insert the control on the screen and scale it.
Select the control and enter a Uid for it. This is what will be used in the code-behind to pass the data to the graph.
Configure the code in the screen code-behind:
Initially, it is necessary to access the control from your Uid. To get a reference from the control to use it, use the following script:
Then the data needs to be passed to the control. It has a function for passing data from a datatable to the control. Your signature can be checked below:
Where:
tagName: refers to the search tag. This parameter is used for the Chart Header.
histValues: refers to a table whose format consists of the first column with values compatible with the type DateTime and the second column with values that are compatible with the types float or Double.
This function can be called as shown below:
Attention: It is extremely important that the table follows the expected format with two columns, being:
First column with values compatible with type DateTime; and
Second column with values compatible with types float or Double.
Tables that do not support this format can have unexpected consequences for the chart.
This specific application of the example used the Spin toolkit to search for measurements of a certain period (last 10 days). The complete code for this application can be checked below:
BarAndSplineCustomChart Members
In the control, users were exposed to some properties and methods for using the chart. In the following tables, you can view the names of properties and methods and their descriptions:
Properties
Name
Description
TagName
Name of the tag to which the chart refers. This name will be shown in the chart header
HistValues
Observable list of objects of type HistorianValues that contains tag value and timestamp information
XAxisLabelFormat
Corresponds to the format of the text you want for the X-axis label.
The default format for this property is "MMM-dd HH:mm".
XAxisLabelRotationAngle
Corresponds to the desired angle of rotation for the X-axis label.
YAxisLabelFormat
Corresponds to the format of the text you want for the Y-axis label.
The default format for this property is "N0".
YAxisLabelRotationAngle
Corresponds to the desired angle of rotation for the label of the Y axis.
Methods
Name
Description
ApplyHistorianData(string, DataTable)
A method that transforms the parameters passed into rows and columns of the chart and applies this information to the chart.
Parameters
tagName: refers to the search tag. This parameter is used for the Chart Header.
histValues: refers to a table whose format consists of the first column with values compatible with the type DateTime and the second column with values that are compatible with the types float or Double