private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue) { if (property != VcProperties.Enabled) { if (dataPoint.Parent.Enabled == false || (Boolean)dataPoint.Enabled == false) { return; } } Chart chart = dataPoint.Chart as Chart; if (chart == null) return; Marker marker = dataPoint.Marker; DataSeries dataSeries = dataPoint.Parent; PlotGroup plotGroup = dataSeries.PlotGroup; Double height = chart.ChartArea.ChartVisualCanvas.Height; Double width = chart.ChartArea.ChartVisualCanvas.Width; Double xPosition, yPosition; Canvas line2dLabelCanvas = null; xPosition = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue); yPosition = Graphics.ValueToPixelPosition(height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue); if (dataSeries.Faces != null) { line2dLabelCanvas = dataSeries.Faces.LabelCanvas as Canvas; ColumnChart.UpdateParentVisualCanvasSize(chart, line2dLabelCanvas); } switch (property) { case VcProperties.Color: if (marker != null && (Boolean)dataPoint.MarkerEnabled) marker.BorderColor = (dataPoint.GetValue(DataPoint.MarkerBorderColorProperty) as Brush == null) ? ((newValue != null) ? newValue as Brush : dataPoint.MarkerBorderColor) : dataPoint.MarkerBorderColor; break; case VcProperties.Cursor: dataPoint.SetCursor2DataPointVisualFaces(); break; case VcProperties.Href: case VcProperties.HrefTarget: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.LabelBackground: //if (marker != null) // marker.TextBackground = dataPoint.LabelBackground; CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); break; case VcProperties.LabelEnabled: //if (marker.LabelEnabled == false) //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); //else // marker.LabelEnabled = (Boolean)dataPoint.LabelEnabled; CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); break; case VcProperties.LabelFontColor: //if (marker != null) // marker.FontColor = dataPoint.LabelFontColor; CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); break; case VcProperties.LabelFontFamily: //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); // marker.FontFamily = dataPoint.LabelFontFamily; break; case VcProperties.LabelFontStyle: //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); //marker.FontStyle = (FontStyle) dataPoint.LabelFontStyle; break; case VcProperties.LabelFontSize: //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); // marker.FontSize = (Double) dataPoint.LabelFontSize; break; case VcProperties.LabelFontWeight: //if (marker != null) // marker.FontWeight = (FontWeight) dataPoint.LabelFontWeight; CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); break; case VcProperties.LabelStyle: //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); break; case VcProperties.LabelAngle: //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); break; case VcProperties.LabelText: //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); //marker.Text = dataPoint.TextParser(dataPoint.LabelText); break; case VcProperties.LegendText: chart.InvokeRender(); break; case VcProperties.LightingEnabled: break; case VcProperties.MarkerBorderColor: if (marker == null) LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); else { if ((Boolean)dataPoint.MarkerEnabled) marker.BorderColor = dataPoint.MarkerBorderColor; } break; case VcProperties.MarkerBorderThickness: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); // marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left; break; case VcProperties.MarkerColor: if (marker != null && (Boolean)dataPoint.MarkerEnabled) marker.MarkerFillColor = dataPoint.MarkerColor; break; case VcProperties.MarkerEnabled: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); //if((Boolean)dataPoint.MarkerEnabled) // ShowDataPointMarker(dataPoint); //else // HideDataPointMarker(dataPoint); break; case VcProperties.MarkerScale: case VcProperties.MarkerSize: case VcProperties.MarkerType: case VcProperties.ShadowEnabled: //Double y = Graphics.ValueToPixelPosition(plotGroup.AxisY.Height, 0, plotGroup.AxisY.InternalAxisMinimum, plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue); //LineChart.GetMarkerForDataPoint(true, chart, y, dataPoint, dataPoint.InternalYValue > 0); LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); break; case VcProperties.Opacity: if (marker != null) marker.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataSeries.Opacity; break; case VcProperties.ShowInLegend: chart.InvokeRender(); break; case VcProperties.ToolTipText: case VcProperties.XValueFormatString: case VcProperties.YValueFormatString: dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition); CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition, ref line2dLabelCanvas, true); break; case VcProperties.XValueType: chart.InvokeRender(); break; case VcProperties.Enabled: if ((Boolean)dataPoint.Parent.Enabled) UpdateDataSeries(dataPoint, VcProperties.Enabled, newValue); break; case VcProperties.XValue: if (Double.IsNaN(dataPoint._oldYValue) || dataPoint.Faces == null) // Broken point of broken line UpdateDataSeries(dataPoint.Parent, property, newValue); else UpdateXAndYValue(dataPoint, line2dLabelCanvas); break; case VcProperties.YValue: case VcProperties.YValues: if (Double.IsNaN(dataPoint._oldYValue) || Double.IsNaN(dataPoint.InternalYValue) || dataPoint.Faces == null) // Broken point of broken line UpdateDataSeries(dataPoint.Parent, property, newValue); else { //UpdateXAndYValue(dataPoint, ref line2dLabelCanvas); chart.Dispatcher.BeginInvoke(new Action<DataPoint, Canvas>(UpdateXAndYValue), new object[] { dataPoint, line2dLabelCanvas }); } break; } }
//internal static void Update(Chart chart, RenderAs currentRenderAs, List<DataSeries> selectedDataSeries4Rendering, VcProperties property, object newValue) //{ // Boolean is3D = chart.View3D; // ChartArea chartArea = chart.ChartArea; // Canvas ChartVisualCanvas = chart.ChartArea.ChartVisualCanvas; // // Double width = chart.ChartArea.ChartVisualCanvas.Width; // // Double height = chart.ChartArea.ChartVisualCanvas.Height; // Panel preExistingPanel = null; // Dictionary<RenderAs, Panel> RenderedCanvasList = chart.ChartArea.RenderedCanvasList; // if (chartArea.RenderedCanvasList.ContainsKey(currentRenderAs)) // { // preExistingPanel = RenderedCanvasList[currentRenderAs]; // } // Panel renderedChart = chartArea.RenderSeriesFromList(preExistingPanel, selectedDataSeries4Rendering); // if (preExistingPanel == null) // { // chartArea.RenderedCanvasList.Add(currentRenderAs, renderedChart); // ChartVisualCanvas.Children.Add(renderedChart); // } //} /// <summary> /// /// </summary> /// <param name="dataPoint"></param> /// <param name="property"></param> /// <param name="newValue"></param> /// <param name="isAxisChanged"></param> private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged) { Chart chart = dataPoint.Chart as Chart; if (chart == null) return; PlotDetails plotDetails = chart.PlotDetails; Marker marker = dataPoint.Marker; DataSeries dataSeries = dataPoint.Parent; if (dataSeries.Faces == null) return; Canvas pointChartCanvas = dataSeries.Faces.Visual as Canvas; Double plotHeight = chart.ChartArea.ChartVisualCanvas.Height; Double plotWidth = chart.ChartArea.ChartVisualCanvas.Width; ColumnChart.UpdateParentVisualCanvasSize(chart, pointChartCanvas); if (property == VcProperties.Enabled || ((dataPoint.Faces == null || Double.IsNaN(dataPoint.InternalYValue)) && (property == VcProperties.XValue || property == VcProperties.YValue))) { CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight); return; } if (dataPoint.Faces == null) return; //Grid bubbleVisual = dataPoint.Faces.Visual as Grid; switch (property) { case VcProperties.Bevel: break; case VcProperties.Cursor: break; case VcProperties.Href: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.HrefTarget: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.LabelBackground: if (marker != null) marker.TextBackground = dataPoint.LabelBackground; break; case VcProperties.LabelEnabled: CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight); //if (marker != null) // marker.LabelEnabled = (Boolean)dataPoint.LabelEnabled; break; case VcProperties.LabelFontColor: if (marker != null) marker.FontColor = dataPoint.LabelFontColor; break; case VcProperties.LabelFontFamily: if (marker != null) marker.FontFamily = dataPoint.LabelFontFamily; break; case VcProperties.LabelFontStyle: if (marker != null) marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle; break; //case VcProperties.LabelFontSize: // if (marker != null) // marker.FontSize = (Double)dataPoint.LabelFontSize; // break; case VcProperties.LabelFontWeight: if (marker != null) marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight; break; case VcProperties.LabelAngle: if (marker != null) marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight; break; case VcProperties.LegendText: chart.InvokeRender(); break; case VcProperties.Color: case VcProperties.LightingEnabled: if (marker != null) marker.MarkerShape.Fill = (chart.View3D ? Graphics.Get3DBrushLighting(dataPoint.Color, (Boolean)dataPoint.LightingEnabled) : ((Boolean)dataPoint.LightingEnabled ? Graphics.GetLightingEnabledBrush(dataPoint.Color, "Linear", null) : dataPoint.Color)); break; case VcProperties.MarkerBorderColor: if (marker != null) marker.BorderColor = dataPoint.MarkerBorderColor; break; case VcProperties.MarkerBorderThickness: if (marker != null) marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left; break; case VcProperties.MarkerColor: if (marker != null) marker.MarkerFillColor = dataPoint.MarkerColor; break; case VcProperties.LabelFontSize: case VcProperties.LabelStyle: case VcProperties.LabelText: case VcProperties.MarkerScale: case VcProperties.MarkerSize: case VcProperties.MarkerType: CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight); break; case VcProperties.ShadowEnabled: if (marker != null) { marker.ShadowEnabled = (Boolean)dataPoint.ShadowEnabled; marker.ApplyRemoveShadow(); } break; case VcProperties.Opacity: if (marker != null) marker.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataSeries.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); CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight); break; case VcProperties.XValueType: chart.InvokeRender(); break; case VcProperties.XValue: case VcProperties.YValue: case VcProperties.YValues: case VcProperties.DataPoints: if (isAxisChanged) UpdateDataSeries(dataSeries, property, newValue, false); else if (marker != null) { dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); if((Boolean)dataPoint.LabelEnabled) marker.Text = dataPoint.TextParser(dataPoint.LabelText); BubbleChart.UpdateBubblePositionAccording2XandYValue(dataPoint, plotWidth, plotHeight, (Boolean)chart.AnimatedUpdate, marker.MarkerShape.Width, marker.MarkerShape.Width); } break; } if (pointChartCanvas.Parent != null) { Double tickLengthOfAxisX = (from tick in chart.AxesX[0].Ticks where (Boolean)chart.AxesX[0].Enabled && (Boolean)tick.Enabled select (Double)tick.TickLength).Sum(); if (tickLengthOfAxisX == 0) tickLengthOfAxisX = 5; Double tickLengthOfPrimaryAxisY = (from axis in chart.AxesY where axis.AxisType == AxisTypes.Primary from tick in axis.Ticks where (Boolean)axis.Enabled && (Boolean)tick.Enabled select (Double)tick.TickLength).Sum(); if (tickLengthOfPrimaryAxisY == 0) tickLengthOfPrimaryAxisY = 8; Double tickLengthOfSecondaryAxisY = (from axis in chart.AxesY where axis.AxisType == AxisTypes.Secondary from tick in axis.Ticks where (Boolean)axis.Enabled && (Boolean)tick.Enabled select (Double)tick.TickLength).Sum(); if (tickLengthOfSecondaryAxisY == 0) tickLengthOfSecondaryAxisY = 8; Double plotGroupCount = (from c in chart.PlotDetails.PlotGroups where c.AxisY.AxisType == AxisTypes.Secondary select c).Count(); RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(-tickLengthOfPrimaryAxisY, -chart.ChartArea.PLANK_DEPTH - 4, plotWidth + tickLengthOfSecondaryAxisY + (plotGroupCount > 0 ? tickLengthOfPrimaryAxisY : 8) + chart.ChartArea.PLANK_OFFSET, plotHeight + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + tickLengthOfAxisX + 4); (pointChartCanvas.Parent as Canvas).Clip = clipRectangle; } }
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 = CalculateDataPointWidth(dsFaces.Visual.Width, dsFaces.Visual.Height, chart); switch (property) { case VcProperties.BorderThickness: ApplyOrUpdateBorder(dataPoint, dataPointWidth); ApplyOrRemoveBevel(dataPoint, dataPointWidth); break; case VcProperties.BorderStyle: ApplyOrUpdateBorder(dataPoint, dataPointWidth); break; case VcProperties.BorderColor: ApplyOrUpdateBorder(dataPoint, dataPointWidth); break; case VcProperties.Bevel: ApplyOrRemoveBevel(dataPoint, dataPointWidth); break; case VcProperties.Color: case VcProperties.PriceUpColor: case VcProperties.PriceDownColor: ApplyOrUpdateColorForACandleStick(dataPoint); 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: CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint); break; case VcProperties.LegendText: chart.InvokeRender(); break; case VcProperties.LightingEnabled: ApplyOrUpdateColorForACandleStick(dataPoint); 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: ApplyOrRemoveShadow(dataPoint, 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); CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint); break; case VcProperties.XValueType: chart.InvokeRender(); break; case VcProperties.Enabled: CreateOrUpdateACandleStick(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) CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint); } if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected) dataPoint.Select(true); break; } }
/// <summary> /// /// </summary> /// <param name="dataPoint"></param> /// <param name="property"></param> /// <param name="newValue"></param> /// <param name="isAxisChanged"></param> private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged) { Chart chart = dataPoint.Chart as Chart; if (chart == null) return; PlotDetails plotDetails = chart.PlotDetails; Marker marker = dataPoint.Marker; DataSeries dataSeries = dataPoint.Parent; if (dataSeries.Faces == null) return; Canvas bubleChartCanvas = dataSeries.Faces.Visual as Canvas; Double plotHeight = chart.ChartArea.ChartVisualCanvas.Height; Double plotWidth = chart.ChartArea.ChartVisualCanvas.Width; Double minimumZVal, maximumZVal; ColumnChart.UpdateParentVisualCanvasSize(chart, bubleChartCanvas); if (property == VcProperties.Enabled || ((dataPoint.Faces == null || Double.IsNaN(dataPoint.InternalYValue)) && (property == VcProperties.XValue || property == VcProperties.YValue))) { dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); // Calculate max and min ZValue from all DataSeries List<DataSeries> seriesList = (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.Bubble && ((Boolean)ds.Enabled == true) select ds).ToList(); CalculateMaxAndMinZValueFromAllSeries(ref seriesList, out minimumZVal, out maximumZVal); CreateOrUpdateAPointDataPoint(bubleChartCanvas, dataPoint, minimumZVal, maximumZVal, plotWidth, plotHeight); return; } if (dataPoint.Faces == null) return; Grid bubbleVisual = dataPoint.Faces.Visual as Grid; switch (property) { case VcProperties.Bevel: break; case VcProperties.Cursor: break; case VcProperties.Href: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.HrefTarget: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.LabelBackground: if (marker != null) marker.TextBackground = dataPoint.LabelBackground; break; case VcProperties.LabelEnabled: CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal); CreateOrUpdateAPointDataPoint(bubleChartCanvas, dataPoint, minimumZVal, maximumZVal, plotWidth, plotHeight); // if (marker != null) // marker.LabelEnabled = (Boolean)dataPoint.LabelEnabled; break; case VcProperties.LabelFontColor: if (marker != null) marker.FontColor = dataPoint.LabelFontColor; break; case VcProperties.LabelFontFamily: if (marker != null) marker.FontFamily = dataPoint.LabelFontFamily; break; case VcProperties.LabelFontStyle: if (marker != null) marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle; break; //case VcProperties.LabelFontSize: // if (marker != null) // marker.FontSize = (Double)dataPoint.LabelFontSize; // break; case VcProperties.LabelFontWeight: if (marker != null) marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight; break; case VcProperties.LabelAngle: if (marker != null) marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight; break; case VcProperties.LegendText: chart.InvokeRender(); break; case VcProperties.Color: case VcProperties.LightingEnabled: if (marker != null) marker.MarkerShape.Fill = (chart.View3D ? Graphics.Get3DBrushLighting(dataPoint.Color, (Boolean)dataPoint.LightingEnabled) : ((Boolean)dataPoint.LightingEnabled ? Graphics.GetLightingEnabledBrush(dataPoint.Color, "Linear", null) : dataPoint.Color)); break; case VcProperties.MarkerBorderColor: if (marker != null) marker.BorderColor = dataPoint.MarkerBorderColor; break; case VcProperties.MarkerBorderThickness: if (marker != null) marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left; break; case VcProperties.XValueFormatString: case VcProperties.YValueFormatString: case VcProperties.LabelFontSize: case VcProperties.LabelStyle: case VcProperties.LabelText: case VcProperties.MarkerScale: case VcProperties.MarkerSize: case VcProperties.MarkerType: dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal); CreateOrUpdateAPointDataPoint(bubleChartCanvas, dataPoint, minimumZVal, maximumZVal, plotWidth, plotHeight); break; case VcProperties.ShadowEnabled: if (marker != null) { marker.ShadowEnabled = (Boolean)dataPoint.ShadowEnabled; marker.ApplyRemoveShadow(); } break; case VcProperties.Opacity: if (marker != null) marker.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataSeries.Opacity; break; case VcProperties.ShowInLegend: chart.InvokeRender(); break; case VcProperties.ToolTipText: dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); break; case VcProperties.XValueType: chart.InvokeRender(); break; case VcProperties.XValue: case VcProperties.YValue: case VcProperties.YValues: case VcProperties.DataPoints: if (isAxisChanged) UpdateDataSeries(dataSeries, property, newValue, false); else if(marker != null) { dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); if ((Boolean)dataPoint.LabelEnabled) marker.Text = dataPoint.TextParser(dataPoint.LabelText); UpdateBubblePositionAccording2XandYValue(dataPoint, plotWidth, plotHeight, (Boolean)chart.AnimatedUpdate, marker.MarkerShape.Width, marker.MarkerShape.Width); } break; case VcProperties.ZValue: dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); //if ((Boolean)dataPoint.LabelEnabled) // marker.Text = dataPoint.TextParser(dataPoint.LabelText); List<DataSeries> seriesList = (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.Bubble && ((Boolean)ds.Enabled == true) select ds).ToList(); CalculateMaxAndMinZValueFromAllSeries(ref seriesList, out minimumZVal, out maximumZVal); // CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal); foreach (DataSeries ds in seriesList) { foreach (DataPoint dp in ds.InternalDataPoints) { if (Double.IsNaN(dp.InternalYValue) || (dp.Enabled == false)) continue; ApplyZValue(dp, minimumZVal, maximumZVal, plotWidth, plotHeight); } } break; } if (bubleChartCanvas.Parent != null) { RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(0, -(dataPoint.Chart as Chart).ChartArea.PLANK_DEPTH, plotWidth + (dataPoint.Chart as Chart).ChartArea.PLANK_OFFSET, plotHeight + (dataPoint.Chart as Chart).ChartArea.PLANK_DEPTH); (bubleChartCanvas.Parent as Canvas).Clip = clipRectangle; } }
/// <summary> /// /// </summary> /// <param name="dataPoint"></param> /// <param name="property"></param> /// <param name="newValue"></param> /// <param name="isAxisChanged"></param> private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged) { Chart chart = dataPoint.Chart as Chart; PlotDetails plotDetails = chart.PlotDetails; Marker marker = dataPoint.Marker; DataSeries dataSeries = dataPoint.Parent; PlotGroup plotGroup = dataSeries.PlotGroup; Canvas areaVisual = dataSeries.Faces.Visual as Canvas; Canvas labelCanvas = ((areaVisual as FrameworkElement).Parent as Panel).Children[0] as Canvas; Double height = chart.ChartArea.ChartVisualCanvas.Height; Double width = chart.ChartArea.ChartVisualCanvas.Width; Double xPosition, yPosition; Faces faces = dataPoint.Faces; switch (property) { case VcProperties.Bevel: UpdateDataSeries(dataSeries, property, newValue); break; case VcProperties.Color: case VcProperties.LightingEnabled: if (property != VcProperties.LightingEnabled && marker != null && (Boolean)dataPoint.MarkerEnabled) marker.BorderColor = (dataPoint.GetValue(DataPoint.MarkerBorderColorProperty) as Brush == null) ? ((newValue != null) ? newValue as Brush : dataPoint.MarkerBorderColor) : dataPoint.MarkerBorderColor; if (faces != null) { if(dataPoint.Faces.BevelLine != null) dataPoint.Faces.BevelLine.Stroke = Graphics.GetBevelTopBrush(dataPoint.Parent.Color); Brush sideBrush = (Boolean)dataSeries.LightingEnabled ? Graphics.GetRightFaceBrush(dataSeries.Color) : dataSeries.Color; Brush topBrush = (Boolean)dataSeries.LightingEnabled ? Graphics.GetTopFaceBrush(dataSeries.Color) : dataSeries.Color; if (dataPoint.Faces.Area3DLeftFace != null) (dataPoint.Faces.Area3DLeftFace.LeftFace as Path).Fill = sideBrush; if (dataPoint.Faces.Area3DRightTopFace != null) (dataPoint.Faces.Area3DRightTopFace.TopFace as Path).Fill = topBrush; if (dataPoint.Faces.Area3DLeftTopFace != null) (dataPoint.Faces.Area3DLeftTopFace.TopFace as Path).Fill = topBrush; if (dataPoint.Faces.Area3DRightFace != null) (dataPoint.Faces.Area3DRightFace.RightFace as Path).Fill = sideBrush; } break; case VcProperties.Opacity: Double opacity = dataPoint.Opacity * dataSeries.Opacity; if (marker != null) marker.Visual.Opacity = opacity; if (faces != null) { if (dataPoint.Faces.BevelLine != null) dataPoint.Faces.BevelLine.Opacity = opacity; if (dataPoint.Faces.Area3DLeftFace != null) (dataPoint.Faces.Area3DLeftFace.LeftFace as Path).Opacity = opacity; if (dataPoint.Faces.Area3DRightTopFace != null) (dataPoint.Faces.Area3DRightTopFace.TopFace as Path).Opacity = opacity; if (dataPoint.Faces.Area3DLeftTopFace != null) (dataPoint.Faces.Area3DLeftTopFace.TopFace as Path).Opacity = opacity; if (dataPoint.Faces.Area3DRightFace != null) (dataPoint.Faces.Area3DRightFace.RightFace as Path).Opacity = opacity; } break; case VcProperties.BorderColor: case VcProperties.BorderStyle: case VcProperties.BorderThickness: if (faces != null) { if (dataPoint.Faces.Area3DLeftFace != null) ApplyBorderProperties(dataPoint.Faces.Area3DLeftFace.LeftFace as Path, dataSeries); if (dataPoint.Faces.Area3DRightTopFace != null) ApplyBorderProperties(dataPoint.Faces.Area3DRightTopFace.TopFace as Path, dataSeries); if (dataPoint.Faces.Area3DLeftTopFace != null) ApplyBorderProperties(dataPoint.Faces.Area3DLeftTopFace.TopFace as Path, dataSeries); if (dataPoint.Faces.Area3DRightFace != null) ApplyBorderProperties(dataPoint.Faces.Area3DRightFace.RightFace as Path, dataSeries); } break; case VcProperties.Cursor: dataPoint.SetCursor2DataPointVisualFaces(); break; case VcProperties.Href: case VcProperties.HrefTarget: dataPoint.SetHref2DataPointVisualFaces(); break; case VcProperties.LabelBackground: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); marker.TextBackground = dataPoint.LabelBackground; break; case VcProperties.LabelEnabled: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); break; case VcProperties.LabelFontColor: marker.FontColor = dataPoint.LabelFontColor; break; case VcProperties.LabelFontFamily: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); // marker.FontFamily = dataPoint.LabelFontFamily; break; case VcProperties.LabelFontStyle: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); //marker.FontStyle = (FontStyle) dataPoint.LabelFontStyle; break; case VcProperties.LabelFontSize: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); // marker.FontSize = (Double) dataPoint.LabelFontSize; break; case VcProperties.LabelFontWeight: marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight; break; case VcProperties.LabelStyle: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); break; case VcProperties.LabelText: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); //marker.Text = dataPoint.TextParser(dataPoint.LabelText); break; case VcProperties.LabelAngle: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); //marker.Text = dataPoint.TextParser(dataPoint.LabelText); break; case VcProperties.LegendText: chart.InvokeRender(); break; case VcProperties.MarkerBorderColor: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); //marker.BorderColor = dataPoint.MarkerBorderColor; break; case VcProperties.MarkerBorderThickness: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); //marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left; break; case VcProperties.MarkerColor: if(marker != null && (Boolean) dataPoint.MarkerEnabled) marker.MarkerFillColor = dataPoint.MarkerColor; break; case VcProperties.MarkerEnabled: LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); // if((Boolean)dataPoint.MarkerEnabled) // ShowDataPointMarker(dataPoint); // else // HideDataPointMarker(dataPoint); break; case VcProperties.MarkerScale: case VcProperties.MarkerSize: case VcProperties.MarkerType: case VcProperties.ShadowEnabled: // Double y = Graphics.ValueToPixelPosition(plotGroup.AxisY.Height, 0, plotGroup.AxisY.InternalAxisMinimum, plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue); // LineChart.GetMarkerForDataPoint(true, chart, y, dataPoint, dataPoint.InternalYValue > 0); LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); break; case VcProperties.ShowInLegend: chart.InvokeRender(); break; case VcProperties.ToolTipText: case VcProperties.XValueFormatString: case VcProperties.YValueFormatString: dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition); break; case VcProperties.XValueType: chart.InvokeRender(); break; case VcProperties.Enabled: UpdateDataSeries(dataSeries, property, newValue); break; case VcProperties.XValue: UpdateDataSeries(dataSeries, property, newValue); break; case VcProperties.YValue: if (isAxisChanged || dataPoint._oldYValue > 0 && dataPoint.InternalYValue < 0 || dataPoint._oldYValue < 0 && dataPoint.InternalYValue > 0) UpdateDataSeries(dataSeries, property, newValue); else { dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); UpdateVisualForYValue4AreaChart(chart, dataPoint, isAxisChanged); //chart.Dispatcher.BeginInvoke(new Action<Chart, DataPoint, Boolean>(UpdateVisualForYValue4AreaChart), new object[] { chart, dataPoint, isAxisChanged}); } chart._toolTip.Hide(); // chart.Dispatcher.BeginInvoke(new Action<DataPoint>(UpdateXAndYValue), new object[]{dataPoint}); break; } }
private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged) { Chart chart = dataPoint.Chart as Chart; if (chart == null) return; 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 || (dpFaces == null && (property == VcProperties.XValue || property == VcProperties.YValues))) { 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 = (Double)dataSeries.Opacity * (Double)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.YValue: case VcProperties.YValues: if (isAxisChanged || dataPoint.InternalYValues == null) 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; } }