Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Tip |
---|
This wpf WPF control was developed in order to present a line bar chart with line. |
Presentation
The BarAndSplineCustomChart control is a custom chart designed to display historical history values for a given tag in column format and with a row that touches the history values on the chart.
Image RemovedImage Added
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";
Image ModifiedWhen you open the component selection screen, select the BarAndSplineCustomChart control;
Image ModifiedInsert 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, you must it is necessary to access the control from your Uid. To take get a reference from the control to use it, use the following script:
Paste code macro | ||
---|---|---|
| ||
SPIN.ActionNet.View.Wpf.Charts.BarAndSplineCustomChart barAndSplineCustomChart1 = this.CurrentDisplay.GetControl("barAndSplineCustomChart1") as SPIN.ActionNet.View.Wpf.Charts.BarAndSplineCustomChart; if(barAndSplineCustomChart1 != null){ //... code goes here } |
Then the data needs to be passed to the control. It has a function for passing data from a datatable to the control. Your subscription signature can be found checked below:
Paste code macro | ||
---|---|---|
| ||
public void ApplyHistorianData(string tagName, DataTable histValues){} |
Where:
tagName: refers to the search tag. This parameter is used for the Chart Header of the chart.
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:
Paste code macro | ||
---|---|---|
| ||
string tagName = @"SE01\TR01\tag1.MED.MW"; DataTable result = GetHistorianMeasures(tagName); if(result != null && result.Rows.Count > 0) barAndSplineCustomChart1.ChartControl.ApplyHistorianData(tagName, result); |
Note |
---|
Attention: It is extremely important that the table follows the expected format with two columns, namelybeing:
Tables that do not support this format can have unexpected consequences for the chart. |
This sample- specific application of the example used the Spin toolkit to search for measures for measurements of a given certain period (last 10 days). The full complete code for this application can be checked below:
Paste code macro | ||||
---|---|---|---|---|
| ||||
using SPIN.ActionNet.View.Wpf.Charts; public void DisplayOpening() { } public void DisplayIsOpen() { } public void DisplayClosing() { } ////This method is only called on Dialog displays public bool DialogOnOK() { return true; } public DataTable GetHistorianMeasures(string tagName){ DataTable result = null; try{ DateTime startDate = DateTime.Now.AddDays(-10); result = @Script.Class.CustomMeasures.GetMeasures(tagName, startDate, DateTime.Now, 10); } catch(Exception ex){ @Info.Trace(ex.Message); } return result; } public void ButGetSampleData_Click(object sender, System.Windows.Input.InputEventArgs e) { SPIN.ActionNet.View.Wpf.Charts.BarAndSplineCustomChart barAndSplineCustomChart1 = this.CurrentDisplay.GetControl("barAndSplineCustomChart1") as SPIN.ActionNet.View.Wpf.Charts.BarAndSplineCustomChart; if(barAndSplineCustomChart1 != null){ string tagName = @"SE01\TR01\tag1.MED.MW"; DataTable result = GetHistorianMeasures(tagName); if(result != null && result.Rows.Count > 0) barAndSplineCustomChart1.ChartControl.ApplyHistorianData(tagName, result); } } |
Paste code macro | ||||
---|---|---|---|---|
| ||||
using SPIN.ActionNet.Biz.Toolkit.Reports; using System.Threading.Tasks; public DataTable GetMeasures(string tagName, DateTime startDate, DateTime endDate, int interval) { List<string> tagNames = new List<string>(); tagNames.Add(tagName); DataTable result = Measures.GetReport(tagNames,startDate, endDate, interval); return result; } |
On this page:
|
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. This is the Timestamp axis. 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. This is the Values Axis. 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 |
Scroll ignore | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
On this page: |