Column Chart with Comma Separator in axisY after 9999 - CanvasJS JavaScript Charts

Column Chart with Comma Separator in axisY after 9999 - CanvasJS JavaScript Charts

by canvasjs

HTML

<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 360px; width: 100%;"></div>

JavaScript

var chart = new CanvasJS.Chart("chartContainer", {
	title: {
  		text: "Comma Separator in axisY only after 9999"
  },
  theme: "light2",
	axisY: {
  		interval: 2000, //Added just to show more values below 10000 where comma separator is not added
  		labelFormatter: function(e){							
          return CanvasJS.formatNumber(e.value, e.value > 9999 ? "#,###" : "###0");
			}
  },
  toolTip: {
      contentFormatter: function(e){
            return e.entries[0].dataPoint.x + ": " + CanvasJS.formatNumber(e.entries[0].dataPoint.y, e.entries[0].dataPoint.y > 9999 ? "#,###" : "###0");
      }
  },
	data: [{
		type: "column",    
		dataPoints: [
			{ y: 11000 },
			{ y: 8000 },
			{ y: 5000 },
			{ y: 6500 },
			{ y: 9500 },
			{ y: 6800 },
			{ y: 2800 },
			{ y: 3400 },
			{ y: 1400 }
		]
	}]
});

chart.render();