美好的一天。我正在创建一个Xamarin.Forms便携式应用程序,我可以使用OxyPlot在那里显示一个图表。
我的问题是:
1。)每当我尝试在我的图表附近放置一个标签时,无论什么时候,只要我在屏幕上滑动,标签似乎都 MOVABLE 。
2。)我无法删除图表周围的黑色边框。
您认为这背后的原因是什么?非常感谢。
这是我的代码:
using OxyPlot;
using OxyPlot.Annotations;
using OxyPlot.Axes;
using OxyPlot.Series;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace XamarinFormsDemo.ViewModels
{
public class SalesPerProductViewModel : INotifyPropertyChanged
{
private PlotModel modelP1;
SalesVM salesVM = new SalesVM();
public SalesPerProductViewModel()
{
// PieViewModel vm = new PieViewModel();
modelP1 = new PlotModel
{
Title = "Sales Per Product",
TitleColor = OxyColors.Teal,
TitleFontSize = 30,
TextColor = OxyColors.White,
DefaultFont = "Arial Black",
DefaultFontSize = 20
};
TextAnnotation annotation = new TextAnnotation();
annotation.Text = "Total Sales Label: ";
annotation.TextColor = OxyColors.White;
annotation.Stroke = OxyColors.Transparent;
annotation.StrokeThickness = 5;
annotation.FontSize = 20;
annotation.TextPosition = new DataPoint(30, 90);
modelP1.Annotations.Add(annotation);
modelP1.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, IsAxisVisible = false });
modelP1.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, IsAxisVisible = false });
// modelP1.Annotations.Add(annotation);
dynamic seriesP1 = new PieSeries { StrokeThickness = 2.0, InsideLabelPosition = 0.8, AngleSpan = 360, StartAngle = 0 };
// seriesP1.Add(salesVM.SalesModelvm);
seriesP1.Slices.Add(new PieSlice("Keyboard", 5900) { IsExploded = false, Fill = OxyColors.Teal });
seriesP1.Slices.Add(new PieSlice("Monitor", 4430) { IsExploded = true });
seriesP1.Slices.Add(new PieSlice("Flash Drive", 11620) { IsExploded = true });
seriesP1.Slices.Add(new PieSlice("Hard Drive", 7000) { IsExploded = true });
seriesP1.Slices.Add(new PieSlice("RAM", 8000) { IsExploded = true });
modelP1.Series.Add(seriesP1);
this.SalesPerProductModel = modelP1;
}
public PlotModel SalesPerProductModel { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}