Beispiel #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string res = null;

            if (value is string)
            {
                DateTime labelValue = System.Convert.ToDateTime(value.ToString());
                if (parameter.ToString().Equals("0"))
                {
                    res = labelValue.ToString("hh:mm:ss");
                }
                else
                {
                    res = labelValue.ToString("dd/MM");
                }
            }
            else
            {
                ChartAxisLabel axlabel    = value as ChartAxisLabel;
                DateTime       labelValue = System.Convert.ToDateTime(axlabel.LabelContent.ToString());

                if (parameter.ToString().Equals("0"))
                {
                    res = labelValue.ToString("hh:mm:ss");
                }
                else
                {
                    res = labelValue.ToString("dd/MM");
                }
            }
            return(res);
        }
Beispiel #2
0
        private void NumericalAxis_ActualRangeChanged(object sender, Syncfusion.UI.Xaml.Charts.ActualRangeChangedEventArgs e)

        {
            var axis = sender as NumericalAxis;

            //Gets the collection of visible labels.

            var labels = axis.VisibleLabels;

            if (labels != null)

            {
                if (axis.CustomLabels.Count > 0)
                {
                    axis.CustomLabels.Clear();
                }

                //To add the custom labels based on the position of visible labels.

                for (int index = 0; index < labels.Count; index++)

                {
                    var axisLabel = new ChartAxisLabel()

                    {
                        Position = labels[index].Position,//To set the position where the custom label should be placed.

                        //LabelContent = index//To set the content from which labels are to be taken.
                    };
                    axis.CustomLabels.Add(axisLabel);
                }
            }
        }
Beispiel #3
0
        internal static void GenerateScaleBreakVisibleLabels(NumericalAxis axis, object actualInterval, double smallTicksPerInterval)
        {
            var ranges = axis != null ? axis.AxisRanges : null;

            if (ranges == null || ranges.Count == 0)
            {
                GenerateVisibleLabels(axis, axis.Minimum, axis.Maximum, axis.Interval, axis.SmallTicksPerInterval);
            }
            else
            {
                for (int i = 0; i < ranges.Count; i++)
                {
                    var position = ranges[i].Start;
                    var interval = axis.CalculateActualInterval(
                        ranges[i],
                        axis.Orientation == Orientation.Vertical
                        ? new Size(axis.AvailableSize.Width, axis.AxisLength[i])
                            : new Size(axis.AxisLength[i], axis.AvailableSize.Height));

                    if (!ranges[i].Inside(position))
                    {
                        continue;
                    }

                    for (; position <= ranges[i].End; position += interval)
                    {
                        axis.VisibleLabels.Add(new ChartAxisLabel(position, axis.GetActualLabelContent(position), position));
                        if (ranges[i].Delta == 0)
                        {
                            break;
                        }
                        if (axis.smallTicksRequired)
                        {
                            axis.AddSmallTicksPoint(position, interval);
                        }
                    }

                    if (ranges[i].End.Equals(position - interval))
                    {
                        continue;
                    }
                    var count     = axis.VisibleLabels.Count;
                    var lastLabel = new ChartAxisLabel();
                    lastLabel.Position     = ranges[i].End;
                    lastLabel.LabelContent = axis.GetActualLabelContent(ranges[i].End);
                    if (Convert.ToDouble(axis.VisibleLabels[count - 1].LabelContent) != ranges[i].End)
                    {
                        axis.VisibleLabels.Add(lastLabel);
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Converts a value from bool to Visibility.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// A converted value. If the method returns null, the valid null value is used.
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ChartAxisLabel x = value as ChartAxisLabel;

            if (x != null)
            {
                double v = System.Convert.ToDouble(x.LabelContent);
                return(Math.Round(v / 100000, 1));
            }
            else
            {
                return(true);
            }
        }
Beispiel #5
0
        private void DrawChart(DataTable dt, int index)
        {
            try
            {
                ChartSeries series = new ChartSeries();
                series.Type = ChartSeriesType.Line;

                chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
                chartControl1.PrimaryXAxis.Labels.Clear();
                chartControl1.PrimaryXAxis.LabelRotate = true;
                chartControl1.PrimaryXAxis.LabelRotateAngle = 90;
                chartControl1.PrimaryXAxis.AutoSize = true;
                chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;

                chartControl1.PrimaryYAxis.AutoSize = false;
                chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
                chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Auto;

                Color[] color1 = new Color[] { Color.Yellow };
                Color[] color2 = new Color[] { Color.DarkOrange };

                if (index == MAXSERIES)
                {
                    series.Style.Interior = new BrushInfo(GradientStyle.Horizontal, color1);
                    series.Style.Border.Width = 3;
                }
                else
                {
                    series.Style.Interior = new BrushInfo(GradientStyle.Horizontal, color2);
                    series.Style.Border.Width = 1;
                }

                int i = 0;
                double minval = 0;
                double maxval = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    double d = Convert.ToDouble(dr["fb(t)"]);
                    if (i == 0)
                    {
                        minval = d;
                        maxval = d;
                    }
                    else
                    {
                        minval = d < minval ? d : minval;
                        maxval = d > maxval ? d : maxval;
                    }

                    ChartAxisLabel label = new ChartAxisLabel(
                        dr["Tenor"].ToString(),
                        Color.White,
                        new Font("Verdana", 8),
                        i,
                        "",
                        ChartValueType.Custom);

                    chartControl1.PrimaryXAxis.Labels.Add(label);
                    series.Points.Add(i++, d);
                }

                //chartControl1.PrimaryYAxis.Range.Min = minval * .95;
                //chartControl1.PrimaryYAxis.Range.Max = maxval * 1.05;
                chartControl1.PrimaryYAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.BothUserAndAutomaticMode;
                chartControl1.PrimaryYAxis.DesiredIntervals = 7;

                txtTimestamp.Text = String.Format("Last Update: {0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());

                chartControl1.Series.Add(series);
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }