Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CustomAxisLabelCollection coll = ((XYDiagram)this.chartControl1.Diagram).AxisX.CustomLabels;

            coll[0].Name = DateTime.Today.DayOfWeek.ToString();
            coll[1].Name = DateTime.Today.AddDays(4).DayOfWeek.ToString();
        }
Example #2
0
        // 根据交易时段设置label
        public static void SetCustomLabel(ChartControl chartControl, DataRow[] drSegment)
        {
            XYDiagram diagram = (XYDiagram)chartControl.Diagram;

            diagram.AxisX.WholeRange.SetMinMaxValues((String)drSegment[0]["BeginTime"], (String)drSegment[drSegment.Length - 1]["EndTime"]);
            diagram.AxisX.VisualRange.SetMinMaxValues((String)drSegment[0]["BeginTime"], (String)drSegment[drSegment.Length - 1]["EndTime"]);

            String dt = DateTime.Now.ToString("yyyyMMdd");

            DateTime dtCur = DateTime.ParseExact(dt + (String)drSegment[0]["BeginTime"], "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);

            dtCur = dtCur.AddDays((long)drSegment[0]["BeginDay"]);

            CustomAxisLabelCollection labels = diagram.AxisX.CustomLabels;

            for (int i = 0; i < drSegment.Length; i++)
            {
                DateTime dtBegin = DateTime.ParseExact(dt + (String)drSegment[i]["BeginTime"], "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);
                dtBegin = dtBegin.AddDays((long)drSegment[i]["BeginDay"]);
                DateTime dtEnd = DateTime.ParseExact(dt + (String)drSegment[i]["EndTime"], "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);
                dtEnd = dtEnd.AddDays((long)drSegment[i]["EndDay"]);

                if (dtCur < dtBegin)
                {
                    if (i == 0)
                    {
                        dtCur = dtBegin;
                    }
                    else if (dtBegin.Hour == 10)
                    {
                        dtCur = dtBegin.AddMinutes(15);
                    }
                    else
                    {
                        dtCur = dtBegin.AddMinutes(30);
                    }
                }

                while (dtCur <= dtEnd)
                {
                    String          strLabel = dtCur.ToString("HH:mm");
                    CustomAxisLabel onelabel = new CustomAxisLabel();
                    onelabel.AxisValue = strLabel;
                    onelabel.Name      = strLabel;
                    labels.Add(onelabel);

                    dtCur = dtCur.AddMinutes(30);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the Visifire.Charts.CustomAxisLabels class
        /// </summary>
        public CustomAxisLabels()
        {
            // Apply default style from generic
#if WPF
            if (!_defaultStyleKeyApplied)
            {
                DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomAxisLabels), new FrameworkPropertyMetadata(typeof(CustomAxisLabels)));
                _defaultStyleKeyApplied = true;

            }
#else
            DefaultStyleKey = typeof(CustomAxisLabels);
#endif

            WidthOfACharacter = Double.NaN;
            InternalAngle = Double.NaN;
            _tag = new ElementData() { Element = this };

            // Initialize CustomAxisLabels list
            Labels = new CustomAxisLabelCollection();

            Labels.CollectionChanged += new NotifyCollectionChangedEventHandler(Labels_CollectionChanged);
        }