2017-05-08 73 views
0

我建立一个highstock图在我的公司,目前我有以下问题:Highcharts - Highstock“inputEditDataFormat”破输入

我需要改变rangeSelector输入字段德语语言环境的格式。例如:25.06.2016

但我注意到,只要我改变选项“inputEditDateFormat”中的日期格式,它就不再起作用了。我不确定图表是否会混合每月和每天,但它不会按照预期的方式进行。

我已经做了一个小提示,让你对我的问题有所了解。 http://jsfiddle.net/G7azG/34/

$('#container').highcharts('StockChart', { 

     "colors": [ 
      "#fedd00", 
      "#22b6ae", 
      "#c0263c", 
      "#136e6c", 
      "#e2a297" 
     ], 
     "legend": { 
      "align": "left", 
      "adjustChartSize": true, 
      "navigation": { 
      "enabled": false 
      }, 
      "enabled": false 
     }, 
     "rangeSelector": { 
      "selected": 4, 
      "inputDateFormat": "%d.%m.%Y", 
      "inputEditDateFormat": "%d.%m.%Y" // <-- blame this fool 
     }, 
     "yAxis": { 
      "labels": {}, 
      "plotLines": [ 
      { 
       "value": 0, 
       "width": 2, 
       "color": "silver" 
      } 
      ] 
     }, 
     "plotOptions": { 
      "series": { 
      "compare": "percent", 
      "showInNavigator": true, 
      "lineWidth": 3 
      } 
     }, 
     "tooltip": { 
      "pointFormat": "<span style=\"color:{series.color}\">{series.name}</span>: <b>{point.y} €/t</b> ({point.change}%)<br/>", 
      "valueDecimals": 2, 
      "split": true 
     }, 
     "series": [ 
      { 
      "data": [ 
       [ 
       1136073600000, 
       72.9 
       ], 
       [ 
       1138752000000, 
       73.6 
       ], 
       [ 
       1141171200000, 
       74.2 
       ], 
       [ 
       1143849600000, 
       75 
       ], 
       [ 
       1146441600000, 
       75.3 
       ], 
       [ 
       1149120000000, 
       75.8 
       ], 
       [ 
       1151712000000, 
       77.3 
       ], 
       [ 
       1154390400000, 
       78.6 
       ], 
       [ 
       1157068800000, 
       80.4 
       ], 
       [ 
       1159660800000, 
       82.8 
       ], 
       [ 
       1162339200000, 
       83.6 
       ], 
       [ 
       1164931200000, 
       86.5 
       ], 
       [ 
       1167609600000, 
       86.8 
       ], 
       [ 
       1170288000000, 
       84.5 
       ], 
       [ 
       1172707200000, 
       82.5 
       ], 
       [ 
       1175385600000, 
       77.6 
       ], 
       [ 
       1177977600000, 
       76.5 
       ], 
       [ 
       1180656000000, 
       76.1 
       ], 
       [ 
       1183248000000, 
       76.2 
       ], 
       [ 
       1185926400000, 
       76.2 
       ], 
       [ 
       1188604800000, 
       77.4 
       ], 
       [ 
       1191196800000, 
       81.1 
       ], 
       [ 
       1193875200000, 
       83.7 
       ], 
       [ 
       1196467200000, 
       83.6 
       ], 
       [ 
       1199145600000, 
       83.9 
       ], 
       [ 
       1201824000000, 
       81.6 
       ], 
       [ 
       1204329600000, 
       75.3 
       ], 
       [ 
       1207008000000, 
       67.6 
       ], 
       [ 
       1209600000000, 
       68 
       ], 
       [ 
       1212278400000, 
       68.2 
       ] 
      ], 
      "visible": true, 
      "name": "Rundholz AT" 
      } 
     ] 
}); 

编辑:

感谢morganfree我得到这个工作。我只需要使用inputDateParser功能,像这样:

rangeSelector: { 
    inputDateFormat: "%d.%m.%Y", 
    inputEditDateFormat: "%d.%m.%Y", 
    inputDateParser: function (value) { 
     value = value.split('.'); 
     console.log(value); 
     return Date.UTC(
      parseInt(value[2]), 
      parseInt(value[1] - 1), 
      parseInt(value[0]) 
     ); 
    } 
} 

干杯;;

+0

你是说你无法编辑日期部分。 –

+0

@Nair Athul 对不起,我的意思是说它不像它应该的那样行事 –

回答

2

从文档inputEditDateFormat

...这必须是由JavaScript Date.parse识别的格式。

您需要使用inputDateParser解析日期。

+0

你钉了它。我不知道我错过了那部分,但这正是我所需要的。谢谢一堆! –