/ / Anotação Oxyplot com pincel - c #, wpf, xaml, oxyplot

Anotação de Oxyplot com pincel - c #, wpf, xaml, oxyplot

Eu desejo colorir meu OxyPlot"s RectangleAnnotation com algo mais bonito do que apenas uma cor simples, ou seja, algum tipo de brush (GradientBrush etc). Eu estou trabalhando no WPF.

Essa questão (PlotAreaBackground pode ser definido usando gradiente?) em seu site GitHub sugere que uma anotação pode receber um gradiente, mas não consigo encontrar o exemplo sugerido.

Existe uma maneira de aplicar um pincel a um RectangleAnnotation? ou qualquer outra forma de criar áreas coloridas em um gráfico que estão ligadas aos valores no eixo?

Respostas:

2 para resposta № 1

Eu acho que esse é o exemplo sugerido.

Eu o modifiquei para parecer uma anotação retangular, porque o exemplo preenche todo o plano de fundo. Espero que ajude.

Efeito:

insira a descrição da imagem aqui

Código:

// 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);