Negative fill color in AreaSpline chart

I want to fill in the color of the area above the spline in the area of ​​the spline diagram. I tried to set a negative fill color, but no result. Can someone let me know how to fill the color of the area above the spline, and not below? Any help would be appreciated.

$(function () {
        $('#container').highcharts({
            chart: {
                type: 'areaspline'
            },
            title: {
                text: 'Average fruit consumption during one week'
            },
            legend: {
                layout: 'vertical',
                align: 'left',
                verticalAlign: 'top',
                x: 150,
                y: 100,
                floating: true,
                borderWidth: 1,
                backgroundColor: '#FFFFFF'
            },
            xAxis: {
                categories: [
                    'Monday',
                    'Tuesday',
                    'Wednesday',
                    'Thursday',
                    'Friday',
                    'Saturday',
                    'Sunday'
                ],
                plotBands: [{ // visualize the weekend
                    from: 4.5,
                    to: 6.5,
                    color: 'rgba(68, 170, 213, .2)',
                }]
            },
            yAxis: {
                title: {
                    text: 'Fruit units'
                }
            },
            tooltip: {
                shared: true,
                valueSuffix: ' units'
            },
            credits: {
                enabled: false
            },
            plotOptions: {
                areaspline: {
                    fillOpacity: 0.5
                }
            },
            series: [{
                name: 'John',
                data: [3, 4, 3, 5, 4, 10, 12],
                negativeFillColor: '#000000'
            }, {
                name: 'Jane',
                data: [1, 3, 4, 3, 3, 5, 4],
                negativeFillColor: '#000000'
            }]
        });
    })

;

Thank you, m

+4
source share
1 answer

Well, the threshold should work. You just need to install

  • endOnTick: false
  • maxPadding: 0
  • threshold: max_value_in_data

See: http://jsfiddle.net/3bQne/1076/

the code:

var data = [3, 4, 3, 5, 4, 10, 12];

Array.prototype.max = function() {
    return Math.max.apply(null, this);
}

$('#container').highcharts({
    chart: {
        type: 'areaspline'
    },
    yAxis: {
        endOnTick: false,
        maxPadding: 0
    },
    plotOptions: {
        areaspline: {
            threshold: data.max(),
        }
    },
    series: [{
        data: data,
        negativeFillColor: 'rgba(255, 0, 0, 0.5)'
    }]
});
+1
source

Source: https://habr.com/ru/post/1536576/


All Articles