@visactor/openinula-vchart 1.10.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/cjs/VChart.js +17 -0
- package/cjs/VChart.js.map +1 -0
- package/cjs/VChartSimple.js +10 -0
- package/cjs/VChartSimple.js.map +1 -0
- package/cjs/charts/AreaChart.js +19 -0
- package/cjs/charts/AreaChart.js.map +1 -0
- package/cjs/charts/BarChart.js +19 -0
- package/cjs/charts/BarChart.js.map +1 -0
- package/cjs/charts/BaseChart.d.ts +26 -0
- package/cjs/charts/BaseChart.js +125 -0
- package/cjs/charts/BaseChart.js.map +1 -0
- package/cjs/charts/BoxPlotChart.js +19 -0
- package/cjs/charts/BoxPlotChart.js.map +1 -0
- package/cjs/charts/CircularProgressChart.js +19 -0
- package/cjs/charts/CircularProgressChart.js.map +1 -0
- package/cjs/charts/CommonChart.js +19 -0
- package/cjs/charts/CommonChart.js.map +1 -0
- package/cjs/charts/FunnelChart.js +19 -0
- package/cjs/charts/FunnelChart.js.map +1 -0
- package/cjs/charts/HistogramChart.js +19 -0
- package/cjs/charts/HistogramChart.js.map +1 -0
- package/cjs/charts/LineChart.js +19 -0
- package/cjs/charts/LineChart.js.map +1 -0
- package/cjs/charts/LinearProgressChart.js +19 -0
- package/cjs/charts/LinearProgressChart.js.map +1 -0
- package/cjs/charts/MapChart.js +19 -0
- package/cjs/charts/MapChart.js.map +1 -0
- package/cjs/charts/PieChart.js +19 -0
- package/cjs/charts/PieChart.js.map +1 -0
- package/cjs/charts/RadarChart.js +19 -0
- package/cjs/charts/RadarChart.js.map +1 -0
- package/cjs/charts/RangeColumnChart.js +19 -0
- package/cjs/charts/RangeColumnChart.js.map +1 -0
- package/cjs/charts/RoseChart.js +18 -0
- package/cjs/charts/RoseChart.js.map +1 -0
- package/cjs/charts/ScatterChart.js +19 -0
- package/cjs/charts/ScatterChart.js.map +1 -0
- package/cjs/charts/SequenceChart.js +19 -0
- package/cjs/charts/SequenceChart.js.map +1 -0
- package/cjs/charts/WordCloudChart.js +19 -0
- package/cjs/charts/WordCloudChart.js.map +1 -0
- package/cjs/charts/index.d.ts +18 -0
- package/cjs/charts/index.js +28 -0
- package/cjs/charts/index.js.map +1 -0
- package/cjs/components/Axis.js +10 -0
- package/cjs/components/Axis.js.map +1 -0
- package/cjs/components/BaseComponent.js +55 -0
- package/cjs/components/BaseComponent.js.map +1 -0
- package/cjs/components/Brush.js +10 -0
- package/cjs/components/Brush.js.map +1 -0
- package/cjs/components/Crosshair.js +10 -0
- package/cjs/components/Crosshair.js.map +1 -0
- package/cjs/components/DataZoom.js +10 -0
- package/cjs/components/DataZoom.js.map +1 -0
- package/cjs/components/Indicator.js +10 -0
- package/cjs/components/Indicator.js.map +1 -0
- package/cjs/components/Legend.js +10 -0
- package/cjs/components/Legend.js.map +1 -0
- package/cjs/components/Mark.js +10 -0
- package/cjs/components/Mark.js.map +1 -0
- package/cjs/components/MarkArea.js +10 -0
- package/cjs/components/MarkArea.js.map +1 -0
- package/cjs/components/MarkLine.js +10 -0
- package/cjs/components/MarkLine.js.map +1 -0
- package/cjs/components/MarkPoint.js +10 -0
- package/cjs/components/MarkPoint.js.map +1 -0
- package/cjs/components/Player.js +10 -0
- package/cjs/components/Player.js.map +1 -0
- package/cjs/components/Region.js +9 -0
- package/cjs/components/Region.js.map +1 -0
- package/cjs/components/ScrollBar.js +10 -0
- package/cjs/components/ScrollBar.js.map +1 -0
- package/cjs/components/Title.js +10 -0
- package/cjs/components/Title.js.map +1 -0
- package/cjs/components/index.d.ts +15 -0
- package/cjs/components/index.js +28 -0
- package/cjs/components/index.js.map +1 -0
- package/cjs/components/tooltip/Tooltip.js +10 -0
- package/cjs/components/tooltip/Tooltip.js.map +1 -0
- package/cjs/components/tooltip/constant.d.ts +1 -0
- package/cjs/components/tooltip/constant.js +10 -0
- package/cjs/components/tooltip/constant.js.map +1 -0
- package/cjs/components/tooltip/index.d.ts +3 -0
- package/cjs/components/tooltip/index.js +22 -0
- package/cjs/components/tooltip/index.js.map +1 -0
- package/cjs/components/tooltip/interface.d.ts +14 -0
- package/cjs/components/tooltip/interface.js +6 -0
- package/cjs/components/tooltip/interface.js.map +1 -0
- package/cjs/components/tooltip/util.d.ts +4 -0
- package/cjs/components/tooltip/util.js +47 -0
- package/cjs/components/tooltip/util.js.map +1 -0
- package/cjs/constants.d.ts +1 -0
- package/cjs/constants.js +6 -0
- package/cjs/constants.js.map +1 -0
- package/cjs/containers/withContainer.d.ts +11 -0
- package/cjs/containers/withContainer.js +64 -0
- package/cjs/containers/withContainer.js.map +1 -0
- package/cjs/context/chart.d.ts +13 -0
- package/cjs/context/chart.js +25 -0
- package/cjs/context/chart.js.map +1 -0
- package/cjs/context/stage.d.ts +9 -0
- package/cjs/context/stage.js +24 -0
- package/cjs/context/stage.js.map +1 -0
- package/cjs/context/view.d.ts +9 -0
- package/cjs/context/view.js +24 -0
- package/cjs/context/view.js.map +1 -0
- package/cjs/eventsUtils.d.ts +256 -0
- package/cjs/eventsUtils.js +114 -0
- package/cjs/eventsUtils.js.map +1 -0
- package/cjs/index.d.ts +7 -0
- package/cjs/index.js +23 -0
- package/cjs/index.js.map +1 -0
- package/cjs/series/Area.js +10 -0
- package/cjs/series/Area.js.map +1 -0
- package/cjs/series/Bar.js +10 -0
- package/cjs/series/Bar.js.map +1 -0
- package/cjs/series/BaseSeries.js +51 -0
- package/cjs/series/BaseSeries.js.map +1 -0
- package/cjs/series/BoxPlot.js +10 -0
- package/cjs/series/BoxPlot.js.map +1 -0
- package/cjs/series/CircularProgress.js +10 -0
- package/cjs/series/CircularProgress.js.map +1 -0
- package/cjs/series/Dot.js +10 -0
- package/cjs/series/Dot.js.map +1 -0
- package/cjs/series/Funnel.js +10 -0
- package/cjs/series/Funnel.js.map +1 -0
- package/cjs/series/Line.js +10 -0
- package/cjs/series/Line.js.map +1 -0
- package/cjs/series/LinearProgress.js +10 -0
- package/cjs/series/LinearProgress.js.map +1 -0
- package/cjs/series/Link.js +9 -0
- package/cjs/series/Link.js.map +1 -0
- package/cjs/series/Map.js +10 -0
- package/cjs/series/Map.js.map +1 -0
- package/cjs/series/Pie.js +10 -0
- package/cjs/series/Pie.js.map +1 -0
- package/cjs/series/Radar.js +10 -0
- package/cjs/series/Radar.js.map +1 -0
- package/cjs/series/RangeColumn.js +10 -0
- package/cjs/series/RangeColumn.js.map +1 -0
- package/cjs/series/Rose.js +10 -0
- package/cjs/series/Rose.js.map +1 -0
- package/cjs/series/Scatter.js +10 -0
- package/cjs/series/Scatter.js.map +1 -0
- package/cjs/series/Series.js +10 -0
- package/cjs/series/Series.js.map +1 -0
- package/cjs/series/WordCloud.js +10 -0
- package/cjs/series/WordCloud.js.map +1 -0
- package/cjs/series/index.d.ts +17 -0
- package/cjs/series/index.js +29 -0
- package/cjs/series/index.js.map +1 -0
- package/cjs/util.js +57 -0
- package/cjs/util.js.map +1 -0
- package/esm/VChart.js +9 -0
- package/esm/VChart.js.map +1 -0
- package/esm/VChartSimple.js +4 -0
- package/esm/VChartSimple.js.map +1 -0
- package/esm/charts/AreaChart.js +9 -0
- package/esm/charts/AreaChart.js.map +1 -0
- package/esm/charts/BarChart.js +9 -0
- package/esm/charts/BarChart.js.map +1 -0
- package/esm/charts/BaseChart.d.ts +26 -0
- package/esm/charts/BaseChart.js +104 -0
- package/esm/charts/BaseChart.js.map +1 -0
- package/esm/charts/BoxPlotChart.js +9 -0
- package/esm/charts/BoxPlotChart.js.map +1 -0
- package/esm/charts/CircularProgressChart.js +9 -0
- package/esm/charts/CircularProgressChart.js.map +1 -0
- package/esm/charts/CommonChart.js +9 -0
- package/esm/charts/CommonChart.js.map +1 -0
- package/esm/charts/FunnelChart.js +9 -0
- package/esm/charts/FunnelChart.js.map +1 -0
- package/esm/charts/HistogramChart.js +9 -0
- package/esm/charts/HistogramChart.js.map +1 -0
- package/esm/charts/LineChart.js +9 -0
- package/esm/charts/LineChart.js.map +1 -0
- package/esm/charts/LinearProgressChart.js +9 -0
- package/esm/charts/LinearProgressChart.js.map +1 -0
- package/esm/charts/MapChart.js +9 -0
- package/esm/charts/MapChart.js.map +1 -0
- package/esm/charts/PieChart.js +9 -0
- package/esm/charts/PieChart.js.map +1 -0
- package/esm/charts/RadarChart.js +9 -0
- package/esm/charts/RadarChart.js.map +1 -0
- package/esm/charts/RangeColumnChart.js +9 -0
- package/esm/charts/RangeColumnChart.js.map +1 -0
- package/esm/charts/RoseChart.js +8 -0
- package/esm/charts/RoseChart.js.map +1 -0
- package/esm/charts/ScatterChart.js +9 -0
- package/esm/charts/ScatterChart.js.map +1 -0
- package/esm/charts/SequenceChart.js +9 -0
- package/esm/charts/SequenceChart.js.map +1 -0
- package/esm/charts/WordCloudChart.js +9 -0
- package/esm/charts/WordCloudChart.js.map +1 -0
- package/esm/charts/index.d.ts +18 -0
- package/esm/charts/index.js +32 -0
- package/esm/charts/index.js.map +1 -0
- package/esm/components/Axis.js +4 -0
- package/esm/components/Axis.js.map +1 -0
- package/esm/components/BaseComponent.js +26 -0
- package/esm/components/BaseComponent.js.map +1 -0
- package/esm/components/Brush.js +6 -0
- package/esm/components/Brush.js.map +1 -0
- package/esm/components/Crosshair.js +4 -0
- package/esm/components/Crosshair.js.map +1 -0
- package/esm/components/DataZoom.js +6 -0
- package/esm/components/DataZoom.js.map +1 -0
- package/esm/components/Indicator.js +4 -0
- package/esm/components/Indicator.js.map +1 -0
- package/esm/components/Legend.js +6 -0
- package/esm/components/Legend.js.map +1 -0
- package/esm/components/Mark.js +4 -0
- package/esm/components/Mark.js.map +1 -0
- package/esm/components/MarkArea.js +4 -0
- package/esm/components/MarkArea.js.map +1 -0
- package/esm/components/MarkLine.js +4 -0
- package/esm/components/MarkLine.js.map +1 -0
- package/esm/components/MarkPoint.js +4 -0
- package/esm/components/MarkPoint.js.map +1 -0
- package/esm/components/Player.js +6 -0
- package/esm/components/Player.js.map +1 -0
- package/esm/components/Region.js +3 -0
- package/esm/components/Region.js.map +1 -0
- package/esm/components/ScrollBar.js +6 -0
- package/esm/components/ScrollBar.js.map +1 -0
- package/esm/components/Title.js +4 -0
- package/esm/components/Title.js.map +1 -0
- package/esm/components/index.d.ts +15 -0
- package/esm/components/index.js +30 -0
- package/esm/components/index.js.map +1 -0
- package/esm/components/tooltip/Tooltip.js +4 -0
- package/esm/components/tooltip/Tooltip.js.map +1 -0
- package/esm/components/tooltip/constant.d.ts +1 -0
- package/esm/components/tooltip/constant.js +4 -0
- package/esm/components/tooltip/constant.js.map +1 -0
- package/esm/components/tooltip/index.d.ts +3 -0
- package/esm/components/tooltip/index.js +6 -0
- package/esm/components/tooltip/index.js.map +1 -0
- package/esm/components/tooltip/interface.d.ts +14 -0
- package/esm/components/tooltip/interface.js +2 -0
- package/esm/components/tooltip/interface.js.map +1 -0
- package/esm/components/tooltip/util.d.ts +4 -0
- package/esm/components/tooltip/util.js +40 -0
- package/esm/components/tooltip/util.js.map +1 -0
- package/esm/constants.d.ts +1 -0
- package/esm/constants.js +2 -0
- package/esm/constants.js.map +1 -0
- package/esm/containers/withContainer.d.ts +11 -0
- package/esm/containers/withContainer.js +33 -0
- package/esm/containers/withContainer.js.map +1 -0
- package/esm/context/chart.d.ts +13 -0
- package/esm/context/chart.js +16 -0
- package/esm/context/chart.js.map +1 -0
- package/esm/context/stage.d.ts +9 -0
- package/esm/context/stage.js +16 -0
- package/esm/context/stage.js.map +1 -0
- package/esm/context/view.d.ts +9 -0
- package/esm/context/view.js +16 -0
- package/esm/context/view.js.map +1 -0
- package/esm/eventsUtils.d.ts +256 -0
- package/esm/eventsUtils.js +126 -0
- package/esm/eventsUtils.js.map +1 -0
- package/esm/index.d.ts +7 -0
- package/esm/index.js +12 -0
- package/esm/index.js.map +1 -0
- package/esm/series/Area.js +4 -0
- package/esm/series/Area.js.map +1 -0
- package/esm/series/Bar.js +4 -0
- package/esm/series/Bar.js.map +1 -0
- package/esm/series/BaseSeries.js +45 -0
- package/esm/series/BaseSeries.js.map +1 -0
- package/esm/series/BoxPlot.js +4 -0
- package/esm/series/BoxPlot.js.map +1 -0
- package/esm/series/CircularProgress.js +4 -0
- package/esm/series/CircularProgress.js.map +1 -0
- package/esm/series/Dot.js +4 -0
- package/esm/series/Dot.js.map +1 -0
- package/esm/series/Funnel.js +4 -0
- package/esm/series/Funnel.js.map +1 -0
- package/esm/series/Line.js +4 -0
- package/esm/series/Line.js.map +1 -0
- package/esm/series/LinearProgress.js +4 -0
- package/esm/series/LinearProgress.js.map +1 -0
- package/esm/series/Link.js +3 -0
- package/esm/series/Link.js.map +1 -0
- package/esm/series/Map.js +4 -0
- package/esm/series/Map.js.map +1 -0
- package/esm/series/Pie.js +4 -0
- package/esm/series/Pie.js.map +1 -0
- package/esm/series/Radar.js +4 -0
- package/esm/series/Radar.js.map +1 -0
- package/esm/series/RangeColumn.js +4 -0
- package/esm/series/RangeColumn.js.map +1 -0
- package/esm/series/Rose.js +4 -0
- package/esm/series/Rose.js.map +1 -0
- package/esm/series/Scatter.js +4 -0
- package/esm/series/Scatter.js.map +1 -0
- package/esm/series/Series.js +4 -0
- package/esm/series/Series.js.map +1 -0
- package/esm/series/WordCloud.js +4 -0
- package/esm/series/WordCloud.js.map +1 -0
- package/esm/series/index.d.ts +17 -0
- package/esm/series/index.js +34 -0
- package/esm/series/index.js.map +1 -0
- package/esm/util.js +36 -0
- package/esm/util.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';
|
|
2
|
+
import { ContainerProps } from '../containers/withContainer';
|
|
3
|
+
import { EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps } from '../eventsUtils';
|
|
4
|
+
import { IReactTooltipProps } from '../components/tooltip/interface';
|
|
5
|
+
export type ChartOptions = Omit<IInitOption, 'dom'>;
|
|
6
|
+
export interface BaseChartProps extends EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps, IReactTooltipProps {
|
|
7
|
+
vchartConstrouctor?: IVChartConstructor;
|
|
8
|
+
type?: string;
|
|
9
|
+
container?: HTMLDivElement;
|
|
10
|
+
spec?: ISpec;
|
|
11
|
+
data?: IData;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
options?: ChartOptions;
|
|
15
|
+
skipFunctionDiff?: boolean;
|
|
16
|
+
onReady?: (instance: IVChart, isInitial: boolean) => void;
|
|
17
|
+
onError?: (err: Error) => void;
|
|
18
|
+
useSyncRender?: boolean;
|
|
19
|
+
}
|
|
20
|
+
type Props = React.PropsWithChildren<BaseChartProps>;
|
|
21
|
+
export declare const createChart: <T extends Props>(componentName: string, defaultProps?: Partial<T>, callback?: (props: T, defaultProps?: Partial<T>) => T) => import("openinula").ExoticComponent<import("openinula").PropsOmitRef<T & ContainerProps>> & {
|
|
22
|
+
key?: import("openinula").Key;
|
|
23
|
+
} & {
|
|
24
|
+
ref?: import("openinula").Ref<any>;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef, useImperativeHandle } from "openinula";
|
|
2
|
+
|
|
3
|
+
import withContainer from "../containers/withContainer";
|
|
4
|
+
|
|
5
|
+
import RootChartContext from "../context/chart";
|
|
6
|
+
|
|
7
|
+
import { isEqual, isNil, pickWithout } from "@visactor/vutils";
|
|
8
|
+
|
|
9
|
+
import ViewContext from "../context/view";
|
|
10
|
+
|
|
11
|
+
import { toArray } from "../util";
|
|
12
|
+
|
|
13
|
+
import { REACT_PRIVATE_PROPS } from "../constants";
|
|
14
|
+
|
|
15
|
+
import { bindEventsToChart, CHART_EVENTS_KEYS, CHART_EVENTS } from "../eventsUtils";
|
|
16
|
+
|
|
17
|
+
import { initCustomTooltip } from "../components/tooltip/util";
|
|
18
|
+
|
|
19
|
+
const notSpecKeys = [ ...REACT_PRIVATE_PROPS, ...CHART_EVENTS_KEYS, "vchartConstrouctor", "useSyncRender", "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ], getComponentId = (child, index) => `${child && child.type && (child.type.displayName || child.type.name)}-${index}`, parseSpecFromChildren = props => {
|
|
20
|
+
const specFromChildren = {};
|
|
21
|
+
return toArray(props.children).map(((child, index) => {
|
|
22
|
+
const parseSpec = child && child.type && child.type.parseSpec;
|
|
23
|
+
if (parseSpec && child.props) {
|
|
24
|
+
const specResult = parseSpec(isNil(child.props.componentId) ? Object.assign(Object.assign({}, child.props), {
|
|
25
|
+
componentId: getComponentId(child, index)
|
|
26
|
+
}) : child.props);
|
|
27
|
+
specResult.isSingle ? specFromChildren[specResult.specName] = specResult.spec : (specFromChildren[specResult.specName] || (specFromChildren[specResult.specName] = []),
|
|
28
|
+
specFromChildren[specResult.specName].push(specResult.spec));
|
|
29
|
+
}
|
|
30
|
+
})), specFromChildren;
|
|
31
|
+
}, BaseChart = React.forwardRef(((props, ref) => {
|
|
32
|
+
const [updateId, setUpdateId] = useState(0), chartContext = useRef({});
|
|
33
|
+
useImperativeHandle(ref, (() => {
|
|
34
|
+
var _a;
|
|
35
|
+
return null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart;
|
|
36
|
+
}));
|
|
37
|
+
const hasSpec = !!props.spec, [view, setView] = useState(null), isUnmount = useRef(!1), prevSpec = useRef(pickWithout(props, notSpecKeys)), specFromChildren = useRef(null), eventsBinded = React.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, [tooltipNode, setTooltipNode] = useState(null), parseSpec = props => {
|
|
38
|
+
let spec;
|
|
39
|
+
spec = hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), specFromChildren.current);
|
|
40
|
+
const tooltipSpec = initCustomTooltip(setTooltipNode, props, spec.tooltip);
|
|
41
|
+
return tooltipSpec && (spec.tooltip = tooltipSpec), spec;
|
|
42
|
+
}, handleChartRender = () => {
|
|
43
|
+
if (!isUnmount.current) {
|
|
44
|
+
if (!chartContext.current || !chartContext.current.chart) return;
|
|
45
|
+
bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);
|
|
46
|
+
const newView = chartContext.current.chart.getCompiler().getVGrammarView();
|
|
47
|
+
setUpdateId(updateId + 1), props.onReady && props.onReady(chartContext.current.chart, 0 === updateId),
|
|
48
|
+
setView(newView);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return useEffect((() => {
|
|
52
|
+
var _a;
|
|
53
|
+
const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);
|
|
54
|
+
if (!(null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart)) return hasSpec || (specFromChildren.current = newSpecFromChildren),
|
|
55
|
+
(props => {
|
|
56
|
+
const cs = new props.vchartConstrouctor(parseSpec(props), Object.assign(Object.assign({}, props.options), {
|
|
57
|
+
onError: props.onError,
|
|
58
|
+
autoFit: !0,
|
|
59
|
+
dom: props.container
|
|
60
|
+
}));
|
|
61
|
+
chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
|
|
62
|
+
chart: cs
|
|
63
|
+
}), isUnmount.current = !1;
|
|
64
|
+
})(props), chartContext.current.chart && (chartContext.current.chart.renderSync({
|
|
65
|
+
reuse: !1
|
|
66
|
+
}), handleChartRender()), void (eventsBinded.current = props);
|
|
67
|
+
if (hasSpec) return void (isEqual(eventsBinded.current.spec, props.spec, {
|
|
68
|
+
skipFunction: skipFunctionDiff
|
|
69
|
+
}) || (eventsBinded.current = props, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
|
|
70
|
+
morph: !1,
|
|
71
|
+
enableExitAnimation: !1
|
|
72
|
+
}), handleChartRender()));
|
|
73
|
+
const newSpec = pickWithout(props, notSpecKeys);
|
|
74
|
+
isEqual(newSpec, prevSpec.current, {
|
|
75
|
+
skipFunction: skipFunctionDiff
|
|
76
|
+
}) && isEqual(newSpecFromChildren, specFromChildren.current) || (prevSpec.current = newSpec,
|
|
77
|
+
specFromChildren.current = newSpecFromChildren, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
|
|
78
|
+
morph: !1,
|
|
79
|
+
enableExitAnimation: !1
|
|
80
|
+
}), handleChartRender());
|
|
81
|
+
}), [ props ]), useEffect((() => () => {
|
|
82
|
+
chartContext && chartContext.current && chartContext.current.chart && (chartContext.current.chart.release(),
|
|
83
|
+
chartContext.current.chart = null), eventsBinded.current = null, isUnmount.current = !0;
|
|
84
|
+
}), []), React.createElement(RootChartContext.Provider, {
|
|
85
|
+
value: chartContext.current
|
|
86
|
+
}, React.createElement(ViewContext.Provider, {
|
|
87
|
+
value: view
|
|
88
|
+
}, toArray(props.children).map(((child, index) => {
|
|
89
|
+
if ("string" == typeof child) return;
|
|
90
|
+
const childId = getComponentId(child, index);
|
|
91
|
+
return React.createElement(React.Fragment, {
|
|
92
|
+
key: childId
|
|
93
|
+
}, React.cloneElement(child, {
|
|
94
|
+
updateId: updateId,
|
|
95
|
+
componentId: childId
|
|
96
|
+
}));
|
|
97
|
+
})), tooltipNode));
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
export const createChart = (componentName, defaultProps, callback) => {
|
|
101
|
+
const Com = withContainer(BaseChart, componentName, (props => callback ? callback(props, defaultProps) : defaultProps ? Object.assign(props, defaultProps) : props));
|
|
102
|
+
return Com.displayName = componentName, Com;
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=BaseChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/BaseChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAa,MAAM,WAAW,CAAC;AAC/F,OAAO,aAAiC,MAAM,6BAA6B,CAAC;AAC5E,OAAO,gBAAsC,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,OA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AO,GAAG,CAAC;AACb,CAAC,CAAC","file":"BaseChart.js","sourcesContent":["import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';\nimport React, { useState, useEffect, useRef, useImperativeHandle, ReactNode } from 'openinula';\nimport withContainer, { ContainerProps } from '../containers/withContainer';\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport type { IView } from '@visactor/vgrammar-core';\nimport { isEqual, isNil, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport {\n bindEventsToChart,\n EventsProps,\n CHART_EVENTS_KEYS,\n CHART_EVENTS,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\nimport { IReactTooltipProps } from '../components/tooltip/interface';\nimport { initCustomTooltip } from '../components/tooltip/util';\n\nexport type ChartOptions = Omit<IInitOption, 'dom'>;\n\nexport interface BaseChartProps\n extends EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps,\n IReactTooltipProps {\n vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\n /** 图表渲染完成事件 */\n onReady?: (instance: IVChart, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n /**\n * use sync render\n *\n * @since 1.8.3\n * @deprecated 1.9.0\n **/\n useSyncRender?: boolean;\n}\n\ntype Props = React.PropsWithChildren<BaseChartProps>;\n\nconst notSpecKeys = [\n ...REACT_PRIVATE_PROPS,\n ...CHART_EVENTS_KEYS,\n 'vchartConstrouctor',\n 'useSyncRender',\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'spec',\n 'container',\n 'options'\n];\n\nconst getComponentId = (child: React.ReactNode, index: number) => {\n const componentName = child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n return `${componentName}-${index}`;\n};\n\nconst parseSpecFromChildren = (props: Props) => {\n const specFromChildren: Omit<ISpec, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map((child, index) => {\n const parseSpec = child && (child as any).type && (child as any).type.parseSpec;\n\n if (parseSpec && (child as any).props) {\n const childProps = isNil((child as any).props.componentId)\n ? {\n ...(child as any).props,\n componentId: getComponentId(child, index)\n }\n : (child as any).props;\n\n const specResult = parseSpec(childProps);\n\n if (specResult.isSingle) {\n specFromChildren[specResult.specName] = specResult.spec;\n } else {\n if (!specFromChildren[specResult.specName]) {\n specFromChildren[specResult.specName] = [];\n }\n\n specFromChildren[specResult.specName].push(specResult.spec);\n }\n }\n });\n\n return specFromChildren;\n};\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({});\n useImperativeHandle(ref, () => chartContext.current?.chart);\n const hasSpec = !!props.spec;\n const [view, setView] = useState<IView>(null);\n const isUnmount = useRef<boolean>(false);\n const prevSpec = useRef(pickWithout(props, notSpecKeys));\n const specFromChildren = useRef<Omit<ISpec, 'type' | 'data' | 'width' | 'height'>>(null);\n const eventsBinded = React.useRef<BaseChartProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n const [tooltipNode, setTooltipNode] = useState<ReactNode>(null);\n\n const parseSpec = (props: Props) => {\n let spec: ISpec = undefined;\n\n if (hasSpec && props.spec) {\n spec = props.spec;\n } else {\n spec = {\n ...prevSpec.current,\n ...specFromChildren.current\n } as ISpec;\n }\n\n const tooltipSpec = initCustomTooltip(setTooltipNode, props, spec.tooltip);\n if (tooltipSpec) {\n spec.tooltip = tooltipSpec;\n }\n return spec;\n };\n\n const createChart = (props: Props) => {\n const cs = new props.vchartConstrouctor(parseSpec(props), {\n ...props.options,\n onError: props.onError,\n autoFit: true,\n dom: props.container\n });\n chartContext.current = { ...chartContext.current, chart: cs };\n isUnmount.current = false;\n };\n\n const handleChartRender = () => {\n // rebind events after render\n if (!isUnmount.current) {\n if (!chartContext.current || !chartContext.current.chart) {\n return;\n }\n\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n\n const newView = chartContext.current.chart.getCompiler().getVGrammarView();\n\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(chartContext.current.chart, updateId === 0);\n }\n setView(newView);\n }\n };\n\n const renderChart = () => {\n if (chartContext.current.chart) {\n chartContext.current.chart.renderSync({\n reuse: false\n });\n handleChartRender();\n }\n };\n\n useEffect(() => {\n const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);\n\n if (!chartContext.current?.chart) {\n if (!hasSpec) {\n specFromChildren.current = newSpecFromChildren;\n }\n\n createChart(props);\n renderChart();\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (\n !isEqual(newSpec, prevSpec.current, { skipFunction: skipFunctionDiff }) ||\n !isEqual(newSpecFromChildren, specFromChildren.current)\n ) {\n prevSpec.current = newSpec;\n specFromChildren.current = newSpecFromChildren;\n\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current && chartContext.current.chart) {\n chartContext.current.chart.release();\n chartContext.current.chart = null;\n }\n }\n eventsBinded.current = null;\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootChartContext.Provider value={chartContext.current}>\n <ViewContext.Provider value={view}>\n {toArray(props.children).map((child, index) => {\n if (typeof child === 'string') {\n return;\n }\n\n const childId = getComponentId(child, index);\n\n return (\n <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\n })}\n </React.Fragment>\n );\n })}\n {tooltipNode}\n </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T, defaultProps?: Partial<T>) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: T) => {\n if (callback) {\n return callback(props, defaultProps);\n }\n\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/BoxPlotChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CACrC,cAAc,EACd;IACE,IAAI,EAAE,SAAS;IACf,kBAAkB,EAAE,MAAM;CAC3B,CACF,CAAC","file":"BoxPlotChart.js","sourcesContent":["import React from 'openinula';\nimport { IBoxPlotChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface BoxPlotChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IBoxPlotChartSpec, 'type'> {}\n\nexport const BoxPlotChart = createChart<React.PropsWithChildren<BoxPlotChartProps> & { type: 'boxPlot' }>(\n 'BoxPlotChart',\n {\n type: 'boxPlot',\n vchartConstrouctor: VChart\n }\n);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as VChart } from "@visactor/vchart";
|
|
2
|
+
|
|
3
|
+
import { createChart } from "./BaseChart";
|
|
4
|
+
|
|
5
|
+
export const CircularProgressChart = createChart("CircularProgressChart", {
|
|
6
|
+
type: "circularProgress",
|
|
7
|
+
vchartConstrouctor: VChart
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=CircularProgressChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/CircularProgressChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAE9C,uBAAuB,EAAE;IACzB,IAAI,EAAE,kBAAkB;IACxB,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"CircularProgressChart.js","sourcesContent":["import React from 'openinula';\nimport { ICircularProgressChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface CircularProgressChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<ICircularProgressChartSpec, 'type'> {}\n\nexport const CircularProgressChart = createChart<\n React.PropsWithChildren<CircularProgressChartProps> & { type: 'circularProgress' }\n>('CircularProgressChart', {\n type: 'circularProgress',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/CommonChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAiE,aAAa,EAAE;IACpH,IAAI,EAAE,QAAQ;IACd,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"CommonChart.js","sourcesContent":["import React from 'openinula';\nimport { ICommonChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface CommonChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<ICommonChartSpec, 'type'> {}\n\nexport const CommonChart = createChart<React.PropsWithChildren<CommonChartProps> & { type: 'common' }>('CommonChart', {\n type: 'common',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/FunnelChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAiE,aAAa,EAAE;IACpH,IAAI,EAAE,QAAQ;IACd,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"FunnelChart.js","sourcesContent":["import React from 'openinula';\nimport { IFunnelChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface FunnelChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IFunnelChartSpec, 'type'> {}\n\nexport const FunnelChart = createChart<React.PropsWithChildren<FunnelChartProps> & { type: 'funnel' }>('FunnelChart', {\n type: 'funnel',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as VChart } from "@visactor/vchart";
|
|
2
|
+
|
|
3
|
+
import { createChart } from "./BaseChart";
|
|
4
|
+
|
|
5
|
+
export const HistogramChart = createChart("HistogramChart", {
|
|
6
|
+
type: "histogram",
|
|
7
|
+
vchartConstrouctor: VChart
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=HistogramChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/HistogramChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CACvC,gBAAgB,EAChB;IACE,IAAI,EAAE,WAAW;IACjB,kBAAkB,EAAE,MAAM;CAC3B,CACF,CAAC","file":"HistogramChart.js","sourcesContent":["import React from 'openinula';\nimport { IHistogramChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface HistogramChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IHistogramChartSpec, 'type'> {}\n\nexport const HistogramChart = createChart<React.PropsWithChildren<HistogramChartProps> & { type: 'histogram' }>(\n 'HistogramChart',\n {\n type: 'histogram',\n vchartConstrouctor: VChart\n }\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/LineChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAA6D,WAAW,EAAE;IAC5G,IAAI,EAAE,MAAM;IACZ,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"LineChart.js","sourcesContent":["import React from 'openinula';\nimport type { ILineChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface LineChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<ILineChartSpec, 'type'> {}\n\nexport const LineChart = createChart<React.PropsWithChildren<LineChartProps> & { type: 'line' }>('LineChart', {\n type: 'line',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as VChart } from "@visactor/vchart";
|
|
2
|
+
|
|
3
|
+
import { createChart } from "./BaseChart";
|
|
4
|
+
|
|
5
|
+
export const LinearProgressChart = createChart("LinearProgressChart", {
|
|
6
|
+
type: "linearProgress",
|
|
7
|
+
vchartConstrouctor: VChart
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=LinearProgressChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/LinearProgressChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAE5C,qBAAqB,EAAE;IACvB,IAAI,EAAE,gBAAgB;IACtB,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"LinearProgressChart.js","sourcesContent":["import React from 'openinula';\nimport { ILinearProgressChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface LinearProgressChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<ILinearProgressChartSpec, 'type'> {}\n\nexport const LinearProgressChart = createChart<\n React.PropsWithChildren<LinearProgressChartProps> & { type: 'linearProgress' }\n>('LinearProgressChart', {\n type: 'linearProgress',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/MapChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAA2D,UAAU,EAAE;IACxG,IAAI,EAAE,KAAK;IACX,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"MapChart.js","sourcesContent":["import React from 'openinula';\nimport type { IMapChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface MapChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IMapChartSpec, 'type'> {}\n\nexport const MapChart = createChart<React.PropsWithChildren<MapChartProps> & { type: 'map' }>('MapChart', {\n type: 'map',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/PieChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAA2D,UAAU,EAAE;IACxG,IAAI,EAAE,KAAK;IACX,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"PieChart.js","sourcesContent":["import React from 'openinula';\nimport type { IPieChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface PieChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IPieChartSpec, 'type'> {}\n\nexport const PieChart = createChart<React.PropsWithChildren<PieChartProps> & { type: 'pie' }>('PieChart', {\n type: 'pie',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/RadarChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAA+D,YAAY,EAAE;IAChH,IAAI,EAAE,OAAO;IACb,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"RadarChart.js","sourcesContent":["import React from 'openinula';\nimport type { IRadarChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface RadarChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IRadarChartSpec, 'type'> {}\n\nexport const RadarChart = createChart<React.PropsWithChildren<RadarChartProps> & { type: 'radar' }>('RadarChart', {\n type: 'radar',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as VChart } from "@visactor/vchart";
|
|
2
|
+
|
|
3
|
+
import { createChart } from "./BaseChart";
|
|
4
|
+
|
|
5
|
+
export const RangeColumnChart = createChart("RangeColumnChart", {
|
|
6
|
+
type: "rangeColumn",
|
|
7
|
+
vchartConstrouctor: VChart
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=RangeColumnChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/RangeColumnChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CACzC,kBAAkB,EAClB;IACE,IAAI,EAAE,aAAa;IACnB,kBAAkB,EAAE,MAAM;CAC3B,CACF,CAAC","file":"RangeColumnChart.js","sourcesContent":["import React from 'openinula';\nimport type { IRangeColumnChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface RangeColumnChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IRangeColumnChartSpec, 'type'> {}\n\nexport const RangeColumnChart = createChart<React.PropsWithChildren<RangeColumnChartProps> & { type: 'rangeColumn' }>(\n 'RangeColumnChart',\n {\n type: 'rangeColumn',\n vchartConstrouctor: VChart\n }\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/RoseChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAA6D,WAAW,EAAE;IAC5G,IAAI,EAAE,MAAM;IACZ,kBAAkB,EAAE,MAAM;CAC3B,CAAC,CAAC","file":"RoseChart.js","sourcesContent":["import React from 'openinula';\nimport type { IRoseChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface RoseChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IRoseChartSpec, 'type'> {}\n\nexport const RoseChart = createChart<React.PropsWithChildren<RoseChartProps> & { type: 'rose' }>('RoseChart', {\n type: 'rose',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/ScatterChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CACrC,cAAc,EACd;IACE,IAAI,EAAE,SAAS;IACf,kBAAkB,EAAE,MAAM;CAC3B,CACF,CAAC","file":"ScatterChart.js","sourcesContent":["import React from 'openinula';\nimport type { IScatterChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface ScatterChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IScatterChartSpec, 'type'> {}\n\nexport const ScatterChart = createChart<React.PropsWithChildren<ScatterChartProps> & { type: 'scatter' }>(\n 'ScatterChart',\n {\n type: 'scatter',\n vchartConstrouctor: VChart\n }\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/SequenceChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CACtC,eAAe,EACf;IACE,IAAI,EAAE,UAAU;IAChB,kBAAkB,EAAE,MAAM;CAC3B,CACF,CAAC","file":"SequenceChart.js","sourcesContent":["import React from 'openinula';\nimport type { ISequenceChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface SequenceChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<ISequenceChartSpec, 'type'> {}\n\nexport const SequenceChart = createChart<React.PropsWithChildren<SequenceChartProps> & { type: 'sequence' }>(\n 'SequenceChart',\n {\n type: 'sequence',\n vchartConstrouctor: VChart\n }\n);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as VChart } from "@visactor/vchart";
|
|
2
|
+
|
|
3
|
+
import { createChart } from "./BaseChart";
|
|
4
|
+
|
|
5
|
+
export const WordCloudChart = createChart("WordCloudChart", {
|
|
6
|
+
type: "wordCloud",
|
|
7
|
+
vchartConstrouctor: VChart
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=WordCloudChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/WordCloudChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CACvC,gBAAgB,EAChB;IACE,IAAI,EAAE,WAAW;IACjB,kBAAkB,EAAE,MAAM;CAC3B,CACF,CAAC","file":"WordCloudChart.js","sourcesContent":["import React from 'openinula';\nimport type { IWordCloudChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface WordCloudChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IWordCloudChartSpec, 'type'> {}\n\nexport const WordCloudChart = createChart<React.PropsWithChildren<WordCloudChartProps> & { type: 'wordCloud' }>(\n 'WordCloudChart',\n {\n type: 'wordCloud',\n vchartConstrouctor: VChart\n }\n);\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './AreaChart';
|
|
2
|
+
export * from './BarChart';
|
|
3
|
+
export * from './LineChart';
|
|
4
|
+
export * from './ScatterChart';
|
|
5
|
+
export * from './PieChart';
|
|
6
|
+
export * from './RoseChart';
|
|
7
|
+
export * from './RadarChart';
|
|
8
|
+
export * from './MapChart';
|
|
9
|
+
export * from './HistogramChart';
|
|
10
|
+
export * from './WordCloudChart';
|
|
11
|
+
export * from './FunnelChart';
|
|
12
|
+
export * from './BoxPlotChart';
|
|
13
|
+
export * from './CircularProgressChart';
|
|
14
|
+
export * from './LinearProgressChart';
|
|
15
|
+
export * from './RangeColumnChart';
|
|
16
|
+
export * from './CommonChart';
|
|
17
|
+
export type { ChartOptions } from './BaseChart';
|
|
18
|
+
export type { IData, IChartSpec } from '@visactor/vchart';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export * from "./AreaChart";
|
|
2
|
+
|
|
3
|
+
export * from "./BarChart";
|
|
4
|
+
|
|
5
|
+
export * from "./LineChart";
|
|
6
|
+
|
|
7
|
+
export * from "./ScatterChart";
|
|
8
|
+
|
|
9
|
+
export * from "./PieChart";
|
|
10
|
+
|
|
11
|
+
export * from "./RoseChart";
|
|
12
|
+
|
|
13
|
+
export * from "./RadarChart";
|
|
14
|
+
|
|
15
|
+
export * from "./MapChart";
|
|
16
|
+
|
|
17
|
+
export * from "./HistogramChart";
|
|
18
|
+
|
|
19
|
+
export * from "./WordCloudChart";
|
|
20
|
+
|
|
21
|
+
export * from "./FunnelChart";
|
|
22
|
+
|
|
23
|
+
export * from "./BoxPlotChart";
|
|
24
|
+
|
|
25
|
+
export * from "./CircularProgressChart";
|
|
26
|
+
|
|
27
|
+
export * from "./LinearProgressChart";
|
|
28
|
+
|
|
29
|
+
export * from "./RangeColumnChart";
|
|
30
|
+
|
|
31
|
+
export * from "./CommonChart";
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAE7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,eAAe,CAAC","file":"index.js","sourcesContent":["export * from './AreaChart';\nexport * from './BarChart';\nexport * from './LineChart';\nexport * from './ScatterChart';\n\nexport * from './PieChart';\nexport * from './RoseChart';\n\nexport * from './RadarChart';\n\nexport * from './MapChart';\nexport * from './HistogramChart';\nexport * from './WordCloudChart';\nexport * from './FunnelChart';\nexport * from './BoxPlotChart';\n\nexport * from './CircularProgressChart';\nexport * from './LinearProgressChart';\nexport * from './RangeColumnChart';\n\nexport * from './CommonChart';\n\nexport type { ChartOptions } from './BaseChart';\nexport type { IData, IChartSpec } from '@visactor/vchart';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Axis.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKtE,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAY,MAAM,EAAE,MAAM,CAAC,CAAC","file":"Axis.js","sourcesContent":["import { BaseComponentProps, createComponent } from './BaseComponent';\nimport type { ICartesianAxisSpec, IPolarAxisSpec } from '@visactor/vchart';\n\nexport type AxisProps = (ICartesianAxisSpec | IPolarAxisSpec) & BaseComponentProps;\n\nexport const Axis = createComponent<AxisProps>('Axis', 'axes');\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { useContext, useEffect } from "openinula";
|
|
2
|
+
|
|
3
|
+
import { pickWithout } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import RootChartContext from "../context/chart";
|
|
6
|
+
|
|
7
|
+
import { bindEventsToChart } from "../eventsUtils";
|
|
8
|
+
|
|
9
|
+
export const createComponent = (componentName, specName, supportedEvents, isSingle) => {
|
|
10
|
+
const ignoreKeys = [ "id", "updateId", "componentId" ], notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys, Comp = props => {
|
|
11
|
+
const context = useContext(RootChartContext), eventsBinded = React.useRef(null), updateId = React.useRef(props.updateId);
|
|
12
|
+
if (props.updateId !== updateId.current) {
|
|
13
|
+
updateId.current = props.updateId;
|
|
14
|
+
!!supportedEvents && bindEventsToChart(context.chart, props, eventsBinded.current, supportedEvents) && (eventsBinded.current = props);
|
|
15
|
+
}
|
|
16
|
+
return useEffect((() => () => {
|
|
17
|
+
supportedEvents && bindEventsToChart(context.chart, null, eventsBinded.current, supportedEvents);
|
|
18
|
+
}), []), null;
|
|
19
|
+
};
|
|
20
|
+
return Comp.displayName = componentName, Comp.parseSpec = props => ({
|
|
21
|
+
spec: pickWithout(props, notSpecKeys),
|
|
22
|
+
specName: specName,
|
|
23
|
+
isSingle: isSingle
|
|
24
|
+
}), Comp;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=BaseComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/BaseComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAQnD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,aAAqB,EACrB,QAAgB,EAChB,eAA+C,EAC/C,QAAkB,EAClB,EAAE;IACF,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAEnG,MAAM,IAAI,GAAgB,CAAC,KAAQ,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAI,IAAI,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAS,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtD,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,OAAO,EAAE;YAEvC,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC;YAGlC,MAAM,mBAAmB,GAAG,eAAe;gBACzC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC;gBAChF,CAAC,CAAC,KAAK,CAAC;YACV,IAAI,mBAAmB,EAAE;gBACvB,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC;aAC9B;SACF;QAED,SAAS,CAAC,GAAG,EAAE;YACb,OAAO,GAAG,EAAE;gBACV,IAAI,eAAe,EAAE;oBACnB,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;iBAC/E;YACH,CAAC,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,IAAY,CAAC,SAAS,GAAG,CAAC,KAAsD,EAAE,EAAE;QACnF,MAAM,gBAAgB,GAAe,WAAW,CAAI,KAAK,EAAE,WAAW,CAAC,CAAC;QAExE,OAAO;YACL,IAAI,EAAE,gBAAgB;YACtB,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","file":"BaseComponent.js","sourcesContent":["import React, { useContext, useEffect } from 'openinula';\nimport { pickWithout } from '@visactor/vutils';\n\nimport RootChartContext from '../context/chart';\nimport { bindEventsToChart } from '../eventsUtils';\n\nexport interface BaseComponentProps {\n id?: string | number;\n}\n\ntype ComponentProps = BaseComponentProps & { updateId?: number; componentId?: number };\n\nexport const createComponent = <T extends ComponentProps>(\n componentName: string,\n specName: string,\n supportedEvents?: Record<string, string> | null,\n isSingle?: boolean\n) => {\n const ignoreKeys = ['id', 'updateId', 'componentId'];\n const notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;\n\n const Comp: React.FC<T> = (props: T) => {\n const context = useContext(RootChartContext);\n const eventsBinded = React.useRef<T>(null);\n const updateId = React.useRef<number>(props.updateId);\n if (props.updateId !== updateId.current) {\n // update triggered by chart when chart is rendered\n updateId.current = props.updateId;\n\n // rebind events after chart render\n const hasPrevEventsBinded = supportedEvents\n ? bindEventsToChart(context.chart, props, eventsBinded.current, supportedEvents)\n : false;\n if (hasPrevEventsBinded) {\n eventsBinded.current = props;\n }\n }\n\n useEffect(() => {\n return () => {\n if (supportedEvents) {\n bindEventsToChart(context.chart, null, eventsBinded.current, supportedEvents);\n }\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n (Comp as any).parseSpec = (props: T & { updateId?: number; componentId?: string }) => {\n const newComponentSpec: Partial<T> = pickWithout<T>(props, notSpecKeys);\n\n return {\n spec: newComponentSpec,\n specName,\n isSingle\n };\n };\n\n return Comp;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Brush.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKtE,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAa,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,IAAI,CAAC,CAAC","file":"Brush.js","sourcesContent":["import { BRUSH_CUSTOMIZED_EVENTS, BrushEventProps } from '../eventsUtils';\nimport { BaseComponentProps, createComponent } from './BaseComponent';\nimport type { IBrushSpec } from '@visactor/vchart';\n\nexport type BrushProps = IBrushSpec & BaseComponentProps & BrushEventProps;\n\nexport const Brush = createComponent<BrushProps>('Brush', 'brush', BRUSH_CUSTOMIZED_EVENTS, true);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Crosshair.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKtE,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAiB,WAAW,EAAE,WAAW,CAAC,CAAC","file":"Crosshair.js","sourcesContent":["import { BaseComponentProps, createComponent } from './BaseComponent';\nimport type { ICartesianCrosshairSpec, IPolarCrosshairSpec } from '@visactor/vchart';\n\nexport type CrosshairProps = (ICartesianCrosshairSpec | IPolarCrosshairSpec) & BaseComponentProps;\n\nexport const Crosshair = createComponent<CrosshairProps>('Crosshair', 'crosshair');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/DataZoom.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAsB,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAItE,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAgB,UAAU,EAAE,UAAU,EAAE,0BAA0B,CAAC,CAAC","file":"DataZoom.js","sourcesContent":["import { DATAZOOM_CUSTOMIZED_EVENTS, DataZoomEventProps } from '../eventsUtils';\nimport { BaseComponentProps, createComponent } from './BaseComponent';\nimport type { IDataZoomSpec } from '@visactor/vchart';\n\nexport type DataZoomProps = IDataZoomSpec & BaseComponentProps & DataZoomEventProps;\nexport const DataZoom = createComponent<DataZoomProps>('DataZoom', 'dataZoom', DATAZOOM_CUSTOMIZED_EVENTS);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Indicator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKtE,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAiB,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC","file":"Indicator.js","sourcesContent":["import { BaseComponentProps, createComponent } from './BaseComponent';\nimport type { IIndicatorSpec } from '@visactor/vchart';\n\nexport type IndicatorProps = IIndicatorSpec & BaseComponentProps;\n\nexport const Indicator = createComponent<IndicatorProps>('Indicator', 'indicator', null, true);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Legend.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAoB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAItE,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CAAc,QAAQ,EAAE,SAAS,EAAE,wBAAwB,CAAC,CAAC","file":"Legend.js","sourcesContent":["import type { IDiscreteLegendSpec } from '@visactor/vchart';\nimport { LEGEND_CUSTOMIZED_EVENTS, LegendEventProps } from '../eventsUtils';\nimport { BaseComponentProps, createComponent } from './BaseComponent';\n\nexport type LegendProps = BaseComponentProps & IDiscreteLegendSpec & LegendEventProps;\n\nexport const Legend = createComponent<LegendProps>('Legend', 'legends', LEGEND_CUSTOMIZED_EVENTS);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Mark.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAItE,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAY,MAAM,EAAE,YAAY,CAAC,CAAC","file":"Mark.js","sourcesContent":["import type { ICustomMarkSpec, EnableMarkType } from '@visactor/vchart';\nimport { BaseComponentProps, createComponent } from './BaseComponent';\n\nexport type MarkProps = ICustomMarkSpec<EnableMarkType> & BaseComponentProps;\n\nexport const Mark = createComponent<MarkProps>('Mark', 'customMark');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/MarkArea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKtE,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAgB,UAAU,EAAE,UAAU,CAAC,CAAC","file":"MarkArea.js","sourcesContent":["import { BaseComponentProps, createComponent } from './BaseComponent';\nimport type { IMarkAreaSpec } from '@visactor/vchart';\n\nexport type MarkAreaProps = IMarkAreaSpec & BaseComponentProps;\n\nexport const MarkArea = createComponent<MarkAreaProps>('MarkArea', 'markArea');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/MarkLine.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKtE,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAgB,UAAU,EAAE,UAAU,CAAC,CAAC","file":"MarkLine.js","sourcesContent":["import { BaseComponentProps, createComponent } from './BaseComponent';\nimport type { IMarkLineSpec } from '@visactor/vchart';\n\nexport type MarkLineProps = IMarkLineSpec & BaseComponentProps;\n\nexport const MarkLine = createComponent<MarkLineProps>('MarkLine', 'markLine');\n"]}
|