Visual Studio Professional 2019 C# project using .NET chart component

Darryl Hoar 116 Reputation points
2021-05-06T16:29:20.38+00:00

Greetings,
I have created a c# winform project. On the form I have a Chart. I create a List<t> to be the datasource of the chart. The Object of the list has a datetime property.

My chart object on my form is named chart2. I have the following code:
chart2.DataSource = comRetriesList;
chart2.Series[0].XValueMember = "eventDate";
chart2.Series[0].XValueType = ChartValueType.DateTime;
chart2.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd HH:mm:ss";
chart2.Series[0].YValueMembers = "retries";
chart2.Series[0].YValueType = ChartValueType.Int32;
chart2.DataBind()

eventDate and retries are properties of the Object in List<t>

when I run the form, the chart displays but the dates are on the Y axis and the ints are on the X axis.

I haven't changed anything else and am confused. I have the Series chartType setup as Bar if that matters.

Anybody know why this is happening ?

thanks in advance. BTW .NET Framework 4.5.2

Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Darryl Hoar 116 Reputation points
    2021-05-06T20:27:00.807+00:00

    Well,
    Changed the chart type to column and it corrected. Weird.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.