private void OnClosestDataPointChanged(CategoricalDataPoint dataPoint)
 {
     if (this.ClosestDataPointChanged != null)
     {
         this.ClosestDataPointChanged(this, new DataPointEventArgs(dataPoint));
     }
 }
        void PerformanceChart_Loaded(object sender, RoutedEventArgs e)
        {
            if (radChart.DataContext != null)
            {
                Employee employee = (Employee)radChart.DataContext;

                if (radChart.Series.Count == 0)
                {
					radChart.HorizontalAxis = new DateTimeCategoricalAxis () { LabelFormat = "dd/MM" };
					radChart.VerticalAxis = new LinearAxis() { LabelFormat = "C0" };


                    IEnumerable<Order> orders = (from o in employee.Orders
                                                  orderby o.OrderDate
                                                  select o).Skip(employee.Orders.Count() - 10);

					BarSeries series = new BarSeries();

                    foreach (Order order in orders)
                    {
                        CategoricalDataPoint dataPoint = new CategoricalDataPoint();
                        dataPoint.Value = (from orderDetail in order.Details
                                                     select orderDetail.Quantity * orderDetail.UnitPrice *
                                                         (1 - orderDetail.Discount)).Sum();
						dataPoint.Category = order.OrderDate;
                        series.DataPoints.Add(dataPoint);
                    }

                    radChart.Series.Add(series);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="chartDataContext"></param>
        /// <returns></returns>
        private Axis CreateContext(ChartDataContext chartDataContext)
        {
            CategoricalDataPoint DataPoint = (CategoricalDataPoint)chartDataContext.ClosestDataPoint.DataPoint;

            return(new Axis()
            {
                X = (DateTime)DataPoint.Category,
                Y = (double)DataPoint.Value
            });
        }
 private void DataPointSelectionChanged(object sender, EventArgs e)
 {
     if ((sender as ChartSelectionBehavior).SelectedPoints.Count <DataPoint>() > 0)
     {
         CategoricalDataPoint selectedPoint = (sender as ChartSelectionBehavior).SelectedPoints.First() as CategoricalDataPoint;
         textblock1.Text = String.Format("The value of the Selected Point is : {0}", selectedPoint.Value);
         textblock2.Text = String.Format("The category of the Selected Point is : {0}", selectedPoint.Category);
         textblock3.Text = String.Format("Show information stored in a property from our model : {0}", (selectedPoint.DataItem as CustomPoint).CustomProperty);
     }
 }
Exemple #5
0
        private void QuintileChart_SelectionChanged(object sender, Telerik.Windows.Controls.ChartView.ChartSelectionChangedEventArgs e)
        {
            bool changedInfo = false;

            //Handle selection of the current point
            if (e.AddedPoints.Count > 0)
            {
                var addedPoint = e.AddedPoints[0];
                var series     = addedPoint.Presenter as LineSeries;

                //Get the Content Presenter of the series
                var pointPresenter = series.
                                     ChildrenOfType <ContentPresenter>().
                                     Where(cp => cp.Tag == addedPoint).FirstOrDefault();
                var ellipseElement = pointPresenter.
                                     ChildrenOfType <Ellipse>().FirstOrDefault();

                //Do whatever you want with it :)
                ellipseElement.Fill = new SolidColorBrush(Colors.Red);
                CategoricalDataPoint point = pointPresenter.Content as CategoricalDataPoint;
                this.Date.Text   = point.Category.ToString();
                this.Valeur.Text = point.Value.ToString();
                changedInfo      = true;
            }

            //Handle de-selection of the current point
            if (e.RemovedPoints.Count > 0)
            {
                var removedPoint = e.RemovedPoints[0];
                var series       = removedPoint.Presenter as LineSeries;
                if (series == null)
                {
                    return;
                }
                var pointPresenter = series.
                                     ChildrenOfType <ContentPresenter>().
                                     Where(cp => cp.Tag == removedPoint).FirstOrDefault();
                if (pointPresenter == null)
                {
                    return;
                }

                var ellipseElement = pointPresenter.
                                     ChildrenOfType <Ellipse>().FirstOrDefault();

                //Do whatever you want with it :)
                ellipseElement.Fill = new SolidColorBrush(Colors.DarkGreen);
                if (!changedInfo)
                {
                    this.Date.Text   = "";
                    this.Valeur.Text = "";
                }
            }
        }
Exemple #6
0
        private void OnCurrentPlotTrackUpdated(object sender, TrackBallInfoEventArgs e)
        {
            if (e.Context.DataPointInfos.Count == 2)
            {
                CategoricalDataPoint dp = e.Context.DataPointInfos[0].DataPoint as CategoricalDataPoint;
                this.txtTime.Text       = ((DateTime)dp.Category).ToString("HH:mm:ss");
                this.txtBatCurrent.Text = ((double)dp.Value).ToString("F3");

                dp = e.Context.DataPointInfos[1].DataPoint as CategoricalDataPoint;
                this.txtVoltage.Text = ((double)dp.Value).ToString("F2");
            }
        }
 private StaticLayout CreateTextInfo(string labelText, CategoricalDataPoint dataPoint)
 {
     return(new StaticLayout(labelText,
                             0,
                             labelText.Length,
                             paint,
                             (int)Math.Round((float)dataPoint.LayoutSlot.Width),
                             Layout.Alignment.AlignCenter,
                             1.0f,
                             1.0f,
                             false));
 }
Exemple #8
0
        public void ResultChartAddSeries(List<ResultData> listdata)
        {
            
            
                CategoricalSeries series = Activator.CreateInstance(typeof(LineSeries)) as CategoricalSeries;

                series.CategoryBinding = new PropertyNameDataPointBinding("Category");
                series.ValueBinding = new PropertyNameDataPointBinding("Value");
                series.Name = listdata[0].ResultName;
                series.Tag = listdata[0].OrderName;
                this.chart.VerticalAxis.ShowLabels = false;
                this.chart.HorizontalAxis.Margin = new Thickness(10, 5, 5, 10);

                ChartSeriesLabelDefinition csld = new ChartSeriesLabelDefinition();
            
         
                csld.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;
                csld.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
                csld.Template = CreateScatterDataLabelTemplate();

                series.LabelDefinitions.Add(csld);
                ResultData[] rdArray = null;
                rdArray = new ResultData[listdata.Count()];

                listdata.CopyTo(rdArray);

                for (int b = 0; b < rdArray.Length; b++)
                {
                    CategoricalDataPoint cdp = new CategoricalDataPoint();

                    cdp.Category = rdArray[b].Category;
                    cdp.Value = (double)rdArray[b].Value;
                    
                    cdp.Label = rdArray[b].ResultDisplayValue;
                   
                    series.DataPoints.Add(cdp);
                   
                }
          
                this.chart.Series.Add(series);

                ChartLegend leg = new ChartLegend();
                leg.ChartControl = this.chart;

                leg.BrushColor = chart.Palette.GetBrush(chart.Series.Count - 1, PaletteVisualPart.Stroke);
                leg.Text = listdata[0].ResultName + "\r\n" + listdata[0].ResultUnits;
                leg.SeriesName = series.Name;
                leg.ChartTitleParent = this.stackTitle;
                leg.StackPanelParent = this.legend;
                this.legend.Children.Add(leg);
          
           
        }
Exemple #9
0
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            CategoricalDataPoint dataPoint = item as CategoricalDataPoint;

            if (dataPoint.Value > 17)
            {
                return(this.FirstTemplate);
            }
            else
            {
                return(this.SecondTemplate);
            }
        }
        private void ChartTrackBallBehavior_TrackInfoUpdated(object sender, Telerik.Windows.Controls.TrackBallInfoEventArgs e)
        {
            DateTime date = DateTime.Now;

            foreach (DataPointInfo info in e.Context.DataPointInfos)
            {
                CategoricalDataPoint dataPoint = info.DataPoint as CategoricalDataPoint;
                date = (DateTime)dataPoint.Category;
                info.DisplayHeader  = info.Series.DisplayName + ": ";
                info.DisplayContent = dataPoint.Value * 1000;
            }
            e.Header = date.ToString("MMMM-yyyy");
        }
Exemple #11
0
 private void DataPointSelectionChanged(object sender, EventArgs e)
 {
     if ((sender as ChartSelectionBehavior).SelectedPoints.Count <DataPoint>() > 0)
     {
         CategoricalDataPoint selectedPoint = (sender as ChartSelectionBehavior).SelectedPoints.First() as CategoricalDataPoint;
         textblock1.Text = string.Format("The selected point value is : {0}", selectedPoint.Value);
         textblock2.Text = string.Format("The selected point category is : {0}", selectedPoint.Category);
         textblock3.Text = string.Format("View model property value: {0}", (selectedPoint.DataItem as CustomPointSelection).CustomProperty);
     }
     else
     {
         textblock1.Text = "No point selected";
         textblock2.Text = "No point selected";
         textblock3.Text = "No point selected";
     }
 }
        private void Display()
        {
            Cursor = Cursors.WaitCursor;

            var distribution = new PoissonDistribution().GetNormalizedValues(_threadCount);

            // Get the time delta between each sample point.
            var delta = TimeSpan.FromTicks(_duration.Ticks / (distribution.Count() - 1));

            _barSeries.DataPoints.Clear();

            for (int i = 0; i < distribution.Count(); i++)
            {
                var time      = TimeSpan.FromSeconds(delta.TotalSeconds * i);
                var dataPoint = new CategoricalDataPoint(distribution.ElementAt(i), time.ToString(@"hh\:mm\:ss"));
                _barSeries.DataPoints.Add(dataPoint);
            }

            Cursor = Cursors.Default;
        }
        void PerformanceChart_Loaded(object sender, RoutedEventArgs e)
        {
            if (radChart.DataContext != null)
            {
                Employee employee = (Employee)radChart.DataContext;

                if (radChart.Series.Count == 0)
                {
                    radChart.HorizontalAxis = new DateTimeCategoricalAxis()
                    {
                        LabelFormat = "dd/MM"
                    };
                    radChart.VerticalAxis = new LinearAxis()
                    {
                        LabelFormat = "C0"
                    };


                    IEnumerable <Order> orders = (from o in employee.Orders
                                                  orderby o.OrderDate
                                                  select o).Skip(employee.Orders.Count() - 10);

                    BarSeries series = new BarSeries();

                    foreach (Order order in orders)
                    {
                        CategoricalDataPoint dataPoint = new CategoricalDataPoint();
                        dataPoint.Value = (from orderDetail in order.Details
                                           select orderDetail.Quantity * orderDetail.UnitPrice *
                                           (1 - orderDetail.Discount)).Sum();
                        dataPoint.Category = order.OrderDate;
                        series.DataPoints.Add(dataPoint);
                    }

                    radChart.Series.Add(series);
                }
            }
        }
Exemple #14
0
        private void InitializeBarChart()
        {
            CategoricalDataPoint point;
            BarSeries            barSeries;
            CartesianArea        area = this.radChartView1.GetArea <CartesianArea>();
            CartesianGrid        grid = area.GetGrid <CartesianGrid>();

            grid.ForeColor             = Color.FromArgb(235, 235, 235);
            grid.DrawVerticalStripes   = false;
            grid.DrawHorizontalStripes = true;
            grid.DrawHorizontalFills   = false;
            grid.DrawVerticalFills     = false;
            area.ShowGrid = true;

            for (int i = 0; i < barSeriesValues.Length; i++)
            {
                barSeries = new BarSeries();
                point     = new CategoricalDataPoint(barSeriesValues[i], "May 2012");
                barSeries.DataPoints.Add(point);
                area.Series.Add(barSeries);
            }

            this.radChartView1.View.Margin = new Padding(0, 0, 30, 0);
        }
Exemple #15
0
        /// <summary>
        /// 初始化Bar
        /// </summary>
        private void InitializeBar(List <KeyValuePair <double, object> > data)
        {
            this.rcv_top.AreaType = ChartAreaType.Cartesian;
            this.rcv_top.ShowGrid = true;
            this.rcv_top.ChartElement.View.ForeColor = Color.White;
            if (data.Count == 0)
            {
                data.Add(new KeyValuePair <double, object>(0, ""));
            }
            foreach (KeyValuePair <double, object> dataItem in data)
            {
                BarSeries bar = new BarSeries();
                //bar.ShowLabels = true;
                bar.LegendTitle = Transformation(dataItem.Value.ToString());
                bar.ForeColor   = Color.White;

                CategoricalDataPoint point = new CategoricalDataPoint(dataItem.Key, dataItem.Value);
                point.Label = string.Format("{0:P2} - {1}", point.Value / 100, point.Category);
                bar.DataPoints.Add(point);

                this.rcv_top.Series.Add(bar);
            }
            this.rcv_top.Axes[0].LabelFitMode = AxisLabelFitMode.MultiLine;
        }
Exemple #16
0
        private void InitializeBar()
        {
            this.radChartView1.AreaType = ChartAreaType.Cartesian;
            this.radChartView2.AreaType = ChartAreaType.Cartesian;

            this.radChartView1.ShowGrid = true;
            this.radChartView2.ShowGrid = true;

            foreach (KeyValuePair <double, object> dataItem in this.data.GetBarData())
            {
                BarSeries bar = new BarSeries();
                bar.ShowLabels             = true;
                bar.LegendTitle            = dataItem.Value.ToString();
                bar.DrawLinesToLabels      = this.radCheckBox1.Checked;
                bar.SyncLinesToLabelsColor = this.radCheckBox3.Checked;

                BarSeries smartBar = new BarSeries();
                smartBar.ShowLabels        = true;
                smartBar.LegendTitle       = dataItem.Value.ToString();
                smartBar.DrawLinesToLabels = this.radCheckBox1.Checked;

                CategoricalDataPoint point = new CategoricalDataPoint(dataItem.Key, dataItem.Value);
                point.Label = string.Format("{0:P2} - {1}", point.Value / 100, point.Category);
                bar.DataPoints.Add(point);

                point       = new CategoricalDataPoint(dataItem.Key, dataItem.Value);
                point.Label = string.Format("{0:P2} - {1}", point.Value / 100, point.Category);
                smartBar.DataPoints.Add(point);

                this.radChartView1.Series.Add(bar);
                this.radChartView2.Series.Add(smartBar);
            }

            this.radChartView1.Axes[0].LabelFitMode = AxisLabelFitMode.MultiLine;
            this.radChartView2.Axes[0].LabelFitMode = AxisLabelFitMode.MultiLine;
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            CategoricalDataPoint dataPoint = item as CategoricalDataPoint;
            RankDateChart        point     = dataPoint?.DataItem as RankDateChart;

            if (point != null)
            {
                switch (point.WinStatus)
                {
                case 1:
                case 2:
                    return(WinTemplate);

                case -1:
                case -2:
                    return(LostTemplate);

                case 0:
                    return(DrawTemplate);
                }
            }

            return(LostTemplate);
        }
Exemple #18
0
 private static void AddIntersectionPoint(RadCartesianChart chart, DataTemplate intersectionPointTemplate, CategoricalDataPoint dataPoint)
 {
     CartesianCustomAnnotation annotation = new CartesianCustomAnnotation();
     annotation.ContentTemplate = intersectionPointTemplate;
     annotation.HorizontalValue = dataPoint.Category;
     annotation.VerticalValue = dataPoint.Value;
     annotation.Tag = typeof(ChartUtilities);
     chart.Annotations.Add(annotation);
 }
        private void ChartTrackBallBehavior_TrackInfoUpdated(object sender, TrackBallInfoEventArgs e)
        {
            CategoricalDataPoint closestDataPoint = e.Context.ClosestDataPoint.DataPoint as CategoricalDataPoint;

            this.OnClosestDataPointChanged(closestDataPoint);
        }
Exemple #20
0
        private void InitializeLine()
        {
            this.radChartView1.AreaType = ChartAreaType.Cartesian;
            this.radChartView2.AreaType = ChartAreaType.Cartesian;

            LineSeries line = new LineSeries();

            line.ShowLabels             = true;
            line.LegendTitle            = "Desktop Internet users";
            line.DrawLinesToLabels      = this.radCheckBox1.Checked;
            line.SyncLinesToLabelsColor = this.radCheckBox3.Checked;

            LineSeries smartLine = new LineSeries();

            smartLine.ShowLabels             = true;
            smartLine.LegendTitle            = "Desktop Internet users";
            smartLine.DrawLinesToLabels      = this.radCheckBox1.Checked;
            smartLine.SyncLinesToLabelsColor = this.radCheckBox3.Checked;

            foreach (KeyValuePair <double, object> dataItem in this.data.GetLineOneData())
            {
                CategoricalDataPoint point = new CategoricalDataPoint(dataItem.Key, dataItem.Value);
                point.Label = point.Value;
                line.DataPoints.Add(point);

                point       = new CategoricalDataPoint(dataItem.Key, dataItem.Value);
                point.Label = point.Value;
                smartLine.DataPoints.Add(point);
            }

            LineSeries line2 = new LineSeries();

            line2.ShowLabels             = true;
            line2.LegendTitle            = "Desktop Internet users";
            line2.DrawLinesToLabels      = this.radCheckBox1.Checked;
            line2.SyncLinesToLabelsColor = this.radCheckBox3.Checked;

            LineSeries smartLine2 = new LineSeries();

            smartLine2.ShowLabels             = true;
            smartLine2.LegendTitle            = "Desktop Internet users";
            smartLine2.DrawLinesToLabels      = this.radCheckBox1.Checked;
            smartLine2.SyncLinesToLabelsColor = this.radCheckBox3.Checked;

            foreach (KeyValuePair <double, object> dataItem in this.data.GetLineTwoData())
            {
                CategoricalDataPoint point = new CategoricalDataPoint(dataItem.Key, dataItem.Value);
                point.Label = point.Value;
                line2.DataPoints.Add(point);

                point       = new CategoricalDataPoint(dataItem.Key, dataItem.Value);
                point.Label = point.Value;
                smartLine2.DataPoints.Add(point);
            }

            this.radChartView1.Series.Add(line);
            this.radChartView1.Series.Add(line2);

            this.radChartView2.Series.Add(smartLine);
            this.radChartView2.Series.Add(smartLine2);
        }
 public DataPointEventArgs(CategoricalDataPoint dataPoint)
 {
     this._dataPoint = dataPoint;
 }
        private static void AddIntersectionPoint(RadCartesianChart chart, DataTemplate intersectionPointTemplate, CategoricalDataPoint dataPoint)
        {
            CartesianCustomAnnotation annotation = new CartesianCustomAnnotation();

            annotation.ContentTemplate = intersectionPointTemplate;
            annotation.HorizontalValue = dataPoint.Category;
            annotation.VerticalValue   = dataPoint.Value;
            annotation.Tag             = typeof(ChartUtilities);
            chart.Annotations.Add(annotation);
        }