gpt4 book ai didi

javascript - Highcharts 中箱形图中标记的条件着色

转载 作者:行者123 更新时间:2023-11-29 16:49:07 24 4
gpt4 key购买 nike

以下是箱形图的 javascript,可以在此 fiddle 中查看.

$(function () {
$('#container').highcharts({

chart: {
type: 'boxplot'
},

title: {
text: 'Highcharts Box Plot Example'
},

legend: {
enabled: false
},

xAxis: {
categories: ['1', '2', '3', '4', '5'],
title: {
text: 'Experiment No.'
}
},

yAxis: {
title: {
text: 'Observations'
},
plotLines: [{
value: 932,
color: 'red',
width: 1,
label: {
text: 'Theoretical mean: 932',
align: 'center',
style: {
color: 'gray'
}
}
}]
},

series: [{
name: 'Observations',
data: [
[760, 801, 848, 895, 965],
[733, 853, 939, 980, 1080],
[714, 762, 817, 870, 918],
[724, 802, 806, 871, 950],
[834, 836, 864, 882, 910]
],
tooltip: {
headerFormat: '<em>Experiment No {point.key}</em><br/>'
}
}, {
name: 'Outlier',
color: 'black',
type: 'scatter',
data: [ // x, y positions where 0 is the first category
[0, 644],
[4, 718],
[4, 951],
[4, 969]
],
marker: {
fillColor: 'red'
},
tooltip: {
pointFormat: 'Observation: {point.y}'
}
}]
});
});

我的意图是根据圆点所在的位置更改圆点的颜色。例如:如果离群值大于 700,我希望它是橙色的。通常,这可以使用格式化程序选项来完成,该选项可用于某些 Highcharts 格式的标签。我有办法做到这一点吗?

最佳答案

您可以在 Highcharts 中使用之前检查您的数据,如果满足要求,可以为每个点添加颜色值。示例:http://jsfiddle.net/nshkf75s/

相关部分代码:

    series: [{
name: 'Observations',
data: [
[760, 801, 848, 895, 965],
[733, 853, 939, 980, 1080, 'orange'],
[714, 762, 817, 870, 918],
[724, 802, 806, 871, 950],
[834, 836, 864, 882, 910]
],
keys: ['low','q1','median','q3','high','color'],
...

关于javascript - Highcharts 中箱形图中标记的条件着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37900098/

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