0
在我的Windows手機通用應用程序我試圖在y軸上添加散射系列。我在圖表上動態添加系列,然後使用最小值,最大值和間隔設置比例。在一些間隔變大的情況下,10個圖表比例不按期望出現。請幫忙。提前致謝。區間大於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;