/// <summary> /// LineChart has a different structure for outline. /// </summary> public override ChartShapeProperties SetChartShapeProperties(OpenXmlCompositeElement chartSeries) { ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); Outline outline = new Outline() { Width = 28575, CapType = LineCapValues.Round }; outline.Append(new SolidFill()); outline.Append(new Round()); chartShapeProperties.Append(new SolidFill()); chartShapeProperties.Append(outline); chartShapeProperties.Append(new EffectList()); Marker marker = new Marker(); marker.Append(new Symbol() { Val = MarkerStyleValues.None }); chartSeries.Append(chartShapeProperties); chartSeries.Append(marker); chartSeries.Append(new Smooth() { Val = false }); return(chartShapeProperties); }
/// <summary> /// Sets the color of the series using a solidcolor brush /// If a null brush is supplied any color is removed so the color will be automatic /// </summary> /// <param name="series">The series.</param> /// <param name="brush">The brush.</param> /// <exception cref="ArgumentNullException">series</exception> public static void UpdateSeriesMarkerBrush(this OpenXmlCompositeElement series, Brush brush) { if (series == null) { throw new ArgumentNullException("series"); } var marker = series.Descendants <Marker>().FirstOrDefault(); if (marker == null) { return; } var scb = brush as SolidColorBrush; if (scb == null) { return; } // clear down and start again marker.RemoveAllChildren(); var chartShapeProperties = new ChartShapeProperties(); SolidFill solidFill = new SolidFill(); StringBuilder hexString = new StringBuilder(); hexString.Append(scb.Color.R.ToString("X")); hexString.Append(scb.Color.G.ToString("X")); hexString.Append(scb.Color.B.ToString("X")); RgbColorModelHex hexColour = new RgbColorModelHex() { Val = hexString.ToString() }; var outlineNoFill = new Outline(); outlineNoFill.Append(new NoFill()); solidFill.Append(hexColour); chartShapeProperties.Append(solidFill); chartShapeProperties.Append(outlineNoFill); marker.Append(chartShapeProperties); }
/// <summary> /// Distinct color for each bar. /// </summary> private DataPoint colorChartLines(uint lineIndex) { DataPoint dataPoint = new DataPoint(); Index index = new Index() { Val = lineIndex }; InvertIfNegative invertIfNegative3 = new InvertIfNegative() { Val = false }; Bubble3D bubble3D1 = new Bubble3D() { Val = false }; ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); SolidFill solidFill = new SolidFill(); solidFill.SchemeColor = new SchemeColor() { Val = SchemeColorValues.Accent1 }; solidFill.RgbColorModelHex = new RgbColorModelHex() { Val = ColourValues[lineIndex] }; Outline outline = new Outline() { Width = 28575, CapType = LineCapValues.Round }; outline.Append(new NoFill()); outline.Append(new Round()); chartShapeProperties.Append(solidFill); chartShapeProperties.Append(outline); chartShapeProperties.Append(new EffectList()); dataPoint.Append(index); dataPoint.Append(chartShapeProperties); return(dataPoint); }
/// <summary> /// Set display, width, color and fill of borders and data (line, bar etc.) in chart. /// </summary> public ChartShapeProperties SetChartShapeProperties(OpenXmlCompositeElement chartSeries, bool visible = true, uint colorPoints = 0) { ChartShapeProperties chartShapeProperties1 = new ChartShapeProperties(); Outline outline1 = new Outline() { Width = 28575, CapType = LineCapValues.Round }; Round round1 = new Round(); outline1.Append(new NoFill()); outline1.Append(round1); EffectList effectList1 = new EffectList(); if (!visible) { chartShapeProperties1.Append(new NoFill()); } chartShapeProperties1.Append(outline1); chartShapeProperties1.Append(effectList1); Marker marker1 = new Marker(); Symbol symbol1 = new Symbol() { Val = MarkerStyleValues.None }; marker1.Append(symbol1); Smooth smooth1 = new Smooth() { Val = false }; chartSeries.Append(chartShapeProperties1); chartSeries.Append(marker1); chartSeries.Append(smooth1); for (uint i = 0; i < colorPoints; i++) { chartSeries.Append(colorChartLines(i)); } return(chartShapeProperties1); }
/// <summary> /// Set display, width, color and fill of borders and data (line, bar etc.) in chart. /// </summary> public virtual ChartShapeProperties SetChartShapeProperties(OpenXmlCompositeElement chartSeries) { ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); Outline outline = new Outline() { Width = 28575, CapType = LineCapValues.Round }; outline.Append(new NoFill()); outline.Append(new Round()); chartShapeProperties.Append(outline); chartShapeProperties.Append(new EffectList()); chartSeries.Append(chartShapeProperties); return(chartShapeProperties); }
public ChartShapeProperties Build() { var chartShapeProperties = new ChartShapeProperties(); if (this.Options.BlackWhiteMode.HasValue) { chartShapeProperties.BlackWhiteMode = this.Options.BlackWhiteMode; } if (this.Options.FillType.HasValue) { switch (this.Options.FillType) { case FillTypes.NoFill: chartShapeProperties.Append(new NoFill()); break; } } if (this.Options.HasLine) { var outlineBuilder = new OutlineBuilder(this.Options.OutlineOptions); chartShapeProperties.Append(outlineBuilder.Build()); } if (this.Options.HasEffectList) { var effectListBuilder = new EffectListBuilder(this.Options.EffectListOptions); chartShapeProperties.Append(effectListBuilder.Build()); } return(chartShapeProperties); }
private void SetWaterfallStructure(BarChartSeries seriesItem, Column dataColumn) { var dataPoints = seriesItem.Elements <DataPoint>(); var labels = seriesItem.FirstElement <DataLabels>(); bool isFirstBar = dataColumn.Data[0] != null; if (!isFirstBar) { int valueToHideInd = dataColumn.Data.IndexOf(dataColumn.Data.First(v => v != null)); DataPoint dataPoint = dataPoints.FirstOrDefault(p => p.Index != null && p.Index.Val != null && p.Index.Val.Value == valueToHideInd); dataPoint.RemoveAllChildren <ChartShapeProperties>(); ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); chartShapeProperties.Append(new A.NoFill()); dataPoint.Append(chartShapeProperties); DataLabel label = labels.Elements <DataLabel>().FirstOrDefault(p => p.Index != null && p.Index.Val != null && p.Index.Val.Value == valueToHideInd); if (label != null) { label.FirstElement <ShowValue>().Val.Value = false; } } labels.FirstElement <ShowValue>().Val.Value = false; }
/// <summary> /// Design settings for Y axis. /// </summary> public ValueAxis SetGanttValueAxis(PlotArea plotArea, TimeSpan minSpan, TimeSpan maxSpan) { MajorGridlines majorGridlines1 = new MajorGridlines(); ChartShapeProperties chartShapeProperties2 = new ChartShapeProperties(); Outline outline2 = new Outline(); SolidFill solidFill2 = new SolidFill(); SchemeColor schemeColor2 = new SchemeColor() { Val = SchemeColorValues.Accent1 }; Alpha alpha1 = new Alpha() { Val = 10000 }; schemeColor2.Append(alpha1); solidFill2.Append(schemeColor2); outline2.Append(solidFill2); chartShapeProperties2.Append(outline2); majorGridlines1.Append(chartShapeProperties2); return(plotArea.AppendChild <ValueAxis>(new ValueAxis(new AxisId() { Val = new UInt32Value(48672768u) }, new Scaling(new Orientation() { Val = new EnumValue <DocumentFormat.OpenXml.Drawing.Charts.OrientationValues>( DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax) }, new MinAxisValue() { Val = 0 }, new MaxAxisValue() { Val = 0.99 }), new Delete() { Val = false }, new AxisPosition() { Val = new EnumValue <AxisPositionValues>(AxisPositionValues.Left) }, majorGridlines1, new MajorTickMark() { Val = TickMarkValues.None }, new MinorTickMark() { Val = TickMarkValues.None }, new MajorUnit() { Val = 4.1666666666666713E-2D }, new DocumentFormat.OpenXml.Drawing.Charts.NumberingFormat() { FormatCode = "h:mm;@", SourceLinked = false }, new TickLabelPosition() { Val = new EnumValue <TickLabelPositionValues> (TickLabelPositionValues.NextTo) }, new CrossingAxis() { Val = new UInt32Value(48650112U) }, new Crosses() { Val = new EnumValue <CrossesValues>(CrossesValues.AutoZero) }, new CrossBetween() { Val = new EnumValue <CrossBetweenValues>(CrossBetweenValues.Between) }))); }
/// <summary> /// Design settings for Y axis. /// </summary> public virtual ValueAxis SetValueAxis(PlotArea plotArea) { // Postavljanje Gridline-a. MajorGridlines majorGridlines = new MajorGridlines(); ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); Outline outline = new Outline(); SolidFill solidFill = new SolidFill(); SchemeColor schemeColor = new SchemeColor() { Val = SchemeColorValues.Accent1 }; Alpha alpha = new Alpha() { Val = 10000 }; schemeColor.Append(alpha); solidFill.Append(schemeColor); outline.Append(solidFill); chartShapeProperties.Append(outline); majorGridlines.Append(chartShapeProperties); var valueAxis = plotArea.AppendChild <ValueAxis>(new ValueAxis( new AxisId() { Val = new UInt32Value(48672768u) }, new Scaling(new Orientation() { Val = new EnumValue <DocumentFormat.OpenXml.Drawing.Charts.OrientationValues>( DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax) }), new Delete() { Val = !ChartProperties.AxisY }, new AxisPosition() { Val = new EnumValue <AxisPositionValues>(AxisPositionValues.Left) }, majorGridlines, SetTitle(ChartProperties.AxisYTitle), new NumberingFormat() { FormatCode = ChartProperties.AxisYFormatCode, SourceLinked = new BooleanValue(true) }, new MajorTickMark() { Val = TickMarkValues.None }, new MinorTickMark() { Val = TickMarkValues.None }, new TickLabelPosition() { Val = new EnumValue <TickLabelPositionValues> (TickLabelPositionValues.NextTo) }, new CrossingAxis() { Val = new UInt32Value(48650112U) }, new Crosses() { Val = new EnumValue <CrossesValues>(CrossesValues.AutoZero) }, new CrossBetween() { Val = new EnumValue <CrossBetweenValues>(CrossBetweenValues.Between) })); if (ChartProperties.AxisYFormatCategory == "Time") { valueAxis.Append(new MajorUnit() { Val = getMajorUnitFromSeconds((int)yAxisValue) }); } return(valueAxis); }
private void SetPropertiesFromLegend(OpenXmlCompositeElement seriesItem, Column dataColumn) { if (dataColumn.Legends.All(l => l == null)) { return; } var dataPoints = seriesItem.Elements <DataPoint>(); var labels = seriesItem.FirstElement <DataLabels>(); for (int rowNo = 0; rowNo < dataColumn.Data.Count; rowNo++) { if (dataColumn.Legends[rowNo] != null && dataColumn.Data[rowNo] != null) { ShapeElement legend = dataColumn.Legends[rowNo] as ShapeElement; DataPoint dataPoint = dataPoints.FirstOrDefault(p => p.Index != null && p.Index.Val != null && p.Index.Val.Value == rowNo); if (legend != null) //KAJ: Actually always true if you have reached this line { if (dataPoint != null) { dataPoint.RemoveAllChildren <ChartShapeProperties>(); A.SolidFill legendFill = legend.Element.GetFill(); A.Outline legendOutline = legend.Element.GetOutline(); ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); chartShapeProperties.Append(legendFill); chartShapeProperties.Append(legendOutline); dataPoint.Append(chartShapeProperties); } if (labels != null) { DataLabel label = labels.Elements <DataLabel>().FirstOrDefault(p => p.Index != null && p.Index.Val != null && p.Index.Val.Value == rowNo); if (label != null) { TextProperties labelTextProperties = label.FirstElement <TextProperties>(); if (labelTextProperties == null) { labelTextProperties = labels.FirstElement <TextProperties>().CloneNode(true) as TextProperties; label.Append(labelTextProperties); } NumberingFormat labelNumberingFormat = label.FirstElement <NumberingFormat>(); if (labelNumberingFormat == null) { labelNumberingFormat = labels.FirstElement <NumberingFormat>().CloneNode(true) as NumberingFormat; label.Append(labelNumberingFormat); } A.Paragraph labelParagraph = labelTextProperties.FirstElement <A.Paragraph>(); var legendRunProperties = legend.Element.GetRunProperties(); labelParagraph.ParagraphProperties.RemoveAllChildren <A.DefaultRunProperties>(); List <OpenXmlElement> list = new List <OpenXmlElement>(); foreach (var item in legendRunProperties.ChildElements) { list.Add(item.CloneNode(true)); } var newLabelRunProperties = new A.DefaultRunProperties(list); labelParagraph.ParagraphProperties.Append(newLabelRunProperties); var labelShapeProperties = label.FirstElement <ChartShapeProperties>(); if (labelShapeProperties != null && labelShapeProperties.FirstElement <A.NoFill>() == null) { label.RemoveAllChildren <ChartShapeProperties>(); } A.SolidFill legendFill = legend.Element.GetFill(); ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); chartShapeProperties.Append(legendFill); label.Append(chartShapeProperties); } } } } } }