private void BarButton_Click(object sender, EventArgs e) { // generate some random Y data int pointCount = 5; double[] ys1 = RandomWalk(pointCount); double[] ys2 = RandomWalk(pointCount); // create series and populate them with data var series1 = new LiveCharts.Wpf.ColumnSeries { Title = "Group A", Values = new LiveCharts.ChartValues <double>(ys1) }; var series2 = new LiveCharts.Wpf.ColumnSeries() { Title = "Group B", Values = new LiveCharts.ChartValues <double>(ys2) }; // display the series in the chart control cartesianChart1.Series.Clear(); cartesianChart1.Series.Add(series1); cartesianChart1.Series.Add(series2); //cartesianChart1.Zoom = LiveCharts.ZoomingOptions.Xy; }
public void AddSeries(Interfaces.IIsChartSeries series) { series.ChangedData += ItemChanged; series.NewData += ItemAdded; series.DataCleared += ItemsCleared; _SeriesSource.Add(series); switch (series.SeriesType) { case "Candle": LiveCharts.Wpf.OhlcSeries chartseries = new LiveCharts.Wpf.OhlcSeries(); chartseries.Title = series.SeriesLabel; chartseries.Values = new LiveCharts.ChartValues <LiveCharts.Defaults.OhlcPoint>(); LiveCharts.Wpf.Axis axis = new LiveCharts.Wpf.Axis() { Title = series.YAxisLabel, ShowLabels = true }; Chart.AxisY.Add(axis); chartseries.ScalesYAt = Chart.AxisY.IndexOf(axis); Chart.Series.Add(chartseries); break; case "Line": LiveCharts.Wpf.LineSeries chartseriesline = new LiveCharts.Wpf.LineSeries(); chartseriesline.Title = series.SeriesLabel; chartseriesline.Values = new LiveCharts.ChartValues <double>(); chartseriesline.PointGeometry = null; LiveCharts.Wpf.Axis axisline = new LiveCharts.Wpf.Axis() { Title = series.YAxisLabel, ShowLabels = true }; Chart.AxisY.Add(axisline); chartseriesline.ScalesYAt = Chart.AxisY.IndexOf(axisline); Chart.Series.Add(chartseriesline); break; case "Column": LiveCharts.Wpf.ColumnSeries chartseriescolumn = new LiveCharts.Wpf.ColumnSeries(); chartseriescolumn.Title = series.SeriesLabel; chartseriescolumn.Values = new LiveCharts.ChartValues <double>(); LiveCharts.Wpf.Axis axiscolumn = new LiveCharts.Wpf.Axis() { Title = series.YAxisLabel, ShowLabels = true }; Chart.AxisY.Add(axiscolumn); chartseriescolumn.ScalesYAt = Chart.AxisY.IndexOf(axiscolumn); Chart.Series.Add(chartseriescolumn); break; case "Bar": default: break; } }