Hi friends,
Could anyone help me regarding below coding it is not updating/loading data to Chart.
Value of Series (LineSeries) will fetch from database dynamically, below are just for testing/demonstration purpose...
I am using UserControls for loading in to Main Form
I want load data into chart
OnForm_Load()
When I click another tab/button to load another UserControl, and again click the Dashoboard the Chart background changes to black
What I have tried:
void getMonthDetails()
{
var months = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
DateTime dt = DateTime.Now;
int mm = dt.Date.Month;
int yy = dt.Date.Year;
string monthsArranged = "";
for (int i = mm; i <= 11; i++)
{
monthsArranged += ("\"" + months[i] + "/" + (yy - 1) + "\", ");
}
for (int i = 0; i <= mm - 1; i++)
{
monthsArranged += ("\"" + months[i] + "/" + (yy) + "\", ");
}
cartesianChart1.Series = new SeriesCollection
{
new LineSeries
{
Title = "Book Issued",
Values = new ChartValues<double> {504, 813, 895, 402, 687, 895, 467, 1087, 975, 542, 687, 465 }
},
new LineSeries
{
Title = "Book Returned",
Values = new ChartValues<double> {306, 407, 703, 704, 796, 1023, 745, 685, 535, 1044, 596, 654},
}
};
cartesianChart1.AxisX.Add(new Axis
{
Title = "Month",
Labels = new[] { monthsArranged.TrimEnd(',', ' ') },
LabelsRotation = 90
});
cartesianChart1.AxisY.Add(new Axis
{
Title = "Books",
});
cartesianChart1.LegendLocation = LegendLocation.Bottom;
}
private void UserControl1_Load(object sender, EventArgs e)
{
getMonthDetails();
}