0
私はプロットして簡単なヒートマップを作成しました。以下のコードです:プロットを使用した動的ヒートマップ
入力データ
var zValues = [
[0.10, 0.30, 0.15, 0.25, 0.40],
[0.20, 0.00, 0.75, 0.75, 0.00],
[0.75, 0.75, 0.15, 0.65, 0.20],
[0.50, 0.40, 0.00, 0.05, 0.10]
];
var data = [{
x: xValues,
y: yValues,
z: zValues,
type: 'heatmap',
colorscale: colorscaleValue,
showscale: true
}];
var layout = {
title: 'Annotated Heatmap',
annotations: [],
xaxis: {
ticks: '',
side: 'bottom'
},
yaxis: {
ticks: '',
ticksuffix: ' ',
width: 700,
height: 700,
autosize: false
}
};
for (var i = 0; i < yValues.length; i++) {
for (var j = 0; j < xValues.length; j++) {
var currentValue = zValues[i][j];
if (currentValue != 0.0) {
var textColor = 'white';
}else{
var textColor = 'black';
}
var result = {
xref: 'x1',
yref: 'y1',
x: xValues[j],
y: yValues[i],
text: zValues[i][j],
font: {
family: 'Arial',
size: 12,
color: 'rgb(50, 171, 96)'
},
showarrow: false,
font: {
color: textColor
}
};
layout.annotations.push(result);
}
}
Plotly.newPlot('myDiv', data, layout);
今私は定期的に後のデータ(zValues)を更新したい(またはデータを改造)ヒートマップの色が上のベース変更に維持する必要がありますように新しいデータ値
どうすればよいですか?
おかげで多くを使用することができます。出来た – fateh