Browse Source

Fixed not correct label text for weight font; Refactoring

pull/3395/head
Vladyslav_Prykhodko 6 years ago
parent
commit
7349108111
  1. 4
      ui-ngx/src/app/modules/home/components/widget/lib/analogue-compass.models.ts
  2. 2
      ui-ngx/src/app/modules/home/components/widget/lib/analogue-compass.ts
  3. 32
      ui-ngx/src/app/modules/home/components/widget/lib/analogue-gauge.models.ts

4
ui-ngx/src/app/modules/home/components/widget/lib/analogue-compass.models.ts

@ -163,7 +163,7 @@ export const analogueCompassSettingsSchema: JsonSettingsSchema = {
form: [ form: [
{ {
key: 'majorTicks', key: 'majorTicks',
items:[ items: [
'majorTicks[]' 'majorTicks[]'
] ]
}, },
@ -267,7 +267,7 @@ export const analogueCompassSettingsSchema: JsonSettingsSchema = {
}, },
{ {
value: '700', value: '700',
label: '800' label: '700'
}, },
{ {
value: '800', value: '800',

2
ui-ngx/src/app/modules/home/components/widget/lib/analogue-compass.ts

@ -43,7 +43,7 @@ export class TbAnalogueCompass extends TbBaseGauge<AnalogueCompassSettings, Radi
protected createGaugeOptions(gaugeElement: HTMLElement, settings: AnalogueCompassSettings): RadialGaugeOptions { protected createGaugeOptions(gaugeElement: HTMLElement, settings: AnalogueCompassSettings): RadialGaugeOptions {
const majorTicks = (settings.majorTicks && settings.majorTicks.length > 0) ? deepClone(settings.majorTicks) : const majorTicks = (settings.majorTicks && settings.majorTicks.length > 0) ? deepClone(settings.majorTicks) :
['N','NE','E','SE','S','SW','W','NW']; ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
majorTicks.push(majorTicks[0]); majorTicks.push(majorTicks[0]);
return { return {

32
ui-ngx/src/app/modules/home/components/widget/lib/analogue-gauge.models.ts

@ -492,7 +492,7 @@ export const analogueGaugeSettingsSchema: JsonSettingsSchema = {
}, },
{ {
value: '700', value: '700',
label: '800' label: '700'
}, },
{ {
value: '800', value: '800',
@ -581,7 +581,7 @@ export const analogueGaugeSettingsSchema: JsonSettingsSchema = {
}, },
{ {
value: '700', value: '700',
label: '800' label: '700'
}, },
{ {
value: '800', value: '800',
@ -670,7 +670,7 @@ export const analogueGaugeSettingsSchema: JsonSettingsSchema = {
}, },
{ {
value: '700', value: '700',
label: '800' label: '700'
}, },
{ {
value: '800', value: '800',
@ -759,7 +759,7 @@ export const analogueGaugeSettingsSchema: JsonSettingsSchema = {
}, },
{ {
value: '700', value: '700',
label: '800' label: '700'
}, },
{ {
value: '800', value: '800',
@ -842,7 +842,7 @@ export abstract class TbBaseGauge<S, O extends GenericOptions> {
private gauge: BaseGauge; private gauge: BaseGauge;
protected constructor(protected ctx: WidgetContext, canvasId: string) { protected constructor(protected ctx: WidgetContext, canvasId: string) {
const gaugeElement = $('#'+canvasId, ctx.$container)[0]; const gaugeElement = $('#' + canvasId, ctx.$container)[0];
const settings: S = ctx.settings; const settings: S = ctx.settings;
const gaugeData: O = this.createGaugeOptions(gaugeElement, settings); const gaugeData: O = this.createGaugeOptions(gaugeElement, settings);
this.gauge = this.createGauge(gaugeData as O).draw(); this.gauge = this.createGauge(gaugeData as O).draw();
@ -859,7 +859,7 @@ export abstract class TbBaseGauge<S, O extends GenericOptions> {
const tvPair = cellData.data[cellData.data.length - const tvPair = cellData.data[cellData.data.length -
1]; 1];
const value = tvPair[1]; const value = tvPair[1];
if(value !== this.gauge.value) { if (value !== this.gauge.value) {
this.gauge.value = value; this.gauge.value = value;
} }
} }
@ -876,10 +876,10 @@ export abstract class TbBaseGauge<S, O extends GenericOptions> {
} }
} }
export abstract class TbAnalogueGauge<S extends AnalogueGaugeSettings, O extends GenericOptions> extends TbBaseGauge<S,O> { export abstract class TbAnalogueGauge<S extends AnalogueGaugeSettings, O extends GenericOptions> extends TbBaseGauge<S, O> {
protected constructor(ctx: WidgetContext, canvasId: string) { protected constructor(ctx: WidgetContext, canvasId: string) {
super(ctx,canvasId); super(ctx, canvasId);
} }
protected createGaugeOptions(gaugeElement: HTMLElement, settings: S): O { protected createGaugeOptions(gaugeElement: HTMLElement, settings: S): O {
@ -891,26 +891,26 @@ export abstract class TbAnalogueGauge<S extends AnalogueGaugeSettings, O extends
const keyColor = settings.defaultColor || dataKey.color; const keyColor = settings.defaultColor || dataKey.color;
const majorTicksCount = settings.majorTicksCount || 10; const majorTicksCount = settings.majorTicksCount || 10;
const total = maxValue-minValue; const total = maxValue - minValue;
let step = (total/majorTicksCount); let step = (total / majorTicksCount);
const valueInt = settings.valueInt || 3; const valueInt = settings.valueInt || 3;
const valueDec = getValueDec(this.ctx, settings); const valueDec = getValueDec(this.ctx, settings);
step = parseFloat(parseFloat(step+'').toFixed(valueDec)); step = parseFloat(parseFloat(step + '').toFixed(valueDec));
const majorTicks: number[] = []; const majorTicks: number[] = [];
const highlights: Highlight[] = []; const highlights: Highlight[] = [];
let tick = minValue; let tick = minValue;
while(tick<=maxValue) { while (tick <= maxValue) {
majorTicks.push(tick); majorTicks.push(tick);
let nextTick = tick+step; let nextTick = tick + step;
nextTick = parseFloat(parseFloat(nextTick+'').toFixed(valueDec)); nextTick = parseFloat(parseFloat(nextTick + '').toFixed(valueDec));
if (tick<maxValue) { if (tick < maxValue) {
const highlightColor = tinycolor(keyColor); const highlightColor = tinycolor(keyColor);
const percent = (tick-minValue)/total; const percent = (tick - minValue) / total;
highlightColor.setAlpha(percent); highlightColor.setAlpha(percent);
const highlight: Highlight = { const highlight: Highlight = {
from: tick, from: tick,

Loading…
Cancel
Save