Skip to content

Commit 44468c3

Browse files
committed
chore: lint
1 parent aead8af commit 44468c3

File tree

1 file changed

+35
-42
lines changed

1 file changed

+35
-42
lines changed

src/charting/renderer/AxisRenderer.ts

+35-42
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
import {Renderer} from './Renderer';
1+
import { Renderer } from './Renderer';
32
import { AxisBase } from '../components/AxisBase';
43
import { Align, Canvas, Paint, Style } from '@nativescript-community/ui-canvas';
54
import { ViewPortHandler } from '../utils/ViewPortHandler';
@@ -12,41 +11,39 @@ import { profile } from '@nativescript/core/profiling';
1211
* @author Philipp Jahoda
1312
*/
1413
export abstract class AxisRenderer extends Renderer {
15-
1614
/** base axis this axis renderer works with */
1715
protected mAxis: AxisBase;
1816

1917
/** transformer to transform values to screen pixels and return */
20-
protected mTrans: Transformer;
18+
protected mTrans: Transformer;
2119

2220
/**
2321
* palet object for the grid lines
2422
*/
25-
protected mGridPaint: Paint;
23+
protected mGridPaint: Paint;
2624

2725
/**
2826
* palet for the x-label values
2927
*/
30-
protected mAxisLabelPaint: Paint;
28+
protected mAxisLabelPaint: Paint;
3129

3230
/**
3331
* palet for the line surrounding the chart
3432
*/
35-
protected mAxisLinePaint: Paint;
33+
protected mAxisLinePaint: Paint;
3634

3735
/**
3836
* palet used for the limit lines
3937
*/
40-
protected mLimitLinePaint: Paint;
38+
protected mLimitLinePaint: Paint;
4139

42-
constructor( viewPortHandler: ViewPortHandler, trans: Transformer, axis: AxisBase) {
40+
constructor(viewPortHandler: ViewPortHandler, trans: Transformer, axis: AxisBase) {
4341
super(viewPortHandler);
4442

4543
this.mTrans = trans;
4644
this.mAxis = axis;
4745

48-
if(this.mViewPortHandler != null) {
49-
46+
if (this.mViewPortHandler != null) {
5047
this.mAxisLabelPaint = new Paint();
5148
this.mAxisLabelPaint.setAntiAlias(true);
5249
this.mAxisLabelPaint.setTextAlign(Align.LEFT);
@@ -73,7 +70,7 @@ export abstract class AxisRenderer extends Renderer {
7370
*
7471
* @return
7572
*/
76-
public getPaintAxisLabels() {
73+
public getPaintAxisLabels() {
7774
return this.mAxisLabelPaint;
7875
}
7976

@@ -83,7 +80,7 @@ export abstract class AxisRenderer extends Renderer {
8380
*
8481
* @return
8582
*/
86-
public getPaintGrid() {
83+
public getPaintGrid() {
8784
return this.mGridPaint;
8885
}
8986

@@ -93,7 +90,7 @@ export abstract class AxisRenderer extends Renderer {
9390
*
9491
* @return
9592
*/
96-
public getPaintAxisLine() {
93+
public getPaintAxisLine() {
9794
return this.mAxisLinePaint;
9895
}
9996

@@ -102,7 +99,7 @@ export abstract class AxisRenderer extends Renderer {
10299
*
103100
* @return
104101
*/
105-
public getTransformer() {
102+
public getTransformer() {
106103
return this.mTrans;
107104
}
108105

@@ -112,8 +109,7 @@ export abstract class AxisRenderer extends Renderer {
112109
* @param min - the minimum value in the data object for this axis
113110
* @param max - the maximum value in the data object for this axis
114111
*/
115-
public computeAxis( min, max, inverted) {
116-
112+
public computeAxis(min, max, inverted) {
117113
// calculate the starting and entry polet of the y-labels (depending on
118114
// zoom / contentrect bounds)
119115
if (this.mViewPortHandler != null && this.mViewPortHandler.contentWidth() > 10 && !this.mViewPortHandler.isFullyZoomedOutY()) {
@@ -122,13 +118,11 @@ export abstract class AxisRenderer extends Renderer {
122118
const p2 = this.mTrans.getValuesByTouchPoint(rect.left, rect.bottom);
123119

124120
if (!inverted) {
125-
126-
min = p2.y;
127-
max = p1.y;
121+
min = p2.y;
122+
max = p1.y;
128123
} else {
129-
130-
min = p1.y;
131-
max = p2.y;
124+
min = p1.y;
125+
max = p2.y;
132126
}
133127

134128
// MPPointD.recycleInstance(p1);
@@ -143,7 +137,7 @@ export abstract class AxisRenderer extends Renderer {
143137
*
144138
* @return
145139
*/
146-
protected computeAxisValues( min, max) {
140+
protected computeAxisValues(min, max) {
147141
const yMin = min;
148142
const yMax = max;
149143

@@ -163,12 +157,13 @@ export abstract class AxisRenderer extends Renderer {
163157

164158
// If granularity is enabled, then do not allow the interval to go below specified granularity.
165159
// This is used to avoid repeated values when rounding values for display.
166-
if (this.mAxis.isGranularityEnabled())
167-
{interval = interval < this.mAxis.getGranularity() ? this.mAxis.getGranularity() : interval;}
160+
if (this.mAxis.isGranularityEnabled()) {
161+
interval = interval < this.mAxis.getGranularity() ? this.mAxis.getGranularity() : interval;
162+
}
168163

169164
// Normalize interval
170-
const intervalMagnitude = Utils.roundToNextSignificant(Math.pow(10, Math.log10(interval)));
171-
const intervalSigDigit = (interval / intervalMagnitude);
165+
const intervalMagnitude = Utils.roundToNextSignificant(Math.pow(10, Math.log10(interval)));
166+
const intervalSigDigit = interval / intervalMagnitude;
172167
if (intervalSigDigit > 5) {
173168
// Use one order of magnitude higher, to avoid intervals like 0.9 or
174169
// 90
@@ -179,8 +174,7 @@ export abstract class AxisRenderer extends Renderer {
179174

180175
// force label count
181176
if (this.mAxis.isForceLabelsEnabled()) {
182-
183-
interval = range / (labelCount - 1);
177+
interval = range / (labelCount - 1);
184178
this.mAxis.mEntryCount = labelCount;
185179

186180
if (this.mAxis.mEntries.length < labelCount) {
@@ -199,9 +193,8 @@ export abstract class AxisRenderer extends Renderer {
199193

200194
// no forced count
201195
} else {
202-
203196
let first = interval === 0 ? 0 : Math.ceil(yMin / interval) * interval;
204-
if(this.mAxis.isCenterAxisLabelsEnabled()) {
197+
if (this.mAxis.isCenterAxisLabelsEnabled()) {
205198
first -= interval;
206199
}
207200

@@ -224,23 +217,23 @@ export abstract class AxisRenderer extends Renderer {
224217
}
225218

226219
for (f = first, i = 0; i < n; f += interval, ++i) {
220+
if (f === 0.0) {
221+
// Fix for negative zero case (Where value == -0.0, and 0.0 == -0.0)
222+
f = 0.0;
223+
}
227224

228-
if (f === 0.0) // Fix for negative zero case (Where value == -0.0, and 0.0 == -0.0)
229-
{f = 0.0;}
230-
231-
this.mAxis.mEntries[i] = f;
225+
this.mAxis.mEntries[i] = f;
232226
}
233227
}
234228

235229
// set decimals
236230
if (interval < 1) {
237-
this.mAxis.mDecimals = Math.ceil(-Math.log10(interval));
231+
this.mAxis.mDecimals = Math.ceil(-Math.log10(interval));
238232
} else {
239233
this.mAxis.mDecimals = 0;
240234
}
241235

242236
if (this.mAxis.isCenterAxisLabelsEnabled()) {
243-
244237
if (this.mAxis.mCenteredEntries.length < n) {
245238
this.mAxis.mCenteredEntries = [];
246239
}
@@ -258,26 +251,26 @@ export abstract class AxisRenderer extends Renderer {
258251
*
259252
* @param c
260253
*/
261-
public abstract renderAxisLabels( c: Canvas);
254+
public abstract renderAxisLabels(c: Canvas);
262255

263256
/**
264257
* Draws the grid lines belonging to the axis.
265258
*
266259
* @param c
267260
*/
268-
public abstract renderGridLines( c: Canvas);
261+
public abstract renderGridLines(c: Canvas);
269262

270263
/**
271264
* Draws the line that goes alongside the axis.
272265
*
273266
* @param c
274267
*/
275-
public abstract renderAxisLine( c: Canvas);
268+
public abstract renderAxisLine(c: Canvas);
276269

277270
/**
278271
* Draws the LimitLines associated with this axis to the screen.
279272
*
280273
* @param c
281274
*/
282-
public abstract renderLimitLines( c: Canvas);
275+
public abstract renderLimitLines(c: Canvas);
283276
}

0 commit comments

Comments
 (0)