Skip to content

Commit 3b2eb25

Browse files
committed
fix(igr-ts): revert charts logic and fix vite config
1 parent d99cc9c commit 3b2eb25

6 files changed

Lines changed: 23 additions & 17 deletions

File tree

packages/cli/templates/react/igr-ts/category-chart/default/files/src/app/__path__/__filePrefix__.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import { IgrCategoryChartModule } from 'igniteui-react-charts';
33
import { IgrCategoryChart } from 'igniteui-react-charts';
44
import style from './style.module.css';
@@ -15,7 +15,11 @@ const data: any = [
1515

1616
export default function $(ClassName)() {
1717
const title = 'Category Chart';
18-
const [chartData] = useState(data);
18+
const [chartData, setChartData] = useState([]);
19+
20+
useEffect(() => {
21+
setChartData(data);
22+
}, []);
1923

2024
return (
2125
<div>

packages/cli/templates/react/igr-ts/doughnut-chart/default/files/src/app/__path__/__filePrefix__.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,12 @@ const data: any = [
2323

2424
export default function $(ClassName)() {
2525
const title = 'Doughnut Chart';
26-
const [chartData] = useState(data);
26+
const [chartData, setChartData] = useState([]);
2727
const legendRef: any = useRef(null);
2828
const chartRef: any = useRef(null);
2929

3030
useEffect(() => {
31-
if (chartRef.current && legendRef.current) {
32-
const chart = chartRef.current;
33-
const series = chart.series?.[0];
34-
if (series) {
35-
series.legend = legendRef.current;
36-
}
37-
}
31+
setChartData(data);
3832
}, []);
3933

4034
return (
@@ -59,6 +53,7 @@ export default function $(ClassName)() {
5953
dataSource={chartData}
6054
labelMemberPath="Company"
6155
valueMemberPath="MarketShare"
56+
legend={legendRef.current}
6257
/>
6358
</IgrDoughnutChart>
6459
</div>

packages/cli/templates/react/igr-ts/financial-chart/default/files/src/app/__path__/__filePrefix__.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react'
1+
import { useEffect, useState } from 'react'
22
import { IgrFinancialChartModule } from 'igniteui-react-charts';
33
import { IgrFinancialChart } from 'igniteui-react-charts';
44
import style from './style.module.css';
@@ -22,7 +22,11 @@ const data: any = [
2222

2323
export default function $(ClassName)() {
2424
const title = 'Financial Chart';
25-
const [chartData] = useState(data);
25+
const [chartData, setChartData] = useState([]);
26+
27+
useEffect(() => {
28+
setChartData(data);
29+
}, []);
2630

2731
return (
2832
<div>

packages/cli/templates/react/igr-ts/pie-chart/default/files/src/app/__path__/__filePrefix__.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ const data: any = [
1818

1919
export default function $(ClassName)() {
2020
const title = 'Pie Chart';
21-
const [chartData] = useState(data);
21+
const [chartData, setChartData] = useState([]);
2222
const legendRef: any = useRef(null);
2323
const chartRef: any = useRef(null);
2424

2525
useEffect(() => {
26-
if (chartRef.current && legendRef.current) {
27-
chartRef.current.legend = legendRef.current;
28-
}
26+
setChartData(data);
2927
}, []);
3028

3129
return (
@@ -49,6 +47,7 @@ export default function $(ClassName)() {
4947
height="500px"
5048
ref={chartRef}
5149
legendLabelMemberPath="Label"
50+
legend={legendRef.current}
5251
/>
5352
</div>
5453
</div>

packages/cli/templates/react/igr-ts/projects/_base/files/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@types/node": "^24.12.0",
2828
"@types/react": "^19.2.14",
2929
"@types/react-dom": "^19.2.3",
30+
"@vitejs/plugin-react": "^5.0.3",
3031
"@vitest/browser-playwright": "^4.1.0",
3132
"eslint": "^9.39.4",
3233
"eslint-plugin-react-hooks": "^7.0.1",

packages/cli/templates/react/igr-ts/projects/_base/files/vite.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/// <reference types="vitest/config" />
12
import { playwright } from '@vitest/browser-playwright'
2-
import { defineConfig } from 'vitest/config'
3+
import { defineConfig } from 'vite'
4+
import react from '@vitejs/plugin-react'
35

46
// https://vitejs.dev/config/
57
export default defineConfig({
68
build: {
79
chunkSizeWarningLimit: 10 * 1024 * 1024, // 10 MB
810
},
11+
plugins: [react()],
912
test: {
1013
browser: {
1114
enabled: true,

0 commit comments

Comments
 (0)