间隔大于10不接受图表

时间:2014-12-26 14:58:53

标签: winrt-xaml-toolkit

在我的Windows手机通用应用程序中我试图在y轴上添加散点图系列。我在图表上动态添加系列,然后使用最小值,最大值和间隔设置比例。在某些情况下,当间隔变大时,10个图表比例不会按预期显示。请帮忙。提前谢谢。

DateTimeAxis x = new DateTimeAxis() { Orientation = AxisOrientation.X, Location =     AxisLocation.Bottom };
        string InterValType = "";
        int interval = 0;

         CalulateInterValForDateAxis(DictVarData.ElementAt(DictVarData.Count - 1).Name, DictVarData.ElementAt(0).Name, ref InterValType, ref interval);

        x.Interval = interval;
        x.IntervalType = InterValType == "Days" ? DateTimeIntervalType.Days : InterValType == "Months" ? DateTimeIntervalType.Months : DateTimeIntervalType.Years;

        Style st = new Style(typeof(DateTimeAxisLabel));
        st.Setters.Add(new Setter(DateTimeAxisLabel.StringFormatProperty, "{0:MM/dd/yy}"));
        st.Setters.Add(new Setter(DateTimeAxisLabel.FontSizeProperty, "10"));
        st.Setters.Add(new Setter(DateTimeAxisLabel.ForegroundProperty, "Black"));

        x.AxisLabelStyle = st;



        Style stmin = new Style(typeof(Line));
        stmin.Setters.Add(new Setter(Line.HeightProperty, "10"));
        stmin.Setters.Add(new Setter(Line.StrokeProperty, "Black"));
        stmin.Setters.Add(new Setter(Line.StrokeThicknessProperty, "2"));
        stmin.Setters.Add(new Setter(Line.X1Property, "0"));
        stmin.Setters.Add(new Setter(Line.X2Property, "10"));
        stmin.Setters.Add(new Setter(Line.Y1Property, "0"));
        stmin.Setters.Add(new Setter(Line.Y2Property, "10"));
        x.MajorTickMarkStyle = stmin;


      LinearAxis y = new LinearAxis() { Orientation = AxisOrientation.Y, Location = AxisLocation.Left, Minimum = YMinValue, Maximum = YMaxValue,Interval=YInterval };
      y.FontSize = 10;
      y.ShowGridLines = true;
      y.Margin = new Thickness(0);
      y.Foreground = new SolidColorBrush(Colors.Black);

      this.ScatterChart.Axes.Add(y);

      ScatterSeries ScatterS = new ScatterSeries();

      for (int cntY = 0; cntY < General.VariableArrayYAxis.Count; cntY++)
      {
          if (cntY != 0)
              ScatterS = new ScatterSeries();

          ScatterS.DependentValuePath = "Value";
          ScatterS.IndependentValuePath = "Name";
          ScatterS.Name = General.VariableArrayYAxis[cntY].ToString();
          ScatterS.DataPointStyle = (Style)App.Current.Resources[GetStyleName(dictColorUsedForVariable[General.VariableArrayYAxis[cntY]])];
          this.ScatterChart.Series.Add(ScatterS);
      }



        this.ScatterChart.Axes.Add(x);

        this.ScatterChart.Background = new SolidColorBrush(Colors.White);

       ScatterS.DependentRangeAxis = this.ScatterChart.ActualAxes[0] as DateTimeAxis;
       ScatterS.DependentRangeAxis = this.ScatterChart.ActualAxes[1] as LinearAxis;

1 个答案:

答案 0 :(得分:0)

在我的情况下,我通过设置范围的最小值和最大值以及间隔来为轴提供自定义范围。在winrt-xaml-toolkit中,它通过自己调整比例,这对我来说是个问题。所以我将更改源代码并使其自动进行自定义缩放和间隔。