Skip to content

Spurious bars created when used with bar chart #5

@ukch

Description

@ukch

I am using the following code to generate a bar chart whose negative values are black:

$(function() {
        var data = [[0, 1], [1, 3], [4, 2], [3, 6], [2, -3], [5, -7], [6, -2],
                    [7, 6]];
        var ticks = [[0, "a"], [1, "c"], [2, "b"], [3, "e"], [4, "d"],
                     [5, "g"], [6, "f"], [7, "h"]];
        var options = {"colors": ["#1f77b4"], "legend": {"show": true},
                       "xaxis": {"tickColor": "#DDDDDD", "ticks": ticks,
                                 "tickLength": 0},
                       "yaxis": {"tickColor": "#DDDDDD"}};

    $.plot($("#placeholder"),
           [{"bars": {"align": "center", "fill": 1, "barWidth": 0.9,
                      "show": true},
             "constraints": [{threshold: 0, color: "#000000",
                              evaluate: function(y, threshold) {
                                return y <= threshold}}],
             "data": data}],
            options);
});

The end result has 2 strange bars added, of size 0, as seen here:
Screenshot #1

If we change the threshold to 2, this becomed much more apparent:
Screenshot #2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions