2017-07-22 7 views
0

J'ai un chandelier HighChart dynamique avec les options suivantes:Comment forcer les unités HighChart xAxis à afficher un format personnalisé dans tous les niveaux de zoom?

chart: { 
    renderTo: 'chart-container', 
    marginRight: 10 
}, 
title: { 
    text: 'My Chart' 
}, 
xAxis: { 
    type: 'datetime' 
}, 
rangeSelector: { 
    buttons: [{ 
     count: 5, 
     type: 'second', 
     text: '5S' 
    }, { 
     count: 30, 
     type: 'second', 
     text: '30S' 
    }, { 
     count: 10, 
     type: 'minute', 
     text: '10M' 
    }, { 
     type: 'all', 
     text: 'All' 
    }], 
    inputEnabled: false, 
    selected: 0 
}, 
tooltip: { 
    formatter: function (e) { 
     var point = this.points[0].point; 
     return '<div><b>Open: </b><span>' + point.open + '</span></div><div><b> Close: </b><span>' + point.close + '</span></div><div><b> High: </b><span>' + point.high + '</span></div><div><b> Low: </b><span>' + point.low + '</span></div><div><b> Custom Param: </b><span>' + point.customParam + '</span></div>' 
    } 
}, 
legend: { 
    enabled: false 
}, 
exporting: { 
    enabled: false 
}, 
series: [ 
    { 
     name: 'My Chart', 
     type: 'candlestick', 
     data: [] 
    }, 
    { 
     name: 'Average', 
     type: 'spline', 
     data: [], 
     marker: { 
      lineWidth: 2, 
      lineColor: Highcharts.getOptions().colors[3], 
      fillColor: 'white' 
     }, 
     color: Highcharts.getOptions().colors[3] 
    }] 

Points ajoutera dynamiquement. Comme vous pouvez le voir dans mes options, j'ai défini rangeSelector. Actuellement, les points sur xAsix s'affichent sous la forme HH: mm: ss.fff. Je veux montrer que je veux montrer des points xAxis avec ce format Juillet - 14: 26: 12.120 comme capture d'écran jointe.

enter image description here

+1

Vous devriez pouvoir utiliser dateTimeLabelFormats dans votre graphique http://api.highcharts.com/highcharts/xAxis.dateTimeLabelFormats ou xAxis.labels.formatter: http://api.highcharts.com/highcharts/xAxis.labels .formatter –

Répondre