fallback to toLocaleString(); #2103
Costa Tsaousis (ktsaou) committed
Apr 19, 2017 at 22:22 UTC
8889e7941124803cafb87318a23be99dfd82a29c
2 files changed
+66
-2
web/dashboard.js
+65
-1
@@ -737,10 +737,11 @@ var NETDATA = window.NETDATA || {};
737
// fast numbers formating
738
739
NETDATA.fastNumberFormat = {
740
+ numberFormatWorks: undefined,
741
formatters_fixed: [],
742
formatters_zero_based: [],
743
743
- get: function(min, max) {
744
+ getIntlNumberFormat: function(min, max) {
745
var key = max;
746
if(min == max) {
747
if(typeof this.formatters_fixed[key] == 'undefined')
@@ -783,6 +784,69 @@ var NETDATA = window.NETDATA || {};
784
maximumFractionDigits: max
785
});
786
}
787
+ },
788
+
789
+ getLocaleString: function(min, max) {
790
+ var key = max;
791
+ if(min == max) {
792
+ if(typeof this.formatters_fixed[key] == 'undefined')
793
+ this.formatters_fixed[key] = {
794
+ format: function (value) {
795
+ return value.toLocaleString(undefined, {
796
+ // style: 'decimal',
797
+ // minimumIntegerDigits: 1,
798
+ // minimumSignificantDigits: 1,
799
+ // maximumSignificantDigits: 1,
800
+ useGrouping: true,
801
+ minimumFractionDigits: min,
802
+ maximumFractionDigits: max
803
+ });
804
+ }
805
+ };
806
+
807
+ return this.formatters_fixed[key];
808
+ }
809
+ else if(min == 0) {
810
+ if(typeof this.formatters_zero_based[key] == 'undefined')
811
+ this.formatters_zero_based[key] = {
812
+ format: function (value) {
813
+ return value.toLocaleString(undefined, {
814
+ // style: 'decimal',
815
+ // minimumIntegerDigits: 1,
816
+ // minimumSignificantDigits: 1,
817
+ // maximumSignificantDigits: 1,
818
+ useGrouping: true,
819
+ minimumFractionDigits: min,
820
+ maximumFractionDigits: max
821
+ });
822
+ }
823
+ };
824
+
825
+ return this.formatters_zero_based[key];
826
+ }
827
+ else {
828
+ return {
829
+ format: function (value) {
830
+ return value.toLocaleString(undefined, {
831
+ // style: 'decimal',
832
+ // minimumIntegerDigits: 1,
833
+ // minimumSignificantDigits: 1,
834
+ // maximumSignificantDigits: 1,
835
+ useGrouping: true,
836
+ minimumFractionDigits: min,
837
+ maximumFractionDigits: max
838
+ });
839
+ }
840
+ };
841
+ }
842
+ },
843
+
844
+ get: function(min, max) {
845
+ //console.log('numberformat');
846
+ //this.get = this.getIntlNumberFormat;
847
+ console.log('localestring');
848
+ this.get = this.getLocaleString;
849
+ return this.get(min, max);
850
}
851
};
852
web/index.html
+1
-1
@@ -3523,4 +3523,4 @@
3523
</div>
3524
</body>
3525
</html>
3526
-<script type="text/javascript" src="dashboard.js?v20170419-1"></script>
3526
+<script type="text/javascript" src="dashboard.js?v20170419-2"></script>