F
F
FLYABRWAY2017-05-24 01:25:25
Mathematics
FLYABRWAY, 2017-05-24 01:25:25

Find a formula for finding the step between values?

Hello. I'm building a chart. We need a formula that, based on the minimum and maximum values, sets the interval (step) between readings. That is, let's say that max=95; min=8; the interval in this case, approximately, should be about ~5. Or max=672; min=35; the interval in this case, approximately, should be ~50. Thank you in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Immortal_pony, 2017-05-24
@Immortal_pony

function calcStep($min, $max, $maxStepsQty=7) {
    return ceil(($max-$min)/$maxStepsQty);
}

X
xmoonlight, 2017-05-24
@xmoonlight

if ($maxValue/25<=25) $d=5; else $d=50;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question