사용한 라이브러리
https://apexcharts.com/docs/react-charts/
React-ApexChart - A React Chart wrapper for ApexCharts.js
Create React Charts using a React Chart component for ApexCharts. Build beautiful and interactive visualizations in your react applications.
apexcharts.com
https://apexcharts.com/javascript-chart-demos/column-charts/column-with-markers/
JavaScript Column Chart with Markers – ApexCharts.js
View the sample of a JavaScript Column Chart with Markers created using ApexCharts.js
apexcharts.com
사용 방법
1. 설치하기 npm install apexcharts --save
https://apexcharts.com/docs/installation/
Installation & Getting Started – ApexCharts.js
Integrating ApexCharts is as simple as it can get with extensive API docs and 100+ samples ready to be used. Check out all the options of ApexCharts
apexcharts.com
2. 코드
import ApexCharts from "apexcharts";
import Chart from "react-apexcharts";
const Chart = () => {
// 데이터
let options_Risk = {
chart: {
type: "bar",
width: "5rem",
},
colors: ["#e5cd85"],
};
let series_Risk = [
{
name: "발암위해도",
data: [
{
x: chem_1,
y: Risk_1,
width: 10,
goals: [
{
name: "기준치",
value: 0.000001,
strokeColor: "rgb(141, 0, 42)",
},
],
},
{
x: chem_2,
y: Risk_2,
goals: [
{
name: "기준치",
value: 0.000001,
strokeColor: "rgb(141, 0, 42)",
},
],
},
{
x: chem_3,
y: Risk_3,
goals: [
{
name: "기준치",
value: 0.000001,
strokeColor: "rgb(141, 0, 42)",
},
],
},
{
x: chem_4,
y: Risk_4,
goals: [
{
name: "기준치",
value: 0.000001,
strokeColor: "rgb(141, 0, 42)",
},
],
},
{
x: chem_5,
y: Risk_5,
goals: [
{
name: "기준치",
value: 0.000001,
strokeColor: "rgb(141, 0, 42)",
},
],
},
],
},
];
return (
<>
<Chart
options={options_Risk}
series={series_Risk}
type="bar"
width="60%"
/>
</>
)
}
'Library-Framework > React' 카테고리의 다른 글
[React] Google Map default zoom 바로 안 먹힘 (0) | 2023.04.03 |
---|---|
[React] React에서 Google Map API 사용하기 & Polygon 그리기 (0) | 2023.02.19 |
[React] MVC 아키텍처, 리액트의 특징 (0) | 2023.01.05 |
[React] styled-component 사용해서 html body 왼쪽 여백 없애기 (0) | 2022.12.11 |
[React] React.js - Django REST framework API 사진 올리기 및 출력하기 (2) | 2022.12.08 |