mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-20 11:48:27 -06:00
1 line
2.5 KiB
JavaScript
1 line
2.5 KiB
JavaScript
"use strict";(self["webpackChunkfirefly_iii"]=self["webpackChunkfirefly_iii"]||[]).push([[7480],{7480:(e,t,a)=>{a.r(t),a.d(t,{default:()=>g});var i=a(9835);function n(e,t,a,n,s,r){const o=(0,i.up)("ApexChart");return(0,i.wg)(),(0,i.iD)("div",null,[(0,i.Wm)(o,{width:"100%",ref:"chart",height:"350",type:"line",options:s.options,series:s.series},null,8,["options","series"])])}a(702);var s=a(1569),r=a(8898);class o{overview(e,t){let a=(0,r.Z)(e.start,"y-MM-dd"),i=(0,r.Z)(e.end,"y-MM-dd");return s.api.get("/api/v1/chart/account/overview",{params:{start:a,end:i,cache:t}})}}var l=a(1049),h=a(9302);const d={name:"HomeChart",computed:{...(0,l.Se)("fireflyiii",["getRange","getCacheKey"])},data(){return{range:{start:null,end:null},loading:!1,currencies:[],options:{theme:{mode:"dark"},dataLabels:{enabled:!1},noData:{text:"Loading..."},chart:{id:"vuechart-home",toolbar:{show:!0,tools:{download:!1,selection:!1,pan:!1}}},yaxis:{labels:{formatter:this.numberFormatter}},labels:[],xaxis:{categories:[]}},series:[],locale:"en-US",dateFormat:"MMMM d, y"}},created(){const e=(0,h.Z)();this.locale=e.lang.getLocale(),this.dateFormat=this.$t("config.month_and_day_fns")},mounted(){const e=(0,h.Z)();if(this.options.theme.mode=e.dark.isActive?"dark":"light",null===this.range.start||null===this.range.end){const e=(0,l.oR)();e.subscribe(((e,t)=>{"fireflyiii/setRange"===e.type&&(this.range=e.payload,this.buildChart())}))}null!==this.getRange.start&&null!==this.getRange.end&&this.buildChart()},methods:{numberFormatter:function(e,t){var a;let i=null!==(a=this.currencies[t])&&void 0!==a?a:"EUR";return Intl.NumberFormat(this.locale,{style:"currency",currency:i}).format(e)},buildChart:function(){if(null!==this.getRange.start&&null!==this.getRange.end){let e=this.getRange.start,t=this.getRange.end;if(!1===this.loading){this.loading=!0;const a=new o;this.generateStaticLabels({start:e,end:t}),a.overview({start:e,end:t},this.getCacheKey).then((e=>{this.generateSeries(e.data)}))}}},generateSeries:function(e){let t;this.series=[];for(let a in e)if(e.hasOwnProperty(a)){t={},t.name=e[a].label,t.data=[],this.currencies.push(e[a].currency_code);for(let i in e[a].entries)t.data.push(e[a].entries[i]);this.series.push(t)}this.loading=!1},generateStaticLabels:function(e){let t,a=new Date(e.start),i=[];while(a<=e.end)i.push((0,r.Z)(a,this.dateFormat)),t=a.setDate(a.getDate()+1),a=new Date(t);this.options={...this.options,labels:i}}},components:{ApexChart:(0,i.RC)((()=>a.e(4736).then(a.t.bind(a,7092,23))))}};var c=a(1639);const u=(0,c.Z)(d,[["render",n]]),g=u}}]); |