Fleet ignoring null values ​​at end of data

I use Flot to plot the chart, and the null elements at the end of the data collection are ignored.

My code is below:

var d1 = []; for (var i = 0; i <= 3; i += 1) d1.push([i, parseInt(Math.random() * 30)]); for (var i = 4; i <= 10; i += 1) d1.push([i, null]); function plotWithOptions() { $.plot($("#placeholder"), [d1], { series: { bars: { show: true } } }); } plotWithOptions();</code> 

Using Flot 0.8.1, this gives the following:

0HNtlZV.png

JSFiddle 0.8.1

Interestingly, using an older version of Flot (0.7), this creates the type of chart that I would expect, with the null elements displayed as spaces:

ojYVjE0.png

JSFiddle 0.7

In 0.8.1, if I add a non-zero element at the end, null entries are displayed as a space, but this is different from 0.7 where they are displayed independently (and what behavior I am trying to achieve).

Is there a setting or something I need to change to achieve this?

+4
source share
2 answers

Change line 1134 as follows:

 if (f.autoscale) { 

For this:

 if (f.autoscale !== false) { 

I will pull out the development fix as soon as I finish testing to make sure it doesn't break anything.

+3
source

This is probably a mistake. I suggest you post the problem on the github page.

If you need to get around this, you can make a second series, which is not shown, and fill in the values ​​with 0 instead of null:

 for (var i = 0; i <= 3; i += 1) { d1.push([i, parseInt(Math.random() * 30)]); d2.push([i, 0]); } for (var i = 4; i <= 10; i += 1) { d1.push([i, null]); d2.push([i, 0]); } 

And then when you call $.plot , use options showing the columns for d1 , but nothing for d2 :

 $.plot($("#placeholder"), [{ data: d1 }, { bars: { show: false }, lines: { show: false }, data: d2 }], { series: { bars: { show: true } } }); 

A working example from your code: http://jsfiddle.net/ryleyb/YWPqS/2/

+3
source

Source: https://habr.com/ru/post/1492959/


All Articles