【问题标题】:Oxyplot annotation with brush带画笔的 Oxyplot 注释
【发布时间】:2016-01-20 19:30:44
【问题描述】:

我希望给我的OxyPlotRectangleAnnotation 上色,而不仅仅是纯色,即某种类型的brushGradientBrush 等)。我在 WPF 中工作。

他们的 GitHub 网站上的这个问题 (PlotAreaBackground can be defined using gradient ?) 建议可以为注释提供渐变,但我找不到建议的示例。

有没有办法在RectangleAnnotation 上使用画笔?或任何其他在图表上创建与轴上的值相关联的彩色区域的方法?

【问题讨论】:

标签: c# wpf xaml oxyplot


【解决方案1】:

我认为这是suggested example

我已将其修改为看起来像一个矩形注释,因为该示例填充了整个背景。希望对您有所帮助。

效果:

代码:

// create a gradient image of height n
int n = 256;
var imageData1 = new OxyColor[n, 1];
for (int i = 0; i < n; i++)
{
    imageData1[i, 0] = OxyColor.Interpolate(OxyColors.Red, OxyColors.Blue, i / (n - 1.0));
}

PngBitmapEncoder encoder = new PngBitmapEncoder();
PngEncoder encode = new PngEncoder(new PngEncoderOptions());
var image1 = new OxyImage(encode.Encode(imageData1));

ImageAnnotation anotation = new ImageAnnotation
{
    ImageSource = image1,
    Interpolate = true,
    Layer = AnnotationLayer.BelowAxes,
    X = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
    Y = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
    Width = new PlotLength(0.1, PlotLengthUnit.RelativeToPlotArea),
    Height = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
    HorizontalAlignment = HorizontalAlignment.Left,
    VerticalAlignment = VerticalAlignment.Top
};
plotModel.Annotations.Add(anotation);

【讨论】:

    猜你喜欢
    • 2018-09-07
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 2013-12-25
    • 1970-01-01
    • 2021-10-25
    • 1970-01-01
    • 2021-10-03
    相关资源
    最近更新 更多