2016-07-26 145 views
0

美好的一天每个人。我目前正在创建一个Xamarin.Forms便携式应用程序。 我能够使用OxyPlot显示图表。但我想通过设计使它更具有可视性。Xamarin.Forms:更改图表的字体大小和字体颜色

你知道我将如何改变PlotModel标题和每个PieSlice标签的颜色和字体大小。我应该添加什么代码?如果您可以建议我可以在图表中添加更多内容,我们将非常感谢。非常感谢。

这里是我的代码:

public PieViewModel() 
    { 

     modelP1 = new PlotModel { Title = "Pie Sample1"}; 

     dynamic seriesP1 = new PieSeries { StrokeThickness = 2.0, InsideLabelPosition = 0.8, AngleSpan = 360, StartAngle = 0 }; 

     seriesP1.Slices.Add(new PieSlice("Africa", 1030) { IsExploded = false, Fill = OxyColors.PaleVioletRed }); 
     seriesP1.Slices.Add(new PieSlice("Americas", 929) { IsExploded = true }); 
     seriesP1.Slices.Add(new PieSlice("Asia", 4157) { IsExploded = true }); 
     seriesP1.Slices.Add(new PieSlice("Europe", 739) { IsExploded = true }); 
     seriesP1.Slices.Add(new PieSlice("Oceania", 35) { IsExploded = true }); 

     modelP1.Series.Add(seriesP1); 
     this.SalesModel = modelP1; 

    } 

回答

1

据我所知,OxyPlot不支持单PieSlice标签个人风格。但是,您可以共同更改所有文字的字体和文字颜色。

  • TitleColor(OxyColor)
  • TitleFont(字符串)

  • :你需要设置的所有属性可以从PlotModel类中找到LegendTextColor(OxyColor)
  • LegendTitleColor(OxyColor)
  • LegendFont(字符串)
  • LegendTitleFont(字符串)

的字体属性是String类型的,需要你想要的字体家族的名称使用。

环顾PlotModel类,你会发现很多其他的样式选项。

+0

先生,我将如何将此代码添加到我的代码来更改我的标题颜色? this.TitleColor = OxyColors.Automatic; –

+1

如果您未定义标题颜色,则默认为OxyColors.Automatic。当您创建PlotModel类的新实例以查看更改时,请尝试以下操作:'modelP1 = new PlotModel {Title =“Pie Sample1”,TitleColor = OxyColors.Gold};' – hankide

+0

好的,先生。馅饼切片怎么样?我应该在我的程序中添加哪些代码? –