Skip to content

Commit 57d88bd

Browse files
authored
[MOO-1630]: Fix chart rendering issue 9.24 (#239)
2 parents 1470848 + e672601 commit 57d88bd

File tree

17 files changed

+43
-38
lines changed

17 files changed

+43
-38
lines changed

packages/jsActions/mobile-resources-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@
5353
"rimraf": "^2.7.1",
5454
"rollup": "^2.68.0"
5555
}
56-
}
56+
}

packages/pluggableWidgets/bar-chart-native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We have resolved an issue preventing Bar chart from rendering correctly.
12+
913
## [3.0.1] - 2023-5-17
1014

1115
### Fixed

packages/pluggableWidgets/bar-chart-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bar-chart-native",
33
"widgetName": "BarChart",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"license": "Apache-2.0",
66
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
77
"repository": {

packages/pluggableWidgets/bar-chart-native/src/components/BarChart.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function BarChart({
5858
style,
5959
warningPrefix
6060
}: BarChartProps): ReactElement | null {
61-
const [chartDimensions, setChartDimensions] = useState<{ height: number; width: number }>();
61+
const [chartDimensions, setChartDimensions] = useState<{ height?: number; width?: number }>();
6262

6363
const warningMessagePrefix = useMemo(() => (warningPrefix ? warningPrefix + "i" : "I"), [warningPrefix]);
6464

@@ -133,16 +133,7 @@ export function BarChart({
133133
}
134134

135135
return <VictoryStack colorScale={normalizedBarColors}>{bars}</VictoryStack>;
136-
}, [
137-
dataTypesResult,
138-
series,
139-
style,
140-
warningMessagePrefix,
141-
sortProps,
142-
showLabels,
143-
normalizedBarColors,
144-
presentation
145-
]);
136+
}, [dataTypesResult, series, style, sortProps, showLabels, normalizedBarColors, presentation]);
146137

147138
const [firstSeries] = series;
148139

@@ -195,8 +186,8 @@ export function BarChart({
195186
(event: LayoutChangeEvent) => {
196187
const { height, width } = event.nativeEvent.layout;
197188
setChartDimensions({
198-
height: height <= 0 ? -1 : height,
199-
width: width <= 0 ? -1 : width
189+
height: height <= 0 ? undefined : height,
190+
width: width <= 0 ? undefined : width
200191
});
201192
},
202193
[setChartDimensions]
@@ -222,8 +213,8 @@ export function BarChart({
222213
// horizontal charts.
223214
<VictoryChart
224215
domainPadding={{ x: style.domain?.padding?.y, y: style.domain?.padding?.x }}
225-
height={chartDimensions?.height}
226-
width={chartDimensions?.width}
216+
height={chartDimensions.height}
217+
width={chartDimensions.width}
227218
padding={aggregateGridPadding(style.grid)}
228219
scale={
229220
dataTypesResult

packages/pluggableWidgets/bar-chart-native/src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="BarChart" version="3.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="BarChart" version="3.0.2" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="BarChart.xml" />
66
</widgetFiles>

packages/pluggableWidgets/column-chart-native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We have resolved an issue preventing Column chart from rendering correctly
12+
913
## [2.0.1] - 2023-5-17
1014

1115
### Fixed

packages/pluggableWidgets/column-chart-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "column-chart-native",
33
"widgetName": "ColumnChart",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"license": "Apache-2.0",
66
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
77
"repository": {

packages/pluggableWidgets/column-chart-native/src/components/ColumnChart.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function ColumnChart({
6666
return sortSeriesDataPoints(series, sortOrder, dataTypesResult);
6767
}, [sortOrder, series, dataTypesResult]);
6868

69-
const [chartDimensions, setChartDimensions] = useState<{ height: number; width: number }>();
69+
const [chartDimensions, setChartDimensions] = useState<{ height?: number; width?: number }>();
7070

7171
// Column Chart user-styling may be missing for certain series. A palette is passed, any missing colours
7272
// fallback to a colour from the palette.
@@ -153,8 +153,8 @@ export function ColumnChart({
153153
(event: LayoutChangeEvent) => {
154154
const { height, width } = event.nativeEvent.layout;
155155
setChartDimensions({
156-
height: height <= 0 ? -1 : height,
157-
width: width <= 0 ? -1 : width
156+
height: height <= 0 ? undefined : height,
157+
width: width <= 0 ? undefined : width
158158
});
159159
},
160160
[setChartDimensions]
@@ -178,10 +178,8 @@ export function ColumnChart({
178178
{chartDimensions ? (
179179
<VictoryChart
180180
domainPadding={{ x: style.domain?.padding?.x, y: style.domain?.padding?.y }}
181-
// width and height can't be zero
182-
// TODO: this needs to be checked for bar chart
183-
height={chartDimensions?.height || undefined}
184-
width={chartDimensions?.width || undefined}
181+
height={chartDimensions.height}
182+
width={chartDimensions.width}
185183
padding={aggregateGridPadding(style.grid)}
186184
scale={
187185
dataTypesResult

packages/pluggableWidgets/column-chart-native/src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="ColumnChart" version="2.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="ColumnChart" version="2.0.2" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="ColumnChart.xml" />
66
</widgetFiles>

packages/pluggableWidgets/line-chart-native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We have resolved an issue preventing Line chart from rendering correctly
12+
913
## [3.0.1] - 2023-5-17
1014

1115
### Fixed

packages/pluggableWidgets/line-chart-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "line-chart-native",
33
"widgetName": "LineChart",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"license": "Apache-2.0",
66
"repository": {
77
"type": "git",

packages/pluggableWidgets/line-chart-native/src/components/LineChart.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ export function LineChart(props: LineChartProps): ReactElement | null {
177177
const xAxisLabelComponent = xAxisLabel ? <Text style={axisLabelStyles.xAxisLabelStyle}>{xAxisLabel}</Text> : null;
178178
const yAxisLabelComponent = yAxisLabel ? <Text style={axisLabelStyles.yAxisLabelStyle}>{yAxisLabel}</Text> : null;
179179

180-
const [chartDimensions, setChartDimensions] = useState<{ height: number; width: number }>();
180+
const [chartDimensions, setChartDimensions] = useState<{ height?: number; width?: number }>();
181181

182182
const updateChartDimensions = useCallback(
183183
(event: LayoutChangeEvent) => {
184184
const { height, width } = event.nativeEvent.layout;
185-
setChartDimensions({ height: height <= 0 ? -1 : height, width: width <= 0 ? -1 : width });
185+
setChartDimensions({ height: height <= 0 ? undefined : height, width: width <= 0 ? undefined : width });
186186
},
187187
[setChartDimensions]
188188
);
@@ -205,8 +205,8 @@ export function LineChart(props: LineChartProps): ReactElement | null {
205205
<View onLayout={updateChartDimensions} style={{ flex: 1 }}>
206206
{chartDimensions ? (
207207
<VictoryChart
208-
height={chartDimensions?.height}
209-
width={chartDimensions?.width}
208+
height={chartDimensions.height}
209+
width={chartDimensions.width}
210210
padding={aggregateGridPadding(style.grid)}
211211
scale={
212212
dataTypesResult

packages/pluggableWidgets/line-chart-native/src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="LineChart" version="3.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="LineChart" version="3.0.2" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="LineChart.xml" />
66
</widgetFiles>

packages/pluggableWidgets/pie-doughnut-chart-native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We have resolved an issue preventing Pie chart from rendering correctly
12+
913
## [2.0.1] - 2023-5-17
1014

1115
### Fixed

packages/pluggableWidgets/pie-doughnut-chart-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pie-doughnut-chart-native",
33
"widgetName": "PieDoughnutChart",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"license": "Apache-2.0",
66
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
77
"repository": {

packages/pluggableWidgets/pie-doughnut-chart-native/src/components/PieDoughnutChart.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface Slice<X extends string, Y extends number> {
2828

2929
export function PieDoughnutChart({ name, presentation, series, style, showLabels }: ChartProps): ReactElement | null {
3030
// due to the nature of the chart type, we only reply on the width, as the chart is always a square
31-
const [chartDimensions, setChartDimensions] = useState<{ width: number }>();
31+
const [chartDimensions, setChartDimensions] = useState<{ width?: number }>();
3232
// Chart user-styling may be missing for certain slices. A palette is passed, any missing colours
3333
// fallback to a colour from the palette or the default color.
3434
const normalizedSliceColors: string[] = useMemo(() => {
@@ -56,7 +56,7 @@ export function PieDoughnutChart({ name, presentation, series, style, showLabels
5656
(event: LayoutChangeEvent) => {
5757
const { width } = event.nativeEvent.layout;
5858
setChartDimensions({
59-
width: width <= 0 ? -1 : width
59+
width: width <= 0 ? undefined : width
6060
});
6161
},
6262
[setChartDimensions]
@@ -89,7 +89,7 @@ export function PieDoughnutChart({ name, presentation, series, style, showLabels
8989
}}
9090
labels={({ datum }) => (showLabels ? datum.x : undefined)}
9191
innerRadius={
92-
presentation === "doughnut"
92+
presentation === "doughnut" && chartDimensions.width && chartDimensions.width > 0
9393
? style.slices?.innerRadius ?? chartDimensions.width / DEFAULT_INNER_RADIUS_RATIO
9494
: undefined
9595
}

packages/pluggableWidgets/pie-doughnut-chart-native/src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="PieDoughnutChart" version="2.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="PieDoughnutChart" version="2.0.2" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="PieDoughnutChart.xml" />
66
</widgetFiles>

0 commit comments

Comments
 (0)