gpt4 book ai didi

javascript - 根据平均值或极限值设置highchart柱的颜色

转载 作者:行者123 更新时间:2023-11-28 06:51:27 24 4
gpt4 key购买 nike

我想根据平均值或极限值设置 highchart 列的颜色。我写了这个脚本;但问题是,当我将鼠标移到红色柱上时,它又恢复为蓝色!有人可以告诉我在我的代码中添加什么以使其保持红色?谢谢

<script>
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'donuts1',
type: 'column',
zoomType: 'xy'
},
title: {
text: 'Les données d\'expression du transcrit : <?php echo $id; ?>'
},
subtitle: {
text: document.ontouchstart === undefined ?
'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
},
xAxis: {
categories: ["<?php echo join($tableauLogin, '","') ?>"] ,
labels: {
rotation: -45,
style: {
fontSize: '11px',
fontFamily: 'Verdana, sans-serif'
}
},
},
yAxis: {
title: {
text: 'Log2(Expression)'
},
minorTickInterval: 1,
min: <?php echo $min-1;?>,
max: <?php echo $max+1;?>,
plotLines: [{
color: '#FF0000',
width: 2,
value: <?php echo $mean ;?> ,// Need to set this probably as a var.
dashStyle: 'ShortDash',
label: {
text: '<?php echo $leg ;?> : <?php echo round($mean,2) ;?>',
align: 'right',
verticalAlign: 'top',
y: -100,
x: -10,
style: {
color: '#FF0000'
}}
}]
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 50,
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true
},
series: [{
name: '<?php echo $name ?>',
data: [<?php echo join($tableauNote, ',') ?>]
}]
},function(chart){

var max = <?php echo $mean ;?>;

$.each(chart.series[0].data,function(i,data){

if(data.y > max)
data.graphic.attr({
fill:'#FE2E2E'
});

});

});
});
$('#preview').html(chart.getCSV());
</script>

最佳答案

我终于自己找到了解决方案

我重新设置了这一行:

data.graphic.attr({ fill:'#FE2E2E'

就这个

data.graphic.css({ color:'#FE2E2E'

关于javascript - 根据平均值或极限值设置highchart柱的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32925332/

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