Skip to content

Commit

Permalink
fix: Chart visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
LeleDallas committed May 15, 2023
1 parent fdcdd57 commit afad65f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
11 changes: 6 additions & 5 deletions src/Consumer/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const Dashboard = () => {
gas: { name: "Gas", data: [0] },
water: { name: "Water", data: [0] },
electric: { name: "Electric", data: [0] },
solar: { name: "Solar", data: 0 },
wind: { name: "Wind", data: 0 },
hydro: { name: "Hydro", data: 0 },
geo: { name: "Geo", data: 0 },
solar: { name: "Solar", data: [0] },
wind: { name: "Wind", data: [0] },
hydro: { name: "Hydro", data: [0] },
geo: { name: "Geo", data: [0] },
});

const navigate = useNavigate();
Expand Down Expand Up @@ -68,7 +68,8 @@ const Dashboard = () => {
<Col lg={8} md={8} xs={8} >
<StatsCard
color={"#ebfafa"}
chart={<ReactApexChart options={statebar("Water", "#008ffb").options as ApexOptions}
chart={<ReactApexChart
options={statebar("Water", "#008ffb").options as ApexOptions}
series={[energy.water] as ApexAxisChartSeries}
type="bar" height={150} />}
/>
Expand Down
9 changes: 6 additions & 3 deletions src/Consumer/DashboardCards/LineCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const options: ApexOptions = {
},
},
toolbar: { show: true, },

},
stroke: {
curve: 'smooth',
Expand Down Expand Up @@ -75,7 +74,7 @@ const options: ApexOptions = {

}
const LineCard = ({ data }: any) => {

const filterData = (e: any) => {
ApexCharts.exec('area-datetime', 'zoomX',
new Date(e[0]).getTime(),
Expand All @@ -92,7 +91,11 @@ const LineCard = ({ data }: any) => {
</CardTitle>
</Col>
<Col>
<DatePicker.RangePicker placeholder={["Start Date", "End Date"]} locale={locale} onChange={(e) => filterData(e)} />
<DatePicker.RangePicker
placeholder={["Start Date", "End Date"]}
locale={locale}
onChange={(e) => filterData(e)}
/>
</Col>
</Row>
<ReactApexChart options={options} series={data} type="area" height={350} />
Expand Down
6 changes: 4 additions & 2 deletions src/Consumer/Invoices/ElectricInvoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useState } from "react"
import ReactApexChart from "react-apexcharts"
import { InvoicesProps, optionsLine, pieOptions } from "./utilsInvoices"
import InvoicesWrapper from "./InvoicesWrapper"
import { sortDate } from "../utils"

const ElectricInvoices = ({ bills, cost, aggregated, filtered }: InvoicesProps) => {
const [metricCubic, setMetric] = useState(true)
Expand Down Expand Up @@ -43,12 +44,13 @@ const ElectricInvoices = ({ bills, cost, aggregated, filtered }: InvoicesProps)
const tmp: Array<any> = []
if (aggregated === undefined || aggregated === "undefined") {
filtered?.forEach((el: any) => {
tmp.push([el[0], el[1]])
tmp.push({ x: el[0], y: el[1] })
})
sortDate(tmp)
setAllElectricLine([{ data: tmp }])
} else {
Object.values(aggregated).map((el: any) => {
tmp.push([el.date, el.electric])
tmp.push({ x: el.date, y: el.electric })
})
setAllElectricLine([{ data: tmp }])
}
Expand Down
9 changes: 6 additions & 3 deletions src/Consumer/Invoices/GasInvoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useState } from "react"
import ReactApexChart from "react-apexcharts"
import { InvoicesProps, optionsLine, pieOptions } from "./utilsInvoices"
import InvoicesWrapper from "./InvoicesWrapper"
import { sortDate } from "../utils"

const GasInvoices = ({ bills, cost, aggregated, filtered }: InvoicesProps) => {
const [metricCubic, setMetric] = useState(true)
Expand Down Expand Up @@ -41,13 +42,15 @@ const GasInvoices = ({ bills, cost, aggregated, filtered }: InvoicesProps) => {
const tmp: any = []
if (aggregated === undefined || aggregated === "undefined") {
filtered?.forEach((el: any) => {
tmp.push([el[0], el[1]])
tmp.push({ x: el[0], y: el[1] })
})
sortDate(tmp)
setAllGasLine([{ data: tmp }])
} else {
Object.values(aggregated)?.map((el: any) => tmp.push([el.date, el.gas]))
Object.values(aggregated).map((el: any) => {
tmp.push({ x: el.date, y: el.gas })
})
setAllGasLine([{ data: tmp }])

}
}, [filtered, metricCubic, aggregated, cost, bills])

Expand Down
10 changes: 5 additions & 5 deletions src/Consumer/Invoices/WaterInvoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useState } from "react"
import ReactApexChart from "react-apexcharts"
import { InvoicesProps, optionsLine, pieOptions } from "./utilsInvoices"
import InvoicesWrapper from "./InvoicesWrapper"
import { sortDate } from "../utils"

const WaterInvoices = ({ bills, cost, aggregated, filtered }: InvoicesProps) => {
const [metricCubic, setMetric] = useState(true)
Expand Down Expand Up @@ -51,17 +52,16 @@ const WaterInvoices = ({ bills, cost, aggregated, filtered }: InvoicesProps) =>
const tmp: Array<any> = []
if (aggregated === undefined || aggregated === "undefined") {
filtered?.forEach((el: any) => {
tmp.push([el[0], el[1]])
tmp.push({ x: el[0], y: el[1] })
})
sortDate(tmp)
setAllWaterLine([{ data: tmp }])
} else {
Object.values(aggregated)?.map((el: any) => {
tmp.push([el.date, el.water])
Object.values(aggregated).map((el: any) => {
tmp.push({ x: el.date, y: el.gas })
})
setAllWaterLine([{ data: tmp }])

}

}, [filtered, aggregated, metricCubic, bills, cost])

return (
Expand Down

0 comments on commit afad65f

Please sign in to comment.