Sfoglia il codice sorgente

Bar Chart in component

uzairrizwan1 7 mesi fa
parent
commit
08b893b71d
4 ha cambiato i file con 60 aggiunte e 46 eliminazioni
  1. 19 19
      myapp/package-lock.json
  2. 1 1
      myapp/package.json
  3. 5 26
      myapp/src/App.js
  4. 35 0
      myapp/src/components/ChartComponent.js

+ 19 - 19
myapp/package-lock.json

@@ -16,7 +16,7 @@
16
         "react": "^19.1.0",
16
         "react": "^19.1.0",
17
         "react-apexcharts": "^1.7.0",
17
         "react-apexcharts": "^1.7.0",
18
         "react-dom": "^19.1.0",
18
         "react-dom": "^19.1.0",
19
-        "react-scripts": "5.0.1",
19
+        "react-scripts": "^5.0.1",
20
         "web-vitals": "^2.1.4"
20
         "web-vitals": "^2.1.4"
21
       }
21
       }
22
     },
22
     },
@@ -3501,15 +3501,6 @@
3501
         "node": ">=18"
3501
         "node": ">=18"
3502
       }
3502
       }
3503
     },
3503
     },
3504
-    "node_modules/@testing-library/dom/node_modules/aria-query": {
3505
-      "version": "5.3.0",
3506
-      "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
3507
-      "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
3508
-      "license": "Apache-2.0",
3509
-      "dependencies": {
3510
-        "dequal": "^2.0.3"
3511
-      }
3512
-    },
3513
     "node_modules/@testing-library/jest-dom": {
3504
     "node_modules/@testing-library/jest-dom": {
3514
       "version": "6.6.3",
3505
       "version": "6.6.3",
3515
       "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz",
3506
       "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz",
@@ -4663,12 +4654,12 @@
4663
       }
4654
       }
4664
     },
4655
     },
4665
     "node_modules/aria-query": {
4656
     "node_modules/aria-query": {
4666
-      "version": "5.3.2",
4667
-      "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz",
4668
-      "integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==",
4657
+      "version": "5.3.0",
4658
+      "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
4659
+      "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
4669
       "license": "Apache-2.0",
4660
       "license": "Apache-2.0",
4670
-      "engines": {
4671
-        "node": ">= 0.4"
4661
+      "dependencies": {
4662
+        "dequal": "^2.0.3"
4672
       }
4663
       }
4673
     },
4664
     },
4674
     "node_modules/array-buffer-byte-length": {
4665
     "node_modules/array-buffer-byte-length": {
@@ -7491,6 +7482,15 @@
7491
         "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9"
7482
         "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9"
7492
       }
7483
       }
7493
     },
7484
     },
7485
+    "node_modules/eslint-plugin-jsx-a11y/node_modules/aria-query": {
7486
+      "version": "5.3.2",
7487
+      "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz",
7488
+      "integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==",
7489
+      "license": "Apache-2.0",
7490
+      "engines": {
7491
+        "node": ">= 0.4"
7492
+      }
7493
+    },
7494
     "node_modules/eslint-plugin-react": {
7494
     "node_modules/eslint-plugin-react": {
7495
       "version": "7.37.5",
7495
       "version": "7.37.5",
7496
       "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.5.tgz",
7496
       "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.5.tgz",
@@ -16441,9 +16441,9 @@
16441
       }
16441
       }
16442
     },
16442
     },
16443
     "node_modules/typescript": {
16443
     "node_modules/typescript": {
16444
-      "version": "4.9.5",
16445
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
16446
-      "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
16444
+      "version": "5.8.3",
16445
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
16446
+      "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
16447
       "license": "Apache-2.0",
16447
       "license": "Apache-2.0",
16448
       "peer": true,
16448
       "peer": true,
16449
       "bin": {
16449
       "bin": {
@@ -16451,7 +16451,7 @@
16451
         "tsserver": "bin/tsserver"
16451
         "tsserver": "bin/tsserver"
16452
       },
16452
       },
16453
       "engines": {
16453
       "engines": {
16454
-        "node": ">=4.2.0"
16454
+        "node": ">=14.17"
16455
       }
16455
       }
16456
     },
16456
     },
16457
     "node_modules/unbox-primitive": {
16457
     "node_modules/unbox-primitive": {

+ 1 - 1
myapp/package.json

@@ -11,7 +11,7 @@
11
     "react": "^19.1.0",
11
     "react": "^19.1.0",
12
     "react-apexcharts": "^1.7.0",
12
     "react-apexcharts": "^1.7.0",
13
     "react-dom": "^19.1.0",
13
     "react-dom": "^19.1.0",
14
-    "react-scripts": "5.0.1",
14
+    "react-scripts": "^5.0.1",
15
     "web-vitals": "^2.1.4"
15
     "web-vitals": "^2.1.4"
16
   },
16
   },
17
   "scripts": {
17
   "scripts": {

+ 5 - 26
myapp/src/App.js

@@ -1,35 +1,14 @@
1
 // src/App.js
1
 // src/App.js
2
 import React from "react";
2
 import React from "react";
3
-import Chart from "react-apexcharts";
4
-
5
-const App = () => {
6
-  const chartOptions = {
7
-    chart: {
8
-      id: "basic-bar"
9
-    },
10
-    xaxis: {
11
-      categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998]
12
-    }
13
-  };
14
-
15
-  const chartSeries = [
16
-    {
17
-      name: "series-1",
18
-      data: [30, 40, 45, 50, 49, 60, 70, 91]
19
-    }
20
-  ];
3
+import ChartComponent from "./components/ChartComponent";
21
 
4
 
5
+function App() {
22
   return (
6
   return (
23
     <div className="App">
7
     <div className="App">
24
-      <h2>ApexCharts Example</h2>
25
-      <Chart
26
-        options={chartOptions}
27
-        series={chartSeries}
28
-        type="bar"
29
-        width="600"
30
-      />
8
+      <h1>My Dashboard</h1>
9
+      <ChartComponent />
31
     </div>
10
     </div>
32
   );
11
   );
33
-};
12
+}
34
 
13
 
35
 export default App;
14
 export default App;

+ 35 - 0
myapp/src/components/ChartComponent.js

@@ -0,0 +1,35 @@
1
+// src/components/ChartComponent.js
2
+import React from "react";
3
+import Chart from "react-apexcharts";
4
+
5
+const ChartComponent = () => {
6
+  const chartOptions = {
7
+    chart: {
8
+      id: "basic-bar"
9
+    },
10
+    xaxis: {
11
+      categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998]
12
+    }
13
+  };
14
+
15
+  const chartSeries = [
16
+    {
17
+      name: "Series 1",
18
+      data: [30, 40, 45, 50, 49, 60, 70, 91]
19
+    }
20
+  ];
21
+
22
+  return (
23
+    <div className="chart-wrapper">
24
+      <h3>Bar Chart</h3>
25
+      <Chart
26
+        options={chartOptions}
27
+        series={chartSeries}
28
+        type="bar"
29
+        width="600"
30
+      />
31
+    </div>
32
+  );
33
+};
34
+
35
+export default ChartComponent;