2016-07-09 5 views
0

이 답변을 사용하여 JavaFX에서 Gantt Chart를 만들 수있었습니다 : Gantt chart from scratch. DateAxis를 Gantt 차트에 추가하기 Javafx

또한 내가 현재 간트 차트는 날짜로 "길이"를 처리하지 못하기 때문에, this- http://myjavafx.blogspot.com.by/2013/09/javafx-charts-display-date-values-on.html

하지만 지금은 사용할 수 없습니다를 사용하여 DateAxis를 추가 할 수 있었다. 따라서 차트의 시작 부분을 완벽하게 묘사하지만 차트의 끝은 어디에서나 가능하며 차트로 창 크기를 조정하면 끝이 훨씬 더 무작위입니다.

나는 "timeLength는"내가 밀리 초 단위의 번호로 설정 .add(new XYChart.Data(job.getTime(), machine, new ExtraData(timeLength, "status-red"))

새로운 차트를 추가하고있다. 하지만 기본적으로 그것이 작동하지 않으며, 그것은 내가 사용할 수있는 FXML을 추가 할 수 없기 때문에 또한 long.Also 나는 JfreeChart를 사용할 수 없습니다받을 수 있습니다.

그렇다면 각 차트의 시작과 끝 모두를 어떻게 정확하게 얻을 수 있습니까?

감사합니다.

답변

0

DateAxis 클래스에 다음 함수를 추가하여 밀리 초에서 시각적 단위까지 배율 인수를 계산합니다.

/** 
* @return The scale factor from milliseconds to visual units 
*/ 
public double getScale(){ 
    final double length = getSide().isHorizontal() ? getWidth() : getHeight(); 

    // Get the difference between the max and min date. 
    double diff = currentUpperBound.get() - currentLowerBound.get(); 

    // Get the actual range of the visible area. 
    // The minimal date should start at the zero position, that's why we subtract it. 
    double range = length - getZeroPosition(); 

    return length/diff; 
} 

시험 결과

Date startDate=new Date(); 
    long duration = 1000*60*1;//1 hour in milliseconds 
    series1.getData().add(new XYChart.Data(startDate, machine, new ExtraData(duration, "status-green"))); 

    startDate = new Date(startDate.getTime()+duration); 
    duration = 1000*60*1;//2 hours in milliseconds 
    series1.getData().add(new XYChart.Data(startDate, machine, new ExtraData(duration, "status-red"))); 

스크린 1