public MainWindow()
        {
            DataContext = this;

            Graph = new PlotModel();
            chart = new ChartAdapter(Graph);
            chart.SetLinearScale(AxisProperty.Both);

            loader = new SchemeLoader();
            loader.Import(@"Scheme.rkt");

            var evaluator = new ProxySchemeEvaluator();
            var schemeCalculator = new SchemeCalculator(evaluator);
            transformer = new LineSeriesTransformer((IFunctionPlotter)schemeCalculator,(ICalculate)schemeCalculator);

            modelCollection = new ObservableLineSeriesModelCollection();
            modelCollection.CollectionChanged += ModelChanged;

            ModelViewCollection = new ObservableLineSeriesViewModelCollection();
            ModelViewCollection.AddModel(new LineSeriesViewModel
                                      {
                                          Function = "(lambda (x) x)",
                                          Name = "Example 1",
                                      });
            InitializeComponent();
        }
        public void AttachAxes(IChart chart, int dimension, string[] axisLabels)
        {
            const double margin = 0.0;
            const double spaceBetweenAxes = 200;

            var horizontalHelperAxis = new Axis();
            horizontalHelperAxis.IsHelper = true;
            horizontalHelperAxis.Orientation = AxisOrientation.Horizontal;
            horizontalHelperAxis.Dimension = dimension;
            horizontalHelperAxis.Label = axisLabels[dimension];
            horizontalHelperAxis.Scale = 1.0;

            for (int i = 0; i < dimension; i++)
            {
                var axis = new Axis();
                axis.Dimension = i;
                axis.Label = axisLabels[i];
                axis.Orientation = AxisOrientation.Vertical;
                axis.OriginalValue = i * spaceBetweenAxes + margin;

                horizontalHelperAxis.DependentAxes.Add(axis);

                chart.Axes.Add(axis);
            }

            horizontalHelperAxis.Transformation.Transform(horizontalHelperAxis, horizontalHelperAxis.DependentAxes);
            chart.Axes.Add(horizontalHelperAxis);
        }
 /// <summary>
 /// Инициализирует компонент для построения графиков настройками
 /// </summary>
 /// <param name="chart">интерфейсная ссылка на объект компонента для построения графиков</param>
 public override void ApplySettingsToChart(IChart chart)
 {
     var settings = (TwoDevicesSettings) Settings;
     base.ApplySettingsToChart(chart);
     chart.SetSeriesNames(Settings.Series1Legend, settings.Series2Legend);
     chart.PlotMode = settings.PlotMode;
 }
 public void AttachDataSets(IChart chart, IEnumerable<MultiDimensionalPoint> points, int pointDimension, object[] tags)
 {
     int i = 0;
     foreach (var point in points)
     {
         AttachDataSet(chart, point, pointDimension, tags[i]);
         i++;
     }
 }
예제 #5
0
        public static void ValidateChartXmlByReflection(IChart chart) {
            var xmlText = ChartExtensions.BuildChartXml(chart, true);

            if(IsDebugEnabled)
                log.Debug(xmlText);

            var doc = new XmlDoc(xmlText);

            Assert.IsTrue(doc.IsValidDocument);
        }
        public DeLongChartPresenter(IDeLongChartView view)
        {
            _view = view;
            _view.Presenter = this;
            _dataConnector = new DataConnector();
            _chart = new Chart(Graphics.FromHwnd(_view.DrawPanelCanvas),
                _dataConnector.GetDeLongImages(),
                _dataConnector.GetDeLongChartSizingData());

            SetVisibilityCheckBoxesToTrue();
            RefreshSelectedMaterials();
        }
예제 #7
0
        public static void ValidateChartXml(IChart chart) {
            var xmlText = chart.GetDataXml(true);

            if(IsDebugEnabled) {
                log.Debug("Chart Xml:");
                log.Debug(xmlText);
            }

            var doc = new XmlDoc(xmlText);

            Assert.IsTrue(doc.IsValidDocument);
        }
예제 #8
0
		public SmaStrategy(IChart chart, ChartCandleElement candlesElem, ChartTradeElement tradesElem, 
			SimpleMovingAverage shortMa, ChartIndicatorElement shortElem,
			SimpleMovingAverage longMa, ChartIndicatorElement longElem,
			CandleSeries series)
		{
			_chart = chart;
			_candlesElem = candlesElem;
			_tradesElem = tradesElem;
			_shortElem = shortElem;
			_longElem = longElem;
			
			_series = series;

			ShortSma = shortMa;
			LongSma = longMa;
		}
        public void SaveMinimap()
        {
            int widthForA4 = (int)((float)_view.DrawPanelWidth * 0.8);
            int heightForA4 = (int)((float)_view.DrawPanelHeight * 0.8);

            Bitmap bitmap = new Bitmap(widthForA4, heightForA4);

            if (_minimapCombination == MinimapCombination.SchaefflerDeLong)
            {
                _chart = new Chart(Graphics.FromImage(bitmap),
                _dataConnector.GetSchaefflerDeLongMinimapImages(),
                _dataConnector.GetSchaefflerDeLongMinimapSizingData());
            }
            else if (_minimapCombination == MinimapCombination.SchaefflerWRC1992)
            {
                _chart = new Chart(Graphics.FromImage(bitmap),
                    _dataConnector.GetSchaefflerWRC1992MinimapImages(),
                    _dataConnector.GetSchaefflerWRC1992MinimapSizingData());
            }

            _chart.ResizeTo(widthForA4, heightForA4);
            _chart.Draw();
            DrawLines();

            _dataConnector.SaveMinimapForPDF(bitmap);

            if (_minimapCombination == MinimapCombination.SchaefflerDeLong)
            {
                _chart = new Chart(Graphics.FromHwnd(_view.DrawPanelCanvas),
                _dataConnector.GetSchaefflerDeLongMinimapImages(),
                _dataConnector.GetSchaefflerDeLongMinimapSizingData());
            }
            else if (_minimapCombination == MinimapCombination.SchaefflerWRC1992)
            {
                _chart = new Chart(Graphics.FromHwnd(_view.DrawPanelCanvas),
                    _dataConnector.GetSchaefflerWRC1992MinimapImages(),
                    _dataConnector.GetSchaefflerWRC1992MinimapSizingData());
            }
            _chart.ResizeTo(_view.DrawPanelWidth, _view.DrawPanelHeight);
            _chart.Draw();
            DrawLines();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartBindingSettings" /> class.
 /// </summary>
 /// <param name="chart">The chart.</param>
 public ChartBindingSettings(IChart chart)
 {
     this.chart = chart;
     Select = new RequestSettings();
 }
 private void LoadChartData()
 {
     if (_minimapCombination == MinimapCombination.SchaefflerDeLong)
     {
         _chart = new Chart(Graphics.FromHwnd(_view.DrawPanelCanvas),
             _dataConnector.GetSchaefflerDeLongMinimapImages(),
             _dataConnector.GetSchaefflerDeLongMinimapSizingData());
     }
     else if (_minimapCombination == MinimapCombination.SchaefflerWRC1992)
     {
         _chart = new Chart(Graphics.FromHwnd(_view.DrawPanelCanvas),
             _dataConnector.GetSchaefflerWRC1992MinimapImages(),
             _dataConnector.GetSchaefflerWRC1992MinimapSizingData());
     }
 }
예제 #12
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiating presentation//Instantiating presentation
            Presentation pres = new Presentation();

            //Accessing the first slide
            ISlide slide = pres.Slides[0];

            //Adding the sample chart
            IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 50, 50, 500, 400);

            //Setting Chart Titile
            chart.HasTitle = true;
            chart.ChartTitle.AddTextFrameForOverriding("");
            IPortion chartTitle = chart.ChartTitle.TextFrameForOverriding.Paragraphs[0].Portions[0];

            chartTitle.Text = "Sample Chart";
            chartTitle.PortionFormat.FillFormat.FillType             = FillType.Solid;
            chartTitle.PortionFormat.FillFormat.SolidFillColor.Color = Color.Gray;
            chartTitle.PortionFormat.FontHeight = 20;
            chartTitle.PortionFormat.FontBold   = NullableBool.True;
            chartTitle.PortionFormat.FontItalic = NullableBool.True;

            //Setting Major grid lines format for value axis
            chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType             = FillType.Solid;
            chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Blue;
            chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.Width     = 5;
            chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.DashStyle = LineDashStyle.DashDot;

            //Setting Minor grid lines format for value axis
            chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.FillFormat.FillType             = FillType.Solid;
            chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Red;
            chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.Width = 3;

            //Setting value axis number format
            chart.Axes.VerticalAxis.IsNumberFormatLinkedToSource = false;
            chart.Axes.VerticalAxis.DisplayUnit  = DisplayUnitType.Thousands;
            chart.Axes.VerticalAxis.NumberFormat = "0.0%";

            //Setting chart maximum, minimum values
            chart.Axes.VerticalAxis.IsAutomaticMajorUnit = false;
            chart.Axes.VerticalAxis.IsAutomaticMaxValue  = false;
            chart.Axes.VerticalAxis.IsAutomaticMinorUnit = false;
            chart.Axes.VerticalAxis.IsAutomaticMinValue  = false;

            chart.Axes.VerticalAxis.MaxValue  = 15f;
            chart.Axes.VerticalAxis.MinValue  = -2f;
            chart.Axes.VerticalAxis.MinorUnit = 0.5f;
            chart.Axes.VerticalAxis.MajorUnit = 2.0f;

            //Setting Value Axis Text Properties
            IChartPortionFormat txtVal = chart.Axes.VerticalAxis.TextFormat.PortionFormat;

            txtVal.FontBold                        = NullableBool.True;
            txtVal.FontHeight                      = 16;
            txtVal.FontItalic                      = NullableBool.True;
            txtVal.FillFormat.FillType             = FillType.Solid;;
            txtVal.FillFormat.SolidFillColor.Color = Color.DarkGreen;
            txtVal.LatinFont                       = new FontData("Times New Roman");

            //Setting value axis title
            chart.Axes.VerticalAxis.HasTitle = true;
            chart.Axes.VerticalAxis.Title.AddTextFrameForOverriding("");
            IPortion valtitle = chart.Axes.VerticalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0];

            valtitle.Text = "Primary Axis";
            valtitle.PortionFormat.FillFormat.FillType             = FillType.Solid;
            valtitle.PortionFormat.FillFormat.SolidFillColor.Color = Color.Gray;
            valtitle.PortionFormat.FontHeight = 20;
            valtitle.PortionFormat.FontBold   = NullableBool.True;
            valtitle.PortionFormat.FontItalic = NullableBool.True;

            //Setting value axis line format : Now Obselete
            // chart.Axes.VerticalAxis.aVerticalAxis.l.AxisLine.Width = 10;
            // chart.Axes.VerticalAxis.AxisLine.FillFormat.FillType = FillType.Solid;
            //chart.Axes.VerticalAxis.AxisLine.FillFormat.SolidFillColor.Color = Color.Red;

            //Setting Major grid lines format for Category axis
            chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.FillFormat.FillType             = FillType.Solid;
            chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Green;
            chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.Width = 5;

            //Setting Minor grid lines format for Category axis
            chart.Axes.HorizontalAxis.MinorGridLinesFormat.Line.FillFormat.FillType             = FillType.Solid;
            chart.Axes.HorizontalAxis.MinorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Yellow;
            chart.Axes.HorizontalAxis.MinorGridLinesFormat.Line.Width = 3;

            //Setting Category Axis Text Properties
            IChartPortionFormat txtCat = chart.Axes.HorizontalAxis.TextFormat.PortionFormat;

            txtCat.FontBold                        = NullableBool.True;
            txtCat.FontHeight                      = 16;
            txtCat.FontItalic                      = NullableBool.True;
            txtCat.FillFormat.FillType             = FillType.Solid;;
            txtCat.FillFormat.SolidFillColor.Color = Color.Blue;
            txtCat.LatinFont                       = new FontData("Arial");

            //Setting Category Titile
            chart.Axes.HorizontalAxis.HasTitle = true;
            chart.Axes.HorizontalAxis.Title.AddTextFrameForOverriding("");

            IPortion catTitle = chart.Axes.HorizontalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0];

            catTitle.Text = "Sample Category";
            catTitle.PortionFormat.FillFormat.FillType             = FillType.Solid;
            catTitle.PortionFormat.FillFormat.SolidFillColor.Color = Color.Gray;
            catTitle.PortionFormat.FontHeight = 20;
            catTitle.PortionFormat.FontBold   = NullableBool.True;
            catTitle.PortionFormat.FontItalic = NullableBool.True;

            //Setting category axis lable position
            chart.Axes.HorizontalAxis.TickLabelPosition = TickLabelPositionType.Low;

            //Setting category axis lable rotation angle
            chart.Axes.HorizontalAxis.TickLabelRotationAngle = 45;

            //Setting Legends Text Properties
            IChartPortionFormat txtleg = chart.Legend.TextFormat.PortionFormat;

            txtleg.FontBold                        = NullableBool.True;
            txtleg.FontHeight                      = 16;
            txtleg.FontItalic                      = NullableBool.True;
            txtleg.FillFormat.FillType             = FillType.Solid;;
            txtleg.FillFormat.SolidFillColor.Color = Color.DarkRed;

            //Set show chart legends without overlapping chart

            chart.Legend.Overlay = true;

            //Ploting first series on secondary value axis
            //chart.ChartData.Series[0].PlotOnSecondAxis = true;

            //Setting chart back wall color
            chart.BackWall.Thickness                        = 1;
            chart.BackWall.Format.Fill.FillType             = FillType.Solid;
            chart.BackWall.Format.Fill.SolidFillColor.Color = Color.Orange;

            chart.Floor.Format.Fill.FillType             = FillType.Solid;
            chart.Floor.Format.Fill.SolidFillColor.Color = Color.Red;
            //Setting Plot area color
            chart.PlotArea.Format.Fill.FillType             = FillType.Solid;
            chart.PlotArea.Format.Fill.SolidFillColor.Color = Color.LightCyan;

            //Save Presentation
            pres.Save(dataDir + "FormattedChart.pptx", SaveFormat.Pptx);
        }
예제 #13
0
        public static void ProcessGame(string userInput, ref int[,] matrix, IChart chart, ref int userMoves)
        {
            if (userInput == null || userInput == string.Empty
                || matrix == null || chart == null)
            {
                throw new ArgumentNullException("Input is null or with with empty value.");
            }

            switch (userInput)
            {
                case "RESTART":
                    matrix = GenerateBoard();
                    PrintBoard(matrix);
                    userMoves = 0;
                    break;

                case "TOP":
                    chart.PrintChart();
                    break;

                case "EXIT":
                    Console.WriteLine("Good Bye!");
                    break;

                default:
                    ValidateInput(userInput, matrix);
                    userMoves++;

                    bool baloonExists = CheckForBaloon(userInput, matrix);
                    if (baloonExists)
                    {
                        PopBaloons(userInput, ref matrix);
                    }
                    else
                    {
                        Console.WriteLine("Cannot pop missing ballon!");
                    }

                    bool allBaloonsArePoped = CheckForGameOver(matrix);
                    if (allBaloonsArePoped)
                    {
                        Console.WriteLine("Gratz! You completed it in {0} moves.", userMoves);

                        bool isForChart = chart.GoodEnoughForChart(userMoves);
                        if (isForChart)
                        {
                            chart.AddToChart(userMoves);
                            chart.SortChart();
                            chart.PrintChart();
                        }
                        else
                        {
                            Console.WriteLine("I am sorry you are not skillful enough for TopFive chart!");
                        }

                        matrix = GenerateBoard();
                        userMoves = 0;
                    }

                    PrintBoard(matrix);
                    break;
            }
        }
예제 #14
0
 public void SetOriginTextFor(string simulationName, IChart chart)
 {
     chart.SetOriginTextFor(_projectRetriever.CurrentProject.Name, simulationName);
 }
예제 #15
0
파일: Column.cs 프로젝트: zxscn/ReoGrid
 /// <summary>
 /// Create column line chart legend.
 /// </summary>
 /// <param name="chart">Parent chart component.</param>
 internal ColumnLineChartLegend(IChart chart)
     : base(chart)
 {
 }
예제 #16
0
 private void SetIsChartEnabled(IChart chart, bool started)
 {
     this.GuiAsync(() => chart.IsAutoRange = started);
 }
        //
        // GET: /ChartWorksheet/

        public ActionResult ChartWorksheet(string Saveoption)
        {
            if (Saveoption == null)
            {
                return(View());
            }

            //New instance of XlsIO is created.[Equivalent to launching Microsoft Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine.
            ExcelEngine excelEngine = new ExcelEngine();
            //Step 2 : Instantiate the excel application object.
            IApplication application = excelEngine.Excel;

            // Default version is set as Excel 2007
            if (Saveoption == "Xls")
            {
                application.DefaultVersion = ExcelVersion.Excel97to2003;
            }
            else
            {
                application.DefaultVersion = ExcelVersion.Excel2016;
            }

            //A new workbook is created.[Equivalent to creating a new workbook in Microsoft Excel]
            //The new workbook will have 1 worksheet.
            IWorkbook workbook = application.Workbooks.Create(1);
            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];

            // Entering the Datas for the chart
            sheet.Range["A1"].Text = "Crescent City, CA";
            sheet.Range["A1:D1"].Merge();
            sheet.Range["A1"].CellStyle.Font.Bold = true;

            sheet.Range["B3"].Text = "Precipitation,in.";
            sheet.Range["C3"].Text = "Temperature,deg.F";

            sheet.Range["A4"].Text  = "Jan";
            sheet.Range["A5"].Text  = "Feb";
            sheet.Range["A6"].Text  = "March";
            sheet.Range["A7"].Text  = "Apr";
            sheet.Range["A8"].Text  = "May";
            sheet.Range["A9"].Text  = "June";
            sheet.Range["A10"].Text = "July";
            sheet.Range["A11"].Text = "Aug";
            sheet.Range["A12"].Text = "Sept";
            sheet.Range["A13"].Text = "Oct";
            sheet.Range["A14"].Text = "Nov";
            sheet.Range["A15"].Text = "Dec";

            sheet.Range["B4"].Number  = 10.9;
            sheet.Range["B5"].Number  = 8.9;
            sheet.Range["B6"].Number  = 8.6;
            sheet.Range["B7"].Number  = 4.8;
            sheet.Range["B8"].Number  = 3.2;
            sheet.Range["B9"].Number  = 1.4;
            sheet.Range["B10"].Number = 0.6;
            sheet.Range["B11"].Number = 0.7;
            sheet.Range["B12"].Number = 1.7;
            sheet.Range["B13"].Number = 5.4;
            sheet.Range["B14"].Number = 9.0;
            sheet.Range["B15"].Number = 10.4;

            sheet.Range["C4"].Number  = 47.5;
            sheet.Range["C5"].Number  = 48.7;
            sheet.Range["C6"].Number  = 48.9;
            sheet.Range["C7"].Number  = 50.2;
            sheet.Range["C8"].Number  = 53.1;
            sheet.Range["C9"].Number  = 56.3;
            sheet.Range["C10"].Number = 58.1;
            sheet.Range["C11"].Number = 59.0;
            sheet.Range["C12"].Number = 58.5;
            sheet.Range["C13"].Number = 55.4;
            sheet.Range["C14"].Number = 51.1;
            sheet.Range["C15"].Number = 47.8;
            sheet.UsedRange.AutofitColumns();

            // Adding a New chart to the Existing Worksheet
            IChart chart = workbook.Charts.Add();

            chart.DataRange      = sheet.Range["A3:C15"];
            chart.Name           = "CrescentCity,CA";
            chart.ChartTitle     = "Crescent City, CA";
            chart.IsSeriesInRows = false;

            chart.PrimaryValueAxis.Title = "Precipitation,in.";
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;
            chart.PrimaryValueAxis.MaximumValue = 14.0;
            chart.PrimaryValueAxis.NumberFormat = "0.0";

            // Format serie
            IChartSerie serieOne = chart.Series[0];

            serieOne.Name = "Precipitation,in.";
            serieOne.SerieFormat.Fill.FillType = ExcelFillType.Gradient;
            serieOne.SerieFormat.Fill.TwoColorGradient(ExcelGradientStyle.Vertical, ExcelGradientVariants.ShadingVariants_2);
            serieOne.SerieFormat.Fill.GradientColorType = ExcelGradientColor.TwoColor;
            serieOne.SerieFormat.Fill.ForeColor         = Color.Plum;

            //Show value as data labels
            serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue  = true;
            serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;

            //Format the second serie
            IChartSerie serieTwo = chart.Series[1];

            serieTwo.SerieType = ExcelChartType.Line_Markers;
            serieTwo.Name      = "Temperature,deg.F";

            //Format marker
            serieTwo.SerieFormat.MarkerStyle              = ExcelChartMarkerType.Diamond;
            serieTwo.SerieFormat.MarkerSize               = 8;
            serieTwo.SerieFormat.MarkerBackgroundColor    = Color.DarkGreen;
            serieTwo.SerieFormat.MarkerForegroundColor    = Color.DarkGreen;
            serieTwo.SerieFormat.LineProperties.LineColor = Color.DarkGreen;

            //Use Secondary Axis
            serieTwo.UsePrimaryAxis = false;

            //Display secondary axis for the series.
            chart.SecondaryCategoryAxis.IsMaxCross = true;
            chart.SecondaryValueAxis.IsMaxCross    = true;

            //Set the title
            chart.SecondaryValueAxis.Title = "Temperature,deg.F";
            chart.SecondaryValueAxis.TitleArea.TextRotationAngle = 90;

            //Hide the secondary category axis
            chart.SecondaryCategoryAxis.Border.LineColor  = Color.Transparent;
            chart.SecondaryCategoryAxis.MajorTickMark     = ExcelTickMark.TickMark_None;
            chart.SecondaryCategoryAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_None;

            chart.Legend.Position         = ExcelLegendPosition.Bottom;
            chart.Legend.IsVerticalLegend = false;

            sheet.Move(1);
            chart.Activate();

            try
            {
                //Saving the workbook to disk.
                if (Saveoption == "Xls")
                {
                    return(excelEngine.SaveAsActionResult(workbook, "Chart.xls", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel97));
                }
                else
                {
                    return(excelEngine.SaveAsActionResult(workbook, "Chart.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016));
                }
            }
            catch (Exception)
            {
            }
            workbook.Close();
            excelEngine.Dispose();
            return(View());
        }
예제 #18
0
        private static void ComputeRange(ChartArea chartArea, IChart iChart, string Axis)
        {
            var    values = from s in chartArea.Series select s.Data;
            double min    = double.MaxValue;
            double max    = double.MinValue;

            foreach (var v in values)
            {
                for (int i = 0; i < v.Count; i++)
                {
                    if (v[i].Y < min)
                    {
                        min = v[i].Y;
                    }

                    if (v[i].Y > max)
                    {
                        max = v[i].Y;
                    }
                }
            }
            #region Range calculation for secondary Axis

            if (Axis == "SecondaryValueAxis")
            {
                if (!iChart.SecondaryValueAxis.IsAutoMajor)
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max + iChart.SecondaryValueAxis.MajorUnit);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min - iChart.SecondaryValueAxis.MajorUnit, max + iChart.SecondaryValueAxis.MajorUnit);
                    }
                }
                else
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min, max);
                    }
                }
            }
            #endregion

            #region Range Calculation for Primary Horizontal Axis
            else if (Axis == "CategoryAxis")
            {
                foreach (var v in values)
                {
                    for (int i = 0; i < v.Count; i++)
                    {
                        if (v[i].X < min)
                        {
                            min = v[i].X;
                        }

                        if (v[i].X > max)
                        {
                            max = v[i].X;
                        }
                    }
                }
                if (!iChart.PrimaryCategoryAxis.IsAutoMajor)
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(0, max + iChart.PrimaryCategoryAxis.MajorUnit);
                    }
                    else
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(min - iChart.PrimaryCategoryAxis.MajorUnit, max + iChart.PrimaryCategoryAxis.MajorUnit);
                    }
                }
                else
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(0, max);
                    }
                    else
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(min, max);
                    }
                }
            }
            #endregion

            #region Range Calculation for Primary Vertical Axis
            else
            {
                if (!iChart.PrimaryValueAxis.IsAutoMajor)
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max + iChart.PrimaryValueAxis.MajorUnit);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min - iChart.PrimaryValueAxis.MajorUnit, max + iChart.PrimaryValueAxis.MajorUnit);
                    }
                }
                else
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min, max);
                    }
                }
            }

            #endregion
        }
예제 #19
0
        private static void CreateChartSeries(ChartArea chartArea, IChart iChart)
        {
            ChartAxis commonaxis = new ChartAxis()
            {
                Orientation = Orientation.Vertical, OpposedPosition = true
            };

            chartArea.Axes.Add(commonaxis);
            for (int count = 0; count < iChart.Series.Count; count++)
            {
                IChartSerie XlsIOChartSerie = iChart.Series[count];
                ChartSeries UIChartSeries   = new ChartSeries()
                {
                    ShowEmptyPoints = false
                };
                SetSerieType(UIChartSeries, XlsIOChartSerie);
                DataTable ct = new DataTable();
                DataTable vt = new DataTable();
                if (XlsIOChartSerie.CategoryLabels != null)
                {
                    ct = XlsIOChartSerie.CategoryLabels.Worksheet.ExportDataTable(XlsIOChartSerie.CategoryLabels, ExcelExportDataTableOptions.ComputedFormulaValues);
                    vt = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.Values, ExcelExportDataTableOptions.ComputedFormulaValues);
                }
                else if (XlsIOChartSerie.NameRange != null)
                {
                    ct = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.NameRange, ExcelExportDataTableOptions.ComputedFormulaValues);
                    vt = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.Values, ExcelExportDataTableOptions.ComputedFormulaValues);
                }
                else if (iChart.DataRange != null)
                {
                    ct = XlsIOChartSerie.Values.Worksheet.ExportDataTable(iChart.DataRange, ExcelExportDataTableOptions.ComputedFormulaValues);
                    vt = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.Values, ExcelExportDataTableOptions.ComputedFormulaValues);
                }

                List <ChartDataPoint> data = ConvertDataTableToDataPoints(ct, vt, iChart.IsSeriesInRows);
                UIChartSeries.DataSource    = data;
                UIChartSeries.BindingPathX  = "X";
                UIChartSeries.BindingPathsY = new List <string> {
                    "Y"
                };
                UIChartSeries.Label           = XlsIOChartSerie.Name;
                UIChartSeries.Resolution      = 5;
                UIChartSeries.UseOptimization = true;
                UIChartSeries.ShowSmartLabels = false;

                #region Pie Chart
                if (UIChartSeries.Type == ChartTypes.Pie)
                {
                    System.Drawing.Color serieborder = new System.Drawing.Color();
                    System.Drawing.Color seriecolor  = new System.Drawing.Color();
                    UIChartSeries.ColorEach = true;
                    UIChartSeries.Palette   = ChartColorPalette.Custom;
                    Brush[] brushes = new Brush[iChart.Workbook.Palette.Length];
                    if (iChart.ChartType == ExcelChartType.Pie_3D)
                    {
                        int i = 0;
                        foreach (Syncfusion.XlsIO.IChartDataPoint dataPoint in XlsIOChartSerie.DataPoints)
                        {
                            if (dataPoint.DataFormat.HasInterior && !dataPoint.DataFormat.Interior.UseAutomaticFormat)
                            {
                                seriecolor = dataPoint.DataFormat.Interior.ForegroundColor;
                                brushes[i] = new SolidColorBrush(Color.FromRgb(seriecolor.R, seriecolor.G, seriecolor.B));
                                i++;
                                UIChartSeries.CustomPalette = brushes;
                            }
                        }
                    }
                    else
                    {
                        serieborder = XlsIOChartSerie.SerieFormat.LineProperties.LineColor;
                        if (XlsIOChartSerie.SerieFormat.AreaProperties.UseAutomaticFormat == false)
                        {
                            seriecolor = XlsIOChartSerie.SerieFormat.Fill.ForeColor;
                        }
                        UIChartSeries.Interior = new SolidColorBrush(Color.FromRgb(seriecolor.R, seriecolor.G, seriecolor.B));
                    }
                    if (XlsIOChartSerie.SerieFormat.HasLineProperties)
                    {
                        UIChartSeries.StrokeThickness = GetLineWidth(XlsIOChartSerie.SerieFormat.LineProperties.LineWeight);
                    }
                    else
                    {
                        UIChartSeries.StrokeThickness = 0;
                    }
                }
                #endregion

                #region Line and Scatter Chart
                else if (UIChartSeries.Type == ChartTypes.Line || UIChartSeries.Type == ChartTypes.Scatter || UIChartSeries.Type == ChartTypes.FastScatter)
                {
                    if (UIChartSeries.Type == ChartTypes.Scatter || UIChartSeries.Type == ChartTypes.FastScatter)
                    {
                        UIChartSeries.BindingPathX = "XDouble";
                    }

                    if (XlsIOChartSerie.SerieFormat.IsMarkerSupported)
                    {
                        if (!XlsIOChartSerie.SerieFormat.IsAutoMarker)
                        {
                            System.Drawing.Color markercolor = XlsIOChartSerie.SerieFormat.MarkerBackgroundColor;
                            UIChartSeries.Interior = new SolidColorBrush(Color.FromRgb(markercolor.R, markercolor.G, markercolor.B));
                            UIChartSeries.Stroke   = new SolidColorBrush(Color.FromRgb(markercolor.R, markercolor.G, markercolor.B));
                        }
                    }

                    if (!XlsIOChartSerie.SerieFormat.LineProperties.IsAutoLineColor)
                    {
                        System.Drawing.Color lineColor = XlsIOChartSerie.SerieFormat.LineProperties.LineColor;
                        UIChartSeries.Stroke = new SolidColorBrush(Color.FromRgb(lineColor.R, lineColor.G, lineColor.B));
                    }
                    UIChartSeries.ColorEach       = false;
                    UIChartSeries.LegendIcon      = ChartLegendIcon.HorizontalLine;
                    UIChartSeries.StrokeThickness = GetLineWidth(XlsIOChartSerie.SerieFormat.LineProperties.LineWeight) + 1;
                }
                #endregion

                #region Other Charts
                else
                {
                    UIChartSeries.ColorEach = false;
                    System.Drawing.Color fcolor;
                    if (XlsIOChartSerie.SerieFormat.AreaProperties != null)
                    {
                        if (XlsIOChartSerie.SerieFormat.AreaProperties.UseAutomaticFormat == false)
                        {
                            fcolor = XlsIOChartSerie.SerieFormat.Fill.ForeColor;
                            Color fclr = Color.FromRgb(fcolor.R, fcolor.G, fcolor.B);
                            UIChartSeries.Interior  = new SolidColorBrush(fclr);
                            UIChartSeries.ColorEach = false;
                        }
                    }
                }
                #endregion

                CreateDataLabels(UIChartSeries, XlsIOChartSerie);
                CreateChartSecondaryAxis(UIChartSeries, XlsIOChartSerie, chartArea, iChart);
                chartArea.Series.Add(UIChartSeries);
            }

            System.Drawing.Color areaColor = iChart.ChartArea.Fill.ForeColor;
            chartArea.Background = new SolidColorBrush(Color.FromRgb(areaColor.R, areaColor.G, areaColor.B));
            if (!iChart.PlotArea.Interior.UseAutomaticFormat)
            {
                System.Drawing.Color plotColor = iChart.PlotArea.Fill.ForeColor;
                chartArea.GridBackground = new SolidColorBrush(Color.FromRgb(plotColor.R, plotColor.G, plotColor.B));
            }
            CreateChartTitle(chartArea, iChart);
            CreateChartLegend(chartArea, iChart);
            CreateChartPrimaryAxis(chartArea, iChart);
        }
예제 #20
0
        private static void CreateChartSecondaryAxis(ChartSeries UIChartSeries, IChartSerie XlsIOChartSerie, ChartArea chartArea, IChart iChart)
        {
            ///Secondary Axis Implementation
            if (!XlsIOChartSerie.UsePrimaryAxis)
            {
                SecondaryAxisflag = true;
                ///Secondary Horizontal Axis Implementation
                #region  Secondary Horizontal Axis
                if (iChart.SecondaryCategoryAxis.Visible)
                {
                    UIChartSeries.XAxis                  = chartArea.Axes[2];
                    UIChartSeries.XAxis.Header           = iChart.SecondaryCategoryAxis.Title;
                    UIChartSeries.XAxis.LabelFontFamily  = new FontFamily(iChart.SecondaryCategoryAxis.Font.FontName);
                    UIChartSeries.XAxis.LabelFontSize    = iChart.SecondaryCategoryAxis.Font.Size;
                    UIChartSeries.XAxis.LabelRotateAngle = iChart.SecondaryCategoryAxis.TextRotationAngle;

                    if (!iChart.SecondaryCategoryAxis.HasMajorGridLines && !iChart.SecondaryCategoryAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(UIChartSeries.XAxis, false);
                    }

                    if (!iChart.SecondaryCategoryAxis.AutoTickLabelSpacing)
                    {
                        UIChartSeries.XAxis.IsAutoSetRange = false;
                        if (iChart.SecondaryCategoryAxis.CategoryLabels != null && iChart.SecondaryCategoryAxis.CategoryLabels.HasDateTime)
                        {
                            UIChartSeries.XAxis.ValueType        = ChartValueType.DateTime;
                            UIChartSeries.XAxis.DateTimeInterval = TimeSpan.FromDays(iChart.SecondaryCategoryAxis.TickLabelSpacing);
                            string format = iChart.SecondaryCategoryAxis.NumberFormat;
                            format = format.Replace("m", "M");
                            UIChartSeries.XAxis.LabelDateTimeFormat = format;
                            UIChartSeries.XAxis.IsAutoSetRange      = true;
                        }
                        else if (iChart.SecondaryCategoryAxis.CategoryLabels != null && iChart.SecondaryCategoryAxis.CategoryLabels.HasNumber)
                        {
                            UIChartSeries.XAxis.ValueType = ChartValueType.Double;
                            UIChartSeries.XAxis.Interval  = iChart.SecondaryCategoryAxis.TickLabelSpacing;
                            UIChartSeries.XAxis.Range     = new DoubleRange(iChart.SecondaryCategoryAxis.MinimumValue, iChart.SecondaryCategoryAxis.MaximumValue);
                        }
                        else
                        {
                            UIChartSeries.XAxis.Interval = iChart.SecondaryCategoryAxis.TickLabelSpacing;
                        }
                    }
                    else
                    {
                        try
                        {
                            if (iChart.SecondaryCategoryAxis.CategoryLabels != null && iChart.SecondaryCategoryAxis.CategoryLabels.HasNumber)
                            {
                                chartArea.PrimaryAxis.ValueType = ChartValueType.Double;
                                foreach (var ser in chartArea.Series)
                                {
                                    ser.Data.ChartXValueType = ChartValueType.Double;
                                }
                                UIChartSeries.XAxis.Interval = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                            }
                        }
                        catch
                        {
                            UIChartSeries.XAxis.IsAutoSetRange = true;
                        }
                    }
                }
                #endregion

                ///Secondary Vertical axis Implementation
                #region Secondary Vertical axis

                if (iChart.SecondaryValueAxis.Visible)
                {
                    UIChartSeries.YAxis = chartArea.Axes[2];
                    if (!iChart.SecondaryValueAxis.HasMajorGridLines && !iChart.SecondaryValueAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(UIChartSeries.YAxis, false);
                    }
                    try { UIChartSeries.YAxis.Header = iChart.SecondaryValueAxis.Title; }
                    catch { }
                    UIChartSeries.YAxis.LabelFontFamily  = new FontFamily(iChart.SecondaryValueAxis.Font.FontName);
                    UIChartSeries.YAxis.LabelFontSize    = iChart.SecondaryValueAxis.Font.Size;
                    UIChartSeries.YAxis.LabelFontWeight  = iChart.PrimaryValueAxis.Font.Bold ? FontWeights.Bold : FontWeights.Normal;
                    UIChartSeries.YAxis.LabelRotateAngle = iChart.SecondaryValueAxis.TextRotationAngle;


                    if (iChart.SecondaryValueAxis.MinimumValue == 0 && iChart.SecondaryValueAxis.MaximumValue == 0)
                    {
                        ComputeRange(chartArea, iChart, "SecondaryValueAxis");
                    }
                    else
                    {
                        UIChartSeries.YAxis.IsAutoSetRange = false;
                        DoubleRange doubleRange = new DoubleRange(iChart.SecondaryValueAxis.MinimumValue, iChart.SecondaryValueAxis.MaximumValue);
                        UIChartSeries.YAxis.Range    = doubleRange;
                        UIChartSeries.YAxis.Interval = iChart.SecondaryValueAxis.MajorUnit;
                    }
                }
                else
                {
                    UIChartSeries.YAxis.AxisVisibility = Visibility.Hidden;
                }
                #endregion
            }
            else if (chartArea.Axes.Count > 2 && !SecondaryAxisflag)
            {
                chartArea.Axes.RemoveAt(2);
            }
        }
예제 #21
0
        private static void CreateChartPrimaryAxis(ChartArea chartArea, IChart iChart)
        {
            if (chartArea.Series[0].Type != ChartTypes.Bar && chartArea.Series[0].Type != ChartTypes.StackingBar && chartArea.Series[0].Type != ChartTypes.StackingBar100)
            {
                #region Primary Horizontal Axis Implementation.
                if (iChart.PrimaryCategoryAxis.Visible)
                {
                    chartArea.PrimaryAxis.Header           = iChart.PrimaryCategoryAxis.Title;
                    chartArea.PrimaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryCategoryAxis.Font.FontName);
                    chartArea.PrimaryAxis.LabelFontSize    = iChart.PrimaryCategoryAxis.Font.Size;
                    chartArea.PrimaryAxis.LabelRotateAngle = iChart.PrimaryCategoryAxis.TextRotationAngle;

                    if (!iChart.PrimaryCategoryAxis.HasMajorGridLines && !iChart.PrimaryCategoryAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.PrimaryAxis, false);
                    }

                    ///In excel Primary X and Primary Y axis will be Value axis for Scatter Charts.
                    ///For others Primary and secondary X axis is category axis
                    /// and Primary and secondary Y axis is value axis. It will work vice versily for Bar chart
                    if (chartArea.Series[0].Type == ChartTypes.Scatter || chartArea.Series[0].Type == ChartTypes.FastScatter)
                    {
                        chartArea.PrimaryAxis.IsAutoSetRange = false;
                        chartArea.PrimaryAxis.ValueType      = ChartValueType.Double;
                        if (iChart.PrimaryCategoryAxis.MinimumValue == 0 && iChart.PrimaryCategoryAxis.MaximumValue == 0)
                        {
                            ComputeRange(chartArea, iChart, "CategoryAxis");
                        }
                        else
                        {
                            DoubleRange doubleRange = new DoubleRange(iChart.PrimaryCategoryAxis.MinimumValue, iChart.PrimaryCategoryAxis.MaximumValue);
                            chartArea.PrimaryAxis.Range    = doubleRange;
                            chartArea.PrimaryAxis.Interval = iChart.PrimaryCategoryAxis.MajorUnit;
                        }
                    }

                    else if (!iChart.PrimaryCategoryAxis.AutoTickLabelSpacing)
                    {
                        if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasDateTime)
                        {
                            chartArea.PrimaryAxis.ValueType        = ChartValueType.DateTime;
                            chartArea.PrimaryAxis.DateTimeInterval = TimeSpan.FromDays(iChart.PrimaryCategoryAxis.TickLabelSpacing);
                            string format = iChart.PrimaryCategoryAxis.NumberFormat;
                            format = format.Replace("m", "M");
                            chartArea.PrimaryAxis.LabelDateTimeFormat = format;
                            chartArea.PrimaryAxis.IsAutoSetRange      = true;
                        }
                        else if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasNumber)
                        {
                            chartArea.PrimaryAxis.ValueType = ChartValueType.Double;
                            chartArea.PrimaryAxis.Interval  = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                        else
                        {
                            chartArea.PrimaryAxis.Interval = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                    }
                }
                else
                {
                    chartArea.PrimaryAxis.AxisVisibility = Visibility.Hidden;
                }
                #endregion

                #region Primary Vertical Axis Implementation
                if (iChart.PrimaryValueAxis.Visible)
                {
                    chartArea.SecondaryAxis.IsAutoSetRange   = false;
                    chartArea.SecondaryAxis.Header           = iChart.PrimaryValueAxis.Title;
                    chartArea.SecondaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryValueAxis.Font.FontName);
                    chartArea.SecondaryAxis.LabelFontSize    = iChart.PrimaryValueAxis.Font.Size;
                    chartArea.SecondaryAxis.LabelRotateAngle = iChart.PrimaryValueAxis.TextRotationAngle;

                    if (!iChart.PrimaryValueAxis.HasMajorGridLines && !iChart.PrimaryValueAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.PrimaryAxis, false);
                    }

                    if (iChart.PrimaryValueAxis.MinimumValue == 0 && iChart.PrimaryValueAxis.MaximumValue == 0)
                    {
                        ComputeRange(chartArea, iChart, "ValueAxis");
                    }
                    else
                    {
                        DoubleRange doubleRange = new DoubleRange(iChart.PrimaryValueAxis.MinimumValue, iChart.PrimaryValueAxis.MaximumValue);
                        chartArea.SecondaryAxis.Range    = doubleRange;
                        chartArea.SecondaryAxis.Interval = iChart.PrimaryValueAxis.MajorUnit;
                    }
                }
                else
                {
                    chartArea.SecondaryAxis.AxisVisibility = Visibility.Hidden;
                }
                #endregion
            }
            #region Axis Implementation for Bar Chart
            else
            {
                //Axis Implementation for Bar Type Chart, because it differs from all Chart.
                //PrimaryAxis Code for BarChart.
                if (iChart.PrimaryValueAxis.Visible)
                {
                    chartArea.PrimaryAxis.Header           = iChart.PrimaryValueAxis.Title;
                    chartArea.PrimaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryValueAxis.Font.FontName);
                    chartArea.PrimaryAxis.LabelFontSize    = iChart.PrimaryValueAxis.Font.Size;
                    chartArea.PrimaryAxis.LabelRotateAngle = iChart.PrimaryValueAxis.TextRotationAngle;
                    chartArea.PrimaryAxis.IsAutoSetRange   = false;

                    if (!iChart.PrimaryValueAxis.HasMajorGridLines && !iChart.PrimaryValueAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.PrimaryAxis, false);
                    }

                    if (iChart.PrimaryValueAxis.MinimumValue == 0 && iChart.PrimaryValueAxis.MaximumValue == 0)
                    {
                        chartArea.PrimaryAxis.IsAutoSetRange = false;
                    }
                    else
                    {
                        DoubleRange doubleRange = new DoubleRange(iChart.PrimaryValueAxis.MinimumValue, iChart.PrimaryValueAxis.MaximumValue);
                        chartArea.PrimaryAxis.Range    = doubleRange;
                        chartArea.PrimaryAxis.Interval = iChart.PrimaryValueAxis.MajorUnit;
                    }
                }
                else
                {
                    chartArea.PrimaryAxis.AxisVisibility = Visibility.Hidden;
                }

                //Secondary Axis code for BarChart.
                if (iChart.PrimaryCategoryAxis.Visible)
                {
                    if (!iChart.PrimaryCategoryAxis.HasMajorGridLines && !iChart.PrimaryCategoryAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.SecondaryAxis, false);
                    }

                    if (!iChart.PrimaryCategoryAxis.AutoTickLabelSpacing)
                    {
                        chartArea.SecondaryAxis.Header           = iChart.PrimaryCategoryAxis.Title;
                        chartArea.SecondaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryCategoryAxis.Font.FontName);
                        chartArea.SecondaryAxis.LabelFontSize    = iChart.PrimaryCategoryAxis.Font.Size;
                        chartArea.SecondaryAxis.LabelRotateAngle = iChart.PrimaryCategoryAxis.TextRotationAngle;

                        if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasDateTime)
                        {
                            chartArea.SecondaryAxis.ValueType        = ChartValueType.DateTime;
                            chartArea.SecondaryAxis.DateTimeInterval = TimeSpan.FromDays(iChart.PrimaryCategoryAxis.TickLabelSpacing);
                            chartArea.SecondaryAxis.LabelFormat      = iChart.PrimaryCategoryAxis.CategoryLabels.NumberFormat;
                        }
                        else if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasNumber)
                        {
                            chartArea.SecondaryAxis.ValueType = ChartValueType.Double;
                            chartArea.SecondaryAxis.Interval  = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                        else
                        {
                            chartArea.SecondaryAxis.Interval = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                    }
                }
                else
                {
                    chartArea.SecondaryAxis.AxisVisibility = Visibility.Hidden;
                }
            }


            #endregion
        }
예제 #22
0
        private static void CreateChartLegend(ChartArea chartArea, IChart iChart)
        {
            if (iChart.HasLegend)
            {
                ChartLegend cl = new ChartLegend();

                if (iChart.Series[0].SerieType == ExcelChartType.Pie || iChart.Series[0].SerieType == ExcelChartType.Pie_3D || iChart.Series[0].SerieType == ExcelChartType.Doughnut || iChart.Series[0].SerieType == ExcelChartType.Doughnut_Exploded)
                {
                    cl.ItemTemplate = pielegendtemplate;
                }

                if (iChart.Legend.TextArea != null)
                {
                    cl.FontFamily = new System.Windows.Media.FontFamily(iChart.Legend.TextArea.FontName);
                    cl.FontSize   = iChart.Legend.TextArea.Size;
                    cl.FontStyle  = iChart.Legend.TextArea.Italic ? FontStyles.Italic : FontStyles.Normal;
                    cl.FontWeight = iChart.Legend.TextArea.Bold ? FontWeights.Bold : FontWeights.Normal;

                    if (iChart.Legend.FrameFormat.HasLineProperties && !iChart.Legend.FrameFormat.Border.AutoFormat && iChart.Legend.FrameFormat.Border.LinePattern != ExcelChartLinePattern.None)
                    {
                        cl.BorderThickness = new Thickness(GetLineWidth(iChart.Legend.FrameFormat.LineProperties.LineWeight));
                    }
                    else
                    {
                        cl.BorderThickness = new Thickness(0);
                    }

                    System.Drawing.Color lineColor = iChart.Legend.FrameFormat.Border.LineColor;
                    Color borderColor = Color.FromRgb(lineColor.R, lineColor.G, lineColor.B);

                    if (iChart.Legend.FrameFormat.Border.Transparency != 1.0)
                    {
                        cl.BorderBrush = new SolidColorBrush(borderColor);
                    }
                    else
                    {
                        cl.BorderBrush = null;
                    }

                    if (iChart.Legend.TextArea.BackgroundMode != ExcelChartBackgroundMode.Transparent)
                    {
                        System.Drawing.Color xlBackColor = iChart.Legend.TextArea.FrameFormat.Fill.BackColor;
                        Color backColor = Color.FromArgb(xlBackColor.A, xlBackColor.R, xlBackColor.G, xlBackColor.B);
                        cl.Background = new SolidColorBrush(backColor);
                    }
                    else
                    {
                        cl.Background = Brushes.Transparent;
                    }

                    System.Drawing.Color xlForeColor = iChart.Legend.TextArea.RGBColor;
                    Color foreColor = Color.FromRgb(xlForeColor.R, xlForeColor.G, xlForeColor.B);
                    cl.Foreground = new SolidColorBrush(foreColor);
                }

                chartArea.Legend = cl;
                switch (iChart.Legend.Position)
                {
                case ExcelLegendPosition.Bottom:
                    Chart.SetDock(cl, ChartDock.Bottom);
                    break;

                case ExcelLegendPosition.Corner:
                    Chart.SetDock(cl, ChartDock.Floating);
                    break;

                case ExcelLegendPosition.Left:
                    Chart.SetDock(cl, ChartDock.Left);
                    break;

                case ExcelLegendPosition.NotDocked:
                    Chart.SetDock(cl, ChartDock.Floating);
                    break;

                case ExcelLegendPosition.Right:
                    Chart.SetDock(cl, ChartDock.Right);
                    break;

                case ExcelLegendPosition.Top:
                    Chart.SetDock(cl, ChartDock.Top);
                    break;

                default:
                    Chart.SetDock(cl, ChartDock.Right);
                    break;
                }
            }
        }
예제 #23
0
        /// <summary>
        /// 재고기준 차트 내용 select
        /// </summary>
        /// <param name="InventoryName">재고기준 : 하티,화이트,칩,치즈 등등</param>
        /// <param name="chart">시작, 종료</param>
        /// <param name="monthYear">월인지 년인지 선택</param>
        /// <returns></returns>
        internal List <InventoryTypeSalesVO> InventorySalesSelect(string InventoryName, IChart chart, bool monthYear)
        {
            lst = new List <InventoryTypeSalesVO>();

            SqlParameter[] sqlParameters = new SqlParameter[4];
            sqlParameters[0] = new SqlParameter("InventoryName", InventoryName);
            sqlParameters[1] = new SqlParameter("StartDate", ((InventoryChart)chart).StartDate);
            sqlParameters[2] = new SqlParameter("EndDate", ((InventoryChart)chart).EndDate);
            sqlParameters[3] = new SqlParameter("MonthYear", (monthYear)?0:1);
            SqlDataReader dr = new DBConnection().Select("SelectInventorySalesChart", sqlParameters);

            while (dr.Read())
            {
                InventoryTypeSalesVO inventoryTypeSalesVO = new InventoryTypeSalesVO();
                inventoryTypeSalesVO.XAxis        = dr["DateOfUse"].ToString();
                inventoryTypeSalesVO.UseInventory = (float)Math.Round((float.Parse(dr["InventoryQuantity"].ToString()) / 1000), 2);
                lst.Add(inventoryTypeSalesVO);
            }
            return(lst);
        }
예제 #24
0
        public static void Run()
        {
            //ExStart:AddDoughnutCallout
            string             dataDir  = RunExamples.GetDataDir_Charts();
            Presentation       pres     = new Presentation(dataDir + "testc.pptx");
            ISlide             slide    = pres.Slides[0];
            IChart             chart    = slide.Shapes.AddChart(ChartType.Doughnut, 10, 10, 500, 500, false);
            IChartDataWorkbook workBook = chart.ChartData.ChartDataWorkbook;

            chart.ChartData.Series.Clear();
            chart.ChartData.Categories.Clear();
            chart.HasLegend = false;
            int seriesIndex = 0;

            while (seriesIndex < 15)
            {
                IChartSeries series = chart.ChartData.Series.Add(workBook.GetCell(0, 0, seriesIndex + 1, "SERIES " + seriesIndex), chart.Type);
                series.Explosion = 0;
                series.ParentSeriesGroup.DoughnutHoleSize = (byte)20;
                series.ParentSeriesGroup.FirstSliceAngle  = 351;
                seriesIndex++;
            }
            int categoryIndex = 0;

            while (categoryIndex < 15)
            {
                chart.ChartData.Categories.Add(workBook.GetCell(0, categoryIndex + 1, 0, "CATEGORY " + categoryIndex));
                int i = 0;
                while (i < chart.ChartData.Series.Count)
                {
                    IChartSeries    iCS       = chart.ChartData.Series[i];
                    IChartDataPoint dataPoint = iCS.DataPoints.AddDataPointForDoughnutSeries(workBook.GetCell(0, categoryIndex + 1, i + 1, 1));
                    dataPoint.Format.Fill.FillType                        = FillType.Solid;
                    dataPoint.Format.Line.FillFormat.FillType             = FillType.Solid;
                    dataPoint.Format.Line.FillFormat.SolidFillColor.Color = Color.White;
                    dataPoint.Format.Line.Width     = 1;
                    dataPoint.Format.Line.Style     = LineStyle.Single;
                    dataPoint.Format.Line.DashStyle = LineDashStyle.Solid;
                    if (i == chart.ChartData.Series.Count - 1)
                    {
                        IDataLabel lbl = dataPoint.Label;
                        lbl.TextFormat.TextBlockFormat.AutofitType                                   = TextAutofitType.Shape;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FontBold                        = NullableBool.True;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.LatinFont                       = new FontData("DINPro-Bold");
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FontHeight                      = 12;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.FillType             = FillType.Solid;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.SolidFillColor.Color = Color.LightGray;
                        lbl.DataLabelFormat.Format.Line.FillFormat.SolidFillColor.Color              = Color.White;
                        lbl.DataLabelFormat.ShowValue        = false;
                        lbl.DataLabelFormat.ShowCategoryName = true;
                        lbl.DataLabelFormat.ShowSeriesName   = false;
                        //lbl.DataLabelFormat.ShowLabelAsDataCallout = true;
                        lbl.DataLabelFormat.ShowLeaderLines        = true;
                        lbl.DataLabelFormat.ShowLabelAsDataCallout = false;
                        chart.ValidateChartLayout();
                        lbl.AsILayoutable.X = (float)lbl.AsILayoutable.X + (float)0.5;
                        lbl.AsILayoutable.Y = (float)lbl.AsILayoutable.Y + (float)0.5;
                    }
                    i++;
                }
                categoryIndex++;
            }
            pres.Save(dataDir + "chart.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DateTime MaxDate = new DateTime(2008, 1, 29);
            DateTime MinDate = new DateTime(2008, 1, 1);

            if (Calendar2.SelectedDate > MaxDate || Calendar2.SelectedDate < MinDate || Calendar1.SelectedDate < MinDate || Calendar1.SelectedDate > MaxDate)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Selected Date is not valid.Please select the date between 1st Jan 2008 and 29th Jan 2008!');", true);
            }
            else
            {
                ExcelEngine  excelEngine = new ExcelEngine();
                IApplication application = excelEngine.Excel;
                // A new workbook is created.[Equivalent to creating a new workbook in Microsoft Excel]
                // The number of default worksheets is the application setting in Microsoft Excel.
                myWorkbook = excelEngine.Excel.Workbooks.Add(XlsIOHelper.ResolveApplicationDataPath("Template.xls", Request));
                ListItem[] StockList;// = new ListItem();
                //  ArrayList[] StockList;
                int index = 0;
                foreach (ListItem lItem in CheckBoxList1.Items)
                {
                    if (lItem.Selected)
                    {
                        index++;
                    }
                }
                StockList = new ListItem[index];
                int stockItem = 0;
                foreach (ListItem lItem in CheckBoxList1.Items)
                {
                    if (lItem.Selected)
                    {
                        StockList[stockItem] = lItem;
                        stockItem++;
                    }
                }
                IChart chart = myWorkbook.Worksheets[1].Charts[0];
                chart.PrimaryCategoryAxis.NumberFormat     = "m/d/yyyy";
                chart.PrimaryValueAxis.NumberFormat        = "\"$\"#,##0.00";
                chart.SecondaryValueAxis.NumberFormat      = "\"$\"#,##0.00";
                chart.SecondaryValueAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_High;

                // Adding new worksheets in workbook's sheets collection
                for (int count = 1; count < StockList.Length; count++)
                {
                    myWorkbook.Worksheets.AddCopyAfter(myWorkbook.Worksheets[1], myWorkbook.Worksheets[0]);
                }

                // Adding hyperlinks to menu sheet
                IWorksheet menu_sheet  = myWorkbook.Worksheets[0];
                int        InsertIndex = DEF_FST_ROW_NUM_SC - 3;

                menu_sheet.HyperLinks.RemoveAt(0);
                menu_sheet.Range["G21"].Text = "";

                for (int count = 0; count < StockList.Length; count++)
                {
                    menu_sheet.InsertRow(InsertIndex, 2, ExcelInsertOptions.FormatAsBefore);
                    IHyperLink report_hyperlink = menu_sheet.HyperLinks.Add(menu_sheet.Range["G" + InsertIndex + ":I" + InsertIndex]);
                    report_hyperlink.Type          = ExcelHyperLinkType.Workbook;
                    report_hyperlink.Address       = StockList[count].Text + "!A1";
                    report_hyperlink.TextToDisplay = StockList[count].Text;

                    InsertIndex += 2;
                }

                // Creating Stock report
                int itemIndex = 1;

                foreach (Object StockListItem in StockList)
                {
                    CreateStockReport(StockListItem.ToString(), itemIndex);
                    FillAnalysisPortfolioSheet(StockListItem.ToString());
                    itemIndex += 1;
                }
                myWorkbook.Worksheets[0].Activate();
                //Saving the workbook to disk.


                if (rBtnXls.Checked == true)
                {
                    myWorkbook.Version = ExcelVersion.Excel97to2003;
                    myWorkbook.SaveAs(reportDirectory + "\\Sample.xls", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);
                }
                else
                {
                    myWorkbook.Version = ExcelVersion.Excel2016;
                    myWorkbook.SaveAs(reportDirectory + "\\Sample.xlsx", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016);
                }
                //No exception will be thrown if there are unsaved workbooks.
                excelEngine.ThrowNotSavedOnDestroy = false;
                excelEngine.Dispose();
            }
        }
예제 #26
0
        private async void btnGenerateExcel_Click(object sender, RoutedEventArgs e)
        {
            #region Setting output location
            StorageFile storageFile;
            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
            {
                FileSavePicker savePicker = new FileSavePicker();
                savePicker.SuggestedStartLocation = PickerLocationId.Desktop;
                savePicker.SuggestedFileName      = "ChartSample";
                if (rdBtn2003.IsChecked.Value)
                {
                    savePicker.FileTypeChoices.Add("Excel Files", new List <string>()
                    {
                        ".xls"
                    });
                }
                else
                {
                    savePicker.FileTypeChoices.Add("Excel Files", new List <string>()
                    {
                        ".xlsx",
                    });
                }
                storageFile = await savePicker.PickSaveFileAsync();
            }
            else
            {
                StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                if (rdBtn2003.IsChecked.Value)
                {
                    storageFile = await local.CreateFileAsync("ChartSample.xls", CreationCollisionOption.ReplaceExisting);
                }
                else
                {
                    storageFile = await local.CreateFileAsync("ChartSample.xlsx", CreationCollisionOption.ReplaceExisting);
                }
            }

            if (storageFile == null)
            {
                return;
            }
            #endregion

            #region Initializing workbook
            //Instantiate excel Engine
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            if (rdBtn2003.IsChecked.Value)
            {
                application.DefaultVersion = ExcelVersion.Excel97to2003;
            }
            else
            {
                application.DefaultVersion = ExcelVersion.Excel2013;
            }

            IWorkbook workbook;

            if (application.DefaultVersion != ExcelVersion.Excel97to2003)
            {
                Assembly assembly     = typeof(Chart).GetTypeInfo().Assembly;
                string   resourcePath = "Syncfusion.SampleBrowser.UWP.XlsIO.XlsIO.Tutorials.Samples.Assets.Resources.Templates.Sparkline.xlsx";
                Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);
                workbook = await application.Workbooks.OpenAsync(fileStream);
            }
            else
            {
                workbook = application.Workbooks.Create(1);
            }
            IWorksheet sheet = workbook.Worksheets[0];
            #endregion

//#if WINDOWS_APP
            if (application.DefaultVersion != ExcelVersion.Excel97to2003)
            {
                #region Sparklines

                #region WholeSale Report

                //A new Sparkline group is added to the sheet sparklinegroups
                ISparklineGroup sparklineGroup = sheet.SparklineGroups.Add();

                //Set the Sparkline group type as line
                sparklineGroup.SparklineType = SparklineType.Line;

                //Set to display the empty cell as line
                sparklineGroup.DisplayEmptyCellsAs = SparklineEmptyCells.Line;

                //Sparkline group style properties
                sparklineGroup.ShowFirstPoint     = true;
                sparklineGroup.FirstPointColor    = Color.FromArgb(Colors.Green.A, Colors.Green.R, Colors.Green.G, Colors.Green.B);
                sparklineGroup.ShowLastPoint      = true;
                sparklineGroup.LastPointColor     = Color.FromArgb(Colors.Orange.A, Colors.Orange.R, Colors.Orange.G, Colors.Orange.B);
                sparklineGroup.ShowHighPoint      = true;
                sparklineGroup.HighPointColor     = Color.FromArgb(Colors.Blue.A, Colors.Blue.R, Colors.Blue.G, Colors.Blue.B);
                sparklineGroup.ShowLowPoint       = true;
                sparklineGroup.LowPointColor      = Color.FromArgb(Colors.Purple.A, Colors.Purple.R, Colors.Purple.G, Colors.Purple.B);
                sparklineGroup.ShowMarkers        = true;
                sparklineGroup.MarkersColor       = Color.FromArgb(Colors.Black.A, Colors.Black.R, Colors.Black.G, Colors.Black.B);
                sparklineGroup.ShowNegativePoint  = true;
                sparklineGroup.NegativePointColor = Color.FromArgb(Colors.Red.A, Colors.Red.R, Colors.Red.G, Colors.Red.B);

                //set the line weight
                sparklineGroup.LineWeight = 0.3;

                //The sparklines are added to the sparklinegroup.
                ISparklines sparklines = sparklineGroup.Add();

                //Set the Sparkline Datarange .
                IRange dataRange = sheet.Range["D6:G17"];
                //Set the Sparkline Reference range.
                IRange referenceRange = sheet.Range["H6:H17"];

                //Create a sparkline with the datarange and reference range.
                sparklines.Add(dataRange, referenceRange);



                #endregion

                #region Retail Trade

                //A new Sparkline group is added to the sheet sparklinegroups
                sparklineGroup = sheet.SparklineGroups.Add();

                //Set the Sparkline group type as column
                sparklineGroup.SparklineType = SparklineType.Column;

                //Set to display the empty cell as zero
                sparklineGroup.DisplayEmptyCellsAs = SparklineEmptyCells.Zero;

                //Sparkline group style properties
                sparklineGroup.ShowHighPoint      = true;
                sparklineGroup.HighPointColor     = Color.FromArgb(Colors.Green.A, Colors.Green.R, Colors.Green.G, Colors.Green.B);
                sparklineGroup.ShowLowPoint       = true;
                sparklineGroup.LowPointColor      = Color.FromArgb(Colors.Red.A, Colors.Red.R, Colors.Red.G, Colors.Red.B);
                sparklineGroup.ShowNegativePoint  = true;
                sparklineGroup.NegativePointColor = Color.FromArgb(Colors.Black.A, Colors.Black.R, Colors.Black.G, Colors.Black.B);

                //The sparklines are added to the sparklinegroup.
                sparklines = sparklineGroup.Add();

                //Set the Sparkline Datarange .
                dataRange = sheet.Range["D21:G32"];
                //Set the Sparkline Reference range.
                referenceRange = sheet.Range["H21:H32"];

                //Create a sparkline with the datarange and reference range.
                sparklines.Add(dataRange, referenceRange);

                #endregion

                #region Manufacturing Trade

                //A new Sparkline group is added to the sheet sparklinegroups
                sparklineGroup = sheet.SparklineGroups.Add();

                //Set the Sparkline group type as win/loss
                sparklineGroup.SparklineType = SparklineType.ColumnStacked100;

                sparklineGroup.DisplayEmptyCellsAs = SparklineEmptyCells.Zero;

                sparklineGroup.DisplayAxis        = true;
                sparklineGroup.AxisColor          = Color.FromArgb(Colors.Black.A, Colors.Black.R, Colors.Black.G, Colors.Black.B);
                sparklineGroup.ShowFirstPoint     = true;
                sparklineGroup.FirstPointColor    = Color.FromArgb(Colors.Green.A, Colors.Green.R, Colors.Green.G, Colors.Green.B);
                sparklineGroup.ShowLastPoint      = true;
                sparklineGroup.LastPointColor     = Color.FromArgb(Colors.Orange.A, Colors.Orange.R, Colors.Orange.G, Colors.Orange.B);
                sparklineGroup.ShowNegativePoint  = true;
                sparklineGroup.NegativePointColor = Color.FromArgb(Colors.Red.A, Colors.Red.R, Colors.Red.G, Colors.Red.B);

                sparklines = sparklineGroup.Add();

                dataRange      = sheet.Range["D36:G46"];
                referenceRange = sheet.Range["H36:H46"];

                sparklines.Add(dataRange, referenceRange);

                #endregion

                #endregion
            }
            //#endif
            #region Creating chart datasource

            IWorksheet chartSheet;

            if (application.DefaultVersion != ExcelVersion.Excel97to2003)
            {
                chartSheet = workbook.Worksheets.Create("Chart Data");
            }
            else
            {
                chartSheet = workbook.Worksheets[0];
            }

            // Entering the Datas for the chart
            chartSheet.Range["A1"].Text = "Crescent City, CA";
            chartSheet.Range["A1:D1"].Merge();
            chartSheet.Range["A1"].CellStyle.Font.Bold = true;

            chartSheet.Range["B3"].Text = "Precipitation,in.";
            chartSheet.Range["C3"].Text = "Temperature,deg.F";

            chartSheet.Range["A4"].Text  = "Jan";
            chartSheet.Range["A5"].Text  = "Feb";
            chartSheet.Range["A6"].Text  = "March";
            chartSheet.Range["A7"].Text  = "Apr";
            chartSheet.Range["A8"].Text  = "May";
            chartSheet.Range["A9"].Text  = "June";
            chartSheet.Range["A10"].Text = "July";
            chartSheet.Range["A11"].Text = "Aug";
            chartSheet.Range["A12"].Text = "Sept";
            chartSheet.Range["A13"].Text = "Oct";
            chartSheet.Range["A14"].Text = "Nov";
            chartSheet.Range["A15"].Text = "Dec";

            chartSheet.Range["B4"].Number  = 10.9;
            chartSheet.Range["B5"].Number  = 8.9;
            chartSheet.Range["B6"].Number  = 8.6;
            chartSheet.Range["B7"].Number  = 4.8;
            chartSheet.Range["B8"].Number  = 3.2;
            chartSheet.Range["B9"].Number  = 1.4;
            chartSheet.Range["B10"].Number = 0.6;
            chartSheet.Range["B11"].Number = 0.7;
            chartSheet.Range["B12"].Number = 1.7;
            chartSheet.Range["B13"].Number = 5.4;
            chartSheet.Range["B14"].Number = 9.0;
            chartSheet.Range["B15"].Number = 10.4;

            chartSheet.Range["C4"].Number  = 4.5;
            chartSheet.Range["C5"].Number  = 2.7;
            chartSheet.Range["C6"].Number  = 9.9;
            chartSheet.Range["C7"].Number  = 4.2;
            chartSheet.Range["C8"].Number  = 6.1;
            chartSheet.Range["C9"].Number  = 5.3;
            chartSheet.Range["C10"].Number = 3.1;
            chartSheet.Range["C11"].Number = 7;
            chartSheet.Range["C12"].Number = 4.5;
            chartSheet.Range["C13"].Number = 8.4;
            chartSheet.Range["C14"].Number = 3.1;
            chartSheet.Range["C15"].Number = 8.8;
            chartSheet.UsedRange.AutofitColumns();
            #endregion

            //#if WINDOWS_APP
            #region Column Chart

            #region Creating ChartSheet with Wall implementation
            // Adding a New chart to the Existing Worksheet
            IChart chart = workbook.Charts.Add("Column Chart");

            chart.DataRange      = chartSheet.Range["A3:C15"];
            chart.ChartTitle     = "Crescent City, CA";
            chart.IsSeriesInRows = false;

            chart.PrimaryValueAxis.Title = "Precipitation,in.";
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;
            chart.PrimaryValueAxis.MaximumValue = 14.0;
            chart.PrimaryValueAxis.NumberFormat = "0.0";

            chart.PrimaryCategoryAxis.Title = "Month";

            IChartSerie serieOne = chart.Series[0];

            //set the Chart Type
            chart.ChartType = ExcelChartType.Column_Clustered_3D;

            //set the Backwall fill option
            chart.BackWall.Fill.FillType = ExcelFillType.Gradient;

            //set the Texture Type
            chart.BackWall.Fill.GradientColorType = ExcelGradientColor.TwoColor;
            chart.BackWall.Fill.GradientStyle     = ExcelGradientStyle.Diagonl_Down;
            chart.BackWall.Fill.ForeColor         = Colors.White;
            chart.BackWall.Fill.BackColor         = Colors.Blue;

            //set the Border Linecolor
            chart.BackWall.Border.LineColor = Colors.Brown;

            //set the Picture Type
            chart.BackWall.PictureUnit = ExcelChartPictureType.stretch;

            //set the Backwall thickness
            chart.BackWall.Thickness = 10;

            //set the sidewall fill option
            chart.SideWall.Fill.FillType = ExcelFillType.SolidColor;

            //set the sidewall foreground and backcolor
            chart.SideWall.Fill.BackColor = Colors.White;
            chart.SideWall.Fill.ForeColor = Colors.White;

            //set the side wall Border color
            chart.SideWall.Border.LineColor = Colors.Red;

            //set floor fill option
            chart.Floor.Fill.FillType = ExcelFillType.Pattern;

            //set the floor pattern Type
            chart.Floor.Fill.Pattern = ExcelGradientPattern.Pat_Divot;

            //Set the floor fore and Back ground color
            chart.Floor.Fill.ForeColor = Colors.Blue;
            chart.Floor.Fill.BackColor = Colors.White;

            //set the floor thickness
            chart.Floor.Thickness = 3;

            //Set rotation angles
            chart.Rotation  = 20;
            chart.Elevation = 15;

            IChartSerie serieTwo = chart.Series[1];
            //Show value as data labels
            serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
            serieTwo.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;


            serieTwo.Name = "Temperature,deg.F";

            // Legend setting
            chart.Legend.Position         = ExcelLegendPosition.Right;
            chart.Legend.IsVerticalLegend = false;

            //Move the worksheet
            chartSheet.Move(1);


            #endregion

            #endregion
//#endif

            #region Pie Chart

            IWorksheet  embeddedChartSheet = workbook.Worksheets.Create("Pie Chart");
            IChartShape embeddedChart      = embeddedChartSheet.Charts.Add();

            embeddedChartSheet.Activate();
            embeddedChart.ChartTitle     = "Precipitation in Months";
            embeddedChart.IsSeriesInRows = false;
            embeddedChart.ChartType      = ExcelChartType.Pie;
            embeddedChart.DataRange      = chartSheet["A4:B15"];
            embeddedChart.Series[0].DataPoints.DefaultDataPoint.DataLabels.IsValue         = true;
            embeddedChart.Series[0].DataPoints.DefaultDataPoint.DataLabels.ShowLeaderLines = true;

            #endregion
#if WINDOWS_PHONE_APP
            workbook.Worksheets[0].Remove();
            embeddedChartSheet.Activate();
#endif

            #region Saving workbook and disposing objects

            await workbook.SaveAsAsync(storageFile);

            workbook.Close();
            excelEngine.Dispose();

            #endregion

            #region Save acknowledgement and launching of ouput file
            MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");

            UICommand yesCmd = new UICommand("Yes");
            msgDialog.Commands.Add(yesCmd);
            UICommand noCmd = new UICommand("No");
            msgDialog.Commands.Add(noCmd);
            IUICommand cmd = await msgDialog.ShowAsync();

            if (cmd == yesCmd)
            {
                // Launch the saved file
                bool success = await Windows.System.Launcher.LaunchFileAsync(storageFile);
            }
            #endregion
        }
        public override void FitToView(IChart chart, IAxis axis, double width, double height)
        {
            if (axis.Orientation == AxisOrientation.Vertical)
            {
                const double margin = 50;
                double min = double.MaxValue, max = double.MinValue;

                foreach (var chartPoint in chart.Points)
                {
                    if (chartPoint.Axes.Contains(axis))
                    {
                        if (chartPoint.Data[axis.Dimension] > max)
                            max = chartPoint.Data[axis.Dimension];

                        if (chartPoint.Data[axis.Dimension] < min)
                            min = chartPoint.Data[axis.Dimension];
                    }
                }

                double heightWithMargin = height - margin;
                double scale = 1.0;
                double translate;

                if (min != max)
                {
                    scale = heightWithMargin / (max - min);
                    translate = (heightWithMargin) / 2 + min * scale;
                }
                else
                {
                    translate = min * scale;
                }

                axis.Scale = -scale;
                axis.Translate = translate;

                Transform(axis, axis.Points);
            }
            else if (axis.Orientation == AxisOrientation.Horizontal)
            {
                const double margin = 50;
                double min = double.MaxValue, max = double.MinValue;

                foreach (var dependentAxis in axis.DependentAxes)
                {
                    if (dependentAxis.OriginalValue > max)
                        max = dependentAxis.OriginalValue;

                    if (dependentAxis.OriginalValue < min)
                        min = dependentAxis.OriginalValue;
                }

                double widthWithMargin = width - margin;
                double scale = 1.0;
                double translate = margin / 2;

                if (min != max)
                    scale = widthWithMargin / (max - min);

                axis.Scale = scale;
                axis.Translate = translate;

                foreach (var dependentAxis in axis.DependentAxes)
                {
                    Transform(axis, dependentAxis);
                }
            }
        }
예제 #28
0
파일: Line.cs 프로젝트: datadiode/ReoGrid
 /// <summary>
 /// Create line chart legend.
 /// </summary>
 /// <param name="chart">Parent chart component.</param>
 public LineChartLegend(IChart chart)
     : base(chart)
 {
 }
예제 #29
0
        private async void btnGenerateExcel_Click(object sender, RoutedEventArgs e)
        {
            StorageFile storageFile;
            string      fileName = "Sunburst_Chart.xlsx";

            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
            {
                FileSavePicker savePicker = new FileSavePicker();
                savePicker.SuggestedStartLocation = PickerLocationId.Desktop;
                savePicker.SuggestedFileName      = fileName;
                savePicker.FileTypeChoices.Add("Excel Files", new List <string>()
                {
                    ".xlsx",
                });
                storageFile = await savePicker.PickSaveFileAsync();
            }
            else
            {
                StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                storageFile = await local.CreateFileAsync("Sunburst_Chart.xlsx", CreationCollisionOption.ReplaceExisting);
            }

            if (storageFile == null)
            {
                return;
            }


            #region Initializing Workbook
            //New instance of XlsIO is created.[Equivalent to launching MS Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine.
            ExcelEngine excelEngine = new ExcelEngine();
            //Step 2 : Instantiate the Excel application object.
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2016;

            Assembly  assembly     = typeof(Sunburst).GetTypeInfo().Assembly;
            string    resourcePath = "Syncfusion.SampleBrowser.UWP.XlsIO.XlsIO.Tutorials.Samples.Assets.Resources.Templates.SunburstTemplate.xlsx";
            Stream    fileStream   = assembly.GetManifestResourceStream(resourcePath);
            IWorkbook workbook     = await application.Workbooks.OpenAsync(fileStream);

            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];
            #endregion

            #region Chart Creation
            IChart chart = null;

            if (this.rdBtnSheet.IsChecked != null && this.rdBtnSheet.IsChecked.Value)
            {
                chart = workbook.Charts.Add();
            }
            else
            {
                chart = workbook.Worksheets[0].Charts.Add();
            }

            #region Sunburst Chart Settings
            chart.ChartType  = ExcelChartType.SunBurst;
            chart.DataRange  = sheet["A1:D29"];
            chart.ChartTitle = "Breakdown of Bookstore Revenue";
            #endregion

            chart.Legend.Position = ExcelLegendPosition.Right;

            if (this.rdBtnSheet.IsChecked != null && this.rdBtnSheet.IsChecked.Value)
            {
                chart.Activate();
            }
            else
            {
                workbook.Worksheets[0].Activate();
                IChartShape chartShape = chart as IChartShape;
                chartShape.TopRow      = 1;
                chartShape.BottomRow   = 23;
                chartShape.LeftColumn  = 6;
                chartShape.RightColumn = 15;
            }
            #endregion

            #region Saving the workbook
            await workbook.SaveAsAsync(storageFile);

            workbook.Close();
            excelEngine.Dispose();
            #endregion

            #region Launching the saved workbook
            MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");

            UICommand yesCmd = new UICommand("Yes");
            msgDialog.Commands.Add(yesCmd);
            UICommand noCmd = new UICommand("No");
            msgDialog.Commands.Add(noCmd);
            IUICommand cmd = await msgDialog.ShowAsync();

            if (cmd == yesCmd)
            {
                // Launch the saved file
                bool success = await Windows.System.Launcher.LaunchFileAsync(storageFile);
            }
            #endregion
        }
예제 #30
0
 public List <InventoryTypeSalesVO> DisplayChart(IChart chart, string type, bool monthYear)
 {
     this.chart = chart;
     return(this.chart.Chart(this.chart, type, monthYear));
 }
예제 #31
0
        private void btnCreateReport_Click(object sender, EventArgs e)
        {
            #region Initialize Workbook
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;
            // A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            // The number of default worksheets is the application setting in MS Excel.
            myWorkbook = excelEngine.Excel.Workbooks.Add(dataDirectory.FullName + "Template.xls");

            //Set the Default version as Excel 97to2003
            if (this.rdbExcel97.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel97to2003;
                fileName           = "StockPortfolioOutput.xls";
            }
            //Set the Default version as Excel 2007
            else if (this.rdbExcek2007.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel2007;
                fileName           = "StockPortfolioOutput.xlsx";
            }
            //Set the Default version as Excel 2010
            else if (this.rdbExcel2010.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel2010;
                fileName           = "StockPortfolioOutput.xlsx";
            }
            //Set the Default version as Excel 2013
            else if (this.rdbExcel2013.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel2013;
                fileName           = "StockPortfolioOutput.xlsx";
            }

            IChart chart = myWorkbook.Worksheets[1].Charts[0];
            chart.PrimaryCategoryAxis.NumberFormat     = "m/d/yyyy";
            chart.PrimaryValueAxis.NumberFormat        = "\"$\"#,##0.00";
            chart.SecondaryValueAxis.NumberFormat      = "\"$\"#,##0.00";
            chart.SecondaryValueAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_High;

            // Adding new worksheets in workbook's sheets collection
            for (int count = 1; count < StockList.SelectedItems.Count; count++)
            {
                myWorkbook.Worksheets.AddCopyAfter(myWorkbook.Worksheets[1], myWorkbook.Worksheets[0]);
            }

            // Adding hyperlinks to menu sheet
            IWorksheet menu_sheet = myWorkbook.Worksheets[0];
            #endregion

            int InsertIndex = DEF_FST_ROW_NUM_SC - 3;

            menu_sheet.HyperLinks.RemoveAt(0);
            menu_sheet.Range["G21"].Text = "";

            #region Insert Hyperlinks for Stock items
            for (int count = 0; count < StockList.SelectedItems.Count; count++)
            {
                menu_sheet.InsertRow(InsertIndex, 2, ExcelInsertOptions.FormatAsBefore);
                IHyperLink report_hyperlink = menu_sheet.HyperLinks.Add(menu_sheet.Range["G" + InsertIndex + ":I" + InsertIndex]);
                report_hyperlink.Type          = ExcelHyperLinkType.Workbook;
                report_hyperlink.Address       = StockList.SelectedItems[count].ToString() + "!A1";
                report_hyperlink.TextToDisplay = StockList.SelectedItems[count].ToString();

                InsertIndex += 2;
            }
            #endregion

            #region Creating Stock report

            int itemIndex = 1;

            foreach (Object StockListItem in StockList.SelectedItems)
            {
                CreateStockReport(StockListItem.ToString(), itemIndex);
                FillAnalysisPortfolioSheet(StockListItem.ToString());
                itemIndex += 1;
            }
            #endregion

            #region Save the Workbook
            myWorkbook.Worksheets[0].Activate();
            // Saving the workbook to disk.
            myWorkbook.SaveAs(reportDirectory + "\\" + fileName);
            #endregion

            #region Dispose the Excel Engine
            // No exception will be thrown if there are unsaved workbooks. No use here since we are
            // saving the workbook.
            excelEngine.ThrowNotSavedOnDestroy = false;
            excelEngine.Dispose();
            #endregion

            #region View the Workbook
            //Message box confirmation to view the created spreadsheet.
            if (MessageBox.Show("Do you want to view the workbook?", "Workbook has been created",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information)
                == DialogResult.Yes)
            {
                //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer]
                System.Diagnostics.Process.Start(reportDirectory + "\\" + fileName);
                //Exit
                this.Close();
            }
            else
            {
                // Exit
                this.Close();
            }
            #endregion
        }
예제 #32
0
 public List <InventoryTypeSalesVO> Chart(IChart chart, string InventoryName, bool monthYear)
 {
     return(new InventorySalesDAO().InventorySalesSelect(InventoryName, chart, monthYear));
 }
예제 #33
0
 internal abstract void Process(IChart chart);
예제 #34
0
        public static void Run()
        {
            //ExStart:ScatteredChart
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            Presentation pres = new Presentation();

            ISlide slide = pres.Slides[0];

            // Creating the default chart
            IChart chart = slide.Shapes.AddChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);

            // Getting the default chart data worksheet index
            int defaultWorksheetIndex = 0;

            // Getting the chart data worksheet
            IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

            // Delete demo series
            chart.ChartData.Series.Clear();

            // Add new series
            chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type);
            chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.Type);

            // Take first chart series
            IChartSeries series = chart.ChartData.Series[0];

            // Add new point (1:3) there.
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 1), fact.GetCell(defaultWorksheetIndex, 2, 2, 3));

            // Add new point (2:10)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 2), fact.GetCell(defaultWorksheetIndex, 3, 2, 10));

            // Edit the type of series
            series.Type = ChartType.ScatterWithStraightLinesAndMarkers;

            // Changing the chart series marker
            series.Marker.Size   = 10;
            series.Marker.Symbol = MarkerStyleType.Star;

            // Take second chart series
            series = chart.ChartData.Series[1];

            // Add new point (5:2) there.
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 3, 5), fact.GetCell(defaultWorksheetIndex, 2, 4, 2));

            // Add new point (3:1)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 3, 3), fact.GetCell(defaultWorksheetIndex, 3, 4, 1));

            // Add new point (2:2)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 4, 3, 2), fact.GetCell(defaultWorksheetIndex, 4, 4, 2));

            // Add new point (5:1)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 5, 3, 5), fact.GetCell(defaultWorksheetIndex, 5, 4, 1));

            // Changing the chart series marker
            series.Marker.Size   = 10;
            series.Marker.Symbol = MarkerStyleType.Circle;

            pres.Save(dataDir + "AsposeChart_out.pptx", SaveFormat.Pptx);
            //ExEnd:ScatteredChart
        }
예제 #35
0
 private void TimeMachineForm_Load(object sender, EventArgs e)
 {
     chart = new ZedGraphProxy(zedGraphControl1);
     AppSettings.Mode.ApplySettingsToChart(chart);
     data = AppSettings.Mode.Data;
 }
예제 #36
0
 public abstract void FitToView(IChart chart, IAxis axis, double width, double height);
예제 #37
0
 public override void ApplySettingsToChart(IChart chart)
 {
     base.ApplySettingsToChart(chart);
     timer.Interval = CustomSettings.MeasurementPeriod;
 }
예제 #38
0
 public override void ApplySettingsToChart(IChart chart)
 {
     base.ApplySettingsToChart(chart);
     chart.PlotMode = CustomSettings.PlotMode;
     chart.SetSeriesNames(CustomSettings.Series1Legend, CustomSettings.Series2Legend);
 }
예제 #39
0
        //Export and saves the chart in Excel Sheet
        #region XLsIO
        private void buttonXLsIO_Click(object sender, EventArgs e)
        {
            try
            {
                //Instantiate the spreadsheet creation engine.
                ExcelEngine excelEngine = new ExcelEngine();

                //Instantiate the excel application object.
                IApplication application = excelEngine.Excel;

                //Set the default version as Excel 2007;
                application.DefaultVersion = ExcelVersion.Excel2007;
                exportFileName             = fileName + ".xlsx";

                //A new workbook with a worksheet is created.
                IWorkbook  chartBook = application.Workbooks.Create(1);
                IWorksheet sheet     = chartBook.Worksheets[0];

                //Fill the worksheet by chart data.
                for (int i = 1; i <= 4; i++)
                {
                    sheet.Range[i, 1].Number = this.chartControl1.Series[0].Points[i - 1].X;
                    sheet.Range[i, 2].Number = this.chartControl1.Series[0].Points[i - 1].YValues[0];
                }
                for (int i = 1; i <= 4; i++)
                {
                    sheet.Range[i + 5, 1].Number = this.chartControl1.Series[1].Points[i - 1].X;
                    sheet.Range[i + 5, 2].Number = this.chartControl1.Series[1].Points[i - 1].YValues[0];
                }

                //Create a chart worksheet.
                IChart chart = chartBook.Charts.Add("Essential Chart");

                //Specifies the title of the Chart.
                chart.ChartTitle = "Essential Chart";

                //Initializes a new series instance and adds it to the series collection of the chart.
                IChartSerie series1 = chart.Series.Add();
                //Specify the chart type of the series.
                series1.SerieType = ExcelChartType.Column_Clustered;
                //Specify the name of the series. This will be displayed as the text of the legend.
                series1.Name = "Sample Series";
                //Specify the value ranges for the series.
                series1.Values = sheet.Range["B1:B5"];
                //Specify the Category labels for the series.
                series1.CategoryLabels = sheet.Range["A1:A5"];


                IChartSerie series2 = chart.Series.Add();
                //Specify the chart type of the series.
                series2.SerieType = ExcelChartType.Column_Clustered;
                //Specify the name of the series. This will be displayed as the text of the legend.
                series2.Name = "Sample Series";
                //Specify the value ranges for the series.
                series2.Values = sheet.Range["B6:B10"];
                //Specify the Category labels for the series.
                series2.CategoryLabels = sheet.Range["A6:A10"];


                //Makes the chart as active sheet.
                chart.Activate();
                //Save the Chart book.
                chartBook.SaveAs(exportFileName);
                chartBook.Close();
                ExcelUtils.Close();
                OpenFile("XLsIO", exportFileName);
                System.Diagnostics.Process.Start(exportFileName);
            }
            catch (Exception ex)
            {
                this.toolStripStatusLabel1.Text = "Chart Export failed.";
                Console.WriteLine(ex.ToString());
            }
        }
 public static IChart SourceData(this IChart chart, IRange range, RowCol cols, ChartType type)
 {
     chart.SetSourceData(range, cols);
     chart.ChartType = type;
     return(chart);
 }
예제 #41
0
        //
        // GET: /Bar/

        public ActionResult Sunburst(string button, string Saveoption)
        {
            if (button == null)
            {
                return(View());
            }
            if (button == "Input Template")
            {
                //Step 1 : Instantiate the spreadsheet creation engine.
                ExcelEngine excelEngine = new ExcelEngine();
                //Step 2 : Instantiate the excel application object.
                IApplication application = excelEngine.Excel;
                IWorkbook    workbook    = application.Workbooks.Open(ResolveApplicationDataPath(@"SunburstTemplate.xlsx"));
                return(excelEngine.SaveAsActionResult(workbook, "InputTemplate.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016));
            }
            else
            {
                //Instantiate the spreadsheet creation engine.
                ExcelEngine  excelEngine = new ExcelEngine();
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2016;
                //A new workbook is created.[Equivalent to creating a new workbook in Microsoft Excel]
                //Open workbook with Data
                IWorkbook  workbook = excelEngine.Excel.Workbooks.Open(ResolveApplicationDataPath("SunburstTemplate.xlsx"));
                IWorksheet sheet    = workbook.Worksheets[0];
                IChart     chart    = null;

                if (Saveoption == "sheet")
                {
                    chart = workbook.Charts.Add();
                }
                else
                {
                    chart = workbook.Worksheets[0].Charts.Add();
                }

                #region Sunburst Chart Settings
                chart.ChartType  = ExcelChartType.SunBurst;
                chart.DataRange  = sheet["A1:D29"];
                chart.ChartTitle = "Breakdown of Bookstore Revenue";
                #endregion

                chart.Legend.Position = ExcelLegendPosition.Right;

                if (Saveoption == "sheet")
                {
                    chart.Activate();
                }
                else
                {
                    workbook.Worksheets[0].Activate();
                    IChartShape chartShape = chart as IChartShape;
                    chartShape.TopRow      = 1;
                    chartShape.BottomRow   = 23;
                    chartShape.LeftColumn  = 6;
                    chartShape.RightColumn = 15;
                }
                try
                {
                    return(excelEngine.SaveAsActionResult(workbook, "Sunburst_Chart.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016));
                }
                catch (Exception)
                {
                }

                workbook.Close();
                excelEngine.Dispose();
            }
            return(View());
        }
예제 #42
0
        /// <summary>
        /// Creates Spreadsheet with Styles and Formatting
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreate_Click(object sender, EventArgs e)
        {
            #region Workbook Initialize
            //New instance of XlsIO is created.[Equivalent to launching MS Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine.
            ExcelEngine excelEngine = new ExcelEngine();
            //Step 2 : Instantiate the excel application object.
            IApplication application = excelEngine.Excel;

            //Set the default version as Excel 2007;
            if (rdbExcel2007.Checked)
            {
                application.DefaultVersion = ExcelVersion.Excel2007;
            }
            //Set the default version as Excel 2010;
            else if (rdbExcel2010.Checked)
            {
                application.DefaultVersion = ExcelVersion.Excel2010;
            }
            else if (rdbExcel2013.Checked)
            {
                application.DefaultVersion = ExcelVersion.Excel2013;
            }

            //Get the path of the input file
            string    inputPath = GetFullTemplatePath("PivotCodeDate.xlsx");
            IWorkbook workbook  = application.Workbooks.Open(inputPath);

            // The first worksheet object in the worksheets collection is accessed.
            IWorksheet worksheet = workbook.Worksheets[0];
            #endregion

            #region Add Pivot Table
            //Access the worksheet to draw pivot table.
            IWorksheet pivotSheet = workbook.Worksheets[1];

            //Select the data to add in cache
            IPivotCache cache = workbook.PivotCaches.Add(worksheet["A1:H50"]);

            //Insert the pivot table.
            IPivotTable pivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet["A1"], cache);
            pivotTable.Fields[2].Axis = PivotAxisTypes.Row;
            pivotTable.Fields[4].Axis = PivotAxisTypes.Row;
            pivotTable.Fields[3].Axis = PivotAxisTypes.Column;

            IPivotField field = pivotSheet.PivotTables[0].Fields[5];
            pivotTable.DataFields.Add(field, "Sum of Units", PivotSubtotalTypes.Sum);

            //Show expand/collapse button.
            pivotTable.ShowDrillIndicators = true;

            //Shows row grand.
            pivotTable.RowGrand = true;

            //Shows filter and field caption.
            pivotTable.DisplayFieldCaptions = true;

            //Apply built in style.
            pivotTable.BuiltInStyle = PivotBuiltInStyles.PivotStyleMedium2;
            pivotSheet.Range[1, 1, 1, 14].ColumnWidth = 11;
            pivotSheet.SetColumnWidth(1, 15.29);
            pivotSheet.SetColumnWidth(2, 15.29);
            #endregion

            #region Add Pivot Chart
            //Add the Pivot chart worksheet to the workbook.
            IChart pivotChartSheet = workbook.Charts.Add();
            pivotChartSheet.Name = "PivotChart";

            //Set the Pivot source for the Pivot Chart.
            pivotChartSheet.PivotSource = pivotTable;

            //Set the Pivot Chart Type.
            pivotChartSheet.PivotChartType = ExcelChartType.Column_Clustered;

            //Activate the pivot worksheet.
            pivotChartSheet.Activate();
            #endregion

            #region Save the Workbook
            //Saving the workbook to disk.
            workbook.SaveAs("PivotChart.xlsx");
            #endregion

            #region Workbook Close and Dispose
            //Close the workbook.
            workbook.Close();

            //No exception will be thrown if there are unsaved workbooks.
            excelEngine.ThrowNotSavedOnDestroy = false;
            excelEngine.Dispose();
            #endregion

            #region View the Workbook
            //Message box confirmation to view the created spreadsheet.
            if (MessageBox.Show("Do you want to view the workbook?", "Workbook has been created",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information)
                == DialogResult.Yes)
            {
                try
                {
                    //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer]
                    System.Diagnostics.Process.Start("PivotChart.xlsx");
                    //Exit
                    this.Close();
                }
                catch (Win32Exception)
                {
                    MessageBox.Show("MS Excel is not installed in this system");
                }
            }
            else
            {
                // Exit
                this.Close();
            }
            #endregion
        }
예제 #43
0
 public override void ApplySettingsToChart(IChart chart)
 {
     base.ApplySettingsToChart(chart);
 }
        public void OnSaveToPDFButtonClicked()
        {
            double? additionalMaterialQuantity = _view.AdditionalMaterialQuantity;
            bool additionalMaterialQuantityIsGreaterThanZeroAndSmallerThanOne100 = (additionalMaterialQuantity > 0 &&
                                                                                    additionalMaterialQuantity < 100);
            if ((!(additionalMaterialQuantity.HasValue && additionalMaterialQuantityIsGreaterThanZeroAndSmallerThanOne100))
                ||
                !_someCountingsFinished)
            {
                MessageBox.Show("Ilość materiału dodatkowego nie jest liczba z zakresu od 0 od 100.\nUpewnij się że przeprowadzono obliczenia.");
                return;
            }

            int widthForA4 = (int)((float)_view.DrawPanelWidth * 0.6);
            int heightForA4 = (int)((float)_view.DrawPanelHeight * 0.6);

            Bitmap bitmap = new Bitmap(widthForA4, heightForA4);

            _chart = new Chart(Graphics.FromImage(bitmap),
                _dataConnector.GetDeLongImages(),
                _dataConnector.GetDeLongChartSizingData());
            _chart.ResizeTo(widthForA4, heightForA4);
            _chart.Draw();
            CountPointsAndLinesPositionAndDraw();

            _dataConnector.SaveMainChartForPDF(bitmap);

            _chart = new Chart(Graphics.FromHwnd(_view.DrawPanelCanvas),
                _dataConnector.GetDeLongImages(),
                _dataConnector.GetDeLongChartSizingData());
            _chart.ResizeTo(_view.DrawPanelWidth, _view.DrawPanelHeight);
            _chart.Draw();
            CountPointsAndLinesPositionAndDraw();

            var schaefflerDeLongMinimapForm = new SchaefflerMinimapForm(MinimapCombination.SchaefflerDeLong, _view.AdditionalMaterialQuantity.Value, true);

            PdfGenerator = new PDFGenerator(PdfFor.DeLong, _dataConnector.GetFirstBasisMarerialForSchaeffler(), _dataConnector.GetSecondBasisMarerialForSchaeffler(), _dataConnector.GetAdditionalMaterialForSchaeffler(), (double)_view.AdditionalMaterialQuantity, "null", "null",_view.NewMaterialMicrophaseTextBox, _view.NewMaterialFerriteQuantityTextBox, _view.NewMaterialFerriteNumberTextBox, "null", "null");
        }
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            #region Workbook Initialize
            //New instance of XlsIO is created.[Equivalent to launching MS Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine.
            ExcelEngine excelEngine = new ExcelEngine();
            //Step 2 : Instantiate the excel application object.

            //Set the default version as Excel97to2003
            IApplication application = excelEngine.Excel;
            if (this.rdbExcel97.Checked)
            {
                application.DefaultVersion = ExcelVersion.Excel97to2003;
                fileName = "ChartWorksheet.xls";
            }
            //Set the default version as Excel 2007;
            else if (this.rdbExcel2007.Checked)
            {
                application.DefaultVersion = ExcelVersion.Excel2007;
                fileName = "ChartWorksheet.xlsx";
            }
            //Set the default version as Excel 2010;
            else if (this.rdbExcel2010.Checked)
            {
                application.DefaultVersion = ExcelVersion.Excel2010;
                fileName = "ChartWorksheet.xlsx";
            }
            //Set the default version as Excel 2010;
            else if (this.rdbExcel2013.Checked)
            {
                application.DefaultVersion = ExcelVersion.Excel2013;
                fileName = "ChartWorksheet.xlsx";
            }
            //A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            //The new workbook will have 1 worksheet.
            IWorkbook workbook = application.Workbooks.Create(1);
            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet worksheet = workbook.Worksheets[0];
            #endregion

            #region Insert Data into Cells of Worksheet
            // Entering the Datas for the chart
            worksheet.Range["A1"].Text = "Crescent City, CA";
            worksheet.Range["A1:D1"].Merge();
            worksheet.Range["A1"].CellStyle.Font.Bold = true;

            worksheet.Range["B3"].Text = "Precipitation,in.";
            worksheet.Range["C3"].Text = "Temperature,deg.F";

            worksheet.Range["A4"].Text  = "Jan";
            worksheet.Range["A5"].Text  = "Feb";
            worksheet.Range["A6"].Text  = "March";
            worksheet.Range["A7"].Text  = "Apr";
            worksheet.Range["A8"].Text  = "May";
            worksheet.Range["A9"].Text  = "June";
            worksheet.Range["A10"].Text = "July";
            worksheet.Range["A11"].Text = "Aug";
            worksheet.Range["A12"].Text = "Sept";
            worksheet.Range["A13"].Text = "Oct";
            worksheet.Range["A14"].Text = "Nov";
            worksheet.Range["A15"].Text = "Dec";

            worksheet.Range["B4"].Number  = 10.9;
            worksheet.Range["B5"].Number  = 8.9;
            worksheet.Range["B6"].Number  = 8.6;
            worksheet.Range["B7"].Number  = 4.8;
            worksheet.Range["B8"].Number  = 3.2;
            worksheet.Range["B9"].Number  = 1.4;
            worksheet.Range["B10"].Number = 0.6;
            worksheet.Range["B11"].Number = 0.7;
            worksheet.Range["B12"].Number = 1.7;
            worksheet.Range["B13"].Number = 5.4;
            worksheet.Range["B14"].Number = 9.0;
            worksheet.Range["B15"].Number = 10.4;

            worksheet.Range["C4"].Number  = 47.5;
            worksheet.Range["C5"].Number  = 48.7;
            worksheet.Range["C6"].Number  = 48.9;
            worksheet.Range["C7"].Number  = 50.2;
            worksheet.Range["C8"].Number  = 53.1;
            worksheet.Range["C9"].Number  = 56.3;
            worksheet.Range["C10"].Number = 58.1;
            worksheet.Range["C11"].Number = 59.0;
            worksheet.Range["C12"].Number = 58.5;
            worksheet.Range["C13"].Number = 55.4;
            worksheet.Range["C14"].Number = 51.1;
            worksheet.Range["C15"].Number = 47.8;
            worksheet.UsedRange.AutofitColumns();
            #endregion

            #region Add New chart to Workbook
            // Adding a New chart to the Existing Worksheet
            IChart chart = workbook.Charts.Add();


            chart.DataRange      = worksheet.Range["A3:C15"];
            chart.Name           = "CrescentCity,CA";
            chart.ChartTitle     = "Crescent City, CA";
            chart.IsSeriesInRows = false;

            chart.PrimaryValueAxis.Title = "Precipitation,in.";
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;
            chart.PrimaryValueAxis.MaximumValue = 14.0;
            chart.PrimaryValueAxis.NumberFormat = "0.0";

            #region Format Series
            // Format serie
            IChartSerie serieOne = chart.Series[0];
            serieOne.Name = "Precipitation,in.";
            serieOne.SerieFormat.Fill.FillType = ExcelFillType.Gradient;
            serieOne.SerieFormat.Fill.TwoColorGradient(ExcelGradientStyle.Vertical, ExcelGradientVariants.ShadingVariants_2);
            serieOne.SerieFormat.Fill.GradientColorType = ExcelGradientColor.TwoColor;
            serieOne.SerieFormat.Fill.ForeColor         = Color.Plum;

            //Show value as data labels
            serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue  = true;
            serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;

            //Format the second serie
            IChartSerie serieTwo = chart.Series[1];
            serieTwo.SerieType = ExcelChartType.Line_Markers;
            serieTwo.Name      = "Temperature,deg.F";

            //Format marker
            serieTwo.SerieFormat.MarkerStyle              = ExcelChartMarkerType.Diamond;
            serieTwo.SerieFormat.MarkerSize               = 8;
            serieTwo.SerieFormat.MarkerBackgroundColor    = Color.DarkGreen;
            serieTwo.SerieFormat.MarkerForegroundColor    = Color.DarkGreen;
            serieTwo.SerieFormat.LineProperties.LineColor = Color.DarkGreen;

            //Use Secondary Axis
            serieTwo.UsePrimaryAxis = false;
            #endregion

            #region Set the Secondary Axis for Second Serie.
            //Display secondary axis for the series.
            chart.SecondaryCategoryAxis.IsMaxCross = true;
            chart.SecondaryValueAxis.IsMaxCross    = true;

            //Set the title
            chart.SecondaryValueAxis.Title = "Temperature,deg.F";
            chart.SecondaryValueAxis.TitleArea.TextRotationAngle = 90;

            //Hide the secondary category axis
            chart.SecondaryCategoryAxis.Border.LineColor  = Color.Transparent;
            chart.SecondaryCategoryAxis.MajorTickMark     = ExcelTickMark.TickMark_None;
            chart.SecondaryCategoryAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_None;
            #endregion

            #region Legend setting
            chart.Legend.Position         = ExcelLegendPosition.Bottom;
            chart.Legend.IsVerticalLegend = false;
            #endregion

            #region Excel2013 Filter Enabled
            if (rdbExcel2013.Checked)
            {
                chart.Series[1].IsFiltered     = true;
                chart.Categories[0].IsFiltered = true;
                chart.Categories[1].IsFiltered = true;
            }
            #endregion
            //Move the worksheet
            worksheet.Move(1);

            //Activate the chart
            chart.Activate();
            #endregion

            #region Save Workbook

            //Saving the workbook to disk.
            workbook.SaveAs(fileName);
            #endregion

            #region Workbook Close and Dispose
            //Close the workbook.
            workbook.Close();

            //No exception will be thrown if there are unsaved workbooks.
            excelEngine.ThrowNotSavedOnDestroy = false;
            excelEngine.Dispose();
            #endregion

            #region View the Workbook
            //Message box confirmation to view the created spreadsheet.
            if (MessageBox.Show("Do you want to view the workbook?", "Workbook has been created",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information)
                == DialogResult.Yes)
            {
                //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer]
                System.Diagnostics.Process.Start(fileName);
                //Exit
                this.Close();
            }
            else
            {
                // Exit
                this.Close();
            }
            #endregion
        }
예제 #46
0
 /// <summary>
 /// Инициализирует компонент для построения графиков настройками
 /// </summary>
 /// <param name="chart">интерфейсная ссылка на объект компонента для построения графиков</param>
 public virtual void ApplySettingsToChart(IChart chart)
 {
     chart.SetSeriesNames(Settings.Series1Legend);
     chart.AutoScroll = Settings.AutoScroll;
     chart.LegendVisible = Settings.LegendVisible;
     chart.DotsPerFrame = Settings.DotsPerFrame;
     chart.Caption = Settings.ChartCaption;
     chart.PlotMode = PlotModes.None;
     chart.XAxisLegend = Settings.XAxisLegend;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartDataBindingSettings" /> class.
 /// </summary>
 /// <param name="chart">The chart.</param>
 public ChartDataBindingSettings(IChart chart)
 {
     Ajax = new ChartBindingSettings(chart);
 }
예제 #48
0
 internal ChartDrawingEventArgs(IChart chart, DrawingContext dc, Rectangle bounds)
     : base(dc, bounds)
 {
     this.Chart = chart;
 }
예제 #49
0
        /// <summary>
        /// 환경설정에 정의된 옵션에 따라 Chart 의 속성을 설정할 수 있다.
        /// 기본적으로는 Export Image에 대한 환경설정을 수행한다.
        /// </summary>
        /// <param name="chart"></param>
        protected virtual void SetChartAttributes(IChart chart) {
            // var exportEnabled = ConfigTool.GetAppSettings(HandlerSettings.ExportEnabledAppKey, true);
            var exportPath = ConfigTool.GetAppSettings(HandlerSettings.ExportPathAppKey, HandlerSettings.ExportHandler);

            if(IsDebugEnabled)
                log.Debug("Settings export Image/PDF attributes, FusionCharts.Export.Path=[{0}]", exportPath);

            // if (exportEnabled)
            //{
            chart.SetExportInServer(exportPath);
            //}
        }
예제 #50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartPanesFactory"/> class.
 /// </summary>
 /// <param name="container">The container.</param>
 public ChartPanesFactory(IChart container)
 {
     Container = container;
 }
예제 #51
0
 public ChartUpdatedEvent(IChart chart, bool propagateChartChangeEvent) : base(chart)
 {
     PropagateChartChangeEvent = propagateChartChangeEvent;
 }
예제 #52
0
 public ChartPropertiesChangedEvent(IChart chart) : base(chart)
 {
 }
예제 #53
0
 public void InitChart(IChart chart)
 {
     ApplySettingsToChart(chart);
     Chart = chart;
 }
예제 #54
0
 protected ChartEvent(IChart chart)
 {
     Chart = chart;
 }
예제 #55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartPanesFactory{TModel}"/> class.
 /// </summary>
 /// <param name="container">The container.</param>
 public ChartPanesFactory(IChart container)
 {
     Container = container;
 }
예제 #56
0
 public void Draw(IChart chart)
 {
     chart.GetElements();
 }
        public ChartLine AttachDataSet(IChart chart, MultiDimensionalPoint point, int pointDimension, object tag)
        {
            var chartPoints = new ChartPoint[pointDimension];
            var chartLineSegments = new ChartLineSegment[pointDimension - 1];

            for (int i = 0; i < pointDimension; i++)
            {
                chartPoints[i] = new ChartPoint { Data = point };
                chart.Axes[i].Points.Add(chartPoints[i]);
                chart.Axes[i].Transformation.Transform(chart.Axes[i], chartPoints[i]);
            }

            for (int i = 0; i < pointDimension - 1; i++)
            {
                chartLineSegments[i] = new ChartLineSegment(chartPoints[i], chartPoints[i + 1]);
            }

            foreach (var chartPoint in chartPoints)
            {
                chart.Points.Add(chartPoint);
            }

            var line = new ChartLine(chartLineSegments) { Tag = tag };
            chart.Lines.Add(line);

            return line;
        }