I'm using Highcharts to generate a line chart that shows currency values. By default the y-axis labels use metric prefixes for abbreviation, e.g. 3k is displayed instead of 3000
I would like to prepend a currency symbol to these labels, e.g. display $3k instead of 3k. However as soon as I add the currency symbol, the metric prefixes are no longer used. I've tried the following
yAxis: {
labels: {
formatter: function () {
return '$' + this.value;
}
}
}
and also tried
yAxis: {
labels: {
format: '${value}'
}
}
But in both cases $3000 is displayed instead of $3k. Is it possible to add a currency symbol without losing the metric prefix?
Here's a demo (JSFiddle here) that illustrates the problem
$(function() {
$('#container').highcharts({
yAxis: {
// if you include the lines below, the metric prefixes disappear
/*
labels: {
format: '${value}'
}
*/
},
series: [{
data: [15000, 20000, 30000]
}]
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px; width: 500px"></div>