* add custom currency render

* tooltip

* remove filters

* remove custom component

* revert tooltip changes'

* update package-lock

* revert package-lock

* revert package-lock again
This commit is contained in:
Paul Sealock 2020-01-14 09:55:54 +13:00 committed by GitHub
parent 0396740c49
commit c0fc8a5be1
2 changed files with 18 additions and 8 deletions

View File

@ -45,10 +45,10 @@ class ChartTooltip {
return Math.max(
this.margin,
elementCoords.left +
elementCoords.width * ( 1 - elementWidthRatio ) -
tooltipSize.width -
this.margin -
leftMargin
elementCoords.width * ( 1 - elementWidthRatio ) -
tooltipSize.width -
this.margin -
leftMargin
);
}

View File

@ -29,21 +29,31 @@ export default class Currency {
this.symbol = config.symbol.toString();
this.symbolPosition = config.symbolPosition.toString();
this.decimalSeparator = config.decimalSeparator.toString();
this.priceFormat = config.priceFormat ? config.priceFormat.toString() : this.getPriceFormat( config );
this.priceFormat = this.getPriceFormat( config );
this.thousandSeparator = config.thousandSeparator.toString();
const precisionNumber = parseInt( config.precision, 10 );
this.precision = precisionNumber;
}
stripTags( str ) {
const tmp = document.createElement( 'DIV' );
tmp.innerHTML = str;
return tmp.textContent || tmp.innerText || '';
}
/**
* Get the default price format from a currency.
*
* @param {Object} currency Currency configuration.
* @param {Object} config Currency configuration.
* @return {String} Price format.
*/
getPriceFormat( currency ) {
switch ( currency.symbolPosition ) {
getPriceFormat( config ) {
if ( config.priceFormat ) {
return this.stripTags( config.priceFormat.toString() );
}
switch ( config.symbolPosition ) {
case 'left':
return '%1$s%2$s';
case 'right':