Class SettableChartGlobalizationSettings

SettableChartGlobalizationSettings class

Implementation of PivotGlobalizationSettings that supports user to set/change pre-defined texts.

public class SettableChartGlobalizationSettings : ChartGlobalizationSettings

Constructors

NameDescription
SettableChartGlobalizationSettings()The default constructor.

Methods

NameDescription
override GetAxisTitleName()Gets the name of Title for Axis.
override GetAxisUnitName(DisplayUnitType)Gets the Name of Axis Unit.
override GetChartTitleName()Gets the name of Chart Title.
override GetLegendDecreaseName()Gets the name of Decrease for Legend.
override GetLegendIncreaseName()Gets the name of increase for Legend.
override GetLegendTotalName()Gets the name of Total for Legend.
override GetOtherName()Gets the name of “Other” labels for Chart.
override GetSeriesName()Gets the name of Series in the Chart.
SetAxisTitleName(string)Sets the name of Title for Axis.
SetAxisUnitName(DisplayUnitType, string)Sets the Name of Axis Unit.
SetChartTitleName(string)Sets the name of Chart Title.
SetLegendDecreaseName(string)Sets the name of Decrease for Legend.
SetLegendIncreaseName(string)Sets the name of increase for Legend.
SetLegendTotalName(string)Sets the name of Total for Legend.
SetOtherName(string)Sets the name of “Other” labels for Chart.
SetSeriesName(string)Sets the name of Series in the Chart.

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using Aspose.Cells.Charts;
    using System;

    public class CellsClassSettableChartGlobalizationSettingsDemo
    {
        public static void Run()
        {
            // Create a new workbook for demonstration
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            try
            {
                // Create an instance of SettableChartGlobalizationSettings
                var settings = new SettableChartGlobalizationSettings();

                // Set custom globalization settings
                settings.SetSeriesName("Custom Series");
                settings.SetChartTitleName("Custom Chart Title");
                settings.SetLegendIncreaseName("Custom Increase");
                settings.SetLegendDecreaseName("Custom Decrease");

                // Create a custom GlobalizationSettings implementation
                workbook.Settings.GlobalizationSettings = new CustomGlobalizationSettings(settings);

                // Create a simple chart to demonstrate the settings
                worksheet.Cells["A1"].PutValue("Category");
                worksheet.Cells["A2"].PutValue("Q1");
                worksheet.Cells["A3"].PutValue("Q2");
                worksheet.Cells["B1"].PutValue("Value");
                worksheet.Cells["B2"].PutValue(100);
                worksheet.Cells["B3"].PutValue(200);

                int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
                Chart chart = worksheet.Charts[chartIndex];
                chart.NSeries.Add("B2:B3", true);
                chart.NSeries.CategoryData = "A2:A3";
                chart.Title.Text = "Demo Chart";

                Console.WriteLine("SettableChartGlobalizationSettings configured successfully");
                workbook.Save("SettableChartGlobalizationSettingsDemo.xlsx");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error working with SettableChartGlobalizationSettings: {ex.Message}");
            }
        }

        private class CustomGlobalizationSettings : GlobalizationSettings
        {
            private readonly SettableChartGlobalizationSettings _chartSettings;

            public CustomGlobalizationSettings(SettableChartGlobalizationSettings chartSettings)
            {
                _chartSettings = chartSettings;
            }

            // Implement required GlobalizationSettings methods here
            // that delegate to the SettableChartGlobalizationSettings instance
        }
    }
}

See Also