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

prettier and eslint fixes #6

Open
wants to merge 1 commit into
base: master
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker_build_push_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set -eo pipefail
REPO_NAME="setusuraj/superset"


REFSPEC="2.0.4"
REFSPEC="2.0.6"
LATEST_TAG="latest"

cat<<EOF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export const D3_FORMAT_OPTIONS: [string, string][] = [
[NumberFormats.INDIAN_FORMAT_NUMBER, t('Indian format')],
[NumberFormats.INDIAN_FORMAT_CURRENCY, t('Indian currency format')],
[NumberFormats.INDIAN_FORMAT_NUMBER_SHORT, t('Indian format (in units)')],
[NumberFormats.INDIAN_FORMAT_CURRENCY_SHORT, t('Indian currency format (in units)')],
[
NumberFormats.INDIAN_FORMAT_CURRENCY_SHORT,
t('Indian currency format (in units)'),
],
[NumberFormats.SMART_NUMBER, t('Adaptive formatting')],
['~g', t('Original value')],
[',d', ',d (12345.432 => 12,345)'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const NumberFormats = {
INDIAN_FORMAT_NUMBER,
INDIAN_FORMAT_CURRENCY,
INDIAN_FORMAT_NUMBER_SHORT,
INDIAN_FORMAT_CURRENCY_SHORT,
INDIAN_FORMAT_CURRENCY_SHORT,
};

export default NumberFormats;
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,37 @@ import NumberFormatter from '../NumberFormatter';
// const float2PointFormatter = d3Format(`.2~f`);
const indianLocaleFormatter = Intl.NumberFormat('en-IN', {
maximumFractionDigits: 2,
minimumFractionDigits: 0
}).format // d3Format or regex whould be alternative
minimumFractionDigits: 0,
}).format; // d3Format or regex whould be alternative

function formatIndianUnitNumber(
value: number,
{ refoldAfterCrs = false },
): string {
let formated_number = 0;
let sufix = [];

const sufix = [];
let local_value = value;
do {
if (value >= 10000000) {
formated_number = value / 10000000;
if (local_value >= 10000000) {
formated_number = local_value / 10000000;
sufix.unshift('Cr');
} else if (value >= 100000) {
formated_number = value / 100000;
} else if (local_value >= 100000) {
formated_number = local_value / 100000;
sufix.unshift('L');
} else if (value >= 1000) {
formated_number = value / 1000;
} else if (local_value >= 1000) {
formated_number = local_value / 1000;
sufix.unshift('K');
} else {
formated_number = value;
formated_number = local_value;
}
value = formated_number;
} while (refoldAfterCrs && value >= 1000);
local_value = formated_number;
} while (refoldAfterCrs && local_value >= 1000);

return indianLocaleFormatter(value) + sufix.join(' ');
return indianLocaleFormatter(local_value) + sufix.join(' ');
}

function formatIndianNumber(value: number): string {
return indianLocaleFormatter(value)
return indianLocaleFormatter(value);
}

export default function createIndianNumberFormatter(
Expand All @@ -74,9 +74,8 @@ export default function createIndianNumberFormatter(

return new NumberFormatter({
description: description || 'Indian Number Formatter',
formatFunc: function (value) {
formatFunc: value => {
const sign = value >= 0 ? '' : '-';
debugger
const formattedNumber = foldToUnit
? formatIndianUnitNumber(Math.abs(value), { refoldAfterCrs })
: formatIndianNumber(Math.abs(value));
Expand Down