internal SLDataBar Clone() { var db = new SLDataBar(); db.Is2010 = Is2010; db.MinimumType = MinimumType; db.MinimumValue = MinimumValue; db.MaximumType = MaximumType; db.MaximumValue = MaximumValue; db.Color = Color.Clone(); db.BorderColor = BorderColor.Clone(); db.NegativeFillColor = NegativeFillColor.Clone(); db.NegativeBorderColor = NegativeBorderColor.Clone(); db.AxisColor = AxisColor.Clone(); db.MinLength = MinLength; db.MaxLength = MaxLength; db.ShowValue = ShowValue; db.Border = Border; db.Gradient = Gradient; db.Direction = Direction; db.NegativeBarColorSameAsPositive = NegativeBarColorSameAsPositive; db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive; db.AxisPosition = AxisPosition; return(db); }
/// <summary> /// Synchronizes the properties. /// </summary> /// <param name="series">The series.</param> protected override void SynchronizeProperties(OxyPlot.Series.Series series) { base.SynchronizeProperties(series); var s = (OxyPlot.Series.LinearBarSeries)series; s.BarWidth = BarWidth; s.FillColor = FillColor.ToOxyColor(); s.StrokeColor = StrokeColor.ToOxyColor(); s.StrokeThickness = StrokeThickness; s.NegativeFillColor = NegativeFillColor.ToOxyColor(); s.NegativeStrokeColor = NegativeStrokeColor.ToOxyColor(); }
/// <summary> /// Synchronizes the properties. /// </summary> /// <param name="series">The series.</param> protected override void SynchronizeProperties(OxyPlot.Series.Series series) { base.SynchronizeProperties(series); var s = (OxyPlot.Series.BarSeriesBase)series; s.BaseValue = BaseValue; s.ColorField = ColorField; s.FillColor = FillColor.ToOxyColor(); s.IsStacked = IsStacked; s.NegativeFillColor = NegativeFillColor.ToOxyColor(); s.StrokeColor = StrokeColor.ToOxyColor(); s.StrokeThickness = StrokeThickness; s.StackGroup = StackGroup; s.ValueField = ValueField; s.LabelFormatString = LabelFormatString; s.LabelMargin = LabelMargin; s.LabelPlacement = LabelPlacement; }
internal SLDataBar2010 Clone() { var db = new SLDataBar2010(); db.Cfvo1 = Cfvo1.Clone(); db.Cfvo2 = Cfvo2.Clone(); db.FillColor = FillColor.Clone(); db.BorderColor = BorderColor.Clone(); db.NegativeFillColor = NegativeFillColor.Clone(); db.NegativeBorderColor = NegativeBorderColor.Clone(); db.AxisColor = AxisColor.Clone(); db.MinLength = MinLength; db.MaxLength = MaxLength; db.ShowValue = ShowValue; db.Border = Border; db.Gradient = Gradient; db.Direction = Direction; db.NegativeBarColorSameAsPositive = NegativeBarColorSameAsPositive; db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive; db.AxisPosition = AxisPosition; return(db); }
public ConditionalFormattingRule Convert(IXLConditionalFormat cf, XLWorkbook.SaveContext context) { ConditionalFormattingRule conditionalFormattingRule = new ConditionalFormattingRule() { Type = DocumentFormat.OpenXml.Spreadsheet.ConditionalFormatValues.DataBar, Id = (cf as XLConditionalFormat).Id.WrapInBraces() }; DataBar dataBar = new DataBar() { MinLength = 0, MaxLength = 100, Gradient = true, ShowValue = !cf.ShowBarOnly }; var cfMinType = cf.ContentTypes.TryGetValue(1, out var contentType1) ? Convert(contentType1.ToOpenXml()) : ConditionalFormattingValueObjectTypeValues.AutoMin; var cfMin = new ConditionalFormattingValueObject { Type = cfMinType }; if (cf.Values.Any() && cf.Values[1]?.Value != null) { cfMin.Type = ConditionalFormattingValueObjectTypeValues.Numeric; cfMin.Append(new Formula() { Text = cf.Values[1].Value }); } var cfMaxType = cf.ContentTypes.TryGetValue(2, out var contentType2) ? Convert(contentType2.ToOpenXml()) : ConditionalFormattingValueObjectTypeValues.AutoMax; var cfMax = new ConditionalFormattingValueObject { Type = cfMaxType }; if (cf.Values.Count >= 2 && cf.Values[2]?.Value != null) { cfMax.Type = ConditionalFormattingValueObjectTypeValues.Numeric; cfMax.Append(new Formula() { Text = cf.Values[2].Value }); } var barAxisColor = new BarAxisColor { Rgb = XLColor.Black.Color.ToHex() }; var negativeFillColor = new NegativeFillColor { Rgb = cf.Colors[1].Color.ToHex() }; if (cf.Colors.Count == 2) { negativeFillColor = new NegativeFillColor { Rgb = cf.Colors[2].Color.ToHex() }; } dataBar.Append(cfMin); dataBar.Append(cfMax); dataBar.Append(negativeFillColor); dataBar.Append(barAxisColor); conditionalFormattingRule.Append(dataBar); return(conditionalFormattingRule); }
internal SLDataBar2010 ToDataBar2010() { var db = new SLDataBar2010(); switch (MinimumType) { case SLConditionalFormatAutoMinMaxValues.Automatic: db.Cfvo1.Type = X14.ConditionalFormattingValueObjectTypeValues.AutoMin; db.Cfvo1.Formula = string.Empty; break; case SLConditionalFormatAutoMinMaxValues.Formula: db.Cfvo1.Type = X14.ConditionalFormattingValueObjectTypeValues.Formula; db.Cfvo1.Formula = MinimumValue; break; case SLConditionalFormatAutoMinMaxValues.Number: db.Cfvo1.Type = X14.ConditionalFormattingValueObjectTypeValues.Numeric; db.Cfvo1.Formula = MinimumValue; break; case SLConditionalFormatAutoMinMaxValues.Percent: db.Cfvo1.Type = X14.ConditionalFormattingValueObjectTypeValues.Percent; db.Cfvo1.Formula = MinimumValue; break; case SLConditionalFormatAutoMinMaxValues.Percentile: db.Cfvo1.Type = X14.ConditionalFormattingValueObjectTypeValues.Percentile; db.Cfvo1.Formula = MinimumValue; break; case SLConditionalFormatAutoMinMaxValues.Value: db.Cfvo1.Type = X14.ConditionalFormattingValueObjectTypeValues.Min; db.Cfvo1.Formula = string.Empty; break; } switch (MaximumType) { case SLConditionalFormatAutoMinMaxValues.Automatic: db.Cfvo2.Type = X14.ConditionalFormattingValueObjectTypeValues.AutoMax; db.Cfvo2.Formula = string.Empty; break; case SLConditionalFormatAutoMinMaxValues.Formula: db.Cfvo2.Type = X14.ConditionalFormattingValueObjectTypeValues.Formula; db.Cfvo2.Formula = MaximumValue; break; case SLConditionalFormatAutoMinMaxValues.Number: db.Cfvo2.Type = X14.ConditionalFormattingValueObjectTypeValues.Numeric; db.Cfvo2.Formula = MaximumValue; break; case SLConditionalFormatAutoMinMaxValues.Percent: db.Cfvo2.Type = X14.ConditionalFormattingValueObjectTypeValues.Percent; db.Cfvo2.Formula = MaximumValue; break; case SLConditionalFormatAutoMinMaxValues.Percentile: db.Cfvo2.Type = X14.ConditionalFormattingValueObjectTypeValues.Percentile; db.Cfvo2.Formula = MaximumValue; break; case SLConditionalFormatAutoMinMaxValues.Value: db.Cfvo2.Type = X14.ConditionalFormattingValueObjectTypeValues.Max; db.Cfvo2.Formula = string.Empty; break; } db.FillColor = Color.Clone(); db.BorderColor = BorderColor.Clone(); db.NegativeFillColor = NegativeFillColor.Clone(); db.NegativeBorderColor = NegativeBorderColor.Clone(); db.AxisColor = AxisColor.Clone(); db.MinLength = MinLength; db.MaxLength = MaxLength; db.ShowValue = ShowValue; db.Border = Border; db.Gradient = Gradient; db.Direction = Direction; db.NegativeBarColorSameAsPositive = NegativeBarColorSameAsPositive; db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive; db.AxisPosition = AxisPosition; return(db); }
internal void FromDataBar(X14.DataBar db) { SetAllNull(); using (var oxr = OpenXmlReader.Create(db)) { var i = 0; while (oxr.Read()) { if (oxr.ElementType == typeof(X14.ConditionalFormattingValueObject)) { if (i == 0) { Cfvo1.FromConditionalFormattingValueObject( (X14.ConditionalFormattingValueObject)oxr.LoadCurrentElement()); ++i; } else if (i == 1) { Cfvo2.FromConditionalFormattingValueObject( (X14.ConditionalFormattingValueObject)oxr.LoadCurrentElement()); ++i; } } else if (oxr.ElementType == typeof(X14.FillColor)) { FillColor.FromFillColor((X14.FillColor)oxr.LoadCurrentElement()); } else if (oxr.ElementType == typeof(X14.BorderColor)) { BorderColor.FromBorderColor((X14.BorderColor)oxr.LoadCurrentElement()); } else if (oxr.ElementType == typeof(X14.NegativeFillColor)) { NegativeFillColor.FromNegativeFillColor((X14.NegativeFillColor)oxr.LoadCurrentElement()); } else if (oxr.ElementType == typeof(X14.NegativeBorderColor)) { NegativeBorderColor.FromNegativeBorderColor((X14.NegativeBorderColor)oxr.LoadCurrentElement()); } else if (oxr.ElementType == typeof(X14.BarAxisColor)) { AxisColor.FromBarAxisColor((X14.BarAxisColor)oxr.LoadCurrentElement()); } } } if (db.MinLength != null) { MinLength = db.MinLength.Value; } if (db.MaxLength != null) { MaxLength = db.MaxLength.Value; } if (db.ShowValue != null) { ShowValue = db.ShowValue.Value; } if (db.Border != null) { Border = db.Border.Value; } if (db.Gradient != null) { Gradient = db.Gradient.Value; } if (db.Direction != null) { Direction = db.Direction.Value; } if (db.NegativeBarColorSameAsPositive != null) { NegativeBarColorSameAsPositive = db.NegativeBarColorSameAsPositive.Value; } if (db.NegativeBarBorderColorSameAsPositive != null) { NegativeBarBorderColorSameAsPositive = db.NegativeBarBorderColorSameAsPositive.Value; } if (db.AxisPosition != null) { AxisPosition = db.AxisPosition.Value; } }
internal X14.DataBar ToDataBar(bool RenderFillColor) { var db = new X14.DataBar(); if (MinLength != 10) { db.MinLength = MinLength; } // according to Open XML specs, this cannot be more than 100 percent. if (MaxLength > 100) { MaxLength = 100; } if (MaxLength != 90) { db.MaxLength = MaxLength; } if (!ShowValue) { db.ShowValue = ShowValue; } if (Border) { db.Border = Border; } if (!Gradient) { db.Gradient = Gradient; } if (Direction != X14.DataBarDirectionValues.Context) { db.Direction = Direction; } if (NegativeBarColorSameAsPositive) { db.NegativeBarColorSameAsPositive = NegativeBarColorSameAsPositive; } if (!NegativeBarBorderColorSameAsPositive) { db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive; } if (AxisPosition != X14.DataBarAxisPositionValues.Automatic) { db.AxisPosition = AxisPosition; } db.Append(Cfvo1.ToConditionalFormattingValueObject()); db.Append(Cfvo2.ToConditionalFormattingValueObject()); // The condition is mainly if the priority of the parent rule exists. See Open XML specs. if (RenderFillColor) { db.Append(FillColor.ToFillColor()); } if (Border) { db.Append(BorderColor.ToBorderColor()); } if (!NegativeBarColorSameAsPositive) { db.Append(NegativeFillColor.ToNegativeFillColor()); } if (!NegativeBarBorderColorSameAsPositive && Border) { db.Append(NegativeBorderColor.ToNegativeBorderColor()); } if (AxisPosition != X14.DataBarAxisPositionValues.None) { db.Append(AxisColor.ToBarAxisColor()); } return(db); }