Пример #1
0
        public BaseChart()
        {
            Background     = new SolidColorBrush(Colors.White);
            VerticalAxis   = new LinearAxis();
            HorizontalAxis = new CategoricalAxis
            {
                SmartLabelsMode    = AxisSmartLabelsMode.SmartStep,
                LabelFitMode       = AxisLabelFitMode.Rotate,
                LabelRotationAngle = 270
            };

            ChartTrackBallBehavior chartTrackBallBehavior = new ChartTrackBallBehavior
            {
                ShowIntersectionPoints = true,
                ShowTrackInfo          = true,
            };
            //System.Windows.Point position = chartTrackBallBehavior.Position;
            //position.X = (23);
            //position.Y = (45);

            //chartTrackBallBehavior.Position = position;


            ChartPanAndZoomBehavior panAndZoomBehavior = new ChartPanAndZoomBehavior
            {
                ZoomMode = ChartPanZoomMode.Both,
                PanMode  = ChartPanZoomMode.Both
            };

            Behaviors.Add(panAndZoomBehavior);
            Behaviors.Add(chartTrackBallBehavior);
        }
Пример #2
0
        private void AppBarToggleButton_Checked(object sender, RoutedEventArgs e)
        {
            ChartTrackBallBehavior behavior = new ChartTrackBallBehavior();

            lineChart.Behaviors.Add(behavior);
            lineChart.PrimaryAxis.ShowTrackBallInfo = true;
        }
		private RadCartesianChartView createChart(){
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat= "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			chart.VerticalAxis = verticalAxis;
			chart.HorizontalAxis = horizontalAxis;


			for (int i = 0; i < 3; i++) {
				//Create the bar series and attach axes and value bindings.
				AreaSeries areaSeries = new AreaSeries();

				//We want to stack the different area series.
				areaSeries.CombineMode = ChartSeriesCombineMode.Stack;

				areaSeries.ValueBinding = new ValueBinding();
				areaSeries.CategoryBinding = new CategoryBinding();

				//Bind series to data
				areaSeries.Data = this.getData();

				//Add series to chart
				chart.Series.Add(areaSeries);
			}

			ChartTrackBallBehavior tbBehavior = new ChartTrackBallBehavior(this.Activity);
			tbBehavior.ShowIntersectionPoints = true;
			chart.Behaviors.Add(tbBehavior);

			return chart;
		}
Пример #4
0
        public static void MoveTrackBall(ChartTrackBallBehavior behav, NavigateDirection direction)
        {
            var chart = (RadCartesianChart)behav.Chart;
            object currentXCategory = null;
            if (chart.PlotAreaClip.X <= behav.Position.X && behav.Position.X <= chart.PlotAreaClip.Right)
            {
                currentXCategory = chart.ConvertPointToData(behav.Position).FirstValue;
            }

            Func<int, int> next = GetPositionXFunction(direction);
            object adjacentXCategory = null;
            int startX = GetCoercedPositionX(behav);
            for (int x = startX; chart.PlotAreaClip.X <= x && x <= chart.PlotAreaClip.Right; x = next(x))
            {
                DataTuple tuple = chart.ConvertPointToData(new Point(x, 0));
                if (!object.Equals(currentXCategory, tuple.FirstValue))
                {
                    adjacentXCategory = tuple.FirstValue;
                    break;
                }
            }

            var adjacentPosition = chart.ConvertDataToPoint(new DataTuple(adjacentXCategory, null));
            adjacentPosition.Y = behav.Chart.ActualHeight / 2;

            behav.Position = adjacentPosition;
        }
Пример #5
0
        public static void MoveTrackBall(ChartTrackBallBehavior behav, NavigateDirection direction)
        {
            var    chart            = (RadCartesianChart)behav.Chart;
            object currentXCategory = null;

            if (chart.PlotAreaClip.X <= behav.Position.X && behav.Position.X <= chart.PlotAreaClip.Right)
            {
                currentXCategory = chart.ConvertPointToData(behav.Position).FirstValue;
            }

            Func <int, int> next = GetPositionXFunction(direction);
            object          adjacentXCategory = null;
            int             startX            = GetCoercedPositionX(behav);

            for (int x = startX; chart.PlotAreaClip.X <= x && x <= chart.PlotAreaClip.Right; x = next(x))
            {
                DataTuple tuple = chart.ConvertPointToData(new Point(x, 0));
                if (!object.Equals(currentXCategory, tuple.FirstValue))
                {
                    adjacentXCategory = tuple.FirstValue;
                    break;
                }
            }

            var adjacentPosition = chart.ConvertDataToPoint(new DataTuple(adjacentXCategory, null));

            adjacentPosition.Y = behav.Chart.ActualHeight / 2;

            behav.Position = adjacentPosition;
        }
Пример #6
0
        public FastChartDemo()
        {
            viewModel = new ViewModel();
            this.InitializeComponent();

            // Since the control is placed in a list view. The grid's manipulation has to be checked for good interactive behavior support.
            if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
            {
                this.grid.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
            }

            tackballBehavior = new ChartTrackBallBehavior()
            {
                ShowLine = false, UseSeriesPalette = true
            };

            if (AnalyticsInfo.VersionInfo.DeviceFamily != "Windows.Mobile")
            {
                OHLCBitXAML.SetValue(ChartTooltip.VerticalAlignmentProperty, VerticalAlignment.Top);
                OHLCBitXAML.SetValue(ChartTooltip.VerticalOffsetProperty, size);

                FBitMapXAML.SetValue(ChartTooltip.VerticalAlignmentProperty, VerticalAlignment.Top);
                FBitMapXAML.SetValue(ChartTooltip.VerticalOffsetProperty, size);
            }
        }
Пример #7
0
        private static void TrackBallGroupChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
        {
            ChartTrackBallBehavior behavior = (ChartTrackBallBehavior)target;

            string oldGroup = (string)args.OldValue;

            if (oldGroup != null)
            {
                behavior.TrackInfoUpdated -= behavior_TrackInfoUpdated;
                RemoveReference(trackBallGroupToBehaviorsDict[oldGroup], behavior);
                if (trackBallGroupToBehaviorsDict[oldGroup].Count == 0)
                {
                    trackBallGroupToBehaviorsDict.Remove(oldGroup);
                }
            }

            string newGroup = (string)args.NewValue;

            if (newGroup != null)
            {
                if (!trackBallGroupToBehaviorsDict.ContainsKey(newGroup))
                {
                    trackBallGroupToBehaviorsDict[newGroup] = new List <WeakReference>();
                }
                trackBallGroupToBehaviorsDict[newGroup].Add(new WeakReference(behavior));
                behavior.TrackInfoUpdated += behavior_TrackInfoUpdated;
            }
        }
Пример #8
0
        private static int GetCoercedPositionX(ChartTrackBallBehavior behav)
        {
            var    chart     = (RadCartesianChart)behav.Chart;
            double positionX = double.IsNaN(behav.Position.X) ? chart.PlotAreaClip.X : behav.Position.X;
            int    coercedX  = (int)Math.Max(chart.PlotAreaClip.X, Math.Min(chart.PlotAreaClip.Right, positionX));

            return(coercedX);
        }
Пример #9
0
        private static void behavior_PositionChanging(object sender, TrackBallPositionChangingEventArgs e)
        {
            ChartTrackBallBehavior behav = (ChartTrackBallBehavior)sender;
            Point pos = new Point(e.NewPosition.X - behav.Chart.PanOffset.X, e.NewPosition.Y - behav.Chart.PanOffset.Y);

            if (!behav.Chart.PlotAreaClip.Contains(pos.X, pos.Y))
            {
                e.NewPosition = e.PreviousPosition;
            }
        }
Пример #10
0
        private static void MoveTrackBallsSafe(string p, object xCategory, ChartTrackBallBehavior behavior)
        {
            moveTrackBallsCallsCount++;

            // Avoid a cycle when different categories are found due to precision.
            if (moveTrackBallsCallsCount < 20)
            {
                MoveTrackBalls(GetTrackBallGroup(behavior), xCategory, behavior);
            }

            moveTrackBallsCallsCount--;
        }
Пример #11
0
        private static void TrackBallStaysOnMouseLeaveChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
        {
            ChartTrackBallBehavior behavior = (ChartTrackBallBehavior)target;

            if ((bool)args.NewValue)
            {
                behavior.PositionChanging += behavior_PositionChanging;
            }
            else
            {
                behavior.PositionChanging -= behavior_PositionChanging;
            }
        }
Пример #12
0
        private static void behavior_TrackInfoUpdated(object sender, TrackBallInfoEventArgs e)
        {
            ChartTrackBallBehavior behavior = (ChartTrackBallBehavior)sender;
            var    chart     = (RadCartesianChart)behavior.Chart;
            object xCategory = null;

            if (e.Context.DataPointInfos.Count != 0)
            {
                var center    = e.Context.DataPointInfos[0].DataPoint.LayoutSlot.Center;
                var dataTuple = chart.ConvertPointToData(new Point(center.X + chart.PanOffset.X, center.Y));
                xCategory = dataTuple.FirstValue;
            }
            MoveTrackBallsSafe(GetTrackBallGroup(behavior), xCategory, behavior);
        }
Пример #13
0
        private static void MoveTrackBalls(string group, object xCategory, ChartTrackBallBehavior behaviorOriginator)
        {
            foreach (var behav in GetLiveInstances <ChartTrackBallBehavior>(trackBallGroupToBehaviorsDict[group]))
            {
                if (behav != behaviorOriginator)
                {
                    var chart    = (RadCartesianChart)behav.Chart;
                    var position = chart.ConvertDataToPoint(new DataTuple(xCategory, null));
                    position.Y = chart.ActualHeight / 2;

                    behav.Position = position;
                }
            }
        }
Пример #14
0
        private static void MoveTrackBalls(string group, object xCategory, ChartTrackBallBehavior behaviorOriginator)
        {
            foreach (var wr in groupToBehaviorsDict[group])
            {
                var behav = wr.Target as ChartTrackBallBehavior;
                if (behav != null && behav != behaviorOriginator)
                {
                    var chart    = (RadCartesianChart)behav.Chart;
                    var position = chart.ConvertDataToPoint(new DataTuple(xCategory, null));
                    position.Y = chart.ActualHeight / 2;

                    behav.Position = position;
                }
            }
            CleanUp(groupToBehaviorsDict[group]);
        }
        private void Indicators_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Any())
            {
                var indicator = (e.AddedItems[0] as ComboBoxItem).DataContext as IndicatorBase;

                if (indicator != null)
                {
                    // ConfigureAxis(BottomChart, indicator);
                    Chart.Indicators.Clear();
                    Chart.Indicators.Add(indicator);
                    var template = LayoutRoot.Resources["EmptyTemplate"] as DataTemplate;

                    ChartTrackBallBehavior.SetTrackInfoTemplate(indicator, template);
                }
            }
        }
Пример #16
0
        public MainWindow()
        {
            InitializeComponent();
            DisableDates(dpStart);
            DisableDates(dpExpiration);

            symbolBox.ItemsSource = data.GetSymbolList();

            Random rnd         = new Random();
            string randomStock = ((List <string>)symbolBox.ItemsSource)[rnd.Next(((List <string>)symbolBox.ItemsSource).Count)];
            Run    name        = new Run();

            name.FontSize = 28;
            name.Text     = randomStock;

            lblInfo.Text = "Stock symbol highlight:\n";
            lblInfo.Inlines.Add(name);

            ChartTrackBallBehavior trackBall = new ChartTrackBallBehavior();

            mainChart.Behaviors.Add(trackBall);
            primaryMain.EnableAutoIntervalOnZooming   = true;
            primaryMain.ShowTrackBallInfo             = true;
            secondaryMain.EnableAutoIntervalOnZooming = true;

            ChartZoomPanBehavior zooming = new ChartZoomPanBehavior();

            mainChart.Behaviors.Add(zooming);

            LineSeries stockPriceSeries = graphs.MakeLineSeries("stockPriceSeries", data.GetStockPrices(randomStock, DateTime.Parse("1/1/2017"), DateTime.Parse("12/31/2017")));

            mainChart.Series.Add(stockPriceSeries);

            graphs.SetNavigator(navigator, navigatorChart, "stockPriceSeries");


            List <DateTime> startDates = data.GetStartDates();

            foreach (var k in startDates)
            {
                while (dpStart.BlackoutDates.Any(bd => bd.Start.Date == k.Date))
                {
                    dpStart.BlackoutDates.Remove(dpStart.BlackoutDates.FirstOrDefault(bd => bd.Start.Date == k.Date));
                }
            }
        }
Пример #17
0
        internal void Update(TrackBallInfoEventArgs e)
        {
            if (this.panel == null)
            {
                this.pendingUpdates = e;
                return;
            }

            if (e.Header != null)
            {
                this.Header = e.Header;
            }

            DataTemplate defaultTemplate = this.DataPointInfoTemplate;

            // add presenter for each data point
            int index = 0;

            foreach (DataPointInfo info in e.Context.DataPoints.OrderBy(c => c.Priority))
            {
                ContentPresenter presenter;
                if (index >= this.panel.Children.Count)
                {
                    presenter = new ContentPresenter();
                    this.panel.Children.Add(presenter);
                }
                else
                {
                    presenter = this.panel.Children[index] as ContentPresenter;
                }

                DataTemplate seriesInfoTemplate = ChartTrackBallBehavior.GetTrackInfoTemplate(info.Series);

                presenter.Content         = info;
                presenter.ContentTemplate = seriesInfoTemplate == null ? defaultTemplate : seriesInfoTemplate;

                index++;
            }

            for (int i = index; i < this.panel.Children.Count; i++)
            {
                this.panel.Children.RemoveAt(i);
            }
        }
 private void AllData_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     foreach (DataToChart data in e.NewItems)
     {
         // Make a series for the line
         ScatterLineSeries scatterLineSeries = new ScatterLineSeries
         {
             Name          = $"Line {LineCount}",
             ItemsSource   = data.DataPoints,
             XValueBinding = new PropertyNameDataPointBinding("XValue"),
             YValueBinding = new PropertyNameDataPointBinding("YValue"),
             DisplayName   = $"Line {LineCount}",
             LegendTitle   = $"Line {LineCount}",
         };
         ChartTrackBallBehavior.SetIntersectionTemplate(scatterLineSeries, ChartTrackIntersectionTemplate);
         // Add the line to the Chart's Series collection
         MainChart.Series.Add(scatterLineSeries);
         // Increment arbitrary counter
         LineCount++;
     }
 }
Пример #19
0
        private RadCartesianChartView createChart()
        {
            //Create the Chart View
            RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

            LinearAxis verticalAxis = new LinearAxis();

            //The values in the linear axis will not have values after the decimal point.
            verticalAxis.LabelFormat = "%.0f";
            CategoricalAxis horizontalAxis = new CategoricalAxis();

            chart.VerticalAxis   = verticalAxis;
            chart.HorizontalAxis = horizontalAxis;


            for (int i = 0; i < 3; i++)
            {
                //Create the bar series and attach axes and value bindings.
                AreaSeries areaSeries = new AreaSeries();

                //We want to stack the different area series.
                areaSeries.CombineMode = ChartSeriesCombineMode.Stack;

                areaSeries.ValueBinding    = new ValueBinding();
                areaSeries.CategoryBinding = new CategoryBinding();

                //Bind series to data
                areaSeries.Data = this.getData();

                //Add series to chart
                chart.Series.Add(areaSeries);
            }

            ChartTrackBallBehavior tbBehavior = new ChartTrackBallBehavior(this.Activity);

            tbBehavior.ShowIntersectionPoints = true;
            chart.Behaviors.Add(tbBehavior);

            return(chart);
        }
        private void UpdateSeries(OhlcSeriesBase series)
        {
            series.HighBinding     = new PropertyNameDataPointBinding("High");
            series.LowBinding      = new PropertyNameDataPointBinding("Low");
            series.OpenBinding     = new PropertyNameDataPointBinding("Open");
            series.CloseBinding    = new PropertyNameDataPointBinding("Close");
            series.CategoryBinding = new PropertyNameDataPointBinding("Date");
            series.SetBinding(CandlestickSeries.ItemsSourceProperty, new Binding {
                Path = new PropertyPath("Data")
            });

            series.Transitions  = null;
            series.PaletteIndex = 0;

            var template = LayoutRoot.Resources["TrackInfoTemplate"] as DataTemplate;

            ChartTrackBallBehavior.SetTrackInfoTemplate(series, template);

            string styleKey = series is CandlestickSeries ? "CandleStickStyle" : "StickStyle";

            series.DefaultVisualStyle = this.Chart.Resources[styleKey] as Style;
        }
Пример #21
0
        private static void MoveTrackBalls(string group, object xCategory, ChartTrackBallBehavior behaviorOriginator)
        {
            foreach (var wr in groupToBehaviorsDict[group])
            {
                var behav = wr.Target as ChartTrackBallBehavior;
                if (behav != null && behav != behaviorOriginator)
                {
                    var chart = (RadCartesianChart)behav.Chart;
                    var position = chart.ConvertDataToPoint(new DataTuple(xCategory, null));
                    position.Y = chart.ActualHeight / 2;

                    behav.Position = position;
                }
            }
            CleanUp(groupToBehaviorsDict[group]);
        }
Пример #22
0
 private static int GetCoercedPositionX(ChartTrackBallBehavior behav)
 {
     var chart = (RadCartesianChart)behav.Chart;
     double positionX = double.IsNaN(behav.Position.X) ? chart.PlotAreaClip.X : behav.Position.X;
     int coercedX = (int)Math.Max(chart.PlotAreaClip.X, Math.Min(chart.PlotAreaClip.Right, positionX));
     return coercedX;
 }
 private void ZoomToggleButton_Click_1(object sender, RoutedEventArgs e)
 {
     RadCartesianChart[] targetCharts = { radChart1, radChart2, radChart3, radChart4 , radChart5, radChart6, radChart7, radChart8 };
     if (flipView1.SelectedIndex < 8)
     {
         RadCartesianChart targetChart = targetCharts[flipView1.SelectedIndex];
         //foreach (RadCartesianChart targetChart in targetCharts)
        // {
             if (targetChart.Behaviors.Count > 0)
             { // disable chart behaviour
                 Debug.WriteLine("Disable chart behaviour: " + targetChart.Behaviors.Count);
                 //ChartPanAndZoomBehavior item1 = targetChart.Behaviors[0] as ChartPanAndZoomBehavior;
                 //ChartTrackBallBehavior item2 = targetChart.Behaviors[1] as ChartTrackBallBehavior;
                 try
                 {
                     targetChart.Behaviors.Clear();
                 }
                 catch (System.ArgumentException)
                 {
                     Debug.WriteLine("ArgumentException");
                 }
                 //if (item2 != null) { targetChart.Behaviors.Remove(item2); }
                 //if (item1 != null) { targetChart.Behaviors.Remove(item1); }                  
                 targetChart.IsHitTestVisible = false;
                 targetChart.Zoom = new Size(1, 1);
             }
             else
             { // enable
                 Debug.WriteLine("Enable chart behaviour: " + targetChart.Behaviors.Count);
                 ChartPanAndZoomBehavior item1 = new ChartPanAndZoomBehavior();
                 item1.ZoomMode = ChartPanZoomMode.Horizontal;
                 item1.PanMode = ChartPanZoomMode.Horizontal;
                 targetChart.Behaviors.Add(item1);
                 ChartTrackBallBehavior item2 = new ChartTrackBallBehavior();
                 item2.ShowIntersectionPoints = true;
                 item2.InfoMode = TrackInfoMode.Multiple;
                 item2.TrackInfoUpdated += ChartTrackBallBehavior_TrackInfoUpdated_1;
                 item2.ShowInfo = true;
                 targetChart.Behaviors.Add(item2);
             } // enabling chart behaviours
         //}
             pageRoot.BottomAppBar.IsOpen = false; // close it
             ZoomToggleSetVisibility(flipView1.SelectedIndex);
     }
 }
        void SetKendoChartSeries()
        {
            //todo: refactor this method into smaller methods. Also, we should probably put the similar code for the two axes in the same places (instead of dealing with one axis, then the other).

            ChartOptions chartO = new ChartOptions();
            var          series = new JSArray <ChartSeriesItem>();

            #region Preparing the data points (series)
            foreach (CartesianSeries cartesianSeries in _series)
            {
                if (cartesianSeries.ItemsSource != null)
                {
                    ChartSeriesItem seriesItem = new ChartSeriesItem();
                    seriesItem.type = cartesianSeries.GetChartType();

                    #region attempt at dealing with tooltips in series.
                    //if(cartesianSeries is LineSeries)
                    //{
                    //    //Note: the following does nothing if chartO.tooltip.shared is true.
                    //    //note: The LineSeries is the only one that has the LineSeries.TrackBallInfoTemplate set in the xaml
                    //    seriesItem.tooltip = new ChartSeriesItemTooltip();
                    //    Interop.ExecuteJavaScript("$0.visible = true", seriesItem.tooltip.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                    //    seriesItem.tooltip.format = "Close: {0}";
                    //}
                    //if(cartesianSeries.TrackBallInfoTemplate != null)
                    //{
                    //    //find a way to generate a kendo-style template in html here, from the cartesianSeries.TrackBallInfoTemplate.
                    //    //that includes creating the html structure and translating the bindings into something in kendo style.
                    //    // for example, the Text="{Binding DataPoint.Category, StringFormat=Date: \{0:d\} }"
                    //}
                    #endregion

                    if (cartesianSeries is CategoricalStrokedSeries)
                    {
                        var    cartesianSeriesAsCategoricalSeries = cartesianSeries as CategoricalStrokedSeries;
                        string categoryField = cartesianSeriesAsCategoricalSeries.CategoryBinding.PropertyPath; //I'll just assume this has to have a value because I can't find a default value or anything like that in the telerik things I found on the internet.
                        string valueField    = cartesianSeriesAsCategoricalSeries.ValueBinding.PropertyPath;    // same as above.

                        SetSeriesItemColor(seriesItem, cartesianSeriesAsCategoricalSeries.Stroke);
                        if (cartesianSeries is AreaSeries)
                        {
                            SetSeriesItemColor(seriesItem, ((AreaSeries)cartesianSeriesAsCategoricalSeries).Fill);
                        }

                        var propNames = new List <string>()
                        {
                            categoryField, valueField
                        };

                        var res = PrepareSeriesData(cartesianSeries.ItemsSource, propNames);

                        seriesItem.categoryField = categoryField;
                        seriesItem.field         = valueField;
                        seriesItem.data          = res;
                        seriesItem.missingValues = "gap";
                    }
                    else
                    {
                        //get the data as points as is.
                    }

                    //var v = new JSObject();
                    //Interop.ExecuteJavaScript(@"$0.UnderlyingJSInstance = [1, 2, 3]", v);
                    //seriesItem.data = v;
                    series.Add(seriesItem);
                }
            }
            #endregion

            var categoryAxis     = new JSArray <ChartCategoryAxisItem>();
            var categoryAxisItem = new ChartCategoryAxisItem();

            if (HorizontalAxis != null)
            {
                var labels = new ChartCategoryAxisItemLabels();
                labels.rotation = HorizontalAxis.LabelFitMode == Charting.AxisLabelFitMode.Rotate ? -60 : 0;
                labels.format   = HorizontalAxis.LabelFormat; //Note: this seems to apply to DateFormats as well so I don't think we need to set labels.dateFormats
                labels.font     = HorizontalAxis.FontFamily != null ? HorizontalAxis.FontFamily.Source : null;

                //labels.color = "LightGray"; //todo: find out what defines the label's color (it is not HorizontalAxis.Foreground apparently)
                categoryAxisItem.labels = labels;

                string XAxisColor = GetStringToSetAsColor(HorizontalAxis.LineStroke);
                if (XAxisColor != null)
                {
                    categoryAxisItem.color = XAxisColor;
                }
            }

            bool hideCategoryAxisGridLines = false;
            bool hideValueAxisGridLines    = false;
            if (Grid != null)
            {
                #region Determining Whether to hide the Grid lines or not.
                switch (Grid.MajorLinesVisibility)
                {
                case GridLineVisibility.None:
                    hideCategoryAxisGridLines = true;
                    hideValueAxisGridLines    = true;
                    break;

                case GridLineVisibility.X:
                    hideValueAxisGridLines = true;
                    break;

                case GridLineVisibility.Y:
                    hideCategoryAxisGridLines = true;
                    break;

                case GridLineVisibility.XY:
                    break;

                default:
                    break;
                }
                #endregion

                //hiding the vertical lines:
                if (hideCategoryAxisGridLines)
                {
                    categoryAxisItem.majorGridLines = new ChartCategoryAxisItemMajorGridLines();
                    Interop.ExecuteJavaScript("$0.visible = false", categoryAxisItem.majorGridLines.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.majorGridLines.visible = false; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                    categoryAxisItem.minorGridLines = new ChartCategoryAxisItemMinorGridLines();
                    Interop.ExecuteJavaScript("$0.visible = false", categoryAxisItem.minorGridLines.UnderlyingJSInstance); //todo: same as above.
                }
            }

            categoryAxis.Add(categoryAxisItem);
            chartO.categoryAxis = categoryAxis;

            var valueAxis     = new JSArray <ChartValueAxisItem>();
            var valueAxisItem = new ChartValueAxisItem();

            if (Grid != null)
            {
                if (Grid.MajorYLineDashArray != null)
                {
                    valueAxisItem.majorGridLines          = new ChartValueAxisItemMajorGridLines();
                    valueAxisItem.majorGridLines.dashType = "dash"; //Note: it's MajorYLineDashArray="5, 2" but I think the kendo charts only support a set of values: "dash","dashDot","dot","longDash","longDashDot","longDashDotDot" and "solid"
                }
            }

            //hiding the horizontal lines:
            if (hideValueAxisGridLines)
            {
                valueAxisItem.majorGridLines = new ChartValueAxisItemMajorGridLines();
                Interop.ExecuteJavaScript("$0.visible = false", valueAxisItem.majorGridLines.UnderlyingJSInstance); //todo: find out how to do valueAxisItem.majorGridLines.visible = false; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                valueAxisItem.minorGridLines = new ChartValueAxisItemMinorGridLines();
                Interop.ExecuteJavaScript("$0.visible = false", valueAxisItem.minorGridLines.UnderlyingJSInstance); //todo: same as above.
            }

            string YAxisColor = GetStringToSetAsColor(VerticalAxis.LineStroke);
            if (YAxisColor != null)
            {
                valueAxisItem.color = YAxisColor;
            }

            valueAxis.Add(valueAxisItem);
            chartO.valueAxis = valueAxis;

            if (Behaviors != null)
            {
                foreach (var behavior in Behaviors)
                {
                    if (behavior is ChartTrackBallBehavior)
                    {
                        ChartTrackBallBehavior behaviorAsCTBB = (ChartTrackBallBehavior)behavior;
                        if (behaviorAsCTBB.ShowIntersectionPoints)
                        {
                            categoryAxisItem.crosshair = new ChartCategoryAxisItemCrosshair();
                            Interop.ExecuteJavaScript("$0.visible = true", categoryAxisItem.crosshair.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                            //categoryAxisItem.crosshair.tooltip = new ChartCategoryAxisItemCrosshairTooltip();
                            //Interop.ExecuteJavaScript("$0.visible = true", categoryAxisItem.crosshair.tooltip.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                            //categoryAxisItem.crosshair.tooltip.format = "Date: {0:d}";

                            chartO.tooltip = new ChartTooltip();                                                //todo: move this to somewhere more adapted?
                            //Interop.ExecuteJavaScript("$0.visible = true", chartO.tooltip.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                            Interop.ExecuteJavaScript("$0.shared = true", chartO.tooltip.UnderlyingJSInstance); //todo: find out how to do chartO.tooltip.shared = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                                                                                                                //                            chartO.tooltip.sharedTemplate = @"<div>#: category #</div>
                                                                                                                //# for (var i = 0; i < points.length; i++) { #
                                                                                                                //    <div>#: points[i].series.name# : #: points[i].value #</div>
                                                                                                                //# } #";
                        }
                    }
                }
            }

            //Setting the chart's background color:
            Brush background = Background;
            if (background != null && background is SolidColorBrush)
            {
                chartO.chartArea            = new ChartChartArea();
                chartO.chartArea.background = (string)((SolidColorBrush)background).ConvertToCSSValue();
            }


            chartO.series = series;
            _kendoChart.setOptions(chartO);
        }
Пример #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TrackBallInfoControl"/> class.
 /// </summary>
 internal TrackBallInfoControl(ChartTrackBallBehavior owner)
 {
     this.DefaultStyleKey = typeof(TrackBallInfoControl);
     this.owner           = owner;
 }