如何为没有数据的单元格添加样式?在文档中,我只找到了 noData 属性,但那是根本没有数据的情况,而不仅仅是单个单元格没有数据。
```
anychart.onDocumentReady(function () {
var data = getData();
var chart = anychart.heatMap(data);
// Set width bound
chart.width('50%');
// Set height bound
chart.height('30%');
chart.title('Set chart width and height');
chart.container('container');
chart.draw();
});
function getData() {
return [
{x: 'Cal', y: '2004', heat: 1704211},
{x: 'Cal', y: '2005', heat: 2782680},
{x: 'Cal', y: '2006', heat: 2992679},
{x: 'Il', y: '2004', heat: 727914},
{x: 'Il', y: '2005', heat: 1150659},
{x: 'Ils', y: '2006', heat: 1134085}, //as of now for "Ils" and years 2004&2005 it would be just empty slot
{x: 'Massachusetts', y: '2004', heat: 238819},
{x: 'Massachusetts', y: '2005', heat: 157719},
{x: 'Massachusetts', y: '2006', heat: 887169},
{x: 'New York', y: '2004', heat: 1667969},
{x: 'New York', y: '2005', heat: 2763503},
{x: 'New York', y: '2006', heat: 3151022},
{x: 'Texas', y: '2004', heat: 219967},
{x: 'Texas', y: '2005', heat: 3732889},
{x: 'Texas', y: '2006', heat: 4185098}
]
}
您可以使用
dataArea
将背景颜色应用于丢失的数据点
anychart.onDocumentReady(function () {
var data = getData();
var chart = anychart.heatMap(data);
// Set width bound
chart.width('50%');
// Set height bound
chart.height('30%');
chart.title('Set chart width and height');
chart.container('container');
//set color for missing datapoints
var dataArea = chart.dataArea();
dataArea.background({fill: '#FFEB3B'});
//
chart.draw();
});
function getData() {
return [
{x: 'Cal', y: '2004', heat: 1704211},
{x: 'Cal', y: '2005', heat: 2782680},
{x: 'Cal', y: '2006', heat: 2992679},
{x: 'Il', y: '2004', heat: 727914},
{x: 'Il', y: '2005', heat: 1150659},
{x: 'Ils', y: '2006', heat: 1134085}, //as of now for "Ils" and years 2004&2005 it would be just empty slot
{x: 'Massachusetts', y: '2004', heat: 238819},
{x: 'Massachusetts', y: '2005', heat: 157719},
{x: 'Massachusetts', y: '2006', heat: 887169},
{x: 'New York', y: '2004', heat: 1667969},
{x: 'New York', y: '2005', heat: 2763503},
{x: 'New York', y: '2006', heat: 3151022},
{x: 'Texas', y: '2004', heat: 219967},
{x: 'Texas', y: '2005', heat: 3732889},
{x: 'Texas', y: '2006', heat: 4185098}
]
}