예제 #1
0
        void PrimaryXAxis_Zooming(object sender, ChartAxisZoomingArgs args)
        {
            if (args.ZoomFactor <= 0.5 && Cursors.Equals(this.chartControl.Cursor, Cursors.Cross))
            {
                ChartDateTimeIntervalType type = this.chartControl.PrimaryXAxis.DateTimeRange.DefaultInterval.Type;
                switch (type)
                {
                case ChartDateTimeIntervalType.Years:
                    this.chartControl.PrimaryXAxis.DateTimeFormat = "MMM-yy";
                    this.chartControl.PrimaryXAxis.DateTimeRange  = new ChartDateTimeRange(series.Points[0].DateX, series.Points[series.Points.Count - 1].DateX, 2, ChartDateTimeIntervalType.Months);
                    this.chartControl.Text = "Monthly View for Stock";
                    break;

                case ChartDateTimeIntervalType.Months:
                    this.chartControl.PrimaryXAxis.DateTimeFormat = "ddd,d,MMM-yy";
                    this.chartControl.PrimaryXAxis.DateTimeRange  = new ChartDateTimeRange(series.Points[0].DateX, series.Points[series.Points.Count - 1].DateX, 5, ChartDateTimeIntervalType.Weeks);
                    this.chartControl.Text = "Weekly View for Stock";

                    break;

                case ChartDateTimeIntervalType.Weeks:
                    this.chartControl.PrimaryXAxis.DateTimeFormat = "dd-MM-yy";
                    this.chartControl.PrimaryXAxis.DateTimeRange  = new ChartDateTimeRange(series.Points[0].DateX, series.Points[series.Points.Count - 1].DateX, 20, ChartDateTimeIntervalType.Days);
                    this.chartControl.Text = "Day View for Stock";

                    break;

                case ChartDateTimeIntervalType.Days:
                    this.chartControl.PrimaryXAxis.DateTimeFormat = "HH:mm";
                    this.chartControl.PrimaryXAxis.DateTimeRange  = new ChartDateTimeRange(series.Points[0].DateX, series.Points[series.Points.Count - 1].DateX, 125, ChartDateTimeIntervalType.Hours);
                    this.chartControl.Text = "Hour View for Stock";
                    break;
                }
            }
            else
            {
                if (args.ZoomFactor == 1)
                {
                    this.chartControl.PrimaryXAxis.DateTimeRange  = new ChartDateTimeRange(series.Points[0].DateX, series.Points[series.Points.Count - 1].DateX, 1, ChartDateTimeIntervalType.Years);
                    this.chartControl.PrimaryXAxis.DateTimeFormat = "yyyy";
                    this.chartControl.Text = "Yearly view for Stock";
                }
            }
        }