Files
firefly-iii/public/v3/js/7700.8a677dfa.js
2023-01-29 15:29:42 +01:00

1 line
2.8 KiB
JavaScript
Vendored

"use strict";(globalThis["webpackChunkfirefly_iii"]=globalThis["webpackChunkfirefly_iii"]||[]).push([[7700],{7700:(e,t,r)=>{r.r(t),r.d(t,{default:()=>p});var s=r(9835);function a(e,t,r,a,n,i){const o=(0,s.up)("ApexChart"),l=(0,s.up)("q-card");return(0,s.wg)(),(0,s.j4)(l,{flat:"",bordered:""},{default:(0,s.w5)((()=>[(0,s.Wm)(o,{ref:"chart",options:n.options,series:n.series,height:"350",type:"line"},null,8,["options","series"])])),_:1})}var n=r(1569),i=r(8898);class o{overview(e,t){let r=(0,i.Z)(e.start,"y-MM-dd"),s=(0,i.Z)(e.end,"y-MM-dd");return n.api.get("/api/v2/chart/account/dashboard",{params:{start:r,end:s,cache:t}})}}var l=r(9302),c=r(3555);const h={name:"AccountChart",data(){return{loading:!1,currencies:[],options:{theme:{mode:"dark"},dataLabels:{enabled:!1},noData:{text:"Loading..."},chart:{id:"account-chart",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",store:null}},created(){this.dateFormat=this.$t("config.month_and_day_fns")},mounted(){this.store=(0,c.S)();const e=(0,l.Z)();this.options.theme.mode=e.dark.isActive?"dark":"light",this.store.$onAction((({name:e,store:t,args:r,after:s,onError:a})=>{s((t=>{"setRange"===e&&(this.locale=this.store.getLocale,this.buildChart())}))})),null!==this.store.getRange.start&&null!==this.store.getRange.end&&this.buildChart()},methods:{numberFormatter:function(e,t){if(t instanceof Object){let r=this.currencies[t.seriesIndex]??"EUR";return Intl.NumberFormat(this.locale,{style:"currency",currency:r}).format(e)}if(Number.isInteger(t)){let r=this.currencies[t]??"EUR";return Intl.NumberFormat(this.locale,{style:"currency",currency:r}).format(e)}return"x"},buildChart:function(){if(console.log("buildChart"),null!==this.store.getRange.start&&null!==this.store.getRange.end&&!1===this.loading){console.log("buildChart go!");let e=this.store.getRange.start,t=this.store.getRange.end;!1===this.loading&&(this.loading=!0,this.generateStaticLabels({start:e,end:t}),(new o).overview({start:e,end:t},this.getCacheKey).then((e=>{this.generateSeries(e.data)})))}},generateSeries:function(e){let t;console.log("generateSeries"),this.series=[];for(let r in e)if(e.hasOwnProperty(r)){t={},t.name=e[r].label,t.data=[],e[r].converted||this.currencies.push(e[r].currency_code),e[r].converted&&this.currencies.push(e[r].native_code);for(let s in e[r].entries)t.data.push(e[r].entries[s]);this.series.push(t)}this.loading=!1},generateStaticLabels:function(e){let t,r=new Date(e.start),s=[];while(r<=e.end)s.push((0,i.Z)(r,this.dateFormat)),t=r.setDate(r.getDate()+1),r=new Date(t);this.options={...this.options,labels:s}}},components:{ApexChart:(0,s.RC)((()=>r.e(4736).then(r.t.bind(r,7092,23))))}};var d=r(1639),u=r(4458),g=r(9984),m=r.n(g);const b=(0,d.Z)(h,[["render",a]]),p=b;m()(h,"components",{QCard:u.Z})}}]);