diff --git a/resources/js/Global/components/Inputs/PersianDate.vue b/resources/js/Global/components/Inputs/PersianDate.vue index 4179c50..2b6c5a9 100644 --- a/resources/js/Global/components/Inputs/PersianDate.vue +++ b/resources/js/Global/components/Inputs/PersianDate.vue @@ -30,129 +30,135 @@ diff --git a/resources/js/Global/plugins/chart/apexhart/type/bar.js b/resources/js/Global/plugins/chart/apexhart/type/bar.js index aba6749..43346ac 100644 --- a/resources/js/Global/plugins/chart/apexhart/type/bar.js +++ b/resources/js/Global/plugins/chart/apexhart/type/bar.js @@ -1,11 +1,11 @@ import chart from "../chart"; - +import {seperator, price} from '@Global/utils/common/format' export default class extends chart { constructor(options) { super(options); this.type = options.type ? options.type : 'daily'; - + this.formatCount = 'number'; this.options = { fill: { colors: ["#e6e6e6"] @@ -15,16 +15,35 @@ export default class extends chart { fontFamily: '"iranyekan-regular-en-num", "Montserrat-Regular"' }, xaxis: { - categories: [] + categories: [], + }, + yaxis: { + labels: { + formatter: (val) => { + if (this.formatCount === 'number') { + return seperator(val) + } else if(this.formatCount === 'price') { + return price(val) + } + } + }, }, dataLabels: { style: { colors: ["#000", "#000", "#000"] - } + }, + enabled: true, + formatter: (val, opt) => { + if (this.formatCount === 'number') { + return seperator(val) + } else if(this.formatCount === 'price') { + return price(val) + } + }, }, series: [ { - name: "bar chart", + name: this.formatCount === 'number' ? "تعداد" : "قیمت", data: [] } ] @@ -41,13 +60,22 @@ export default class extends chart { setOptions() { switch (this.type) { case 'weekly': + this.formatCount = 'number'; + return this.setWeekly(); case 'cost-weekly': + this.formatCount = 'price'; return this.setWeekly(); case 'monthly': + this.formatCount = 'number'; + return this.setMonthly(); case 'cost-monthly': + this.formatCount = 'price'; return this.setMonthly(); case 'daily': + this.formatCount = 'number'; + return this.setDaily(); case 'cost-daily': + this.formatCount = 'price'; return this.setDaily(); } } diff --git a/resources/js/Global/plugins/chart/apexhart/type/pie.js b/resources/js/Global/plugins/chart/apexhart/type/pie.js index e796e7b..c1cb126 100644 --- a/resources/js/Global/plugins/chart/apexhart/type/pie.js +++ b/resources/js/Global/plugins/chart/apexhart/type/pie.js @@ -41,7 +41,7 @@ export default class extends chart { this.options.fill.label = this.responseChart.map(x => x.category.name); this.options['colors'] = this.responseChart.map( x =>{ let colorText = x.category.color ? x.category.color : color[parseInt((Math.random() * 100) % 14)].color; - return color.find(x => x.color == colorText).hex; + return color.find(x => x.color === colorText).hex; } ); } } diff --git a/resources/js/Global/utils/common/Object.js b/resources/js/Global/utils/common/Object.js index 73d94b5..0da9510 100644 --- a/resources/js/Global/utils/common/Object.js +++ b/resources/js/Global/utils/common/Object.js @@ -40,3 +40,4 @@ Array.prototype.matchItems = function (array) { } // Hide method from for-in loops Object.defineProperty(Array.prototype, "matchItems", {enumerable: false}); + diff --git a/resources/js/Global/utils/common/format.js b/resources/js/Global/utils/common/format.js new file mode 100644 index 0000000..420631c --- /dev/null +++ b/resources/js/Global/utils/common/format.js @@ -0,0 +1,6 @@ +export const price = (number, currency = 'تومان') => { + return Intl.NumberFormat().format(number) + ' ' + currency; +} +export const seperator = (number) => { + return new Intl.NumberFormat().format(number); +}