Class ChartFrame

ChartFrame class

Encapsulates the object that represents the frame object in a chart.

public class ChartFrame

Properties

NameDescription
virtual Area { get; }Gets the area.
virtual AutoScaleFont { get; set; }True if the text in the object changes font size when the object size changes. The default value is True.
Background { get; set; }(Obsolete.) Gets and sets the display mode of the background
BackgroundMode { get; set; }Gets and sets the display mode of the background
virtual Border { get; }Gets the border.
DefaultHeight { get; }Represents height of default position
DefaultWidth { get; }Represents width of default position
DefaultX { get; }Represents x of default position
DefaultY { get; }Represents y of default position
virtual Font { get; }Gets a Font object of the specified ChartFrame object.
virtual Height { get; set; }Gets or sets the height of frame in units of 1/4000 of the chart area.
virtual IsAutomaticSize { get; set; }Indicates whether the chart frame is automatic sized.
IsDefaultPosBeSet { get; }Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.
IsInnerMode { get; set; }Indicates whether the size of the plot area size includes the tick marks, and the axis labels. False specifies that the size shall determine the size of the plot area, the tick marks, and the axis labels.
Shadow { get; set; }True if the frame has a shadow.
ShapeProperties { get; }Gets the ShapeProperties object.
virtual TextFont { get; }(Obsolete.) Gets a Font object of the specified ChartFrame object.
virtual TextOptions { get; }Gets and sets the options of the text.
virtual Width { get; set; }Gets or sets the width of frame in units of 1/4000 of the chart area.
virtual X { get; set; }Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area.
virtual Y { get; set; }Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area.

Methods

NameDescription
virtual SetPositionAuto()Set position of the frame to automatic

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using Aspose.Cells.Charts;
    using Aspose.Cells.Drawing;
    using Aspose.Cells.Drawing.Texts;
    using System;
    using System.Drawing;

    public class ChartFrameDemo
    {
        public static void ChartFrameExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add sample data
            worksheet.Cells["A1"].PutValue("Category");
            worksheet.Cells["A2"].PutValue("A");
            worksheet.Cells["A3"].PutValue("B");
            worksheet.Cells["A4"].PutValue("C");
            worksheet.Cells["B1"].PutValue("Value");
            worksheet.Cells["B2"].PutValue(10);
            worksheet.Cells["B3"].PutValue(20);
            worksheet.Cells["B4"].PutValue(30);

            // Add a chart to the worksheet
            int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
            Chart chart = worksheet.Charts[chartIndex];

            // Add series to the chart
            chart.NSeries.Add("B2:B4", true);
            chart.NSeries.CategoryData = "A2:A4";

            // Access the chart frame
            ChartFrame chartFrame = chart.ChartArea;

            // Set properties of the chart frame
            chartFrame.IsInnerMode = false;
            chartFrame.AutoScaleFont = true;
            chartFrame.BackgroundMode = BackgroundMode.Transparent;
            chartFrame.IsAutomaticSize = true;
            chartFrame.X = 1000; // 1/4000 of the chart area
            chartFrame.Y = 1000; // 1/4000 of the chart area
            chartFrame.Width = 3000; // 1/4000 of the chart area
            chartFrame.Height = 2000; // 1/4000 of the chart area
            chartFrame.Shadow = true;

            // Access and modify the border of the chart frame
            Line border = chartFrame.Border;
            border.Color = Color.Red;
            border.Style = LineType.Solid;

            // Access and modify the area of the chart frame
            Area area = chartFrame.Area;
            area.ForegroundColor = Color.Yellow;
            area.BackgroundColor = Color.Blue;

            // Access and modify the font of the chart frame
            Aspose.Cells.Font font = chartFrame.TextFont;
            font.Name = "Arial";
            font.Size = 12;
            font.IsBold = true;
            font.Color = Color.Green;

            // Save the workbook
            workbook.Save("ChartFrameExample.xlsx");
            workbook.Save("ChartFrameExample.pdf");
        }
    }
}

See Also