antvis/G2

请问怎么设置色块图的默认背景色 #3455

quicklearning123 posted onGitHub

  • I have searched the issues of this repository and believe that this is not a duplicate.

https://g2.antv.vision/zh/examples/heatmap/basic#basic

Steps to reproduce

必现。希望数据不正常时显示指定的颜色。 image

Environment Info
g2 4.1.17
System -
Browser -

<!-- generated by antv-issue-helper. DO NOT REMOVE -->


没有数据,就不渲染,目前是空(透明)。如果要做默认逻辑,那么可以在 color 中进行回调,对于空数据设置对应自己的默认颜色。

posted by hustcc almost 4 years ago

目前可以用两个 view 解决。

const v0 = chart.createView();
v0.data(source);
v0
  .polygon()
  .position('name*day')
  .color('sales', '#BAE7FF-#1890FF-#0050B3')
  .label('sales', {
    offset: -2,
    style: {
      fill: '#fff',
      shadowBlur: 2,
      shadowColor: 'rgba(0, 0, 0, .45)',
    },
  })
  .style({
    lineWidth: 1,
    stroke: '#fff',
  });

// 空数据绘制在另一个 view
const v1 = chart.createView();

v1.data([{
    name: 0,
    day: 1,
    sales: 0,
}]);

v1
  .polygon()
  .position('name*day')
  .color('sales', 'red')
  .style({
    lineWidth: 1,
    stroke: '#fff',
  });

image

posted by pearmini over 3 years ago

Fund this Issue

$0.00
Funded

Pull requests