Пример #1
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);
     }
 }
Пример #2
0
       private ExcelChartSerie AddSeries(string SeriesAddress, string XSeriesAddress)
        {
               XmlElement ser = _node.OwnerDocument.CreateElement("ser", ExcelPackage.schemaChart);
               XmlNodeList node = _node.SelectNodes("c:ser", _ns);
               if (node.Count > 0)
               {
                   _node.InsertAfter(ser, node[node.Count-1]);
               }
               else
               {
                   InserAfter(_node, "c:varyColors,c:grouping,c:barDir,c:scatterStyle", ser);
                }
               int idx = FindIndex();
               ser.InnerXml = string.Format("<c:idx val=\"{1}\" /><c:order val=\"{1}\" /><c:tx><c:strRef><c:f></c:f><c:strCache><c:ptCount val=\"1\" /></c:strCache></c:strRef></c:tx>{5}{0}{2}{3}{4}", AddExplosion(Chart.ChartType), idx, AddScatterPoint(Chart.ChartType), AddAxisNodes(Chart.ChartType), AddSmooth(Chart.ChartType), AddMarker(Chart.ChartType));
               ExcelChartSerie serie;
               switch (Chart.ChartType)
               {
                   case eChartType.XYScatter:
                   case eChartType.XYScatterLines:
                   case eChartType.XYScatterLinesNoMarkers:
                   case eChartType.XYScatterSmooth:
                   case eChartType.XYScatterSmoothNoMarkers:
                       serie = new ExcelScatterChartSerie(this, NameSpaceManager, ser, _isPivot);
                       break;
                   case eChartType.Pie:
                   case eChartType.Pie3D:
                   case eChartType.PieExploded:
                   case eChartType.PieExploded3D:
                   case eChartType.PieOfPie:
                   case eChartType.Doughnut:
                   case eChartType.DoughnutExploded:
                   case eChartType.BarOfPie:
                       serie = new ExcelPieChartSerie(this, NameSpaceManager, ser, _isPivot);
                       break;
                   case eChartType.Line:
                   case eChartType.LineMarkers:
                   case eChartType.LineMarkersStacked:
                   case eChartType.LineMarkersStacked100:
                   case eChartType.LineStacked:
                   case eChartType.LineStacked100:
                       serie = new ExcelLineChartSerie(this, NameSpaceManager, ser, _isPivot);
                       if (Chart.ChartType == eChartType.LineMarkers ||
                           Chart.ChartType == eChartType.LineMarkersStacked ||
                           Chart.ChartType == eChartType.LineMarkersStacked100)
                       {
                           ((ExcelLineChartSerie)serie).Marker = eMarkerStyle.Square;
                       }
                       ((ExcelLineChartSerie)serie).Smooth = ((ExcelLineChart)Chart).Smooth;
                       break;

                   default:
                       serie = new ExcelChartSerie(this, NameSpaceManager, ser, _isPivot);
                       break;
               }               
               serie.Series = SeriesAddress;
               serie.XSeries = XSeriesAddress;               
           _list.Add(serie);
               return serie;
        }