コード例 #1
0
        public DateTimeAxisGrouping()
        {
            InitializeComponent();
            Tag = AppResources.DateTimeAxisGroupingTag;

            // Instantiate and assign the AxisGroupProvider,
            //and set the TimeUnits for each desired level.
            // To use the built-in provider:
            //   DateTimeGroupProvider mtgp = new DateTimeGroupProvider(axis);

            // For the purposes of the sample, use the included provider.
            Axis axis = flexChart.AxisX;
            MyDateTimeGroupProvider mtgp = new MyDateTimeGroupProvider(axis);

            axis.GroupProvider = mtgp;

            // Explicitly set Groups by TimeUnit
            //mtgp.GroupTypes.Add(TimeUnits.Month);
            //mtgp.GroupTypes.Add(TimeUnits.Quarter);
            //mtgp.GroupTypes.Add(TimeUnits.Year);

            // Non-default formatting is available.
            //mtgp.GroupFormats.Add(TimeUnits.Quarter, "Q{0} / {1}");

            // can force a label for the minimum and maximum limits on the axis.
            //axis.LabelMin = axis.LabelMax = true;

            // can provide and set MajorUnit in terms of TimeUnits.
            // below the MajorUnit is set to 2 months.
            //axis.TimeUnit = TimeUnits.Month;
            //axis.MajorUnit = 2;
        }
コード例 #2
0
        private void cbMajorUnit_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (flexChart == null)
            {
                return;
            }

            ComboBox cb  = sender as ComboBox;
            int      idx = cb.SelectedIndex;
            Axis     ax  = flexChart.AxisX;

            switch (idx)
            {
            case 0:
                ax.MajorUnit = double.NaN;
                ax.TimeUnit  = TimeUnits.Day;
                break;

            case 1:
                ax.MajorUnit = 1;
                ax.TimeUnit  = TimeUnits.Week;
                break;

            case 2:
                ax.MajorUnit = 2;
                ax.TimeUnit  = TimeUnits.Week;
                break;

            case 3:
                ax.MajorUnit = 1;
                ax.TimeUnit  = TimeUnits.Month;
                break;

            case 4:
                ax.MajorUnit = 2;
                ax.TimeUnit  = TimeUnits.Month;
                break;

            case 5:
                ax.MajorUnit = 3;
                ax.TimeUnit  = TimeUnits.Month;
                break;
            }
            MyDateTimeGroupProvider mtgp = flexChart.AxisX.GroupProvider as MyDateTimeGroupProvider;

            if (mtgp != null)
            {
                mtgp.GroupTypes.Clear();               // reset automatic calculation.
            }
        }