Why does the line chart not align to the labels on the x-axis? I am using a subset of infragistics sample data to display the problem.
To recreate, create a simple project that has one Form. On the form, Add a winchart. Set the ChartType to LineChart. Switch to code view. Copy and paste and below card. Compile and run. I have played around with a great many of the Axis and Label appearance but nothing seems to work.
Any help will be greatly appreciated.
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace SimpleLineChart{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private DataTable GenerateData() { DataTable dt = new DataTable(); dt.Columns.Add("StockName", typeof(string)); dt.Columns.Add("Monday", typeof(double)); dt.Columns.Add("Tuesday", typeof(double)); DataRow row1 = dt.NewRow(); row1.ItemArray = new object[ { "IBM", 111, 96 }; DataRow row2 = dt.NewRow(); row2.ItemArray = new object[ { "MSN", 75, 23 }; DataRow row3 = dt.NewRow(); row3.ItemArray = new object[ { "MCI", 55, 63 }; dt.Rows.Add(row1); dt.Rows.Add(row2); dt.Rows.Add(row3); return dt; } private void Form1_Load(object sender, EventArgs e) { _lineChart.DataSource = GenerateData(); _lineChart.DataBind(); } }}
I'm not exactly sure what means "Line chart not align", but if you want "IBM", "MSN", "MCI" to be on the x-axis, you need to include:
_lineChart.Data.SwapRowsAndColumns =
Sorry that I didn't response in time. I'm attaching a screenshot of the chart that is created with your code. Could you please provide a little bit more information what is this picture is not as expected?