如何给分产生热图热图

由网友(酒涩)分享简介:我要生成的窗口形式的热图。我有一个设定点作为输入。如何去最简单的方式这样做呢?谢谢你。I want to generate a heat map in windows form. I have a set of points as the input. How to go about doing this in t...

我要生成的窗口形式的热图。我有一个设定点作为输入。如何去最简单的方式这样做呢? 谢谢你。

I want to generate a heat map in windows form. I have a set of points as the input. How to go about doing this in the simplest way? Thanks.

推荐答案

下面是将生成基于最小和最大之间的值的相对位置的颜色的简单方法。值越接近分钟将更加绿色,而值越接近最大值会更红。 要使用此方法,生成值列表,计算最小值和最大值。如果你正在建设一个网格,可以处理RowDataBound事件或类似的东西,并从那里调用热图的方法。获取引用的单元格,设置背景颜色由热图方法返回的颜色。

Here is a simple method that will generate a color based on the relative position of a value between min and max. Values closer to min will be greener, while values closer to max will be redder. To use this method, generate your list of values and calculate the min and max values. If you are building a grid you can handle the RowDataBound event or something similar and call the HeatMap method from there. Get a reference to the cell and set the background color to the color returned by the HeatMap method.

public Color HeatMap(decimal value, decimal min, decimal max)
{
   decimal val = (value - min) / (max-min);
   return new Color
   {
       A = 255,
       R = Convert.ToByte(255 * val),
       G = Convert.ToByte(255 * (1-val)),
       B = 0
   };
}
阅读全文

相关推荐

最新文章