@visactor/vchart
Version:
charts lib based @visactor/VGrammar
64 lines (45 loc) • 2.69 kB
JavaScript
import { getCartesianAxisTheme, getDirectionByOrient, getOrient } from "../axis/cartesian/util/common";
import { getPolarAxisTheme } from "../axis/polar/util/common";
import { getCartesianCrosshairTheme, getPolarCrosshairTheme } from "../crosshair/utils";
import { ComponentTypeEnum } from "../interface/type";
import { getComponentThemeFromOption } from "../util";
import { mergeSpec } from "@visactor/vutils-extension";
export function getComponentThemeFromGlobalTheme(type, getTheme, componentSpec, chartSpec) {
switch (type) {
case ComponentTypeEnum.cartesianBandAxis:
return getCartesianAxisTheme(getOrient(componentSpec, [ "z" ]), "band", getTheme);
case ComponentTypeEnum.cartesianLinearAxis:
return getCartesianAxisTheme(getOrient(componentSpec, [ "z" ]), "linear", getTheme);
case ComponentTypeEnum.cartesianLogAxis:
return getCartesianAxisTheme(getOrient(componentSpec, [ "z" ]), "log", getTheme);
case ComponentTypeEnum.cartesianSymlogAxis:
return getCartesianAxisTheme(getOrient(componentSpec, [ "z" ]), "symlog", getTheme);
case ComponentTypeEnum.cartesianAxis:
case ComponentTypeEnum.cartesianTimeAxis:
return getCartesianAxisTheme(getOrient(componentSpec), void 0, getTheme);
case ComponentTypeEnum.polarBandAxis:
return getPolarAxisTheme(componentSpec.orient, "band", getTheme);
case ComponentTypeEnum.polarLinearAxis:
return getPolarAxisTheme(componentSpec.orient, "linear", getTheme);
case ComponentTypeEnum.polarAxis:
return getPolarAxisTheme(componentSpec.orient, void 0, getTheme);
case ComponentTypeEnum.cartesianCrosshair:
return getCartesianCrosshairTheme(getTheme, chartSpec);
case ComponentTypeEnum.polarCrosshair:
return getPolarCrosshairTheme(getTheme, chartSpec);
case ComponentTypeEnum.colorLegend:
case ComponentTypeEnum.sizeLegend:
case ComponentTypeEnum.discreteLegend:
case ComponentTypeEnum.dataZoom:
case ComponentTypeEnum.scrollBar:
return getComponentThemeWithDirection(componentSpec, getComponentThemeFromOption(type, getTheme));
default:
return getComponentThemeFromOption(type, getTheme);
}
}
export const getComponentThemeWithDirection = (componentSpec, originalTheme) => {
var _a;
const orient = null !== (_a = componentSpec.orient) && void 0 !== _a ? _a : originalTheme.orient, directionTheme = originalTheme[getDirectionByOrient(orient)], finalTheme = mergeSpec({}, originalTheme, directionTheme);
return delete finalTheme.horizontal, delete finalTheme.vertical, finalTheme;
};
//# sourceMappingURL=util.js.map