Summary description for ChartTitle.
Inheritance: IContent, IContentContainer
コード例 #1
0
        /// <summary>
        /// create the chart title
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private IContent CreateChartTitle(XElement node)
        {
            try
            {
                ChartTitle title = new ChartTitle(Chart.Document, node)
                {
                    Chart = Chart
                };
                Chart.ChartTitle = title;
                //title.Node                   = node;
                ChartStyleProcessor csp       = new ChartStyleProcessor(Chart);
                XElement            nodeStyle = csp.ReadStyleNode(title.StyleName);
                IStyle            style       = csp.ReadStyle(nodeStyle, "title");
                ContentCollection iColl       = new ContentCollection();

                if (style != null)
                {
                    title.Style = style;
                    Chart.Styles.Add(style);
                }

                foreach (XElement nodeChild in title.Node.Elements())
                {
                    IContent icontent = CreateContent(nodeChild);

                    if (icontent != null)
                    {
                        AddToCollection(icontent, iColl);
                    }
                }

                title.Node.Value = "";

                foreach (IContent icontent in iColl)
                {
                    AddToCollection(icontent, title.Content);
                }

                return(title);
            }

            catch (Exception ex)
            {
                throw new AODLException("Exception while creating the chart title!", ex);
            }
        }
コード例 #2
0
 public void New()
 {
     IsNewed = true;
     LoadBlankContent();
     LoadBlankStyles();
     InitStandards();
     ChartLegend = new ChartLegend(this, "ch2");
     ChartTitle  = new ChartTitle(this, "ch3");
     ChartTitle.InitTitle();
     Content.Add(ChartTitle);
     ChartPlotArea = new ChartPlotArea(this, "ch4");
     if (Frame == null)
     {
         Frame = new Frame(Document, "gr1");
         //this.CreateParentNode (null);
         Frame.Content.Add(this);
     }
     InitChart();
 }
コード例 #3
0
        public void NewBasicChartThenSetTitle()
        {
            string expected="Basic Chart";
            SpreadsheetDocument doc = new SpreadsheetDocument();
            doc.New();
            Table table = new Table(doc, "tab1", "tab1");

            for (int i = 1; i <= 1; i++)
            {
                for (int j = 1; j <= 6; j++)
                {
                    Cell cell = table.CreateCell();
                    cell.OfficeValueType = "float";
                    Paragraph paragraph = new Paragraph(doc);
                    string text = (j + i - 1).ToString();
                    paragraph.TextContent.Add(new SimpleText(doc, text));
                    cell.Content.Add(paragraph);
                    cell.OfficeValueType = "string";
                    cell.OfficeValue = text;
                    table.InsertCellAt(i, j, cell);
                }
            }
            Chart basicChart = ChartBuilder.CreateChart(table, ChartTypes.line, "A4:F8");
            ChartTitle ct = new ChartTitle(basicChart);
            //ct.InitTitle();
            ct.SetTitle(expected);
            Assert.AreEqual(expected, ((Paragraph)ct.Content[0]).TextContent[0].Text);
            basicChart.ChartTitle = ct;
            IContent chartTitleContent = null;
            chartTitleContent=basicChart.Content.Find(o => o is ChartTitle);
            if (chartTitleContent == null)
            {
                foreach (IContent iContent in basicChart.Content)
                {
                    if (iContent is ChartTitle) chartTitleContent = iContent;
                }
            }
            Assert.AreEqual(expected, ((Paragraph)((ChartTitle)chartTitleContent).Content[0]).TextContent[0].Text);
            table.InsertChartAt("H2", basicChart);
            doc.TableCollection.Add(table);
            doc.SaveTo(Path.Combine(AARunMeFirstAndOnce.outPutFolder,"BasicChartWithTitlesetafterwards.ods"));
        }
コード例 #4
0
		/// <summary>
		/// create the chart title
		/// </summary>
		/// <param name="node"></param>
		/// <returns></returns>
		private IContent CreateChartTitle(XmlNode node)
		{
			try
			{
				ChartTitle title             = new ChartTitle (this.Chart.Document ,node);
				title.Chart                  = this.Chart ;
				this.Chart .ChartTitle       =title;
				//title.Node                   = node;
				ChartStyleProcessor csp      = new ChartStyleProcessor (this.Chart );
				XmlNode nodeStyle            = csp.ReadStyleNode(title .StyleName);
				IStyle style                 = csp.ReadStyle (nodeStyle,"title");
				ContentCollection iColl     = new ContentCollection ();

				if ( style!= null)
				{
					title.Style =style;
					this.Chart .Styles .Add (style);
				}

				foreach(XmlNode nodeChild in title.Node .ChildNodes )
				{
					IContent icontent       = CreateContent(nodeChild);

					if (icontent!= null)
						AddToCollection(icontent,iColl);
				}

				title.Node.InnerXml  ="";

				foreach(IContent icontent in iColl)
				{
					AddToCollection(icontent,title.Content );
				}
				
				return title;
			}

			catch(Exception ex)
			{
				throw new AODLException("Exception while creating the chart title!", ex);
			}
		}