Remove hours from time series

Mercier

Dygraphs allows easy display of time series...

However, if my data contains only two data points, it automatically fills the gaps in X axis with hours. Is it possible to disable this functionality?
I searched and tried many options but not found anything useful.

Example might be the 'Time Series Drawing Demo' from the gallery - if executed on only few datapoints, it fills the 'gaps' with hours.

This is a good example:

g = new Dygraph(document.getElementById('plot'),"a,b\n2008-12-01,0.9\n2008-12-02,0.3\n2008-12-03,0.7\n")

UPDATE- this seems to be working:

ticker: function(a, b, pixels, opts, dygraph, vals) {
  var chosen = Dygraph.pickDateTickGranularity(a, b, pixels, opts);
  if(chosen==12) chosen=13;
  if (chosen >= 0) {
    return Dygraph.getDateAxis(a, b, chosen, opts, dygraph);
  } else {
    // this can happen if self.width_ is zero.
    return [];
  }
};
kaliatech

Your issue is not that you have two points, but that your points cover a certain amount of time. Dygraphs tries to calculate the best granularity for the x axis tick marks in a given set of data.

기본 계산을 수정하는 한 가지 방법은 pixelsPerLabel 옵션 을 사용하는 것입니다.

예 : http://jsfiddle.net/kaliatech/P8ehg/

var data = "a,b\n2008-12-01,0.9\n2008-12-02,0.3\n2008-12-03,0.7\n";
g = new Dygraph(document.getElementById("plot"), data, {
  axes: {
    x: {
        pixelsPerLabel: 100
      }
    }
});

그래도 픽셀 너비를 하드 코딩해야하며 그래도 궁극적으로 그래프로 표시하는 데이터 세트에 따라 달라집니다. 더 유연한 접근 방식은 표시기 옵션 을 사용하여 레이블 세분성을 계산하는 고유 한 기능을 제공 할 수 있습니다. dygraph-tickers.js 의 문서 및 내장 기능을 참조하십시오 .

또한보십시오:


편집 : 시세 사용 예제. 이를 위해서는 데이터에 익숙하고 데이터 범위가 다소 일정해야합니다. 그렇지 않으면 읽을 수없는 x 축 레이블이 표시 될 수 있습니다.

var g = new Dygraph(document.getElementById("demodiv3"), data(), {
  title: 'Example for changing x-axis label granularity 3',
  axes: {
    x: {
        ticker: function(a, b, pixels, opts, dygraph, vals) {
          var chosen = Dygraph.pickDateTickGranularity(a, b, pixels, opts);
          //Force to DAILY if built-in calculation returned SIX_HOURLY
            //if(chosen==Dygraph.SIX_HOURLY)
            //    chosen=Dygraph.DAILY;
          //or

          //Force to DAILY always
          chosen = Dygraph.DAILY;

          if (chosen >= 0) {
            return Dygraph.getDateAxis(a, b, chosen, opts, dygraph);
          } else {
            return [];
          }
        }        
      }

    }
});

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Selecting regular intervals from time series

분류에서Dev

JavaScript formatting time 24hours format to 12hours

분류에서Dev

Resample Time Series in pandas

분류에서Dev

for loop in irregular time series

분류에서Dev

R: time series with value

분류에서Dev

How to remove time segment completely from datetime after converting to string?

분류에서Dev

How do I remove "ghost" backups from Time Machine?

분류에서Dev

How to output time remaining in days or hours with liquid?

분류에서Dev

Calculating days from TimeSpan hours

분류에서Dev

pandas series use truncate get specified hours, minutes and seconds?

분류에서Dev

xarray: calculate time-series of daily anomalies from *local* monthly means

분류에서Dev

Time count and session variable for 4 hours long time

분류에서Dev

Time Series using numpy or pandas

분류에서Dev

Subsequent time-series matching

분류에서Dev

Expand a time series by specified time lengths in R

분류에서Dev

Converting 24hours time format to 12hours for slider bar

분류에서Dev

Subtract 12 hours from timestamp (batch file)

분류에서Dev

Automatically get the time taking day light saving hours into account

분류에서Dev

php turning number (hours) to php date and time format

분류에서Dev

Only display hours if time is greater than 60 minutes

분류에서Dev

Conditional creation of a series from other series

분류에서Dev

Time Series Prediction with Keras - Error in Model Values

분류에서Dev

Plotly: How to plot time series in Dash Plotly

분류에서Dev

Aggregation of time-series data on multiple columns

분류에서Dev

issues plotting multivariate time series in R

분류에서Dev

Combining time series data into a single data frame

분류에서Dev

format a time series as dataframe with julian date

분류에서Dev

TIme series data in R, problems with dates

분류에서Dev

Pandas - Extracting data from Series

Related 관련 기사

  1. 1

    Selecting regular intervals from time series

  2. 2

    JavaScript formatting time 24hours format to 12hours

  3. 3

    Resample Time Series in pandas

  4. 4

    for loop in irregular time series

  5. 5

    R: time series with value

  6. 6

    How to remove time segment completely from datetime after converting to string?

  7. 7

    How do I remove "ghost" backups from Time Machine?

  8. 8

    How to output time remaining in days or hours with liquid?

  9. 9

    Calculating days from TimeSpan hours

  10. 10

    pandas series use truncate get specified hours, minutes and seconds?

  11. 11

    xarray: calculate time-series of daily anomalies from *local* monthly means

  12. 12

    Time count and session variable for 4 hours long time

  13. 13

    Time Series using numpy or pandas

  14. 14

    Subsequent time-series matching

  15. 15

    Expand a time series by specified time lengths in R

  16. 16

    Converting 24hours time format to 12hours for slider bar

  17. 17

    Subtract 12 hours from timestamp (batch file)

  18. 18

    Automatically get the time taking day light saving hours into account

  19. 19

    php turning number (hours) to php date and time format

  20. 20

    Only display hours if time is greater than 60 minutes

  21. 21

    Conditional creation of a series from other series

  22. 22

    Time Series Prediction with Keras - Error in Model Values

  23. 23

    Plotly: How to plot time series in Dash Plotly

  24. 24

    Aggregation of time-series data on multiple columns

  25. 25

    issues plotting multivariate time series in R

  26. 26

    Combining time series data into a single data frame

  27. 27

    format a time series as dataframe with julian date

  28. 28

    TIme series data in R, problems with dates

  29. 29

    Pandas - Extracting data from Series

뜨겁다태그

보관