Charts — addChart API
Every chart family through one generic entry point: addChart(ChartType.…, data, ChartOpts) with axes, legends, titles and series styling.
DemoChart
Source file Modules/DemoChart.cs
Slide methods genSlide01 – 21 · devSlide01 – 07
Output files chart_genSlide*.pptx
1Overview
DemoChart is the big showcase of the generic chart API: slide.addChart(ChartType.bar, data, opts). Each of the 21 slides takes one topic — a chart family, an option group or a multi-series layout — and annotates the result with caption tables.
Chart data lives in Constants (dataChartBar8Series, CHART_DATA.EvSales_Vol, dataChartPieStat…). ChartOpts is the central options bag: x/y/w/h, barDir/barGrouping, title, cat/val axes, legend, chartColors, data labels and more.
2Demo methods
| Method | What it demonstrates |
|---|---|
| genSlide01 | Chart options — full ChartOpts (title, cat/val axes) on a stacked bar. |
| genSlide02 | Bar — various designs. |
| genSlide03 | Bar — axis, dataLabel and grid options. |
| genSlide04 | Bar — stacked series. |
| genSlide05 | Bar — series colors, majorUnits and valAxisLabelFormatCode. |
| genSlide06 | Bar — 3D. |
| genSlide07 | Bar — tornado (diverging) chart. |
| genSlide08 | Line chart. |
| genSlide09 | Line — smoothing, line size, symbol size. |
| genSlide10 | Line — lineDataSymbol and lineDataSymbolSize. |
| genSlide11 | Area chart. |
| genSlide12 | Pie chart. |
| genSlide13 | Doughnut chart. |
| genSlide14 | XY scatter chart. |
| genSlide15 | Bubble chart. |
| genSlide16 | Radar chart. |
| genSlide17 | Multi-level category axis (2 levels). |
| genSlide18 | Multi-level category axis (3 levels). |
| genSlide19 | Combo chart — bar + line with secondary axes. |
| 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 | DEV — reference checks. |
| devSlide06 | DEV — legacy regression tests. |
| devSlide07 | DEV — title options and inverted colors. |
3Code samples
Chart title & axis options ChartOpts: showTitle, title fonts, cat/val axis titles and colors. DemoChart.cs · genSlide01
new TableCell { text = "Chart Options: Chart Title, Cat/Val Axis Title", options = Constants.BASE_TEXT_OPTS_L },
Constants.BASE_TEXT_OPTS_R
}
}, Constants.BASE_TABLE_OPTS);
// Chart options
var optsChart = new ChartOpts
{
x = 0.5,
y = 0.5,
w = "90%",
h = "90%",
barDir = BarDirection.col, // "col",
barGrouping = ChartBarGrouping.stacked,
chartColors = Constants.COLORS_CHART,
invertedColors = new List<string> { "C0504D" },
showLegend = true,
// title options
showTitle = true,
title = "Chart Title",
titleFontFace = "Helvetica Neue Thin",
titleFontSize = 24,
titleColor = Constants.COLORS_ACCENT[0],
titlePos = new PositionXY { x = 1.5, y = 0 },
//titleRotate = 10,
// Category axis options
showCatAxisTitle = true,
catAxisLabelColor = Constants.COLORS_ACCENT[1],
catAxisTitleColor = Constants.COLORS_ACCENT[1],
catAxisTitle = "Cat Axis Title",
catAxisTitleFontSize = 14,
// 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.addChart(ChartType.bar, Constants.dataChartBar8Series, optsChart);
}
/// <summary>
/// SLIDE 2: Bar Chart: Various Designs
Combo — dual value axes Two ChartPropsAxisVal entries with independent titles and max values. DemoChart.cs · genSlide19
showValAxisTitle = true,
valAxisTitle = "Cars Produced (m)",
valAxisMaxVal = 20,
valAxisTitleColor = "1982c4",
valAxisLabelColor = "1982c4"
},
new ChartPropsAxisVal{
showValAxisTitle = true,
valAxisTitle = "Global Market Share (%)",
valAxisMaxVal = 20,
valAxisTitleColor = "F38940",
valAxisLabelColor = "F38940",
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 {
Combo — bar + line series ChartMulti list: stacked bar plus a line on secondary axes. DemoChart.cs · genSlide19
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);
}
/// <summary>
// SLIDE 20: Combo Chart: Various options
/// </summary>
/// <param name="pptx"></param>
Bar — various designs Horizontal/vertical bars, stacked bars, titles; chartArea/plotArea and data labels. DemoChart.cs · genSlide02
// TOP-LEFT: Horizontal bar chart
var optsChartBar1 = new ChartOpts
{
x = 0.5, y = 0.6, w = 6.0, h = 3.0,
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,
catAxisLabelColor = Constants.COLORS_ACCENT[0],
catAxisLabelFontFace = "Helvetica Neue",
catAxisMajorTickMark = ChartAxisTickMark.@in,
valAxisMajorTickMark = ChartAxisTickMark.cross,
};
slide.addChart(ChartType.bar, arrDataSersCats, optsChartBar1);
Bar — axis, dataLabel, grid Category/value axis titles, grid lines, hidden axes and data-label formatting. DemoChart.cs · genSlide03
// TOP-LEFT: Horizontal bar chart — axis/grid
var optsChartBar1 = new ChartOpts{
x = 0.5, y = 0.6, w = 6.0, h = 3.0,
barDir = BarDirection.bar,
plotArea = new ChartPropsFillLine { fill = "F1F1F1" },
chartColors = Constants.COLORS_ACCENT,
catAxisLabelColor = "CC0000",
catGridLine = new OptsChartGridLine { style = GridLineStyle.none },
catAxisHidden = true,
valGridLine = new OptsChartGridLine { color = "cc6699", style = GridLineStyle.dash, size = 1 },
valAxisLineColor = "44AA66",
showLegend = true, showTitle = true,
title = "catAxisHidden:true, valGridLine/valAxisLine:dash"
};
slide.addChart(ChartType.bar, arrDataRegions, optsChartBar1);
Bar — stacked series Stacked and 100% stacked columns with data table and fill opacity. DemoChart.cs · genSlide04
// TOP-RIGHT: Vertical stacked column
var optsChartBar2 = new ChartOpts {
x = 7.0, y = 0.6, w = 6.0, h = 3.0,
chartArea = new ChartAreaProps { fill = "0d0d0d" },
plotArea = new ChartPropsFillLine { fill = "4d4d4d" },
chartColors = Constants.COLORS_VIVID,
valGridLine = new OptsChartGridLine { color = "141414" },
barDir = BarDirection.col,
barGrouping = ChartBarGrouping.stacked,
dataLabelFontFace = "Arial",
dataLabelFontSize = 12,
dataLabelFontBold = true,
showValue = true,
showLegend = false, showTitle = false
};
slide.addChart(ChartType.bar, Constants.dataChartBar3Series, optsChartBar2);
Bar — colors & majorUnits Per-category colors, catLabel/valAxis format codes, majorUnits and negatives. DemoChart.cs · genSlide05
// TOP-LEFT: Multi-color bars with date formatting
slide.addChart(
ChartType.bar,
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 ChartOpts {
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" },
catLabelFormatCode = "yyyy-mm",
valAxisHidden = true,
showTitle = true,
title = "Categories can be Multi-Color",
titleColor = "0088CC", titleFontSize = 14
}
);
Bar — 3D bar3d with cylinder/pyramid/cone shapes, v3D rotation and serAxis. DemoChart.cs · genSlide06
// TOP-LEFT: Horizontal 3D bar
var optsChartBar1 = new ChartOpts{
x = 0.5, y = 0.6, w = 6.0, h = 3.0,
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,
catAxisLabelColor = Constants.COLORS_SPECTRUM[1],
serAxisLabelFontFace = "Arial",
valAxisLabelColor = Constants.COLORS_SPECTRUM[0]
};
slide.addChart(ChartType.bar3d, arrDataRegions, optsChartBar1);
Bar — tornado (diverging) Stacked diverging bars with positive/negative colors and dashed grid. DemoChart.cs · genSlide07
// Tornado (diverging) chart
slide.addChart(
ChartType.bar,
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 ChartOpts {
x = 0.5, y = 0.5, w = "90%", h = "90%",
valAxisMaxVal = 1,
catGridLine = new OptsChartGridLine { color = "D8D8D8", style = GridLineStyle.dash, size = 1, cap = ChartLineCap.round },
valGridLine = new OptsChartGridLine { color = "D8D8D8", style = GridLineStyle.dash, size = 1, cap = ChartLineCap.square },
catAxisLineShow = false, valAxisLineShow = false,
barGrouping = ChartBarGrouping.stacked,
shadow = new ShadowProps { type = ShadowType.none },
chartColors = new List<string> { "0077BF", "4E9D2D", "ECAA00", "5FC4E3", "DE4216", "154384", "7D666A", "A3C961", "EF907B", "9BA0A3" },
invertedColors = new List<string> { "0065A2", "428526", "C99100", "51A7C1", "BD3813", "123970", "6A575A", "8BAB52", "CB7A69", "84888B" },
barGapWidthPct = 25, valAxisMajorUnit = 0.2
}
);
Line chart Full-slide line: lineSize, symbols, right legend, rotated labels. DemoChart.cs · genSlide08
// FULL SLIDE: Line chart
var OPTS_CHART = new ChartOpts {
x = 0.5, y = 0.6, w = "95%", h = "85%",
plotArea = new ChartPropsFillLine { fill = "e3e3e3" },
showLegend = true,
legendPos = LegendPosition.r,
catAxisLabelRotate = 90,
valAxisLabelFormatCode = "#,##0",
lineSize = 4,
chartColors = [COLOR_GRN],
lineDataSymbolSize = 10,
lineDataSymbolLineColor = "4472C4",
lineDataSymbolLineSize = 3,
showTitle = true,
title = CHART_DATA.Fedi_MAU.chartTitle,
titleColor = "0088CC", titleFontFace = "Arial", titleFontSize = 18
};
slide.addChart(ChartType.line, Constants.CHART_DATA.Fedi_MAU.chartData, OPTS_CHART);
Line — smoothing & symbols lineSmooth, lineSize and lineDataSymbolSize with custom shadow. DemoChart.cs · genSlide09
// Top-left: Smooth line with thick line size
var optsChartLine1 = new ChartOpts{
x = 0.5, y = 0.6, w = 6.0, h = 3.0,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
chartColors = Constants.COLORS_RYGU,
lineSize = 8,
lineSmooth = true,
showLegend = true,
legendPos = LegendPosition.t,
catAxisLabelPos = CatAxisLabelPos.high
};
slide.addChart(ChartType.line, Constants.arrDataLineStat, optsChartLine1);
Line — lineDataSymbol Loop over lineDataSymbol shapes (circle, dash, diamond, dot, none…). DemoChart.cs · genSlide10
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.addChart(ChartType.line, Constants.arrDataLineStat, new ChartOpts {
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,
title = opt, showTitle = true
});
}
Area chart Basic and stacked area charts with opacity and custom colors. DemoChart.cs · genSlide11
// TOP-LEFT: Basic area chart
var optsChartLine1 = new ChartOpts {
x = 0.5, y = 0.6, w = "45%", h = 3,
chartArea = new ChartAreaProps { fill = "e9e9e9" },
plotArea = new ChartPropsFillLine { fill = "f2f9fc" },
dataBorder = new BorderProps("F1F1F1", null, 1),
showTitle = true,
title = Constants.CHART_DATA.CeoPayRatio_Comp.chartTitle,
titleFontSize = 11, titleColor = "fc0000",
valAxisLabelFormatCode = "#-1",
chartColors = new List<string> { "EF423E" },
chartColorsOpacity = 25
};
slide.addChart(ChartType.area, Constants.CHART_DATA.CeoPayRatio_Comp.chartData, optsChartLine1);
Pie chart Pie: legend position, leader lines, percent/value labels. DemoChart.cs · genSlide12
// Pie chart with legend + labels
slide.addChart(ChartType.pie, Constants.dataChartPieStat, new ChartOpts
{
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),
legendPos = LegendPosition.l,
legendFontFace = "Courier New",
showLegend = true,
showLeaderLines = true,
showPercent = false, showValue = true,
dataLabelColor = "FFFFFF",
dataLabelFontSize = 14,
dataLabelPosition = DataLabelPosition.bestFit
});
Doughnut chart Doughnut with holeSize, inner shadow and percent labels. DemoChart.cs · genSlide13
var optsChartPie1 = new ChartOpts {
x = 0.5, y = 0.6, w = 6.0, h = 6.4,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
holeSize = 70,
showLabel = false, showValue = false, showPercent = true,
showLegend = true, legendPos = LegendPosition.b,
chartColors = Constants.COLORS_RYGU,
dataBorder = new BorderProps("F1F1F1", null, 2),
dataLabelColor = "FFFFFF",
dataLabelFontSize = 14,
showTitle = false,
title = "Project Status", titleColor = "33CF22", titleFontFace = "Helvetica Neue", titleFontSize = 24
};
slide.addChart(ChartType.doughnut, Constants.dataChartPieStat, optsChartPie1);
XY scatter chart Scatter with axis titles, smoothing and custom point labels. DemoChart.cs · genSlide14
// TOP-LEFT: XY scatter
var optsChartScat1 = new ChartOpts {
x = 0.5, y = 0.6, w = "45%", h = 3,
valAxisTitle = "Renters",
valAxisTitleColor = "428442", valAxisTitleFontSize = 14,
showValAxisTitle = true,
lineSize = 0,
catAxisTitle = "Last 6 Months",
catAxisTitleColor = "428442", catAxisTitleFontSize = 14,
showCatAxisTitle = true,
showLabel = true, dataLabelPosition = DataLabelPosition.b
};
slide.addChart(ChartType.scatter, arrDataScatter1, optsChartScat1);
Bubble chart Bubble (and bubble3d) charts with sizes, opacity and data labels. DemoChart.cs · genSlide15
// TOP-LEFT: Bubble chart
var optsChartBubble1 = new ChartOpts {
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),
dataLabelFontFace = "Arial", dataLabelFontSize = 10,
dataLabelColor = "363636",
dataLabelPosition = DataLabelPosition.r,
showSerName = true, showLeaderLines = true
};
slide.addChart(ChartType.bubble, arrDataBubble1, optsChartBubble1);
Radar chart Radar styles standard/marker/filled with line & marker options. DemoChart.cs · genSlide16
// TOP-L: standard radar
var optsChartRadar1 = new ChartOpts {
x = 0.5, y = 0.6, w = 4.0, h = 3.0,
chartArea = new ChartAreaProps { fill = "F9F9F9" },
radarStyle = RadarStyle.standard,
showTitle = true,
titleColor = "7F7F7F", titleFontFace = "Segoe UI", titleFontSize = 12,
title = "radarStyle: 'standard'",
lineDataSymbol = LineDataSymbolType.none
};
slide.addChart(ChartType.radar, arrDataRegions, optsChartRadar1);
Multi-level category axis (2) catAxisMultiLevelLabels across area/bar/bar3d/line charts. DemoChart.cs · genSlide17
// Two-level category labels: [part, group]
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 opts1 = new ChartOpts { x = 0.5, y = 0.6, w = 6.0, h = 3.0,
chartArea = new ChartAreaProps { fill = "F1F1F1" },
catAxisMultiLevelLabels = true,
catAxisLabelFontFace = "Helvetica Neue Thin" };
slide.addChart(ChartType.area, arrDataRegions, opts1);
slide.addChart(ChartType.bar, arrDataRegions, opts2);
Multi-level category axis (3) Three-level category labels with per-series colors. DemoChart.cs · genSlide18
var opts1 = new ChartOpts {
x = 0.5, y = 0.6, w = 12.3, h = 6.5,
chartArea = new ChartAreaProps { fill = "F1F1F1", roundedCorners = false },
catAxisMultiLevelLabels = true,
chartColors = new List<string> { "C0504D", "C0504D", "C0504D", "C0504D", "FFC000", "FFC000", "FFC000", "FFC000" }
};
slide.addChart(ChartType.bar, arrDataRegions, opts1);
Combo — series-level options Column/area/line and stacked combos with secondary axes. DemoChart.cs · genSlide20
void doColumnAreaLine() // Column/Area/Line combo
{
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 = opts.valAxes != null, secondaryCatAxis = opts.catAxes != null } },
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 = opts.valAxes != null, secondaryCatAxis = opts.catAxes != null } }
};
slide.addChart(columnAreaLineCharts, opts);
}
Misc — shadow & transparent Bar/pie shadows and transparent chart colors. DemoChart.cs · genSlide21
// TOP-LEFT: Horizontal bar with shadow
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
}
};
slide.addChart(ChartType.bar, single, optsChartBar1);
DEV — many-series bars 30 columns (>26) with invertedColors and axis titles. DemoChart.cs · devSlide01
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. DemoChart.cs · devSlide02
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. DemoChart.cs · devSlide03
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" },
dataLabelColor = "B7B7B7",
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. DemoChart.cs · devSlide04
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. DemoChart.cs · devSlide05
var optsChartPie1 = new ChartOpts();
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.legendPos = LegendPosition.b;
optsChartPie1.chartColors = Constants.COLORS_SPECTRUM;
optsChartPie1.dataBorder = new BorderProps("F1F1F1", null, 2);
optsChartPie1.dataLabelColor = "FFFFFF"; optsChartPie1.dataLabelFontSize = 14;
optsChartPie1.showTitle = false;
optsChartPie1.title = "Project Status"; optsChartPie1.titleColor = "33CF22";
slide.addChart(ChartType.doughnut, 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. DemoChart.cs · devSlide06
var optsChartBar1 = new ChartOpts();
optsChartBar1.x = 0.5; optsChartBar1.y = 0.6; optsChartBar1.w = 6.0; optsChartBar1.h = 3.0;
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.catAxisLabelColor = "CC0000";
optsChartBar1.catAxisLabelFontFace = "Helvetica Neue";
optsChartBar1.catAxisLabelFontSize = 14;
optsChartBar1.catAxisOrientation = "maxMin";
optsChartBar1.catAxisMajorTickMark = ChartAxisTickMark.@in;
optsChartBar1.catAxisMinorTickMark = ChartAxisTickMark.cross;
slide.addChart(ChartType.bar, arrDataHighVals, optsChartBar1);
DEV — title & inverted colors Rotated title (titleRotate) together with invertedColors. DemoChart.cs · devSlide07
ChartOpts optsChart = new ChartOpts {
x = 0.5, y = 0.5, w = "90%", h = "90%",
barDir = BarDirection.col,
showTitle = true,
title = "Rotated Title",
titleFontSize = 20,
titleRotate = 10,
showLegend = true,
chartColors = Constants.COLORS_CHART,
invertedColors = new List<string> { "C0504D" },
showCatAxisTitle = true, catAxisTitle = "Cat Axis Title", catAxisTitleColor = "4286f4", catAxisTitleFontSize = 14,
showValAxisTitle = true, valAxisTitle = "Val Axis Title", valAxisTitleColor = "c11c13", valAxisTitleFontSize = 16
};
slide.addChart(ChartType.bar, arrDataHighVals, optsChart);
4Key notes
The generic entry point is slide.addChart(ChartType.bar|line|pie|…, data, ChartOpts); data is a List<OptsChartData> of named series.
ChartOpts mixes geometry (x/y/w/h), series layout (barDir, barGrouping), legend, chartColors, invertedColors, and chart-specific toggles such as valAxisMaxVal.
Combo charts take a List<ChartMulti> { type = ChartType.…, data = …, options = … }; the second series enables secondaryValAxis/secondaryCatAxis to get its own scales.
devSlide* methods are stress/regression helpers used by the byte-compare suite — they are a gold mine of edge cases (escaped XML, many series, legacy flags).