aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/DataChart
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2023-11-26 12:48:42 -0800
committerPinapelz <yukais@pinapelz.com>2023-11-26 12:48:42 -0800
commit68cba8a186ef8f641562066d73f85bd53c240dd0 (patch)
treed7ed0dda4f9e40348d0736ddbdde94cdd1499813 /src/components/DataChart
parentcf108e9e7272641f35be20e35635985a69e042c7 (diff)
bump dependency and minor style changes
Diffstat (limited to 'src/components/DataChart')
-rw-r--r--src/components/DataChart/DataChart.tsx53
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;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage