Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for number formatting in charts #1742

Open
wants to merge 3 commits into
base: 2024.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 68 additions & 1 deletion client/web/compose/src/components/Chart/Report/FunnelChart.vue
Expand Up @@ -28,7 +28,7 @@
</b-form-group>
</template>

<template #metric-options="{ metric }">
<template #metric-options="{ metric, presetFormattedOptions }">
<b-row>
<b-col
cols="12"
Expand Down Expand Up @@ -59,6 +59,73 @@
</b-form-group>
</b-col>
</b-row>

<hr>

<b-row>
<b-col
cols="12"
md="6"
lg="6"
>
<b-form-group
:label="$t('numberFormat')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.numberFormat"
:disabled="report.metricFormatter.presetFormat !== 'noFormat'"
placeholder="0.00"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('prefix')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.prefix"
placeholder="USD/mo"
/>
</b-form-group>
</b-col>
<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('suffix')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.suffix"
placeholder="$"
/>
</b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group
:label="$t('edit.additionalConfig.tooltip.formatting.presetFormats.label')"
label-class="text-primary"
style="white-space: pre-line;"
:description="presetFormattedOptions.formattedOptionsDescription"
>
<b-form-select
v-model="report.metricFormatter.presetFormat"
:options="presetFormattedOptions.formatOptions"
:disabled="!!report.metricFormatter.numberFormat"
/>
</b-form-group>
</b-col>
</b-row>
</template>
</report-edit>
</template>
Expand Down
74 changes: 73 additions & 1 deletion client/web/compose/src/components/Chart/Report/GaugeChart.vue
Expand Up @@ -56,7 +56,7 @@
</b-form-group>
</template>

<template #metric-options="{ metric }">
<template #metric-options="{ metric, presetFormattedOptions }">
<b-row>
<b-col
cols="12"
Expand Down Expand Up @@ -89,7 +89,9 @@
</b-form-checkbox>
</b-form-group>
</b-col>
</b-row>

<b-row>
<b-col
cols="12"
lg="6"
Expand Down Expand Up @@ -122,6 +124,76 @@
</b-form-group>
</b-col>
</b-row>

<hr>

<b-row>
<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('numberFormat')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.numberFormat"
:disabled="report.metricFormatter.presetFormat !== 'noFormat'"
placeholder="0.00"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('prefix')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.prefix"
placeholder="USD/mo"
/>
</b-form-group>
</b-col>
</b-row>

<b-row>
<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('suffix')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.suffix"
placeholder="$"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
lg="6"
>
<b-form-group
:label="$t('edit.additionalConfig.tooltip.formatting.presetFormats.label')"
label-class="text-primary"
style="white-space: pre-line;"
:description="presetFormattedOptions.formattedOptionsDescription"
>
<b-form-select
v-model="report.metricFormatter.presetFormat"
:disabled="!!report.metricFormatter.numberFormat"
:options="presetFormattedOptions.formatOptions"
/>
</b-form-group>
</b-col>
</b-row>
</template>
</report-edit>
</template>
Expand Down
136 changes: 133 additions & 3 deletions client/web/compose/src/components/Chart/Report/GenericChart.vue
Expand Up @@ -80,7 +80,9 @@
/>
</b-form-group>
</b-col>
</b-row>

<b-row>
<b-col
cols="12"
lg="6"
Expand Down Expand Up @@ -112,7 +114,11 @@
/>
</b-form-group>
</b-col>
</b-row>

<b-row
class="mb-2"
>
<b-col
cols="12"
lg="6"
Expand All @@ -136,6 +142,7 @@
<b-form-group
:label="$t('edit.yAxis.options.label')"
label-class="text-primary"
class="mb-0"
>
<b-form-checkbox
v-model="report.yAxis.axisType"
Expand Down Expand Up @@ -166,10 +173,59 @@
</b-form-group>
</b-col>
</b-row>

<hr>

<b-row>
<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('numberFormat')"
label-class="text-primary"
>
<b-input
v-model="report.yAxisFormatter.numberFormat"
placeholder="0.00"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('prefix')"
label-class="text-primary"
>
<b-input
v-model="report.yAxisFormatter.prefix"
placeholder="USD/mo"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('suffix')"
label-class="text-primary"
>
<b-input
v-model="report.yAxisFormatter.suffix"
placeholder="$"
/>
</b-form-group>
</b-col>
</b-row>
</div>
</template>

<template #metric-options="{ metric }">
<template #metric-options="{ metric, presetFormattedOptions }">
<b-row>
<b-col
cols="12"
Expand Down Expand Up @@ -312,13 +368,85 @@
</b-form-group>
</b-col>
</b-row>

<hr>

<b-row>
<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('numberFormat')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.numberFormat"
:disabled="report.metricFormatter.presetFormat !== 'noFormat'"
placeholder="0.00"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('prefix')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.prefix"
placeholder="USD/mo"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('suffix')"
label-class="text-primary"
>
<b-input
v-model="report.metricFormatter.suffix"
placeholder="$"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
lg="6"
>
<b-form-group
:label="$t('edit.additionalConfig.tooltip.formatting.presetFormats.label')"
label-class="text-primary"
style="white-space: pre-line;"
:description="presetFormattedOptions.formattedOptionsDescription"
>
<b-form-select
v-model="report.metricFormatter.presetFormat"
:disabled="!!report.metricFormatter.formatting"
:options="presetFormattedOptions.formatOptions"
/>
</b-form-group>
</b-col>
</b-row>
</template>

<template #additional-config="{ hasAxis, report }">
<hr>
<div class="px-3">
<h5 class="mb-3">
<h5 class="d-flex mb-3">
{{ $t('edit.additionalConfig.tooltip.label') }}
<c-hint
:tooltip="$t('edit.additionalConfig.tooltip.formatting.disclaimer')"
icon-class="text-warning"
/>
</h5>

<b-row>
Expand All @@ -327,16 +455,18 @@
lg="6"
>
<b-form-group
:label="$t('edit.additionalConfig.tooltip.formatting.label')"
:label="$t('edit.additionalConfig.tooltip.formatting.customFormatting')"
:description="$t('edit.additionalConfig.tooltip.formatting.description')"
label-class="text-primary"
>
<b-input
v-model="report.tooltip.formatting"
:disabled="report.tooltipFormatter.presetFormat !== 'noFormat'"
:placeholder="$t('edit.additionalConfig.tooltip.formatting.placeholder')"
/>
</b-form-group>
</b-col>

<b-col
v-if="!hasAxis"
cols="12"
Expand Down