Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- slickslider
- googleicon
- owlcarousel
- maxwidth
- 정적객체
- XEIcon
- 의존성문제
- minwidth
- 이미지반응형
- 플러그인
- package.json
- npm install 문제
- 아이콘사용법
- git lab clone
- react npm install
- npm install
- fontawesome
- 글자들여쓰기
- 웹아이콘
- node 오류
- node설치
- vscode git clone
- 동적객체
- 단어단위로떨어지기
- npm start
- legacy-peer
- MediaQuery
- window 정책변경
- Git clone
- 그누보드반응형
Archives
- Today
- Total
어쩌다 알게 된 ƪ(•̃͡•̃͡ ƪ
🟦 [React] Chart.js 라이브러리 설치 o 본문
728x90
2025.03.09 - [리액트] - 🟦 [React] Chart.js 라이브러리 설치 x , cdn 사용
🟦 [React] Chart.js 라이브러리 설치 x , cdn 사용
✔️ 일반 html로 차트 꾸리기 Chart.js 대시보드 리액트로 바꿔보기 ✔️ 라이브러리 설치 안하고 cdn으로! - Dashboard.jsx 컴포넌트 파일import React, { useDebugValue, useEffect, useRef } from "react";import "./D
dazzle-bini.tistory.com
✅ 설치 방법
npm install chart.js react-chartjs-2
- DashboardLib.jsx
import React from "react";
import { Bar } from 'react-chartjs-2';
import { Chart as ChartJS, BarElement, CategoryScale, LinearScale, Title, Tooltip, Legend } from "chart.js";
ChartJS.register(BarElement, CategoryScale, LinearScale, Title, Tooltip, Legend);
const ChartComponent = () => {
const chartData = {
labels: ["1월", "2월", "3월", "4월", "5월", "6월"],
datasets: [
{
label: "월별 판매량",
data: [65, 95, 30, 20, 50, 67],
backgroundColor: "rgba(0, 192, 255, 0.8)",
borderColor: "rgba(0, 192, 255, 1)",
borderWidth: 2,
},
],
};
const options = {
responsive: true,
plugins: {
legend: { display: true },
title: { display: true, text: "월별 판매량" }
},
};
return <Bar data={chartData} options={options} />;
};
const Dashboard = () => {
return (
<div>
<ChartComponent />
</div>
);
};
export default Dashboard;728x90
'개발 > 🟦 React' 카테고리의 다른 글
| 🟦 [React] npm, npx 차이 (0) | 2025.03.17 |
|---|---|
| 🟦 [React] Next.js란? (0) | 2025.03.17 |
| 🟦 [React] Chart.js 라이브러리 설치 x , cdn 사용 (0) | 2025.03.09 |
| 🟦 [React] useEffect 개념 잡기 (0) | 2025.03.09 |
| 🟦 [React] useRef 개념 잡기 (0) | 2025.03.09 |
Comments
