Nun*_*ves 6 javascript gwt highcharts highstock
我正在使用HighCharts库进行GWT,我遇到了问题.
我正在尝试这样的事情:股票图表示例.我对这个问题唯一感兴趣的是buttons里面的属性rangeSelector,我想在其中自定义按钮文本).在javascript上代码是这样的:
rangeSelector: {
buttons: [{
type: 'day',
count: 3,
text: '3dias'
}, {
type: 'week',
count: 1,
text: '1w'
}, {
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 6,
text: '6MS'
}, {
type: 'year',
count: 1,
text: '1ano'
}, {
type: 'all',
text: 'All'
}],
selected: 3
}
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试在GWT中使用图表上的setOption()方法做同样的事情.但似乎没有任何效果.
我觉得我遇到了麻烦,因为该buttons属性需要一系列属性,这就是我无法弄清楚如何解决的问题.
我试过的东西:
chart.setOption("/rangeSelector/buttons",
new String[]{"{type: 'day', count: 1, text: '1dia'}", "{type: 'day', count: 1, text: '1dia'}"});`
Run Code Online (Sandbox Code Playgroud)
这是我能想到的最好的,它创建了两个空按钮而没有动作.
任何帮助,将不胜感激.非常感谢你.
更新:(2012年12月13日)
在接受了答案后,我需要设置按钮.仅用于:
buttonTheme: {
width: 80
}
Run Code Online (Sandbox Code Playgroud)
就像是:
rangeSelector: {
selected: 2,
inputBoxStyle: {
top: '40px',
right: '10px'},
buttons: [{
type: 'week',
count: 1,
text: '1 semana'
}],
buttonTheme: {
width: 80
}
}
Run Code Online (Sandbox Code Playgroud)
您可以尝试以下操作吗:
String rangeSelectorConfig = " {\n" +
" buttons: [{\n" +
" type: 'day',\n" +
" count: 3,\n" +
" text: '3dias'\n" +
" }, {\n" +
" type: 'week',\n" +
" count: 1,\n" +
" text: '1w'\n" +
" }]" +
" }" ;
JSONValue config = JSONParser.parseLenient(rangeSelectorConfig);
chart.setOption("/rangeSelector", config);
Run Code Online (Sandbox Code Playgroud)
Chart类(在 的帮助下Configurable)不会为您解析 JSON 对象,因此代码中的按钮会作为字符串文字传递给本机 HightCharts JS。
| 归档时间: |
|
| 查看次数: |
8075 次 |
| 最近记录: |