diff --git a/Chart.js b/Chart.js index ffbe16f3711..297ebbc5267 100755 --- a/Chart.js +++ b/Chart.js @@ -879,14 +879,14 @@ window.Chart = function(context){ for (var i=0; i 0){ - ctx.translate(yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize); + ctx.translate(yAxisPosX + i*valueHop + valueHop/2,xAxisPosY + config.scaleFontSize); ctx.rotate(-(rotateLabels * (Math.PI/180))); ctx.fillText(data.labels[i], 0,0); ctx.restore(); } - + else{ - ctx.fillText(data.labels[i], yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize+3); + ctx.fillText(data.labels[i], yAxisPosX + i*valueHop + valueHop/2,xAxisPosY + config.scaleFontSize+3); } ctx.beginPath(); @@ -929,7 +929,7 @@ window.Chart = function(context){ ctx.stroke(); if (config.scaleShowLabels){ - ctx.fillText(calculatedScale.labels[j],yAxisPosX-8,xAxisPosY - ((j+1) * scaleHop)); + ctx.fillText(thousand_separator(calculatedScale.labels[j]),yAxisPosX-8,xAxisPosY - ((j+1) * scaleHop)); } } @@ -1087,12 +1087,12 @@ window.Chart = function(context){ for (var i=0; i 0){ - ctx.translate(yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize); + ctx.translate(yAxisPosX + i*valueHop + valueHop/2,xAxisPosY + config.scaleFontSize); ctx.rotate(-(rotateLabels * (Math.PI/180))); ctx.fillText(data.labels[i], 0,0); ctx.restore(); } - + else{ ctx.fillText(data.labels[i], yAxisPosX + i*valueHop + valueHop/2,xAxisPosY + config.scaleFontSize+3); } @@ -1421,6 +1421,24 @@ window.Chart = function(context){ // Provide some basic currying to the user return data ? fn( data ) : fn; }; + + function thousand_separator(input) { + var number = input.split('.'); + num = number[0]; + num = num.split("").reverse().join(""); + var numpoint = ''; + for (var i = 0; i < num.length; i++) { + numpoint += num.substr(i,1); + if (((i+1)%3 == 0) && i != num.length-1) { + numpoint += ','; + } + } + num = numpoint.split("").reverse().join(""); + if (number[1] != undefined) { + num = num+'.'+number[1]; + } + return num; + } }