chore: chart 컴포넌트 문서 수정
This commit is contained in:
@@ -17,8 +17,82 @@ import { getCssVariableValue } from "../../lib/utils";
|
||||
const meta: Meta<typeof Bar> = {
|
||||
title: "Chart/Bar",
|
||||
component: Bar,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://react-chartjs-2.js.org/)
|
||||
`,
|
||||
},
|
||||
source: {
|
||||
code: `
|
||||
import {
|
||||
Chart as ChartJS,
|
||||
CategoryScale,
|
||||
LinearScale,
|
||||
BarElement,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
type ChartOptions,
|
||||
} from "chart.js";
|
||||
import { Bar } from "react-chartjs-2";
|
||||
import { fakerKO as faker } from "@faker-js/faker";
|
||||
|
||||
ChartJS.register(
|
||||
CategoryScale,
|
||||
LinearScale,
|
||||
BarElement,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
);
|
||||
|
||||
const options: ChartOptions<"bar"> = {
|
||||
responsive: true,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: "Chart.js Bar Chart",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const labels = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
];
|
||||
|
||||
const data = {
|
||||
labels,
|
||||
datasets: [
|
||||
{
|
||||
data: labels.map(() => faker.number.int({ min: 10, max: 100 })),
|
||||
backgroundColor: labels.map((_, i) =>
|
||||
getCssVariableValue(\`--chart-\${i + 1}\`),
|
||||
),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex h-[20vw] w-[50vw] justify-center">
|
||||
<Bar options={options} data={data} />
|
||||
</div>
|
||||
);
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Bar>;
|
||||
|
||||
@@ -37,7 +111,7 @@ export const Default: Story = {
|
||||
responsive: true,
|
||||
plugins: {
|
||||
legend: {
|
||||
position: "top",
|
||||
display: false,
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
@@ -60,7 +134,6 @@ export const Default: Story = {
|
||||
labels,
|
||||
datasets: [
|
||||
{
|
||||
label: "Dataset 1",
|
||||
data: labels.map(() => faker.number.int({ min: 10, max: 100 })),
|
||||
backgroundColor: labels.map((_, i) =>
|
||||
getCssVariableValue(`--chart-${i + 1}`),
|
||||
|
||||
@@ -14,7 +14,7 @@ const meta: Meta<typeof DataTable> = {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://tanstack.com/table/v8/docs/introduction)
|
||||
`,
|
||||
`,
|
||||
},
|
||||
source: {
|
||||
code: `
|
||||
|
||||
Reference in New Issue
Block a user