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> /// Initializes a new instance of the Visifire.Charts.PlotDetails class /// </summary> public CircularPlotDetails(ChartOrientationType chartOrientation, RenderAs renderAs) { ChartOrientation = chartOrientation; CircularChartType = renderAs; ListOfPoints4CircularAxis = new List<Point>(); }
private void CmbChartShapeSelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { _renderAs = (RenderAs)e.AddedItems[0]; DrawChart(_dataInfos, _renderAs); } }
/// <summary> /// Initializes a new instance of the Visifire.Charts.PlotGroup class. /// </summary> /// <param name="renderAs">RenderAs</param> /// <param name="axisX">axisX</param> /// <param name="axisY">AxisY</param> public PlotGroup(RenderAs renderAs, Axis axisX, Axis axisY) { DataSeriesList = new List<DataSeries>(); XWiseStackedDataList = new Dictionary<Double, XWiseStackedData>(); RenderAs = renderAs; AxisX = axisX; AxisY = axisY; }
/// <summary> /// Initializes a new instance of the Visifire.Charts.PlotGroup class. /// </summary> /// <param name="renderAs">RenderAs</param> /// <param name="axisX">axisX</param> /// <param name="axisY">AxisY</param> public PlotGroup(RenderAs renderAs, Axis axisX, Axis axisY) { DataSeriesList = new List <DataSeries>(); XWiseStackedDataList = new Dictionary <Double, XWiseStackedData>(); RenderAs = renderAs; AxisX = axisX; AxisY = axisY; }
/// <summary> /// Validates PartialUpdate /// </summary> /// <param name="chart">Chart</param> /// <returns>true - Get entry for PartialUpdate /// false - Get entry for PartialUpdate</returns> internal virtual Boolean ValidatePartialUpdate(RenderAs renderAs, VcProperties property) { Chart chart = Chart as Chart; if (chart == null || chart.ChartArea == null || chart.ChartArea._isFirstTimeRender) { return(false); } else { return(true); } }
/// <summary> /// 속성들을 Xml Attribute로 생성합니다. /// </summary> /// <param name="writer">Attribute를 쓸 Writer</param> public override void GenerateXmlAttributes(System.Xml.XmlWriter writer) { base.GenerateXmlAttributes(writer); if (SeriesName.IsNotWhiteSpace()) { writer.WriteAttributeString("seriesName", SeriesName); } if (Color.HasValue) { writer.WriteAttributeString("color", Color.Value.ToHexString()); } if (Alpha.IsNotWhiteSpace()) { writer.WriteAttributeString("alpha", Alpha); } if (Ratio.IsNotWhiteSpace()) { writer.WriteAttributeString("ratio", Ratio); } if (ShowValues.HasValue) { writer.WriteAttributeString("showValues", ShowValues.GetHashCode().ToString()); } if (Dashed.HasValue) { writer.WriteAttributeString("dashed", Dashed.GetHashCode().ToString()); } if (IncludeInLegend.HasValue) { writer.WriteAttributeString("includeInLegend", IncludeInLegend.GetHashCode().ToString()); } if (RenderAs.HasValue) { writer.WriteAttributeString("renderAs", RenderAs.ToString()); } if (ParentYAxis.HasValue) { writer.WriteAttributeString("parentYAxis", ParentYAxis.ToString()); } if (_anchorAttr != null) { _anchorAttr.GenerateXmlAttributes(writer); } if (_lineAttr != null) { _lineAttr.GenerateXmlAttributes(writer); } }
public override void WriteInitializationScript(System.IO.TextWriter writer) { if (ErrorCorrection != DefaultErrorCorrection) { Options["errorCorrection"] = ErrorCorrection.ToString(); } if (Encoding != DefaultEncoding) { Options["encoding"] = Encoding.ToString(); } if (!string.IsNullOrEmpty(Value)) { Options["value"] = Value; } if (RenderAs.HasValue) { Options["renderAs"] = RenderAs.ToString().ToLowerInvariant(); } if (!string.IsNullOrEmpty(Background)) { Options["background"] = Background; } if (!string.IsNullOrEmpty(Color)) { Options["color"] = Color; } if (this.Size.HasValue) { Options["size"] = Size; } if (this.Border.ShouldSerialize()) { Options["border"] = Border.ToJson(); } if (Padding.HasValue) { Options["padding"] = Padding; } writer.Write(Initializer.Initialize(Selector, "QRCode", Options)); base.WriteInitializationScript(writer); }
/// <summary> /// 图表类型更改(下拉列表) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { //设置当前所选择的图表类型 this.render = this.SelectedRenderAsEntity.RenderType; //刷新图表 this.Reflesh(); } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } }
internal static Boolean NonPartialUpdateChartTypes(RenderAs renderAs) { switch (renderAs) { case RenderAs.StackedArea: case RenderAs.StackedArea100: case RenderAs.Pie: case RenderAs.Doughnut: case RenderAs.SectionFunnel: case RenderAs.StreamLineFunnel: return(true); default: return(false); } }
public static void InitDataSerise(DataSeries ds, bool showInLengend, string lengendText, Brush brush,RenderAs render) { if (ds == null) { ds = new DataSeries(); } ds.ShowInLegend = showInLengend; ds.RenderAs = render; if (brush != null) { ds.Color = brush; } if (showInLengend) { ds.LegendText = lengendText; } }
protected virtual void Serialize(IDictionary <string, object> options) { SerializeData("chartArea", ChartArea.CreateSerializer().Serialize(), options); SerializeData("plotArea", PlotArea.CreateSerializer().Serialize(), options); SerializeTheme(options); if (RenderAs.HasValue) { options.Add("renderAs", RenderAs.ToString().ToLowerInvariant()); } SerializeData("title", Title.CreateSerializer().Serialize(), options); SerializeData("legend", Legend.CreateSerializer().Serialize(), options); SerializeSeries(options); SerializePanes(options); SerializeData("seriesDefaults", SeriesDefaults.CreateSerializer().Serialize(), options); SerializeData("axisDefaults", AxisDefaults.CreateSerializer().Serialize(), options); SerializeAxes("categoryAxis", CategoryAxes, options); SerializeAxes("valueAxis", ValueAxes, options); SerializeAxes("xAxis", XAxes, options); SerializeAxes("yAxis", YAxes, options); SerializeTransitions(options); SerializeDataSource(options); SerializeSeriesColors(options); SerializeData("tooltip", Tooltip.CreateSerializer().Serialize(), options); if (AutoBind.HasValue) { options.Add("autoBind", AutoBind.Value); } }
/// <summary> /// Validates PartialUpdate /// </summary> /// <param name="chart">Chart</param> /// <returns>true - Get entry for PartialUpdate /// false - Get entry for PartialUpdate</returns> internal virtual Boolean ValidatePartialUpdate(RenderAs renderAs, VcProperties property) { Chart chart = Chart as Chart; if (chart == null || chart.ChartArea == null || chart.ChartArea._isFirstTimeRender) { return(false); } else if ((chart.SamplingThreshold != 0 && property != VcProperties.ScrollBarScale) || (chart.PlotDetails != null && chart.PlotDetails.AutoFitToPlotArea && property != VcProperties.ScrollBarScale)) { FirePropertyChanged(property); return(false); } else { return(true); } }
public override void WriteInitializationScript(TextWriter writer) { var options = new Dictionary <string, object>(); SerializeData("gaugeArea", this.GaugeArea.CreateSerializer().Serialize(), options); SerializeData("pointer", this.Pointer.CreateSerializer().Serialize(), options); SerializeData("scale", this.Scale.CreateSerializer().Serialize(), options); if (RenderAs.HasValue) { options.Add("renderAs", RenderAs.ToString().ToLowerInvariant()); } SerializeTheme(options); SerializeTransitions(options); writer.Write(Initializer.Initialize(Selector, "LinearGauge", options)); base.WriteInitializationScript(writer); }
/// <summary> /// Returns curved path segment /// </summary> /// <param name="pieParams">Pie parameters</param> /// <param name="radius">Radius</param> /// <param name="startAngle">StartAngle</param> /// <param name="stopAngle">StopAngle</param> /// <param name="topFaceCenter">Top face center</param> /// <param name="bottomFaceCenter">Bottom face center</param> /// <param name="centroid">Centroid</param> /// <param name="isOuterSide">Whether outer side curve</param> /// <returns>Path</returns> private static Path GetCurvedSegment(SectorChartShapeParams pieParams, Double radius, Double startAngle, Double stopAngle, Point3D topFaceCenter, Point3D bottomFaceCenter, Point3D centroid, Boolean isOuterSide, RenderAs renderAs) { Point3D topArcStart = new Point3D(); topArcStart.X = topFaceCenter.X + radius * Math.Cos(startAngle); topArcStart.Y = topFaceCenter.Y + radius * Math.Sin(startAngle) * pieParams.YAxisScaling; topArcStart.Z = (topFaceCenter.Z + radius) * Math.Sin(startAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle); Point3D topArcStop = new Point3D(); topArcStop.X = topFaceCenter.X + radius * Math.Cos(stopAngle); topArcStop.Y = topFaceCenter.Y + radius * Math.Sin(stopAngle) * pieParams.YAxisScaling; topArcStop.Z = (topFaceCenter.Z + radius) * Math.Sin(stopAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle); Point3D bottomArcStart = new Point3D(); bottomArcStart.X = bottomFaceCenter.X + radius * Math.Cos(startAngle); bottomArcStart.Y = bottomFaceCenter.Y + radius * Math.Sin(startAngle) * pieParams.YAxisScaling; bottomArcStart.Z = (bottomFaceCenter.Z + radius) * Math.Sin(startAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle); Point3D bottomArcStop = new Point3D(); bottomArcStop.X = bottomFaceCenter.X + radius * Math.Cos(stopAngle); bottomArcStop.Y = bottomFaceCenter.Y + radius * Math.Sin(stopAngle) * pieParams.YAxisScaling; bottomArcStop.Z = (bottomFaceCenter.Z + radius) * Math.Sin(stopAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle); Path pieFace = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } }; // pieFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Linear", new Double[] { 0.745, 0.99, }) : pieParams.Background; pieFace.Fill = Get3DFaceColor(RenderAs.Doughnut, pieParams.Lighting, pieParams.Background, PieFaceTypes.CurvedSurface, startAngle,stopAngle, pieParams.TiltAngle); //if (renderAs == RenderAs.Pie) //{ // pieFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, startAngle * 180 / Math.PI, "Linear", new Double[] { 0.99, 0.845 }) : pieParams.Background; //} //else //{ // if (stopAngle > Math.PI) // pieFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, pieParams.TiltAngle * 180 / Math.PI, "Linear", new Double[] { 0.99, 0.845 }) : pieParams.Background; // else // pieFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, startAngle * 180 / Math.PI, "Linear", new Double[] { 0.99, 0.845 }) : pieParams.Background; //} List<PathGeometryParams> pathGeometryList = new List<PathGeometryParams>(); Boolean isLargeArc = (Math.Abs(stopAngle - startAngle) > Math.PI) ? true : false; if (stopAngle < startAngle) isLargeArc = (Math.Abs((stopAngle + Math.PI * 2) - startAngle) > Math.PI) ? true : false; pathGeometryList.Add(new LineSegmentParams(new Point(topArcStop.X, topArcStop.Y))); pathGeometryList.Add(new ArcSegmentParams(new Size(radius, radius * pieParams.YAxisScaling), 0, isLargeArc, SweepDirection.Counterclockwise, new Point(topArcStart.X, topArcStart.Y))); pathGeometryList.Add(new LineSegmentParams(new Point(bottomArcStart.X, bottomArcStart.Y))); pathGeometryList.Add(new ArcSegmentParams(new Size(radius, radius * pieParams.YAxisScaling), 0, isLargeArc, SweepDirection.Clockwise, new Point(bottomArcStop.X, bottomArcStop.Y))); pieFace.Data = GetPathGeometryFromList(FillRule.Nonzero, new Point(bottomArcStop.X, bottomArcStop.Y), pathGeometryList, true); PathFigure figure = (pieFace.Data as PathGeometry).Figures[0]; PathSegmentCollection segments = figure.Segments; return pieFace; }
public static void UpdateVisualForYValue4StackedColumnChart(RenderAs chartType, Chart chart, DataPoint dataPoint, Boolean isAxisChanged) { if (dataPoint.Faces == null) return; System.Diagnostics.Debug.WriteLine("Animate--YValue" + dataPoint.YValue.ToString() + " IsAxisChange=" + isAxisChanged.ToString()); Boolean animationEnabled = chart.AnimatedUpdate; // Whether the animation for the DataPoint is enabled DataSeries dataSeries = dataPoint.Parent; // parent of the current DataPoint Canvas dataPointVisual = dataPoint.Faces.Visual as Canvas; // Old visual for the column Canvas labelCanvas = dataPoint.Faces.LabelCanvas;// (columnCanvas.Parent as Canvas).Children[0] as Canvas; // Parent canvas of Datapoint label Canvas columnCanvas = (labelCanvas.Parent as Canvas).Children[1] as Canvas; //dataSeries.Faces.Visual as Canvas;// dataPointVisual.Parent as Canvas; // Existing parent canvas of column UpdateParentVisualCanvasSize(chart, columnCanvas); UpdateParentVisualCanvasSize(chart, labelCanvas); Double height = labelCanvas.Height; Double width = labelCanvas.Width; PlotGroup plotGroup = dataSeries.PlotGroup; // PlotGroup reference // Calculate 3d depth for the DataPoints Double depth3d = chart.ChartArea.PLANK_DEPTH / chart.PlotDetails.Layer3DCount * (chart.View3D ? 1 : 0); // Calculate required parameters for Creating new Stacked Columns Double minDiff, widthPerColumn, maxColumnWidth; widthPerColumn = CalculateWidthOfEachStackedColumn(chart, plotGroup, width, out minDiff, out maxColumnWidth); // List of effected DataPoints for the current update of YValue property of the DataPoint XWiseStackedData effectedDataPoints = plotGroup.XWiseStackedDataList[dataPoint.InternalXValue]; // Marging all DataPoints in to single a single list of DataPoint List<DataPoint> positiveList = effectedDataPoints.Positive.ToList(); List<DataPoint> negativeList = effectedDataPoints.Negative.ToList(); List<DataPoint> listOfDataPoint = new List<DataPoint>(); listOfDataPoint.AddRange(positiveList); listOfDataPoint.AddRange(negativeList); // Storing reference of old Visual foreach(DataPoint dp in listOfDataPoint) { if (dp.Marker != null && dp.Marker.Visual != null) dp._oldMarkerPosition = new Point((Double)dp.Marker.Visual.GetValue(Canvas.LeftProperty), (Double)dp.Marker.Visual.GetValue(Canvas.TopProperty)); if (dp.LabelVisual != null) dp._oldLabelPosition = new Point((Double)dp.LabelVisual.GetValue(Canvas.LeftProperty), (Double)dp.LabelVisual.GetValue(Canvas.TopProperty)); if (dp.Faces != null) { dp._oldVisual = dp.Faces.Visual; columnCanvas.Children.Remove(dp._oldVisual); } } // Calculate limiting value Double limitingYValue = (plotGroup.AxisY.InternalAxisMinimum > 0)? plotGroup.AxisY.InternalAxisMinimum : (plotGroup.AxisY.InternalAxisMaximum < 0)? plotGroup.AxisY.InternalAxisMaximum : 0; // Create new Column with new YValue DrawStackedColumnsAtXValue(chartType, dataPoint.InternalXValue, plotGroup, columnCanvas, labelCanvas, plotGroup.DrawingIndex, dataPointVisual.Width, maxColumnWidth, limitingYValue, depth3d, false); Boolean isPositive; if (animationEnabled) { // Create new Storyboard for animation if (dataPoint.Storyboard != null) { dataPoint.Storyboard.Stop(); dataPoint.Storyboard = null; } dataPoint.Storyboard = new Storyboard(); // Whether to animate the top of DataPoint Visual Boolean isAnimateTop = false; // Loop through all Datapoints under the PlotGroup of the current DataPoint and apply animation foreach (DataPoint dp in listOfDataPoint) { if (dp.Faces == null || dp._oldVisual == null) continue; FrameworkElement newVisual = dp.Faces.Visual; // New StackedColumn visual reference of DataPoint Double oldTop = (Double)dp._oldVisual.GetValue(Canvas.TopProperty); // Top of the old visual of the DataPoint Double newTop = (Double)newVisual.GetValue(Canvas.TopProperty); // Top of the new visual of the DataPoint Double oldHeight = dp._oldVisual.Height; // Height of the old visual of the DataPoint Double newHeight = newVisual.Height; // Height of the new visual of the DataPoint Double oldScale = oldHeight / newHeight; // Scale value for the old DataPoint System.Diagnostics.Debug.WriteLine("DataPoint--oldTop =" + oldTop.ToString() + " newTop=" + newTop.ToString() + "oldYValue=" + dp._oldYValue.ToString() + " newYValue=" + dp.InternalYValue.ToString()); if (dp == dataPoint) { isPositive = (dataPoint._oldYValue < 0 && dataPoint.InternalYValue > 0) ? true : (dataPoint._oldYValue > 0 && dataPoint.InternalYValue < 0) ? false : dp._oldYValue >= 0 ? true : false; } else isPositive = dp.InternalYValue >= 0 ? true : false; if (isPositive) newVisual.RenderTransformOrigin = new Point(0.5, 1); else newVisual.RenderTransformOrigin = new Point(0.5, 0); // Apply new RenderTransform to the DataPoint Visual newVisual.RenderTransform = new ScaleTransform(); if(Double.IsInfinity(oldScale) || Double.IsNaN(oldScale)) oldScale = 0; // if (oldScale > 1) // oldScale = 1.1; if (oldScale != 1) dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(newVisual, "(UIElement.RenderTransform).(ScaleTransform.ScaleY)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { oldScale, 1 }, null); if ((isAnimateTop && oldTop != newTop) || (dp._oldYValue == dp.InternalYValue && oldTop != newTop)) { System.Diagnostics.Debug.WriteLine("Animate Top ----"); newVisual.SetValue(Canvas.TopProperty, oldTop); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(newVisual, "(Canvas.Top)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { oldTop, newTop }, null); } if (dp == dataPoint) isAnimateTop = true; // Apply animation to markers if marker exists if (dp.Marker != null && dp.Marker.Visual != null) { Double markerNewTop = (Double)dp.Marker.Visual.GetValue(Canvas.TopProperty); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(dp.Marker.Visual, "(Canvas.Top)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { dp._oldMarkerPosition.Y, markerNewTop }, null); dp.Marker.Visual.SetValue(Canvas.TopProperty, dp._oldMarkerPosition.Y); } if (dp.LabelVisual != null) { Double labelNewTop = (Double)dp.LabelVisual.GetValue(Canvas.TopProperty); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(dp.LabelVisual, "(Canvas.Top)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { dp._oldLabelPosition.Y, labelNewTop }, null); dp.LabelVisual.SetValue(Canvas.TopProperty, dp._oldLabelPosition.Y); } dataPoint.Storyboard.SpeedRatio = 2; // Remove old visual of the DataPoint from the columncanvas dp._oldVisual = null; } dataPoint.Storyboard.SpeedRatio = 2; // Begin storyboard animation #if WPF dataPoint.Storyboard.Begin(dataPoint.Chart._rootElement, true); #else dataPoint.Storyboard.Begin(); #endif } if (columnCanvas.Parent != null) { width = chart.ChartArea.ChartVisualCanvas.Width; height = chart.ChartArea.ChartVisualCanvas.Height; RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(0, -chart.ChartArea.PLANK_DEPTH - (chart.View3D ? 0 : 5), width + chart.ChartArea.PLANK_DEPTH, height + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + (chart.View3D ? 0 : 10)); (columnCanvas.Parent as Canvas).Clip = clipRectangle; } if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected) dataPoint.Select(true); }
/// <summary> /// Get visual object for stacked column chart /// </summary> /// <param name="width">Width of the PlotArea</param> /// <param name="height">Height of the PlotArea</param> /// <param name="plotDetails">PlotDetails</param> /// <param name="chart">Chart</param> /// <param name="plankDepth">PlankDepth</param> /// <param name="animationEnabled">Whether animation is enabled for chart</param> /// <returns>StackedColumn chart canvas</returns> internal static Canvas GetVisualObjectForStackedColumnChart(RenderAs chartType, Panel preExistingPanel, Double width, Double height, PlotDetails plotDetails, Chart chart, Double plankDepth, bool animationEnabled) { if (Double.IsNaN(width) || Double.IsNaN(height) || width <= 0 || height <= 0) return null; Canvas visual, labelCanvas, columnCanvas; RenderHelper.RepareCanvas4Drawing(preExistingPanel as Canvas, out visual, out labelCanvas, out columnCanvas, width, height); List<PlotGroup> plotGroupList = (from plots in plotDetails.PlotGroups where plots.RenderAs == chartType select plots).ToList(); Double depth3d = plankDepth / plotDetails.Layer3DCount * (chart.View3D ? 1 : 0); Double visualOffset = depth3d * (plotDetails.SeriesDrawingIndex[plotGroupList[0].DataSeriesList[0]] + 1); visual.SetValue(Canvas.TopProperty, visualOffset); visual.SetValue(Canvas.LeftProperty, -visualOffset); List<DataSeries> seriesList = plotDetails.GetSeriesListByRenderAs(chartType); Dictionary<Axis, Dictionary<Axis, Int32>> seriesIndex = ColumnChart.GetSeriesIndex(seriesList); Double minDiff, widthPerColumn, maxColumnWidth; DataSeries currentDataSeries = null; foreach (PlotGroup plotGroup in plotGroupList) { if (!seriesIndex.ContainsKey(plotGroup.AxisY)) continue; currentDataSeries = plotGroup.DataSeriesList[0]; List<Double> xValuesList = plotGroup.XWiseStackedDataList.Keys.ToList(); plotGroup.DrawingIndex = seriesIndex[plotGroup.AxisY][plotGroup.AxisX]; widthPerColumn = CalculateWidthOfEachStackedColumn(chart, plotGroup, width, out minDiff, out maxColumnWidth); Double limitingYValue = 0; if (plotGroup.AxisY.InternalAxisMinimum > 0) limitingYValue = (Double)plotGroup.AxisY.InternalAxisMinimum; if (plotGroup.AxisY.InternalAxisMaximum < 0) limitingYValue = (Double)plotGroup.AxisY.InternalAxisMaximum; foreach (Double xValue in xValuesList) { DrawStackedColumnsAtXValue(chartType, xValue, plotGroup, columnCanvas, labelCanvas, plotGroup.DrawingIndex, widthPerColumn, maxColumnWidth, limitingYValue, depth3d, animationEnabled); } } // Apply animation if (animationEnabled && currentDataSeries != null) { if (currentDataSeries.Storyboard == null) currentDataSeries.Storyboard = new Storyboard(); // Apply animation to the marker and labels currentDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, currentDataSeries, currentDataSeries.Storyboard, 1, 1, 0, 1); } ColumnChart.CreateOrUpdatePlank(chart, plotGroupList[0].AxisY, columnCanvas, 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(columnCanvas); } else { labelCanvas.SetValue(Canvas.ZIndexProperty, 1); visual.Children.Add(labelCanvas); visual.Children.Add(columnCanvas); } RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(0, -chart.ChartArea.PLANK_DEPTH - (chart.View3D ? 0 : 5), width + chart.ChartArea.PLANK_DEPTH, height + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + (chart.View3D ? 0 : 10)); 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(); }
/// <summary> /// Get visual object for stacked column chart /// </summary> /// <param name="width">Width of the PlotArea</param> /// <param name="height">Height of the PlotArea</param> /// <param name="plotDetails">PlotDetails</param> /// <param name="chart">Chart</param> /// <param name="plankDepth">PlankDepth</param> /// <param name="animationEnabled">Whether animation is enabled for chart</param> /// <returns>StackedColumn chart canvas</returns> internal static Canvas GetVisualObjectForStackedColumnChart(RenderAs chartType, Panel preExistingPanel, Double width, Double height, PlotDetails plotDetails, Chart chart, Double plankDepth, bool animationEnabled) { if (Double.IsNaN(width) || Double.IsNaN(height) || width <= 0 || height <= 0) { return(null); } Canvas visual, labelCanvas, columnCanvas; RenderHelper.RepareCanvas4Drawing(preExistingPanel as Canvas, out visual, out labelCanvas, out columnCanvas, width, height); List <PlotGroup> plotGroupList = (from plots in plotDetails.PlotGroups where plots.RenderAs == chartType select plots).ToList(); Double depth3d = plankDepth / plotDetails.Layer3DCount * (chart.View3D ? 1 : 0); Double visualOffset = depth3d * (plotDetails.SeriesDrawingIndex[plotGroupList[0].DataSeriesList[0]] + 1); visual.SetValue(Canvas.TopProperty, visualOffset); visual.SetValue(Canvas.LeftProperty, -visualOffset); List <DataSeries> seriesList = plotDetails.GetSeriesListByRenderAs(chartType); Dictionary <Axis, Dictionary <Axis, Int32> > seriesIndex = ColumnChart.GetSeriesIndex(seriesList); Double minDiff, widthPerColumn, maxColumnWidth; DataSeries currentDataSeries = null; foreach (PlotGroup plotGroup in plotGroupList) { if (!seriesIndex.ContainsKey(plotGroup.AxisY)) { continue; } currentDataSeries = plotGroup.DataSeriesList[0]; List <Double> xValuesList = plotGroup.XWiseStackedDataList.Keys.ToList(); plotGroup.DrawingIndex = seriesIndex[plotGroup.AxisY][plotGroup.AxisX]; widthPerColumn = CalculateWidthOfEachStackedColumn(chart, plotGroup, width, out minDiff, out maxColumnWidth); Double limitingYValue = 0; if (plotGroup.AxisY.InternalAxisMinimum > 0) { limitingYValue = (Double)plotGroup.AxisY.InternalAxisMinimum; } if (plotGroup.AxisY.InternalAxisMaximum < 0) { limitingYValue = (Double)plotGroup.AxisY.InternalAxisMaximum; } foreach (Double xValue in xValuesList) { DrawStackedColumnsAtXValue(chartType, xValue, plotGroup, columnCanvas, labelCanvas, plotGroup.DrawingIndex, widthPerColumn, maxColumnWidth, limitingYValue, depth3d, animationEnabled); } } // Apply animation if (animationEnabled && currentDataSeries != null) { if (currentDataSeries.Storyboard == null) { currentDataSeries.Storyboard = new Storyboard(); } // Apply animation to the marker and labels currentDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, currentDataSeries, currentDataSeries.Storyboard, 1, 1, 0, 1); } ColumnChart.CreateOrUpdatePlank(chart, plotGroupList[0].AxisY, columnCanvas, 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(columnCanvas); } else { labelCanvas.SetValue(Canvas.ZIndexProperty, 1); visual.Children.Add(labelCanvas); visual.Children.Add(columnCanvas); } RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(0, -chart.ChartArea.PLANK_DEPTH - (chart.View3D ? 0 : 5), width + chart.ChartArea.PLANK_DEPTH, height + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + (chart.View3D ? 0 : 10)); 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); //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 void DrawStackedBarsAtXValue(RenderAs chartType, Double xValue, PlotGroup plotGroup, Canvas columnCanvas, Canvas labelCanvas, Double drawingIndex, Double heightPerBar, Double maxBarHeight, Double limitingYValue, Double depth3d, Boolean animationEnabled) { RectangularChartShapeParams barParams = new RectangularChartShapeParams(); barParams.ShadowOffset = 5; barParams.Depth = depth3d; barParams.IsStacked = true; Boolean isTopOFStack; DataPoint dataPointAtTopOfStack = null; Int32 positiveIndex = 1, negativeIndex = 1; Double top = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, xValue) + drawingIndex * heightPerBar - (maxBarHeight / 2); Double left = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue); Double columnHeight = CalculateHeightOfEachColumn(ref top, heightPerBar, columnCanvas.Height); Double right=0; Double prevSum = 0; Double animationBeginTime = 0.4; Double animationTime = 1.0 / plotGroup.XWiseStackedDataList[xValue].Positive.Count; if (plotGroup.XWiseStackedDataList[xValue].Positive.Count > 0) dataPointAtTopOfStack = plotGroup.XWiseStackedDataList[xValue].Positive.Last(); Double absoluteSum = Double.NaN; if (chartType == RenderAs.StackedBar100) absoluteSum = plotGroup.XWiseStackedDataList[xValue].AbsoluteYValueSum; // Plot positive values foreach (DataPoint dataPoint in plotGroup.XWiseStackedDataList[xValue].Positive) { dataPoint.Parent.Faces = new Faces { Visual = columnCanvas, LabelCanvas = labelCanvas }; if (!(Boolean)dataPoint.Enabled || Double.IsNaN(dataPoint.InternalYValue)) { ColumnChart.CleanUpMarkerAndLabel(dataPoint, labelCanvas); continue; } isTopOFStack = (dataPoint == dataPointAtTopOfStack); CreateStackedBarVisual(dataPoint.Parent.RenderAs, dataPoint.InternalYValue >= 0, columnCanvas, labelCanvas, dataPoint, top, ref left, ref right, columnHeight, ref prevSum, absoluteSum, depth3d, animationEnabled, animationBeginTime, isTopOFStack, positiveIndex, plotGroup.XWiseStackedDataList[xValue].Positive.ToList()); animationBeginTime += animationTime; positiveIndex++; } prevSum = 0; right = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue); dataPointAtTopOfStack = null; if (plotGroup.XWiseStackedDataList[xValue].Negative.Count > 0) { dataPointAtTopOfStack = plotGroup.XWiseStackedDataList[xValue].Negative.Last(); animationTime = 1.0 / plotGroup.XWiseStackedDataList[xValue].Negative.Count; animationBeginTime = 0.4; } // Plot negative values foreach (DataPoint dataPoint in plotGroup.XWiseStackedDataList[xValue].Negative) { dataPoint.Parent.Faces = new Faces { Visual = columnCanvas, LabelCanvas = labelCanvas }; if (!(Boolean)dataPoint.Enabled || Double.IsNaN(dataPoint.InternalYValue)) continue; isTopOFStack = (dataPoint == dataPointAtTopOfStack); CreateStackedBarVisual(dataPoint.Parent.RenderAs, dataPoint.InternalYValue >= 0, columnCanvas, labelCanvas, dataPoint, top, ref left, ref right, columnHeight, ref prevSum, absoluteSum, depth3d, animationEnabled, animationBeginTime, isTopOFStack, negativeIndex, plotGroup.XWiseStackedDataList[xValue].Negative.ToList()); animationBeginTime += animationTime; negativeIndex--; } }
public static void UpdateVisualForYValue4StackedColumnChart(RenderAs chartType, Chart chart, DataPoint dataPoint, Boolean isAxisChanged) { if (dataPoint.Faces == null) { return; } System.Diagnostics.Debug.WriteLine("Animate--YValue" + dataPoint.YValue.ToString() + " IsAxisChange=" + isAxisChanged.ToString()); Boolean animationEnabled = chart.AnimatedUpdate; // Whether the animation for the DataPoint is enabled DataSeries dataSeries = dataPoint.Parent; // parent of the current DataPoint Canvas dataPointVisual = dataPoint.Faces.Visual as Canvas; // Old visual for the column Canvas labelCanvas = dataPoint.Faces.LabelCanvas; // (columnCanvas.Parent as Canvas).Children[0] as Canvas; // Parent canvas of Datapoint label Canvas columnCanvas = (labelCanvas.Parent as Canvas).Children[1] as Canvas; //dataSeries.Faces.Visual as Canvas;// dataPointVisual.Parent as Canvas; // Existing parent canvas of column UpdateParentVisualCanvasSize(chart, columnCanvas); UpdateParentVisualCanvasSize(chart, labelCanvas); Double height = labelCanvas.Height; Double width = labelCanvas.Width; PlotGroup plotGroup = dataSeries.PlotGroup; // PlotGroup reference // Calculate 3d depth for the DataPoints Double depth3d = chart.ChartArea.PLANK_DEPTH / chart.PlotDetails.Layer3DCount * (chart.View3D ? 1 : 0); // Calculate required parameters for Creating new Stacked Columns Double minDiff, widthPerColumn, maxColumnWidth; widthPerColumn = CalculateWidthOfEachStackedColumn(chart, plotGroup, width, out minDiff, out maxColumnWidth); // List of effected DataPoints for the current update of YValue property of the DataPoint XWiseStackedData effectedDataPoints = plotGroup.XWiseStackedDataList[dataPoint.InternalXValue]; // Marging all DataPoints in to single a single list of DataPoint List <DataPoint> positiveList = effectedDataPoints.Positive.ToList(); List <DataPoint> negativeList = effectedDataPoints.Negative.ToList(); List <DataPoint> listOfDataPoint = new List <DataPoint>(); listOfDataPoint.AddRange(positiveList); listOfDataPoint.AddRange(negativeList); // Storing reference of old Visual foreach (DataPoint dp in listOfDataPoint) { if (dp.Marker != null && dp.Marker.Visual != null) { dp._oldMarkerPosition = new Point((Double)dp.Marker.Visual.GetValue(Canvas.LeftProperty), (Double)dp.Marker.Visual.GetValue(Canvas.TopProperty)); } if (dp.LabelVisual != null) { dp._oldLabelPosition = new Point((Double)dp.LabelVisual.GetValue(Canvas.LeftProperty), (Double)dp.LabelVisual.GetValue(Canvas.TopProperty)); } if (dp.Faces != null) { dp._oldVisual = dp.Faces.Visual; columnCanvas.Children.Remove(dp._oldVisual); } } // Calculate limiting value Double limitingYValue = (plotGroup.AxisY.InternalAxisMinimum > 0)? plotGroup.AxisY.InternalAxisMinimum : (plotGroup.AxisY.InternalAxisMaximum < 0)? plotGroup.AxisY.InternalAxisMaximum : 0; // Create new Column with new YValue DrawStackedColumnsAtXValue(chartType, dataPoint.InternalXValue, plotGroup, columnCanvas, labelCanvas, plotGroup.DrawingIndex, dataPointVisual.Width, maxColumnWidth, limitingYValue, depth3d, false); Boolean isPositive; if (animationEnabled) { // Create new Storyboard for animation if (dataPoint.Storyboard != null) { dataPoint.Storyboard.Stop(); dataPoint.Storyboard = null; } dataPoint.Storyboard = new Storyboard(); // Whether to animate the top of DataPoint Visual Boolean isAnimateTop = false; // Loop through all Datapoints under the PlotGroup of the current DataPoint and apply animation foreach (DataPoint dp in listOfDataPoint) { if (dp.Faces == null || dp._oldVisual == null) { continue; } FrameworkElement newVisual = dp.Faces.Visual; // New StackedColumn visual reference of DataPoint Double oldTop = (Double)dp._oldVisual.GetValue(Canvas.TopProperty); // Top of the old visual of the DataPoint Double newTop = (Double)newVisual.GetValue(Canvas.TopProperty); // Top of the new visual of the DataPoint Double oldHeight = dp._oldVisual.Height; // Height of the old visual of the DataPoint Double newHeight = newVisual.Height; // Height of the new visual of the DataPoint Double oldScale = oldHeight / newHeight; // Scale value for the old DataPoint System.Diagnostics.Debug.WriteLine("DataPoint--oldTop =" + oldTop.ToString() + " newTop=" + newTop.ToString() + "oldYValue=" + dp._oldYValue.ToString() + " newYValue=" + dp.InternalYValue.ToString()); if (dp == dataPoint) { isPositive = (dataPoint._oldYValue < 0 && dataPoint.InternalYValue > 0) ? true : (dataPoint._oldYValue > 0 && dataPoint.InternalYValue < 0) ? false : dp._oldYValue >= 0 ? true : false; } else { isPositive = dp.InternalYValue >= 0 ? true : false; } if (isPositive) { newVisual.RenderTransformOrigin = new Point(0.5, 1); } else { newVisual.RenderTransformOrigin = new Point(0.5, 0); } // Apply new RenderTransform to the DataPoint Visual newVisual.RenderTransform = new ScaleTransform(); if (Double.IsInfinity(oldScale) || Double.IsNaN(oldScale)) { oldScale = 0; } // if (oldScale > 1) // oldScale = 1.1; if (oldScale != 1) { dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(newVisual, "(UIElement.RenderTransform).(ScaleTransform.ScaleY)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { oldScale, 1 }, null); } if ((isAnimateTop && oldTop != newTop) || (dp._oldYValue == dp.InternalYValue && oldTop != newTop)) { System.Diagnostics.Debug.WriteLine("Animate Top ----"); newVisual.SetValue(Canvas.TopProperty, oldTop); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(newVisual, "(Canvas.Top)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { oldTop, newTop }, null); } if (dp == dataPoint) { isAnimateTop = true; } // Apply animation to markers if marker exists if (dp.Marker != null && dp.Marker.Visual != null) { Double markerNewTop = (Double)dp.Marker.Visual.GetValue(Canvas.TopProperty); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(dp.Marker.Visual, "(Canvas.Top)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { dp._oldMarkerPosition.Y, markerNewTop }, null); dp.Marker.Visual.SetValue(Canvas.TopProperty, dp._oldMarkerPosition.Y); } if (dp.LabelVisual != null) { Double labelNewTop = (Double)dp.LabelVisual.GetValue(Canvas.TopProperty); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(dp.LabelVisual, "(Canvas.Top)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { dp._oldLabelPosition.Y, labelNewTop }, null); dp.LabelVisual.SetValue(Canvas.TopProperty, dp._oldLabelPosition.Y); } dataPoint.Storyboard.SpeedRatio = 2; // Remove old visual of the DataPoint from the columncanvas dp._oldVisual = null; } dataPoint.Storyboard.SpeedRatio = 2; // Begin storyboard animation #if WPF dataPoint.Storyboard.Begin(dataPoint.Chart._rootElement, true); #else dataPoint.Storyboard.Begin(); #endif } if (columnCanvas.Parent != null) { width = chart.ChartArea.ChartVisualCanvas.Width; height = chart.ChartArea.ChartVisualCanvas.Height; RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(0, -chart.ChartArea.PLANK_DEPTH - (chart.View3D ? 0 : 5), width + chart.ChartArea.PLANK_DEPTH, height + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + (chart.View3D ? 0 : 10)); (columnCanvas.Parent as Canvas).Clip = clipRectangle; } if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected) { dataPoint.Select(true); } }
public MyChart GetPng(MyChart chart,RenderAs mode) { // 新建一个 ColorSet 实例 ColorSet cs = new ColorSet(); cs.Id = "colorset1"; // 设置ColorSet 的 Id 为 colorset1 cs.Brushes.Add(new SolidColorBrush(Colors.Green)); cs.Brushes.Add(new SolidColorBrush(Colors.Red)); cs.Brushes.Add(new SolidColorBrush(Colors.Blue)); cs.Brushes.Add(new SolidColorBrush(Colors.Yellow)); cs.Brushes.Add(new SolidColorBrush(Colors.Orange)); chart.ColorSets.Add(cs); chart.ColorSet = "colorset1"; // 设置 Chart 使用自定义的颜色集合 colorset1 chart.AnimationEnabled = false; DataSeries dataSeries = new DataSeries(); dataSeries.RenderAs = mode; dataSeries.DataPoints.Add(new DataPoint { YValue = 20 }); dataSeries.DataPoints.Add(new DataPoint { YValue = 40 }); chart.Series.Add(dataSeries); return chart; }
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> /// Calculate width of each column /// </summary> /// <param name="left">Left position</param> /// <param name="widthPerColumn">Width of a column</param> /// <param name="width">Width of chart canvas</param> /// <returns>Final width of DataPoint</returns> internal static Double CalculateWidthOfEachColumn(Chart chart, Double width, Axis axisX, RenderAs chartType, Orientation direction) { PlotDetails plotDetails = chart.PlotDetails; Double minDiffValue = plotDetails.GetMinOfMinDifferencesForXValue(chartType, RenderAs.StackedColumn, RenderAs.StackedColumn100); if (Double.IsPositiveInfinity(minDiffValue)) minDiffValue = 0; Axis axisXwithMinInterval = axisX; Double dataAxisDifference = width; Double maxColumnWidth = dataAxisDifference * (1 - COLUMN_GAP_RATIO); Double numberOfDivisions = plotDetails.DrawingDivisionFactor; Double heightOrwidthPerColumn; if (minDiffValue == 0) { heightOrwidthPerColumn = width * .5 / numberOfDivisions; } else { heightOrwidthPerColumn = Graphics.ValueToPixelPosition(0, width, (Double)axisXwithMinInterval.InternalAxisMinimum, (Double)axisXwithMinInterval.InternalAxisMaximum, minDiffValue + (Double)axisXwithMinInterval.InternalAxisMinimum); heightOrwidthPerColumn *= (1 - ((direction == Orientation.Horizontal) ? COLUMN_GAP_RATIO : BarChart.BAR_GAP_RATIO)); heightOrwidthPerColumn /= numberOfDivisions; } if (!Double.IsNaN(chart.DataPointWidth)) { if (chart.DataPointWidth >= 0) heightOrwidthPerColumn = chart.DataPointWidth / 100 * ((direction == Orientation.Horizontal) ? chart.PlotArea.Width : chart.PlotArea.Height); } Double finalWidth = heightOrwidthPerColumn; return finalWidth; }
private void DrawChart(Dictionary<string, double> amountInfos, RenderAs renderAs) { if (amountInfos == null) { return; } double totalMoney = 0; var chart = new Chart { Watermark = false }; chart.AxesY.Add(new Axis { Suffix = "元" }); var dataSeries = new DataSeries { RenderAs = renderAs, LabelEnabled = true }; foreach (var amountInfo in amountInfos) { var month = amountInfo.Key; var money = amountInfo.Value; totalMoney += money; dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = month, YValue = money }); } chart.Series.Add(dataSeries); ChartPanel.Content = chart; TxtTotalMoney.Text = totalMoney.ToString(); if(_statisticsType == StatisticsType.AmountInfo) { if(_statisticsRange == "Month") { int monthCount; if(amountInfos.Count < 1) { monthCount = 0; } else if(amountInfos.Count < 2) { monthCount = 1; } else { List<DateTime> months = new List<DateTime>(); foreach(var time in amountInfos.Keys) { months.Add(DateTime.Parse(time.Replace("年", "-").Replace("月", "-") + "1 0:0:0")); } monthCount = GetMonthCount(months.Min(), months.Max()); } if(monthCount > 0) { TxtAverageMoney.Text = Math.Round((totalMoney / monthCount), 2).ToString(); } else { TxtAverageMoney.Text = "0"; } } else { int yearCount; if(amountInfos.Count < 1) { yearCount = 0; }else if(amountInfos.Count < 2) { yearCount = 1; } else { List<DateTime> years = new List<DateTime>(); foreach (var time in amountInfos.Keys) { years.Add(DateTime.Parse(time.Replace("年", "-1-1 0:0:0"))); } yearCount = years.Max().Year - years.Min().Year + 1; } if (yearCount > 0) { TxtAverageMoney.Text = Math.Round((totalMoney / yearCount),2).ToString(); } else { TxtAverageMoney.Text = "0"; } } } }
/// <summary> /// Apply column chart animation /// </summary> /// <param name="column">Column visual reference</param> /// <param name="storyboard">Storyboard</param> /// <param name="columnParams">Column parameters</param> /// <returns>Storyboard</returns> private static Storyboard ApplyColumnChartAnimation( DataSeries currentDataSeries, Panel column, Storyboard storyboard, Boolean isPositive, Double beginTime, Double[] timeCollection, Double[] valueCollection, RenderAs renderAs) { ScaleTransform scaleTransform; String property2Animate; // storyboard.Pause(); if(renderAs == RenderAs.Column) { property2Animate ="(ScaleTransform.ScaleY)"; scaleTransform = new ScaleTransform() { ScaleY = valueCollection[0] }; column.RenderTransformOrigin = (isPositive) ? new Point(0.5, 1) : new Point(0.5, 0); } else { scaleTransform = new ScaleTransform() { ScaleX = valueCollection[0] }; property2Animate= "(ScaleTransform.ScaleX)"; column.RenderTransformOrigin = (isPositive) ? new Point(0, 0.5) : new Point(1, 0.5); } column.RenderTransform = scaleTransform; DoubleCollection values = Graphics.GenerateDoubleCollection(valueCollection); DoubleCollection frameTimes = Graphics.GenerateDoubleCollection(timeCollection); List<KeySpline> splines = null; if(valueCollection.Length == 2) splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 1), new Point(0.5, 1) ); DoubleAnimationUsingKeyFrames growAnimation = AnimationHelper.CreateDoubleAnimation(currentDataSeries, scaleTransform, property2Animate, beginTime, frameTimes, values, splines); storyboard.Children.Add(growAnimation); return storyboard; }
public static void InitDataSerise(DataSeries ds, bool showInLengend, string lengendText, Brush brush, RenderAs render) { if (ds == null) { ds = new DataSeries(); } ds.ShowInLegend = showInLengend; ds.RenderAs = render; if (brush != null) { ds.Color = brush; } if (showInLengend) { ds.LegendText = lengendText; } }
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); }
public static void UpdateVisualForYValue4StackedBarChart(RenderAs chartType, Chart chart, DataPoint dataPoint, Boolean isAxisChanged) { //if (dataPoint.Faces == null) // return; if (chart != null && !chart._internalPartialUpdateEnabled) return; Boolean animationEnabled = (Boolean)chart.AnimatedUpdate; // Whether the animation for the DataPoint is enabled DataSeries dataSeries = dataPoint.Parent; // parent of the current DataPoint Canvas columnCanvas, labelCanvas; PlotGroup plotGroup = dataSeries.PlotGroup; // PlotGroup reference // Calculate 3d depth for the DataPoints Double depth3d = chart.ChartArea.PLANK_DEPTH / chart.PlotDetails.Layer3DCount * (chart.View3D ? 1 : 0); // Calculate required parameters for Creating new Stacked Columns Double minDiff, heightPerBar, maxBarHeight; // Calculate limiting value Double limitingYValue = (plotGroup.AxisY.InternalAxisMinimum > 0) ? plotGroup.AxisY.InternalAxisMinimum : (plotGroup.AxisY.InternalAxisMaximum < 0) ? plotGroup.AxisY.InternalAxisMaximum : 0; if (dataPoint.Faces == null) { if (dataSeries != null && dataSeries.Faces != null) { labelCanvas = dataSeries.Faces.LabelCanvas as Canvas; columnCanvas = dataSeries.Faces.Visual as Canvas; heightPerBar = CalculateWidthOfEachStackedColumn(chart, plotGroup, columnCanvas.Height, out minDiff, out maxBarHeight); if (dataPoint.Parent.RenderAs == RenderAs.StackedBar || dataPoint.Parent.RenderAs == RenderAs.StackedBar100) { // Create new Column with new YValue BarChart.DrawStackedBarsAtXValue(chartType, dataPoint.InternalXValue, plotGroup, columnCanvas, labelCanvas, plotGroup.DrawingIndex, heightPerBar, maxBarHeight, limitingYValue, depth3d, false); } if (dataPoint.Faces == null) return; } else { UpdateDataSeries(dataSeries, VcProperties.YValue, null); return; } } Canvas dataPointVisual = dataPoint.Faces.Visual as Canvas; // Old visual for the column labelCanvas = dataPoint.Faces.LabelCanvas; // Parent canvas of Datapoint label if (labelCanvas == null) return; columnCanvas = (labelCanvas.Parent as Canvas).Children[1] as Canvas;//dataPointVisual.Parent as Canvas; // Existing parent canvas of column heightPerBar = CalculateWidthOfEachStackedColumn(chart, plotGroup, columnCanvas.Height, out minDiff, out maxBarHeight); UpdateParentVisualCanvasSize(chart, columnCanvas); UpdateParentVisualCanvasSize(chart, labelCanvas); // List of effected DataPoints for the current update of YValue property of the DataPoint XWiseStackedData effectedDataPoints = plotGroup.XWiseStackedDataList[dataPoint.InternalXValue]; // Marging all DataPoints in to single a single list of DataPoint List<DataPoint> positiveList = effectedDataPoints.Positive.ToList(); List<DataPoint> negativeList = effectedDataPoints.Negative.ToList(); List<DataPoint> listOfDataPoint = new List<DataPoint>(); listOfDataPoint.AddRange(positiveList); listOfDataPoint.AddRange(negativeList); // Storing reference of old Visual foreach (DataPoint dp in listOfDataPoint) { if (dp.Marker != null && dp.Marker.Visual != null) dp._oldMarkerPosition = new Point((Double)dp.Marker.Visual.GetValue(Canvas.LeftProperty), (Double)dp.Marker.Visual.GetValue(Canvas.TopProperty)); if (dp.LabelVisual != null) dp._oldLabelPosition = new Point((Double)dp.LabelVisual.GetValue(Canvas.LeftProperty), (Double)dp.LabelVisual.GetValue(Canvas.TopProperty)); if (dp.Faces != null) { dp._oldVisual = dp.Faces.Visual; columnCanvas.Children.Remove(dp._oldVisual); CleanUpMarkerAndLabel(dp, labelCanvas); } } // Create new Column with new YValue BarChart.DrawStackedBarsAtXValue(chartType, dataPoint.InternalXValue, plotGroup, columnCanvas, labelCanvas, plotGroup.DrawingIndex, dataPointVisual.Height, maxBarHeight, limitingYValue, depth3d, false); if (dataSeries.ToolTipElement != null) dataSeries.ToolTipElement.Hide(); CreateOrUpdatePlank(chart, dataSeries.PlotGroup.AxisY, columnCanvas, depth3d, (dataPoint.Parent.RenderAs == RenderAs.StackedColumn || dataPoint.Parent.RenderAs == RenderAs.StackedColumn100) ? Orientation.Horizontal : Orientation.Vertical); Boolean isPositive; if (animationEnabled) { // Create new Storyboard for animation if (dataPoint.Storyboard != null) { dataPoint.Storyboard.Stop(); //dataPoint.Storyboard = null; dataPoint.Storyboard.Children.Clear(); } if (dataPoint.Storyboard == null) dataPoint.Storyboard = new Storyboard(); // Whether to animate the top of DataPoint Visual Boolean isAnimateLeft = false; // Loop through all Datapoints under the PlotGroup of the current DataPoint and apply animation foreach (DataPoint dp in listOfDataPoint) { if (dp.Faces == null || dp._oldVisual == null) continue; FrameworkElement newVisual = dp.Faces.Visual; // New StackedColumn visual reference of DataPoint Double oldLeft = (Double)dp._oldVisual.GetValue(Canvas.LeftProperty); // Left of the old visual of the DataPoint Double newLeft = (Double)newVisual.GetValue(Canvas.LeftProperty); // Left of the new visual of the DataPoint Double oldWidth = dp._oldVisual.Width; // Width of the old visual of the DataPoint Double newWidth = newVisual.Width; // Width of the new visual of the DataPoint Double oldScale = oldWidth / newWidth; // Scale value for the old DataPoint if (dp == dataPoint) { isPositive = (dataPoint._oldYValue < 0 && dataPoint.InternalYValue > 0) ? true : (dataPoint._oldYValue > 0 && dataPoint.InternalYValue < 0) ? false : dp._oldYValue >= 0 ? true : false; } else isPositive = dp.InternalYValue >= 0 ? true : false; if (isPositive) newVisual.RenderTransformOrigin = new Point(0, 0.5); else newVisual.RenderTransformOrigin = new Point(1, 0.5); // Apply new RenderTransform to the DataPoint Visual newVisual.RenderTransform = new ScaleTransform(); if (Double.IsInfinity(oldScale) || Double.IsNaN(oldScale)) oldScale = 0; if (oldScale != 1) dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(newVisual, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { oldScale, 1 }, null); if ((isAnimateLeft && oldLeft != newLeft) || dp._oldYValue == dp.InternalYValue && oldLeft != newLeft) { newVisual.SetValue(Canvas.LeftProperty, oldLeft); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(newVisual, "(Canvas.Left)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { oldLeft, newLeft }, null); } if (dp == dataPoint) isAnimateLeft = true; // Apply animation to markers if marker exists if (dp.Marker != null && dp.Marker.Visual != null) { Double markerNewLeft = (Double)dp.Marker.Visual.GetValue(Canvas.LeftProperty); dp.Marker.Visual.SetValue(Canvas.LeftProperty, dp._oldMarkerPosition.X); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(dp.Marker.Visual, "(Canvas.Left)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { dp._oldMarkerPosition.X, markerNewLeft }, null); } if (dp.LabelVisual != null) { Double labelNewLeft = (Double)dp.LabelVisual.GetValue(Canvas.LeftProperty); System.Diagnostics.Debug.WriteLine("oldPos=" + dp._oldLabelPosition.X.ToString() + " NewPos=" + labelNewLeft.ToString()); dp.LabelVisual.SetValue(Canvas.LeftProperty, dp._oldLabelPosition.X); dataPoint.Storyboard = AnimationHelper.ApplyPropertyAnimation(dp.LabelVisual, "(Canvas.Left)", dataPoint, dataPoint.Storyboard, 0, new Double[] { 0, 1 }, new Double[] { dp._oldLabelPosition.X, labelNewLeft }, null); } dataPoint.Storyboard.SpeedRatio = 2; // Remove old visual of the DataPoint from the columncanvas dp._oldVisual = null; } dataPoint.Storyboard.SpeedRatio = 2; // Begin storyboard animation #if WPF dataPoint.Storyboard.Begin(dataPoint.Chart._rootElement, true); #else dataPoint.Storyboard.Begin(); #endif } if (columnCanvas.Parent != null) { Double width = chart.ChartArea.ChartVisualCanvas.Width; Double height = chart.ChartArea.ChartVisualCanvas.Height; RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(-(chart.View3D ? 0 : 5) - chart.ChartArea.PLANK_THICKNESS, -chart.ChartArea.PLANK_DEPTH, width + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + (chart.View3D ? 0 : 10) , height + chart.ChartArea.PLANK_DEPTH); (columnCanvas.Parent as Canvas).Clip = clipRectangle; } if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected) dataPoint.Select(true); }
/// <summary> /// Get PathGeometry for Line and Shadow /// </summary> /// <param name="pointCollectionList">List of points collection</param> /// <returns>Geometry</returns> /// <summary> /// Get PathGeometry for Line and Shadow /// </summary> /// <param name="dataPointCollectionList">List of Segments. And EachSegments contains a list of DataPoints</param> /// <returns></returns> internal static Geometry GetPathGeometry(RenderAs renderAs, GeometryGroup oldData, List<List<DataPoint>> dataPointCollectionList, Boolean isShadow, Double width, Double height, Canvas line2dLabelCanvas) { GeometryGroup gg; if (oldData != null) { gg = oldData; gg.Children.Clear(); } else { gg = new GeometryGroup(); } foreach (List<DataPoint> pointCollection in dataPointCollectionList) { PathGeometry geometry = new PathGeometry(); PathFigure pathFigure = new PathFigure(); if (pointCollection.Count > 0) { pathFigure.StartPoint = pointCollection[0]._visualPosition; Faces faces = new Faces(); //Add LineSegment faces.Parts.Add(null); // Add PathFigure faces.Parts.Add(pathFigure); if (isShadow) pointCollection[0].ShadowFaces = faces; else { pointCollection[0].Faces = faces; faces.PreviousDataPoint = null; if(pointCollection.Count > 1) faces.NextDataPoint = pointCollection[1]; CreateMarkerAndLabel(pointCollection, 0, width, height, line2dLabelCanvas); } if (renderAs == RenderAs.Spline) GeneratePointCollections4SpLine(pointCollection, width, height, isShadow, pathFigure, ref line2dLabelCanvas); else GeneratePointCollections4Line(pointCollection, width, height, isShadow, pathFigure, ref line2dLabelCanvas); } geometry.Figures.Add(pathFigure); gg.Children.Add(geometry); } return gg; }
/// <summary> /// Convert RenderAs to MarkerType /// Note: Used for Single series chart /// </summary> /// <param name="renderAs">Chart type</param> /// <param name="dataSeries">DataSeries</param> /// <returns>MarkerType</returns> internal MarkerTypes RenderAsToLegendMarkerType(RenderAs renderAs, DataPoint dataPoint) { DataSeries dataSeries = dataPoint.Parent; if (dataSeries.RenderAs == RenderAs.QuickLine) return MarkerTypes.Line; else if (RenderHelper.IsLineCType(dataSeries)) return ((Boolean)dataPoint.MarkerEnabled ? (MarkerTypes)dataPoint.MarkerType : MarkerTypes.Line); else return (MarkerTypes)RenderAsToLegendMarkerType(renderAs, dataSeries); }
public void PlotTimeSeries(DoubleTimeSeries ts, string titletext, Color color, RenderAs linetype) { if (!keepSeries.IsChecked.Value) { clearSeries_Click(null, null); } if (keepSeries.IsChecked.Value) { timeseriesChart.Titles[0].Text = ""; } else { timeseriesChart.Titles[0].Text = titletext; } _DoubleTimeSeries = ts; var dataSeries = new DataSeries(); // Set DataSeries properties dataSeries.RenderAs = RenderAs.QuickLine; dataSeries.XValueType = ChartValueTypes.DateTime; dataSeries.LegendText = titletext; dataSeries.LineThickness = 2; double max = ts.Values.Max(); double min = ts.Values.Min(); double range = max - min; var axisy = timeseriesChart.AxesY[0]; if (range > 0) { var maxy = max + range * 0.1; var miny = min - range * 0.1; miny = miny < 0 ? 0 : miny; axisy.AxisMaximum = maxy; axisy.AxisMinimum = miny; } for (int i = 0; i < ts.DateTimes.Count; i++) { DataPoint dataPoint = new DataPoint(); dataPoint.XValue = ts.DateTimes[i]; dataPoint.YValue = ts.Values[i]; dataSeries.DataPoints.Add(dataPoint); } dataSeries.Color = new SolidColorBrush(color); timeseriesChart.Series.Add(dataSeries); }
public override void WriteInitializationScript(TextWriter writer) { var options = new Dictionary <string, object>(Events); options["type"] = this.Encoding; if (this.Encoding == BarcodeSymbology.GS1128) { options["type"] = "gs1-128"; } if (this.Checksum == false) { options["checksum"] = this.Checksum; } if (Value.HasValue()) { options["value"] = Value; } if (RenderAs.HasValue) { options["renderAs"] = RenderAs.ToString().ToLowerInvariant(); } if (Background.HasValue()) { options["background"] = Background; } if (Color.HasValue()) { options["color"] = Color; } if (Height.HasValue) { options["height"] = Height; } if (Width.HasValue) { options["width"] = Width; } if (this.Border.Color.HasValue() || this.Border.DashType != null || this.Border.Width.HasValue) { options["border"] = new BarcodeElementBorderSerializer(this.Border).Serialize(); } if (this.Padding.ShouldSerialize()) { options["padding"] = this.Padding.CreateSerializer().Serialize(); } if (this.Text.ShouldSerialize()) { options["text"] = this.Text.ToJson(); } writer.Write(Initializer.Initialize(Selector, "Barcode", options)); base.WriteInitializationScript(writer); }
/// <summary> /// Convert RenderAs to MarkerType /// </summary> /// <param name="renderAs">Chart type</param> /// <param name="dataSeries">DataSeries</param> /// <returns>MarkerType</returns> internal MarkerTypes RenderAsToMarkerType(RenderAs renderAs, DataSeries dataSeries) { switch (renderAs) { case RenderAs.Pie: case RenderAs.Doughnut: case RenderAs.Bubble: return MarkerTypes.Circle; case RenderAs.Point: return dataSeries.MarkerType; case RenderAs.Line: case RenderAs.Stock: case RenderAs.CandleStick: return dataSeries.MarkerType; case RenderAs.Area: case RenderAs.StackedArea: case RenderAs.StackedArea100: return MarkerTypes.Triangle; default: return MarkerTypes.Square; } }
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; ResetMarkersForSeries(dataSeriesList4Rendering); 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: case RenderAs.Spline: renderedCanvas = LineChart.GetVisualObjectForLineChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; case RenderAs.QuickLine: renderedCanvas = QuickLineChart.GetVisualObjectForQuickLineChart(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.Radar: renderedCanvas = RadarChart.GetVisualObjectForRadarChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.Polar: renderedCanvas = PolarChart.GetVisualObjectForPolarChart(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.Pyramid: renderedCanvas = PyramidChart.GetVisualObjectForPyramidChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); 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; case RenderAs.StepLine: renderedCanvas = StepLineChart.GetVisualObjectForLineChart(preExistingPanel, width, height, plotDetails, dataSeriesList4Rendering, chart, plankDepth, animationEnabled); break; } return renderedCanvas; }
/// <summary> /// Draws a All Stacked column under a XValue with a particular dtrawingIndex /// </summary> /// <param name="xValue">XValue</param> /// <param name="plotGroup">PlotGroup reference</param> /// <param name="columnCanvas">Parent canvas of StackedColumn visuals</param> /// <param name="labelCanvas">Parent canvas of StackedColumn labels</param> /// <param name="drawingIndex">Drawing index of the DataSeries</param> /// <param name="widthPerColumn">Width par each column</param> /// <param name="maxColumnWidth">Max width of a Column</param> /// <param name="limitingYValue">Limiting value</param> /// <param name="depth3d">3d depth for 3d charts</param> /// <param name="animationEnabled">Whether animation for chart is enabled</param> private static void DrawStackedColumnsAtXValue(RenderAs chartType, Double xValue, PlotGroup plotGroup, Canvas columnCanvas, Canvas labelCanvas, Double drawingIndex, Double widthPerColumn, Double maxColumnWidth, Double limitingYValue, Double depth3d, Boolean animationEnabled) { Double top; Double prevSum = 0; Int32 positiveIndex = 1, negativeIndex = 1; Boolean isTopOFStack; DataPoint dataPointAtTopOfStack = null; Double columnHeight = 0; Double absoluteSum = 0; Double left = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, xValue) + drawingIndex * widthPerColumn - (maxColumnWidth / 2); Double bottom = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue); if (plotGroup.XWiseStackedDataList[xValue].Positive.Count > 0) dataPointAtTopOfStack = plotGroup.XWiseStackedDataList[xValue].Positive.Last(); if(chartType == RenderAs.StackedColumn100) absoluteSum = plotGroup.XWiseStackedDataList[xValue].AbsoluteYValueSum; Double animationBeginTime = 0.4; Double animationTime = 1.0 / plotGroup.XWiseStackedDataList[xValue].Positive.Count; // Plot positive values foreach (DataPoint dataPoint in plotGroup.XWiseStackedDataList[xValue].Positive) { dataPoint.Parent.Faces = new Faces() { Visual = columnCanvas, LabelCanvas = labelCanvas }; if (!(Boolean)dataPoint.Enabled || Double.IsNaN(dataPoint.InternalYValue)) continue; isTopOFStack = (dataPoint == dataPointAtTopOfStack); if (chartType == RenderAs.StackedColumn) { top = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue + prevSum); prevSum += dataPoint.InternalYValue; columnHeight = Math.Abs(top - bottom); } else // if (chartType == RenderAs.StackedColumn100) { Double percentYValue = 0; if(absoluteSum != 0) percentYValue = (dataPoint.InternalYValue / absoluteSum * 100); top = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum); columnHeight = Math.Abs(top - bottom); prevSum += percentYValue; } if (chartType == RenderAs.StackedColumn || chartType == RenderAs.StackedColumn100) CreateStackedColumnVisual(true, columnCanvas, labelCanvas, dataPoint, isTopOFStack, left, ref top, ref bottom, widthPerColumn, columnHeight, depth3d, ref positiveIndex, animationEnabled, animationBeginTime); else if (chartType == RenderAs.StackedColumn || chartType == RenderAs.StackedColumn100) BarChart.CreateBarDataPointVisual(dataPoint, labelCanvas, columnCanvas, dataPoint.InternalYValue >= 0, widthPerColumn, depth3d, false); animationBeginTime += animationTime; positiveIndex++; } prevSum = 0; top = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue); dataPointAtTopOfStack = null; if (plotGroup.XWiseStackedDataList[xValue].Negative.Count > 0) { dataPointAtTopOfStack = plotGroup.XWiseStackedDataList[xValue].Negative.Last(); animationTime = 1.0 / plotGroup.XWiseStackedDataList[xValue].Negative.Count; animationBeginTime = 0.4; } // Plot negative values foreach (DataPoint dataPoint in plotGroup.XWiseStackedDataList[xValue].Negative) { dataPoint.Parent.Faces = new Faces() { Visual = columnCanvas, LabelCanvas = labelCanvas }; if (!(Boolean)dataPoint.Enabled || Double.IsNaN(dataPoint.InternalYValue)) continue; isTopOFStack = (dataPoint == dataPointAtTopOfStack); if (chartType == RenderAs.StackedColumn) { bottom = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue + prevSum); prevSum += dataPoint.InternalYValue; columnHeight = Math.Abs(top - bottom); } else // if (chartType == RenderAs.StackedColumn100) { Double percentYValue = (dataPoint.InternalYValue / absoluteSum * 100); bottom = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum); columnHeight = Math.Abs(top - bottom); prevSum += percentYValue; } CreateStackedColumnVisual(false, columnCanvas, labelCanvas, dataPoint, isTopOFStack, left, ref top, ref bottom, widthPerColumn, columnHeight, depth3d, ref negativeIndex, animationEnabled, animationBeginTime); animationBeginTime += animationTime; negativeIndex--; } }
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(); }
internal static Brush Get3DFaceColor(RenderAs renderAs, Boolean lightingEnabled, Brush color, PieFaceTypes faceType, Double startAngle, Double stopAngle, Double tiltAngle) { Brush retVal = null; switch (faceType) { case PieFaceTypes.Top: case PieFaceTypes.Bottom: if(renderAs == RenderAs.Pie) retVal = lightingEnabled ? Graphics.GetLightingEnabledBrush(color, "Linear", new Double[] { 0.99, 0.789 }) : color; else retVal = lightingEnabled ? Graphics.GetLightingEnabledBrush(color, -75, "Linear", new Double[] { 0.99, 0.854 }) : color; break; case PieFaceTypes.Left: case PieFaceTypes.Right: retVal = lightingEnabled ? Graphics.GetLightingEnabledBrush(color, "Linear", new Double[] { 0.845, 0.79 }) : color; break; case PieFaceTypes.CurvedSurface: if (renderAs == RenderAs.Pie) { retVal = lightingEnabled ? Graphics.GetLightingEnabledBrush(color, startAngle * 180 / Math.PI, "Linear", new Double[] { 0.99, 0.789 }) : color; } else { if (stopAngle > Math.PI) retVal = lightingEnabled ? Graphics.GetLightingEnabledBrush(color, tiltAngle * 180 / Math.PI, "Linear", new Double[] { 0.99, 0.845 }) : color; else retVal = lightingEnabled ? Graphics.GetLightingEnabledBrush(color, startAngle * 180 / Math.PI, "Linear", new Double[] { 0.99, 0.845 }) : color; } break; } return retVal; }
/// <summary> /// Draws a All Stacked column under a XValue with a particular dtrawingIndex /// </summary> /// <param name="xValue">XValue</param> /// <param name="plotGroup">PlotGroup reference</param> /// <param name="columnCanvas">Parent canvas of StackedColumn visuals</param> /// <param name="labelCanvas">Parent canvas of StackedColumn labels</param> /// <param name="drawingIndex">Drawing index of the DataSeries</param> /// <param name="widthPerColumn">Width par each column</param> /// <param name="maxColumnWidth">Max width of a Column</param> /// <param name="limitingYValue">Limiting value</param> /// <param name="depth3d">3d depth for 3d charts</param> /// <param name="animationEnabled">Whether animation for chart is enabled</param> private static void DrawStackedColumnsAtXValue(RenderAs chartType, Double xValue, PlotGroup plotGroup, Canvas columnCanvas, Canvas labelCanvas, Double drawingIndex, Double widthPerColumn, Double maxColumnWidth, Double limitingYValue, Double depth3d, Boolean animationEnabled) { Double top; Double prevSum = 0; Int32 positiveIndex = 1, negativeIndex = 1; Boolean isTopOFStack; DataPoint dataPointAtTopOfStack = null; Double columnHeight = 0; Double absoluteSum = 0; Double left = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, xValue) + drawingIndex * widthPerColumn - (maxColumnWidth / 2); Double bottom = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue); if (plotGroup.XWiseStackedDataList[xValue].Positive.Count > 0) { dataPointAtTopOfStack = plotGroup.XWiseStackedDataList[xValue].Positive.Last(); } if (chartType == RenderAs.StackedColumn100) { absoluteSum = plotGroup.XWiseStackedDataList[xValue].AbsoluteYValueSum; } Double animationBeginTime = 0.4; Double animationTime = 1.0 / plotGroup.XWiseStackedDataList[xValue].Positive.Count; // Plot positive values foreach (DataPoint dataPoint in plotGroup.XWiseStackedDataList[xValue].Positive) { dataPoint.Parent.Faces = new Faces() { Visual = columnCanvas, LabelCanvas = labelCanvas }; if (!(Boolean)dataPoint.Enabled || Double.IsNaN(dataPoint.InternalYValue)) { continue; } isTopOFStack = (dataPoint == dataPointAtTopOfStack); if (chartType == RenderAs.StackedColumn) { top = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue + prevSum); prevSum += dataPoint.InternalYValue; columnHeight = Math.Abs(top - bottom); } else // if (chartType == RenderAs.StackedColumn100) { Double percentYValue = 0; if (absoluteSum != 0) { percentYValue = (dataPoint.InternalYValue / absoluteSum * 100); } top = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum); columnHeight = Math.Abs(top - bottom); prevSum += percentYValue; } if (chartType == RenderAs.StackedColumn || chartType == RenderAs.StackedColumn100) { CreateStackedColumnVisual(true, columnCanvas, labelCanvas, dataPoint, isTopOFStack, left, ref top, ref bottom, widthPerColumn, columnHeight, depth3d, ref positiveIndex, animationEnabled, animationBeginTime); } else if (chartType == RenderAs.StackedColumn || chartType == RenderAs.StackedColumn100) { BarChart.CreateBarDataPointVisual(dataPoint, labelCanvas, columnCanvas, dataPoint.InternalYValue >= 0, widthPerColumn, depth3d, false); } animationBeginTime += animationTime; positiveIndex++; } prevSum = 0; top = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue); dataPointAtTopOfStack = null; if (plotGroup.XWiseStackedDataList[xValue].Negative.Count > 0) { dataPointAtTopOfStack = plotGroup.XWiseStackedDataList[xValue].Negative.Last(); animationTime = 1.0 / plotGroup.XWiseStackedDataList[xValue].Negative.Count; animationBeginTime = 0.4; } // Plot negative values foreach (DataPoint dataPoint in plotGroup.XWiseStackedDataList[xValue].Negative) { dataPoint.Parent.Faces = new Faces() { Visual = columnCanvas, LabelCanvas = labelCanvas }; if (!(Boolean)dataPoint.Enabled || Double.IsNaN(dataPoint.InternalYValue)) { continue; } isTopOFStack = (dataPoint == dataPointAtTopOfStack); if (chartType == RenderAs.StackedColumn) { bottom = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue + prevSum); prevSum += dataPoint.InternalYValue; columnHeight = Math.Abs(top - bottom); } else // if (chartType == RenderAs.StackedColumn100) { Double percentYValue = (dataPoint.InternalYValue / absoluteSum * 100); bottom = Graphics.ValueToPixelPosition(columnCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum); columnHeight = Math.Abs(top - bottom); prevSum += percentYValue; } CreateStackedColumnVisual(false, columnCanvas, labelCanvas, dataPoint, isTopOFStack, left, ref top, ref bottom, widthPerColumn, columnHeight, depth3d, ref negativeIndex, animationEnabled, animationBeginTime); animationBeginTime += animationTime; negativeIndex--; } }
private DataSeries GetAvgSDSeries(List<double> list, bool showInLengend, string lengendText, Brush brush,RenderAs render) { DataSeries ds = null; Dispatcher.Invoke(new Action(() => { ds= new DataSeries(); DataSeriseUtil.InitDataSerise(ds, true, lengendText, brush,render); DataSeriseUtil.AddDataToDataSerise(ds, list); })); return ds; }
/// <summary> /// /// </summary> /// <param name="chartType"></param> /// <param name="isPositive"></param> /// <param name="columnCanvas"></param> /// <param name="labelCanvas"></param> /// <param name="dataPoint"></param> /// <param name="top"></param> /// <param name="left"></param> /// <param name="right"></param> /// <param name="finalHeight"></param> /// <param name="prevSum"></param> /// <param name="absoluteSum">Absolute sum of DataPoints if applicable</param> /// <param name="depth3d"></param> /// <param name="animationEnabled"></param> /// <param name="animationBeginTime"></param> private static void CreateStackedBarVisual(RenderAs chartType, Boolean isPositive, Canvas columnCanvas, Canvas labelCanvas, DataPoint dataPoint, Double top, ref Double left, ref Double right, Double finalHeight, ref Double prevSum, Double absoluteSum, Double depth3d, Boolean animationEnabled, Double animationBeginTime, Boolean isTopOFStack, Int32 PositiveOrNegativeZIndex, List<DataPoint> listOfDataPointsInXValue) { PlotGroup plotGroup = dataPoint.Parent.PlotGroup; Chart chart = dataPoint.Chart as Chart; Double percentYValue = 0; if (chartType == RenderAs.StackedBar100) { if (absoluteSum != 0) { if (plotGroup.AxisY.Logarithmic) { percentYValue = Math.Log((dataPoint.InternalYValue / absoluteSum * 100), plotGroup.AxisY.LogarithmBase); } else percentYValue = (dataPoint.InternalYValue / absoluteSum * 100); } } else percentYValue = dataPoint.InternalYValue; if (isPositive) { if(plotGroup.AxisY.Logarithmic) right = ColumnChart.CalculatePositionOfDataPointForLogAxis(dataPoint, columnCanvas.Width, plotGroup, listOfDataPointsInXValue, absoluteSum); else right = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum); } else left = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum); Double barWidth = Math.Abs(right - left); prevSum += percentYValue; // barParams.Size = new Size(barWidth, finalHeight); Faces bar; Panel barVisual = null; if ((dataPoint.Chart as Chart).View3D) { bar = ColumnChart.Get3DColumn(dataPoint, barWidth, finalHeight, depth3d, dataPoint.Color, null, null, null, (Boolean)dataPoint.LightingEnabled, (BorderStyles)dataPoint.BorderStyle, dataPoint.BorderColor, dataPoint.BorderThickness.Left); barVisual = bar.Visual as Panel; barVisual.SetValue(Canvas.ZIndexProperty, GetStackedBarZIndex(chart.ChartArea.PlotAreaCanvas.Height, left, top, columnCanvas.Width, columnCanvas.Height, (dataPoint.InternalYValue > 0), PositiveOrNegativeZIndex)); dataPoint.Faces = bar; if (!VisifireControl.IsMediaEffectsEnabled) ColumnChart.ApplyOrRemoveShadow4XBAP(dataPoint, true, false); } else { bar = ColumnChart.Get2DColumn(dataPoint, barWidth, finalHeight, true, isTopOFStack); barVisual = bar.Visual as Panel; dataPoint.Faces = bar; } if (VisifireControl.IsMediaEffectsEnabled) ApplyOrRemoveShadow(chart, dataPoint); dataPoint.Faces.LabelCanvas = labelCanvas; barVisual.SetValue(Canvas.LeftProperty, left); barVisual.SetValue(Canvas.TopProperty, top); columnCanvas.Children.Add(barVisual); dataPoint.IsTopOfStack = isTopOFStack; CreateOrUpdateMarker4HorizontalChart(dataPoint.Chart as Chart, labelCanvas, dataPoint, left, top, isPositive, depth3d); //labelCanvas.Children.Add(CreateMarker(chart, barParams, dataPoint, left, top)); // Apply animation if (animationEnabled) { if (dataPoint.Parent.Storyboard == null) dataPoint.Parent.Storyboard = new Storyboard(); currentDataSeries = dataPoint.Parent; // Apply animation to the data points dataSeriesIndex.e to the rectangles that form the columns dataPoint.Parent.Storyboard = ApplyStackedBarChartAnimation(barVisual, dataPoint.Parent.Storyboard, animationBeginTime, 0.5); } if (isPositive) left = right; else right = left; if (isPositive) dataPoint._visualPosition = new Point(right, top + finalHeight / 2); else dataPoint._visualPosition = new Point(left, top + finalHeight / 2); dataPoint.Faces.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity; dataPoint.AttachEvent2DataPointVisualFaces(dataPoint); dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent); dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText); if(!chart.IndicatorEnabled) dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.Visual); dataPoint.AttachHref(chart, dataPoint.Faces.Visual, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget); dataPoint.SetCursor2DataPointVisualFaces(); }
private Boolean CheckShowYValueAndPercentageInLegendApplicable(RenderAs renderAs) { return (renderAs == RenderAs.Stock || renderAs == RenderAs.CandleStick) ? false : true; }
private DataSeries GetAvgSDSeries(List <double> list, bool showInLengend, string lengendText, Brush brush, RenderAs render) { DataSeries ds = null; Dispatcher.Invoke(new Action(() => { ds = new DataSeries(); DataSeriseUtil.InitDataSerise(ds, true, lengendText, brush, render); DataSeriseUtil.AddDataToDataSerise(ds, list); })); return(ds); }