diff --git a/demos/common/demos.js b/demos/common/demos.js index 812fbf5ff..997287f39 100644 --- a/demos/common/demos.js +++ b/demos/common/demos.js @@ -1141,7 +1141,7 @@ function genSlides_Chart(pptx) { var arrDataHighVals = [ { - name : 'TEST: getExcelColName', + name : 'Single Data Set', labels: LETTERS.concat(['AA','AB','AC','AD']), values: [-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 ] } @@ -1159,7 +1159,8 @@ function genSlides_Chart(pptx) { catAxisTitleColor: "4286f4", catAxisTitleFontSize: 14, - chartColors: ['EE1122'], + showLegend: true, + chartColors: ['154384'], invertedColors: ['0088CC'], showValAxisTitle: true, @@ -1183,7 +1184,7 @@ function genSlides_Chart(pptx) { pptx.charts.BAR, [ { - name : 'Labels are Excel Date Values', + name : 'Excel Date Values', labels: [37987,38018,38047,38078,38108,38139], values: [20, 30, 10, 25, 15, 5] } @@ -1775,13 +1776,16 @@ function genSlides_Chart(pptx) { fill: 'f2f9fc', //catAxisOrientation: 'maxMin', //valAxisOrientation: 'maxMin', + showLegend: true, + chartColors: ['FF0000','0088CC'], + showValAxisTitle: false, lineSize: 0, catAxisTitle : "Data Point Labels", catAxisTitleColor : "0088CC", catAxisTitleFontSize: 14, - showCatAxisTitle : true, + showCatAxisTitle : false, // Data Labels showLabel : true, // Must be set to true or labels will not be shown diff --git a/src/core-interfaces.ts b/src/core-interfaces.ts index 002066110..3cc0c2878 100644 --- a/src/core-interfaces.ts +++ b/src/core-interfaces.ts @@ -1112,7 +1112,6 @@ export interface IChartPropsChartBar { barGapDepthPct?: number barGapWidthPct?: number barGrouping?: string - valueBarColors?: string[] } export interface IChartPropsChartDoughnut { dataNoEffects?: boolean diff --git a/src/gen-charts.ts b/src/gen-charts.ts index e8d0109cf..385ea1a3e 100644 --- a/src/gen-charts.ts +++ b/src/gen-charts.ts @@ -792,9 +792,15 @@ function makeChartType(chartType: CHART_NAME, data: OptsChartData[], opts: IChar strXml += '' } - // Color chart bars various colors // Allow users with a single data set to pass their own array of colors (check for this using != ours) - if ((chartType === CHART_TYPE.BAR || chartType === CHART_TYPE.BAR3D) && (data.length === 1 || opts.valueBarColors) && opts.chartColors !== BARCHART_COLORS) { + // Color chart bars various colors when >1 color + // NOTE: `` created with various colors will change PPT legend by design so each dataPt/color is an legend item! + if ( + (chartType === CHART_TYPE.BAR || chartType === CHART_TYPE.BAR3D) && + data.length === 1 && + opts.chartColors !== BARCHART_COLORS && + opts.chartColors.length > 1 + ) { // Series Data Point colors obj.values.forEach((value, index) => { let arrColors = value < 0 ? opts.invertedColors || opts.chartColors || BARCHART_COLORS : opts.chartColors || [] @@ -1132,10 +1138,10 @@ function makeChartType(chartType: CHART_NAME, data: OptsChartData[], opts: IChar // Color bar chart bars various colors // Allow users with a single data set to pass their own array of colors (check for this using != ours) - if ((data.length === 1 || opts.valueBarColors) && opts.chartColors !== BARCHART_COLORS) { + if (data.length === 1 && opts.chartColors !== BARCHART_COLORS) { // Series Data Point colors obj.values.forEach((value, index) => { - let arrColors = value < 0 ? opts.invertedColors || BARCHART_COLORS : opts.chartColors || [] + let arrColors = value < 0 ? opts.invertedColors || opts.chartColors || BARCHART_COLORS : opts.chartColors || [] strXml += ' ' strXml += ' ' @@ -1591,7 +1597,7 @@ function makeCatAxis(opts: IChartOptsLib, axisId: string, valAxisId: string): st strXml += ' ' strXml += ' ' strXml += opts.catAxisLineShow === false ? '' : '' - strXml += ' ' + strXml += ' ' strXml += ' ' strXml += ' ' strXml += ' ' @@ -1693,7 +1699,7 @@ function makeValAxis(opts: IChartOptsLib, valAxisId: string): string { strXml += ' ' strXml += ' ' strXml += opts.valAxisLineShow === false ? '' : '' - strXml += ' ' + strXml += ' ' strXml += ' ' strXml += ' ' strXml += ' ' diff --git a/types/index.d.ts b/types/index.d.ts index b89e4c711..b71ec1b4e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1863,7 +1863,6 @@ declare namespace PptxGenJS { barGapDepthPct?: number barGapWidthPct?: number barGrouping?: string - valueBarColors?: string[] } export interface IChartPropsChartDoughnut { dataNoEffects?: boolean