Hi,
i have multiple y-axis in my graph which is being plotted dynamically and name associated with it comes on the basis of selection done in dropdown list.my project follows MVVM architecture. x-axis represents time.so i need to generate all y values for particular time and then add the lineseries to the Series dynamically. problem is that graph is being plotted but could not be seen.
private void LoadData()
{
rnd = new Random();
GraphDatas = new ObservableCollection<GraphData>();
GraphData gd = null;
Linearaxis = new List<LinearAxis>();
for (int x = 0; x < 35; x++)
{
foreach (WeldDataMapping _weldDataMapping in _arrayOfWeldDataMapping.Where(ab => ab.IsSelected))
{
GraphDatas = new ObservableCollection<GraphData>();
gd = new GraphData();
gd.XValue = x;
gd.YValue = rnd.NextDouble() * 100 ;
GraphDatas.Add(gd);
LineSeries line = new LineSeries();
Brush objBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_weldDataMapping.WeldDataColor));
if (!Linearaxis.Any(ab => ab.Title.ToString() == _weldDataMapping.WeldDataName))
{
LinearAxis yaxis = new LinearAxis { Title = _weldDataMapping.WeldDataName, Foreground = objBrush, LineStroke = objBrush, FontSize = 15 };
line.VerticalAxis = yaxis;
Linearaxis.Add(yaxis);
line.Name = _weldDataMapping.WeldDataName;
line.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_weldDataMapping.WeldDataColor));
line.DisplayName = _weldDataMapping.WeldDataName;
line.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "XValue" };
line.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "YValue" };
line.ItemsSource = GraphDatas;
//adds the lineseries to the graph.
_graphView.xCartesianGraph.Series.Add(line);
}
else
{
line.VerticalAxis = Linearaxis.FirstOrDefault(ab => ab.Title.ToString() == _weldDataMapping.WeldDataName);
line.Name = _weldDataMapping.WeldDataName;
line.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_weldDataMapping.WeldDataColor));
line.DisplayName = _weldDataMapping.WeldDataName;
line.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "XValue" };
line.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "YValue" };
line.ItemsSource = GraphDatas;
//adds the lineseries to the graph.
_graphView.xCartesianGraph.Series.Add(line);
}
}
}
}
please provide me the solution asap.
i have multiple y-axis in my graph which is being plotted dynamically and name associated with it comes on the basis of selection done in dropdown list.my project follows MVVM architecture. x-axis represents time.so i need to generate all y values for particular time and then add the lineseries to the Series dynamically. problem is that graph is being plotted but could not be seen.
private void LoadData()
{
rnd = new Random();
GraphDatas = new ObservableCollection<GraphData>();
GraphData gd = null;
Linearaxis = new List<LinearAxis>();
for (int x = 0; x < 35; x++)
{
foreach (WeldDataMapping _weldDataMapping in _arrayOfWeldDataMapping.Where(ab => ab.IsSelected))
{
GraphDatas = new ObservableCollection<GraphData>();
gd = new GraphData();
gd.XValue = x;
gd.YValue = rnd.NextDouble() * 100 ;
GraphDatas.Add(gd);
LineSeries line = new LineSeries();
Brush objBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_weldDataMapping.WeldDataColor));
if (!Linearaxis.Any(ab => ab.Title.ToString() == _weldDataMapping.WeldDataName))
{
LinearAxis yaxis = new LinearAxis { Title = _weldDataMapping.WeldDataName, Foreground = objBrush, LineStroke = objBrush, FontSize = 15 };
line.VerticalAxis = yaxis;
Linearaxis.Add(yaxis);
line.Name = _weldDataMapping.WeldDataName;
line.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_weldDataMapping.WeldDataColor));
line.DisplayName = _weldDataMapping.WeldDataName;
line.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "XValue" };
line.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "YValue" };
line.ItemsSource = GraphDatas;
//adds the lineseries to the graph.
_graphView.xCartesianGraph.Series.Add(line);
}
else
{
line.VerticalAxis = Linearaxis.FirstOrDefault(ab => ab.Title.ToString() == _weldDataMapping.WeldDataName);
line.Name = _weldDataMapping.WeldDataName;
line.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_weldDataMapping.WeldDataColor));
line.DisplayName = _weldDataMapping.WeldDataName;
line.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "XValue" };
line.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "YValue" };
line.ItemsSource = GraphDatas;
//adds the lineseries to the graph.
_graphView.xCartesianGraph.Series.Add(line);
}
}
}
}
please provide me the solution asap.