如何使用Angular JS在Highcharts中设置“lang”属性? [英] How to set 'lang' property in Highcharts using Angular JS?
问题描述
Highcharts.setOptions({
lang:{
thousandsSep:','
}
});
但是,在我的代码中写入时,出现Highcharts未定义的错误,即使我只在配置对象中设置了lang属性:
function extendBaseConfiguration(config){
//这些选项是所有图表的默认值。传入一个对象来覆盖这些值(或者只是在返回时才更改它们)
return $ .extend(true,{
chart:{
plotBackgroundColor:null,
plotBorderWidth:0,
plotShadow:false,
borderWidth:0
},
plotOptions:{
列:{
分组:false,
pointPadding:0.2,
borderWidth:0
}
},
lang:{
decimalPoint:$ locale.NUMBER_FORMATS.DECIMAL_SEP,
thousandsSep:$ locale.NUMBER_FORMATS.GROUP_SEP
},
tooltip:{pointFormat:'{series.name}:{point.y}'},
导出:{enabled:true},
学分:{enabled:false}
},config);
}
那么我该如何或在哪里注入这个Highcharts,以便设置它的值。或者是有任何其他的技术,我可以使数量的用户文化特定的格式。
尝试使用setOptions里面控制器,似乎应用了选项。
Highcharts.setOptions({
lang:{
printChart: 'aaaa',
thousandsSep:','
}
});
$ scope.chartConfig = {
options:{
chart:{
type:'bar'
}
},
series:[{
data:[1000,1500,1200,8000,7000]
}],
title:{
text:'Hello'
},
loading:false
}
$ h $ $ $ $ $ $ $ $
We are using Highcharts in our application using Angular JS. I want to set the formatting of amounts in a user culture specific formats which I am receiving from $locale service. After refering a link i got know that we can set values in below property for Highcharts:
Highcharts.setOptions({
lang: {
thousandsSep: ','
}
});
But while writing it in my code I am getting error that Highcharts is not defined, and also not working even if I set only lang property in the config object:
function extendBaseConfiguration(config) {
// these options are the default for all the charts. Pass in an object to override these values (or just change them once they're returned)
return $.extend(true, {
chart: {
plotBackgroundColor: null,
plotBorderWidth: 0,
plotShadow: false,
borderWidth: 0
},
plotOptions: {
column: {
grouping: false,
pointPadding: 0.2,
borderWidth: 0
}
},
lang: {
decimalPoint: $locale.NUMBER_FORMATS.DECIMAL_SEP,
thousandsSep: $locale.NUMBER_FORMATS.GROUP_SEP
},
tooltip: { pointFormat: '{series.name}: {point.y}'},
exporting: {enabled: true},
credits: {enabled: false}
}, config);
}
So how or where could I inject this Highcharts so that I can set it's value. Or is there any other technique by which i can make the amount user culture specific formatted.
Try to use a setOptions inside a controller, seems that options are applied.
Highcharts.setOptions({
lang: {
printChart: 'Aaaa',
thousandsSep: ','
}
});
$scope.chartConfig = {
options: {
chart: {
type: 'bar'
}
},
series: [{
data: [1000, 1500, 1200, 8000, 7000]
}],
title: {
text: 'Hello'
},
loading: false
}
Example: http://jsfiddle.net/Hjdnw/1426/
这篇关于如何使用Angular JS在Highcharts中设置“lang”属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!