gpt4 book ai didi

c# - OxyPlot 热图矩形注释

转载 作者:行者123 更新时间:2023-11-30 21:35:04 26 4
gpt4 key购买 nike

最近我一直在使用 OxyPlot 库制作一些图表。我想知道我是否可以为每个矩形制作一个带有注释的热图。期待答案。

最佳答案

This is how it looks我终于发现我需要创建一个新类并扩展热图系列并覆盖 RenderLabels 方法以更改其功能。

protected override void RenderLabels(IRenderContext rc, OxyRect rect)
{
var clip = this.GetClippingRect();
int m = this.Data.GetLength(0);
int n = this.Data.GetLength(1);
double fontSize = (rect.Height / n) * this.LabelFontSize;

double left = this.X0;
double right = this.X1;
double bottom = this.Y0;
double top = this.Y1;

var s00 = this.Orientate(this.Transform(left, bottom)); // disorientate
var s11 = this.Orientate(this.Transform(right, top)); // disorientate

double sdx = (s11.X - s00.X) / (m - 1);
double sdy = (s11.Y - s00.Y) / (n - 1);

for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
var point = this.Orientate(new ScreenPoint(s00.X + (i * sdx), s00.Y + (j * sdy))); // re-orientate
var v = GetValue(this.Data, i, j);
var color = this.ColorAxis.GetColor(v);
var hsv = color.ToHsv();
var textColor = hsv[2] > 0.6 ? OxyColors.Black : OxyColors.White;
var label = this.Labels[i, j];
rc.DrawClippedText(
clip,
point,
label,
textColor,
this.ActualFont,
fontSize,
500,
0,
HorizontalAlignment.Center,
VerticalAlignment.Middle);
}
}
}

关于c# - OxyPlot 热图矩形注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49536306/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com