UNPKG

@visactor/vmind

Version:

<div align="center"> <a href="https://github.com/VisActor#gh-light-mode-only" target="_blank"> <img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/logo_500_200_light.svg"/> </a> <a href="https://githu

103 lines (96 loc) 3.04 kB
import { isArray } from "@visactor/vutils"; import { DIMENSION_AXIS_ID, MAIN_SERIES_ID, MEASURE_AXIS_LEFT_ID, MEASURE_AXIS_RIGHT_ID, SUB_SERIES_ID } from "../constants"; import { color, data, discreteLegend } from "./common"; import { COLOR_FIELD } from "@visactor/chart-advisor"; export const dualAxisSeries = context => { var _a; const {cell: cell, spec: spec, simpleVChartSpec: simpleVChartSpec} = context, {color: color} = cell, dataValues = spec.data.values; return simpleVChartSpec && simpleVChartSpec.series ? (spec.series = simpleVChartSpec.series.map((s => Object.assign(Object.assign({}, s), { data: { id: `data_${s.type}`, values: s.data }, xField: cell.x, yField: cell.y[0], seriesField: color ? isArray(color) ? color[0] : color : null }))), { spec: spec }) : (spec.series = [ { type: "bar", id: MAIN_SERIES_ID, data: { id: spec.data.id + "_bar", values: color ? dataValues : dataValues.map((d => Object.assign(Object.assign({}, d), { [COLOR_FIELD]: cell.y[0] }))) }, dataIndex: 0, label: { visible: !0 }, xField: cell.x, yField: cell.y[0], seriesField: color ? isArray(color) ? color[0] : color : COLOR_FIELD, bar: { style: {} } }, { type: "line", id: SUB_SERIES_ID, dataIndex: 0, data: { id: spec.data.id + "_line", values: color ? dataValues : dataValues.map((d => Object.assign(Object.assign({}, d), { [COLOR_FIELD]: cell.y[1] }))) }, label: { visible: !0 }, xField: cell.x, yField: cell.y[(null === (_a = cell.y) || void 0 === _a ? void 0 : _a.length) - 1], seriesField: color ? isArray(color) ? color[0] : color : COLOR_FIELD, line: { style: {} }, point: { style: {} } } ], spec.data = void 0, spec.labelLayout = "region", { spec: spec }); }; export const dualAxisAxes = context => { const {spec: spec, simpleVChartSpec: simpleVChartSpec} = context; return simpleVChartSpec && simpleVChartSpec.series || (spec.axes = [ { id: DIMENSION_AXIS_ID, type: "band", orient: "bottom" }, { id: MEASURE_AXIS_LEFT_ID, seriesId: MAIN_SERIES_ID, type: "linear", orient: "left", label: { style: {} } }, { id: MEASURE_AXIS_RIGHT_ID, seriesId: SUB_SERIES_ID, type: "linear", orient: "right", tick: { visible: !1 }, grid: { visible: !1 }, label: { style: {} } } ]), { spec: spec }; }; export const pipelineDualAxis = [ data, color, dualAxisSeries, dualAxisAxes, discreteLegend ]; //# sourceMappingURL=dualAxis.js.map