Browse Source

minor fixes

merge-requests/1/merge
rozetko 3 years ago
parent
commit
28ea6f1d1e
  1. 1
      dist/index.d.ts
  2. 2
      dist/index.js
  3. 4
      dist/types.d.ts
  4. 11
      src/index.ts
  5. 5
      src/types.ts

1
dist/index.d.ts vendored

@ -5,6 +5,7 @@ export declare class ChartwerkGaugePod extends ChartwerkPod<GaugeTimeSerie, Gaug
constructor(el: HTMLElement, _series?: GaugeTimeSerie[], _options?: GaugeOptions);
renderMetrics(): void;
private get _valueRange();
private get _sortedStops();
private get _colors();
private get _stat();
private get _innerRadius();

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

4
dist/types.d.ts vendored

@ -5,6 +5,10 @@ export declare enum Stat {
MAX = "max",
TOTAL = "total"
}
export declare type Stop = {
color: string;
value: number | null;
};
export declare type GaugeTimeSerie = TimeSerie;
export declare type GaugeOptionsParams = {
innerRadius: number;

11
src/index.ts

@ -1,4 +1,4 @@
import { GaugeTimeSerie, GaugeOptions, Stat } from './types';
import { GaugeTimeSerie, GaugeOptions, Stat, Stop } from './types';
import { ChartwerkPod, VueChartwerkPodMixin, ZoomType } from '@chartwerk/core';
@ -94,7 +94,8 @@ export class ChartwerkGaugePod extends ChartwerkPod<GaugeTimeSerie, GaugeOptions
// TODO: better name
private get _valueRange(): number[] {
// TODO: refactor
const stopValues = [...this.options.stops.map(stop => stop.value), this.options.maxValue || this.maxValue]
// TODO: max value might be less than the latest stop
const stopValues = [...this._sortedStops.map(stop => stop.value), this.options.maxValue || this.maxValue];
if(stopValues.length < 2) {
return stopValues;
@ -106,9 +107,13 @@ export class ChartwerkGaugePod extends ChartwerkPod<GaugeTimeSerie, GaugeOptions
return range;
}
private get _sortedStops(): Stop[] {
return _.sortBy(this.options.stops);
}
private get _colors(): string[] {
// TODO: refactor
return [...this.options.stops.map(stop => stop.color), this.options.defaultColor];
return [...this._sortedStops.map(stop => stop.color), this.options.defaultColor];
}
private get _stat(): Stat {

5
src/types.ts

@ -7,6 +7,11 @@ export enum Stat {
TOTAL = 'total'
}
export type Stop = {
color: string,
value: number | null
};
export type GaugeTimeSerie = TimeSerie;
export type GaugeOptionsParams = {

Loading…
Cancel
Save