GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid creating a new formatter if null · FlyingAndroid/MPAndroidChart@2176873

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • MPChartLib/src/main/java/com/github/mikephil/charting
    • charts
      • Chart.java
    • data
      • BaseDataSet.java
    • utils
      • Utils.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java‎

Copy file name to clipboardExpand all lines: MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
9898
/**
9999
* default value-formatter, number of digits depends on provided chart-data
100100
*/
101-
protected DefaultValueFormatter mDefaultFormatter = new DefaultValueFormatter(0);
101+
protected DefaultValueFormatter mDefaultValueFormatter = new DefaultValueFormatter(0);
102102

103103
/**
104104
* paint object used for drawing the description text in the bottom right
@@ -305,8 +305,8 @@ public void setData(T data) {
305305
setupDefaultFormatter(data.getYMin(), data.getYMax());
306306

307307
for (IDataSet set : mData.getDataSets()) {
308-
if (set.needsFormatter() || set.getValueFormatter() == mDefaultFormatter)
309-
set.setValueFormatter(mDefaultFormatter);
308+
if (set.needsFormatter() || set.getValueFormatter() == mDefaultValueFormatter)
309+
set.setValueFormatter(mDefaultValueFormatter);
310310
}
311311

312312
// let the chart know there is new data
@@ -393,7 +393,7 @@ protected void setupDefaultFormatter(float min, float max) {
393393
int digits = Utils.getDecimals(reference);
394394

395395
// setup the formatter with a new number of digits
396-
mDefaultFormatter.setup(digits);
396+
mDefaultValueFormatter.setup(digits);
397397
}
398398

399399
/**
@@ -981,7 +981,7 @@ public XAxis getXAxis() {
981981
* @return
982982
*/
983983
public IValueFormatter getDefaultValueFormatter() {
984-
return mDefaultFormatter;
984+
return mDefaultValueFormatter;
985985
}
986986

987987
/**
Collapse file

‎MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.java‎

Copy file name to clipboardExpand all lines: MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public void setValueFormatter(IValueFormatter f) {
268268
@Override
269269
public IValueFormatter getValueFormatter() {
270270
if (needsFormatter())
271-
return new DefaultValueFormatter(1);
271+
return Utils.getDefaultValueFormatter();
272272
return mValueFormatter;
273273
}
274274

Collapse file

‎MPChartLib/src/main/java/com/github/mikephil/charting/utils/Utils.java‎

Copy file name to clipboardExpand all lines: MPChartLib/src/main/java/com/github/mikephil/charting/utils/Utils.java
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import android.view.View;
1919
import android.view.ViewConfiguration;
2020

21+
import com.github.mikephil.charting.formatter.DefaultValueFormatter;
22+
import com.github.mikephil.charting.formatter.IValueFormatter;
23+
2124
import java.util.List;
2225

2326
/**
@@ -233,6 +236,19 @@ public static void calcTextSize(Paint paint, String demoText, FSize outputFSize)
233236
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
234237
};
235238

239+
private static IValueFormatter mDefaultValueFormatter = generateDefaultValueFormatter();
240+
241+
private static IValueFormatter generateDefaultValueFormatter() {
242+
final DefaultValueFormatter formatter = new DefaultValueFormatter(1);
243+
return formatter;
244+
}
245+
246+
/// - returns: The default value formatter used for all chart components that needs a default
247+
public static IValueFormatter getDefaultValueFormatter()
248+
{
249+
return mDefaultValueFormatter;
250+
}
251+
236252
/**
237253
* Formats the given number to the given number of decimals, and returns the
238254
* number as a string, maximum 35 characters. If thousands are separated, the separating

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.