1

https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Example

如何将工具提示中的小数点从句点更改为逗号?

4

1 回答 1

0

Google Charts 使用ICU DecimalFormat Class的一个子集。不幸的是,据我所知,该子集不包括更改语言环境的能力。如果您确实想尝试,您可以尝试使用使用逗号作为小数分隔符的区域设置(例如欧洲)的此 javascript 版本(这会打印出所有区域设置信息,因此您必须深入研究参考以找出如何首先设置单个语言环境):

// Normally we would have a GUI with a menu for this
int32_t locCount;
const Locale* locales = NumberFormat::getAvailableLocales(locCount);
double myNumber = -1234.56;
UErrorCode success = U_ZERO_ERROR;
NumberFormat* form;
// Print out a number with the localized number, currency and percent
// format for each locale.
UnicodeString countryName;
UnicodeString displayName;
UnicodeString str;
UnicodeString pattern;
Formattable fmtable;
for (int32_t j = 0; j < 3; ++j) {
  cout << endl << "FORMAT " << j << endl;
  for (int32_t i = 0; i < locCount; ++i) {
    if (locales[i].getCountry(countryName).size() == 0) {
      // skip language-only
      continue;
    }
    switch (j) {
      case 0:
        form = NumberFormat::createInstance(locales[i], success ); break;
      case 1:
        form = NumberFormat::createCurrencyInstance(locales[i], success ); break;
      default:
        form = NumberFormat::createPercentInstance(locales[i], success ); break;
    }
    if (form) {
      str.remove();
      pattern = ((DecimalFormat*)form)->toPattern(pattern);
      cout << locales[i].getDisplayName(displayName) << ": " << pattern;
      cout << " -> " << form->format(myNumber,str) << endl;
      form->parse(form->format(myNumber,str), fmtable, success);
      delete form;
    }
  }
}
于 2013-03-13T00:16:55.053 回答