@@ -4,11 +4,9 @@ import { ISerializedDataFrame } from "@data-forge/serialization";
44import { exportTemplate , IExportOptions } from "inflate-template" ;
55import { captureImage , ICaptureOptions } from "capture-template" ;
66import { IPlotConfig , IAxisMap } from "./chart-def" ;
7- import { isObject , isString , isArray } from "./utils" ;
7+ import { isObject } from "./utils" ;
88import { ChartType , IChartDef , AxisType , HorizontalLabelPosition , VerticalLabelPosition , IAxisConfig , IYAxisSeriesConfig , IAxisSeriesConfig } from "@data-forge-plot/chart-def" ;
9- import { expandChartDef , expandYSeriesConfigArray } from "./expand-chart-def" ;
10- import { ISeriesConfig } from "data-forge/build/lib/series" ;
11- import { appendFile } from "fs" ;
9+ import { expandChartDef } from "./expand-chart-def" ;
1210import { applyDefaults } from "./apply-defaults" ;
1311
1412const DEFAULT_CHART_PACKAGE = "@data-forge-plot/apex" ;
@@ -251,13 +249,19 @@ export interface IYAxisConfigAPI extends IAxisConfigAPI<IYAxisConfigAPI> {
251249 */
252250export abstract class AbstractPlotAPI implements IPlotAPI {
253251
254- /**
255- * The expanded chart def.
256- * /
252+ //
253+ // The expanded chart def.
254+ / /
257255 protected chartDef : IChartDef ;
258256
259- constructor ( chartDef : IChartDef ) {
257+ //
258+ // Defaults for the chart configuration.
259+ //
260+ private plotDefaults ?: IPlotConfig ;
261+
262+ constructor ( chartDef : IChartDef , plotDefaults ?: IPlotConfig ) {
260263 this . chartDef = chartDef ;
264+ this . plotDefaults = plotDefaults ;
261265 }
262266
263267 /**
@@ -414,7 +418,7 @@ export abstract class AbstractPlotAPI implements IPlotAPI {
414418 * The JSON definition of the chart can be used to instantiate the chart in a browser.
415419 */
416420 serialize ( ) : IChartDef {
417- return applyDefaults ( this . chartDef ) ; // Set missing default values after configuration by the fluent.
421+ return applyDefaults ( this . chartDef , this . plotDefaults ) ; // Set missing default values after configuration by the fluent.
418422 }
419423
420424 /**
@@ -439,12 +443,12 @@ export class PlotAPI extends AbstractPlotAPI {
439443 return new PlotAPI ( chartDef . data , chartDef . plotConfig , chartDef . axisMap ) ;
440444 }
441445
442- constructor ( data : ISerializedDataFrame , plotConfig : IPlotConfig , axisMap : IAxisMap ) {
446+ constructor ( data : ISerializedDataFrame , plotConfig : IPlotConfig , axisMap : IAxisMap , plotDefaults ?: IPlotConfig ) {
443447 if ( ! isObject ( data ) ) {
444448 throw new Error ( "Expected 'data' parameter to PlotAPI constructor to be a serialized dataframe." ) ;
445449 }
446450
447- super ( expandChartDef ( data , plotConfig , axisMap ) ) ;
451+ super ( expandChartDef ( data , plotConfig , axisMap ) , plotDefaults ) ;
448452 }
449453}
450454
0 commit comments