2016-11-02 12 views
0

이 질문에 답변하지는 못했습니다. here. showRoller : true를 코드에 추가 한 다음 1보다 큰 값으로 설정하면 그래프가 사라지고 왼쪽 가장자리의 첫 번째 점만 그려집니다. 나는 그것이 내 다른 매개 변수 중 하나와 약간의 충돌이있다 생각하고dygraphs의 showRoller가 rollPeriod> 1과 함께 실패하는 이유

 g[gnum] = new Dygraph(document.getElementById(gdiv), mylines, { 
      rollPeriod: 1, 
      showRoller: true, 
      labels: mylabels, 
      drawXAxis: true, 
      drawYAxis: true, 
      drawXGrid: true, 
      drawYGrid: true, 
      valueRange: myrange, 
      ylabel: ylabel[gnum], 
      fillGraph: false, 
      labelsShowZeroValues: true, 
      highlightCircleSize: 0, 
      strokeWidth: 0.4, 
      gridLineColor: '#dedede', 
      axisLabelColor: '#999999', 
      colors: colors, 
      rightGap: 15, 
      highlightSeriesBackgroundAlpha: .6, 
      highlightSeriesOpts: { 
       strokeWidth: 0.5, 
       strokeBorderWidth: 1, 
       strokeBorderColor: "#6699ff", 
       highlightCircleSize: 4 
      }, 
      labelsDivWidth: 300, 
      labelsDivStyles: { 
       'text-align': 'right' 
      }, 
      xAxisLabelWidth: 70, 
      axisLabelFontSize: 13, 
      axes: { 
       x: { 
        pixelsPerLabel:80, 
        valueFormatter: function(ms) { 
         return ' ' + new Date(ms).strftime('%m/%d/%Y %T') + ' '; 
        }, 
        axisLabelFormatter: function(d, gran) { 
         return Dygraph.zeropad(d.strftime('%m/%d/%Y')); 
        } 
       }, 
       y: { 
        valueFormatter: function(y) { 
         //if (!y) return ' null '; 
         return ' ' + y + ' ' + yfmt[gnum] + ' '; 
        } 
       } 
      }, 
      drawCallback: function(me, initial) { 
       var xrange = me.xAxisRange(); 
       if ((xrange[0] == oldxrange[0] && xrange[1] == oldxrange[1]) || blockRedraw || initial) return; 
       else { 
        blockRedraw = true; 
        for (var j = 1; j <= maxGraphs; j++) 
        { 
         if (gnum == j) continue; // don't draw if this graph or if graph doesn't exist 
         else { 
          g[j].updateOptions({ 
           dateWindow: xrange 
          }); 
         } 
        } 
        blockRedraw = false; 
        oldxrange = xrange; 
       } 
      }, 
      underlayCallback: function(canvas, area, g) { 
       // critical threshold lines 
       var bottom_left = g.toDomCoords(new Date(first[gnum]), critical[gnum][0]); 
       var top_right = g.toDomCoords(new Date(last[gnum]), critical[gnum][0]); 
       var left = bottom_left[0]; 
       var bottom = bottom_left[1]; 
       var right = top_right[0]; 
       var top = top_right[1]+5; 
       canvas.fillStyle = "rgba(250, 0, 0, 1)"; 
       canvas.fillRect(left, bottom, right-left, 1); 

       bottom_left = g.toDomCoords(new Date(first[gnum]), critical[gnum][1]); 
       top_right = g.toDomCoords(new Date(last[gnum]), critical[gnum][1]); 
       left = bottom_left[0]; 
       bottom = bottom_left[1]; 
       right = top_right[0]; 
       top = top_right[1]+5; 
       canvas.fillStyle = "rgba(250, 0, 0, 1)"; 
       canvas.fillRect(left, bottom, right-left, 1); 

       // maintenance threshold lines 
       bottom_left = g.toDomCoords(new Date(first[gnum]), maintenance[gnum][0]); 
       top_right = g.toDomCoords(new Date(last[gnum]), maintenance[gnum][0]); 
       left = bottom_left[0]; 
       bottom = bottom_left[1]; 
       right = top_right[0]; 
       top = top_right[1]+5; 
       canvas.fillStyle = "rgba(255, 220, 0, 1)"; 
       canvas.fillRect(left, bottom, right-left, 1); 

       bottom_left = g.toDomCoords(new Date(first[gnum]), maintenance[gnum][1]); 
       top_right = g.toDomCoords(new Date(last[gnum]), maintenance[gnum][1]); 
       left = bottom_left[0]; 
       bottom = bottom_left[1]; 
       right = top_right[0]; 
       top = top_right[1]+5; 
       canvas.fillStyle = "rgba(255, 220, 0, 1)"; 
       canvas.fillRect(left, bottom, right-left, 1); 
      } 
     }); 

: 여기

내 코드? dygraphs 샘플 코드를 내 시스템에 넣으면 잘 작동합니다. 내 데이터에 큰 격차 (약 10 일)이 : 내 데이터는

Tue Oct 04 2016 11:00:01 GMT-0700 (PDT),136.00,135.78,136.60,137.16, 
Tue Oct 04 2016 17:00:01 GMT-0700 (PDT),135.89,135.89,136.56,137.19, 
Tue Oct 04 2016 23:00:01 GMT-0700 (PDT),135.93,136.04,136.45,137.23, 
Wed Oct 05 2016 05:00:01 GMT-0700 (PDT),135.96,136.00,136.45,137.08, 
Wed Oct 05 2016 11:00:01 GMT-0700 (PDT),136.00,135.96,136.49,137.16, 
Wed Oct 05 2016 17:00:01 GMT-0700 (PDT),135.96,135.96,136.52,137.12, 
Wed Oct 05 2016 23:00:01 GMT-0700 (PDT),135.96,135.89,136.56,137.08, 
Thu Oct 06 2016 05:00:01 GMT-0700 (PDT),136.00,135.93,136.56,137.08, 
Thu Oct 06 2016 11:00:01 GMT-0700 (PDT),136.00,135.93,136.56,137.08, 
Thu Oct 06 2016 11:00:07 GMT-0700 (PDT),135.81,135.78,136.45,136.90, 
Thu Oct 06 2016 17:00:01 GMT-0700 (PDT),136.00,135.89,136.60,137.12, 
Thu Oct 06 2016 23:00:01 GMT-0700 (PDT),136.07,135.89,136.60,137.05, 
Fri Oct 07 2016 05:00:01 GMT-0700 (PDT),136.04,135.89,136.60,137.01, 
Fri Oct 07 2016 11:00:01 GMT-0700 (PDT),135.96,135.89,136.52,137.19, 

한 노트 ... 다음과 같습니다? 그게 중요합니까? 나는 dygraphs가 날짜가 무엇이든 관계없이 지연된 롤링 평균을 계산한다고 생각합니다. 여기

은 = 1 enter image description here

롤 기간 그래프이고, 여기서이 점은 여전히 ​​롤 기간 = 2의 그래프에서 활성임을 롤 기간 = 2 enter image description here

주이다. 마우스 오른쪽 버튼을 클릭하여 데이터를 볼 수 있습니다. 그러나 선들은 그려지지 않습니다. 무엇이 이것을 일으킬 수 있습니까?

+0

dygraphs.com/fiddle을 통해 재현 가능한 예를 제공하십시오. – danvk

+0

그건 아주 복잡한 문제입니다. 전체 js 호출이 위에 있습니다. 그 밖의 무엇이 필요합니까? 데이터에 큰 차이가 있으면 문제가 발생합니다. –

+0

내 문제는 추세선, 변수 사용 등을 위해 데이터를 가져 오는 것이므로 매우 복잡합니다. 제 질문은 어떤 종류의 것들이 작동하지 않을 수 있는지입니다. –

답변

0

이 문제가있는 다른 사람들에게 어떤 문제가 있는지 물어보고 무엇을 찾아야 할지를 물었습니다. 찾았어요. 내 정밀도를 .toFixed (2)로 2 소수로 변환했습니다. 그러면 데이터가 다시 문자열로 변환됩니다. 따라서이 문제가 있으면 데이터 형식을 확인하십시오. 혼란스러운 이유는 그래프가 문자열로 표시된 숫자로 그릴 수 있기 때문입니다. 그러나 데이터가 문자열 인 경우 롤링 평균을 계산하는 데 필요한 수학을 수행 할 수 없습니다.

다른 사람들에게 도움이되기를 바랍니다.

+1

당신이 그것을 알아 낸 것을 기쁘게 생각합니다! 기본 JavaScript WTF. – danvk