@jiaminghi/charts
Advanced tools
Comparing version 0.2.15 to 0.2.16
@@ -0,1 +1,7 @@ | ||
# 0.2.16-alpha (2020-06-16) | ||
### Perfect | ||
- **numberText:** Add number formatter. | ||
# 0.2.15-alpha (2020-05-06) | ||
@@ -2,0 +8,0 @@ |
@@ -149,3 +149,5 @@ "use strict"; | ||
position: [0, 0], | ||
toFixed: 0 | ||
toFixed: 0, | ||
rowGap: 0, | ||
formatter: null | ||
}, | ||
@@ -171,10 +173,14 @@ validator: function validator(_ref7) { | ||
toFixed = shape.toFixed, | ||
rowGap = shape.rowGap; | ||
rowGap = shape.rowGap, | ||
formatter = shape.formatter; | ||
var textSegments = content.split('{nt}'); | ||
var lastSegmentIndex = textSegments.length - 1; | ||
var textString = ''; | ||
textSegments.forEach(function (t, i) { | ||
var currentNumber = number[i]; | ||
if (i === lastSegmentIndex) currentNumber = ''; | ||
if (typeof currentNumber === 'number') currentNumber = currentNumber.toFixed(toFixed); | ||
var currentNumber = number[i] || ''; | ||
if (typeof currentNumber === 'number') { | ||
currentNumber = currentNumber.toFixed(toFixed); | ||
if (typeof formatter === 'function') currentNumber = formatter(currentNumber); | ||
} | ||
textString += t + (currentNumber || ''); | ||
@@ -188,3 +194,3 @@ }); | ||
content: textString, | ||
rowGap: rowGap || 0 | ||
rowGap: rowGap | ||
}) | ||
@@ -191,0 +197,0 @@ }); |
{ | ||
"name": "@jiaminghi/charts", | ||
"version": "0.2.15", | ||
"version": "0.2.16", | ||
"author": "JiaMing <743192023@qq.com>", | ||
@@ -5,0 +5,0 @@ "description": "Lightweight charting", |
@@ -138,3 +138,5 @@ import { extendNewGraph } from '@jiaminghi/c-render' | ||
position: [0, 0], | ||
toFixed: 0 | ||
toFixed: 0, | ||
rowGap: 0, | ||
formatter: null | ||
}, | ||
@@ -156,16 +158,16 @@ | ||
draw ({ ctx }, { shape }) { | ||
const { number, content, toFixed, rowGap } = shape | ||
const { number, content, toFixed, rowGap, formatter } = shape | ||
const textSegments = content.split('{nt}') | ||
const lastSegmentIndex = textSegments.length - 1 | ||
let textString = '' | ||
textSegments.forEach((t, i) => { | ||
let currentNumber = number[i] | ||
let currentNumber = number[i] || '' | ||
if (i === lastSegmentIndex) currentNumber = '' | ||
if (typeof currentNumber === 'number') { | ||
currentNumber = currentNumber.toFixed(toFixed) | ||
if (typeof currentNumber === 'number') currentNumber = currentNumber.toFixed(toFixed) | ||
if (typeof formatter === 'function') currentNumber = formatter(currentNumber) | ||
} | ||
@@ -175,3 +177,3 @@ textString += t + (currentNumber || '') | ||
text.draw({ ctx }, { shape: { ...shape, content: textString, rowGap: rowGap || 0 } }) | ||
text.draw({ ctx }, { shape: { ...shape, content: textString, rowGap } }) | ||
} | ||
@@ -178,0 +180,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1596431
25655