gpt4 book ai didi

highcharts - AreaSpline Graph 中的负填充颜色

转载 作者:行者123 更新时间:2023-12-03 21:20:22 25 4
gpt4 key购买 nike

我想在面积样条图中填充样条上方的区域颜色。
我试图设置负填充颜色但没有结果。
谁能告诉我如何在样条曲线上方而不是下方填充区域颜色?
任何帮助将不胜感激。

$(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'
}]
});
})

;

谢谢,

最佳答案

好吧,阈值应该有效。只需要设置

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

  • 见: http://jsfiddle.net/3bQne/1076/

    代码:
    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)'
    }]
    });

    关于highcharts - AreaSpline Graph 中的负填充颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23081146/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com