Javascript / Coffeescript newb在这里。我最近一直在用coffeescript摆弄highcharts双仪表api。我正在尝试更改标签样式(即颜色,字体大小)。我在highchart网站(Highchart API参考)上查看了一些示例,这些示例将javascript转换为coffeescript可能有点挑剔。下面的语法似乎不正确,我只是想知道样式标签的正确语法是什么。
咖啡脚本:
@chart = undefined labels = {0: '0s', 5: '0.5s', 10: '1s', 15: '10s', 20: '20s'}
。
yAxis: [{
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[@value]`
style:
'font-size': '20px'
'color': '#00ff00'`
我没有使用过HighCharts,但是我可以帮助Coffeescript语法。
您链接到的文档中的CSS对象在Coffee中看起来像这样:
style =
color: '#6D869F'
fontWeight: 'bold'
您发布的yAxis数组不应该具有第一个大括号,而需要最后一个方括号。它看起来应该像这样:
yAxis: [
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[@value]
style:
'font-size': '20px'
'color': '#00ff00'
]
这将为您提供一个内部带有对象的数组。
如果您需要一个包含多个对象的数组,则可以使用以下方法:
yAxis: [
{
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[@value]
style:
'font-size': '20px'
'color': '#00ff00'
}
{
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[@value]
style:
'font-size': '20px'
'color': '#00ff00'
}
]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句