none
Displaying specific dates in a VB.NET Chart RRS feed

  • Question

  • Good afternoon, I have a series of charts that in the X-Axis shows the dates but I would like to show only the 1st and 15th day of every month.  I have looked all over the internet but have not been able to find answers to that.

    Can anyone let me know how I can do that?

    Thanks

    Thursday, March 1, 2018 9:04 PM

All replies

  • I came up with this it sets first or 15th by month. Perhaps you can play with it for both.

                Chart1.ChartAreas(0).AxisX.Interval = 1
                Chart1.ChartAreas(0).AxisX.IntervalType = DateTimeIntervalType.Months
                'Chart1.ChartAreas(0).AxisX.IntervalOffset = 0 'start on first
                Chart1.ChartAreas(0).AxisX.IntervalOffset = 14  'start on 15th
                Chart1.ChartAreas(0).AxisX.IntervalOffsetType = DateTimeIntervalType.Days


    PS I assume you have this?

    https://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61

    Thursday, March 1, 2018 10:05 PM
  • Thank you for the answer, I will be trying it soon and will let you know the results of it.
    Thursday, March 1, 2018 11:32 PM
  • Thanks, it worked as expected although I do not have the package you assumed I was able to figure out using the available code in VS 2015:

            MainForm.chrShortFutOps.ChartAreas(0).AxisX.Interval = 1
            MainForm.chrShortFutOps.ChartAreas(0).AxisX.IntervalType = DataVisualization.Charting.DateTimeIntervalType.Months
            MainForm.chrShortFutOps.ChartAreas(0).AxisX.IntervalOffset = 14
            MainForm.chrShortFutOps.ChartAreas(0).AxisX.IntervalOffsetType = DataVisualization.Charting.DateTimeIntervalType.Days

    Friday, March 2, 2018 4:56 PM
  • Thanks, it worked as expected although I do not have the package you assumed I was able to figure out using the available code in VS 2015:

            MainForm.chrShortFutOps.ChartAreas(0).AxisX.Interval = 1
            MainForm.chrShortFutOps.ChartAreas(0).AxisX.IntervalType = DataVisualization.Charting.DateTimeIntervalType.Months
            MainForm.chrShortFutOps.ChartAreas(0).AxisX.IntervalOffset = 14
            MainForm.chrShortFutOps.ChartAreas(0).AxisX.IntervalOffsetType = DataVisualization.Charting.DateTimeIntervalType.Days

    Oh good. Mark my post as the answer then to close the thread please.

    Those are the chart control instructions in that link. It is a c# app you open and run in visual studio. It is not a chart control. It is the instructions for what you have. You should get it and run it you will see what I mean.

    Friday, March 2, 2018 6:20 PM