private static void UpdateYValueAndXValuePosition(DataPoint dataPoint, Double canvasWidth, Double canvasHeight, Double dataPointWidth) { Canvas dataPointVisual = dataPoint.Faces.Visual as Canvas; Faces faces = dataPoint.Faces; Line highLowLine = faces.VisualComponents[0] as Line; // HighLowline Line closeLine = faces.VisualComponents[1] as Line; // Closeline Line openLine = faces.VisualComponents[2] as Line; // Openline Double highY = 0, lowY = 0, openY = 0, closeY = 0; PlotGroup plotGroup = dataPoint.Parent.PlotGroup; CandleStick.SetDataPointValues(dataPoint, ref highY, ref lowY, ref openY, ref closeY); // Calculate required pixel positions Double xPositionOfDataPoint = Graphics.ValueToPixelPosition(0, canvasWidth, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue); openY = Graphics.ValueToPixelPosition(canvasHeight, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, openY); closeY = Graphics.ValueToPixelPosition(canvasHeight, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, closeY); highY = Graphics.ValueToPixelPosition(canvasHeight, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, highY); lowY = Graphics.ValueToPixelPosition(canvasHeight, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, lowY); Double dataPointTop = (lowY < highY) ? lowY : highY; openY = openY - dataPointTop; closeY = closeY - dataPointTop; dataPointVisual.Width = dataPointWidth; dataPointVisual.Height = Math.Abs(lowY - highY); // Set DataPoint Visual position dataPointVisual.SetValue(Canvas.LeftProperty, xPositionOfDataPoint - dataPointWidth / 2); dataPointVisual.SetValue(Canvas.TopProperty, dataPointTop); // Set position for high-low line highLowLine.X1 = dataPointVisual.Width / 2; highLowLine.X2 = dataPointVisual.Width / 2; highLowLine.Y1 = 0; highLowLine.Y2 = dataPointVisual.Height; // Set position for open line openLine.X1 = 0; openLine.X2 = dataPointVisual.Width / 2; openLine.Y1 = openY; openLine.Y2 = openY; // Set position for close line closeLine.X1 = dataPointVisual.Width / 2; closeLine.X2 = dataPointVisual.Width; closeLine.Y1 = closeY; closeLine.Y2 = closeY; // Need to apply shadow according to position of DataPoint ApplyOrUpdateShadow(dataPoint, dataPointVisual, highLowLine, openLine, closeLine, dataPointWidth); // Place label for the DataPoint CandleStick.CreateAndPositionLabel(dataPoint.Parent.Faces.LabelCanvas, dataPoint); }
internal static void UpdateVisualObject(RenderAs chartType, Visifire.Commons.ObservableObject sender, VcProperties property, object newValue, Boolean isAXisChanged) { Boolean isDataPoint = sender.GetType().Equals(typeof(DataPoint)); DataPoint dataPoint = sender as DataPoint; Chart chart = (sender as ObservableObject).Chart as Chart; switch (chartType) { case RenderAs.Column: case RenderAs.Bar: ColumnChart.Update(sender, property, newValue, isAXisChanged); //ColumnChart.GetVisualObjectForColumnChart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; // renderedCanvas = BarChart.GetVisualObjectForBarChart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); case RenderAs.Line: //if (isAXisChanged && isDataPoint && chart._partialUpdateAnimation) //{ foreach (DataSeries ds in chart.Series) // { // //if (ds == dataPoint.Parent) // // continue; // foreach (DataPoint dp in ds.DataPoints) // { // RenderHelper.UpdateVisualObject(ds.RenderAs, dp, property, newValue, false); // } // } //} //else // LineChart.Update(sender, property, newValue); LineChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.Point: PointChart.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = PointChart.GetVisualObjectForPointChart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.Bubble: BubbleChart.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = BubbleChart.GetVisualObjectForBubbleChart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.Area: AreaChart.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = AreaChart.GetVisualObjectForAreaChart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.StackedColumn: ColumnChart.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = ColumnChart.GetVisualObjectForStackedColumnChart(width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.StackedColumn100: ColumnChart.Update(sender, property, newValue, isAXisChanged); // renderedCanvas = ColumnChart.GetVisualObjectForStackedColumn100Chart(width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.StackedBar: ColumnChart.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = BarChart.GetVisualObjectForStackedBarChart(width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.StackedBar100: ColumnChart.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = BarChart.GetVisualObjectForStackedBar100Chart(width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.Pie: //renderedCanvas = PieChart.GetVisualObjectForPieChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.Doughnut: //renderedCanvas = PieChart.GetVisualObjectForDoughnutChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.StackedArea: //renderedCanvas = AreaChart.GetVisualObjectForStackedAreaChart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.StackedArea100: //renderedCanvas = AreaChart.GetVisualObjectForStackedArea100Chart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.SectionFunnel: //renderedCanvas = FunnelChart.GetVisualObjectForFunnelChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled, false); break; case RenderAs.StreamLineFunnel: //renderedCanvas = FunnelChart.GetVisualObjectForFunnelChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled, true); break; case RenderAs.Stock: StockChart.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = StockChart.GetVisualObjectForStockChart(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.CandleStick: CandleStick.Update(sender, property, newValue, isAXisChanged); //renderedCanvas = CandleStick.GetVisualObjectForCandleStick(width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; } chart.ChartArea.AttachScrollEvents(); }
internal static Panel GetVisualObject(Panel preExistingPanel, RenderAs chartType, Double width, Double height, PlotDetails plotDetails, List <DataSeries> dataSeriesList4Rendering, Chart chart, Double plankDepth, bool animationEnabled) { Panel renderedCanvas = null; switch (chartType) { case RenderAs.Column: renderedCanvas = ColumnChart.GetVisualObjectForColumnChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.Bar: renderedCanvas = ColumnChart.GetVisualObjectForColumnChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); //renderedCanvas = BarChart.GetVisualObjectForBarChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.Line: renderedCanvas = LineChart.GetVisualObjectForLineChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.Point: renderedCanvas = PointChart.GetVisualObjectForPointChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.Bubble: renderedCanvas = BubbleChart.GetVisualObjectForBubbleChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.Area: renderedCanvas = AreaChart.GetVisualObjectForAreaChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.StackedColumn: renderedCanvas = ColumnChart.GetVisualObjectForStackedColumnChart(chartType, preExistingPanel, width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.StackedColumn100: renderedCanvas = ColumnChart.GetVisualObjectForStackedColumnChart(chartType, preExistingPanel, width, height, plotDetails, chart, plankDepth, animationEnabled); //renderedCanvas = ColumnChart.GetVisualObjectForStackedColumn100Chart(width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.StackedBar: renderedCanvas = BarChart.GetVisualObjectForStackedBarChart(chartType, preExistingPanel, width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.StackedBar100: renderedCanvas = BarChart.GetVisualObjectForStackedBarChart(chartType, preExistingPanel, width, height, plotDetails, chart, plankDepth, animationEnabled); // renderedCanvas = BarChart.GetVisualObjectForStackedBar100Chart(width, height, plotDetails, chart, plankDepth, animationEnabled); break; case RenderAs.Pie: renderedCanvas = PieChart.GetVisualObjectForPieChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.Doughnut: renderedCanvas = PieChart.GetVisualObjectForDoughnutChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.StackedArea: renderedCanvas = AreaChart.GetVisualObjectForStackedAreaChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.StackedArea100: renderedCanvas = AreaChart.GetVisualObjectForStackedArea100Chart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.SectionFunnel: renderedCanvas = FunnelChart.GetVisualObjectForFunnelChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled, false); break; case RenderAs.StreamLineFunnel: renderedCanvas = FunnelChart.GetVisualObjectForFunnelChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled, true); break; case RenderAs.Stock: renderedCanvas = StockChart.GetVisualObjectForStockChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.CandleStick: renderedCanvas = CandleStick.GetVisualObjectForCandleStick(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; } return(renderedCanvas); }
private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged) { Chart chart = dataPoint.Chart as Chart; DataSeries dataSeries = dataPoint.Parent; PlotGroup plotGroup = dataSeries.PlotGroup; Faces dsFaces = dataSeries.Faces; Faces dpFaces = dataPoint.Faces; Double dataPointWidth; if (dsFaces != null) { ColumnChart.UpdateParentVisualCanvasSize(chart, dsFaces.Visual as Canvas); } if (dpFaces != null && dpFaces.Visual != null) { dataPointWidth = dpFaces.Visual.Width; } else if (dsFaces == null) { return; } else { dataPointWidth = CandleStick.CalculateDataPointWidth(dsFaces.Visual.Width, dsFaces.Visual.Height, chart); } if (property == VcProperties.Enabled) { CreateOrUpdateAStockDataPoint(dataPoint, dsFaces.Visual as Canvas, dsFaces.LabelCanvas, dsFaces.Visual.Width, dsFaces.Visual.Height, dataPointWidth); return; } if (dpFaces == null) { return; } Canvas dataPointVisual = dpFaces.Visual as Canvas; // DataPoint visual canvas Line highLowLine = dpFaces.VisualComponents[0] as Line; // HighLowline Line closeLine = dpFaces.VisualComponents[1] as Line; // Closeline Line openLine = dpFaces.VisualComponents[2] as Line; // Openline switch (property) { case VcProperties.BorderThickness: case VcProperties.BorderStyle: ApplyBorderProperties(dataPoint, highLowLine, openLine, closeLine, dataPointWidth); break; case VcProperties.Color: ApplyOrUpdateColorForAStockDp(dataPoint, highLowLine, openLine, closeLine); break; case VcProperties.Cursor: dataPoint.SetCursor2DataPointVisualFaces(); break; case VcProperties.Href: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.HrefTarget: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.LabelBackground: case VcProperties.LabelEnabled: case VcProperties.LabelFontColor: case VcProperties.LabelFontFamily: case VcProperties.LabelFontStyle: case VcProperties.LabelFontSize: case VcProperties.LabelFontWeight: case VcProperties.LabelStyle: case VcProperties.LabelText: CandleStick.CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint); break; case VcProperties.LegendText: chart.InvokeRender(); break; case VcProperties.LightingEnabled: ApplyOrUpdateColorForAStockDp(dataPoint, highLowLine, openLine, closeLine); break; //case VcProperties.MarkerBorderColor: //case VcProperties.MarkerBorderThickness: //case VcProperties.MarkerColor: //case VcProperties.MarkerEnabled: //case VcProperties.MarkerScale: //case VcProperties.MarkerSize: //case VcProperties.MarkerType: case VcProperties.ShadowEnabled: ApplyOrUpdateShadow(dataPoint, dataPointVisual, highLowLine, openLine, closeLine, dataPointWidth); break; case VcProperties.Opacity: dpFaces.Visual.Opacity = dataSeries.Opacity * dataPoint.Opacity; break; case VcProperties.ShowInLegend: chart.InvokeRender(); break; case VcProperties.ToolTipText: dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); break; case VcProperties.XValueFormatString: case VcProperties.YValueFormatString: dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); CandleStick.CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint); break; case VcProperties.XValueType: chart.InvokeRender(); break; case VcProperties.Enabled: CreateOrUpdateAStockDataPoint(dataPoint, dsFaces.Visual as Canvas, dsFaces.LabelCanvas, dsFaces.Visual.Width, dsFaces.Visual.Height, dataPointWidth); break; case VcProperties.XValue: case VcProperties.YValues: if (isAxisChanged) { UpdateDataSeries(dataSeries, property, newValue, isAxisChanged); } else { dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); UpdateYValueAndXValuePosition(dataPoint, dsFaces.Visual.Width, dsFaces.Visual.Height, dpFaces.Visual.Width); if ((Boolean)dataPoint.LabelEnabled) { CandleStick.CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint); } } if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected) { dataPoint.Select(true); } break; } }
/// <summary> /// Get visual object for point chart /// </summary> /// <param name="width">Width of the charat</param> /// <param name="height">Height of the charat</param> /// <param name="plotDetails">plotDetails</param> /// <param name="seriesList">List of DataSeries</param> /// <param name="chart">Chart</param> /// <param name="plankDepth">Plank depth</param> /// <param name="animationEnabled">Whether animation is enabled</param> /// <returns>Point chart canvas</returns> internal static Canvas GetVisualObjectForStockChart(Panel preExistingPanel, Double width, Double height, PlotDetails plotDetails, List <DataSeries> seriesList, Chart chart, Double plankDepth, bool animationEnabled) { if (Double.IsNaN(width) || Double.IsNaN(height) || width <= 0 || height <= 0) { return(null); } Canvas visual, labelCanvas, stockChartCanvas; RenderHelper.RepareCanvas4Drawing(preExistingPanel as Canvas, out visual, out labelCanvas, out stockChartCanvas, width, height); Double depth3d = plankDepth / (plotDetails.Layer3DCount == 0 ? 1 : plotDetails.Layer3DCount) * (chart.View3D ? 1 : 0); Double visualOffset = depth3d * (plotDetails.SeriesDrawingIndex[seriesList[0]] + 1 - (plotDetails.Layer3DCount == 0 ? 0 : 1)); visual.SetValue(Canvas.TopProperty, visualOffset); visual.SetValue(Canvas.LeftProperty, -visualOffset); Double animationBeginTime = 0; DataSeries _tempDataSeries = null; // Calculate width of a DataPoint Double dataPointWidth = CandleStick.CalculateDataPointWidth(width, height, chart); foreach (DataSeries series in seriesList) { if (series.Enabled == false) { continue; } Faces dsFaces = new Faces() { Visual = stockChartCanvas, LabelCanvas = labelCanvas }; series.Faces = dsFaces; PlotGroup plotGroup = series.PlotGroup; _tempDataSeries = series; foreach (DataPoint dataPoint in series.InternalDataPoints) { CreateOrUpdateAStockDataPoint(dataPoint, stockChartCanvas, labelCanvas, width, height, dataPointWidth); } } // Apply animation to series if (animationEnabled) { if (_tempDataSeries.Storyboard == null) { _tempDataSeries.Storyboard = new Storyboard(); } _tempDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(stockChartCanvas, _tempDataSeries, _tempDataSeries.Storyboard, animationBeginTime, 1, 0, 1); animationBeginTime += 0.5; } // Label animation if (animationEnabled && _tempDataSeries != null) { _tempDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, _tempDataSeries, _tempDataSeries.Storyboard, animationBeginTime, 1, 0, 1); } stockChartCanvas.Tag = null; // ColumnChart.CreateOrUpdatePlank(chart, seriesList[0].PlotGroup.AxisY, stockChartCanvas, depth3d, Orientation.Horizontal); // Remove old visual and add new visual in to the existing panel if (preExistingPanel != null) { visual.Children.RemoveAt(1); visual.Children.Add(stockChartCanvas); } else { labelCanvas.SetValue(Canvas.ZIndexProperty, 1); visual.Children.Add(labelCanvas); visual.Children.Add(stockChartCanvas); } RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(0, -chart.ChartArea.PLANK_DEPTH, width + chart.ChartArea.PLANK_OFFSET, height + chart.ChartArea.PLANK_DEPTH); visual.Clip = clipRectangle; return(visual); }
internal static void UpdateVisualObject(RenderAs chartType, Visifire.Commons.ObservableObject sender, VcProperties property, object newValue, Boolean isAXisChanged) { Boolean isDataPoint = sender.GetType().Equals(typeof(DataPoint)); DataPoint dataPoint = sender as DataPoint; Chart chart = (sender as ObservableObject).Chart as Chart; switch (chartType) { case RenderAs.Column: case RenderAs.Bar: ColumnChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.Line: case RenderAs.Spline: LineChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.QuickLine: QuickLineChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.StepLine: StepLineChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.Point: PointChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.Bubble: BubbleChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.Area: AreaChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.StackedColumn: ColumnChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.StackedColumn100: ColumnChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.StackedBar: ColumnChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.StackedBar100: ColumnChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.Pie: //renderedCanvas = PieChart.GetVisualObjectForPieChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.Doughnut: //renderedCanvas = PieChart.GetVisualObjectForDoughnutChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.StackedArea: List <DataSeries> stackedAreaList = (from ds in chart.Series where ds.RenderAs == RenderAs.StackedArea select ds).ToList(); if (stackedAreaList.Count > 0) { ColumnChart.Update(chart, stackedAreaList[0].RenderAs, stackedAreaList); } chart.ChartArea.AttachEventsToolTipHref2DataSeries(); break; case RenderAs.StackedArea100: List <DataSeries> stackedArea100List = (from ds in chart.Series where ds.RenderAs == RenderAs.StackedArea select ds).ToList(); if (stackedArea100List.Count > 0) { ColumnChart.Update(chart, stackedArea100List[0].RenderAs, stackedArea100List); } chart.ChartArea.AttachEventsToolTipHref2DataSeries(); break; case RenderAs.SectionFunnel: case RenderAs.StreamLineFunnel: case RenderAs.Pyramid: //renderedCanvas = FunnelChart.GetVisualObjectForFunnelChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled, true); break; case RenderAs.Stock: StockChart.Update(sender, property, newValue, isAXisChanged); break; case RenderAs.CandleStick: CandleStick.Update(sender, property, newValue, isAXisChanged); break; } //chart.ChartArea.AttachScrollEvents(); }