Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task
quicklearning123 opened this issue Jun 3, 2021 · 2 comments
Closed
1 task

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

quicklearning123 opened this issue Jun 3, 2021 · 2 comments

Comments

@quicklearning123
Copy link

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

Reproduction link

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

Steps to reproduce

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

Environment Info
g2 4.1.17
System -
Browser -
@hustcc
Copy link
Member

hustcc commented Jun 9, 2021

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

@pearmini
Copy link
Member

目前可以用两个 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants