UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

51 lines (46 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.BaseModelSpecTransformer = void 0; const util_1 = require("../util"), vutils_extension_1 = require("@visactor/vutils-extension"); class BaseModelSpecTransformer { constructor(option) { this._option = option, this.type = option.type; } _initTheme(spec, chartSpec) { return this._theme = this.getTheme(spec, chartSpec), this._mergeThemeToSpec(spec, chartSpec); } getTheme(spec, chartSpec) {} transformSpec(spec, chartSpec, chartSpecInfo) { this._transformSpecBeforeMergingTheme(spec, chartSpec, chartSpecInfo); const result = this._initTheme(spec, chartSpec); return this._transformSpecAfterMergingTheme(result.spec, chartSpec, chartSpecInfo), result; } _transformSpecBeforeMergingTheme(spec, chartSpec, chartSpecInfo) {} _transformSpecAfterMergingTheme(spec, chartSpec, chartSpecInfo) {} _mergeThemeToSpec(spec, chartSpec) { const theme = this._theme; if (this._shouldMergeThemeToSpec()) { const specFromChart = this._getDefaultSpecFromChart(chartSpec), merge = originalSpec => (0, vutils_extension_1.mergeSpec)({}, theme, specFromChart, originalSpec); return (0, util_1.isArray)(spec) ? { spec: spec.map((specItem => merge(specItem))), theme: theme } : { spec: merge(spec), theme: theme }; } return { spec: spec, theme: theme }; } _shouldMergeThemeToSpec() { return !0; } _getDefaultSpecFromChart(chartSpec) {} } exports.BaseModelSpecTransformer = BaseModelSpecTransformer; //# sourceMappingURL=base-model-transformer.js.map