Browse Source

update options

merge-requests/1/merge
vargburz 4 years ago
parent
commit
32c1c225dc
  1. 1
      dist/index.d.ts
  2. 2
      dist/index.js
  3. 16
      src/index.ts

1
dist/index.d.ts vendored

@ -3,6 +3,7 @@ import { ChartwerkPod } from '@chartwerk/core';
export declare class ChartwerkGaugePod extends ChartwerkPod<GaugeTimeSerie, GaugeOptions> { export declare class ChartwerkGaugePod extends ChartwerkPod<GaugeTimeSerie, GaugeOptions> {
constructor(el: HTMLElement, _series?: GaugeTimeSerie[], _options?: GaugeOptions); constructor(el: HTMLElement, _series?: GaugeTimeSerie[], _options?: GaugeOptions);
renderMetrics(): void; renderMetrics(): void;
protected updateOptions(newOptions: GaugeOptions): void;
get _gaugeTransform(): string; get _gaugeTransform(): string;
get _gaugeCenterTranform(): string; get _gaugeCenterTranform(): string;
get _gaugeCenterCoordinate(): { get _gaugeCenterCoordinate(): {

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

16
src/index.ts

@ -1,6 +1,6 @@
import { GaugeTimeSerie, GaugeOptions, Stat, Stop, IconConfig, IconPosition } from './types'; import { GaugeTimeSerie, GaugeOptions, Stat, Stop, IconConfig, IconPosition } from './types';
import { ChartwerkPod, VueChartwerkPodMixin, AxisFormat } from '@chartwerk/core'; import { ChartwerkPod, VueChartwerkPodMixin, AxisFormat, CrosshairOrientation } from '@chartwerk/core';
import { findClosest } from './utils'; import { findClosest } from './utils';
@ -43,6 +43,7 @@ const DEFAULT_GAUGE_OPTIONS: GaugeOptions = {
axis: { axis: {
x: { isActive: false, format: AxisFormat.NUMERIC }, x: { isActive: false, format: AxisFormat.NUMERIC },
y: { isActive: false, format: AxisFormat.NUMERIC }, y: { isActive: false, format: AxisFormat.NUMERIC },
y1: { isActive: false, format: AxisFormat.NUMERIC },
}, },
margin: { margin: {
top: 0, bottom: 0, top: 0, bottom: 0,
@ -58,6 +59,10 @@ const DEFAULT_GAUGE_OPTIONS: GaugeOptions = {
value: 20 value: 20
} }
], ],
crosshair: {
orientation: CrosshairOrientation.VERTICAL,
color: 'red'
},
defaultColor: 'red', defaultColor: 'red',
stat: Stat.CURRENT, stat: Stat.CURRENT,
innerRadius: DEFAULT_INNER_RADIUS, innerRadius: DEFAULT_INNER_RADIUS,
@ -88,6 +93,15 @@ export class ChartwerkGaugePod extends ChartwerkPod<GaugeTimeSerie, GaugeOptions
this._renderIcons(); this._renderIcons();
} }
protected updateOptions(newOptions: GaugeOptions): void {
if(newOptions === undefined) {
return;
}
let options = _.cloneDeep(newOptions);
_.defaultsDeep(options, DEFAULT_GAUGE_OPTIONS);
this.options = options;
}
get _gaugeTransform(): string { get _gaugeTransform(): string {
return `translate(${this.width / 2},${0.8 * this.height})`; return `translate(${this.width / 2},${0.8 * this.height})`;
} }

Loading…
Cancel
Save