2017-08-01 170 views
2

我有以下AreaSeries图表使用OxyPlotXamarin Forms。它有三个系列。添加MarkerStroke颜色在Smooth正确时添加粗线条

  1. 光滑= TRUE,MarkerStroke =默认情况下,如预期结果
  2. 光滑= TRUE,MarkerStroke =黄色粗线显示了该行预期
  3. 光滑=假,MarkerStroke =黄色,结果

因此,当我使用Smooth = true并为MarkerStroke定义颜色时,它会添加不需要的粗线。如何解决/解决它?

注意:在线系列,它按预期工作。问题只在区域系列上。

enter image description here

情节模式

public class MyOxyPlotModelData 
{ 
     public PlotModel AreaModel { get; set; } 

     public MyOxyPlotModelData() 
     { 
      AreaModel = CreateAreaChart(); 

     } 

     public PlotModel CreateAreaChart() 
     { 
      PlotModel plotModel1 = new PlotModel { Title = "Area" }; 
      var valueAxisX = new LinearAxis 
      { 
       Position = AxisPosition.Bottom, 
       AxislineColor = OxyColors.White, 
       TicklineColor = OxyColors.White, 
       TextColor = OxyColors.White, 
       FontSize = 12, 
       IsZoomEnabled = false, 
       IsPanEnabled = false 
      }; 

      var valueAxisY = new LinearAxis 
      { 
       Position = AxisPosition.Left, 
       //Maximum = 15, 
       //Minimum = 0, 
       AxislineColor = OxyColors.White, 
       TicklineColor = OxyColors.White, 
       TextColor = OxyColors.White, 
       FontSize = 12, 
       IsZoomEnabled = false, 
       IsPanEnabled = false 
      }; 

      plotModel1.Axes.Add(valueAxisX); 
      plotModel1.Axes.Add(valueAxisY); 

      plotModel1.DefaultColors = new List<OxyColor> 
      { 
       OxyColors.Purple, 
       OxyColors.DeepPink, 
       OxyColors.Teal 
       //OxyColor.FromRgb(0x20, 0x4A, 0x87) 
      }; 

      AreaSeries areaSeries1 = new AreaSeries 
      { 
       MarkerType = MarkerType.Circle, 
       MarkerSize = 2, 
       //MarkerStroke = OxyColors.White, 
       StrokeThickness = 1, 
       Smooth = true 
      }; 
      areaSeries1.Points.Add(new DataPoint(0, 50)); 
      areaSeries1.Points.Add(new DataPoint(10, 140)); 
      areaSeries1.Points.Add(new DataPoint(20, 80)); 


      AreaSeries areaSeries2 = new AreaSeries 
      { 
       MarkerType = MarkerType.Circle, 
       MarkerSize = 2, 
       MarkerStroke = OxyColors.Yellow, 
       StrokeThickness = 1, 
       Smooth = true 
      }; 
      areaSeries2.Points.Add(new DataPoint(0, 30)); 
      areaSeries2.Points.Add(new DataPoint(15, 150)); 
      areaSeries2.Points.Add(new DataPoint(20, 20)); 


      AreaSeries areaSeries3 = new AreaSeries 
      { 
       MarkerType = MarkerType.Circle, 
       MarkerSize = 2, 
       MarkerStroke = OxyColors.Yellow, 
       StrokeThickness = 1, 
       Smooth = false 
      }; 
      areaSeries3.Points.Add(new DataPoint(0, 40)); 
      areaSeries3.Points.Add(new DataPoint(15, 110)); 
      areaSeries3.Points.Add(new DataPoint(20, 55)); 

      plotModel1.Series.Add(areaSeries1); 
      plotModel1.Series.Add(areaSeries2); 
      plotModel1.Series.Add(areaSeries3); 


      return plotModel1; 

     } 
} 

应用。 XAML.cs

public App() 
    { 
     InitializeComponent(); 
     var vSampleData = new MyOxyPlotModelData(); 

     MainPage = new OxyPlotNewSeries.MainPage { BindingContext = vSampleData }; 

    } 

MainPage.xaml中你有

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:local="clr-namespace:OxyPlotNewSeries" 
      xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms" 
      x:Class="OxyPlotNewSeries.MainPage"> 

    <AbsoluteLayout> 

     <oxy:PlotView Model="{Binding AreaModel}" BackgroundColor="#000000" 
        AbsoluteLayout.LayoutBounds="10,30,.9,.9" 
        AbsoluteLayout.LayoutFlags="WidthProportional,HeightProportional" /> 
    </AbsoluteLayout> 

</ContentPage> 
+1

平滑产生很多中间点。当你定义一个标记时,它会在所有这些点上绘制一个标记。粗线只是标记靠在一起。你通过不添加标记来解决它。 –

+0

就像@PalleDue指出的那样,如果你不需要它,就不要使用它。虽然如果厚度是你的不喜欢,我没有看到MarkerStrokeThickness属性设置在任何地方? –

+0

@PalleDue为什么它在系列系列中工作正常,而不是在系列系列中?请参阅问题 – Lijo

回答

1

一种选择是使用TwoColorAreaSeries代替,因为你描述不会发生这一系列类型的问题。

enter image description here

TwoColorAreaSeries areaSeries2 = new TwoColorAreaSeries 
{ 
    MarkerType = MarkerType.Circle, 
    MarkerSize = 5, 
    MarkerStroke = OxyColors.Yellow, 
    MarkerStrokeThickness = 5, 
    StrokeThickness = 1, 
    Smooth = true 
}; 
areaSeries2.Points.Add(new DataPoint(0, 30)); 
areaSeries2.Points.Add(new DataPoint(15, 140)); 
areaSeries2.Points.Add(new DataPoint(20, 20)); 

编辑:它是一个错误吗?这可能是......虽然通过自己的例子来看,似乎它的意思是这个样子绘制这样的事情:

enter image description here

这:

enter image description here

+0

那么,它在AreaSeries中是一个错误吗? – Lijo

+0

请参阅我的**编辑**。 – jsanalytics