2017-05-08 76 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

你釘了它。我不知道我錯過了那部分,但這正是我所需要的。謝謝一堆! –