diff --git a/examples/02-reversed.html b/examples/02-reversed.html new file mode 100644 index 0000000..d45c114 --- /dev/null +++ b/examples/02-reversed.html @@ -0,0 +1,36 @@ + + + + + + + + + +
+ + + + diff --git a/src/index.ts b/src/index.ts index 2c4ac3a..2c9384e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,11 +9,11 @@ import * as d3 from 'd3'; import * as _ from 'lodash'; const SPACE_BETWEEN_CIRCLES = 2; -const CIRCLES_ROUNDING = 0.15; //radians +const CIRCLES_ROUNDING = 0.25; //radians const BACKGROUND_COLOR = 'rgba(38, 38, 38, 0.1)'; -const DEFAULT_INNER_RADIUS = 48; +const DEFAULT_INNER_RADIUS = 52; const DEFAULT_OUTER_RADIUS = 72; -const STOPS_CIRCLE_WIDTH = 4; +const STOPS_CIRCLE_WIDTH = 8; const VALUE_TEXT_FONT_SIZE = 16; const DEFAULT_VALUE_TEXT_Decimals = 2; const VALUE_TEXT_MARGIN = 10; @@ -48,7 +48,8 @@ const DEFAULT_GAUGE_OPTIONS: GaugeOptions = { outerRadius: DEFAULT_OUTER_RADIUS, icons: [], valueFontSize: VALUE_TEXT_FONT_SIZE, - valueArcBackgroundColor: BACKGROUND_COLOR + valueArcBackgroundColor: BACKGROUND_COLOR, + reversed: false, }; export class ChartwerkGaugePod extends ChartwerkPod { @@ -221,6 +222,9 @@ export class ChartwerkGaugePod extends ChartwerkPod stop.color), this.options.defaultColor]; + const colors = [...this._sortedStops.map(stop => stop.color), this.options.defaultColor]; + if(this.options.reversed === true) { + return _.reverse(colors); + } + return colors; } private get _valueText(): string { diff --git a/src/types.ts b/src/types.ts index 8f95477..4118a0c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -40,5 +40,6 @@ export type GaugeOptionsParams = { icons: IconConfig[]; valueFontSize: number; valueArcBackgroundColor: string; + reversed: boolean; } export type GaugeOptions = Options & Partial;