RN01 XY Chart (NEBULA)
Outline
Nebula Visualization is a widgets library for data visualization in science, engineering and SCADA areas. XY diagrams draw two groups of numbers as a set of XY coordinates. XY diagrams show the relationship of two records.
Platforms: |
|
|||
Requirements: |
|
|||
Known limitations: |
|
|||
Status: |
|
|||
Extensibility: |
|
|||
Supported signal types: |
|
|||
Chart Parameters: |
|
|||
Plot Parameters: |
|
Compatible signal data
The XY chart provider supports struct signals, numerical arrays or simple numerical signals. Arrays signals with 2 members are usually the best choice for XY charts.
time;x;y 0.000000ms;0.3332716083675362;9.994444958828685 0.000010ms;0.3665845116956737;9.993278530881888 0.000020ms;0.3998933418663416;9.99200106660978 0.000030ms;0.43319772878176954;9.990612580206397 0.000040ms;0.46649730239355675;9.989113087099351 0.000050ms;0.4997916927067833;9.987502603949663 0.000060ms;0.5330805297841217;9.98578114865157 0.000070ms;0.5663634437499467;9.98394874033234 0.000080ms;0.599640064794446;9.982005399352042 0.000090ms;0.6329100231777278;9.979951147303336 0.000100ms;0.6661729492339299;9.977786007011224 0.000110ms;0.6994284733753277;9.975510002532795
Chart Configuration
You can modify the chart behavior under Preferences->impulse->Charts.
- You may add own charts or chart variants
- Modify existing charts (Chart Parameters)
- Title: No Title, Description, Plot Name, Plot Description.
- Options: Annotated, Show Legend, Show Title, Show Grid.
- Max Points: Limits the maximum number of points to be displayed.
- Nebula Script: Extend the chart with Java Script.
- Apply Script: Enables/Disables the Nebula scripting.
- Manual Fill: Disables the provider's default signal processing; instead, the script shall provide the display data.
You can extend the XY chart using scripts. To achieve this you have access to the nebula graph object.
// graph: XYGraph figure ( https://eclipse.org/nebula/widgets/visualization/visualization.php) // x,y,width,height: geometry // color, background: Colors // readable: input of IReadableSamples // simple modifications graph.primaryXAxis.setAutoScale(false); graph.primaryXAxis.setTitle("my x"); graph.primaryYAxis.setAutoScale(false); graph.primaryYAxis.setTitle("my y"); graph.primaryYAxis.setDashGridLine(true); graph.primaryYAxis.setShowMajorGrid(true);
If you check both "Apply script" and "Manual Fill", the script shall load the sample data into the chart (the standard data handling is disabled):
// add a trace - use "Manual Fill" flag to disable default traces importPackage(Packages.org.eclipse.nebula.visualization.xygraph.dataprovider); importPackage(Packages.org.eclipse.nebula.visualization.xygraph.figures); var traceDataProvider = new CircularBufferDataProvider(false); var length = Math.min(500, readable.getCount()); traceDataProvider.setBufferSize(length); for (var n = 0; n < length; n++) { var value = readable.compoundAt(n); if (!value.isNone()) { traceDataProvider.addSample(new Sample(value.getUnits(), value.floatValue())); } } var trace = new Trace("my trace", graph.primaryXAxis, graph.primaryYAxis, traceDataProvider); trace.setForegroundColor(color); graph.addTrace(trace);
Beside the chart parameters, you can set the default plot parameters. You can override them in the actual plot.
Plot Configuration
To display a chart in a given plot:
- Configure production/source to gain a compatible signal
- Set the plot type to "Chart",
- Configure the charts plot parameter ("Chart Style").
- Members : Identify the structure or array elements you want to display. Use a comma-separated list of all members, e.g.'X,Y'.
- Samples : Identify the samples you want to display. Use a comma-separated list of all sample indices, for example, '0,1,5-8'.
Signal script to define chart data
Use the following signal script example to prepare chart data using a FloatArray signal. You may use a Signal Script Production or a recJs file.
out.addMember( "x", null, ISample.FORMAT_DEFAULT); out.addMember( "y", null, ISample.FORMAT_DEFAULT); var array = java.lang.reflect.Array.newInstance(java.lang.Double.TYPE, 2); for (t=0; t < 100000; t += 10) { array[0] = Math.sin((t + 100) / 3000.0) * 10.0; array[1] = Math.cos((t + 100) / 3000.0) * 10.0; out.writeDoubleArray(t, false, array); }