Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

dygraph floating points for x-axis values

I'm not able to make dygraph plotting a graph with my data. The data consists of ~16,000 sets, but it doesn't work with just a couple of points either.

Example of data:

WL;Part1;Part2
187,3284416;-1748,493056;-1840,460648
187,3555635;-1884,175926;-1940,453704
187,382693;-1998,740741;-2017,085648
187,40983;-2143,993056;-2090,243056
187,4369744;-1977,905093;-1956,724537
187,4641264;-2019,69213;-1901,358796

My code so far:

  g = new Dygraph(
    document.getElementById("graphdiv"),
    "data.csv", 
    {delimiter:';',
     xValueParser: parseFloat}
  );

If I change the data points of the X-axis as follows, I get a nice graph:

WL;Part1;Part2
187,3284416;-1748,493056;-1840,460648
188,3555635;-1884,175926;-1940,453704
189,382693;-1998,740741;-2017,085648
190,40983;-2143,993056;-2090,243056
191,4369744;-1977,905093;-1956,724537
192,4641264;-2019,69213;-1901,358796

Unfortunately, this doesn't help me because the points have to be like in the first example. What is wrong here?

question from:https://stackoverflow.com/questions/65941671/dygraph-floating-points-for-x-axis-values

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It will work if you use points instead of commas for your decimals:

WL;Part1;Part2
187.3284416;-1748.493056;-1840.460648
187.3555635;-1884.175926;-1940.453704
187.382693;-1998.740741;-2017.085648
187.40983;-2143.993056;-2090.243056
187.4369744;-1977.905093;-1956.724537
187.4641264;-2019.69213;-1901.358796

Graph with decimal points on X axis

You'll see that the X axis labels have gone a bit crazy, but you can use the axisLabelFormatter options to get that under control - or maybe it will be fine once you've put in your whole dataset.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...