本文整理汇总了C#中LineSeries.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# LineSeries.SetBinding方法的具体用法?C# LineSeries.SetBinding怎么用?C# LineSeries.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineSeries
的用法示例。
在下文中一共展示了LineSeries.SetBinding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNewCurves
} // constructor
public void AddNewCurves(CurvePoint[][] xCurvePoints, double xYShift)
{
if (!Dispatcher.CheckAccess())
{
Action lAction = () => { AddNewCurves(xCurvePoints, xYShift); };
App.Current.Dispatcher.BeginInvoke(lAction);
return;
}
// find the Y axis
LinearAxis lYAxis = null;
foreach (IAxis lAxis in _MainWindow.myChart.Axes)
{
if (lAxis.Orientation != AxisOrientation.Y) continue;
lYAxis = lAxis as LinearAxis;
}
int lCount = xCurvePoints.GetUpperBound(0);
LineSeries[] lLineSeries = new LineSeries[lCount];
for (int x = 0, n = lCount; x < n; x++)
{
LineSeries lLine = new LineSeries();
lLineSeries[x] = lLine;
lLine.DependentRangeAxis = lYAxis;
lLine.Title = "manually added curve";
lLine.SetBinding(LineSeries.ItemsSourceProperty, new Binding());
lLine.IndependentValueBinding = new Binding("Time");
lLine.DependentValueBinding = new Binding("CurveId");
Style lLineStyle = new Style(typeof(Polyline));
//lLineStyle.Setters.Add(new Setter(Polyline.StrokeStartLineCapProperty, PenLineCap.Flat));
//lLineStyle.Setters.Add(new Setter(Polyline.StrokeEndLineCapProperty, PenLineCap.Triangle));
Style lPointStyle = new Style(typeof(DataPoint));
if (xYShift == 0.0)
{
lLineStyle.Setters.Add(new Setter(Polyline.StrokeThicknessProperty, 3.0));
lPointStyle.Setters.Add(new Setter(DataPoint.WidthProperty, 0.0));
lPointStyle.Setters.Add(new Setter(DataPoint.BackgroundProperty, new SolidColorBrush(Colors.LightGreen)));
}
else
{
lLineStyle.Setters.Add(new Setter(Polyline.StrokeThicknessProperty, 1.0));
lPointStyle.Setters.Add(new Setter(DataPoint.WidthProperty, 0.0));
lPointStyle.Setters.Add(new Setter(DataPoint.BackgroundProperty, new SolidColorBrush(Colors.Black)));
}
lLine.PolylineStyle = lLineStyle;
lLine.DataPointStyle = lPointStyle;
xCurvePoints[x][0].CurveId -= xYShift;
xCurvePoints[x][1].CurveId -= xYShift;
lLine.ItemsSource = xCurvePoints[x];
_MainWindow.myChart.Series.Add(lLine);
}
} //
示例2: UpdateChart
private void UpdateChart()
{
foreach (SeriesData seriesData in Controller.Graph.Series.Where(s => s.Visible))
{
var series = new LineSeries
{
DependentValuePath = "Amount",
IndependentValuePath = "Month",
IsSelectionEnabled = true,
DataContext = seriesData
};
var plotsBinding = new Binding
{
Path = new PropertyPath("Plots")
};
series.SetBinding(DataPointSeries.ItemsSourceProperty, plotsBinding);
var titleBinding = new Binding
{
Path = new PropertyPath("SeriesName")
};
series.SetBinding(Series.TitleProperty, titleBinding);
var visibilityBinding = new Binding
{
Path = new PropertyPath("Visible"),
Converter = new BooleanToVisibilityConverter()
};
series.SetBinding(VisibilityProperty, visibilityBinding);
series.SelectionChanged += SeriesOnSelectionChanged;
this.Chart.Series.Add(series);
}
}
示例3: DrawCurve_WPF_Runtime
private void DrawCurve_WPF_Runtime(Chart lChart, AxisPointDateTime lAxisPointDateTimeX, AxisPointLinear lAxisPointLinearY)
{
PriceClusterSimple lDataPoint = new PriceClusterSimple(lAxisPointDateTimeX.MouseAxisValueAbsolute, lAxisPointLinearY.MouseAxisValueAbsolute);
if (ManualPoints != null)
{
if (_DrawNewLine)
{
_DrawNewLine = false;
ManualPoints.Clear();
ManualPoints.Add(lDataPoint); // from
ManualPoints.Add(lDataPoint); // to
}
else
{
ManualPoints.RemoveAt(1);
ManualPoints.Add(lDataPoint); // to
}
return;
}
ManualPoints = new ObservableCollection<PriceClusterSimple>();
ManualPoints.Add(lDataPoint);
ManualPoints.Add(lDataPoint);
LineSeries lNewLineSeries = new LineSeries();
lNewLineSeries.Title = "manually added curve";
lNewLineSeries.SetBinding(LineSeries.ItemsSourceProperty, new Binding());
lNewLineSeries.ItemsSource = ManualPoints;
lNewLineSeries.IndependentValueBinding = new Binding("Date");
lNewLineSeries.DependentValueBinding = new Binding("Price");
lNewLineSeries.DependentRangeAxis = lAxisPointLinearY.Axis;
Setter lHeightSetter = new Setter(FrameworkElement.HeightProperty, 0.0);
Setter lWidthSetter = new Setter(FrameworkElement.WidthProperty, 0.0);
Setter lColor = new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Black));
Style lStyle = new Style(typeof(Control));
lNewLineSeries.DataPointStyle = lStyle;
lStyle.Setters.Add(lHeightSetter);
lStyle.Setters.Add(lWidthSetter);
lStyle.Setters.Add(lColor);
lChart.Series.Add(lNewLineSeries);
} //
示例4: viewModel_SelectedParameterIDChanged
void viewModel_SelectedParameterIDChanged(object sender, EventArgs e)
{
FlightAnalysisSubLiteViewModel viewModel = this.GetViewModel();
if (viewModel == null || viewModel.ChartViewModel == null
|| this.DataLoader == null)
return;
var tempArray = new string[] { viewModel.SelectedParameterID };
this.DataLoader.LoadRawDataAsync(tempArray);
var tempGroup = AircraftDataAnalysisModel1.WinRT.DataModel.FlightAnalysisChartGroupFactory.CalculateBindingGroups(tempArray);
//Group must be only one
var gpName = tempGroup.First().Key;
var rawDatas = DataLoader.GetRawData(viewModel.SelectedParameterID);
Dictionary<int, SimpleDataPoint> pointMapper = new Dictionary<int, SimpleDataPoint>();
foreach (var item in viewModel.ChartViewModel)
{
if (!pointMapper.ContainsKey(item.Second))
{
pointMapper.Add(item.Second, item);
}
}
foreach (var raw in rawDatas)
{
if (pointMapper.ContainsKey(raw.Second))
{
pointMapper[raw.Second].Value = raw.Values[0];
}
}
var Xaxis1 = this.tracker1.Axes["xm1XAxis1"] as CategoryXAxis;
var Yaxis1 = this.tracker1.Axes["xm1YAxis1"] as NumericYAxis;
var Xaxis2 = this.tracker1.Axes["xm1XAxis2"] as CategoryXAxis;
var Yaxis2 = this.tracker1.Axes["xm1YAxis2"] as NumericYAxis;
//Left YAxis
var xaxis = Xaxis1;
var yaxis = Yaxis1;
if (gpName != viewModel.Group1ID)
{ //Right YAxis
xaxis = Xaxis2;
yaxis = Yaxis2;
}
Series temp = this.tracker1.Series["addParamSerie"];
if (temp != null)
this.tracker1.Series.Remove(temp);
LineSeries serie = new LineSeries() { Name = "addParamSerie" };
serie.XAxis = xaxis;
serie.ItemsSource = viewModel.ChartViewModel;
serie.SetBinding(LineSeries.VisibilityProperty, new Binding()
{
Path = new PropertyPath("CompareParameterSerieVisibility"),
Source = viewModel
});
serie.YAxis = yaxis;
serie.Title = ApplicationContext.Instance.GetFlightParameterCaption(viewModel.SelectedParameterID);
serie.Legend = this.TitleLegend;
serie.MarkerType = MarkerType.None;
serie.ValueMemberPath = "Value";
serie.DataContext = viewModel;
this.tracker1.Series.Add(serie);
}