feat: Implement support for currencies in more charts (#24594)

(cherry picked from commit d74d7eca23)
This commit is contained in:
Kamil Gabryjelski
2023-07-07 19:28:13 +02:00
committed by Michael S. Molina
parent 9a96d8cf8b
commit 6b366a2cff
18 changed files with 404 additions and 78 deletions

View File

@@ -51,7 +51,7 @@ const propTypes = {
leftMargin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
metric: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
normalized: PropTypes.bool,
numberFormat: PropTypes.string,
valueFormatter: PropTypes.object,
showLegend: PropTypes.bool,
showPercentage: PropTypes.bool,
showValues: PropTypes.bool,
@@ -90,7 +90,7 @@ function Heatmap(element, props) {
leftMargin,
metric,
normalized,
numberFormat,
valueFormatter,
showLegend,
showPercentage,
showValues,
@@ -115,8 +115,6 @@ function Heatmap(element, props) {
const pixelsPerCharX = 4.5; // approx, depends on font size
let pixelsPerCharY = 6; // approx, depends on font size
const valueFormatter = getNumberFormatter(numberFormat);
// Dynamically adjusts based on max x / y category lengths
function adjustMargins() {
let longestX = 1;

View File

@@ -1,3 +1,5 @@
import { getValueFormatter } from '@superset-ui/core';
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -17,7 +19,7 @@
* under the License.
*/
export default function transformProps(chartProps) {
const { width, height, formData, queriesData } = chartProps;
const { width, height, formData, queriesData, datasource } = chartProps;
const {
bottomMargin,
canvasImageRendering,
@@ -37,7 +39,13 @@ export default function transformProps(chartProps) {
yAxisBounds,
yAxisFormat,
} = formData;
const { columnFormats = {}, currencyFormats = {} } = datasource;
const valueFormatter = getValueFormatter(
metric,
currencyFormats,
columnFormats,
yAxisFormat,
);
return {
width,
height,
@@ -50,7 +58,6 @@ export default function transformProps(chartProps) {
leftMargin,
metric,
normalized,
numberFormat: yAxisFormat,
showLegend,
showPercentage: showPerc,
showValues,
@@ -59,5 +66,6 @@ export default function transformProps(chartProps) {
xScaleInterval: parseInt(xscaleInterval, 10),
yScaleInterval: parseInt(yscaleInterval, 10),
yAxisBounds,
valueFormatter,
};
}