SimplePlot constructor
Plots arrays
as polylines (curves), along with coordinate axes,
a coordinate grid and legend text.
plotDiv
- the html DivElement that will contain the plot.
plotAttr
- plot attributes controlling the appearance and layout of the
polylines. If null
, internal defaults are used.
xaxisAttr
- x axis attributes controlling the appearance and layout of the
x (horizontal) coordinate axis. If null
, internal defaults are used.
yaxisAttr
- y axis attributes controlling the appearance and layout of the
y (vertical) coordinate axis. If null
, internal defaults are used.
legendAttr
- attributes controlling the appearance and layout of the
text legend. If null
, internal defaults are used.
poly_colors
- these are the color in which arrays
get displayed. This
list may be bigger than the list a arrays
, but not smaller.
If null
, internal default colors are used.
See the example provided with this package how simple is it is to generate
the plot.
NOTE 1: Displaying more than a single array only makes sense if the value
ranges in the different arrays are commensurable, otherwise a simultaneous
plot is not meaningful.
NOTE 2: The sizes of the arrays may be different. The width of the plot
is computed from plotDiv
.
Implementation
SimplePlot(this.arrays, plotDiv, this.plotAttr, this.xaxisAttr,
this.yaxisAttr, this.legendAttr, this.poly_colors) {
// Set up the containers where the graphics is to be drawn
pl = PlotLayoutSVG(plotDiv, null);
createPolylines();
// Compute x and y axis for the first polyline
createAxes(polylines[0]);
legend = createLegend(legendAttr, poly_colors);
// append polylines the "data area" of the layout
for (int i = 0; i < arrays.length; i++) {
pl.dataArea.append(polylines[i].polylineContainer);
}
if (legendAttr != null) {
// append the legend to the "data area" of the layout
pl.dataArea.append(legend.legendContainer);
}
// append x axis, y axis and axes grid to the "plot area" of the layout
pl.plotArea.append(xaxis.labelsContainer);
pl.plotArea.append(yaxis.labelsContainer);
pl.plotArea.append(xaxis.xyGrid.gridContainer);
pl.plotArea.append(yaxis.xyGrid.gridContainer);
}