@wavemaker/react-native-echarts 1.0.0-dev.8 → 1.0.0-dev.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"area-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/area-chart.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAWzD,OAAO,KAAqC,MAAM,OAAO,CAAC;AAK1D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,UAAU,GACX,MAAM,oBAAoB,CAAC;AA+d5B,eAAO,MAAM,SAAS;;;;;;;CAEpB,CAAC"}
1
+ {"version":3,"file":"area-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/area-chart.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAWzD,OAAO,KAAqC,MAAM,OAAO,CAAC;AAK1D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,UAAU,GACX,MAAM,oBAAoB,CAAC;AA4e5B,eAAO,MAAM,SAAS;;;;;;;CAEpB,CAAC"}
@@ -7,7 +7,7 @@ import { GridComponent, LegendComponent, TooltipComponent } from 'echarts/compon
7
7
  import * as echarts from 'echarts/core';
8
8
  import React, { useEffect, useMemo, useRef } from 'react';
9
9
  import { View } from 'react-native';
10
- import { getAxis } from '../axis';
10
+ import { getAxis, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
11
11
  // Register necessary components for this chart
12
12
  echarts.use([
13
13
  TooltipComponent,
@@ -16,7 +16,7 @@ echarts.use([
16
16
  SkiaRenderer,
17
17
  LineChart,
18
18
  ]);
19
- const ChartComponent = ({ data, width = 220, height = 350, type = 'default', step, boundaryGap = false, stack, stackNormalize = false, symbol, symbolSize, areaOpacity = 0.6, areaFill = 'gradient', showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = true, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisTicks, xAxisLabel, yAxisLabel, onSelect, renderTooltip, ...props }) => {
19
+ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', step, boundaryGap = false, stack, stackNormalize = false, symbol, symbolSize, areaOpacity = 0.6, areaFill = 'gradient', showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = true, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
20
20
  const { theme } = useChartTheme(props.theme, props.colors);
21
21
  const chartRef = useRef(null);
22
22
  const onSelectRef = useRef(onSelect);
@@ -105,14 +105,14 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
105
105
  : { data: normalizedData };
106
106
  });
107
107
  }, [normalizedSeries, stackNormalize]);
108
+ const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
109
+ const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
108
110
  const xAxisData = useMemo(() => {
109
111
  const dataPoints = normalizedSeries
110
112
  .map(s => s.data.map(item => item[0]))
111
113
  .flat();
112
- return xAxisTicks != null && xAxisTicks.length > 0
113
- ? xAxisTicks
114
- : getAxis(dataPoints).map(String);
115
- }, [normalizedSeries, xAxisTicks]);
114
+ return getAxis(dataPoints).map(String);
115
+ }, [normalizedSeries]);
116
116
  axisTooltipContextRef.current = { displaySeries, categoryAxisData: xAxisData };
117
117
  const option = useMemo(() => {
118
118
  // Build xAxis config (category with data indices)
@@ -140,7 +140,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
140
140
  show: false,
141
141
  },
142
142
  axisTick: {
143
- show: showXAxisTicks,
143
+ show: showXAxis && showXAxisTicks,
144
144
  lineStyle: {
145
145
  color: theme.axis.x.tickColor,
146
146
  width: theme.axis.x.tickWidth,
@@ -153,15 +153,15 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
153
153
  width: theme.axis.x.splitLineWidth,
154
154
  },
155
155
  },
156
+ boundaryGap,
157
+ ...(xAxisBounds ?? {}),
156
158
  };
157
- xAxisConfig.boundaryGap = boundaryGap;
158
- // Build yAxis config (value, auto-scale from data)
159
+ // Build yAxis config (value axis: optional min/max/interval; else ECharts auto-scale, except stack-normalized %)
159
160
  const yAxisConfig = {
160
161
  type: 'value',
161
- ...(stackNormalize && displaySeries.length > 1 && {
162
- min: 0,
163
- max: 100,
164
- }),
162
+ ...(stackNormalize && displaySeries.length > 1
163
+ ? { min: 0, max: 100 }
164
+ : (valueAxisBounds ?? {})),
165
165
  ...(yAxisLabel != null && yAxisLabel !== '' && {
166
166
  name: yAxisLabel,
167
167
  nameLocation: 'middle',
@@ -185,7 +185,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
185
185
  show: false,
186
186
  },
187
187
  axisTick: {
188
- show: showYAxisTicks,
188
+ show: showYAxis && showYAxisTicks,
189
189
  lineStyle: {
190
190
  color: theme.axis.y.tickColor,
191
191
  width: theme.axis.y.tickWidth,
@@ -340,9 +340,10 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
340
340
  tooltipOverlayActive,
341
341
  xAxisTickLabelFormatter,
342
342
  yAxisTickLabelFormatter,
343
- xAxisTicks,
344
343
  xAxisLabel,
345
344
  yAxisLabel,
345
+ valueAxisBounds,
346
+ xAxisBounds,
346
347
  ]);
347
348
  useEffect(() => {
348
349
  let chart;
package/axis.d.ts CHANGED
@@ -1,3 +1,29 @@
1
1
  export declare const getAxisByMinMax: (min?: number, max?: number, interval?: number) => number[];
2
2
  export declare const getAxis: (data: number[]) => number[];
3
+ /**
4
+ * Maps explicit Cartesian Y (value) axis props to axis `min` / `max` / `interval`.
5
+ * When all three are omitted, returns `undefined` so the chart library chooses the scale.
6
+ */
7
+ export declare function valueAxisBoundsFromProps(params: {
8
+ minY?: number;
9
+ maxY?: number;
10
+ intervalY?: number;
11
+ }): {
12
+ min?: number;
13
+ max?: number;
14
+ interval?: number;
15
+ } | undefined;
16
+ /**
17
+ * Maps explicit Cartesian X-axis props to axis `min` / `max` / `interval`.
18
+ * When all three are omitted, returns `undefined` so the chart library chooses the scale.
19
+ */
20
+ export declare function xAxisBoundsFromProps(params: {
21
+ minX?: number;
22
+ maxX?: number;
23
+ intervalX?: number;
24
+ }): {
25
+ min?: number;
26
+ max?: number;
27
+ interval?: number;
28
+ } | undefined;
3
29
  //# sourceMappingURL=axis.d.ts.map
package/axis.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../../components/chart/axis.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,YAAO,EAAE,YAAS,EAAE,WAAW,MAAM,aAUpE,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,aAIrC,CAAA"}
1
+ {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../../components/chart/axis.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,YAAO,EAAE,YAAS,EAAE,WAAW,MAAM,aAUpE,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,aAIrC,CAAA;AAiBD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAMhE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAMhE"}
package/axis.js CHANGED
@@ -14,3 +14,38 @@ export const getAxis = (data) => {
14
14
  const max = Math.max(...data);
15
15
  return getAxisByMinMax(min, max);
16
16
  };
17
+ function axisMinMaxIntervalFromFields(params) {
18
+ const out = {};
19
+ if (params.min !== undefined)
20
+ out.min = params.min;
21
+ if (params.max !== undefined)
22
+ out.max = params.max;
23
+ if (params.interval !== undefined)
24
+ out.interval = params.interval;
25
+ if (out.min === undefined && out.max === undefined && out.interval === undefined) {
26
+ return undefined;
27
+ }
28
+ return out;
29
+ }
30
+ /**
31
+ * Maps explicit Cartesian Y (value) axis props to axis `min` / `max` / `interval`.
32
+ * When all three are omitted, returns `undefined` so the chart library chooses the scale.
33
+ */
34
+ export function valueAxisBoundsFromProps(params) {
35
+ return axisMinMaxIntervalFromFields({
36
+ min: params.minY,
37
+ max: params.maxY,
38
+ interval: params.intervalY,
39
+ });
40
+ }
41
+ /**
42
+ * Maps explicit Cartesian X-axis props to axis `min` / `max` / `interval`.
43
+ * When all three are omitted, returns `undefined` so the chart library chooses the scale.
44
+ */
45
+ export function xAxisBoundsFromProps(params) {
46
+ return axisMinMaxIntervalFromFields({
47
+ min: params.minX,
48
+ max: params.maxX,
49
+ interval: params.intervalX,
50
+ });
51
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"bubble-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/bubble/bubble-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAO1D,+CAA+C;AAC/C,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAyW/E,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
1
+ {"version":3,"file":"bubble-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/bubble/bubble-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAQ1D,+CAA+C;AAC/C,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA6X/E,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
@@ -6,6 +6,7 @@ import { GridComponent, LegendComponent, TooltipComponent, } from 'echarts/compo
6
6
  import * as echarts from 'echarts/core';
7
7
  import React, { useEffect, useMemo, useRef } from 'react';
8
8
  import { View } from 'react-native';
9
+ import { valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
9
10
  import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
10
11
  import { createScatterTooltipPreset, useScatterItemTooltip } from '../scatter/tooltip';
11
12
  echarts.use([
@@ -22,7 +23,7 @@ function scaleSize(value, dataMin, dataMax, outMin, outMax) {
22
23
  return outMin + t * (outMax - outMin);
23
24
  }
24
25
  const DEFAULT_SIZE_RANGE = [8, 50];
25
- const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sizeRange = DEFAULT_SIZE_RANGE, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, onSelect, renderTooltip, ...props }) => {
26
+ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sizeRange = DEFAULT_SIZE_RANGE, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
26
27
  const { theme } = useChartTheme(props.theme, props.colors);
27
28
  const chartRef = useRef(null);
28
29
  const onSelectRef = useRef(onSelect);
@@ -77,6 +78,8 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
77
78
  selectContextRef.current = {
78
79
  normalizedSeries: normalizedSeries,
79
80
  };
81
+ const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
82
+ const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
80
83
  const option = useMemo(() => {
81
84
  const tooltipConfig = tooltipOverlayActive
82
85
  ? {
@@ -100,6 +103,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
100
103
  const xAxisConfig = {
101
104
  type: 'value',
102
105
  boundaryGap,
106
+ ...(xAxisBounds ?? {}),
103
107
  ...(xAxisLabel != null && xAxisLabel !== '' && {
104
108
  name: xAxisLabel,
105
109
  nameLocation: 'middle',
@@ -121,7 +125,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
121
125
  }
122
126
  : { show: false },
123
127
  axisTick: {
124
- show: showXAxisTicks,
128
+ show: showXAxis && showXAxisTicks,
125
129
  lineStyle: {
126
130
  color: theme.axis.x.tickColor,
127
131
  width: theme.axis.x.tickWidth,
@@ -137,6 +141,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
137
141
  };
138
142
  const yAxisConfig = {
139
143
  type: 'value',
144
+ ...(valueAxisBounds ?? {}),
140
145
  ...(yAxisLabel != null && yAxisLabel !== '' && {
141
146
  name: yAxisLabel,
142
147
  nameLocation: 'middle',
@@ -158,7 +163,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
158
163
  }
159
164
  : { show: false },
160
165
  axisTick: {
161
- show: showYAxisTicks,
166
+ show: showYAxis && showYAxisTicks,
162
167
  lineStyle: {
163
168
  color: theme.axis.y.tickColor,
164
169
  width: theme.axis.y.tickWidth,
@@ -251,6 +256,8 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
251
256
  yAxisTickLabelFormatter,
252
257
  xAxisLabel,
253
258
  yAxisLabel,
259
+ valueAxisBounds,
260
+ xAxisBounds,
254
261
  ]);
255
262
  useEffect(() => {
256
263
  let chart;
@@ -1 +1 @@
1
- {"version":3,"file":"candlestick-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/candlestick/candlestick-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,2BAA2B,CAAC;AASxF,OAAO,KAAqC,MAAM,OAAO,CAAC;AAG1D,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAyUzG,eAAO,MAAM,gBAAgB;;;;;;;CAE3B,CAAC"}
1
+ {"version":3,"file":"candlestick-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/candlestick/candlestick-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,2BAA2B,CAAC;AASxF,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAsVzG,eAAO,MAAM,gBAAgB;;;;;;;CAE3B,CAAC"}
@@ -5,6 +5,7 @@ import { BarChart, CandlestickChart as EChartsCandlestickChart, LineChart } from
5
5
  import { GridComponent, LegendComponent, TooltipComponent, } from 'echarts/components';
6
6
  import * as echarts from 'echarts/core';
7
7
  import React, { useEffect, useMemo, useRef } from 'react';
8
+ import { valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
8
9
  echarts.use([
9
10
  TooltipComponent,
10
11
  GridComponent,
@@ -14,25 +15,25 @@ echarts.use([
14
15
  BarChart,
15
16
  LineChart,
16
17
  ]);
17
- const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width = 220, height = 350, boundaryGap = true, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = true, positiveColor = '#008000', negativeColor = '#FF2C2C', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisTicks, xAxisLabel, yAxisLabel, onSelect, ...props }) => {
18
+ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width = 220, height = 350, boundaryGap = true, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = true, positiveColor = '#008000', negativeColor = '#FF2C2C', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, ...props }) => {
18
19
  const { theme } = useChartTheme(props.theme, undefined);
19
20
  const chartRef = useRef(null);
20
21
  const onSelectRef = useRef(onSelect);
21
22
  onSelectRef.current = onSelect;
22
23
  const selectContextRef = useRef({ categories: [], ohlcData: [] });
23
24
  const categories = useMemo(() => {
24
- if (xAxisTicks != null && xAxisTicks.length > 0)
25
- return xAxisTicks;
26
25
  if (xAxisData?.length)
27
26
  return xAxisData.map(String);
28
27
  return data.map((_, i) => String(i));
29
- }, [xAxisTicks, xAxisData, data]);
28
+ }, [xAxisData, data]);
30
29
  const hasVolume = volumeData != null && volumeData.length > 0;
31
30
  const hasMA = (ma5?.length ?? 0) > 0 || (ma10?.length ?? 0) > 0 || (ma20?.length ?? 0) > 0;
32
31
  selectContextRef.current = { categories, ohlcData: data };
33
32
  const option = useMemo(() => {
34
33
  if (!data?.length)
35
34
  return { series: [] };
35
+ const valueAxisBounds = valueAxisBoundsFromProps({ minY, maxY, intervalY });
36
+ const xAxisBounds = xAxisBoundsFromProps({ minX, maxX, intervalX });
36
37
  const tooltipConfig = showHighlighter
37
38
  ? {
38
39
  trigger: 'axis',
@@ -66,13 +67,14 @@ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width =
66
67
  ? { show: true, lineStyle: { color: theme.axis.x.lineColor, width: theme.axis.x.lineWidth } }
67
68
  : { show: false },
68
69
  axisTick: {
69
- show: showXAxisTicks,
70
+ show: showXAxis && showXAxisTicks,
70
71
  lineStyle: { color: theme.axis.x.tickColor, width: theme.axis.x.tickWidth },
71
72
  },
72
73
  splitLine: {
73
74
  show: showXAxisSplitLines,
74
75
  lineStyle: { color: theme.axis.x.splitLineColor, width: theme.axis.x.splitLineWidth },
75
76
  },
77
+ ...(xAxisBounds ?? {}),
76
78
  };
77
79
  if (hasVolume) {
78
80
  xAxisMain.gridIndex = 0;
@@ -80,7 +82,7 @@ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width =
80
82
  }
81
83
  const yAxisMain = {
82
84
  type: 'value',
83
- scale: true,
85
+ ...(valueAxisBounds ?? { scale: true }),
84
86
  ...(yAxisLabel != null && yAxisLabel !== '' && {
85
87
  name: yAxisLabel,
86
88
  nameLocation: 'middle',
@@ -96,7 +98,7 @@ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width =
96
98
  ? { show: true, lineStyle: { color: theme.axis.y.lineColor, width: theme.axis.y.lineWidth } }
97
99
  : { show: false },
98
100
  axisTick: {
99
- show: showYAxisTicks,
101
+ show: showYAxis && showYAxisTicks,
100
102
  lineStyle: { color: theme.axis.y.tickColor, width: theme.axis.y.tickWidth },
101
103
  },
102
104
  splitLine: {
@@ -230,9 +232,14 @@ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width =
230
232
  negativeColor,
231
233
  xAxisTickLabelFormatter,
232
234
  yAxisTickLabelFormatter,
233
- xAxisTicks,
234
235
  xAxisLabel,
235
236
  yAxisLabel,
237
+ minX,
238
+ maxX,
239
+ intervalX,
240
+ minY,
241
+ maxY,
242
+ intervalY,
236
243
  ]);
237
244
  useEffect(() => {
238
245
  let chart;
@@ -1 +1 @@
1
- {"version":3,"file":"column-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/column/column-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAO1D,oCAAoC;AACpC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAqnB7D,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
1
+ {"version":3,"file":"column-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/column/column-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAO1D,oCAAoC;AACpC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAqoB7D,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
@@ -6,7 +6,7 @@ import { GridComponent, LegendComponent, TooltipComponent, } from 'echarts/compo
6
6
  import * as echarts from 'echarts/core';
7
7
  import React, { useEffect, useMemo, useRef } from 'react';
8
8
  import { View } from 'react-native';
9
- import { getAxis } from '../axis';
9
+ import { getAxis, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
10
10
  import { createAxisTooltipPreset, useAxisTooltip } from '../cartesian/tooltip';
11
11
  echarts.use([
12
12
  TooltipComponent,
@@ -24,7 +24,7 @@ function columnCornerRadiusDep(value) {
24
24
  return value.join(',');
25
25
  return '4,4,0,0';
26
26
  }
27
- const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, cornerRadius = DEFAULT_COLUMN_CORNER_RADIUS, horizontal = false, stack, stackNormalize = false, activeIndex, activeColor, barInsideLabelPosition = 'start', barInsideLabelFormatter, barOutsideLabelPosition = 'start', barOutsideLabelFormatter, itemStyle, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = false, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisTicks, xAxisLabel, yAxisLabel, onSelect, renderTooltip, ...props }) => {
27
+ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, cornerRadius = DEFAULT_COLUMN_CORNER_RADIUS, horizontal = false, stack, stackNormalize = false, activeIndex, activeColor, barInsideLabelPosition = 'start', barInsideLabelFormatter, barOutsideLabelPosition = 'start', barOutsideLabelFormatter, itemStyle, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = false, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
28
28
  const { theme } = useChartTheme(props.theme, props.colors);
29
29
  const chartRef = useRef(null);
30
30
  const onSelectRef = useRef(onSelect);
@@ -116,6 +116,8 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
116
116
  };
117
117
  });
118
118
  }, [normalizedSeries, stackNormalize]);
119
+ const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
120
+ const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
119
121
  const showLabelInside = barInsideLabelFormatter != null;
120
122
  const showLabelOutside = barOutsideLabelFormatter != null;
121
123
  const isSingleSeries = displaySeries.length === 1;
@@ -123,12 +125,8 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
123
125
  const categoryAxisData = useMemo(() => {
124
126
  const categories = (displaySeries[0]?.data ?? []).map((item) => String(item[0]));
125
127
  const dataPoints = displaySeries.flatMap((s) => s.data.map((d) => d[1]));
126
- return xAxisTicks != null && xAxisTicks.length > 0
127
- ? xAxisTicks
128
- : categories.length > 0
129
- ? categories
130
- : getAxis(dataPoints).map(String);
131
- }, [displaySeries, xAxisTicks]);
128
+ return categories.length > 0 ? categories : getAxis(dataPoints).map(String);
129
+ }, [displaySeries]);
132
130
  selectContextRef.current = {
133
131
  displaySeries,
134
132
  categoryAxisData,
@@ -142,6 +140,7 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
142
140
  type: 'category',
143
141
  data: xAxisData,
144
142
  boundaryGap,
143
+ ...(!horizontal ? (xAxisBounds ?? {}) : {}),
145
144
  ...((horizontal ? yAxisLabel : xAxisLabel) != null && (horizontal ? yAxisLabel : xAxisLabel) !== '' && {
146
145
  name: horizontal ? yAxisLabel : xAxisLabel,
147
146
  nameLocation: 'middle',
@@ -177,13 +176,15 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
177
176
  },
178
177
  },
179
178
  };
179
+ const stackPct = stackNormalize && displaySeries.length > 1;
180
+ const valueAxisNumericExtras = stackPct
181
+ ? { min: 0, max: 100 }
182
+ : horizontal
183
+ ? { ...(valueAxisBounds ?? {}), ...(xAxisBounds ?? {}) }
184
+ : (valueAxisBounds ?? {});
180
185
  const valueAxisConfig = {
181
186
  type: 'value',
182
- ...(stackNormalize &&
183
- displaySeries.length > 1 && {
184
- min: 0,
185
- max: 100,
186
- }),
187
+ ...valueAxisNumericExtras,
187
188
  ...((horizontal ? xAxisLabel : yAxisLabel) != null && (horizontal ? xAxisLabel : yAxisLabel) !== '' && {
188
189
  name: horizontal ? xAxisLabel : yAxisLabel,
189
190
  nameLocation: 'middle',
@@ -452,10 +453,11 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
452
453
  tooltipOverlayActive,
453
454
  xAxisTickLabelFormatter,
454
455
  yAxisTickLabelFormatter,
455
- xAxisTicks,
456
456
  xAxisLabel,
457
457
  yAxisLabel,
458
458
  categoryAxisData,
459
+ valueAxisBounds,
460
+ xAxisBounds,
459
461
  ]);
460
462
  useEffect(() => {
461
463
  let chart;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker/react-native-echarts",
3
- "version": "1.0.0-dev.8",
3
+ "version": "1.0.0-dev.9",
4
4
  "description": "React Native chart components built on using e-charts library.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,23 +43,39 @@ export interface CartesianChartProps extends CommonChartProps {
43
43
  */
44
44
  boundaryGap?: boolean;
45
45
  /**
46
- * Custom X-axis tick values (numbers only). When provided, used as the x-axis data; labels are
47
- * generated using xAxisTickLabelFormatter. Otherwise each chart derives x-axis from data.
48
- * @default undefined
46
+ * X-axis minimum when set. Applies to the chart’s **X** axis (category or value, depending on the chart).
47
+ * For horizontal column/bar, the **value** (bar length) scale is on **X** — use `minX` / `maxX` / `intervalX` for that scale.
48
+ * When omitted, the minimum is derived from the data or chosen automatically.
49
49
  */
50
- xAxisTicks?: number[];
50
+ minX?: number;
51
51
  /**
52
- * Custom Y-axis tick positions (for value axis).
53
- * @default undefined
52
+ * X-axis maximum when set. See {@link minX} for layout notes. When omitted, the maximum is derived from the data or chosen automatically.
53
+ */
54
+ maxX?: number;
55
+ /**
56
+ * X-axis tick interval when set. See {@link minX} for layout notes. When omitted, the tick step is chosen automatically.
57
+ */
58
+ intervalX?: number;
59
+ /**
60
+ * Y-axis (value scale) minimum when set. Applies to the chart’s **Y** axis.
61
+ * When omitted, the minimum is derived from the data or chosen automatically.
62
+ */
63
+ minY?: number;
64
+ /**
65
+ * Y-axis (value scale) maximum when set. When omitted, the maximum is derived from the data or chosen automatically.
66
+ */
67
+ maxY?: number;
68
+ /**
69
+ * Y-axis (value scale) tick interval when set. When omitted, the tick step is chosen automatically.
54
70
  */
55
- yAxisTicks?: number[];
71
+ intervalY?: number;
56
72
  /**
57
73
  * Whether to show the X-axis line and labels.
58
74
  * @default true
59
75
  */
60
76
  showXAxis?: boolean;
61
77
  /**
62
- * Whether to show X-axis tick marks.
78
+ * Whether to show X-axis tick marks. Only applies when {@link showXAxis} is true.
63
79
  * @default true
64
80
  */
65
81
  showXAxisTicks?: boolean;
@@ -69,7 +85,7 @@ export interface CartesianChartProps extends CommonChartProps {
69
85
  */
70
86
  showYAxis?: boolean;
71
87
  /**
72
- * Whether to show Y-axis tick marks.
88
+ * Whether to show Y-axis tick marks. Only applies when {@link showYAxis} is true.
73
89
  * @default true
74
90
  */
75
91
  showYAxisTicks?: boolean;
@@ -103,7 +119,7 @@ export interface CartesianChartProps extends CommonChartProps {
103
119
  */
104
120
  showLegend?: boolean;
105
121
  /**
106
- * Whether ECharts applies **emphasis** (hover highlight) while the axis pointer / tooltip is near the series.
122
+ * Whether **emphasis** (hover highlight) is applied while the axis pointer / tooltip is near the series.
107
123
  * Column and bar charts default this to `false`; area defaults to `true`.
108
124
  */
109
125
  showHighlighter?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"cartesian.d.ts","sourceRoot":"","sources":["../../../../components/chart/props/cartesian.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,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AO,CAAC;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;OAEG;IACH,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7E;;OAEG;IACH,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7E;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACtD;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,SAAS,CAAC;CAC1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"scatter-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAS/D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAQ1D,qCAAqC;AACrC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA4XlF,eAAO,MAAM,YAAY;;;;;;;CAEvB,CAAC"}
1
+ {"version":3,"file":"scatter-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAS/D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAQ1D,qCAAqC;AACrC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA2YlF,eAAO,MAAM,YAAY;;;;;;;CAEvB,CAAC"}
@@ -6,7 +6,7 @@ import { GridComponent, LegendComponent, TooltipComponent, } from 'echarts/compo
6
6
  import * as echarts from 'echarts/core';
7
7
  import React, { useEffect, useMemo, useRef } from 'react';
8
8
  import { View } from 'react-native';
9
- import { getAxis } from '../axis';
9
+ import { getAxis, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
10
10
  import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
11
11
  import { createScatterTooltipPreset, useScatterItemTooltip } from './tooltip';
12
12
  echarts.use([
@@ -34,7 +34,7 @@ function linearRegression(points) {
34
34
  const intercept = (sumY - slope * sumX) / n;
35
35
  return { slope, intercept };
36
36
  }
37
- const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', symbolSize = 8, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, tooltip = 'card', showRegressionLine = false, xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisTicks, xAxisLabel, yAxisLabel, onSelect, renderTooltip, ...props }) => {
37
+ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', symbolSize = 8, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, tooltip = 'card', showRegressionLine = false, xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
38
38
  const { theme } = useChartTheme(props.theme, props.colors);
39
39
  const chartRef = useRef(null);
40
40
  const onSelectRef = useRef(onSelect);
@@ -72,11 +72,11 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
72
72
  }, [data]);
73
73
  const hasNamedSeries = useMemo(() => normalizedSeries.some((s) => 'name' in s && s.name), [normalizedSeries]);
74
74
  selectContextRef.current = { normalizedSeries };
75
+ const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
76
+ const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
75
77
  const option = useMemo(() => {
76
78
  const dataPoints = normalizedSeries.map(s => s.data.map(item => item[0])).flat();
77
- const xAxisData = xAxisTicks != null && xAxisTicks.length > 0
78
- ? xAxisTicks
79
- : getAxis(dataPoints).map(String);
79
+ const xAxisData = getAxis(dataPoints).map(String);
80
80
  const tooltipConfig = tooltipOverlayActive
81
81
  ? {
82
82
  trigger: 'item',
@@ -96,11 +96,12 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
96
96
  }),
97
97
  }
98
98
  : { show: false };
99
- // Scatter uses value axes for both x and y (data is [x, y] pairs)
99
+ // X: category from binned coordinates; Y: value (data is [x, y] pairs)
100
100
  const xAxisConfig = {
101
101
  type: 'category',
102
102
  boundaryGap,
103
103
  data: xAxisData,
104
+ ...(xAxisBounds ?? {}),
104
105
  ...(xAxisLabel != null && xAxisLabel !== '' && {
105
106
  name: xAxisLabel,
106
107
  nameLocation: 'middle',
@@ -122,7 +123,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
122
123
  }
123
124
  : { show: false },
124
125
  axisTick: {
125
- show: showXAxisTicks,
126
+ show: showXAxis && showXAxisTicks,
126
127
  lineStyle: {
127
128
  color: theme.axis.x.tickColor,
128
129
  width: theme.axis.x.tickWidth,
@@ -138,6 +139,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
138
139
  };
139
140
  const yAxisConfig = {
140
141
  type: 'value',
142
+ ...(valueAxisBounds ?? {}),
141
143
  ...(yAxisLabel != null && yAxisLabel !== '' && {
142
144
  name: yAxisLabel,
143
145
  nameLocation: 'middle',
@@ -159,7 +161,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
159
161
  }
160
162
  : { show: false },
161
163
  axisTick: {
162
- show: showYAxisTicks,
164
+ show: showYAxis && showYAxisTicks,
163
165
  lineStyle: {
164
166
  color: theme.axis.y.tickColor,
165
167
  width: theme.axis.y.tickWidth,
@@ -269,9 +271,10 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
269
271
  showRegressionLine,
270
272
  xAxisTickLabelFormatter,
271
273
  yAxisTickLabelFormatter,
272
- xAxisTicks,
273
274
  xAxisLabel,
274
275
  yAxisLabel,
276
+ valueAxisBounds,
277
+ xAxisBounds,
275
278
  ]);
276
279
  useEffect(() => {
277
280
  let chart;