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); }
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; } }