Search code examples
c#wpfchartsvisual-studio-2015

Chart in Visual Studio Blend 2015


I am working in Visual Studio Blend 2015 and I need to add a line chart in my WPF application. The problem is that I don´t found the 'Chart' tool, as the existing in Visual Studio. I´ve try to add new references but this tool doesn´t appear. Anyone knows about that?

Thanks for your help!


Solution

  • Finally I have got the solution. I have created a line chart with two lines as it is showed in the picture.

    enter image description here

    'using OxyPlot' The code is:

                
                OxyPlot.PlotModel PM = new OxyPlot.PlotModel();
                PM.LegendTitle = "Legend";
    
                PM.IsLegendVisible = false;
                PM.PlotAreaBorderColor = OxyColor.FromRgb(203, 203, 203);
    
                var valueAxisX = new OxyPlot.Axes.LinearAxis() { MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, Title = "Value" };
                valueAxisX.Position = OxyPlot.Axes.AxisPosition.Bottom;
                valueAxisX.StartPosition = 0;
                valueAxisX.Title = "Weeks";
                valueAxisX.TitleColor = OxyColor.FromRgb(66, 66, 66);
                PM.Axes.Add(valueAxisX);
                var valueAxisY = new OxyPlot.Axes.LinearAxis() { MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, Title = "Value" };
                valueAxisY.Position = OxyPlot.Axes.AxisPosition.Left;
                valueAxisY.StartPosition = 0;
                valueAxisY.Title = "Requirements";
                valueAxisY.TitleColor = OxyColor.FromRgb(66, 66, 66);
                PM.Axes.Add(valueAxisY);
    
                var lineSerie = new OxyPlot.Series.LineSeries();
                lineSerie.StrokeThickness = 3;
                lineSerie.Color = OxyColor.FromRgb(59, 127, 196);
                lineSerie.MarkerType = MarkerType.None;
                lineSerie.Title = "Requirements";
                lineSerie.Smooth = false;
    
                lineSerie.Points.Add(new DataPoint(1, 25));
                lineSerie.Points.Add(new DataPoint(2, 40));
                lineSerie.Points.Add(new DataPoint(3, 40));
                lineSerie.Points.Add(new DataPoint(4, 50));
                lineSerie.Points.Add(new DataPoint(5, 100));
    
                var lineSerie2 = new OxyPlot.Series.LineSeries();
                lineSerie2.StrokeThickness = 2;
                lineSerie2.Color = OxyColor.FromRgb(141, 190, 239);
                lineSerie2.MarkerType = MarkerType.None;
                lineSerie2.Title = "Requirements_traced";
                lineSerie2.Smooth = false;
    
                lineSerie2.Points.Add(new DataPoint(1, 20));
                lineSerie2.Points.Add(new DataPoint(2, 30));
                lineSerie2.Points.Add(new DataPoint(3, 40));
                lineSerie2.Points.Add(new DataPoint(4, 45));
                lineSerie2.Points.Add(new DataPoint(5, 75));
    
                PM.Series.Add(lineSerie2);
                PM.Series.Add(lineSerie);
    
                PlotView.Model = PM;