windows 64bit2020-09-07T13:35:41AdnQywADAAAAAAAAAAAAFgAAAZwAAAI2AAAAAAAAABYAAAGcAAACNgAAAAAAAAAAB4AAAAAAAAAAFgAAAZwAAAI2AdnQywADAAAAAAAAAAAAFgAAAZwAAAA7AAAAAAAAABYAAAGcAAAAOwAAAAAAAAAAB4AAAAAAAAAAFgAAAZwAAAA7
1024
768
5000
area
number
SELECT * FROM plotsample
mapToValue
cumAvg = 0;
function mapToValue(index,srcValue)
{
// Make sure we always reset our global variable for the first index
if (index === 0)
{
cumAvg = 0;
}
cumAvg = (srcValue + index * cumAvg) / (index + 1);
return cumAvg;
}
// This script generates a line plot using nvd3.js (which builds on d3.js).
// You are free to customize as you wish using any nvd3 or d3 functionality.
// For more information about these libraries, see the documentation below:
//
// http://nvd3-community.github.io/nvd3/examples/documentation.html
// http://nvd3.org/examples/line.html.
// http://d3js.org/
//
// All inputs available to your CreateChart operation are available via the
// "ws.inputs" variable, and a number of extra utility functions are available
// in the "ws" variable.
/**
* Generates an array of objects, each of which represents a line on our graph.
* Modify this function to source any data you wish from the "inputs" object.
*/
ws.createData = function() {
// Iterate over each of our items and add it to an array which we will return.
var plotItems = [];
for (var i = 0; i < ws.inputs.LineItems.length; i++) {
// Check to make sure our source dimensions match.
var lineItem = ws.inputs.LineItems[i];
if (lineItem.XValues.length !== lineItem.YValues.length) {
console.log('ERROR: SourceX and SourceY dimensions for line item "' + ws.inputs.LineItems[i].Key + '" do not match.');
continue;
}
// Create the data series data.
var series = [];
for (var j = 0; j < lineItem.XValues.length; j++) {
series.push({
x: lineItem.XValues[j],
y: lineItem.YValues[j]
});
}
// Create our plot item.
var key = (lineItem.Key === undefined || lineItem.Key.length === 0) ? "Series " + i : lineItem.Key;
plotItems.push({
area: false,
values: series,
key: key,
strokeWidth: 2.0,
classed: lineItem.ClassName
});
}
return plotItems;
};
/**
* Creates our line plot using the nvd3 lineChart model and sets up the axes.
*/
ws.addChart(function() {
// This controls the type of chart we're using. See the nvd3 docs for the list of chart types.
var chart = nv.models.lineChart();
chart.options({
duration: 250,
useInteractiveGuideline: true,
color: d3.scale.category20().range()
});
chart.legend.margin({ top: 15, bottom: 15 });
// Set up our scales.
chart.xScale(d3.scale.linear());
chart.yScale(d3.scale.linear());
// Set up our chart axes. For information on the formatting used on the x and y axes, see
// the d3 documentation here: https://github.com/mbostock/d3/wiki/Formatting
chart.xAxis.axisLabel(ws.inputs.XAxisLabel).tickFormat(d3.format(',.1f')).staggerLabels(false);
chart.yAxis.axisLabel(ws.inputs.YAxisLabel).tickFormat(d3.format(',.2f'));
ws.setTitle(ws.inputs.Title);
return chart;
});
text {
font: 12px sans-serif;
}
.dashed {
stroke-dasharray: 5,5;
}
#title {
font: 14px sans-serif;
font-weight: bold;
text-decoration: underline;
}
Modify and Save Tutorial
Number
Cumulative Area
ws:outputimage.png
SELECT * FROM plotsample
cumulativeAverage
0
0
ws:newplotsample1.csv
,
1
ws:plotsample.csv
,
1
0
0
plotsample
0