com.github.mikephil.charting.utils.Utils.formatNumber()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(208)

本文整理了Java中com.github.mikephil.charting.utils.Utils.formatNumber()方法的一些代码示例,展示了Utils.formatNumber()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.formatNumber()方法的具体详情如下:
包路径:com.github.mikephil.charting.utils.Utils
类名称:Utils
方法名:formatNumber

Utils.formatNumber介绍

[英]Formats the given number to the given number of decimals, and returns the number as a string, maximum 35 characters. If thousands are separated, the separating character is a dot (".").
[中]将给定的数字格式化为给定的小数位数,并以字符串形式返回该数字,最多35个字符。如果数千个字符被分隔开,则分隔字符是一个点(“.”)。

代码示例

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Formats the given number to the given number of decimals, and returns the
 * number as a string, maximum 35 characters. If thousands are separated, the separating
 * character is a dot (".").
 *
 * @param number
 * @param digitCount
 * @param separateThousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number, int digitCount, boolean separateThousands) {
  return formatNumber(number, digitCount, separateThousands, '.');
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public void refreshContent(Entry e, Highlight highlight) {
  if (e instanceof CandleEntry) {
    CandleEntry ce = (CandleEntry) e;
    tvContent.setText(Utils.formatNumber(ce.getHigh(), 0, true));
  } else {
    tvContent.setText(Utils.formatNumber(e.getY(), 0, true));
  }
  super.refreshContent(e, highlight);
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public void refreshContent(Entry e, Highlight highlight) {
  if (e instanceof BarEntry) {
    BarEntry be = (BarEntry) e;
    if(be.getYVals() != null) {
      // draw the stack value
      tvContent.setText(Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true));
    } else {
      tvContent.setText(Utils.formatNumber(be.getY(), 0, true));
    }
  } else {
    tvContent.setText(Utils.formatNumber(e.getY(), 0, true));
  }
  super.refreshContent(e, highlight);
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

/**
 * Formats the given number to the given number of decimals, and returns the
 * number as a string, maximum 35 characters. If thousands are separated, the separating
 * character is a dot (".").
 *
 * @param number
 * @param digitCount
 * @param separateThousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number, int digitCount, boolean separateThousands) {
  return formatNumber(number, digitCount, separateThousands, '.');
}

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

/**
 * Formats the given number to the given number of decimals, and returns the
 * number as a string, maximum 35 characters. If thousands are separated, the separating
 * character is a dot (".").
 *
 * @param number
 * @param digitCount
 * @param separateThousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number, int digitCount, boolean separateThousands) {
  return formatNumber(number, digitCount, separateThousands, '.');
}

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

/**
 * Formats the given number to the given number of decimals, and returns the
 * number as a string, maximum 35 characters. If thousands are separated, the separating
 * character is a dot (".").
 *
 * @param number
 * @param digitCount
 * @param separateThousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number, int digitCount, boolean separateThousands) {
  return formatNumber(number, digitCount, separateThousands, '.');
}

代码示例来源:origin: WenWangAndroid/ChartManager

/**
 * Formats the given number to the given number of decimals, and returns the
 * number as a string, maximum 35 characters. If thousands are separated, the separating
 * character is a dot (".").
 *
 * @param number
 * @param digitCount
 * @param separateThousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number, int digitCount, boolean separateThousands) {
  return formatNumber(number, digitCount, separateThousands, '.');
}

代码示例来源:origin: zhuanghongji/mp-android-chart

@Override
public void refreshContent(Entry e, Highlight highlight) {
  if (e instanceof CandleEntry) {
    CandleEntry ce = (CandleEntry) e;
    tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true));
  } else {
    tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true));
  }
  super.refreshContent(e, highlight);
}

代码示例来源:origin: tiandawu/IotXmpp

@Override
public void refreshContent(Entry e, Highlight highlight) {
  if (e instanceof CandleEntry) {
    CandleEntry ce = (CandleEntry) e;
    tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true));
  } else {
    tvContent.setText("" + e.getVal());
  }
}

代码示例来源:origin: zhuanghongji/mp-android-chart

@Override
public void refreshContent(Entry e, Highlight highlight) {
  if (e instanceof BarEntry) {
    BarEntry be = (BarEntry) e;
    if(be.getYVals() != null) {
      // draw the stack value
      tvContent.setText("" + Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true));
    } else {
      tvContent.setText("" + Utils.formatNumber(be.getY(), 0, true));
    }
  } else {
    tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true));
  }
  super.refreshContent(e, highlight);
}

相关文章