MemLeak
MemLeak

Reputation: 4640

How to set an fillArea offset in HighCharts

I try to set an reference value for a area-plot in higcharts. this should be similar to this example but with 100 as baseline. Because its hard to describe i attach a picture. I'm really lost on this topic, thanks for any help/hint in advance.

image to describe the problem

Upvotes: 2

Views: 152

Answers (2)

MemLeak
MemLeak

Reputation: 4640

threshold was what im looking for. add it to the series, see jsfiddle

series: [{
    name: 'John',
    data: [105, 103, 104, 107, 102],
    threshold : 100
} ....

Upvotes: 2

Charles Clayton
Charles Clayton

Reputation: 17976

I don't think you can set the baseline to actually be anything other than 0, but what you can do is modify the axis such that it displays the actual value we're graphing offset by 100. Then for your data, you can offset it by the same amount in the opposite direction.

yAxis: {           
    labels: {
         formatter: function () {
             return [this.value + 100];
         }
    }
},
series: [{
        name: 'John',
        data: [105, 103, 104, 107, 102].offset(-100)
    }, {
        name: 'Jane',
        data: [102, 98, 97, 102, 101].offset(-100)
    }, {
        name: 'Joe',
        data: [103, 104, 104, 98, 105].offset(-100)
    }
]

Where

Array.prototype.offset = function (ofs) {
    var a = [];
    this.forEach(function (d) {
        a.push(d + ofs);
    });
    return a;
};

Doing that I created the graph you were hoping for:

enter image description here

JSFiddle

Upvotes: 2

Related Questions