How can I create a Vertical Chart
-
sábado, 10 de marzo de 2012 8:55
Hi,
I have to create a chart vertically instead of horizontal chart. In order to do that I searched for a property. But I couldn't find anything. Can anyone help me to do that?
(Excuse me for my poor english language)
Mohammad - C# Lover
Todas las respuestas
-
sábado, 10 de marzo de 2012 19:03
Hi Mohammad,
check below Chart Sample,
http://www.codeproject.com/Articles/29842/Simple-WPF-BarChart-Horizontal-and-Vertical-Part-I
Regards
-
sábado, 10 de marzo de 2012 21:12
Thanks my dear friend. but i want to do that in a Windows Form Application, not in WPF.
Thanks again.
Mohammad - C# Lover
-
lunes, 12 de marzo de 2012 8:30
-
lunes, 12 de marzo de 2012 16:33Moderador
Hi,
I have to create a chart vertically instead of horizontal chart. In order to do that I searched for a property. But I couldn't find anything. Can anyone help me to do that?
(Excuse me for my poor english language)
Mohammad - C# Lover
not sure what you want - do you want the datapoints vertical or horizontal? Here are examples of Column and Bar - are one of these what you want?
Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column
Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Bar
-
martes, 13 de marzo de 2012 10:30
This a solution for Column chart-type only. I need a way for all, specially for line types.
Thanks
Mohammad - C# Lover
-
martes, 13 de marzo de 2012 15:35Moderador
This a solution for Column chart-type only. I need a way for all, specially for line types.
Thanks
Mohammad - C# Lover
I don't think anyone here understands what you want. Perhaps you can show an image of a sample chart you are looking for.
Here is a Line type chart:
Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
-
sábado, 17 de marzo de 2012 8:41
Thanks for your reply and sorry for my poor english language.
This is what excatly i have to generate.
Again sorry for my bad description.
Mohammad - C# Lover
-
martes, 27 de marzo de 2012 8:49Moderador
Unfortunately there is no simple way to rotate a chart.
However in this case you could just create a normal line chart and swap x values and y values.
Dim xValues As Double() = {1, 2, 3, 4, 5, 6, 7} Dim yValues As Double() = {1, 4, 2, 5, 6, 3, 8} Chart1.Series(0).Points.DataBindXY(yValues, xValues) 'yValues and xValues swapped -
martes, 27 de marzo de 2012 22:10
I had tried this solution, before. It gives me an oblique line, instead of a vertical line.
I think I have to talk to my manager ;)
Thanks anyway.
Mohammad - C# Lover
- Editado Mohammad Mir mostafa martes, 27 de marzo de 2012 22:10
-
miércoles, 28 de marzo de 2012 8:51Moderador
I'm not sure why this doesn't work for you. I tried this, the result looks pretty vertical to me.. also very similar to the picture you provided.
The code for this:
Imports System.Windows.Forms.DataVisualization.Charting Public Class Form1 Private WithEvents Chart1 As New Chart() Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Controls.Add(Chart1) Chart1.Size = Me.ClientSize Dim area As New ChartArea("AREA") Chart1.ChartAreas.Add(area) area.AxisX.Interval = 4 area.AxisX.MinorGrid.Enabled = True area.AxisX.MinorGrid.Interval = 1 area.AxisX.MinorGrid.LineColor = Color.LightGray area.AxisY.Interval = 5 area.AxisY.MinorGrid.Enabled = True area.AxisY.MinorGrid.Interval = 1 area.AxisY.MinorGrid.LineColor = Color.LightGray Dim series As New Series("SERIES") Chart1.Series.Add(series) series.ChartType = SeriesChartType.Line series.BorderWidth = 3 series.Color = Color.Black Dim series2 As New Series("SERIES2") Chart1.Series.Add(series2) series2.ChartType = SeriesChartType.Line series2.BorderWidth = 3 series2.Color = Color.DarkRed Dim xValues As Double() = {1, 2, 3, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16} Dim yValues As Double() = {1, 1, 12, 12, 2, 2, 7, 7, 1, 1, 13, 13, 2, 2} Dim xValues2 As Double() = {1, 3, 6, 7, 10, 11, 14, 15, 16, 17} Dim yValues2 As Double() = {5, 1, 1, 6, 6, 1, 1, 6, 6, 1} series.Points.DataBindXY(yValues, xValues) series2.Points.DataBindXY(yValues2, xValues2) End Sub End Class- Editado siplaModerator miércoles, 28 de marzo de 2012 8:51
- Propuesto como respuesta siplaModerator martes, 03 de abril de 2012 10:20
- Marcado como respuesta Mohammad Mir mostafa miércoles, 04 de abril de 2012 19:38
-
jueves, 29 de marzo de 2012 0:02
I'm not sure why this doesn't work for you. I tried this, the result looks pretty vertical to me.. also very similar to the picture you provided.
The code for this:
Imports System.Windows.Forms.DataVisualization.Charting Public Class Form1 Private WithEvents Chart1 As New Chart() Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Controls.Add(Chart1) Chart1.Size = Me.ClientSize Dim area As New ChartArea("AREA") Chart1.ChartAreas.Add(area) area.AxisX.Interval = 4 area.AxisX.MinorGrid.Enabled = True area.AxisX.MinorGrid.Interval = 1 area.AxisX.MinorGrid.LineColor = Color.LightGray area.AxisY.Interval = 5 area.AxisY.MinorGrid.Enabled = True area.AxisY.MinorGrid.Interval = 1 area.AxisY.MinorGrid.LineColor = Color.LightGray Dim series As New Series("SERIES") Chart1.Series.Add(series) series.ChartType = SeriesChartType.Line series.BorderWidth = 3 series.Color = Color.Black Dim series2 As New Series("SERIES2") Chart1.Series.Add(series2) series2.ChartType = SeriesChartType.Line series2.BorderWidth = 3 series2.Color = Color.DarkRed Dim xValues As Double() = {1, 2, 3, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16} Dim yValues As Double() = {1, 1, 12, 12, 2, 2, 7, 7, 1, 1, 13, 13, 2, 2} Dim xValues2 As Double() = {1, 3, 6, 7, 10, 11, 14, 15, 16, 17} Dim yValues2 As Double() = {5, 1, 1, 6, 6, 1, 1, 6, 6, 1} series.Points.DataBindXY(yValues, xValues) series2.Points.DataBindXY(yValues2, xValues2) End Sub End ClassThis is EXACTLY what I was looking for. I thought I was doing it like this, but I guess I had something off in my code. I took your basic code and added quite a bit of my own and created the exact graph I needed. Thanks for the post. I believe this is what Mohammad is looking for, maybe he is doing something wrong.
- Marcado como respuesta Mohammad Mir mostafa miércoles, 04 de abril de 2012 19:34
- Desmarcado como respuesta Mohammad Mir mostafa miércoles, 04 de abril de 2012 19:38
-
miércoles, 04 de abril de 2012 19:37
Thank you so much. That's what I want.
And this is C# version of above code:
(Just drag and drop a Chart into form)
this.Controls.Add(this.Chart1); this.Chart1.Size = this.ClientSize; var area = new ChartArea("AREA"); this.Chart1.ChartAreas.Add(area); area.AxisX.Interval = 4; area.AxisX.MinorGrid.Enabled = true; area.AxisX.MinorGrid.Interval = 1; area.AxisX.MinorGrid.LineColor = Color.LightGray; area.AxisY.Interval = 5; area.AxisY.MinorGrid.Enabled = true; area.AxisY.MinorGrid.Interval = 1; area.AxisY.MinorGrid.LineColor = Color.LightGray; var series = new Series("SERIES"); this.Chart1.Series.Add(series); series.ChartType = SeriesChartType.Line; series.BorderWidth = 3; series.Color = Color.Black; var series2 = new Series("SERIES2"); this.Chart1.Series.Add(series2); series2.ChartType = SeriesChartType.Line; series2.BorderWidth = 3; series2.Color = Color.DarkRed; double[] xValues = {1, 2, 3, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16}; double[] yValues = {1, 1, 12, 12, 2, 2, 7, 7, 1, 1, 13, 13, 2, 2}; double[] xValues2 = {1, 3, 6, 7, 10, 11, 14, 15, 16, 17}; double[] yValues2 = {5, 1, 1, 6, 6, 1, 1, 6, 6, 1}; series.Points.DataBindXY(yValues, xValues); series2.Points.DataBindXY(yValues2, xValues2);Mohammad - C# Lover

