2014-11-26 3 views
1

우리는 양수 값과 음수 값을 가진 간단한 ColumnChart를 가지고 있습니다.OxyPlot Zero Line

0 행에는 있지만 차트에는 선이 없습니다. 어떻게 우리는 제로 라인을 가로 질러 사용할 수 있습니까?

는 IOS에 그것을 테스트하지 않은 이미지

enter image description here

답변

-1

이 한 번 봐 안드로이드에 나를 위해 작동 첨부 참조 :

public static PlotModel Withnegativevalues() 
{ 
    var plotModel1 = new PlotModel(); 
    plotModel1.LegendBorderThickness = 0; 
    plotModel1.LegendOrientation = LegendOrientation.Horizontal; 
    plotModel1.LegendPlacement = LegendPlacement.Outside; 
    plotModel1.LegendPosition = LegendPosition.BottomCenter; 
    plotModel1.Title = "With negative values"; 
    var categoryAxis1 = new CategoryAxis(); 
    categoryAxis1.MinorStep = 1; 
    categoryAxis1.Labels.Add("Category A"); 
    categoryAxis1.Labels.Add("Category B"); 
    categoryAxis1.Labels.Add("Category C"); 
    categoryAxis1.Labels.Add("Category D"); 
    categoryAxis1.ActualLabels.Add("Category A"); 
    categoryAxis1.ActualLabels.Add("Category B"); 
    categoryAxis1.ActualLabels.Add("Category C"); 
    categoryAxis1.ActualLabels.Add("Category D"); 
    plotModel1.Axes.Add(categoryAxis1); 
    var linearAxis1 = new LinearAxis(); 
    linearAxis1.MaximumPadding = 0.06; 
    linearAxis1.MinimumPadding = 0.06; 
    linearAxis1.ExtraGridlines = new Double[1]; 
    linearAxis1.ExtraGridlines[0] = 0; 
    plotModel1.Axes.Add(linearAxis1); 
    var columnSeries1 = new ColumnSeries(); 
    columnSeries1.StrokeThickness = 1; 
    columnSeries1.Title = "Series 1"; 
    columnSeries1.Items.Add(new ColumnItem(25,-1,"OxyColors.Automatic")); 
    columnSeries1.Items.Add(new ColumnItem(137,-1,"OxyColors.Automatic")); 
    columnSeries1.Items.Add(new ColumnItem(18,-1,"OxyColors.Automatic")); 
    columnSeries1.Items.Add(new ColumnItem(40,-1,"OxyColors.Automatic")); 
    plotModel1.Series.Add(columnSeries1); 
    var columnSeries2 = new ColumnSeries(); 
    columnSeries2.StrokeThickness = 1; 
    columnSeries2.Title = "Series 2"; 
    columnSeries2.Items.Add(new ColumnItem(-12,-1,"OxyColors.Automatic")); 
    columnSeries2.Items.Add(new ColumnItem(-14,-1,"OxyColors.Automatic")); 
    columnSeries2.Items.Add(new ColumnItem(-120,-1,"OxyColors.Automatic")); 
    columnSeries2.Items.Add(new ColumnItem(-26,-1,"OxyColors.Automatic")); 
    plotModel1.Series.Add(columnSeries2); 
    var columnSeries3 = new ColumnSeries(); 
    columnSeries3.StrokeThickness = 1; 
    columnSeries3.Title = "Series 3"; 
    columnSeries3.Items.Add(new ColumnItem(21,-1,"OxyColors.Automatic")); 
    columnSeries3.Items.Add(new ColumnItem(8,-1,"OxyColors.Automatic")); 
    columnSeries3.Items.Add(new ColumnItem(48,-1,"OxyColors.Automatic")); 
    columnSeries3.Items.Add(new ColumnItem(3,-1,"OxyColors.Automatic")); 
    plotModel1.Series.Add(columnSeries3); 
    var columnSeries4 = new ColumnSeries(); 
    columnSeries4.StrokeThickness = 1; 
    columnSeries4.Title = "Series 4"; 
    columnSeries4.Items.Add(new ColumnItem(-8,-1,"OxyColors.Automatic")); 
    columnSeries4.Items.Add(new ColumnItem(-21,-1,"OxyColors.Automatic")); 
    columnSeries4.Items.Add(new ColumnItem(-3,-1,"OxyColors.Automatic")); 
    columnSeries4.Items.Add(new ColumnItem(-48,-1,"OxyColors.Automatic")); 
    plotModel1.Series.Add(columnSeries4); 
    return plotModel1; 
} 
5

당신은 Y에 대한의 LinearAxis을 사용하고 있다고 가정하면 중심선.

LinearAxis를 추가하기 만하면됩니다.

plotModel.Axes.Add(new LinearAxis() 
     { 
      Title = "Percentage", 
      Position = AxisPosition.Left, 
      // Magic Happens here we add the extra grid line on our Y Axis at zero 
      ExtraGridlines = new Double[] { 0 } 
     });