2017-10-13 5 views
0

내 현재의 X 축과 같은 값을 직접 : 내가 가장하고 가장 큰 값으로 첫 번째와 마지막 틱을 조정해야Highcharts 먼저 조정하고 x 축에 마지막 틱은 다음과 같은 이미지의

My current x-axis

을 . 그러면 첫 번째 진드기는 26.4.2015 18:38:36이고 마지막 진드기는 27.4.2015 9:07:27이됩니다. 나머지 진드기는 자동으로 계산되어야합니다.

$('#container').highcharts({ 
    chart: { 
    zoomType: "x" 
    }, 
    xAxis: { 
    type: "datetime", 
    title: { 
     text: "Time" 
    }, 
    minPadding: 0, 
    maxPadding: 0, 
    min: 1430073516000, 
    tickmarkPlacement: "on", 
    showFirstLabel: true, 
    showLastLabel: true, 
    startOnTick: false, 
    endOnTick: false, 
    labels: { 
     formatter() { 
     if (this.isFirst || this.isLast) { 
      return Highcharts.dateFormat("%e.%m.%Y %H:%M:%S", this.value); 
     } else { 
      return this.axis.defaultLabelFormatter.call(this); 
     } 
     } 
    } 
    }, 
    yAxis: { 
    title: { 
     text: "Value" 
    } 
    }, 
    tooltip: { 
    shared: true 
    }, 
    series: [ 
    { 
     id: "First", 
     name: "First", 
     marker: { 
     enabled: false 
     }, 
     data: [0, 0, 0, 0, 0, 0, 242, 542, 456, 422, 445, 884, 123], 
     pointStart: 1430073516000, 
     pointInterval: 60000 
    }, 
    { 
     id: "Second", 
     name: "Second", 
     marker: { 
     enabled: false 
     }, 
     data: [0, 0, 0, 25, 356, 427, 242, 456, 811, 422, 541, 5, 0], 
     pointStart: 1430073516000, 
     pointInterval: 60000 
    } 
    ] 
}); 

JSFiddle : http://jsfiddle.net/vy5uL2aw/1/

+0

답변을 원하면 적어도 시리즈 데이터를 공유해야합니다. 가급적 현재 그래프로 jsfiddle하십시오. – ewolden

+0

JSFiddle이 추가되었습니다. – Janek

+0

일부 눈금을 설정할 수없고 차트가 다른 축을 자동으로 생성하도록 할 수 없습니다. 시도 할 수있는 두 가지 방법 : 1) 두 개의 틱을 지정하는 두 번째'xAxis '를 만듭니다 (오프셋을 조정하고 라인을 숨길 필요가 있습니다). 2) 두 개의'plotLines'를 차트에 추가하고 귀하의 목표를 달성하기위한 레이블. 그렇지 않으면'tickPositioner()'함수를 사용하여 하나의 축에서 모든 틱을 적절히 설정합니다. – jlbriggs

답변

0

해결 함수는 x 축 아래 된 객체에 추가.

tickPositioner() { 
    let tickPositions = this.tickPositions; 
    tickPositions[0] = this.dataMin; 
    tickPositions[tickPositions.length - 1] = this.dataMax; 
    return tickPositions; 
}