SettableChartGlobalizationSettings.SetAxisUnitName
SettableChartGlobalizationSettings.SetAxisUnitName method
Sets the Name of Axis Unit.
public void SetAxisUnitName(DisplayUnitType type, string name)
| Parameter | Type | Description |
|---|---|---|
| type | DisplayUnitType | The unit type for displaying axis labels. |
| name | String | local dependent name |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Charts;
using System;
public class SettableChartGlobalizationSettingsMethodSetAxisUnitNameWithDisplayUnitTypeStringDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add minimal data for context
worksheet.Cells["A1"].Value = "Sample Data";
try
{
// Create an instance of SettableChartGlobalizationSettings
SettableChartGlobalizationSettings settings = new SettableChartGlobalizationSettings();
// Set custom axis unit names for different display unit types
settings.SetAxisUnitName(DisplayUnitType.Thousands, "K");
settings.SetAxisUnitName(DisplayUnitType.Millions, "M");
settings.SetAxisUnitName(DisplayUnitType.Percentage, "Pct");
// Verify the settings by retrieving the values
string thousandsUnit = settings.GetAxisUnitName(DisplayUnitType.Thousands);
string millionsUnit = settings.GetAxisUnitName(DisplayUnitType.Millions);
string percentageUnit = settings.GetAxisUnitName(DisplayUnitType.Percentage);
// Display the results
Console.WriteLine($"Thousands unit name set to: {thousandsUnit}");
Console.WriteLine($"Millions unit name set to: {millionsUnit}");
Console.WriteLine($"Percentage unit name set to: {percentageUnit}");
// Save the workbook
workbook.Save("SetAxisUnitNameDemo.xlsx");
Console.WriteLine("SetAxisUnitName method called successfully. Workbook saved.");
}
catch (Exception ex)
{
Console.WriteLine($"Error calling SetAxisUnitName: {ex.Message}");
}
}
}
}
See Also
- enum DisplayUnitType
- class SettableChartGlobalizationSettings
- namespace Aspose.Cells
- assembly Aspose.Cells