Skip to content

Commit

Permalink
Update TimeseriesBarChart.js
Browse files Browse the repository at this point in the history
  • Loading branch information
vaishnav4281 authored Dec 17, 2024
1 parent 3ef1ea8 commit f16de0b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/Chart/TimeseriesBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ import {

import { SectionTitle } from "../Typography/Title";

function TimeseriesBarChart({ name, data, dataKeys, colors }) {
function TimeseriesBarChart({ name, data, dataKeys = [], colors = [] }) {
const { mode } = useContext(WindmillContext);

// Ensure dataKeys and colors are matched
if (dataKeys.length !== colors.length) {
console.error("The number of dataKeys must match the number of colors.");
return null;
}

return (
<div>
<SectionTitle>{name}</SectionTitle>
Expand All @@ -35,7 +41,7 @@ function TimeseriesBarChart({ name, data, dataKeys, colors }) {
<XAxis dataKey="date" />
<YAxis />
<Tooltip
cursor={false}
cursor={{ fill: mode === "dark" ? "#333" : "#f5f5f5" }}
contentStyle={{
backgroundColor:
mode === "dark"
Expand All @@ -48,6 +54,7 @@ function TimeseriesBarChart({ name, data, dataKeys, colors }) {
borderRadius: "0.5rem",
borderStyle: "none",
}}
formatter={(value, name) => [value, name.toUpperCase()]} // Tooltip formatter
/>
<Legend
wrapperStyle={{
Expand Down

0 comments on commit f16de0b

Please sign in to comment.