2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: tentative fix to single value charts

- i.e. when This Month
This commit is contained in:
18alantom 2022-01-28 01:09:48 +05:30 committed by Alan
parent 55fc6d8b66
commit 281de603e4
3 changed files with 16 additions and 5 deletions

View File

@ -13,7 +13,11 @@
<span class="ml-2 text-gray-900">{{ t('Outflow') }}</span> <span class="ml-2 text-gray-900">{{ t('Outflow') }}</span>
</div> </div>
</div> </div>
<PeriodSelector :value="period" @change="(value) => (period = value)" /> <PeriodSelector
:value="period"
@change="(value) => (period = value)"
:options="['This Year', 'This Quarter']"
/>
</div> </div>
<LineChart <LineChart
v-if="hasData" v-if="hasData"
@ -136,7 +140,7 @@ export default {
const colors = ['#2490EF', '#B7BFC6']; const colors = ['#2490EF', '#B7BFC6'];
const format = (value) => frappe.format(value ?? 0, 'Currency'); const format = (value) => frappe.format(value ?? 0, 'Currency');
const yMax = getYMax(points); const yMax = getYMax(points);
return { points, xLabels, colors, format, yMax, formatX:formatXLabels }; return { points, xLabels, colors, format, yMax, formatX: formatXLabels };
}, },
}, },
methods: { methods: {

View File

@ -39,14 +39,20 @@
import Dropdown from '@/components/Dropdown'; import Dropdown from '@/components/Dropdown';
export default { export default {
name: 'PeriodSelector', name: 'PeriodSelector',
props: ['value'], props: {
value: String,
options: {
type: Array,
default: () => ['This Year', 'This Quarter', 'This Month'],
},
},
components: { components: {
Dropdown, Dropdown,
}, },
data() { data() {
let options = ['This Year', 'This Quarter', 'This Month'];
return { return {
periodOptions: options.map((option) => { periodOptions: this.options.map((option) => {
return { return {
label: option, label: option,
action: () => this.selectOption(option), action: () => this.selectOption(option),

View File

@ -5,6 +5,7 @@
<PeriodSelector <PeriodSelector
slot="action" slot="action"
:value="period" :value="period"
:options="['This Year', 'This Quarter']"
@change="(value) => (period = value)" @change="(value) => (period = value)"
/> />
</SectionHeader> </SectionHeader>