/// <summary> /// Initializes a new instance of the Visifire.Charts.AxisManager class /// </summary> /// <param name="maxValue">Maximum Value.</param> /// <param name="minValue">Minimum Value.</param> /// <param name="startFromZero">Makes sure that the zero is included in the axis range</param> /// <param name="allowLimitOverflow">Applies limits so that axis range doesn't cross it</param> public AxisManager(Double maxValue, Double minValue, Boolean startFromZero, Boolean allowLimitOverflow, Boolean stackingOverride, AxisRepresentations axisRepresentation) { if (maxValue < minValue) throw (new ArgumentException("Invalid Argument:: Maximum Data value should be always greater than the minimum data value.")); this._max = (Decimal)maxValue; this._min = (Decimal)minValue; AxisRepresentation = axisRepresentation; if (startFromZero) { if (minValue >= 0) AxisMinimumValue = 0; else if (maxValue <= 0) AxisMaximumValue = 0; } if (!allowLimitOverflow) { if (minValue == 0) AxisMinimumValue = 0; if (maxValue == 0) AxisMaximumValue = 0; } if (!allowLimitOverflow & stackingOverride) { AxisMaximumValue = maxValue; AxisMinimumValue = minValue; } }
/// <summary> /// Initializes a new instance of the Visifire.Charts.AxisManager class /// </summary> /// <param name="maxValue">Maximum Value.</param> /// <param name="minValue">Minimum Value.</param> /// <param name="startFromZero">Makes sure that the zero is included in the axis range</param> /// <param name="allowLimitOverflow">Applies limits so that axis range doesn't cross it</param> public AxisManager(Double maxValue, Double minValue, Boolean startFromZero, Boolean allowLimitOverflow, Boolean stackingOverride, AxisRepresentations axisRepresentation) { if (maxValue < minValue) { throw (new ArgumentException("Invalid Argument:: Maximum Data value should be always greater than the minimum data value.")); } this._max = (Decimal)maxValue; this._min = (Decimal)minValue; AxisRepresentation = axisRepresentation; if (startFromZero) { if (minValue >= 0) { AxisMinimumValue = 0; } else if (maxValue <= 0) { AxisMaximumValue = 0; } } if (!allowLimitOverflow) { if (minValue == 0) { AxisMinimumValue = 0; } if (maxValue == 0) { AxisMaximumValue = 0; } } if (!allowLimitOverflow & stackingOverride) { AxisMaximumValue = maxValue; AxisMinimumValue = minValue; } }
/// <summary> /// Creates the various regions required for drawing horizontal charts /// </summary> /// <param name="chartSize">Chart size as Double</param> /// <param name="NewSize">NewSize</param> /// <returns>Size</returns> private Size CreateRegionsForHorizontalCharts(Double chartSize, Size NewSize, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { Double chartCanvasHeight = 0; Double chartCanvasWidth = 0; if (Double.IsNaN(NewSize.Height) || NewSize.Height <= 0 || Double.IsNaN(NewSize.Width) || NewSize.Width <= 0 || Double.IsNaN(chartSize) || chartSize <= 0) { return new Size(chartCanvasWidth, chartCanvasHeight); } else { if (Chart.View3D) { if(_horizontalPlank != null) { if (PlottingCanvas.Children.Contains(_horizontalPlank.Visual)) PlottingCanvas.Children.Remove(_horizontalPlank.Visual); } // Draw 3D vertical plank DrawVerticalPlank(PLANK_DEPTH, PLANK_THICKNESS, renderAxisType, isPartialUpdate); // Set the chart canvas size chartCanvasHeight = chartSize - PLANK_DEPTH; chartCanvasWidth = NewSize.Width - PLANK_OFFSET; } else { // Set the chart canvas size chartCanvasHeight = chartSize; chartCanvasWidth = NewSize.Width; } } // if either height or width is invalid if (chartCanvasHeight <= 0 || chartCanvasWidth <= 0) return new Size(0, 0); // Return the size of the drawing canvas return new Size(chartCanvasWidth, chartCanvasHeight); }
/// <summary> /// Creates the various regions required for drawing vertical charts /// </summary> /// <param name="chartSize">Chart size as Double</param> /// <param name="NewSize">NewSize</param> /// <returns>Size</returns> private Size CreateRegionsForVerticalCharts(Double chartSize, Size NewSize, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { Double chartCanvasHeight = 0; Double chartCanvasWidth = 0; if (Double.IsNaN(NewSize.Height) || NewSize.Height <= 0 || Double.IsNaN(NewSize.Width) || NewSize.Width <= 0 || Double.IsNaN(chartSize) || chartSize <= 0) { return new Size(chartCanvasWidth, chartCanvasHeight); } else { if (Chart.View3D) { Double plankOpacity = 0.3; // Draw 3D horizontal plank if (Chart.Background != null && (Chart.Background as SolidColorBrush) != null) { if ((Chart.Background as SolidColorBrush).Color == Colors.Black) plankOpacity = 1; } DrawHorizontalPlank(PLANK_DEPTH, PLANK_THICKNESS, NewSize.Height, renderAxisType, isPartialUpdate); if (NewSize.Height - PLANK_DEPTH - PLANK_THICKNESS > 0) DrawVerticalPlank(NewSize.Height - PLANK_DEPTH - PLANK_THICKNESS, PLANK_DEPTH, 0.25, plankOpacity, isPartialUpdate); // Set the chart canvas size chartCanvasHeight = NewSize.Height - PLANK_OFFSET; //chartCanvasWidth = PlotAreaCanvas.ActualWidth - PlankDepth; chartCanvasWidth = chartSize - PLANK_DEPTH; } else { // Set the chart canvas size chartCanvasHeight = NewSize.Height; //chartCanvasWidth = PlotAreaCanvas.ActualWidth; chartCanvasWidth = chartSize; } } // if either height or width is invalid if (chartCanvasHeight <= 0 || chartSize <= 0) return new Size(0, 0); // Return the size of the drawing canvas return new Size(chartCanvasWidth, chartCanvasHeight); }
/// <summary> /// Update the axis /// </summary> /// <param name="isSizeChanged"></param> internal void PrePartialUpdateConfiguration(VisifireElement sender, VcProperties property, object oldValue, object newValue, Boolean updateLists, Boolean calculatePlotDetails, Boolean updateAxis, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { if(updateLists) PopulateInternalSeriesList(); if (calculatePlotDetails) { // PlotDetails = new PlotDetails(Chart); PlotDetails.ReCreate(sender, property, oldValue, newValue); } if (updateLists) { SetDataPointColorFromColorSet(Chart.Series); } if (updateAxis) { PopulateInternalAxesXList(); PopulateInternalAxesYList(); ClearAxesPanel(); // Check if drawing axis is necessary or not //if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis) // SetAxesProperties(); Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize); ResizePanels(remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); // Draw the chart grids if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis) { RenderGrids(); RenderTrendLines(); } } AddOrRemovePanels(Chart); }
/// <summary> /// Renders charts based on the orientation type /// </summary> /// <param name="newSize">NewSize</param> private void RenderChart(Size remainingSizeAfterDrawingAxes, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { if (Chart._forcedRedraw || PlotDetails.ChartOrientation == ChartOrientationType.NoAxis) { Chart._forcedRedraw = true; ClearPlotAreaChildren(); } ResizePanels(remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); // Draw the chart grids if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis) { RenderGrids(); RenderTrendLines(); } // Render each plot group from the plotgroups list of plotdetails RenderSeries(); _renderCount++; }
/// <summary> /// Resize existing panels to update the chart /// </summary> internal void ResizePanels(Size remainingSizeAfterDrawingAxes, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { PlotAreaScrollViewer = Chart._plotAreaScrollViewer; PlotAreaScrollViewer.Background = Graphics.TRANSPARENT_BRUSH; PlotAreaCanvas.Width = remainingSizeAfterDrawingAxes.Width; PlotAreaCanvas.Height = remainingSizeAfterDrawingAxes.Height; if (Chart._forcedRedraw || PlottingCanvas == null) { PlottingCanvas = new Canvas(); PlottingCanvas.Loaded += new RoutedEventHandler(PlottingCanvas_Loaded); PlottingCanvas.SetValue(Canvas.ZIndexProperty, 1); PlotAreaCanvas.Children.Add(PlottingCanvas); //PlottingCanvas.Background = Graphics.GetRandomColor(); } if (Double.IsNaN(remainingSizeAfterDrawingAxes.Height) || remainingSizeAfterDrawingAxes.Height <= 0 || Double.IsNaN(remainingSizeAfterDrawingAxes.Width) || remainingSizeAfterDrawingAxes.Width <= 0) { return; } else { if (PlotDetails.ChartOrientation == ChartOrientationType.Vertical) { PlottingCanvas.Width = ScrollableLength + PLANK_DEPTH; PlottingCanvas.Height = remainingSizeAfterDrawingAxes.Height; } else if (PlotDetails.ChartOrientation == ChartOrientationType.Horizontal) { PlottingCanvas.Width = remainingSizeAfterDrawingAxes.Width; PlottingCanvas.Height = ScrollableLength + PLANK_DEPTH; } } // Create the chart canvas if (Chart._forcedRedraw || ChartVisualCanvas == null) { ChartVisualCanvas = new Canvas(); PlottingCanvas.Children.Add(ChartVisualCanvas); } // Default size of the chart canvas Size chartCanvasSize = new Size(0, 0); // Create the various region required for drawing charts switch (PlotDetails.ChartOrientation) { case ChartOrientationType.Vertical: chartCanvasSize = CreateRegionsForVerticalCharts(ScrollableLength, remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); // set chart Canvas position ChartVisualCanvas.SetValue(Canvas.LeftProperty, PLANK_DEPTH); Chart.PlotArea.BorderElement.SetValue(Canvas.LeftProperty, PLANK_DEPTH); break; case ChartOrientationType.Horizontal: chartCanvasSize = CreateRegionsForHorizontalCharts(ScrollableLength, remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); // set chart Canvas position ChartVisualCanvas.SetValue(Canvas.LeftProperty, PLANK_OFFSET); Chart.PlotArea.BorderElement.SetValue(Canvas.LeftProperty, PLANK_OFFSET); break; case ChartOrientationType.NoAxis: chartCanvasSize = CreateRegionsForChartsWithoutAxis(remainingSizeAfterDrawingAxes); break; default: // No chart to render break; } // Don't atempt to draw chart if the size is not fesiable if (chartCanvasSize.Width <= 0 || chartCanvasSize.Height <= 0) return; // set the ChartVisualCanvas Size ChartVisualCanvas.Width = chartCanvasSize.Width - ((PlotDetails.ChartOrientation == ChartOrientationType.Horizontal) ? SCROLLVIEWER_OFFSET4HORIZONTAL_CHART : 0); ChartVisualCanvas.Height = chartCanvasSize.Height - ((PlotDetails.ChartOrientation == ChartOrientationType.NoAxis) ? Chart.SHADOW_DEPTH : 0); Chart.PlotArea.BorderElement.Height = ChartVisualCanvas.Height; Chart.PlotArea.BorderElement.Width = chartCanvasSize.Width; Chart.PlotArea.ApplyBevel(PLANK_DEPTH, PLANK_THICKNESS); Chart.PlotArea.ApplyShadow(remainingSizeAfterDrawingAxes, PLANK_OFFSET, PLANK_DEPTH, PLANK_THICKNESS); Chart._plotCanvas.Width = PlottingCanvas.Width; Chart._plotCanvas.Height = PlottingCanvas.Height; Chart._bottomAxisScrollBar.UpdateLayout(); Chart._topAxisScrollBar.UpdateLayout(); Chart._leftAxisScrollBar.UpdateLayout(); Chart._rightAxisScrollBar.UpdateLayout(); }
/// <summary> /// Draws the Vertical 3D Plank /// </summary> /// <param name="plankDepth">PlankDepth</param> /// <param name="plankThickness">PlankThickness</param> private void DrawVerticalPlank(Double plankDepth, Double plankThickness, AxisRepresentations axisChanged, Boolean isPartialUpdate) { if (isPartialUpdate && axisChanged == AxisRepresentations.AxisX) { ColumnChart.Update3DPlank(plankThickness, ScrollableLength - plankDepth, plankDepth, _verticalPlank); return; } if (_verticalPlank != null && _verticalPlank.Visual != null && _verticalPlank.Visual.Parent != null) { Panel parent = _verticalPlank.Visual.Parent as Canvas; parent.Children.Remove(_verticalPlank.Visual); } RectangularChartShapeParams columnParams = new RectangularChartShapeParams(); Brush frontBrush, topBrush, rightBrush; List<Color> colors = new List<Color>(); colors.Add(Color.FromArgb(255, 134, 134, 134)); // #FF868686 colors.Add(Color.FromArgb(255, 210, 210, 210)); // #FFD2D2D2 colors.Add(Color.FromArgb(255, 255, 255, 255)); // #FFFFFFFF colors.Add(Color.FromArgb(255, 223, 223, 223)); // #FFDFDFDF frontBrush = Graphics.CreateLinearGradientBrush(0, new Point(1.1, 0.49), new Point(-0.15, 0.49), colors, new List<double>() { 0, 0.844, 1, 0.442 }); colors = new List<Color>(); colors.Add(Color.FromArgb(255, 232, 232, 232)); // #FFE8E8E8 colors.Add(Color.FromArgb(255, 142, 135, 135)); // #FF8E8787 rightBrush = Graphics.CreateLinearGradientBrush(0, new Point(0, 0.5), new Point(1, 0.5), colors, new List<double>() { 1, 0 }); colors = new List<Color>(); colors.Add(Color.FromArgb(255, 232, 232, 232)); // #FFE8E8E8 colors.Add(Color.FromArgb(255, 142, 135, 135)); // #FF8E8787 topBrush = Graphics.CreateLinearGradientBrush(0, new Point(0.084, 0.441), new Point(1.916, 0.443), colors, new List<double>() { 0, 1 }); _verticalPlank = ColumnChart.Get3DPlank(plankThickness, ScrollableLength - plankDepth, plankDepth, frontBrush, topBrush, rightBrush); Panel plank = _verticalPlank.Visual as Panel; plank.SetValue(Canvas.TopProperty, plankDepth); plank.SetValue(Canvas.ZIndexProperty, -1); PlottingCanvas.Children.Add(plank); }
/// <summary> /// Draws the horizontal 3D Plank /// </summary> /// <param name="plankDepth">PlankDepth</param> /// <param name="plankThickness">PlankThickness</param> /// <param name="position">Position</param> private void DrawHorizontalPlank(Double plankDepth, Double plankThickness, Double position, AxisRepresentations axisChanged, Boolean isPartialUpdate) { if (isPartialUpdate && axisChanged == AxisRepresentations.AxisY) { // Update with new size ColumnChart.Update3DPlank(ScrollableLength - plankDepth, plankThickness, plankDepth, _horizontalPlank); #if SL _horizontalPlank.Visual.SetValue(Canvas.TopProperty, position - plankThickness); #else PlottingCanvas.Measure(new Size(Double.MaxValue, Double.MaxValue)); _horizontalPlank.Visual.SetValue(Canvas.TopProperty, PlottingCanvas.DesiredSize.Height - plankThickness); #endif return; } if (_horizontalPlank != null && _horizontalPlank.Visual != null && _horizontalPlank.Visual.Parent != null) { Panel parent = _horizontalPlank.Visual.Parent as Canvas; parent.Children.Remove(_horizontalPlank.Visual); } Brush frontBrush, topBrush, rightBrush; ExtendedGraphics.GetBrushesForPlank(Chart, out frontBrush, out topBrush, out rightBrush, false); _horizontalPlank = ColumnChart.Get3DPlank(ScrollableLength - plankDepth, plankThickness, plankDepth, frontBrush, topBrush, rightBrush); Panel plank = _horizontalPlank.Visual as Panel; #if SL plank.SetValue(Canvas.TopProperty, position - plankThickness); #else PlottingCanvas.Measure(new Size(Double.MaxValue, Double.MaxValue)); plank.SetValue(Canvas.TopProperty, PlottingCanvas.DesiredSize.Height - plankThickness); #endif plank.SetValue(Canvas.ZIndexProperty, -1); plank.Opacity = 0.9; PlottingCanvas.Children.Add(plank); }
/// <summary> /// Initializes a new instance of the Visifire.Charts.AxisManager class /// </summary> /// <param name="maxValue">Maximum Value.</param> /// <param name="minValue">Minimum Value.</param> /// <param name="startFromZero">Makes sure that the zero is included in the axis range</param> /// <param name="allowLimitOverflow">Applies limits so that axis range doesn't cross it</param> public AxisManager(Double maxValue, Double minValue, Boolean startFromZero, Boolean allowLimitOverflow, Boolean stackingOverride, Boolean isCircularAxis, AxisRepresentations axisRepresentation, Boolean isLogarithmic, Double logarithmicBase, Boolean startFromMinimumValue4LogScale) { if (maxValue < minValue) { throw (new ArgumentException("Invalid Argument:: Maximum Data value should be always greater than the minimum data value.")); } this._max = (Decimal)maxValue; this._min = (Decimal)minValue; AxisRepresentation = axisRepresentation; if (AxisRepresentation == AxisRepresentations.AxisY) { Logarithmic = isLogarithmic; LogarithmicBase = logarithmicBase; if (startFromMinimumValue4LogScale) { if (this._min == 0) { MinimumValue4LogScale = 1; } else { MinimumValue4LogScale = (Double)this._min; } } else { MinimumValue4LogScale = Double.NaN; } } if (startFromZero) { if (minValue >= 0) { if (Logarithmic) { AxisMinimumValue = Math.Pow(LogarithmicBase, 0); } else { AxisMinimumValue = 0; } } else if (maxValue <= 0) { AxisMaximumValue = 0; } } if (!allowLimitOverflow) { if (minValue == 0) { if (Logarithmic) { AxisMinimumValue = Math.Pow(LogarithmicBase, 0); } else { AxisMinimumValue = 0; } } if (maxValue == 0) { AxisMaximumValue = 0; } } if (!allowLimitOverflow & stackingOverride) { AxisMaximumValue = maxValue; if (Logarithmic && minValue == 0) { AxisMinimumValue = Math.Pow(LogarithmicBase, 0); } else { AxisMinimumValue = minValue; } } if (isCircularAxis && axisRepresentation == AxisRepresentations.AxisX) { IsCircularAxis = isCircularAxis; if (!this._overrideAxisMaximumValue) { AxisMaximumValue = 360; } } }
/// <summary> /// Update the axis /// </summary> /// <param name="isSizeChanged"></param> internal void PrePartialUpdateConfiguration(VisifireElement sender, ElementTypes elementType, VcProperties property, object oldValue, object newValue, Boolean updateLists, Boolean calculatePlotDetails, Boolean updateAxis, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { if (updateLists) PopulateInternalSeriesList(false); if (calculatePlotDetails) { PlotDetails.ReCreate(sender, elementType, property, oldValue, newValue); } if (updateLists) { SetDataPointColorFromColorSet(Chart.Series); } if (updateAxis) { PopulateInternalAxesXList(); PopulateInternalAxesYList(); ClearAxesPanel(); CreateTrendLinesLabel(); /* Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize); */ //---------- Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize); remainingSizeAfterDrawingAxes = RecalculateAxisAndRerenderBasedOnChartTypes(_plotAreaSize, remainingSizeAfterDrawingAxes); //----------- ResizePanels(remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); // Draw the chart grids if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis) { RenderGrids(); RenderTrendLines(); } } AddOrRemovePanels(Chart); }
/// <summary> /// Renders charts based on the orientation type /// </summary> /// <param name="newSize">NewSize</param> private void RenderChart(Size remainingSizeAfterDrawingAxes, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { if (Chart._forcedRedraw || PlotDetails.ChartOrientation == ChartOrientationType.NoAxis || PlotDetails.ChartOrientation == ChartOrientationType.Circular) { Chart._forcedRedraw = true; ClearPlotAreaChildren(); } ResizePanels(remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); if (Double.IsNaN(remainingSizeAfterDrawingAxes.Height) || Double.IsNaN(remainingSizeAfterDrawingAxes.Width) || remainingSizeAfterDrawingAxes.Height == 0 || remainingSizeAfterDrawingAxes.Width == 0) { throw new ArgumentException("Size must be non-negative."); } // Draw the chart grids if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis && PlotDetails.ChartOrientation != ChartOrientationType.Circular) { RenderGrids(); RenderTrendLines(); } RenderAxes4CircularChart(); // Render each plot group from the plotgroups list of plotdetails RenderSeries(); _renderCount++; }
/// <summary> /// Initializes a new instance of the Visifire.Charts.AxisManager class /// </summary> /// <param name="maxValue">Maximum Value.</param> /// <param name="minValue">Minimum Value.</param> /// <param name="startFromZero">Makes sure that the zero is included in the axis range</param> /// <param name="allowLimitOverflow">Applies limits so that axis range doesn't cross it</param> public AxisManager(Double maxValue, Double minValue, Boolean startFromZero, Boolean allowLimitOverflow, Boolean stackingOverride, Boolean isCircularAxis, AxisRepresentations axisRepresentation, Boolean isLogarithmic, Double logarithmicBase, Boolean startFromMinimumValue4LogScale) { if (maxValue < minValue) throw (new ArgumentException("Invalid Argument:: Maximum Data value should be always greater than the minimum data value.")); this._max = (Decimal)maxValue; this._min = (Decimal)minValue; AxisRepresentation = axisRepresentation; if (AxisRepresentation == AxisRepresentations.AxisY) { Logarithmic = isLogarithmic; LogarithmicBase = logarithmicBase; if (startFromMinimumValue4LogScale) { if (this._min == 0) MinimumValue4LogScale = 1; else MinimumValue4LogScale = (Double)this._min; } else MinimumValue4LogScale = Double.NaN; } if (startFromZero) { if (minValue >= 0) { if (Logarithmic) AxisMinimumValue = Math.Pow(LogarithmicBase, 0); else AxisMinimumValue = 0; } else if (maxValue <= 0) AxisMaximumValue = 0; } if (!allowLimitOverflow) { if (minValue == 0) { if (Logarithmic) AxisMinimumValue = Math.Pow(LogarithmicBase, 0); else AxisMinimumValue = 0; } if (maxValue == 0) AxisMaximumValue = 0; } if (!allowLimitOverflow & stackingOverride) { AxisMaximumValue = maxValue; if (Logarithmic && minValue == 0) AxisMinimumValue = Math.Pow(LogarithmicBase, 0); else AxisMinimumValue = minValue; } if (isCircularAxis && axisRepresentation == AxisRepresentations.AxisX) { IsCircularAxis = isCircularAxis; if (!this._overrideAxisMaximumValue) AxisMaximumValue = 360; } }