Esempio n. 1
0
 internal static void Map(Chart chart, DocumentObjectModel.Shapes.Charts.Chart domChart)
 {
     LegendMapper mapper = new LegendMapper();
     mapper.MapObject(chart, domChart);
 }
Esempio n. 2
0
        void MapObject(Chart chart, DocumentObjectModel.Shapes.Charts.Chart domChart)
        {
            DocumentObjectModel.Shapes.Charts.Legend domLegend = null;
            DocumentObjectModel.Shapes.Charts.TextArea textArea = null;

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.BottomArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Bottom;
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea = domChart.BottomArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.RightArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Right;
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea = domChart.RightArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.LeftArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Left;
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea = domChart.LeftArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.TopArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Top;
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea = domChart.TopArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.HeaderArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Top;
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea = domChart.HeaderArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.FooterArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Bottom;
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea = domChart.FooterArea;
                }
            }

            if (domLegend != null)
            {
                if (!domLegend.IsNull("LineFormat"))
                    LineFormatMapper.Map(chart.Legend.LineFormat, domLegend.LineFormat);
                if (!textArea.IsNull("Style"))
                    FontMapper.Map(chart.Legend.Font, textArea.Document, textArea.Style);
                if (!domLegend.IsNull("Format.Font"))
                    FontMapper.Map(chart.Legend.Font, domLegend.Format.Font);
            }
        }
Esempio n. 3
-1
 /// <summary>
 /// Adds a chart to the ChartFrame.
 /// </summary>
 public void Add(Chart chart)
 {
   if (this.chartList == null)
     this.chartList = new ArrayList();
   this.chartList.Add(chart);
 }
Esempio n. 4
-1
        public PdfSharp.Charting.Chart LineChart()
        {
            List <Activity> filteredProfitExpenses;

            if (SelectedType.Equals(Constants.PROFIT))
            {
                if (!SelectedCategory.Equals(Constants.ALL_DATA))
                {
                    List <Activity> profits = profitActivities.Where(p => p.category.Equals(SelectedCategory)).ToList();
                    filteredProfitExpenses = filterPeriod(profits);
                }
                else
                {
                    filteredProfitExpenses = filterPeriod(profitActivities);
                }
            }
            else if (SelectedType.Equals(Constants.EXPENSE))
            {
                if (!SelectedCategory.Equals(Constants.ALL_DATA))
                {
                    List <Activity> expenses = expenseActivities.Where(p => p.category.Equals(SelectedCategory)).ToList();
                    filteredProfitExpenses = filterPeriod(expenses);
                }
                else
                {
                    filteredProfitExpenses = filterPeriod(expenseActivities);
                }
            }
            else
            {
                filteredProfitExpenses = filterPeriod(profitExpenses);
            }

            PdfSharp.Charting.Chart chart = new PdfSharp.Charting.Chart(ChartType.Line);
            Series series;

            if (filteredProfitExpenses.Find(o => o.type.Equals(Constants.PROFIT)) != null)
            {
                series      = chart.SeriesCollection.AddSeries();
                series.Name = "Profit";
                series.Add(filteredProfitExpenses
                           .Where(o => o.type.Equals(Constants.PROFIT)).ToList()
                           .ConvertAll(o => o.amount).ToArray());
            }

            if (filteredProfitExpenses.Find(o => o.type.Equals(Constants.EXPENSE)) != null)
            {
                series      = chart.SeriesCollection.AddSeries();
                series.Name = "Expense";
                series.Add(filteredProfitExpenses
                           .Where(o => o.type.Equals(Constants.EXPENSE)).ToList()
                           .ConvertAll(o => o.amount).ToArray());
            }

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            chart.XAxis.Title.Caption = "Date";

            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.Title.Caption     = "Amount";
            chart.YAxis.HasMajorGridlines = true;

            chart.PlotArea.LineFormat.Color   = XColors.DarkGray;
            chart.PlotArea.LineFormat.Width   = 1;
            chart.PlotArea.LineFormat.Visible = true;

            chart.Legend.Docking            = DockingType.Bottom;
            chart.Legend.LineFormat.Visible = true;

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add(filteredProfitExpenses.ConvertAll(o => o.dateTime.ToShortDateString()).ToArray());

            return(chart);
        }
Esempio n. 5
-1
 /// <summary>
 /// Adds a chart to the ChartFrame.
 /// </summary>
 public void Add(Chart chart)
 {
     if (_chartList == null)
         _chartList = new List<Chart>();
     _chartList.Add(chart);
 }
Esempio n. 6
-2
        private ChartFrame MapObject(DocumentObjectModel.Shapes.Charts.Chart domChart)
        {
            ChartFrame chartFrame = new ChartFrame();
            chartFrame.Size = new XSize(domChart.Width.Point, domChart.Height.Point);
            chartFrame.Location = new XPoint(domChart.Left.Position.Point, domChart.Top.Position.Point);

            Chart chart = new Chart((ChartType)domChart.Type);

            if (!domChart.IsNull("XAxis"))
                AxisMapper.Map(chart.XAxis, domChart.XAxis);
            if (!domChart.IsNull("YAxis"))
                AxisMapper.Map(chart.YAxis, domChart.YAxis);

            PlotAreaMapper.Map(chart.PlotArea, domChart.PlotArea);

            SeriesCollectionMapper.Map(chart.SeriesCollection, domChart.SeriesCollection);

            LegendMapper.Map(chart, domChart);

            chart.DisplayBlanksAs = (BlankType)domChart.DisplayBlanksAs;
            chart.HasDataLabel = domChart.HasDataLabel;
            if (!domChart.IsNull("DataLabel"))
                DataLabelMapper.Map(chart.DataLabel, domChart.DataLabel);

            if (!domChart.IsNull("Style"))
                FontMapper.Map(chart.Font, domChart.Document, domChart.Style);
            if (!domChart.IsNull("Format.Font"))
                FontMapper.Map(chart.Font, domChart.Format.Font);
            if (!domChart.IsNull("XValues"))
                XValuesMapper.Map(chart.XValues, domChart.XValues);

            chartFrame.Add(chart);
            return chartFrame;
        }
Esempio n. 7
-2
    /// <summary>
    /// Returns the chart renderer appropriate for the chart.
    /// </summary>
    private ChartRenderer GetChartRenderer(Chart chart, RendererParameters parms)
    {
      ChartType chartType = chart.Type;
      bool useCombinationRenderer = false;
      foreach (Series series in chart.seriesCollection)
      {
        if (series.chartType != chartType)
        {
          useCombinationRenderer = true;
          break;
        }
      }

      if (useCombinationRenderer)
        return new CombinationChartRenderer(parms);

      switch (chartType)
      {
        case ChartType.Line:
          return new LineChartRenderer(parms);

        case ChartType.Column2D:
        case ChartType.ColumnStacked2D:
          return new ColumnChartRenderer(parms);

        case ChartType.Bar2D:
        case ChartType.BarStacked2D:
          return new BarChartRenderer(parms);

        case ChartType.Area2D:
          return new AreaChartRenderer(parms);

        case ChartType.Pie2D:
        case ChartType.PieExploded2D:
          return new PieChartRenderer(parms);
      }

      return null;
    }