Ejemplo n.º 1
0
        //internal ExcelBarChart(ExcelDrawings drawings, XmlNode node) :
        //    base(drawings, node/*, 1*/)
        //{
        //    SetChartNodeText("");
        //}
        //internal ExcelBarChart(ExcelDrawings drawings, XmlNode node, eChartType type) :
        //    base(drawings, node, type)
        //{
        //    SetChartNodeText("");

        //    SetTypeProperties(drawings, type);
        //}
        internal ExcelBarChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) :
            base(drawings, node, type, topChart, PivotTableSource)
        {
            SetChartNodeText("");

            SetTypeProperties(drawings, type);
        }
Ejemplo n.º 2
0
 internal ExcelChartSeries(ExcelChart chart, XmlNamespaceManager ns, XmlNode node, bool isPivot)
     : base(ns,node)
 {
     _ns = ns;
     _chart=chart;
     _node=node;
     _isPivot = isPivot;
     SchemaNodeOrder = new string[] { "view3D", "plotArea", "barDir", "grouping", "scatterStyle", "varyColors", "ser", "explosion", "dLbls", "firstSliceAng", "holeSize", "shape", "legend", "axId" };
     foreach(XmlNode n in node.SelectNodes("c:ser",ns))
     {
         ExcelChartSerie s;
         if (chart.ChartNode.LocalName == "scatterChart")
         {
             s = new ExcelScatterChartSerie(this, ns, n, isPivot);
         }
         else if (chart.ChartNode.LocalName == "lineChart")
         {
             s = new ExcelLineChartSerie(this, ns, n, isPivot);
         }
         else if (chart.ChartNode.LocalName == "pieChart" ||
                  chart.ChartNode.LocalName == "ofPieChart" ||
                  chart.ChartNode.LocalName == "pie3DChart" ||
                  chart.ChartNode.LocalName == "doughnutChart")                                                                       
         {
             s = new ExcelPieChartSerie(this, ns, n, isPivot);
         }
         else
         {
             s = new ExcelChartSerie(this, ns, n, isPivot);
         }
         _list.Add(s);
     }
 }
Ejemplo n.º 3
0
 internal ExcelDoughnutChart(ExcelChart topChart, XmlNode chartNode) :
     base(topChart, chartNode)
 {
     //SetPaths();
 }
Ejemplo n.º 4
0
 internal ExcelDoughnutChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) :
     base(drawings, node, type, topChart, PivotTableSource)
 {
     //SetPaths();
 }        
Ejemplo n.º 5
0
 internal ExcelLineChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) :
     base(drawings, node, type, topChart, PivotTableSource)
 {
     Smooth = false;
 }
Ejemplo n.º 6
0
 internal ExcelLineChart(ExcelChart topChart, XmlNode chartNode) :
     base(topChart, chartNode)
 {
 }
Ejemplo n.º 7
0
  internal ExcelChartPlotArea(XmlNamespaceManager ns, XmlNode node, ExcelChart firstChart)
     : base(ns,node)
 {
     _firstChart = firstChart;
 }
Ejemplo n.º 8
0
 internal ExcelScatterChart(ExcelChart topChart, XmlNode chartNode) :
     base(topChart, chartNode)
 {
     SetTypeProperties();
 }
Ejemplo n.º 9
0
 internal ExcelScatterChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) :
     base(drawings, node, type, topChart, PivotTableSource)
 {
     SetTypeProperties();
 }
Ejemplo n.º 10
0
 internal ExcelBarChart(ExcelChart topChart, XmlNode chartNode) : 
     base(topChart, chartNode)
 {
     SetChartNodeText(chartNode.Name);
 }
Ejemplo n.º 11
0
       private void CreateNewChart(ExcelDrawings drawings, eChartType type, ExcelChart topChart)
       {
           if (topChart == null)
           {
               XmlElement graphFrame = TopNode.OwnerDocument.CreateElement("graphicFrame", ExcelPackage.schemaSheetDrawings);
               graphFrame.SetAttribute("macro", "");
               TopNode.AppendChild(graphFrame); 
               graphFrame.InnerXml = string.Format("<xdr:nvGraphicFramePr><xdr:cNvPr id=\"{0}\" name=\"Chart 1\" /><xdr:cNvGraphicFramePr /></xdr:nvGraphicFramePr><xdr:xfrm><a:off x=\"0\" y=\"0\" /> <a:ext cx=\"0\" cy=\"0\" /></xdr:xfrm><a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"rId1\" />   </a:graphicData>  </a:graphic>",_id);
               TopNode.AppendChild(TopNode.OwnerDocument.CreateElement("clientData", ExcelPackage.schemaSheetDrawings));

               Package package = drawings.Worksheet._package.Package;
               UriChart = GetNewUri(package, "/xl/charts/chart{0}.xml");

               ChartXml = new XmlDocument();
               ChartXml.PreserveWhitespace = ExcelPackage.preserveWhitespace;
               LoadXmlSafe(ChartXml, ChartStartXml(type));

               // save it to the package
               Part = package.CreatePart(UriChart, "application/vnd.openxmlformats-officedocument.drawingml.chart+xml", _drawings._package.Compression);

               StreamWriter streamChart = new StreamWriter(Part.GetStream(FileMode.Create, FileAccess.Write));
               ChartXml.Save(streamChart);
               streamChart.Close();
               package.Flush();

               PackageRelationship chartRelation = drawings.Part.CreateRelationship(PackUriHelper.GetRelativeUri(drawings.UriDrawing, UriChart), TargetMode.Internal, ExcelPackage.schemaRelationships + "/chart");
               graphFrame.SelectSingleNode("a:graphic/a:graphicData/c:chart", NameSpaceManager).Attributes["r:id"].Value = chartRelation.Id;
               package.Flush();
               _chartNode = ChartXml.SelectSingleNode(string.Format("c:chartSpace/c:chart/c:plotArea/{0}", GetChartNodeText()), NameSpaceManager);
           }
           else
           {
               ChartXml = topChart.ChartXml;
               Part = topChart.Part;
               _plotArea = topChart.PlotArea;
               UriChart = topChart.UriChart;
               _axis = topChart._axis;

               XmlNode preNode = _plotArea.ChartTypes[_plotArea.ChartTypes.Count - 1].ChartNode;
               _chartNode = ((XmlDocument)ChartXml).CreateElement(GetChartNodeText(), ExcelPackage.schemaChart);
               preNode.ParentNode.InsertAfter(_chartNode, preNode);
               if (topChart.Axis.Length == 0)
               {
                   AddAxis();
               }
               string serieXML = GetChartSerieStartXml(type, int.Parse(topChart.Axis[0].Id), int.Parse(topChart.Axis[1].Id));
               _chartNode.InnerXml = serieXML;
           }
       }
Ejemplo n.º 12
0
       internal ExcelChart(ExcelChart topChart, XmlNode chartNode) :
           base(topChart._drawings, topChart.TopNode, "xdr:graphicFrame/xdr:nvGraphicFramePr/xdr:cNvPr/@name")
       {
           UriChart = topChart.UriChart;
           Part = topChart.Part;
           ChartXml = topChart.ChartXml;
           _plotArea = topChart.PlotArea;
           _chartNode = chartNode;

           InitChartLoad(topChart._drawings, chartNode);
       }
Ejemplo n.º 13
0
       internal ExcelChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) :
           base(drawings, node, "xdr:graphicFrame/xdr:nvGraphicFramePr/xdr:cNvPr/@name")
       {
           ChartType = type;
           CreateNewChart(drawings, type, topChart);

           Init(drawings, _chartNode);

           _chartSeries = new ExcelChartSeries(this, drawings.NameSpaceManager, _chartNode, PivotTableSource!=null);
           if (PivotTableSource != null) SetPivotSource(PivotTableSource);

           SetTypeProperties(drawings);
           if (topChart == null)
               LoadAxis();
           else
           {
               _axis = topChart.Axis;
               if (_axis.Length > 0)
               {
                   XAxis = _axis[0];
                   YAxis = _axis[1];
               }
           }
       }
Ejemplo n.º 14
0
 internal static ExcelChart GetNewChart(ExcelDrawings drawings, XmlNode drawNode, eChartType chartType, ExcelChart topChart, ExcelPivotTable PivotTableSource)
 {
      switch(chartType)
      {
          case eChartType.Pie:
          case eChartType.PieExploded:
          case eChartType.Pie3D:
          case eChartType.PieExploded3D:
              return new ExcelPieChart(drawings, drawNode, chartType, topChart, PivotTableSource);
          case eChartType.BarOfPie:
          case eChartType.PieOfPie:
              return new ExcelOfPieChart(drawings, drawNode, chartType, topChart, PivotTableSource);
          case eChartType.Doughnut:
          case eChartType.DoughnutExploded:
              return new ExcelDoughnutChart(drawings, drawNode, chartType, topChart, PivotTableSource);
          case eChartType.BarClustered:
          case eChartType.BarStacked:
          case eChartType.BarStacked100:
          case eChartType.BarClustered3D:
          case eChartType.BarStacked3D:
          case eChartType.BarStacked1003D:
          case eChartType.ConeBarClustered:
          case eChartType.ConeBarStacked:
          case eChartType.ConeBarStacked100:
          case eChartType.CylinderBarClustered:
          case eChartType.CylinderBarStacked:
          case eChartType.CylinderBarStacked100:
          case eChartType.PyramidBarClustered:
          case eChartType.PyramidBarStacked:
          case eChartType.PyramidBarStacked100:
          case eChartType.ColumnClustered:
          case eChartType.ColumnStacked:
          case eChartType.ColumnStacked100:
          case eChartType.Column3D:
          case eChartType.ColumnClustered3D:
          case eChartType.ColumnStacked3D:
          case eChartType.ColumnStacked1003D:
          case eChartType.ConeCol:
          case eChartType.ConeColClustered:
          case eChartType.ConeColStacked:
          case eChartType.ConeColStacked100:
          case eChartType.CylinderCol:
          case eChartType.CylinderColClustered:
          case eChartType.CylinderColStacked:
          case eChartType.CylinderColStacked100:
          case eChartType.PyramidCol:
          case eChartType.PyramidColClustered:
          case eChartType.PyramidColStacked:
          case eChartType.PyramidColStacked100:
              return new ExcelBarChart(drawings, drawNode, chartType, topChart, PivotTableSource);
          case eChartType.XYScatter:
          case eChartType.XYScatterLines:
          case eChartType.XYScatterLinesNoMarkers:
          case eChartType.XYScatterSmooth:
          case eChartType.XYScatterSmoothNoMarkers:
              return new ExcelScatterChart(drawings, drawNode, chartType, topChart, PivotTableSource);
          case eChartType.Line:
          case eChartType.Line3D:
          case eChartType.LineMarkers:
          case eChartType.LineMarkersStacked:
          case eChartType.LineMarkersStacked100:
          case eChartType.LineStacked:
          case eChartType.LineStacked100:
              return new ExcelLineChart(drawings, drawNode, chartType, topChart, PivotTableSource);
          default:
              return new ExcelChart(drawings, drawNode, chartType, topChart, PivotTableSource);
      }
  }
Ejemplo n.º 15
0
 internal static ExcelChart GetChart(XmlElement chartNode, ExcelDrawings drawings, XmlNode node,  Uri uriChart, PackagePart part, XmlDocument chartXml, ExcelChart topChart)
 {
     switch (chartNode.LocalName)
     {
         case "area3DChart":
         case "areaChart":
         case "bubbleChart":
         case "radarChart":
         case "surface3DChart":
         case "surfaceChart":
         case "stockChart":
             if (topChart == null)
             {
                 return new ExcelChart(drawings, node, uriChart, part, chartXml, chartNode);
             }
             else
             {
                 return new ExcelChart(topChart, chartNode);
             }
         case "barChart":
         case "bar3DChart":
             if (topChart == null)
             {
                 return new ExcelBarChart(drawings, node, uriChart, part, chartXml, chartNode);
             }
             else
             {
                 return new ExcelBarChart(topChart, chartNode);
             }
         case "doughnutChart":
             if (topChart == null)
             {
                 return new ExcelDoughnutChart(drawings, node, uriChart, part, chartXml, chartNode);
             }
             else
             {
                 return new ExcelDoughnutChart(topChart, chartNode);
             }
         case "pie3DChart":
         case "pieChart":
             if (topChart == null)
             {
                 return new ExcelPieChart(drawings, node, uriChart, part, chartXml, chartNode);
             }
             else
             {
                 return new ExcelPieChart(topChart, chartNode);
             }
     case "ofPieChart":
             if (topChart == null)
             {
                 return new ExcelOfPieChart(drawings, node, uriChart, part, chartXml, chartNode);
             }
             else
             {
                 return new ExcelBarChart(topChart, chartNode);
             }
         case "lineChart":
         case "line3DChart":
             if (topChart == null)
             {
                 return new ExcelLineChart(drawings, node, uriChart, part, chartXml, chartNode);
             }
             else
             {
                 return new ExcelLineChart(topChart, chartNode);
             }
         case "scatterChart":
             if (topChart == null)
             {
                 return new ExcelScatterChart(drawings, node, uriChart, part, chartXml, chartNode);
             }
             else
             {
                 return new ExcelScatterChart(topChart, chartNode);
             }
         default:
             return null;
     }       
 }
Ejemplo n.º 16
0
  internal ExcelChartLegend(XmlNamespaceManager ns, XmlNode node, ExcelChart chart)
     : base(ns,node)
 {
     _chart=chart;
     SchemaNodeOrder = new string[] { "legendPos", "layout","overlay", "txPr", "bodyPr", "lstStyle", "spPr" };
 }