Skip to content

Commit 6aecbd5

Browse files
authored
fix(react-charting): Enable rounded corners and improve schema validation errors (#34473)
1 parent b464615 commit 6aecbd5

6 files changed

Lines changed: 54 additions & 24 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix(chart-utilities): Improve schema error handling",
4+
"packageName": "@fluentui/chart-utilities",
5+
"email": "98592573+AtishayMsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix(react-charting): Enable rounded corners",
4+
"packageName": "@fluentui/react-charting",
5+
"email": "98592573+AtishayMsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/charts/chart-utilities/src/PlotlySchemaConverter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ export const getValidSchema = (input: any): PlotlySchema => {
125125
if (!validatedSchema) {
126126
throw new Error('Plotly input is null or undefined');
127127
}
128-
if (!validatedSchema.data) {
129-
throw new Error('Plotly input data is null or undefined');
128+
if (typeof validatedSchema !== 'object') {
129+
throw new Error(`Plotly input is not an object. Input type: ${typeof validatedSchema}`);
130+
}
131+
if (!isArrayOrTypedArray(validatedSchema.data)) {
132+
throw new Error('Plotly input data is not a valid array or typed array');
130133
}
131134
if (validatedSchema.data.length === 0) {
132135
throw new Error('Plotly input data is empty');

packages/charts/react-charting/src/components/DeclarativeChart/PlotlySchemaAdapter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export const transformPlotlyJsonToDonutProps = (
279279
innerRadius,
280280
hideLabels,
281281
showLabelsInPercent: firstData.textinfo ? ['percent', 'label+percent'].includes(firstData.textinfo) : true,
282+
roundCorners: true,
282283
};
283284
};
284285

@@ -362,6 +363,7 @@ export const transformPlotlyJsonToVSBCProps = (
362363
...secondaryYAxisValues,
363364
hideTickOverlap: true,
364365
hideLegend,
366+
roundCorners: true,
365367
};
366368
};
367369

@@ -419,6 +421,7 @@ export const transformPlotlyJsonToGVBCProps = (
419421
...secondaryYAxisValues,
420422
hideTickOverlap: true,
421423
hideLegend,
424+
roundCorners: true,
422425
};
423426
};
424427

@@ -500,6 +503,7 @@ export const transformPlotlyJsonToVBCProps = (
500503
hideTickOverlap: true,
501504
maxBarWidth: 50,
502505
hideLegend,
506+
roundCorners: true,
503507
};
504508
};
505509

@@ -664,6 +668,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (
664668
hideLegend,
665669
noOfCharsToTruncate: 20,
666670
showYAxisLablesTooltip: true,
671+
roundCorners: true,
667672
};
668673
};
669674

@@ -937,6 +942,7 @@ export const transformPlotlyJsonToGaugeProps = (
937942
height: input.layout?.height ?? 220,
938943
styles,
939944
variant: firstData.gauge?.steps?.length ? GaugeChartVariant.MultipleSegments : GaugeChartVariant.SingleSegment,
945+
roundCorners: true,
940946
};
941947
};
942948
const cleanText = (text: string): string => {

packages/charts/react-charting/src/components/DeclarativeChart/__snapshots__/DeclarativeChartRTL.test.tsx.snap

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
15281528
&::-moz-focus-inner {
15291529
border: 0;
15301530
}
1531-
d="M0.58,-41.996A42,42,0,0,1,7.882,-41.254L-8.616,39.061Z"
1531+
d="M0.58,-38.835A3,3,0,0,1,3.855,-41.823A42,42,0,0,1,4.639,-41.743A3,3,0,0,1,7.246,-38.158L-8.616,39.061Z"
15321532
data-is-focusable="false"
15331533
id="_Pie_1AMC1"
15341534
role="img"
@@ -1550,7 +1550,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
15501550
&::-moz-focus-inner {
15511551
border: 0;
15521552
}
1553-
d="M9.018,-41.02A42,42,0,0,1,16.022,-38.824L-16.299,36.528Z"
1553+
d="M8.382,-37.924A3,3,0,0,1,12.192,-40.192A42,42,0,0,1,12.943,-39.956A3,3,0,0,1,14.776,-35.919L-16.299,36.528Z"
15541554
data-is-focusable="true"
15551555
id="_Pie_1Cadillac1"
15561556
role="img"
@@ -1572,7 +1572,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
15721572
&::-moz-focus-inner {
15731573
border: 0;
15741574
}
1575-
d="M17.088,-38.367A42,42,0,0,1,23.506,-34.806L-23.316,32.502Z"
1575+
d="M15.842,-35.462A3,3,0,0,1,20.03,-36.916A42,42,0,0,1,20.718,-36.534A3,3,0,0,1,21.701,-32.211L-23.316,32.502Z"
15761576
data-is-focusable="false"
15771577
id="_Pie_1Camaro1"
15781578
role="img"
@@ -1594,7 +1594,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
15941594
&::-moz-focus-inner {
15951595
border: 0;
15961596
}
1597-
d="M24.458,-34.144A42,42,0,0,1,30.029,-29.364L-29.379,27.145Z"
1597+
d="M22.653,-31.549A3,3,0,0,1,27.048,-32.131A42,42,0,0,1,27.646,-31.618A3,3,0,0,1,27.739,-27.186L-29.379,27.145Z"
15981598
data-is-focusable="false"
15991599
id="_Pie_1Chrysler1"
16001600
role="img"
@@ -1616,7 +1616,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
16161616
&::-moz-focus-inner {
16171617
border: 0;
16181618
}
1619-
d="M30.828,-28.524A42,42,0,0,1,35.323,-22.721L-34.24,20.678Z"
1619+
d="M28.538,-26.345A3,3,0,0,1,32.96,-26.031A42,42,0,0,1,33.443,-25.409A3,3,0,0,1,32.642,-21.048L-34.24,20.678Z"
16201620
data-is-focusable="false"
16211621
id="_Pie_1Datsun1"
16221622
role="img"
@@ -1638,7 +1638,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
16381638
&::-moz-focus-inner {
16391639
border: 0;
16401640
}
1641-
d="M35.937,-21.737A42,42,0,0,1,39.173,-15.149L-37.701,13.366Z"
1641+
d="M33.256,-20.064A3,3,0,0,1,37.524,-18.867A42,42,0,0,1,37.871,-18.16A3,3,0,0,1,36.209,-14.05L-37.701,13.366Z"
16421642
data-is-focusable="false"
16431643
id="_Pie_1Dodge1"
16441644
role="img"
@@ -1660,7 +1660,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
16601660
&::-moz-focus-inner {
16611661
border: 0;
16621662
}
1663-
d="M39.576,-14.061A42,42,0,0,1,41.42,-6.957L-39.619,5.506Z"
1663+
d="M36.613,-12.962A3,3,0,0,1,40.553,-10.93A42,42,0,0,1,40.751,-10.168A3,3,0,0,1,38.296,-6.477L-39.619,5.506Z"
16641664
data-is-focusable="false"
16651665
id="_Pie_1Duster1"
16661666
role="img"
@@ -1682,7 +1682,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
16821682
&::-moz-focus-inner {
16831683
border: 0;
16841684
}
1685-
d="M41.596,-5.81A42,42,0,0,1,41.972,1.52L-39.917,-2.578Z"
1685+
d="M38.472,-5.33A3,3,0,0,1,41.923,-2.547A42,42,0,0,1,41.963,-1.76A3,3,0,0,1,38.816,1.362L-39.917,-2.578Z"
16861686
data-is-focusable="false"
16871687
id="_Pie_1Ferrari1"
16881688
role="img"
@@ -1704,7 +1704,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
17041704
&::-moz-focus-inner {
17051705
border: 0;
17061706
}
1707-
d="M41.915,2.678A42,42,0,0,1,38.326,17.179L-36.023,-17.388Z"
1707+
d="M38.758,2.52A3,3,0,0,1,41.578,5.941A42,42,0,0,1,39.55,14.136A3,3,0,0,1,35.46,15.847L-36.023,-17.388Z"
17081708
data-is-focusable="false"
17091709
id="_Pie_1Fiat2"
17101710
role="img"
@@ -1726,7 +1726,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
17261726
&::-moz-focus-inner {
17271727
border: 0;
17281728
}
1729-
d="M37.837,18.231A42,42,0,0,1,34.085,24.54L-31.788,-24.281Z"
1729+
d="M34.971,16.899A3,3,0,0,1,36.299,21.128A42,42,0,0,1,35.896,21.805A3,3,0,0,1,31.546,22.658L-31.788,-24.281Z"
17301730
data-is-focusable="false"
17311731
id="_Pie_1Ford1"
17321732
role="img"
@@ -1748,7 +1748,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
17481748
&::-moz-focus-inner {
17491749
border: 0;
17501750
}
1751-
d="M33.395,25.472A42,42,0,0,1,28.45,30.896L-26.252,-30.18Z"
1751+
d="M30.855,23.59A3,3,0,0,1,31.305,28A42,42,0,0,1,30.775,28.582A3,3,0,0,1,26.342,28.542L-26.252,-30.18Z"
17521752
data-is-focusable="false"
17531753
id="_Pie_1Honda1"
17541754
role="img"
@@ -1770,7 +1770,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
17701770
&::-moz-focus-inner {
17711771
border: 0;
17721772
}
1773-
d="M27.586,31.67A42,42,0,0,1,14.757,39.322L-12.988,-37.833Z"
1773+
d="M25.478,29.316A3,3,0,0,1,25.031,33.726A42,42,0,0,1,17.78,38.051A3,3,0,0,1,13.687,36.348L-12.988,-37.833Z"
17741774
data-is-focusable="false"
17751775
id="_Pie_1Hornet2"
17761776
role="img"
@@ -1792,7 +1792,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
17921792
&::-moz-focus-inner {
17931793
border: 0;
17941794
}
1795-
d="M13.665,39.715A42,42,0,0,1,6.542,41.487L-5.11,-39.672Z"
1795+
d="M12.595,36.741A3,3,0,0,1,10.524,40.66A42,42,0,0,1,9.76,40.85A3,3,0,0,1,6.093,38.359L-5.11,-39.672Z"
17961796
data-is-focusable="false"
17971797
id="_Pie_1Lincoln1"
17981798
role="img"
@@ -1814,7 +1814,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
18141814
&::-moz-focus-inner {
18151815
border: 0;
18161816
}
1817-
d="M5.394,41.652A42,42,0,0,1,-1.939,41.955L2.977,-39.889Z"
1817+
d="M4.945,38.524A3,3,0,0,1,2.127,41.946A42,42,0,0,1,1.341,41.979A3,3,0,0,1,-1.75,38.8L2.977,-39.889Z"
18181818
data-is-focusable="false"
18191819
id="_Pie_1Lotus1"
18201820
role="img"
@@ -1836,7 +1836,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
18361836
&::-moz-focus-inner {
18371837
border: 0;
18381838
}
1839-
d="M-3.097,41.886A42,42,0,0,1,-10.342,40.707L10.943,-38.474Z"
1839+
d="M-2.908,38.731A3,3,0,0,1,-6.356,41.516A42,42,0,0,1,-7.134,41.39A3,3,0,0,1,-9.521,37.655L10.943,-38.474Z"
18401840
data-is-focusable="false"
18411841
id="_Pie_1Maserati1"
18421842
role="img"
@@ -1858,7 +1858,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
18581858
&::-moz-focus-inner {
18591859
border: 0;
18601860
}
1861-
d="M-11.462,40.406A42,42,0,0,1,-24.879,33.838L24.597,-31.543Z"
1861+
d="M-10.641,37.353A3,3,0,0,1,-14.58,39.388A42,42,0,0,1,-22.163,35.676A3,3,0,0,1,-22.972,31.318L24.597,-31.543Z"
18621862
data-is-focusable="false"
18631863
id="_Pie_1Mazda2"
18641864
role="img"
@@ -1880,7 +1880,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
18801880
&::-moz-focus-inner {
18811881
border: 0;
18821882
}
1883-
d="M-25.804,33.138A42,42,0,0,1,-39.287,-14.85L37.001,15.196Z"
1883+
d="M-23.897,30.618A3,3,0,0,1,-28.311,31.024A42,42,0,0,1,-40.326,-11.739A3,3,0,0,1,-36.346,-13.692L37.001,15.196Z"
18841884
data-is-focusable="false"
18851885
id="_Pie_1Merc7"
18861886
role="img"
@@ -1902,7 +1902,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
19021902
&::-moz-focus-inner {
19031903
border: 0;
19041904
}
1905-
d="M-38.862,-15.929A42,42,0,0,1,-35.495,-22.452L33.186,22.331Z"
1905+
d="M-35.921,-14.771A3,3,0,0,1,-37.5,-18.913A42,42,0,0,1,-37.139,-19.613A3,3,0,0,1,-32.848,-20.725L33.186,22.331Z"
19061906
data-is-focusable="false"
19071907
id="_Pie_1Pontiac1"
19081908
role="img"
@@ -1924,7 +1924,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
19241924
&::-moz-focus-inner {
19251925
border: 0;
19261926
}
1927-
d="M-34.862,-23.423A42,42,0,0,1,-30.252,-29.135L28.014,28.552Z"
1927+
d="M-32.214,-21.697A3,3,0,0,1,-32.928,-26.072A42,42,0,0,1,-32.433,-26.685A3,3,0,0,1,-28.006,-26.911L28.014,28.552Z"
19281928
data-is-focusable="false"
19291929
id="_Pie_1Porsche1"
19301930
role="img"
@@ -1946,7 +1946,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
19461946
&::-moz-focus-inner {
19471947
border: 0;
19481948
}
1949-
d="M-29.436,-29.959A42,42,0,0,1,-17.088,-38.367L15.233,36.986Z"
1949+
d="M-27.19,-27.735A3,3,0,0,1,-27.008,-32.165A42,42,0,0,1,-20.03,-36.916A3,3,0,0,1,-15.842,-35.462L15.233,36.986Z"
19501950
data-is-focusable="false"
19511951
id="_Pie_1Toyota2"
19521952
role="img"
@@ -1968,7 +1968,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
19681968
&::-moz-focus-inner {
19691969
border: 0;
19701970
}
1971-
d="M-16.022,-38.824A42,42,0,0,1,-9.018,-41.02L7.48,39.294Z"
1971+
d="M-14.776,-35.919A3,3,0,0,1,-12.943,-39.956A42,42,0,0,1,-12.192,-40.192A3,3,0,0,1,-8.382,-37.924L7.48,39.294Z"
19721972
data-is-focusable="false"
19731973
id="_Pie_1Valiant1"
19741974
role="img"
@@ -1990,7 +1990,7 @@ exports[`DeclarativeChart Should render donutchart in DeclarativeChart 1`] = `
19901990
&::-moz-focus-inner {
19911991
border: 0;
19921992
}
1993-
d="M-7.882,-41.254A42,42,0,0,1,-0.58,-41.996L-0.58,39.996Z"
1993+
d="M-7.246,-38.158A3,3,0,0,1,-4.639,-41.743A42,42,0,0,1,-3.855,-41.823A3,3,0,0,1,-0.58,-38.835L-0.58,39.996Z"
19941994
data-is-focusable="false"
19951995
id="_Pie_1Volvo1"
19961996
role="img"

packages/charts/react-charting/src/components/DeclarativeChart/__snapshots__/PlotlySchemaAdapterUT.test.tsx.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ Object {
202202
"hideLabels": false,
203203
"hideLegend": false,
204204
"innerRadius": 42,
205+
"roundCorners": true,
205206
"showLabelsInPercent": true,
206207
"width": undefined,
207208
}
@@ -238,6 +239,7 @@ Object {
238239
"hideLabels": false,
239240
"hideLegend": false,
240241
"innerRadius": 0,
242+
"roundCorners": true,
241243
"showLabelsInPercent": false,
242244
"width": undefined,
243245
}
@@ -358,6 +360,7 @@ Object {
358360
"hideLegend": true,
359361
"hideTickOverlap": true,
360362
"mode": "plotly",
363+
"roundCorners": true,
361364
"width": 850,
362365
"xAxisTitle": "Votes",
363366
"yAxisTitle": "Framework",
@@ -372,6 +375,7 @@ Object {
372375
"height": 400,
373376
"maxValue": 500,
374377
"minValue": undefined,
378+
"roundCorners": true,
375379
"segments": Array [
376380
Object {
377381
"color": "#00ffff",
@@ -2993,6 +2997,7 @@ Object {
29932997
"hideLegend": true,
29942998
"hideTickOverlap": true,
29952999
"noOfCharsToTruncate": 20,
3000+
"roundCorners": true,
29963001
"secondaryYAxistitle": "",
29973002
"showYAxisLables": true,
29983003
"showYAxisLablesTooltip": true,
@@ -4890,6 +4895,7 @@ Object {
48904895
"hideTickOverlap": true,
48914896
"maxBarWidth": 50,
48924897
"mode": "histogram",
4898+
"roundCorners": true,
48934899
"supportNegativeData": true,
48944900
"width": undefined,
48954901
"xAxisTitle": "",
@@ -4987,6 +4993,7 @@ Object {
49874993
"hideLegend": true,
49884994
"hideTickOverlap": true,
49894995
"mode": "plotly",
4996+
"roundCorners": true,
49904997
"width": undefined,
49914998
"xAxisTitle": "",
49924999
"yAxisTitle": "",

0 commit comments

Comments
 (0)