Skip to content

Commit

Permalink
Add Case Cost bar chart module
Browse files Browse the repository at this point in the history
  • Loading branch information
metroid-samus committed Jan 23, 2025
1 parent a6d8541 commit b2d20b3
Showing 1 changed file with 110 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<template>
<dashboard-card
:loading="loading"
type="bar"
:options="chartOptions"
:series="series"
title="Cost"
/>
</template>

<script>
import { forEach, sumBy } from "lodash"
import DashboardCard from "@/dashboard/DashboardCard.vue"
export default {
name: "CaseCostBarChartCard",
props: {
modelValue: {
type: Object,
default: function () {
return {}
},
},
loading: {
type: [String, Boolean],
default: function () {
return false
},
},
},
components: {
DashboardCard,
},
computed: {
chartOptions() {
return {
chart: {
type: "bar",
height: 350,
animations: {
enabled: false,
},
},
responsive: [
{
options: {
legend: {
position: "top",
},
},
},
],
xaxis: {
categories: this.categoryData || [],
title: {
text: "Month",
},
},
yaxis: {
labels: {
show: false,
formatter: function (val) {
var formatter = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
maximumSignificantDigits: 6,
})
return formatter.format(val) /* $2,500.00 */
},
},
},
fill: {
opacity: 1,
},
legend: {
position: "top",
},
dataLabels: {
enabled: true,
formatter: function (val) {
var formatter = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
maximumSignificantDigits: 6,
})
return formatter.format(val) /* $2,500.00 */
},
},
}
},
series() {
console.log('series')

Check failure on line 96 in src/dispatch/static/dispatch/src/dashboard/case/CaseCostBarChartCard.vue

View workflow job for this annotation

GitHub Actions / build

Replace `'series'` with `"series"`
console.log(this.modelValue)
let series = { name: "cost", data: [] }
forEach(this.modelValue, function (value) {
series.data.push(sumBy(value, "total_cost"))
})
return [series]
},
categoryData() {
return Object.keys(this.modelValue)
},
},
}
</script>

0 comments on commit b2d20b3

Please sign in to comment.