Beispiel #1
0
        public SchemeColor Build()
        {
            var schemaColor = new SchemeColor();

            schemaColor.Val = this.Options.SchemeColor;

            decimal decTint = this.Options.Tint;

            // we don't have to do anything extra if the tint's zero.
            if (decTint < 0.0m)
            {
                decTint += 1.0m;
                decTint *= 100000m;
                schemaColor.Append(new LuminanceModulation()
                {
                    Val = Convert.ToInt32(decTint)
                });
            }
            else if (decTint > 0.0m)
            {
                decTint *= 100000m;
                decTint  = decimal.Floor(decTint);
                schemaColor.Append(new LuminanceModulation()
                {
                    Val = Convert.ToInt32(100000m - decTint)
                });
                schemaColor.Append(new LuminanceOffset()
                {
                    Val = Convert.ToInt32(decTint)
                });
            }

            var alpha = CalculateAlpha();

            if (alpha < 100000)
            {
                schemaColor.Append(new Alpha()
                {
                    Val = alpha
                });
            }

            return(schemaColor);
        }
Beispiel #2
0
        /// <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);
        }
        public ValueAxis Build()
        {
            var valueAxis = new ValueAxis();

            valueAxis.AxisId = new AxisId {
                Val = this.Options.Id
            };

            valueAxis.Scaling = new Scaling();

            valueAxis.Scaling.Orientation = new Orientation {
                Val = this.Options.Orientation
            };

            if (this.Options.MinMaxBounds.HasValue)
            {
                var minAxisValue = new MinAxisValue {
                    Val = this.Options.MinMaxBounds.Value.MinValue
                };

                var maxAxisValue = new MaxAxisValue {
                    Val = this.Options.MinMaxBounds.Value.MaxValue
                };

                valueAxis.Scaling.Append(minAxisValue);

                valueAxis.Scaling.Append(maxAxisValue);
            }

            if (this.Options.MinMaxUnits.HasValue)
            {
                var minorUnit = new MinorUnit {
                    Val = this.Options.MinMaxUnits.Value.MinValue
                };

                var majorUnit = new MajorUnit {
                    Val = this.Options.MinMaxUnits.Value.MaxValue
                };

                valueAxis.Append(minorUnit);

                valueAxis.Append(majorUnit);
            }

            valueAxis.Delete = new Delete {
                Val = false
            };

            valueAxis.AxisPosition = new AxisPosition {
                Val = this.Options.AxisPosition
            };

            if (this.Options.ShowMajorGridlines)
            {
                var majorGridlinesBuilder = new MajorGridlinesBuilder(this.Options.MajorGridlinesOptions);

                valueAxis.MajorGridlines = majorGridlinesBuilder.Build();
            }

            if (this.Options.HasNumberingFormat)
            {
                valueAxis.NumberingFormat = new NumberingFormat
                {
                    FormatCode   = this.Options.FormatCode,
                    SourceLinked = this.Options.SourceLinked
                };
            }

            valueAxis.MajorTickMark = new MajorTickMark {
                Val = this.Options.MajorTickMark
            };

            valueAxis.MinorTickMark = new MinorTickMark {
                Val = this.Options.MinorTickMark
            };

            valueAxis.TickLabelPosition = new TickLabelPosition {
                Val = this.Options.TickLabelPosition
            };

            if (this.Options.HasChartShapeProperties)
            {
                var chartShapePropertiesBuilder = new ChartShapePropertiesBuilder(this.Options.ChartShapePropertiesOptions);

                valueAxis.ChartShapeProperties = chartShapePropertiesBuilder.Build();
            }

            if (this.Options.IsTextStylish)
            {
                valueAxis.TextProperties = new TextProperties();
                valueAxis.TextProperties.BodyProperties = new BodyProperties()
                {
                    Rotation            = -60000000,
                    UseParagraphSpacing = true,
                    VerticalOverflow    = TextVerticalOverflowValues.Ellipsis,
                    Vertical            = TextVerticalValues.Horizontal,
                    Wrap         = TextWrappingValues.Square,
                    Anchor       = TextAnchoringTypeValues.Center,
                    AnchorCenter = true
                };
                valueAxis.TextProperties.ListStyle = new ListStyle();

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

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

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

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

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

                valueAxis.TextProperties.Append(para);
            }

            valueAxis.CrossingAxis = new CrossingAxis {
                Val = this.Options.CrossingAxisVal
            };

            if (this.Options.Crosses.HasValue)
            {
                valueAxis.Append(new Crosses {
                    Val = this.Options.Crosses
                });
            }
            else if (this.Options.CrossesAtVal.HasValue)
            {
                valueAxis.Append(new CrossesAt()
                {
                    Val = this.Options.CrossesAtVal
                });
            }

            valueAxis.Append(new CrossBetween {
                Val = this.Options.CrossBetween
            });

            return(valueAxis);
        }