Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

This wpf control was developed in order to present a bar chart with line.

Presentation

The BarAndSplineCustomChart control is a custom chart designed to display historical values for a given tag in column format and with 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

  1. Insert the file "SPIN. ActionNet.View.Wpf.Charts.dll" in the WpfControls folder of the installation (typically under "C:\Program Files (x86)\SPIN\Action.Net\an-x.x\WpfControls\") if it does not exist.

  2. Open the project of Action.Net where the control will be used;

  3. In the "Draw" tab, choose the page where the control will be used;

  4. In the toolsidebar, choose the item "Insert Component";

    Image Modified
  5. When you open the component selection screen, select the BarAndSplineCustomChart control;

    Image Modified
  6. Insert the control into the screen and scale it.

  7. Select the control and insert a Uid into it. This is what will be used in the code-behind to pass the data to the chart.

  8. Set up the code in the screen code-behind:

Initially, you must access the control from your Uid. To take a reference from the control to use it, use the following script:

Paste code macro
languagecs
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 can be found below:

Paste code macro
languagecs
public void ApplyHistorianData(string tagName, DataTable histValues){}

Where:

tagName: refers to the search tag. This parameter is used for the 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 compatible with the types float or Double.

This function can be called as shown below:

Paste code macro
languagecs
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, namely:

  • 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 sample-specific application used the Spin toolkit to search for measures for a given period (last 10 days). The full code for this application can be checked below:

Paste code macro
languagecs
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);		
	}
	
}
Scroll ignore
scroll-viewporttrue
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-htmltrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue

On this page:

Table of ContentsminLevel

1

maxLevel3
2false