ChangeColor
更改主题配色方案中的颜色。
语法
expression.ChangeColor(nPos, oColor);
expression - 表示 ApiThemeColorScheme 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| nPos | 必需 | number | 将被更改的配色方案中的颜色位置。 | |
| oColor | 必需 | ApiUniColor | ApiRGBColor | 主题配色方案的新颜色。 |
返回值
boolean
示例
此示例更改主题配色方案中的颜色。
// How to get a color scheme of a theme and change its color.
// Get color scheme and update its colors.
const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const master = presentation.GetMaster(0);
const theme = master.GetTheme();
const colorScheme = theme.GetColorScheme();
colorScheme.ChangeColor(0, Api.CreateRGBColor(255, 111, 61));
colorScheme.ChangeColor(1, Api.CreateRGBColor(51, 51, 51));
const chart = Api.CreateChart("bar3D", [
[200, 240, 280],
[250, 260, 280]
], ["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016], 4051300, 2347595, 24);
chart.SetVerAxisTitle("USD In Hundred Thousands", 10);
chart.SetHorAxisTitle("Year", 11);
chart.SetLegendPos("bottom");
chart.SetShowDataLabels(false, false, true, false);
chart.SetTitle("Financial Overview", 20);
chart.SetSize(300 * 36000, 130 * 36000);
chart.SetPosition(608400, 1267200);
slide.AddObject(chart);