diff options
| author | Pinapelz <yukais@pinapelz.com> | 2023-11-26 12:48:42 -0800 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2023-11-26 12:48:42 -0800 |
| commit | 68cba8a186ef8f641562066d73f85bd53c240dd0 (patch) | |
| tree | d7ed0dda4f9e40348d0736ddbdde94cdd1499813 /src/components/DataChart | |
| parent | cf108e9e7272641f35be20e35635985a69e042c7 (diff) | |
bump dependency and minor style changes
Diffstat (limited to 'src/components/DataChart')
| -rw-r--r-- | src/components/DataChart/DataChart.tsx | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/components/DataChart/DataChart.tsx b/src/components/DataChart/DataChart.tsx index 9fbc5fe..4f8eecd 100644 --- a/src/components/DataChart/DataChart.tsx +++ b/src/components/DataChart/DataChart.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; import { Chart as ChartJS, CategoryScale, @@ -8,9 +8,8 @@ import { Title, Tooltip, Legend, -} from 'chart.js'; -import { Line } from 'react-chartjs-2'; - +} from "chart.js"; +import { Line } from "react-chartjs-2"; ChartJS.register( CategoryScale, @@ -22,52 +21,62 @@ ChartJS.register( Legend ); - interface DataChartProps { - channel_name?: string; chartData?: any; graphTitle?: string; + fullData?: boolean; + overrideBorderColor?: string + overrideBGColor?: string } -const DataChart: React.FC<DataChartProps> = ({ channel_name, chartData, graphTitle }) => { +const DataChart: React.FC<DataChartProps> = ({ + chartData, + graphTitle, + fullData, + overrideBGColor, + overrideBorderColor +}) => { const options = { responsive: true, plugins: { legend: { - position: 'top' as const, + position: "top" as const, }, title: { display: true, - text: graphTitle || 'Historical Subscriber Data', + text: graphTitle || "Historical Subscriber Data", font: { - size: 18 - } + size: 18, + }, }, }, scales: { x: { ticks: { autoSkip: true, - maxTicksLimit: 10 - } - } - } + maxTicksLimit: 10, + }, + }, + }, }; const data = { labels: chartData.labels, datasets: [ { - label: 'Subscriber Count', + label: "Subscriber Count", data: chartData.datasets, - borderColor: 'rgb(255, 99, 132)', - backgroundColor: 'rgba(255, 99, 132, 0.5)', + borderColor: overrideBorderColor||"rgb(255, 99, 132)", + backgroundColor: overrideBGColor||"rgba(255, 99, 132, 0.5)", }, ], - } - + }; - return <Line options={options} data={data} />; + if (!fullData) { + return <Line options={options} data={data} />; + } else { + return <Line options={options} data={chartData} />; + } }; -export default DataChart;
\ No newline at end of file +export default DataChart; |
