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

Support for minPointLength in x-range study #5221

Closed
TR4Android opened this Issue Apr 16, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@TR4Android

TR4Android commented Apr 16, 2016

Expected behaviour

The x-range study should take into account the minPointLength specified in the plotOptions while making sure that the adjusted values still don't get cut off at the chart extremes.

Actual behaviour

Currently the x-range study doesn't support the minPointLength at all. After adding minimal support for minPointLength the values are partially drawn outside the bounds of the chart (see jsfiddle below).

Live demo of the issue

  • Default x-range study: note how the value of zero (the last value in the series data) isn't presented in the chart (should be at the top left).
  • X-range study with added minPointLength support: note how the value of zero is drawn in the chart, but being cut off. I haven't found a way around this and was hoping that someone could help out.

Steps to reproduce the behaviour

The only change made in the second jsfiddle (compared to th first) is the translate function, which was adjusted to take into account the minPointLength:

translate: function () {
    columnType.prototype.translate.apply(this, arguments);
    var series = this,
        xAxis = series.xAxis,
        metrics = series.columnMetrics,
        minPointLength = series.options.minPointLength;

    H.each(series.points, function (point) {
        var barWidth = xAxis.translate(H.pick(point.x2, point.x + (point.len || 0))) - point.plotX;
        var barWidthDifference = 0;
        if (barWidth < minPointLength) {
            barWidthDifference = (minPointLength - barWidth);
        }
        point.shapeArgs = {
            x: point.plotX - barWidthDifference / 2,
            y: point.plotY + metrics.offset,
            width: barWidth + barWidthDifference,
            height: metrics.width
        };
        point.tooltipPos[0] += barWidth / 2;
        point.tooltipPos[1] -= metrics.width / 2;
    });
}

Affected browser(s)

All, as far as I can tell, but tested on Firefox 45.0.2 and Windows 10

Thanks for the great charting library 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment