Пример #1
0
        internal C.ValueAxis ToValueAxis(bool IsStylish = false)
        {
            var va = new C.ValueAxis();

            va.AxisId = new C.AxisId {
                Val = AxisId
            };

            va.Scaling             = new C.Scaling();
            va.Scaling.Orientation = new C.Orientation {
                Val = Orientation
            };
            if (LogBase != null)
            {
                va.Scaling.LogBase = new C.LogBase {
                    Val = LogBase.Value
                }
            }
            ;
            if (MaxAxisValue != null)
            {
                va.Scaling.MaxAxisValue = new C.MaxAxisValue {
                    Val = MaxAxisValue.Value
                }
            }
            ;
            if (MinAxisValue != null)
            {
                va.Scaling.MinAxisValue = new C.MinAxisValue {
                    Val = MinAxisValue.Value
                }
            }
            ;

            va.Delete = new C.Delete {
                Val = Delete
            };

            var axpos = AxisPosition;

            if (!ForceAxisPosition)
            {
                if (OtherAxisIsInReverseOrder)
                {
                    axpos = SLChartTool.GetOppositePosition(axpos);
                }
                if (OtherAxisCrossedAtMaximum)
                {
                    axpos = SLChartTool.GetOppositePosition(axpos);
                }
            }
            va.AxisPosition = new C.AxisPosition {
                Val = axpos
            };

            if (ShowMajorGridlines)
            {
                va.MajorGridlines = MajorGridlines.ToMajorGridlines(IsStylish);
            }

            if (ShowMinorGridlines)
            {
                va.MinorGridlines = MinorGridlines.ToMinorGridlines(IsStylish);
            }

            if (ShowTitle)
            {
                va.Title = Title.ToTitle(IsStylish);
            }

            if (HasNumberingFormat)
            {
                va.NumberingFormat = new C.NumberingFormat
                {
                    FormatCode   = FormatCode,
                    SourceLinked = SourceLinked
                }
            }
            ;

            va.MajorTickMark = new C.MajorTickMark {
                Val = MajorTickMark
            };
            va.MinorTickMark = new C.MinorTickMark {
                Val = MinorTickMark
            };
            va.TickLabelPosition = new C.TickLabelPosition {
                Val = TickLabelPosition
            };

            if (ShapeProperties.HasShapeProperties)
            {
                va.ChartShapeProperties = ShapeProperties.ToChartShapeProperties(IsStylish);
            }

            if ((Rotation != null) || (Vertical != null) || (Anchor != null) || (AnchorCenter != null))
            {
                va.TextProperties = new C.TextProperties();
                va.TextProperties.BodyProperties = new A.BodyProperties();
                if (Rotation != null)
                {
                    va.TextProperties.BodyProperties.Rotation =
                        (int)(Rotation.Value * SLConstants.DegreeToAngleRepresentation);
                }
                if (Vertical != null)
                {
                    va.TextProperties.BodyProperties.Vertical = Vertical.Value;
                }
                if (Anchor != null)
                {
                    va.TextProperties.BodyProperties.Anchor = Anchor.Value;
                }
                if (AnchorCenter != null)
                {
                    va.TextProperties.BodyProperties.AnchorCenter = AnchorCenter.Value;
                }

                va.TextProperties.ListStyle = new A.ListStyle();

                var para = new A.Paragraph();
                para.ParagraphProperties = new A.ParagraphProperties();
                para.ParagraphProperties.Append(new A.DefaultRunProperties());
                va.TextProperties.Append(para);
            }
            else if (IsStylish)
            {
                va.TextProperties = new C.TextProperties();
                va.TextProperties.BodyProperties = new A.BodyProperties
                {
                    Rotation            = -60000000,
                    UseParagraphSpacing = true,
                    VerticalOverflow    = A.TextVerticalOverflowValues.Ellipsis,
                    Vertical            = A.TextVerticalValues.Horizontal,
                    Wrap         = A.TextWrappingValues.Square,
                    Anchor       = A.TextAnchoringTypeValues.Center,
                    AnchorCenter = true
                };
                va.TextProperties.ListStyle = new A.ListStyle();

                var para = new A.Paragraph();
                para.ParagraphProperties = new A.ParagraphProperties();

                var defrunprops = new A.DefaultRunProperties();
                defrunprops.FontSize  = 900;
                defrunprops.Bold      = false;
                defrunprops.Italic    = false;
                defrunprops.Underline = A.TextUnderlineValues.None;
                defrunprops.Strike    = A.TextStrikeValues.NoStrike;
                defrunprops.Kerning   = 1200;
                defrunprops.Baseline  = 0;

                var schclr = new A.SchemeColor {
                    Val = A.SchemeColorValues.Text1
                };
                schclr.Append(new A.LuminanceModulation {
                    Val = 65000
                });
                schclr.Append(new A.LuminanceOffset {
                    Val = 35000
                });
                defrunprops.Append(new A.SolidFill
                {
                    SchemeColor = schclr
                });

                defrunprops.Append(new A.LatinFont {
                    Typeface = "+mn-lt"
                });
                defrunprops.Append(new A.EastAsianFont {
                    Typeface = "+mn-ea"
                });
                defrunprops.Append(new A.ComplexScriptFont {
                    Typeface = "+mn-cs"
                });

                para.ParagraphProperties.Append(defrunprops);
                para.Append(new A.EndParagraphRunProperties {
                    Language = CultureInfo.CurrentCulture.Name
                });

                va.TextProperties.Append(para);
            }

            va.CrossingAxis = new C.CrossingAxis {
                Val = CrossingAxis
            };

            if (IsCrosses != null)
            {
                if (IsCrosses.Value)
                {
                    va.Append(new C.Crosses {
                        Val = Crosses
                    });
                }
                else
                {
                    va.Append(new C.CrossesAt {
                        Val = CrossesAt
                    });
                }
            }

            va.Append(new C.CrossBetween {
                Val = CrossBetween
            });
            if (MajorUnit != null)
            {
                va.Append(new C.MajorUnit {
                    Val = MajorUnit.Value
                });
            }
            if (MinorUnit != null)
            {
                va.Append(new C.MinorUnit {
                    Val = MinorUnit.Value
                });
            }

            if (BuiltInUnitValues != null)
            {
                var du = new C.DisplayUnits();
                du.Append(new C.BuiltInUnit {
                    Val = BuiltInUnitValues.Value
                });
                if (ShowDisplayUnitsLabel)
                {
                    var dul = new C.DisplayUnitsLabel();
                    dul.Layout = new C.Layout();
                    du.Append(dul);
                }
                va.Append(du);
            }

            return(va);
        }
 internal void RefreshFormula()
 {
     Formula = SLChartTool.GetChartReferenceFormula(WorksheetName, StartRowIndex, StartColumnIndex, EndRowIndex,
                                                    EndColumnIndex);
 }