Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small 10-point data breaks uplot #200

Closed
danyalejandro opened this issue May 6, 2020 · 7 comments
Closed

Small 10-point data breaks uplot #200

danyalejandro opened this issue May 6, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@danyalejandro
Copy link

https://jsbin.com/vuxizorupu/edit?html,js,console,output

Try zooming into an area with 6 samples or less, breaking in my Chrome.

Note that this error didn't happen in a previous version (not sure which one exactly)

@leeoniya
Copy link
Owner

leeoniya commented May 6, 2020

i can't reproduce this :(

everything works okay for me when zooming down to 1 point, or even 0 points.

@danyalejandro
Copy link
Author

Maybe some kind of cache error? It works for me now as well.

Try this one please:
https://jsbin.com/serocequha/edit?html,js,console,output
This one has a formatting option that I think is triggering the bug

@leeoniya
Copy link
Owner

leeoniya commented May 6, 2020

This one has a formatting option

where? the code looks identical to the first jsbin.

@danyalejandro
Copy link
Author

My fault, didn't save the right snapshot. This one should work:

https://jsbin.com/vuxizorupu/edit?html,js,console,output

@leeoniya
Copy link
Owner

leeoniya commented May 6, 2020

ok, this was not a regression.

the minimal repro is this:

const data = [
  [
    1576713600.736,
    1576713601.727,
    1576713602.726,
    1576713603.727,
    1576713604.73,
    1576713605.73,
    1576713606.73,
    1576713607.73,
    1576713608.732,
    1576713609.731
  ],
  [
    3.38625,
    3.3866,
    3.38684,
    3.38697,
    3.38716,
    3.38741,
    3.38771,
    3.38744,
    3.38675,
    3.38649
  ]
];

const opts = {
  width: 400,
  height: 300,
  series: [{},{}],
};

let u = new uPlot(opts, data, document.body);

the cause of this was that uPlot found only 1 tick for the given data, plot width (400px) and the default combo of axis.space (50px) and axis.incrs (1,5,10,15,30...).

to reduce some redundancy in arguments, axis.values() relied on inferring the foundIncr from the difference between the first 2 ticks, which failed when only 1 tick was provided. the foundIncr is now passed explicitly to axis.values().

should be fixed.

@leeoniya
Copy link
Owner

leeoniya commented May 6, 2020

the value formatting config you provided only goes down to 1s, so it will still error out if you try to zoom in too much since it lacks sub-second rules. but i assume that you'll avoid this by limiting zoom-in (#187) or something.

@leeoniya leeoniya added the bug Something isn't working label May 6, 2020
@leeoniya
Copy link
Owner

leeoniya commented May 6, 2020

actually, rather than limiting zoom-in, you should just limit the max split resolution by restricting the bottom end of incrs so the axis cannot be split finer than the smallest available formatter:

axes: [
  {
    incrs: [
      1,
      5,
      10,
      15,
      30,
  //  ...
    ],
    values: [
      [3600 * 24 * 365,    "{YYYY}",            7,   "{YYYY}"                   ],
      [3600 * 24 * 28,     "{MMM}",             7,   "{MMM}\n{YYYY}"            ],
      [3600 * 24,          "{MMM}/{D}",         7,   "{MMM}/{D}\n{YYYY}"        ],
      [3600,               "{HH}:{mm}",         4,   "{HH}:{mm}\n{MMM}/{D}"     ],
      [60,                 "{HH}:{mm}",         4,   "{HH}:{mm}\n{MMM}/{D}"     ],
      [1,                  "{HH}:{mm}:{ss}",    4,   "{HH}:{mm}:{ss}\n{MMM}/{D}"]
    ]
  },
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants