krzysu / flot.tooltip

tooltip plugin for wonderful Flot plotting library
https://github.com/krzysu/flot.tooltip
187 stars 153 forks source link

Wrong values for y axis are showed for stepped line chart with fill option on #133

Open jsscks opened 8 years ago

jsscks commented 8 years ago

Here is jquey.flot.js:

            if (!format) {
                format = [];
                // find out how to copy
                format.push({ x: true, number: true, required: true });
                format.push({ y: true, number: true, required: true });

                  if (s.bars.show || (s.lines.show && s.lines.fill)) {
                    ...
                   format.push({ y true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
                    ...
            s.datapoints.pointsize = format.length;

Bars and lines with filling will have 3 points shift in datapoints.

Here is jquery.flot.tooltip.js:

    if (typeof item.series.lines !== "undefined" && item.series.lines.steps) {
        x = item.series.datapoints.points[item.dataIndex * 2];
        y = item.series.datapoints.points[item.dataIndex * 2 + 1];
        // TODO: where to find custom text in this variant?
        customText = "";
    }

Shift by 2 is forced. You should multiply on item.series.datapoints.pointsize instead of 2.

SLOPapa commented 8 years ago

Awesome! Thanks @jsscks - couldn't figure out what was going on until I saw this.

SoundBlaster commented 8 years ago

I have this issue too. Cause of it is datapoints.pointsize, when it equals 3 than plugin incorrectly calc index for y value (390 & 391 lines on full script version)

SoundBlaster commented 8 years ago
390: var pointSize = item.series.datapoints.pointsize;
391: var idx = item.dataIndex * pointSize;
392: x = item.series.datapoints.points[idx];
393: y = item.series.datapoints.points[idx + 1];