Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9087645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:44:34+00:00 2026-06-16T21:44:34+00:00

I am creating small program what shows us total sell sum by months via

  • 0

I am creating small program what shows us total sell sum by months via chart, and i need to call X axis points (1, 2, 3, 4, 5) by my SQL response names (2012’7, 2012’8, 2012’9), but cant find how to do this.

enter image description here

Code:

        sqlQuery = "SELECT YEAR(`importdate`) as 'Year', MONTH(`importdate`) as 'Month', SUM(`price`) as 'Sum' FROM `wagon` GROUP BY MONTH(`importdate`), YEAR(`importdate`) ORDER BY YEAR(`importdate`), MONTH(`importdate`) ASC LIMIT 12";

        MySqlConnection sqlConnection = new MySqlConnection(sqlParams);
        MySqlCommand sqlCommand = new MySqlCommand(sqlQuery, sqlConnection);

        chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.Gainsboro;
        chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.Gainsboro;

        try
        {
            sqlConnection.Open();

            MySqlDataReader sqlReader = sqlCommand.ExecuteReader();

            if (sqlReader.HasRows)
            {
                while (sqlReader.Read())
                {
                    string Sum = sqlReader["Sum"].ToString();
                    if (Sum.Contains(",")) Sum = Sum.Replace(",", ".");

                    string serieName = "Series1";
                   // string serieName = sqlReader["Year"].ToString() + '\'' + sqlReader["Month"].ToString();
                   // chart1.Series.Add(sqlReader["Year"].ToString() + '\'' + sqlReader["Month"].ToString());

                   // chart1.Series[serieName].ChartArea = "ChartArea1";

                    chart1.Series[serieName].Points.AddY(Sum);


                    chart1.Series[serieName].ChartType = SeriesChartType.Line;
                    chart1.Series[serieName].IsValueShownAsLabel = true;
                    //sqlReader["Year"].ToString() + '"' + sqlReader["Month"].ToString()
                }
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:44:35+00:00Added an answer on June 16, 2026 at 9:44 pm

    If I get you right, you use this:

    Chart1.ChartAreas(0).AxisX.CustomLabels.Add(0.5, 1.5, "1");
                Chart1.ChartAreas(0).AxisX.CustomLabels.Add(1.5, 2.5, "2");
                Chart1.ChartAreas(0).AxisX.CustomLabels.Add(2.5, 3.5, "3");
                Chart1.ChartAreas(0).AxisX.CustomLabels.Add(3.5, 4.5, "4");
                Chart1.ChartAreas(0).AxisX.CustomLabels.Add(4.5, 5.5, "5");
    

    First two numbers determine how far those labels will spread. third is label itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating small program what shows us total sell sum by months via
So i'm creating a small program and I want to use a custom icon
I am creating an invoice program for a small local company but have run
I'm creating a small program for viewing images. However, the whole idea is that
I'm currently creating a small C# program that inserts data from files into a
I'm creating a small program to use with an irc bot that should take
I'm creating a small program that saves a int value into a text file,
I am creating a small program over entityframework which allows to edit the POCOs
I'm learning C# through creating a small program, and couldn't find a similar post
I am creating a small program to show off to my friends.... This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.