locked
To remove Selected Custom Labels of X axis RRS feed

  • Question

  • Hello,

           I am using Mschart for plotting the line graph for day wise , but on Xaxis  need to show on month end dates .

    example 30-Sep-2015 ,31-Oct-2015 ..

    I tired to use

    tmpChart.ChartAreas[tmpArea].AxisX.IntervalType = DateTimeIntervalType.Months;

    but result was 01-Sep-2015 ,01-Oct-2015 ...   instead of end date of month.

    Later  I tired to  remove the  labels


     List<CustomLabel> lstRemove = new List<CustomLabel>();
                    DateTime Dt = new DateTime();
                    int c = 0;
                    foreach (CustomLabel lbl in Chart1.ChartAreas[0].AxisX.CustomLabels)
                    {
                        Dt = Convert.ToDateTime(lbl.Text);
    
                        if (Dt.Day != DateTime.DaysInMonth(Dt.Year, Dt.Month))
                        {
                            lstRemove.Add(lbl);
                        }
                        else
                        {
                            lbl.RowIndex = c;
                            c++;
                        }
    
                        //        dp.Label = "";
    
    
                        //  lbl.Text = range[count];
    
                    }
                    foreach (CustomLabel lbl in lstRemove)
                        Chart1.ChartAreas[0].AxisX.CustomLabels.Remove(lbl);

    When I debug  : proper data is available after remove .

    But,  in UI   labels are not removed .

    Please help...

    



    • Edited by Fabcoder Thursday, October 15, 2015 9:43 AM
    Thursday, October 15, 2015 7:17 AM

All replies

  • Hello there,

    Set RowIndex to 0 for my Custom Labels. Now things line up just fine.

    Cheers

    Dinesh

    • Proposed as answer by Dinesh Gabhane Friday, October 16, 2015 10:34 AM
    Friday, October 16, 2015 10:34 AM