Skip to content

Commit 7e851cd

Browse files
committed
Fixed various examples.
Exposed chart def decls from the package. Chart options are now passed to the chart via JSON. The makeStatic flag and a new flag showChartDef that displays the expanded/formatted chart def.
1 parent 4ebefd9 commit 7e851cd

14 files changed

Lines changed: 79 additions & 31 deletions

examples/example-10.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DataFrame } from 'data-forge';
1313
import '../src/index';
1414
import * as fs from 'fs-extra';
1515
import * as path from 'path';
16-
import { ChartType, IAxisMap } from '../src/chart-def';
16+
import { ChartType } from '../src/index';
1717

1818
const outputName = path.basename(__filename, ".ts");
1919
const outputPath = path.join("./output", outputName);
@@ -34,14 +34,16 @@ async function main(): Promise<void> {
3434

3535
const plot = df.plot()
3636
.chartType(ChartType.Scatter)
37-
.y("versicolor_y")
38-
.seriesLabel("Versicolor")
39-
//todo: .color("blue")
40-
.x("versicolor_x")
41-
.y("setosa_y")
42-
.seriesLabel("Setosa")
43-
//todo: .color("green")
44-
.x("setosa_x");
37+
.y()
38+
.addSeries("versicolor_y")
39+
.label("Versicolor")
40+
//todo: .color("blue")
41+
.setX("versicolor_x")
42+
.y()
43+
.addSeries("setosa_y")
44+
.label("Setosa")
45+
//todo: .color("green")
46+
.setX("setosa_x");
4547

4648
await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
4749
await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });

examples/example-4.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ async function main(): Promise<void> {
3131
//console.log(df.toString());
3232

3333
const plot = df.plot()
34-
.x("date")
35-
.y("data1")
36-
.y("data2");
34+
.x()
35+
.setSeries("date")
36+
.y()
37+
.addSeries("data1")
38+
.y()
39+
.addSeries("data2");
3740
await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
3841
await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
3942
}

examples/example-5.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { DataFrame } from 'data-forge';
1212
import '../src/index';
1313
import * as fs from 'fs-extra';
1414
import * as path from 'path';
15-
import { ChartType } from '../src/chart-def';
15+
import { ChartType } from '../src/index';
1616

1717
const outputName = path.basename(__filename, ".ts");
1818
const outputPath = path.join("./output", outputName);

examples/example-6.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { DataFrame } from 'data-forge';
1212
import '../src/index';
1313
import * as fs from 'fs-extra';
1414
import * as path from 'path';
15-
import { ChartType } from '../src/chart-def';
15+
import { ChartType } from '../src/index';
1616

1717
const outputName = path.basename(__filename, ".ts");
1818
const outputPath = path.join("./output", outputName);

examples/example-7.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { DataFrame } from 'data-forge';
1111
import '../src/index';
1212
import * as fs from 'fs-extra';
1313
import * as path from 'path';
14-
import { ChartType } from '../src/chart-def';
14+
import { ChartType } from '../src/index';
1515

1616
const outputName = path.basename(__filename, ".ts");
1717
const outputPath = path.join("./output", outputName);

examples/example-8.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { DataFrame } from 'data-forge';
1111
import '../src/index';
1212
import * as fs from 'fs-extra';
1313
import * as path from 'path';
14-
import { ChartType } from '../src/chart-def';
14+
import { ChartType } from '../src/index';
1515

1616
const outputName = path.basename(__filename, ".ts");
1717
const outputPath = path.join("./output", outputName);
@@ -30,8 +30,10 @@ async function main(): Promise<void> {
3030

3131
const plot = df.plot()
3232
.chartType(ChartType.Scatter)
33-
.x("versicolor_x")
34-
.y("versicolor_y");
33+
.x()
34+
.setSeries("versicolor_x")
35+
.y()
36+
.addSeries("versicolor_y");
3537
await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
3638
await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
3739
}

examples/example-9.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DataFrame } from 'data-forge';
1313
import '../src/index';
1414
import * as fs from 'fs-extra';
1515
import * as path from 'path';
16-
import { ChartType, IAxisMap } from '../src/chart-def';
16+
import { ChartType } from '../src/index';
1717

1818
const outputName = path.basename(__filename, ".ts");
1919
const outputPath = path.join("./output", outputName);

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"homepage": "https://github.com/data-forge/data-forge-plot#readme",
3636
"dependencies": {
37-
"@data-forge-plot/apex": "0.0.26",
37+
"@data-forge-plot/apex": "0.0.30",
3838
"@data-forge-plot/chart-def": "^1.0.9",
3939
"@data-forge/serialization": "^1.0.0",
4040
"capture-template": "^1.1.10",

src/apply-defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ export function applyDefaults(inputChartDef: IChartDef, plotDefaults?: IPlotConf
117117
}
118118

119119
return chartDef;
120-
}
120+
}

0 commit comments

Comments
 (0)