Skip to content

Commit d3f7512

Browse files
committed
fix: remove array shuffling for more consistency when running screenshot testing
1 parent 4ecf545 commit d3f7512

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

pages/03-core/core-dual-axis-chart.page.tsx

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ function randomInt(min: number, max: number) {
1515
return min + Math.floor(pseudoRandom() * (max - min));
1616
}
1717

18-
function shuffleArray<T>(array: T[]): T[] {
19-
let currentIndex = array.length;
20-
while (currentIndex !== 0) {
21-
const randomIndex = Math.floor(Math.random() * currentIndex);
22-
currentIndex--;
23-
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
24-
}
25-
return array;
26-
}
27-
2818
const colors = [
2919
"#F15C80",
3020
"#2B908F",
@@ -101,20 +91,21 @@ for (let i = 0; i < 10; i++) {
10191
secondarySeriesData[`data${letter}`] = generateSecondaryAxisData(letter, i);
10292
}
10393

104-
const series: Highcharts.SeriesOptionsType[] = shuffleArray(
105-
[...Object.values(primarySeriesData), ...Object.values(secondarySeriesData)].map((data, index) => {
106-
const name = data[0].name;
107-
const isPercentage = name.startsWith("Percentage");
108-
return {
109-
name,
110-
type: "line",
111-
data: data,
112-
yAxis: isPercentage ? 1 : 0,
113-
color: colors[index % colors.length],
114-
dashStyle: isPercentage ? "Dash" : "Solid",
115-
};
116-
}),
117-
);
94+
const series: Highcharts.SeriesOptionsType[] = [
95+
...Object.values(primarySeriesData),
96+
...Object.values(secondarySeriesData),
97+
].map((data, index) => {
98+
const name = data[0].name;
99+
const isPercentage = name.startsWith("Percentage");
100+
return {
101+
name,
102+
type: "line",
103+
data: data,
104+
yAxis: isPercentage ? 1 : 0,
105+
color: colors[index % colors.length],
106+
dashStyle: isPercentage ? "Dash" : "Solid",
107+
};
108+
});
118109

119110
export default function () {
120111
const { chartProps } = useChartSettings();

0 commit comments

Comments
 (0)