简体   繁体   English

如何在 ngx-charts-heat-map 上反转颜色

[英]How do I invert colours on ngx-charts-heat-map

I'm using ngx-charts-heat-map to create a heat map. This is all going well enough, the map works, however, one small detail I can't figure out.我正在使用ngx-charts-heat-map创建一个热图 map。这一切都很顺利,map 有效,但是,有一个小细节我无法弄清楚。
At the moment the higher the value of a cell, the more red it gets, and the lower the value, the less red it gets.此时一个单元格的值越高,它越红,值越低,它越红。
In my context however, a large number is good, a small number is bad, so I'd like the colours to be inverted, and I'm not sure how to do that here.然而,在我的上下文中,大数字是好的,小数字是坏的,所以我想要反转颜色,但我不确定如何在这里做到这一点。 Essentially, I want the user to be drawn to the things with low values, not high values.本质上,我希望用户被低价值而非高价值的事物所吸引。
Is there a setting I'm missing?有没有我缺少的设置?

Yes, color scheme.是的,配色方案。

scheme is an object containing the color scheme of the chart. scheme是一个 object 包含图表的配色方案。 You can use it with predefined colors like so:您可以像这样将它与预定义的 colors 一起使用:

<ngx-charts-heat-map
  [view]="view"
  scheme="neons"
  ...

Predefined list of named colormaps can be checked out here .可以在此处查看命名颜色图的预定义列表。

Or define your custom object like so:或者像这样定义您的自定义 object:

(in template) (在模板中)

<ngx-charts-heat-map
  [view]="view"
  [scheme]="colorScheme"
  ...

(in component) (在组件中)

colorScheme = {
  domain: ['#5AA454', '#E44D25', '#CFC0BB', '#7aa3e5', '#a8385d', '#aae3f5']
};

Taken straight from the official demo .直接取自官方演示

Adopt the color scheme to your needs.根据您的需要采用配色方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM