Skip to content

Commit

Permalink
web: format tooltip label batter discharge and charge
Browse files Browse the repository at this point in the history
  • Loading branch information
hoang-rio committed Nov 27, 2024
1 parent 8318ced commit 5601036
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 11 deletions.
20 changes: 18 additions & 2 deletions web_viewer/fe_src/src/components/HourlyChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import "./HourlyChart.css";
import Chart from "react-apexcharts";
import { IClassNameProps, IUpdateChart, SeriesItem } from "../Intefaces";

const BATTERY_SERIE_NAME = "Battery";

const HourlyChart = forwardRef(({ className }: IClassNameProps, ref: ForwardedRef<IUpdateChart>) => {
const [chartData, setChartData] = useState<never[][]>([]);
const [isDark, setIsDark] = useState(false);
Expand All @@ -39,7 +41,7 @@ const HourlyChart = forwardRef(({ className }: IClassNameProps, ref: ForwardedRe
data: pvSeries,
},
{
name: "Battery",
name: BATTERY_SERIE_NAME,
data: batterySeries,
},
{
Expand Down Expand Up @@ -169,8 +171,22 @@ const HourlyChart = forwardRef(({ className }: IClassNameProps, ref: ForwardedRe
if (opts.seriesIndex === 4) {
return `${val}%`;
}
return `${val} W`;
return `${Math.abs(val)} W`;
},
title: {
formatter(seriesName, opts) {
console.log(opts);
if (seriesName === BATTERY_SERIE_NAME) {
const batteryValue =
opts.series[1][opts.dataPointIndex];
if (batteryValue < 0) {
return `${seriesName} charge:`;
}
return `${seriesName} discharge:`;
}
return `${seriesName}:`;
},
}
},
},
}}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
import{j as e}from"./index-Ck0kjt3K.js";function l({value:r,unit:s,className:n}){return e.jsxs("div",{className:`${n||""} general-value`,children:[e.jsx("strong",{children:r}),s]})}export{l as G};
import{j as e}from"./index-BMg5kuNt.js";function l({value:r,unit:s,className:n}){return e.jsxs("div",{className:`${n||""} general-value`,children:[e.jsx("strong",{children:r}),s]})}export{l as G};
1 change: 1 addition & 0 deletions web_viewer/public/assets/HourlyChart-CtYj-DJz.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion web_viewer/public/assets/HourlyChart-DaorG-El.js

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5601036

Please sign in to comment.