Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

(add) comments for ui/chart

kruzhambus70d0a88af1d6
diff --git a/src/ui/Chart.tsx b/src/ui/Chart.tsx
index 6914fbc84..a887dfa4a 100644
--- a/src/ui/Chart.tsx
+++ b/src/ui/Chart.tsx
@@ -3,14 +3,18 @@ import bb from 'billboard.js'
import 'billboard.js/dist/theme/datalab.css'
import 'billboard.js/dist/billboard.css'
+// Define the prop types for the component
interface IChart {
+ // (string): The ID of the chart container.
current: string,
+ // (object): The chart options.
options: any,
}
const Chart = ({ current, options }: IChart): JSX.Element => {
let chartInstance: any = {}
+ // Destroy the chart instance
const destroy = () => {
if (chartInstance !== null) {
try {
@@ -23,6 +27,7 @@ const Chart = ({ current, options }: IChart): JSX.Element => {
}
}
+ // Render the chart
const renderChart = () => {
if (current !== null) {
chartInstance = bb.generate({
@@ -32,6 +37,7 @@ const Chart = ({ current, options }: IChart): JSX.Element => {
}
}
+ // Render the chart on mount
useEffect(() => {
renderChart()
return destroy