Skip to content

Commit

Permalink
fix: getAxisLabel has viewPortHandler as parameter for user to use
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Jul 14, 2021
1 parent 7deb707 commit dd50c42
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
24 changes: 13 additions & 11 deletions src/charting/formatter/IAxisValueFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AxisBase } from '../components/AxisBase';
import { ViewPortHandler } from '../utils/ViewPortHandler';

/**
* Created by Philipp Jahoda on 20/09/15.
Expand All @@ -9,15 +10,16 @@ import { AxisBase } from '../components/AxisBase';
*/
export interface IAxisValueFormatter {
/**
* Called when a value from an axis is to be formatted
* before being drawn. For performance reasons, avoid excessive calculations
* and memory allocations inside this method.
*
* @param value the value to be formatted
* @param axis the axis the value belongs to
* @return
*
* Extend {@link ValueFormatter} and use {@link ValueFormatter#getAxisLabel(float, AxisBase)}
*/
getAxisLabel(value, axis: AxisBase): string;
* Called when a value from an axis is to be formatted
* before being drawn. For performance reasons, avoid excessive calculations
* and memory allocations inside this method.
*
* @param value the value to be formatted
* @param axis the axis the value belongs to
* @param viewPortHandler the viewPortHandler
* @return
*
* Extend {@link ValueFormatter} and use {@link ValueFormatter#getAxisLabel(float, AxisBase)}
*/
getAxisLabel(value, axis: AxisBase, viewPortHandler: ViewPortHandler): string;
}
4 changes: 2 additions & 2 deletions src/charting/renderer/AxisRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export abstract class AxisRenderer extends Renderer {

for (let i = 0; i < labelCount; i++) {
axis.mEntries[i] = v;
axis.mLabels[i] = formatter.getAxisLabel(v, axis);
axis.mLabels[i] = formatter.getAxisLabel(v, axis, this.mViewPortHandler);
v += interval;
}
n = labelCount;
Expand Down Expand Up @@ -258,7 +258,7 @@ export abstract class AxisRenderer extends Renderer {
}

axis.mEntries[i] = f;
axis.mLabels[i] = formatter.getAxisLabel(f, axis);
axis.mLabels[i] = formatter.getAxisLabel(f, axis, this.mViewPortHandler);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/charting/renderer/YAxisRendererRadarChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class YAxisRendererRadarChart extends YAxisRenderer {

for (let i = 0; i < labelCount; i++) {
axis.mEntries[i] = v;
axis.mLabels[i] = formatter.getAxisLabel(v, axis);
axis.mLabels[i] = formatter.getAxisLabel(v, axis, this.mViewPortHandler);
v += step;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ export class YAxisRendererRadarChart extends YAxisRenderer {
}

axis.mEntries[i] = f;
axis.mLabels[i] = formatter.getAxisLabel(f, axis);
axis.mLabels[i] = formatter.getAxisLabel(f, axis, this.mViewPortHandler);
}
}

Expand Down

0 comments on commit dd50c42

Please sign in to comment.