2014-02-13 1 views
1

나는 Dashing이라는 Sinatra 기반 프레임 워크를 사용하여 프로젝트 작업을하고 있습니다. 내 프로젝트의 일부는 RickShaw Graph를 사용하여 그래프를 작성하는 것입니다. 내 문제는 X 축에 월 이름과 날짜를 표시 할 수 없다는 것입니다. 나는 이러한 값을 표현하기 위해 coffeescript를 사용하고 있습니다. 내가 여기에 사용할 수있는 인력거 그래프 API 이해 것과Coffeescript의 Rickshaw Graph에 월 이름을 표시 할 수 없습니다.

class Dashing.Graph extends Dashing.Widget 



@accessor 'points', Dashing.AnimatedValue 

    @accessor 'current', -> 
    return @get('displayedValue') if @get('displayedValue') 
    points = @get('points') 
    if points 
     points[points.length - 1].y 

#ready is triggered when ever the page is loaded. 
    ready: -> 
    container = $(@node).parent() 
    # Gross hacks. Let's fix this. 
    width = (Dashing.widget_base_dimensions[0] * container.data("sizex")) + Dashing.widget_margins[0] * 2 * (container.data("sizex") - 1) 
    height = (Dashing.widget_base_dimensions[1] * container.data("sizey")) 
    @graph = new Rickshaw.Graph(
     element: @node 
     width: width 
     height: height 
     renderer: @get("graphtype") 
     series: [ 
     { 
     color: "#fff", 
     data: [{x:0, y:0}] 
     } 
     ] 
    ) 

    @graph.series[0].data = @get('points') if @get('points') 
    time = new Rickshaw.Fixtures.Time() 
    days = time.unit("day") 

    x_axis = new Rickshaw.Graph.Axis.Time(
     graph: @graph 
     timeUnit: days 
    ) 
    y_axis = new Rickshaw.Graph.Axis.Y(graph: @graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT) 
    @graph.render() 

:

https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Fixtures.Time.js

당신이 장치의 이름을 지정할 수 있다고 여기 그래프에 대한 코드입니다. 그래서이 인스턴스에 대해서는 테스트 목적으로 "하루"를 사용했지만이 기능은 작동하지 않는 것 같습니다. 도움이 될 것입니다.

답변

0

timeFixture을 지정하면 x 축의 눈금에 레이블을 지정하는 방법을 결정할 수 있습니다.

var xAxis = new Rickshaw.Graph.Axis.Time({ 
    graph: graph, 
    timeFixture: new Rickshaw.Fixtures.Time.Local() 
}); 

정체 시간 범위 케어 표시되는 소요 포맷의 일자/시간 FO 적절한 수준의 세부, 예를 들면, 트리거 몇 년에서 몇 시간으로 확대.

당신은 또한 자신의 '시간 고정'을 만들고 거기를 설정 Rickshaw.Fixtures.Time.Local

대안 Rickshaw.Fixtures.Time 봐이나 걸릴 수

는 기기의 '는 일명 간격 고정 지정하면 항상 표시하려면 : 답장을

var timeFixture = new Rickshaw.Fixtures.Time(); 
var unitHour = timeFixture.unit('hour'); 
var xAxis = new Rickshaw.Graph.Axis.Time({ 
    graph: graph, 
    timeUnit: unitHour, 
    timeFixture: timeFixture 
}); 
+0

감사합니다, 나는 문제가 업데이트되었습니다 나는이 Rickshaw.min.js 파일을 업데이트하지 않았다고 생각. 이전 버전에는 Time.Local이 없습니다. 최신 버전을 원하는 사람이라면 https://raw.github.com/shutterstock/rickshaw/master/rickshaw.min.js에서 다운로드 할 수 있습니다. – Joshi

관련 문제