VS2010 Chart Control [modified]
-
Hi all, Could you please let me know which property of the chart object will allow me to format values in Currency? I want to have my Y axis to show Currency Amonut Like ($100,$200,%300 etc...) Here is my code.. How can i format the chart control so that the revenue apprears in £ sign? At the moment its jUst showing Numbers not having a $ sign. Here is Code: With dt .Columns.Add(New DataColumn("Hours", System.Type.GetType("System.String"))) .Columns.Add(New DataColumn("Revenue", System.Type.GetType("System.String"))) .PrimaryKey = New DataColumn() {dt.Columns("Hour")} End With Using con As SqlConnection = New SqlConnection(Session("ConnectionString").ToString) Using com As SqlCommand = New SqlCommand(strCommand, con) con.Open() Dim i As Integer = 0 Using reader As SqlDataReader = com.ExecuteReader While reader.Read() ' Dim sSeries As String = reader(0).ToString.Trim. Dim sSeries As String = reader.GetName(i) Dim dr As DataRow Dim sData As String = ConvertToString(reader(0)) If sData = "Total" Then Else ' For f As Integer = 1 To reader. dr = dt.NewRow() 'dr("Hour") = reader.GetName(i) Try dr("Hours") = Convert.ToString(reader(0)) dr("Revenue") = Convert.ToDecimal(reader(1)) Catch ex As Exception End Try dt.Rows.Add(dr) dt.AcceptChanges() End If End While Dim Count As Integer = dt.Rows.Count If Count = 0 Then Exit Sub End If With Chart1 .Titles.Add("Revenue Generated by Hour and Channel ") .Series.Clear() .Series.Add("Revenue") .ChartAreas.Clear() .ChartAreas.Add("ChartArea1") .ChartAreas("ChartArea1").AxisX.Title = "HOUR"
-
Hi all, Could you please let me know which property of the chart object will allow me to format values in Currency? I want to have my Y axis to show Currency Amonut Like ($100,$200,%300 etc...) Here is my code.. How can i format the chart control so that the revenue apprears in £ sign? At the moment its jUst showing Numbers not having a $ sign. Here is Code: With dt .Columns.Add(New DataColumn("Hours", System.Type.GetType("System.String"))) .Columns.Add(New DataColumn("Revenue", System.Type.GetType("System.String"))) .PrimaryKey = New DataColumn() {dt.Columns("Hour")} End With Using con As SqlConnection = New SqlConnection(Session("ConnectionString").ToString) Using com As SqlCommand = New SqlCommand(strCommand, con) con.Open() Dim i As Integer = 0 Using reader As SqlDataReader = com.ExecuteReader While reader.Read() ' Dim sSeries As String = reader(0).ToString.Trim. Dim sSeries As String = reader.GetName(i) Dim dr As DataRow Dim sData As String = ConvertToString(reader(0)) If sData = "Total" Then Else ' For f As Integer = 1 To reader. dr = dt.NewRow() 'dr("Hour") = reader.GetName(i) Try dr("Hours") = Convert.ToString(reader(0)) dr("Revenue") = Convert.ToDecimal(reader(1)) Catch ex As Exception End Try dt.Rows.Add(dr) dt.AcceptChanges() End If End While Dim Count As Integer = dt.Rows.Count If Count = 0 Then Exit Sub End If With Chart1 .Titles.Add("Revenue Generated by Hour and Channel ") .Series.Clear() .Series.Add("Revenue") .ChartAreas.Clear() .ChartAreas.Add("ChartArea1") .ChartAreas("ChartArea1").AxisX.Title = "HOUR"
I've checked. That's not C# - not even with some hinky dink extension methods going on there. Please take your VB.NET out of our nice case sensitive forum.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
I've checked. That's not C# - not even with some hinky dink extension methods going on there. Please take your VB.NET out of our nice case sensitive forum.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Thanks for your comment. DataTable dt = new DataTable(); { 006 dt.Columns.Add(new DataColumn("Hours", System.Type.GetType("System.String"))); 007 dt.Columns.Add(new DataColumn("TotalCall", System.Type.GetType("System.String"))); 008 dt.Columns.Add(new DataColumn("Minutes", System.Type.GetType("System.String"))); 009 dt.Columns.Add(new DataColumn("Revenue", System.Type.GetType("System.String"))); 010 011 dt.PrimaryKey = new DataColumn[] { dt.Columns("Hour") }; 012 013 } 014 015 using (SqlConnection con = new SqlConnection(Session("BMEAS_ConnectionString").ToString)) { 016 using (SqlCommand com = new SqlCommand(strCommand, con)) { 017 con.Open(); 018 int i = 0; 019 using (SqlDataReader reader = com.ExecuteReader) { 020 while (reader.Read()) { 021 string sSeries = reader.GetName(i); 022 DataRow dr = null; 023 string sData = ConvertToString(reader(0)); 024 025 if (sData == "Total") { 026 027 } else { 028 dr = dt.NewRow(); 029 try { 030 dr["Hours"] = Convert.ToString(reader(0)); 031 dr["TotalCall"] = Convert.ToString(reader(1)); 032 dr["Minutes"] = Convert.ToString(reader(2)); 033 dr["Revenue"] = Convert.ToDecimal(reader(3)); 034 } catch (Exception ex) { 035 } 036 037 dt.Rows.Add(dr); 038 039 } 040 041 } 042 int Count = dt.Rows.Count; 043 if (Count == 0) { 044 return; 045 } 046 047 { 048 Chart1.Series("Default").Color = Color.MediumSeaGreen; 049 Chart1.Series("Default").BackSecondaryColor = Color.Green; 050 Chart1.Series("Default").BackGradientStyle = GradientStyle.DiagonalLeft; 051 052 Chart1.Series("Default").BorderColor = Color.Black; 053 Chart1.Series("Default").BorderWidth = 2; 054 Chart1.Series("Default").BorderDashStyle = ChartDashStyle.Solid; 055 056 Chart1.Series("Default").ShadowOffset = 2; 057 058 Chart1.Titles.Add("Revenue Generated by Hour and Channel "); 059 Chart1.Series.Clear(); 060 Chart1.Series.Add("Revenue"); 061
-
Thanks for your comment. DataTable dt = new DataTable(); { 006 dt.Columns.Add(new DataColumn("Hours", System.Type.GetType("System.String"))); 007 dt.Columns.Add(new DataColumn("TotalCall", System.Type.GetType("System.String"))); 008 dt.Columns.Add(new DataColumn("Minutes", System.Type.GetType("System.String"))); 009 dt.Columns.Add(new DataColumn("Revenue", System.Type.GetType("System.String"))); 010 011 dt.PrimaryKey = new DataColumn[] { dt.Columns("Hour") }; 012 013 } 014 015 using (SqlConnection con = new SqlConnection(Session("BMEAS_ConnectionString").ToString)) { 016 using (SqlCommand com = new SqlCommand(strCommand, con)) { 017 con.Open(); 018 int i = 0; 019 using (SqlDataReader reader = com.ExecuteReader) { 020 while (reader.Read()) { 021 string sSeries = reader.GetName(i); 022 DataRow dr = null; 023 string sData = ConvertToString(reader(0)); 024 025 if (sData == "Total") { 026 027 } else { 028 dr = dt.NewRow(); 029 try { 030 dr["Hours"] = Convert.ToString(reader(0)); 031 dr["TotalCall"] = Convert.ToString(reader(1)); 032 dr["Minutes"] = Convert.ToString(reader(2)); 033 dr["Revenue"] = Convert.ToDecimal(reader(3)); 034 } catch (Exception ex) { 035 } 036 037 dt.Rows.Add(dr); 038 039 } 040 041 } 042 int Count = dt.Rows.Count; 043 if (Count == 0) { 044 return; 045 } 046 047 { 048 Chart1.Series("Default").Color = Color.MediumSeaGreen; 049 Chart1.Series("Default").BackSecondaryColor = Color.Green; 050 Chart1.Series("Default").BackGradientStyle = GradientStyle.DiagonalLeft; 051 052 Chart1.Series("Default").BorderColor = Color.Black; 053 Chart1.Series("Default").BorderWidth = 2; 054 Chart1.Series("Default").BorderDashStyle = ChartDashStyle.Solid; 055 056 Chart1.Series("Default").ShadowOffset = 2; 057 058 Chart1.Titles.Add("Revenue Generated by Hour and Channel "); 059 Chart1.Series.Clear(); 060 Chart1.Series.Add("Revenue"); 061
That's still isn't valid C#. The converter you used sucks. Why don't you try the VB forum?
-
I've checked. That's not C# - not even with some hinky dink extension methods going on there. Please take your VB.NET out of our nice case sensitive forum.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Signature updated! :thumbsup:
Dave
If this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) -
Signature updated! :thumbsup:
Dave
If this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Like it.:thumbsup:
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.