Skip to content

Commit

Permalink
[Feature] Add direction option in Pie Chart (getredash#3762)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshidajp authored and harveyrendell committed Nov 14, 2019
1 parent 0f25814 commit 9c8698e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/app/visualizations/chart/chart-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
</ui-select>
</div>

<div class="form-group" ng-if="$ctrl.options.globalSeriesType === 'pie'">
<label class="control-label">Direction</label>

<ui-select ng-model="$ctrl.options.direction.type">
<ui-select-match placeholder="Choose Direction...">{{$select.selected.label}}</ui-select-match>
<ui-select-choices repeat="direction.value as direction in $ctrl.directions">
<div ng-bind-html="direction.label | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
</div>

<div class="checkbox" ng-if="['custom', 'heatmap'].indexOf($ctrl.options.globalSeriesType) == -1">
<label>
<input type="checkbox" ng-model="$ctrl.options.legend.enabled">
Expand Down
6 changes: 6 additions & 0 deletions client/app/visualizations/chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const DEFAULT_OPTIONS = {
seriesOptions: {},
valuesOptions: {},
columnMapping: {},
direction: { type: 'counterclockwise' },

// showDataLabels: false, // depends on chart type
numberFormat: '0,0[.]00000',
Expand Down Expand Up @@ -126,6 +127,11 @@ const ChartEditor = {
this.chartTypes.custom = { name: 'Custom', icon: 'code' };
}

this.directions = [
{ label: 'Counterclockwise', value: 'counterclockwise' },
{ label: 'Clockwise', value: 'clockwise' },
];

this.xAxisScales = [
{ label: 'Auto Detect', value: '-' },
{ label: 'Datetime', value: 'datetime' },
Expand Down
1 change: 1 addition & 0 deletions client/app/visualizations/chart/plotly/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ function preparePieData(seriesList, options) {
textposition: 'inside',
textfont: { color: '#ffffff' },
name: serie.name,
direction: options.direction.type,
domain: {
x: [xPosition, xPosition + cellWidth - xPadding],
y: [yPosition, yPosition + cellHeight - yPadding],
Expand Down

0 comments on commit 9c8698e

Please sign in to comment.