Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
chore(donut chart): Add more default colors for donut chart (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabeng authored and jeff-phillips-18 committed Jan 19, 2018
1 parent dec146e commit 74cdae7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
23 changes: 23 additions & 0 deletions src/js/patternfly-settings-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@
]
};
},
getDefaultRelationshipDonutColors = function () {
return {
pattern: [
patternfly.pfPaletteColors.blue,
patternfly.pfPaletteColors.red100,
patternfly.pfPaletteColors.orange400,
patternfly.pfPaletteColors.green400,
patternfly.pfPaletteColors.cyan500,
patternfly.pfPaletteColors.gold200,
]
};
},
getDefaultDonutTooltip = function () {
return {
show: false
Expand All @@ -174,6 +186,15 @@
tooltip: this.getDefaultDonutTooltip()
};
},
getDefaultRelationshipDonutConfig = function (title) {
return {
donut: this.getDefaultDonut(title),
size: this.getDefaultDonutSize(),
legend: this.getDefaultDonutLegend(),
color: this.getDefaultRelationshipDonutColors(),
tooltip: this.getDefaultDonutTooltip()
};
},
getDefaultPie = function () {
return {
expand: true,
Expand Down Expand Up @@ -391,9 +412,11 @@
getDefaultDonutTooltip: getDefaultDonutTooltip,
getDefaultDonutLegend: getDefaultDonutLegend,
getDefaultDonutConfig: getDefaultDonutConfig,
getDefaultRelationshipDonutConfig: getDefaultRelationshipDonutConfig,
getDefaultPie: getDefaultPie,
getDefaultPieSize: getDefaultPieSize,
getDefaultPieColors: getDefaultPieColors,
getDefaultRelationshipDonutColors: getDefaultRelationshipDonutColors,
getDefaultPieTooltip: getDefaultPieTooltip,
getDefaultPieLegend: getDefaultPieLegend,
getDefaultPieConfig: getDefaultPieConfig,
Expand Down
8 changes: 1 addition & 7 deletions tests/pages/_includes/widgets/charts/donut-mini.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@

var donutData = {
type : 'donut',
colors: {
Cats: $.pfPaletteColors.blue,
Hamsters: $.pfPaletteColors.green,
Fish: $.pfPaletteColors.orange,
Dogs: $.pfPaletteColors.red
},
columns: [
['Dogs', 2],
['Cats', 2],
Expand All @@ -23,7 +17,7 @@
};

// Small Donut Chart
var donutChartSmallConfig = c3ChartDefaults.getDefaultDonutConfig('8');
var donutChartSmallConfig = c3ChartDefaults.getDefaultRelationshipDonutConfig('8');
donutChartSmallConfig.bindto = '#{{include.id}}';
donutChartSmallConfig.tooltip = {show: true};
donutChartSmallConfig.data = donutData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

var donutData = {
type : 'donut',
colors: {
Cats: $.pfPaletteColors.blue,
Hamsters: $.pfPaletteColors.green,
Fish: $.pfPaletteColors.orange,
Dogs: $.pfPaletteColors.red
},
columns: [
['Dogs', 2],
['Cats', 2],
Expand All @@ -24,7 +18,7 @@
};

// Donut Chart without Legend
var donutChartConfig = c3ChartDefaults.getDefaultDonutConfig();
var donutChartConfig = c3ChartDefaults.getDefaultRelationshipDonutConfig();
donutChartConfig.bindto = '#{{include.id}}1';
donutChartConfig.tooltip = {show: true};
donutChartConfig.data = donutData;
Expand All @@ -40,7 +34,7 @@
$().pfSetDonutChartTitle("#{{include.id}}1", "8", "Animals");

// Right Legend
var donutChartRightConfig = c3ChartDefaults.getDefaultDonutConfig();
var donutChartRightConfig = c3ChartDefaults.getDefaultRelationshipDonutConfig();
donutChartRightConfig.bindto = '#{{include.id}}2';
donutChartRightConfig.tooltip = {show: true};
donutChartRightConfig.data = donutData;
Expand All @@ -60,7 +54,7 @@
$().pfSetDonutChartTitle("#{{include.id}}2", "8", "Animals");

// Donut Chart Bottom Legend
var donutChartBottomConfig = c3ChartDefaults.getDefaultDonutConfig();
var donutChartBottomConfig = c3ChartDefaults.getDefaultRelationshipDonutConfig();
donutChartBottomConfig.bindto = '#{{include.id}}3';
donutChartBottomConfig.tooltip = {show: true};
donutChartBottomConfig.data = donutData;
Expand Down

0 comments on commit 74cdae7

Please sign in to comment.