将图表转换为针对日本地区的图像
Contents
[
Hide
]
在本主题中,我们将向您展示如何为图表设置日本地区。
定义继承类
首先,您需要定义一个从ChartGlobalizationSettings继承的类"ChartJapaneseSetttings"。 然后,通过重写相关函数,您可以将图表元素的文本设置为您自己的语言。 代码示例:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using Aspose.Cells.Charts; | |
namespace ChartGlobalizationSettingsTest | |
{ | |
public class ChartJapaneseSetttings: ChartGlobalizationSettings | |
{ | |
public override string GetAxisTitleName() | |
{ | |
return "軸タイトル"; | |
} | |
public override string GetAxisUnitName(DisplayUnitType type) | |
{ | |
switch (type) | |
{ | |
case DisplayUnitType.None: | |
return string.Empty; | |
case DisplayUnitType.Hundreds: | |
return "百"; | |
case DisplayUnitType.Thousands: | |
return "千"; | |
case DisplayUnitType.TenThousands: | |
return "万"; | |
case DisplayUnitType.HundredThousands: | |
return "10万"; | |
case DisplayUnitType.Millions: | |
return "百万"; | |
case DisplayUnitType.TenMillions: | |
return "千万"; | |
case DisplayUnitType.HundredMillions: | |
return "億"; | |
case DisplayUnitType.Billions: | |
return "10億"; | |
case DisplayUnitType.Trillions: | |
return "兆"; | |
default: | |
return string.Empty; | |
} | |
} | |
public override string GetChartTitleName() | |
{ | |
return "グラフ タイトル"; | |
} | |
public override string GetLegendDecreaseName() | |
{ | |
return "削減"; | |
} | |
public override string GetLegendIncreaseName() | |
{ | |
return "ぞうか"; | |
} | |
public override string GetLegendTotalName() | |
{ | |
return "すべての"; | |
} | |
public override string GetOtherName() | |
{ | |
return "その他"; | |
} | |
public override string GetSeriesName() | |
{ | |
return "シリーズ"; | |
} | |
} | |
} |
为图表配置日本设置
在这一步中,您将使用在上一步中定义的"ChartJapaneseSetttings"类。 代码示例:
Workbook wb = new Workbook("Japanese.xls");
wb.Settings.GlobalizationSettings.ChartSettings = new ChartJapaneseSetttings();
Chart chart0 = wb.Worksheets[0].Charts[0];
chart0.ToImage("Output.png");
然后,您可以在输出图像中看到效果,图表中的元素将根据您的设置进行渲染。
结论
在此示例中,如果不为图表设置日本地区,则以下图表元素可能以默认语言(如英文)呈现。 在上述操作后,我们可以获得一个具有日本区域的输出图表图片。
支持的元素 | 本示例中的值 | 英文环境中的默认值 |
---|---|---|
轴标题名称 | 軸タイトル | Axis Title |
轴单位名称 | 百,千… | Hundreds, Thousands… |
图表标题名称 | グラフ タイトル | Chart Title |
图例增加名称 | ぞうか | Increase |
图例减少名称 | 削減 | Decrease |
图例总数名称 | すべての | Total |
其它名称 | その他 | Other |
系列名称 | シリーズ | Series |