@wavemaker/react-native-echarts 1.0.0-dev.12 → 1.0.0-dev.14

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;AAS1D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,UAAU,GACX,MAAM,oBAAoB,CAAC;AAuf5B,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;AAS1D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,UAAU,GACX,MAAM,oBAAoB,CAAC;AAkgB5B,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, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
10
+ import { getAxis, valueAxisBoundsFromProps, categoryAxisBoundsFromProps } from '../axis';
11
11
  import { echartsLegendLayoutFragment, mergeCartesianGridForLegend, } from '../legend/echarts-legend-layout';
12
12
  // Register necessary components for this chart
13
13
  echarts.use([
@@ -46,7 +46,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
46
46
  });
47
47
  // Derive smooth/step from type
48
48
  const effectiveSmooth = type === 'smooth';
49
- const effectiveStep = type === 'step' ? (step ?? 'start') : (step ?? false);
49
+ const effectiveStep = type === 'step' ? (step ?? 'start') : false;
50
50
  // Normalize data to array of { data: number[] } or { name: string; data: number[] }
51
51
  const normalizedSeries = useMemo(() => {
52
52
  let normalizedData = [];
@@ -89,25 +89,29 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
89
89
  const len = normalizedSeries[0]?.data?.length ?? 0;
90
90
  if (len === 0)
91
91
  return normalizedSeries;
92
- return normalizedSeries.map(s => {
92
+ return normalizedSeries.map((s) => {
93
93
  const rawData = s.data;
94
94
  const sumsAt = new Array(len).fill(0);
95
- normalizedSeries.forEach((other, _i) => {
95
+ normalizedSeries.forEach((other) => {
96
96
  const d = 'data' in other ? other.data : [];
97
- d.forEach((v, i) => { if (i < len)
98
- sumsAt[i] += v; });
97
+ d.forEach((v, i) => {
98
+ if (i < len)
99
+ sumsAt[i] += typeof v === 'number' ? v : v[1];
100
+ });
99
101
  });
100
102
  const normalizedData = rawData.map((v, i) => {
103
+ const val = typeof v === 'number' ? v : v[1];
101
104
  const sum = sumsAt[i] || 1;
102
- return sum > 0 ? (v[1] / sum) * 100 : 0;
105
+ return sum > 0 ? (val / sum) * 100 : 0;
103
106
  });
104
- return 'name' in s && s.name
105
- ? { name: s.name, data: normalizedData }
106
- : { data: normalizedData };
107
+ return {
108
+ name: s.name,
109
+ data: rawData.map((v, i) => [typeof v === 'number' ? String(i) : v[0], normalizedData[i]]),
110
+ };
107
111
  });
108
112
  }, [normalizedSeries, stackNormalize]);
109
113
  const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
110
- const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
114
+ const categoryAxisBounds = useMemo(() => categoryAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
111
115
  const xAxisData = useMemo(() => {
112
116
  const dataPoints = normalizedSeries
113
117
  .map(s => s.data.map(item => item[0]))
@@ -130,6 +134,9 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
130
134
  show: showXAxis || xAxisTickLabelFormatter != null,
131
135
  color: theme.axis.x.tickLabelColor,
132
136
  formatter: xAxisTickLabelFormatter ?? undefined,
137
+ ...(categoryAxisBounds?.axisLabelInterval !== undefined
138
+ ? { interval: categoryAxisBounds.axisLabelInterval }
139
+ : {}),
133
140
  },
134
141
  axisLine: showXAxis ? {
135
142
  show: true,
@@ -155,7 +162,8 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
155
162
  },
156
163
  },
157
164
  boundaryGap,
158
- ...(xAxisBounds ?? {}),
165
+ ...(categoryAxisBounds?.min !== undefined && { min: categoryAxisBounds.min }),
166
+ ...(categoryAxisBounds?.max !== undefined && { max: categoryAxisBounds.max }),
159
167
  };
160
168
  // Build yAxis config (value axis: optional min/max/interval; else ECharts auto-scale, except stack-normalized %)
161
169
  const yAxisConfig = {
@@ -348,7 +356,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
348
356
  xAxisLabel,
349
357
  yAxisLabel,
350
358
  valueAxisBounds,
351
- xAxisBounds,
359
+ categoryAxisBounds,
352
360
  ]);
353
361
  useEffect(() => {
354
362
  let chart;
package/axis.d.ts CHANGED
@@ -26,4 +26,17 @@ export declare function xAxisBoundsFromProps(params: {
26
26
  max?: number;
27
27
  interval?: number;
28
28
  } | undefined;
29
+ /**
30
+ * Category-axis bounds: `min` / `max` on the axis; `intervalX` maps to `axisLabel.interval`
31
+ * (ECharts skips `interval` on category axes at the root).
32
+ */
33
+ export declare function categoryAxisBoundsFromProps(params: {
34
+ minX?: number;
35
+ maxX?: number;
36
+ intervalX?: number;
37
+ }): {
38
+ min?: number;
39
+ max?: number;
40
+ axisLabelInterval?: number;
41
+ } | undefined;
29
42
  //# 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;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"}
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;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,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,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAYzE"}
package/axis.js CHANGED
@@ -49,3 +49,23 @@ export function xAxisBoundsFromProps(params) {
49
49
  interval: params.intervalX,
50
50
  });
51
51
  }
52
+ /**
53
+ * Category-axis bounds: `min` / `max` on the axis; `intervalX` maps to `axisLabel.interval`
54
+ * (ECharts skips `interval` on category axes at the root).
55
+ */
56
+ export function categoryAxisBoundsFromProps(params) {
57
+ const raw = xAxisBoundsFromProps(params);
58
+ if (!raw)
59
+ return undefined;
60
+ const { min, max, interval } = raw;
61
+ const out = {};
62
+ if (min !== undefined)
63
+ out.min = min;
64
+ if (max !== undefined)
65
+ out.max = max;
66
+ if (interval !== undefined) {
67
+ // intervalX step N → show every Nth category label (0, N, 2N, …)
68
+ out.axisLabelInterval = interval <= 1 ? 0 : interval - 1;
69
+ }
70
+ return Object.keys(out).length > 0 ? out : undefined;
71
+ }
@@ -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;AAK1D,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAwWzG,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;AAK1D,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AA4WzG,eAAO,MAAM,gBAAgB;;;;;;;CAE3B,CAAC"}
@@ -5,7 +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
+ import { valueAxisBoundsFromProps, categoryAxisBoundsFromProps } from '../axis';
9
9
  import { echartsLegendLayoutFragment } from '../legend/echarts-legend-layout';
10
10
  echarts.use([
11
11
  TooltipComponent,
@@ -34,7 +34,7 @@ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width =
34
34
  if (!data?.length)
35
35
  return { series: [] };
36
36
  const valueAxisBounds = valueAxisBoundsFromProps({ minY, maxY, intervalY });
37
- const xAxisBounds = xAxisBoundsFromProps({ minX, maxX, intervalX });
37
+ const categoryAxisBounds = categoryAxisBoundsFromProps({ minX, maxX, intervalX });
38
38
  const tooltipConfig = showHighlighter
39
39
  ? {
40
40
  trigger: 'axis',
@@ -81,6 +81,9 @@ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width =
81
81
  show: showXAxis || xAxisTickLabelFormatter != null,
82
82
  color: theme.axis.x.tickLabelColor,
83
83
  formatter: xAxisTickLabelFormatter ?? undefined,
84
+ ...(categoryAxisBounds?.axisLabelInterval !== undefined
85
+ ? { interval: categoryAxisBounds.axisLabelInterval }
86
+ : {}),
84
87
  },
85
88
  axisLine: showXAxis
86
89
  ? { show: true, lineStyle: { color: theme.axis.x.lineColor, width: theme.axis.x.lineWidth } }
@@ -93,7 +96,8 @@ const ChartComponent = ({ data, xAxisData, volumeData, ma5, ma10, ma20, width =
93
96
  show: showXAxisSplitLines,
94
97
  lineStyle: { color: theme.axis.x.splitLineColor, width: theme.axis.x.splitLineWidth },
95
98
  },
96
- ...(xAxisBounds ?? {}),
99
+ ...(categoryAxisBounds?.min !== undefined && { min: categoryAxisBounds.min }),
100
+ ...(categoryAxisBounds?.max !== undefined && { max: categoryAxisBounds.max }),
97
101
  };
98
102
  if (hasVolume) {
99
103
  xAxisMain.gridIndex = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"chart-container.d.ts","sourceRoot":"","sources":["../../../components/chart/chart-container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAqGrD,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,GAAG,UAAU,MAAM,EAAE,MACrG,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,sBAmB/F,CAAC"}
1
+ {"version":3,"file":"chart-container.d.ts","sourceRoot":"","sources":["../../../components/chart/chart-container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAqG9D,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,GAAG,UAAU,MAAM,EAAE,MACrG,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,sBA+B/F,CAAC"}
@@ -1,4 +1,4 @@
1
- import React, { useState, useCallback } from 'react';
1
+ import React, { useState, useCallback, useMemo } from 'react';
2
2
  import { View, StyleSheet, Text } from 'react-native';
3
3
  const ChartContainer = ({ width = '100%', height = 350, data, noDataText = 'No data to render chart.', noDataIcon, noDataTextStyle = {}, noDataContainerStyle = {}, render, style, }) => {
4
4
  const [dimensions, setDimensions] = useState(null);
@@ -26,7 +26,7 @@ const ChartContainer = ({ width = '100%', height = 350, data, noDataText = 'No d
26
26
  height: typeof height === 'number' ? height : height,
27
27
  };
28
28
  return (<View style={[styles.container, containerStyle, style]} onLayout={handleLayout}>
29
- {data ? (dimensions ? render(dimensions.width, dimensions.height) : null) : (<View style={[styles.noDataContainer, noDataContainerStyle, style]}>
29
+ {data !== undefined && data !== null ? (dimensions ? render(dimensions.width, dimensions.height) : null) : (<View style={[styles.noDataContainer, noDataContainerStyle, style]}>
30
30
  <Text style={[styles.noDataText, noDataTextStyle]}>{noDataText}</Text>
31
31
  </View>)}
32
32
  </View>);
@@ -50,6 +50,18 @@ const styles = StyleSheet.create({
50
50
  });
51
51
  export const withResponsiveContainer = (Component, ...dataName) => {
52
52
  return (props) => {
53
+ const width = useMemo(() => {
54
+ if (typeof props.width === 'string' && !props.width.endsWith('%')) {
55
+ return parseFloat(props.width.match(/\d+/)?.[0] || '0');
56
+ }
57
+ return props.width;
58
+ }, [props.width]);
59
+ const height = useMemo(() => {
60
+ if (typeof props.height === 'string' && !props.height.endsWith('%')) {
61
+ return parseFloat(props.height.match(/\d+/)?.[0] || '0');
62
+ }
63
+ return props.height;
64
+ }, [props.height]);
53
65
  const render = useCallback((width, height) => {
54
66
  return React.createElement(Component, {
55
67
  ...props,
@@ -57,7 +69,7 @@ export const withResponsiveContainer = (Component, ...dataName) => {
57
69
  height: height,
58
70
  });
59
71
  }, [props]);
60
- const data = dataName.length > 0 ? dataName.find((name) => !!props[name]) || props.data : props.data;
61
- return (<ChartContainer width={props.width} height={props.height} style={props.style} data={data} render={render} noDataText={props.noDataText}/>);
72
+ const data = dataName.length > 0 ? dataName.find((name) => props[name] !== undefined) || props.data : props.data;
73
+ return (<ChartContainer width={width} height={height} style={props.style} data={data} render={render} noDataText={props.noDataText}/>);
62
74
  };
63
75
  };
@@ -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;AAW1D,oCAAoC;AACpC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAgpB7D,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;AAW1D,oCAAoC;AACpC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA0qB7D,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, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
9
+ import { getAxis, valueAxisBoundsFromProps, xAxisBoundsFromProps, categoryAxisBoundsFromProps } from '../axis';
10
10
  import { createAxisTooltipPreset, useAxisTooltip } from '../cartesian/tooltip';
11
11
  import { echartsLegendLayoutFragment, mergeCartesianGridForLegend, } from '../legend/echarts-legend-layout';
12
12
  echarts.use([
@@ -119,6 +119,9 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
119
119
  }, [normalizedSeries, stackNormalize]);
120
120
  const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
121
121
  const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
122
+ const categoryAxisBounds = useMemo(() => horizontal
123
+ ? categoryAxisBoundsFromProps({ minX: minY, maxX: maxY, intervalX: intervalY })
124
+ : categoryAxisBoundsFromProps({ minX, maxX, intervalX }), [horizontal, minX, maxX, intervalX, minY, maxY, intervalY]);
122
125
  const showLabelInside = barInsideLabelFormatter != null;
123
126
  const showLabelOutside = barOutsideLabelFormatter != null;
124
127
  const isSingleSeries = displaySeries.length === 1;
@@ -137,43 +140,59 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
137
140
  const option = useMemo(() => {
138
141
  const categories = (displaySeries[0]?.data ?? []).map((item) => String(item[0]));
139
142
  const xAxisData = categoryAxisData;
143
+ const categoryShow = horizontal ? showYAxis : showXAxis;
144
+ const categoryShowTicks = horizontal ? showYAxisTicks : showXAxisTicks;
145
+ const categoryShowSplitLines = horizontal ? showYAxisSplitLines : showXAxisSplitLines;
146
+ const categoryTickFormatter = horizontal ? yAxisTickLabelFormatter : xAxisTickLabelFormatter;
147
+ const categoryAxisTheme = horizontal ? theme.axis.y : theme.axis.x;
148
+ const categoryAxisTitle = horizontal ? yAxisLabel : xAxisLabel;
149
+ const valueShow = horizontal ? showXAxis : showYAxis;
150
+ const valueShowTicks = horizontal ? showXAxisTicks : showYAxisTicks;
151
+ const valueShowSplitLines = horizontal ? showXAxisSplitLines : showYAxisSplitLines;
152
+ const valueTickFormatter = horizontal ? xAxisTickLabelFormatter : yAxisTickLabelFormatter;
153
+ const valueAxisTheme = horizontal ? theme.axis.x : theme.axis.y;
154
+ const valueAxisTitle = horizontal ? xAxisLabel : yAxisLabel;
140
155
  const categoryAxisConfig = {
141
156
  type: 'category',
142
157
  data: xAxisData,
143
158
  boundaryGap,
144
- ...(!horizontal ? (xAxisBounds ?? {}) : {}),
145
- ...((horizontal ? yAxisLabel : xAxisLabel) != null && (horizontal ? yAxisLabel : xAxisLabel) !== '' && {
146
- name: horizontal ? yAxisLabel : xAxisLabel,
159
+ ...(categoryAxisBounds?.min !== undefined && { min: categoryAxisBounds.min }),
160
+ ...(categoryAxisBounds?.max !== undefined && { max: categoryAxisBounds.max }),
161
+ ...(categoryAxisTitle != null && categoryAxisTitle !== '' && {
162
+ name: categoryAxisTitle,
147
163
  nameLocation: 'middle',
148
164
  nameGap: 25,
149
- nameTextStyle: { color: horizontal ? theme.axis.y.tickLabelColor : theme.axis.x.tickLabelColor },
165
+ nameTextStyle: { color: categoryAxisTheme.tickLabelColor },
150
166
  }),
151
167
  axisLabel: {
152
- show: showXAxis || xAxisTickLabelFormatter != null,
153
- color: theme.axis.x.tickLabelColor,
154
- formatter: xAxisTickLabelFormatter ?? undefined,
168
+ show: categoryShow || categoryTickFormatter != null,
169
+ color: categoryAxisTheme.tickLabelColor,
170
+ formatter: categoryTickFormatter ?? undefined,
171
+ ...(categoryAxisBounds?.axisLabelInterval !== undefined
172
+ ? { interval: categoryAxisBounds.axisLabelInterval }
173
+ : {}),
155
174
  },
156
- axisLine: showXAxis
175
+ axisLine: categoryShow
157
176
  ? {
158
177
  show: true,
159
178
  lineStyle: {
160
- color: theme.axis.x.lineColor,
161
- width: theme.axis.x.lineWidth,
179
+ color: categoryAxisTheme.lineColor,
180
+ width: categoryAxisTheme.lineWidth,
162
181
  },
163
182
  }
164
183
  : { show: false },
165
184
  axisTick: {
166
- show: showXAxis && showXAxisTicks,
185
+ show: categoryShow && categoryShowTicks,
167
186
  lineStyle: {
168
- color: theme.axis.x.tickColor,
169
- width: theme.axis.x.tickWidth,
187
+ color: categoryAxisTheme.tickColor,
188
+ width: categoryAxisTheme.tickWidth,
170
189
  },
171
190
  },
172
191
  splitLine: {
173
- show: showXAxisSplitLines,
192
+ show: categoryShowSplitLines,
174
193
  lineStyle: {
175
- color: theme.axis.x.splitLineColor,
176
- width: theme.axis.x.splitLineWidth,
194
+ color: categoryAxisTheme.splitLineColor,
195
+ width: categoryAxisTheme.splitLineWidth,
177
196
  },
178
197
  },
179
198
  };
@@ -181,46 +200,46 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
181
200
  const valueAxisNumericExtras = stackPct
182
201
  ? { min: 0, max: 100 }
183
202
  : horizontal
184
- ? { ...(valueAxisBounds ?? {}), ...(xAxisBounds ?? {}) }
203
+ ? (xAxisBounds ?? {})
185
204
  : (valueAxisBounds ?? {});
186
205
  const valueAxisConfig = {
187
206
  type: 'value',
188
207
  ...valueAxisNumericExtras,
189
- ...((horizontal ? xAxisLabel : yAxisLabel) != null && (horizontal ? xAxisLabel : yAxisLabel) !== '' && {
190
- name: horizontal ? xAxisLabel : yAxisLabel,
208
+ ...(valueAxisTitle != null && valueAxisTitle !== '' && {
209
+ name: valueAxisTitle,
191
210
  nameLocation: 'middle',
192
211
  nameGap: 40,
193
- nameTextStyle: { color: horizontal ? theme.axis.x.tickLabelColor : theme.axis.y.tickLabelColor },
212
+ nameTextStyle: { color: valueAxisTheme.tickLabelColor },
194
213
  }),
195
214
  axisLabel: {
196
- show: showYAxis || yAxisTickLabelFormatter != null,
197
- color: theme.axis.y.tickLabelColor,
198
- formatter: yAxisTickLabelFormatter ??
215
+ show: valueShow || valueTickFormatter != null,
216
+ color: valueAxisTheme.tickLabelColor,
217
+ formatter: valueTickFormatter ??
199
218
  (stackNormalize && displaySeries.length > 1
200
219
  ? (value) => `${value}%`
201
220
  : undefined),
202
221
  },
203
- axisLine: showYAxis
222
+ axisLine: valueShow
204
223
  ? {
205
224
  show: true,
206
225
  lineStyle: {
207
- color: theme.axis.y.lineColor,
208
- width: theme.axis.y.lineWidth,
226
+ color: valueAxisTheme.lineColor,
227
+ width: valueAxisTheme.lineWidth,
209
228
  },
210
229
  }
211
230
  : { show: false },
212
231
  axisTick: {
213
- show: showYAxis && showYAxisTicks,
232
+ show: valueShow && valueShowTicks,
214
233
  lineStyle: {
215
- color: theme.axis.y.tickColor,
216
- width: theme.axis.y.tickWidth,
234
+ color: valueAxisTheme.tickColor,
235
+ width: valueAxisTheme.tickWidth,
217
236
  },
218
237
  },
219
238
  splitLine: {
220
- show: showYAxisSplitLines,
239
+ show: valueShowSplitLines,
221
240
  lineStyle: {
222
- color: theme.axis.y.splitLineColor,
223
- width: theme.axis.y.splitLineWidth,
241
+ color: valueAxisTheme.splitLineColor,
242
+ width: valueAxisTheme.splitLineWidth,
224
243
  },
225
244
  },
226
245
  };
@@ -462,6 +481,7 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
462
481
  yAxisLabel,
463
482
  categoryAxisData,
464
483
  valueAxisBounds,
484
+ categoryAxisBounds,
465
485
  xAxisBounds,
466
486
  ]);
467
487
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"digital.gauge.d.ts","sourceRoot":"","sources":["../../../../../components/chart/gauge/digital/digital.gauge.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;GAGG;AACH,UAAU,iBAAkB,SAAQ,cAAc;IAChD;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AA+UD,eAAO,MAAM,YAAY;;;;;;;CAEvB,CAAC"}
1
+ {"version":3,"file":"digital.gauge.d.ts","sourceRoot":"","sources":["../../../../../components/chart/gauge/digital/digital.gauge.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAGpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;GAGG;AACH,UAAU,iBAAkB,SAAQ,cAAc;IAChD;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAyVD,eAAO,MAAM,YAAY;;;;;;;CAEvB,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import { withResponsiveContainer } from '../../chart-container';
2
2
  import { useChartTheme, withChartTheme } from '../../chart-theme.context';
3
- import React, { useEffect, useRef, useState } from 'react';
3
+ import { getAxisByMinMax } from '../../axis';
4
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
4
5
  import { useWindowDimensions } from 'react-native';
5
6
  import Svg, { Defs, G, LinearGradient, Path, Stop, Text as SvgText } from 'react-native-svg';
6
7
  // SVG Gauge Component
7
- const SVGGaugeChart = ({ value, max = 100, showInnerArc = false, width, height, animationDuration = 1000, colors, axisBgColor: axisBgColorProp, axisWidth: axisWidthProp, tickColor: tickColorProp, }) => {
8
+ const SVGGaugeChart = ({ value, min = 0, max = 100, showInnerArc = false, width, height, animationDuration = 1000, colors, axisBgColor: axisBgColorProp, axisWidth: axisWidthProp, tickColor: tickColorProp, }) => {
8
9
  const { theme: chartTheme } = useChartTheme(undefined, colors);
9
10
  // Use theme colors; allow overrides from props
10
11
  const gradientColors = chartTheme.series.map(item => item.color);
@@ -50,6 +51,13 @@ const SVGGaugeChart = ({ value, max = 100, showInnerArc = false, width, height,
50
51
  }
51
52
  };
52
53
  }, [value, animationDuration]);
54
+ const { majorTickPositions, minorStep } = useMemo(() => {
55
+ const scaleRange = Math.max(max - min, 1);
56
+ const majors = getAxisByMinMax(min, max);
57
+ const majorInterval = majors.length >= 2 ? majors[1] - majors[0] : Math.max(scaleRange / 5, 1);
58
+ const step = Math.max(1, Math.round(majorInterval / 10));
59
+ return { majorTickPositions: majors, minorStep: step };
60
+ }, [min, max]);
53
61
  // If height not provided, use 90% of available height
54
62
  // If width not provided, use the same as height to keep it square
55
63
  const calculatedHeight = height ?? dimensions.height * 0.9;
@@ -62,7 +70,9 @@ const SVGGaugeChart = ({ value, max = 100, showInnerArc = false, width, height,
62
70
  const startAngle = -135;
63
71
  const endAngle = 135;
64
72
  const totalAngle = endAngle - startAngle;
65
- const percentage = (animatedValue / max) * 100;
73
+ const scaleRange = Math.max(max - min, 1);
74
+ const normalizedValue = (animatedValue - min) / scaleRange;
75
+ const percentage = normalizedValue * 100;
66
76
  const valueAngle = (percentage / 100) * totalAngle;
67
77
  const polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
68
78
  const angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
@@ -130,18 +140,18 @@ const SVGGaugeChart = ({ value, max = 100, showInnerArc = false, width, height,
130
140
  }
131
141
  ticks.push(<Path key={i} d={`M ${outerPoint.x} ${outerPoint.y} L ${innerPoint.x} ${innerPoint.y}`} stroke={tickColor} strokeWidth={tickStrokeWidth} strokeLinecap="round"/>);
132
142
  }
133
- // Generate scale labels and inner ticks
143
+ // Generate scale labels and inner ticks from min/max
134
144
  const scaleLabels = [];
135
145
  const innerTicks = [];
136
- const majorTickPositions = [0, 20, 40, 60, 80, 100];
137
146
  const labelRadius = radius - 40;
138
147
  const innerTickLength = 4;
139
148
  const minorTickLength = 2;
140
149
  const gapFromOuterTicks = 4; // Gap between outer and inner elements
141
150
  const innerTickOuterRadius = radius - outerTickLength - gapFromOuterTicks;
151
+ const majorTickSet = new Set(majorTickPositions);
142
152
  // Add major ticks and labels
143
153
  for (const labelValue of majorTickPositions) {
144
- const labelAngle = startAngle + (labelValue / max) * totalAngle;
154
+ const labelAngle = startAngle + ((labelValue - min) / scaleRange) * totalAngle;
145
155
  const labelPosition = polarToCartesian(center, center, labelRadius, labelAngle);
146
156
  // Add scale label
147
157
  scaleLabels.push(<SvgText key={`label-${labelValue}`} x={labelPosition.x} y={labelPosition.y} textAnchor="middle" fontSize="12" fill={labelColor}>
@@ -152,17 +162,14 @@ const SVGGaugeChart = ({ value, max = 100, showInnerArc = false, width, height,
152
162
  const tickInnerPoint = polarToCartesian(center, center, innerTickOuterRadius - innerTickLength, labelAngle);
153
163
  innerTicks.push(<Path key={`inner-tick-${labelValue}`} d={`M ${tickOuterPoint.x} ${tickOuterPoint.y} L ${tickInnerPoint.x} ${tickInnerPoint.y}`} stroke={innerTickColor} strokeWidth={2} strokeLinecap="round"/>);
154
164
  }
155
- // Add minor ticks (9 ticks between each major tick)
156
- // Major ticks are at 0, 20, 40, 60, 80, 100
157
- // So we need ticks at every 2 units, excluding the major positions
158
- for (let value = 0; value <= max; value += 2) {
159
- // Skip if this is a major tick position
160
- if (majorTickPositions.includes(value))
165
+ // Minor ticks between major labels
166
+ for (let tickValue = min; tickValue <= max; tickValue += minorStep) {
167
+ if (majorTickSet.has(tickValue))
161
168
  continue;
162
- const tickAngle = startAngle + (value / max) * totalAngle;
169
+ const tickAngle = startAngle + ((tickValue - min) / scaleRange) * totalAngle;
163
170
  const tickOuterPoint = polarToCartesian(center, center, innerTickOuterRadius, tickAngle);
164
171
  const tickInnerPoint = polarToCartesian(center, center, innerTickOuterRadius - minorTickLength, tickAngle);
165
- innerTicks.push(<Path key={`inner-minor-tick-${value}`} d={`M ${tickOuterPoint.x} ${tickOuterPoint.y} L ${tickInnerPoint.x} ${tickInnerPoint.y}`} stroke={inactiveTickColor} strokeWidth={1} strokeLinecap="round"/>);
172
+ innerTicks.push(<Path key={`inner-minor-tick-${tickValue}`} d={`M ${tickOuterPoint.x} ${tickOuterPoint.y} L ${tickInnerPoint.x} ${tickInnerPoint.y}`} stroke={inactiveTickColor} strokeWidth={1} strokeLinecap="round"/>);
166
173
  }
167
174
  // Calculate the animated end angle for the outer arc
168
175
  const animatedEndAngle = startAngle + valueAngle;
@@ -205,8 +212,8 @@ const SVGGaugeChart = ({ value, max = 100, showInnerArc = false, width, height,
205
212
  </SvgText>
206
213
  </Svg>);
207
214
  };
208
- const ChartComponent = ({ value = 46, min = 0, max = 90, width, height, axisBgColor, axisWidth, tickColor, showInnerArc, animationDuration, ...props }) => {
209
- return (<SVGGaugeChart value={value} max={max} width={width} height={height} colors={props.colors} axisBgColor={axisBgColor} axisWidth={axisWidth} tickColor={tickColor} showInnerArc={showInnerArc} animationDuration={animationDuration}/>);
215
+ const ChartComponent = ({ value = 46, min = 0, max = 100, width, height, axisBgColor, axisWidth, tickColor, showInnerArc, animationDuration, ...props }) => {
216
+ return (<SVGGaugeChart value={value} min={min} max={max} width={width} height={height} colors={props.colors} axisBgColor={axisBgColor} axisWidth={axisWidth} tickColor={tickColor} showInnerArc={showInnerArc} animationDuration={animationDuration}/>);
210
217
  };
211
218
  export const DigitalGauge = Object.assign(withResponsiveContainer(withChartTheme(ChartComponent), 'value'), {
212
219
  displayName: 'DigitalGauge',
@@ -1 +1 @@
1
- {"version":3,"file":"radial.gauge.d.ts","sourceRoot":"","sources":["../../../../../components/chart/gauge/radial/radial.gauge.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAUrD;;;GAGG;AACH,UAAU,gBAAiB,SAAQ,cAAc;CAAG;AAgSpD,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
1
+ {"version":3,"file":"radial.gauge.d.ts","sourceRoot":"","sources":["../../../../../components/chart/gauge/radial/radial.gauge.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAUrD;;;GAGG;AACH,UAAU,gBAAiB,SAAQ,cAAc;CAAG;AA8RpD,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { withResponsiveContainer } from '../../chart-container';
2
2
  import { useChartTheme, withChartTheme } from '../../chart-theme.context';
3
+ import { getAxisByMinMax } from '../../axis';
3
4
  import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
4
5
  import { BarChart } from 'echarts/charts';
5
6
  import { GaugeChart } from 'echarts/charts';
@@ -32,6 +33,7 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
32
33
  radius: [innerRadius, outerRadius],
33
34
  },
34
35
  angleAxis: {
36
+ min: min,
35
37
  max: max,
36
38
  startAngle: 225,
37
39
  endAngle: -45,
@@ -46,7 +48,7 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
46
48
  series: [
47
49
  {
48
50
  type: 'bar',
49
- data: [max],
51
+ data: [max - min],
50
52
  coordinateSystem: 'polar',
51
53
  name: 'Background',
52
54
  tooltip: {
@@ -64,7 +66,7 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
64
66
  },
65
67
  {
66
68
  type: 'bar',
67
- data: [value],
69
+ data: [Math.max(value - min, 0)],
68
70
  coordinateSystem: 'polar',
69
71
  name: 'Value',
70
72
  itemStyle: {
@@ -79,7 +81,7 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
79
81
  },
80
82
  ]
81
83
  };
82
- }, [chartTheme, value, max, width, height, axisBgColorProp]);
84
+ }, [chartTheme, value, min, max, width, height, axisBgColorProp]);
83
85
  // Gauge option (progressArcOption)
84
86
  const gaugeOption = useMemo(() => {
85
87
  // Gauge radius smaller than radial inner ring to create a gap
@@ -94,6 +96,8 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
94
96
  const anchorBorderColor = tickColorProp ?? chartTheme.axis.r.tickColor;
95
97
  const valueColor = chartTheme.axis.r.tickLabelColor;
96
98
  const unitColor = chartTheme.axis.r.tickLabelColor;
99
+ const majorTicks = getAxisByMinMax(min, max);
100
+ const splitNumber = Math.max(majorTicks.length - 1, 1);
97
101
  return {
98
102
  series: [
99
103
  {
@@ -104,7 +108,7 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
104
108
  endAngle: -45,
105
109
  min: min,
106
110
  max: max,
107
- splitNumber: 5,
111
+ splitNumber,
108
112
  axisLine: {
109
113
  show: false,
110
114
  distance: 1,
@@ -144,12 +148,7 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
144
148
  distance: 16,
145
149
  fontSize: 12,
146
150
  color: labelColor,
147
- formatter: function (value) {
148
- if (value === 20 || value === 80) {
149
- return value.toString();
150
- }
151
- return '';
152
- },
151
+ formatter: (tickValue) => String(Math.round(tickValue)),
153
152
  },
154
153
  anchor: {
155
154
  show: true,
@@ -165,9 +164,7 @@ const ChartComponent = ({ value, min = 0, max = 100, width = 220, height = 240,
165
164
  },
166
165
  detail: {
167
166
  valueAnimation: true,
168
- formatter: function (value) {
169
- return '{value|' + Math.round(value) + '}{unit|/100}';
170
- },
167
+ formatter: (detailValue) => `{value|${Math.round(detailValue)}}{unit|/${max}}`,
171
168
  offsetCenter: [0, '70%'],
172
169
  rich: {
173
170
  value: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker/react-native-echarts",
3
- "version": "1.0.0-dev.12",
3
+ "version": "1.0.0-dev.14",
4
4
  "description": "React Native chart components built on using e-charts library.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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;AAY1D,qCAAqC;AACrC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAsZlF,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;AAY1D,qCAAqC;AACrC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA0ZlF,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, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
9
+ import { getAxis, valueAxisBoundsFromProps, categoryAxisBoundsFromProps } from '../axis';
10
10
  import { echartsLegendLayoutFragment, mergeCartesianGridForLegend, } from '../legend/echarts-legend-layout';
11
11
  import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
12
12
  import { createScatterTooltipPreset, useScatterItemTooltip } from './tooltip';
@@ -74,7 +74,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
74
74
  const hasNamedSeries = useMemo(() => normalizedSeries.some((s) => 'name' in s && s.name), [normalizedSeries]);
75
75
  selectContextRef.current = { normalizedSeries };
76
76
  const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
77
- const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
77
+ const categoryAxisBounds = useMemo(() => categoryAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
78
78
  const option = useMemo(() => {
79
79
  const dataPoints = normalizedSeries.map(s => s.data.map(item => item[0])).flat();
80
80
  const xAxisData = getAxis(dataPoints).map(String);
@@ -102,7 +102,8 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
102
102
  type: 'category',
103
103
  boundaryGap,
104
104
  data: xAxisData,
105
- ...(xAxisBounds ?? {}),
105
+ ...(categoryAxisBounds?.min !== undefined && { min: categoryAxisBounds.min }),
106
+ ...(categoryAxisBounds?.max !== undefined && { max: categoryAxisBounds.max }),
106
107
  ...(xAxisLabel != null && xAxisLabel !== '' && {
107
108
  name: xAxisLabel,
108
109
  nameLocation: 'middle',
@@ -113,6 +114,9 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
113
114
  show: showXAxis || xAxisTickLabelFormatter != null,
114
115
  color: theme.axis.x.tickLabelColor,
115
116
  ...(xAxisTickLabelFormatter && { formatter: xAxisTickLabelFormatter }),
117
+ ...(categoryAxisBounds?.axisLabelInterval !== undefined
118
+ ? { interval: categoryAxisBounds.axisLabelInterval }
119
+ : {}),
116
120
  },
117
121
  axisLine: showXAxis
118
122
  ? {
@@ -279,7 +283,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
279
283
  xAxisLabel,
280
284
  yAxisLabel,
281
285
  valueAxisBounds,
282
- xAxisBounds,
286
+ categoryAxisBounds,
283
287
  ]);
284
288
  useEffect(() => {
285
289
  let chart;