-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathexample2.ts
32 lines (28 loc) · 1.07 KB
/
example2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as supportLib from './supportLib';
import * as pbPlots from './pbPlots';
var series = pbPlots.GetDefaultScatterPlotSeriesSettings();
series.xs = [-2, -1, 0, 1, 2];
series.ys = [2, -1, -2, -1, 2];
series.linearInterpolation = true;
series.lineType = "dashed".split('');
series.lineThickness = 2;
series.color = pbPlots.GetGray(0.3);
var settings = pbPlots.GetDefaultScatterPlotSettings();
settings.width = 800;
settings.height = 600;
settings.autoBoundaries = true;
settings.autoPadding = true;
settings.title = "x^2 - 2".split('');
settings.xLabel = "X axis".split('');
settings.yLabel = "Y axis".split('');
settings.scatterPlotSeries = [series];
var imageReference = pbPlots.CreateRGBABitmapImageReference();
var errorMessage = new pbPlots.StringReference();
var success = pbPlots.DrawScatterPlotFromSettings(imageReference, settings, errorMessage);
if(success){
var pngdata = pbPlots.ConvertToPNG(imageReference.image);
supportLib.WriteToFile(pngdata, "example2.png");
pbPlots.DeleteImage(imageReference.image);
}else{
console.error(errorMessage.stringx.join(''));
}