Use custom function for number formatting

This commit is contained in:
2015-03-17 16:26:23 +07:00
parent bb0154638a
commit 32914aca2b
5 changed files with 14 additions and 9 deletions
+2 -2
View File
@@ -209,7 +209,7 @@ var Bar = React.createClass({
calculateLabelPosition: function() {
var val = this.props.value,
offset = this.props.offset,
label = this.props.item + ': ' + numberFormat(val),
label = this.props.item + ': ' + formatNumber(val),
labelWidth = textWidth(label),
labelOffsetWidth = labelWidth + 2*this.labelPaddingH,
labelX;
@@ -247,7 +247,7 @@ var Bar = React.createClass({
},
render: function() {
var label = this.props.item ? (this.props.item + ': ' + numberFormat(this.props.value)) : '',
var label = this.props.item ? (this.props.item + ': ' + formatNumber(this.props.value)) : '',
labelWidth = textWidth(label),
labelOuterWidth = (labelWidth == 0 ? 0 : labelWidth + 2*this.labelPaddingH),
barX = (this.state.lastBarX && this.state.lastBarX !== this.props.x
-5
View File
@@ -9,11 +9,6 @@ var SVGChartMixin = {
var fontFamily = 'Helvetica Neue, Helvetica, sans-serif',
fontSize = 16;
function numberFormat(num) {
// FIXME: Not supported in IE10- and Safari
return Intl.NumberFormat().format(num);
}
function textWidth(str) {
var svg = document.createElementNS('http://www.w3.org/2000/svg', "svg");
text = document.createElementNS('http://www.w3.org/2000/svg', "text");
+1 -1
View File
@@ -179,7 +179,7 @@ var StackedAreaChart = React.createClass({
return (
<StackedArea key={'area-'+ i}
item={item} i={i}
d={roundPathCorners(this.buildPathD(path), 4)}
d={roundPathCorners(this.buildPathD(path), 3)}
color={Colors[i]}
onMouseOver={this.handleFocusIn.bind(this, i)} />
);