Charts — typed helpers
The same chart power behind type-safe entry points — addBarChart, addPieChart, addLineChart… — with option classes specialised per chart family.
DemoChartByChartType
Source file Modules/DemoChartByChartType.cs
Slide methods genSlide01 – 21 · devSlide01 – 07
Output files chart_genSlide*.pptx
1Overview
DemoChartByChartType mirrors the generic DemoChart slide by slide, but every chart is created through a typed helper: slide.addBarChart(data, BarChartOpts), slide.addPieChart(data, PieChartOpts) and so on.
The family-specific option classes break the monolithic ChartOpts into focused objects: BarChartOpts carries flat position (x/y/w/h), titleProps (ChartPropsTitle) and axisCat/axisVal (ChartPropsAxisCat/Val); PieChartOpts adds legendProps, leader lines and data labels.
2Demo methods
| Method | What it demonstrates |
|---|---|
| genSlide01 | Typed bar chart — BarChartOpts with title and axis objects. |
| genSlide02_BarChart | Typed bar — various designs. |
| genSlide03_BarChart | Typed bar — axis, dataLabel and grid options. |
| genSlide04_BarChart | Typed bar — stacked series. |
| genSlide05_BarChart | Typed bar — series colors, majorUnits, format code. |
| genSlide06_Bat3dChart | Typed 3D bar chart. |
| genSlide07_BarChart | Typed bar — tornado chart. |
| genSlide08_LineChart | Typed line chart. |
| genSlide09_LineChart | Typed line — smoothing, line size, symbol size. |
| genSlide10_LineChart | Typed line — data symbols and symbol size. |
| genSlide11_AreaChart | Typed area chart. |
| genSlide12_PieChart | Typed pie chart — PieChartOpts (legend, labels). |
| genSlide13_DoughnutChart | Typed doughnut chart. |
| genSlide14_ScatterChart | Typed XY scatter chart. |
| genSlide15_BubbleChart | Typed bubble chart. |
| genSlide16_RadarChart | Typed radar chart. |
| genSlide17 | Multi-level category axis (2 levels). |
| genSlide18_BarChart | Multi-level category axis (3 levels). |
| genSlide19 | Combo chart — typed series mixing. |
| genSlide20 | Combo — series-level options. |
| genSlide21 | Misc options — shadow and transparent colors. |
| devSlide01 | DEV — bar chart with many series. |
| devSlide02 | DEV — line chart with many series. |
| devSlide03 | DEV — escaped-XML label rendering. |
| devSlide04 | DEV — combo chart stress cases. |
| devSlide05_DoughnutChart | DEV — doughnut reference checks. |
| devSlide06_BarChart | DEV — legacy regression tests. |
| devSlide07_BarChart | DEV — title options and inverted colors. |
3Code samples
Typed bar chart options BarChartOpts: flat x/y/w/h position, titleProps and axisCat/axisVal. DemoChartByChartType.cs · genSlide01
}, Constants.BASE_TABLE_OPTS);
// Chart options
var barChartOption = new BarChartOpts
{
barDir = BarDirection.col, // "col",
barGrouping = ChartBarGrouping.stacked,
chartColors = Constants.COLORS_CHART,
invertedColors = new List<string> { "C0504D" },
showLegend = true,
showTitle = true,
// title options
//titleRotate = 10,
};
barChartOption.x = 0.5;
barChartOption.y = 0.5;
barChartOption.w = "90%";
barChartOption.h = "90%";
barChartOption.titleProps = new ChartPropsTitle
{
title = "Chart Title",
titleFontFace = "Helvetica Neue Thin",
titleFontSize = 24,
titleColor = Constants.COLORS_ACCENT[0],
titlePos = new PositionXY { x = 1.5, y = 0 },
//titleRotate = 10,
};
barChartOption.axisCat = new ChartPropsAxisCat
{
// Category axis options
showCatAxisTitle = true,
catAxisLabelColor = Constants.COLORS_ACCENT[1],
catAxisTitleColor = Constants.COLORS_ACCENT[1],
catAxisTitle = "Cat Axis Title",
catAxisTitleFontSize = 14
};
barChartOption.axisVal = new ChartPropsAxisVal
{
// Value axis options
showValAxisTitle = true,
valAxisLabelColor = Constants.COLORS_ACCENT[2],
valAxisTitleColor = Constants.COLORS_ACCENT[2],
valAxisTitle = "Val Axis Title",
valAxisTitleFontSize = 14
};
// Add bar chart
slide.addBarChart(Constants.dataChartBar8Series, barChartOption);
}
/// <summary>
/// 使用 <see cref="BarChartOpts"/> 增加 bar 的图表
Typed pie chart options addPieChart + PieChartOpts: chartArea, legendProps, leader lines, data labels. DemoChartByChartType.cs · genSlide12_PieChart
slide.addPieChart(Constants.dataChartPieStat, new PieChartOpts
{
// position = new PositionProps(0.5, 0.6, 4.0, 3.2),
x = 0.5,
y = 0.6,
w = 4.0,
h = 3.2,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
chartColors = Constants.COLORS_RYGU,
dataBorder = new BorderProps("F1F1F1", null, 2),
legendProps = new ChartPropsLegend
{
//
legendPos = LegendPosition.l,
legendFontFace = "Courier New",
},
showLegend = true,
//
showLeaderLines = true,
showPercent = false,
showValue = true,
dataLabel = new ChartPropsDataLabel
{
dataLabelColor = "FFFFFF",
dataLabelFontSize = 14,
dataLabelPosition = DataLabelPosition.bestFit // "bestFit", // 'bestFit' | 'outEnd' | 'inEnd' | 'ctr'
}
});
Typed bar — various designs Horizontal/vertical bars via BarChartOpts with axisCat/axisVal. DemoChartByChartType.cs · genSlide02_BarChart
// TOP-LEFT: Horizontal bar chart (typed BarChartOpts)
var optsChartBar1 = new BarChartOpts
{
chartArea = new ChartAreaProps { border = new BorderProps(Constants.COLORS_SPECTRUM[0], null, 1) },
plotArea = new ChartPropsFillLine { fill = "DAE3F3" },
chartColors = Constants.COLORS_SPECTRUM,
objectName = "bar chart (top L)",
altText = "this is the alt text content",
barDir = BarDirection.bar,
x = 0.5, y = 0.6, w = 6, h = 3,
axisCat = new ChartPropsAxisCat
{
catAxisLabelColor = Constants.COLORS_ACCENT[0],
catAxisLabelFontFace = "Helvetica Neue",
catAxisMajorTickMark = ChartAxisTickMark.@in,
},
axisVal = new ChartPropsAxisVal
{
valAxisMajorTickMark = ChartAxisTickMark.cross,
}
};
slide.addBarChart(arrDataSersCats, optsChartBar1);
Typed bar — axis, dataLabel, grid BarChartOpts axisCat/axisVal, grid lines and dataLabel formatting. DemoChartByChartType.cs · genSlide03_BarChart
// TOP-LEFT: Horizontal bar — axis/grid (typed BarChartOpts)
var optsChartBar1 = new BarChartOpts
{
x = 0.5, y = 0.6, w = 6, h = 3,
barDir = BarDirection.bar,
plotArea = new ChartPropsFillLine { fill = "F1F1F1" },
chartColors = Constants.COLORS_ACCENT,
axisCat = new ChartPropsAxisCat {
catAxisLabelColor = "CC0000",
catAxisLabelFontFace = "Helvetica Neue",
catAxisLabelFontSize = 14,
catGridLine = new OptsChartGridLine { style = GridLineStyle.none },
catAxisHidden = true,
},
axisVal = new ChartPropsAxisVal
{
valGridLine = new OptsChartGridLine { color = "cc6699", style = GridLineStyle.dash, size = 1 },
valAxisLineColor = "44AA66",
},
showLegend = true,
showTitle = true,
titleProps = new ChartPropsTitle { title = "catAxisHidden:true, valGridLine/valAxisLine:dash" }
};
slide.addBarChart(arrDataRegions, optsChartBar1);
Typed bar — stacked series BarChartOpts stacked/percentStacked with data table and invertedColors. DemoChartByChartType.cs · genSlide04_BarChart
// TOP-LEFT: Horizontal stacked bar (typed BarChartOpts)
var optsChartBar1 = new BarChartOpts
{
x = 0.5, y = 0.6, w = 6, h = 3,
chartArea = new ChartAreaProps { fill = "404040" },
plotArea = new ChartPropsFillLine { fill = "0d0d0d" },
barDir = BarDirection.bar,
barGrouping = ChartBarGrouping.stacked,
chartColors = new List<string> { "F2AF00", "4472C4" },
axisCat = new ChartPropsAxisCat
{
catAxisOrientation = "maxMin",
catAxisLabelColor = "4472C4",
catAxisLabelFontFace = "Helvetica Neue",
catAxisLabelFontSize = 14,
},
dataLabel = new ChartPropsDataLabel { dataLabelColor = "FFFFFF" },
showValue = true
};
slide.addBarChart(arrDataRegions, optsChartBar1);
Typed bar — colors & format Multi-color bars, catLabelFormatCode and valAxisLabelFormatCode. DemoChartByChartType.cs · genSlide05_BarChart
// TOP-LEFT: Multi-color bars with date formatting (typed BarChartOpts)
slide.addBarChart(
new List<OptsChartData> {
new OptsChartData{
name = "Excel Date Values",
labels = new List<List<string>> { new List<string> { "37987", "38018", "38047", "38078", "38108", "38139" } },
values = new List<double?> { 20, 30, 10, 25, 15, 5 }
}
},
new BarChartOpts
{
x = 0.5, y = 0.6, w = "45%", h = 3,
chartArea = new ChartAreaProps { fill = "404040" },
barDir = BarDirection.bar,
chartColors = new List<string> { "0077BF", "4E9D2D", "ECAA00", "5FC4E3", "DE4216", "154384" },
axisCat = new ChartPropsAxisCat { catAxisLabelColor = "F1F1F1", catLabelFormatCode = "yyyy-mm" },
axisVal = new ChartPropsAxisVal { valAxisHidden = true },
showTitle = true,
titleProps = new ChartPropsTitle { title = "Categories can be Multi-Color", titleColor = "0088CC", titleFontSize = 14 }
}
);
Typed bar 3D Bar3dChartOpts with cylinder shape and v3D rotation. DemoChartByChartType.cs · genSlide06_Bat3dChart
// TOP-LEFT: Horizontal 3D bar (typed Bar3dChartOpts)
var optsChartBar1 = new Bar3dChartOpts
{
x = 0.5, y = 0.6, w = 6.0, h = 3,
chartArea = new ChartAreaProps { fill = new ShapeFillProps("F1F1F1", 50) },
barDir = BarDirection.bar,
barGapWidthPct = 25,
chartColors = Constants.COLORS_SPECTRUM,
chartColorsOpacity = 80,
v3DRotX = 20, v3DRotY = 10, v3DRAngAx = false,
axisCat = new ChartPropsAxisCat
{
catAxisLabelColor = Constants.COLORS_SPECTRUM[1],
catAxisLabelFontFace = "Arial",
catAxisLabelFontSize = 10,
},
axisSer = new ChartPropsAxisSer
{
serAxisLabelFontFace = "Arial",
serAxisLabelFontSize = 10,
}
};
slide.addBar3dChart(arrDataRegions, optsChartBar1);
Typed bar — tornado Diverging stacked bar via BarChartOpts with invertedColors. DemoChartByChartType.cs · genSlide07_BarChart
// Tornado (diverging) bar — typed BarChartOpts
slide.addBarChart(
new List<OptsChartData> {
new OptsChartData{ name = "High", labels = new List<List<string>> { new List<string> { "London", "Munich", "Tokyo" } }, values = new List<double?> { 0.2, 0.32, 0.41 } },
new OptsChartData{ name = "Low", labels = new List<List<string>> { new List<string> { "London", "Munich", "Tokyo" } }, values = new List<double?> { -0.11, -0.22, -0.29 } }
},
new BarChartOpts
{
x = 0.5, y = 0.5, w = "90%", h = "90%",
chartArea = new ChartAreaProps { fill = new ShapeFillProps("F1F1F1", 50) },
axisVal = new ChartPropsAxisVal { valAxisMaxVal = 1, valAxisLineShow = false, valAxisMajorUnit = 0.2 },
axisCat = new ChartPropsAxisCat { catAxisLineShow = false, catAxisLabelPos = CatAxisLabelPos.low },
barDir = BarDirection.bar,
barGrouping = ChartBarGrouping.stacked,
shadow = new ShadowProps { type = ShadowType.none },
chartColors = new List<string> { "0077BF", "4E9D2D", "ECAA00", "5FC4E3", "DE4216", "154384" },
invertedColors = new List<string> { "0065A2", "428526", "C99100", "51A7C1", "BD3813", "123970" },
barGapWidthPct = 25,
}
);
Typed line chart LineChartOpts with legend, rotated labels and lineSize. DemoChartByChartType.cs · genSlide08_LineChart
// FULL SLIDE: line chart (typed LineChartOpts)
var OPTS_CHART = new LineChartOpts
{
x = 0.5, y = 0.6, w = "95%", h = "85%",
plotArea = new ChartPropsFillLine { fill = "e3e3e3" },
showLegend = true,
legendProps = new ChartPropsLegend { legendPos = LegendPosition.r },
axisCat = new ChartPropsAxisCat { catAxisLabelRotate = 90 },
axisVal = new ChartPropsAxisVal { valAxisLabelFormatCode = "#,##0" },
lineSize = 4,
lineDataSymbolSize = 10,
lineDataSymbolLineColor = "4472C4",
lineDataSymbolLineSize = 3,
chartColors = [COLOR_GRN],
showTitle = true,
titleProps = new ChartPropsTitle { title = CHART_DATA.Fedi_MAU.chartTitle, titleColor = "0088CC", titleFontFace = "Arial", titleFontSize = 18 }
};
slide.addLineChart(Constants.CHART_DATA.Fedi_MAU.chartData, OPTS_CHART);
Typed line — smoothing & symbols LineChartOpts lineSmooth, lineSize and legend. DemoChartByChartType.cs · genSlide09_LineChart
// Top-left: Smooth line with thick line size (typed LineChartOpts)
var optsChartLine1 = new LineChartOpts
{
x = 0.5, y = 0.6, w = 6, h = 3,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
chartColors = Constants.COLORS_RYGU,
lineSize = 8,
lineSmooth = true,
showLegend = true,
legendProps = new ChartPropsLegend { legendPos = LegendPosition.t },
axisCat = new ChartPropsAxisCat { catAxisLabelPos = CatAxisLabelPos.high }
};
slide.addLineChart(Constants.arrDataLineStat, optsChartLine1);
Typed line — lineDataSymbol Loop over LineChartOpts.lineDataSymbol shapes. DemoChartByChartType.cs · genSlide10_LineChart
// Loop over lineDataSymbol shapes (typed LineChartOpts)
var opts_lineDataSymbol = new List<string> { "circle", "dash", LineDataSymbolType.diamond.ToString().ToLower(), "dot", "none", LineDataSymbolType.square.ToString().ToLower(), "triangle" };
for (int idx = 0; idx < opts_lineDataSymbol.Count; idx++)
{
var opt = opts_lineDataSymbol[idx];
slide.addLineChart(Constants.arrDataLineStat, new LineChartOpts
{
x = (idx < 3 ? idx * intWgap : idx < 6 ? (idx - 3) * intWgap : (idx - 6) * intWgap) + 0.3,
y = idx < 3 ? 0.5 : idx < 6 ? 2.85 : 5.1,
w = 4.25, h = 2.25,
lineCap = ChartLineCap.round,
lineDataSymbol = Enum.Parse<LineDataSymbolType>(opt, true),
lineDataSymbolSize = idx == 5 ? 9 : idx == 6 ? 12 : null,
chartColors = Constants.COLORS_VIVID,
titleProps = new ChartPropsTitle { title = opt },
showTitle = true
});
}
Typed area chart AreaChartOpts with plotArea fill and axis formats. DemoChartByChartType.cs · genSlide11_AreaChart
// TOP-LEFT: Basic area chart (typed AreaChartOpts)
var optsChartLine1 = new AreaChartOpts
{
x = 0.5, y = 0.6, w = "45%", h = 3.0,
chartArea = new ChartAreaProps { fill = "e9e9e9" },
plotArea = new ChartPropsFillLine { fill = "f2f9fc" },
dataBorder = new BorderProps("F1F1F1", null, 1),
showTitle = true,
titleProps = new ChartPropsTitle { title = Constants.CHART_DATA.CeoPayRatio_Comp.chartTitle, titleFontSize = 11, titleColor = "fc0000" },
axisVal = new ChartPropsAxisVal { valAxisLabelFormatCode = "#-1", valAxisLabelFontSize = 10, valAxisLabelColor = "494949" },
axisCat = new ChartPropsAxisCat { catAxisLabelFontSize = 10 }
};
slide.addAreaChart(Constants.CHART_DATA.CeoPayRatio_Comp.chartData, optsChartLine1);
Typed doughnut chart DoughnutChartOpts holeSize, legendProps and data labels. DemoChartByChartType.cs · genSlide13_DoughnutChart
// TOP-LEFT: Doughnut chart (typed DoughnutChartOpts)
var optsChartPie1 = new DoughnutChartOpts
{
x = 0.5, y = 0.6, w = 6, h = 6.4,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
holeSize = 70,
showLabel = false, showValue = false, showPercent = true,
showLegend = true,
legendProps = new ChartPropsLegend { legendPos = LegendPosition.b },
chartColors = Constants.COLORS_RYGU,
dataBorder = new BorderProps("F1F1F1", null, 2),
dataLabel = new ChartPropsDataLabel { dataLabelColor = "FFFFFF", dataLabelFontSize = 14 },
showTitle = false,
titleProps = new ChartPropsTitle { title = "Project Status", titleColor = "33CF22", titleFontFace = "Helvetica Neue", titleFontSize = 24 }
};
slide.addDougnutChart(Constants.dataChartPieStat, optsChartPie1);
Typed XY scatter ScatterChartOpts with axis titles and data labels. DemoChartByChartType.cs · genSlide14_ScatterChart
// TOP-LEFT: XY scatter (typed ScatterChartOpts)
var optsChartScat1 = new ScatterChartOpts
{
x = 0.5, y = 0.6, w = "45%", h = 3,
axisVal = new ChartPropsAxisVal {
valAxisTitle = "Renters", valAxisTitleColor = "428442", valAxisTitleFontSize = 14, showValAxisTitle = true
},
lineSize = 0,
axisCat = new ChartPropsAxisCat {
catAxisTitle = "Last 6 Months", catAxisTitleColor = "428442", catAxisTitleFontSize = 14, showCatAxisTitle = true
},
showLabel = true,
dataLabel = new ChartPropsDataLabel { dataLabelPosition = DataLabelPosition.b }
};
slide.addScatterChart(arrDataScatter1, optsChartScat1);
Typed bubble chart BubbleChartOpts with opacity, data labels and leader lines. DemoChartByChartType.cs · genSlide15_BubbleChart
// TOP-LEFT: Bubble chart (typed BubbleChartOpts)
var optsChartBubble1 = new BubbleChartOpts
{
x = 0.5, y = 0.6, w = "45%", h = 3,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
chartColors = Constants.COLORS_ACCENT,
chartColorsOpacity = 40,
dataBorder = new BorderProps("FFFFFF", null, 1),
dataLabel = new ChartPropsDataLabel
{
dataLabelFontFace = "Arial", dataLabelFontSize = 10, dataLabelColor = "363636", dataLabelPosition = DataLabelPosition.r
},
showSerName = true,
showLeaderLines = true
};
slide.addBubbleChart(arrDataBubble1, optsChartBubble1);
Typed radar chart RadarChartOpts radarStyle standard/marker/filled. DemoChartByChartType.cs · genSlide16_RadarChart
// TOP-L: standard radar (typed RadarChartOpts)
var optsChartRadar1 = new RadarChartOpts
{
x = 0.5, y = 0.6, w = 4.0, h = 3.0,
chartArea = new ChartAreaProps { fill = "F9F9F9" },
radarStyle = RadarStyle.standard,
showTitle = true,
titleProps = new ChartPropsTitle
{
titleColor = "7F7F7F", titleFontFace = "Segoe UI", titleFontSize = 12, title = "radarStyle: 'standard'"
},
lineDataSymbol = LineDataSymbolType.none
};
slide.addRadarChart(arrDataRegions, optsChartRadar1);
Multi-level category axis (2) catAxisMultiLevelLabels on area/bar/bar3d/line charts. DemoChartByChartType.cs · genSlide17
// Two-level category labels — BarChartOpts.catAxisMultiLevelLabels
var arrDataLabels = new List<List<string>> {
new List<string> { "Gear", "Bearing", "Motor", "Switch", "Plug", "Cord", "Fuse", "Bulb", "Pump", "Leak", "Seals" },
new List<string> { "Mechanical", "", "", "Electrical", "", "", "", "", "Hydraulic", "", "" }
};
var opts2 = new BarChartOpts
{
x = 6.8, y = 0.6, w = 6.0, h = 3,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
axisCat = new ChartPropsAxisCat { catAxisMultiLevelLabels = true, catAxisLabelFontFace = "Helvetica Neue Thin" },
barDir = BarDirection.col, barGapWidthPct = 0
};
slide.addBarChart(arrDataRegions, opts2);
Multi-level category axis (3) Three-level labels via BarChartOpts with per-series colors. DemoChartByChartType.cs · genSlide18_BarChart
// Three-level category labels (typed BarChartOpts)
var arrDataRegions = new List<OptsChartData> {
new OptsChartData{
name = "Fruits",
labels = new List<List<string>> {
new List<string> { "Q1", "Q2", "Q3", "Q4", "Q1", "Q2", "Q3", "Q4", "Q1", "Q2", "Q3", "Q4", "Q1", "Q2", "Q3", "Q4" },
new List<string> { "Apple", "", "", "", "Banana", "", "", "", "Apple", "", "", "", "Banana", "", "", "" },
new List<string> { "2024", "", "", "", "", "", "", "", "2025", "", "", "", "", "", "", "" }
},
values = new List<double?> { 734, 465, 656, 176, 434, 165, 613, 359, 279, 660, 307, 270, 539, 142, 554, 405 }
}
};
var opts1 = new BarChartOpts
{
x = 0.5, y = 0.6, w = 12.3, h = 6.5,
chartArea = new ChartAreaProps { fill = "F1F1F1", roundedCorners = false },
axisCat = new ChartPropsAxisCat { catAxisMultiLevelLabels = true },
chartColors = new List<string> { "C0504D", "C0504D", "C0504D", "C0504D", "FFC000", "FFC000", "FFC000", "FFC000" }
};
slide.addBarChart(arrDataRegions, opts1);
Combo — typed series ChartMulti list (bar+line) with secondary axes. DemoChartByChartType.cs · genSlide19
// Typed combo: bar + line on secondary axes
var comboProps = new ChartOpts
{
x = 0.5, y = 0.6, w = 12.3, h = "85%",
chartArea = new ChartAreaProps { fill = "F1F1F1" },
barDir = BarDirection.col, barGrouping = ChartBarGrouping.stacked,
showLegend = true, legendPos = LegendPosition.b,
showTitle = true, title = Constants.CHART_DATA.EvSales_Vol.chartTitle,
valAxes = new List<ChartPropsAxisVal>{
new ChartPropsAxisVal { showValAxisTitle = true, valAxisTitle = "Cars Produced (m)", valAxisMaxVal = 20 },
new ChartPropsAxisVal { showValAxisTitle = true, valAxisTitle = "Global Market Share (%)", valAxisMaxVal = 20, valGridLine = new OptsChartGridLine { style = GridLineStyle.none } }
},
catAxes = new List<ChartPropsAxisCat> { new ChartPropsAxisCat { catAxisTitle = "Year" }, new ChartPropsAxisCat { catAxisHidden = true } }
};
var comboTypes = new List<ChartMulti> {
new ChartMulti { type = ChartType.bar, data = Constants.CHART_DATA.EvSales_Vol.chartData, options = new ChartOpts { chartColors = Constants.COLORS_SPECTRUM, barGrouping = ChartBarGrouping.stacked } },
new ChartMulti { type = ChartType.line, data = Constants.CHART_DATA.EvSales_Pct.chartData, options = new ChartOpts { chartColors = new List<string> { "F38940" }, secondaryValAxis = true, secondaryCatAxis = true } }
};
slide.addChart(comboTypes, comboProps);
Combo — series-level options Column/area/line combo via ChartOpts and ChartMulti. DemoChartByChartType.cs · genSlide20
void doColumnAreaLine() // Column/Area/Line combo (typed ChartMulti)
{
var opts = new ChartOpts {
x = 0.6, y = 0.6, w = 6.0, h = 3.0,
barDir = BarDirection.col,
showLegend = false, showTitle = false,
valAxisMaxVal = 100, valAxisMajorUnit = 10,
valAxes = new List<ChartPropsAxisVal> {
new ChartPropsAxisVal { showValAxisTitle = true, valAxisTitle = "Primary Value Axis" },
new ChartPropsAxisVal { showValAxisTitle = true, valAxisTitle = "Secondary Value Axis", valGridLine = new OptsChartGridLine { style = GridLineStyle.none } }
},
catAxes = new List<ChartPropsAxisCat> {
new ChartPropsAxisCat { catAxisTitle = "Primary Category Axis" },
new ChartPropsAxisCat { catAxisHidden = true }
}
};
var columnAreaLineCharts = new List<ChartMulti> {
new ChartMulti { type = ChartType.area, data = new List<OptsChartData> { new OptsChartData { name = "Current", labels = labels, values = new List<double?> { 1, 4, 7, 2, 3 } } }, options = new ChartOpts { chartColors = new List<string> { "00FFFF" }, barGrouping = ChartBarGrouping.standard, secondaryValAxis = true, secondaryCatAxis = true } },
new ChartMulti { type = ChartType.bar, data = new List<OptsChartData> { new OptsChartData { name = "Bottom", labels = labels, values = new List<double?> { 17, 26, 53, 10, 4 } } }, options = new ChartOpts { chartColors = new List<string> { "0000FF" }, barGrouping = ChartBarGrouping.stacked } },
new ChartMulti { type = ChartType.line, data = new List<OptsChartData> { new OptsChartData { name = "Current", labels = labels, values = new List<double?> { 5, 3, 2, 4, 7 } } }, options = new ChartOpts { barGrouping = ChartBarGrouping.standard, secondaryValAxis = true, secondaryCatAxis = true } }
};
slide.addChart(columnAreaLineCharts, opts);
}
Misc — shadow & transparent ShadowProps on bar/pie; transparent chartColors. DemoChartByChartType.cs · genSlide21
// TOP-LEFT: Horizontal bar with shadow (generic addChart)
var optsChartBar1 = new ChartOpts
{
x = 0.5, y = 0.6, w = 6.0, h = 3.0,
showTitle = true, title = "Large blue shadow",
barDir = BarDirection.bar, barGrouping = ChartBarGrouping.standard,
dataLabelColor = "FFFFFF", showValue = true,
shadow = new ShadowProps { type = ShadowType.outer, blur = 10, offset = 5, angle = 45, color = "0059B1", opacity = 1 }
};
// BOTTOM-LEFT: stacked bar with transparent colors
var optsChartBar3 = new ChartOpts
{
x = 0.5, y = 3.8, w = 6.0, h = 3.5,
showTitle = true, title = "No shadow, transparent colors",
barDir = BarDirection.bar, barGrouping = ChartBarGrouping.stacked,
chartColors = new List<string> { "transparent", "5DA5DA", "transparent", "FAA43A" },
shadow = new ShadowProps { type = ShadowType.none }
};
slide.addChart(ChartType.bar, single, optsChartBar1);
DEV — many-series bars 30 columns (>26) with invertedColors and axis titles. DemoChartByChartType.cs · devSlide01
// DEV: >26 columns with invertedColors (generic addChart)
var letters = Enumerable.Range(0, 26).Select(i => ((char)('A' + i)).ToString()).ToList();
letters.AddRange(new[] { "AA", "AB", "AC", "AD" });
var arrDataHighVals = new List<OptsChartData> {
new OptsChartData { name = "Alphabet Letter Value", labels = new List<List<string>> { letters }, values = new List<double?> { -5, -3, 0, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 } }
};
var optsChart = new ChartOpts {
x = 0.5, y = 0.5, w = "90%", h = "90%",
barDir = BarDirection.col, showLegend = true,
chartColors = new List<string> { "154384" }, invertedColors = new List<string> { "0088CC" },
title = "Chart With >26 Cols", showTitle = true, titleFontSize = 18,
showCatAxisTitle = true, catAxisTitle = "Letters", catAxisTitleColor = "4286f4", catAxisTitleFontSize = 14,
showValAxisTitle = true, valAxisTitle = "Column Index", valAxisTitleColor = "c11c13", valAxisTitleFontSize = 16
};
slide.addChart(pptx.charts.BAR, arrDataHighVals, optsChart);
DEV — many-series line 15 line series with valAxisMaxVal and right legend. DemoChartByChartType.cs · devSlide02
// DEV: 15 line series with valAxisMaxVal (generic addChart)
int MAXVAL = 20000;
var months = Constants.MONS;
var monthCount = months[0].Count;
var arrDataTimeline = Enumerable.Range(0, 15).Select(idx => new OptsChartData {
name = $"Series {idx}", labels = months,
values = Enumerable.Range(0, monthCount).Select(i => (double?)MAXVAL - 29 * idx - 13 * i).ToList()
} as OptsChartData).ToList();
var optsChartLine1 = new ChartOpts {
x = 0.5, y = 0.6, w = "95%", h = "85%",
plotArea = new ChartPropsFillLine { fill = "F2F9FC" },
valAxisMaxVal = MAXVAL, showLegend = true, legendPos = LegendPosition.r
};
slide.addChart(ChartType.line, arrDataTimeline, optsChartLine1);
DEV — escaped XML labels Bar chart whose labels contain ', ", &, < and > characters. DemoChartByChartType.cs · devSlide03
// DEV: labels contain ', ", &, < and > characters
slide.addChart(
ChartType.bar,
new List<OptsChartData> {
new OptsChartData{
name = "Escaped XML chars",
labels = new List<List<string>> { new List<string> { "escaped", "xml", "chars", "'", "\"", "&", "<", ">" } },
values = new List<double?> { 1.2, 2.3, 2.15, 6.05, 8.01, 2.02, 9.9, 0.9 }
}
},
new ChartOpts {
x = 0.5, y = 0.6, w = "90%", h = "90%",
chartArea = new ChartAreaProps { fill = "404040" },
catAxisLabelColor = "F1F1F1", valAxisLabelColor = "F1F1F1",
valGridLine = new OptsChartGridLine { color = "7F7F7F" },
barDir = BarDirection.bar, showValue = true,
chartColors = Constants.COLORS_ACCENT.Concat(Constants.COLORS_ACCENT).ToList(),
barGapWidthPct = 25, catAxisOrientation = "maxMin", valAxisOrientation = "maxMin",
valAxisMaxVal = 10, valAxisMajorUnit = 1
}
);
DEV — combo chart Bar + line combo via ChartMulti with secondary axes. DemoChartByChartType.cs · devSlide04
// DEV: bar + line combo via ChartMulti (generic addChart)
var labels = new List<List<string>> { new List<string> { "Q1", "Q2", "Q3", "Q4", "OT" } };
var chartTypes = new List<ChartMulti> {
new ChartMulti { type = ChartType.bar, data = new List<OptsChartData> { new OptsChartData { name = "Projected", labels = labels, values = new List<double?> { 17, 26, 53, 10, 4 } } }, options = new ChartOpts { barDir = BarDirection.col, chartColors = Constants.COLORS_VIVID } },
new ChartMulti { type = ChartType.line, data = new List<OptsChartData> { new OptsChartData { name = "Current", labels = labels, values = new List<double?> { 5, 3, 2, 4, 7 } } }, options = new ChartOpts { secondaryValAxis = true, secondaryCatAxis = true } }
};
var multiOpts = new ChartOpts {
x = 0.5, y = 0.6, w = 12.33, h = 6,
valAxisMaxVal = 100, valAxisMinVal = 0, valAxisMajorUnit = 20,
valAxes = new List<ChartPropsAxisVal> {
new ChartPropsAxisVal { showValAxisTitle = true, valAxisTitle = "Primary Value Axis" },
new ChartPropsAxisVal { showValAxisTitle = true, valAxisTitle = "Secondary Value Axis", valAxisMajorUnit = 1, valAxisMaxVal = 10, valAxisMinVal = 1, valGridLine = new OptsChartGridLine { style = GridLineStyle.none } }
},
catAxes = new List<ChartPropsAxisCat> { new ChartPropsAxisCat { catAxisTitle = "Primary Category Axis" }, new ChartPropsAxisCat { catAxisHidden = true } }
};
slide.addChart(chartTypes, null!, multiOpts);
DEV — ref-check Doughnut plus an image to verify reference counting. DemoChartByChartType.cs · devSlide05_DoughnutChart
// DEV: doughnut + image to verify ref counting (typed DoughnutChartOpts)
var optsChartPie1 = new DoughnutChartOpts();
optsChartPie1.x = 0.5; optsChartPie1.y = 0.6; optsChartPie1.w = 6.0; optsChartPie1.h = 6.4;
optsChartPie1.chartArea = new ChartAreaProps { fill = "F1F1F1" };
optsChartPie1.holeSize = 70;
optsChartPie1.showLabel = false; optsChartPie1.showValue = false; optsChartPie1.showPercent = true;
optsChartPie1.showLegend = true; optsChartPie1.legendProps = LegendPosition.b;
optsChartPie1.chartColors = Constants.COLORS_SPECTRUM;
optsChartPie1.dataBorder = new BorderProps("F1F1F1", null, 2);
optsChartPie1.dataLabel = new(); optsChartPie1.dataLabel.dataLabelColor = "FFFFFF"; optsChartPie1.dataLabel.dataLabelFontSize = 14;
optsChartPie1.showTitle = false;
optsChartPie1.titleProps = new(); optsChartPie1.titleProps.title = "Project Status"; optsChartPie1.titleProps.titleColor = "33CF22";
slide.addDougnutChart(Constants.dataChartPieStat, optsChartPie1);
var imageProps = new ImageProps();
imageProps.path = Constants.IMAGE_PATHS.ccCopyRemix.path;
imageProps.x = 6.83; imageProps.y = 0.6; imageProps.w = 6.0; imageProps.h = 6.0;
slide.addImage(imageProps);
DEV — legacy regression Legacy-style bar chart built via property setters. DemoChartByChartType.cs · devSlide06_BarChart
// DEV: legacy-style bar via property setters (typed BarChartOpts)
var optsChartBar1 = new BarChartOpts();
optsChartBar1.x = 0.5; optsChartBar1.y = 0.6; optsChartBar1.w = 6.0; optsChartBar1.h = 3;
optsChartBar1.chartArea = new ChartAreaProps { fill = (SCHEME_COLORS.bg2) };
optsChartBar1.plotArea = new ChartPropsFillLine { fill = (SCHEME_COLORS.bg1), border = new BorderProps(SCHEME_COLORS.bg2, null, 1) };
optsChartBar1.objectName = "bar chart (top L)";
optsChartBar1.altText = "this is the alt text content";
optsChartBar1.barDir = BarDirection.bar;
optsChartBar1.border = new BorderProps("00CE00", null, 3);
optsChartBar1.fill = "F1F1F1";
optsChartBar1.axisCat = new ChartPropsAxisCat();
optsChartBar1.axisCat.catAxisLabelColor = "CC0000";
optsChartBar1.axisCat.catAxisLabelFontFace = "Helvetica Neue";
optsChartBar1.axisCat.catAxisLabelFontSize = 14;
optsChartBar1.axisCat.catAxisOrientation = "maxMin";
slide.addBarChart(arrDataHighVals, optsChartBar1);
DEV — title & inverted colors Rotated title (titleRotate) together with invertedColors. DemoChartByChartType.cs · devSlide07_BarChart
// DEV: rotated title + invertedColors (typed BarChartOpts)
var optsChart = new BarChartOpts
{
x = 0.5, y = 0.5, w = "90%", h = "90%",
barDir = BarDirection.col,
showTitle = true,
titleProps = new ChartPropsTitle { title = "Rotated Title", titleFontSize = 20, titleRotate = 10 },
showLegend = true,
chartColors = Constants.COLORS_CHART,
invertedColors = new List<string> { "C0504D" },
axisCat = new ChartPropsAxisCat { showCatAxisTitle = true, catAxisTitle = "Cat Axis Title", catAxisTitleColor = "4286f4", catAxisTitleFontSize = 14 },
axisVal = new ChartPropsAxisVal { showValAxisTitle = true, valAxisTitle = "Val Axis Title", valAxisTitleColor = "c11c13", valAxisTitleFontSize = 16 }
};
slide.addBarChart(arrDataHighVals, optsChart);
4Key notes
Each chart family gets its own typed method: slide.addBarChart / addLineChart / addAreaChart / addPieChart / addDoughnutChart / addScatterChart / addBubbleChart / addRadarChart.
BarChartOpts carries the parts of a chart: flat position x/y/w/h, titleProps (ChartPropsTitle) and axisCat/axisVal (ChartPropsAxisCat/Val).
PieChartOpts shows the pie-specific surface: chartArea fill, dataBorder, legendProps (position/font), showLeaderLines, showPercent/showValue and dataLabel with DataLabelPosition.
Typed helpers and the generic addChart render identical PPTX — pick whichever reads better for the chart you are building.