Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. VS2010 Chart Control [modified]

VS2010 Chart Control [modified]

Scheduled Pinned Locked Moved C#
questioncomsales
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    It_tech
    wrote on last edited by
    #1

    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"

    P 1 Reply Last reply
    0
    • I It_tech

      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"

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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.

      My blog | My articles | MoXAML PowerToys | Onyx

      I D 2 Replies Last reply
      0
      • P Pete OHanlon

        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.

        My blog | My articles | MoXAML PowerToys | Onyx

        I Offline
        I Offline
        It_tech
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • I It_tech

          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

          D Offline
          D Offline
          Daniel Grunwald
          wrote on last edited by
          #4

          That's still isn't valid C#. The converter you used sucks. Why don't you try the VB forum?

          1 Reply Last reply
          0
          • P Pete OHanlon

            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.

            My blog | My articles | MoXAML PowerToys | Onyx

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            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)

            P 1 Reply Last reply
            0
            • D DaveyM69

              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)

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              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.

              My blog | My articles | MoXAML PowerToys | Onyx

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups