2017-12-28 29 views
1

그래픽을 그리기 위해 C3 js로 자바 웹 애플리케이션을 개발했습니다. C3 js 툴팁에서 필자는 최소 4 자릿수의 숫자를 인쇄하려고합니다. 필자는 여러 환경, 데스크탑 및 모바일 (IOS & Android)에서 애플리케이션을 테스트하지만 안드로이드에서는 툴팁의 숫자가 단 3 자릿수로 인쇄됩니다. 여기 안드로이드 숫자로 실행되는 자바 웹 애플리케이션 번호

는 C3 JS는 툴팁을 그리기 위해 사용하는 내 JS 코드 :

tooltip: { 
           grouped: false, 
           contents: function(d, defaultTitleFormat, defaultValueFormat, color) { 
           var $$ = this, config = $$.config, titleFormat = config.tooltip_format_title || defaultTitleFormat, nameFormat = config.tooltip_format_name 
             || function(name) { 
              return name; 
             }, valueFormat = config.tooltip_format_value || defaultValueFormat, text, i, title, value, name, bgcolor; 

           for (i = 0; i < d.length; i++) { 
            if (!(d[i] && (d[i].value || d[i].value === 0))) { 
            continue; 
            } 

            if (!text) { 
            title = titleFormat ? titleFormat(d[i].x) : d[i].x; 
            text = "<table class='" + $$.CLASS.tooltip + "'>" 
              + (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : ""); 
            } 

            name = nameFormat(d[i].name); 

            var fundName = dojo.query('#hiddenFundName')[0].value; 
            var raiffeisenAcumulareFundName = 'raiffeisen acumulare'; 
            if (fundName.toLowerCase() == raiffeisenAcumulareFundName) { 
            value = valueFormat(d[i].value.toLocaleString("en-US", { 
             minimumFractionDigits: 6 
            }), d[i].ratio, d[i].id, d[i].index); 
            } else { 
            value = valueFormat(d[i].value.toLocaleString("en-US", { 
             minimumFractionDigits: 4 
            }), d[i].ratio, d[i].id, d[i].index); 
            } 
            bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); 
            var initialNAV = dojo.attr(query("#initialnavPU")[0], "value"); 
            text += "<tr class='" + $$.CLASS.tooltipName + "-" + d[i].id + "'>"; 
            text += "<td class='value'>" + '<h5>' + titleFormat(d[i].x) + '</h5>' + '<h5>Valoarea unitatii de fond: ' + value 
              + '</h5>' + '<h5>Randament: ' + ((d[i].value/initialNAV - 1) * 100).toFixed(2) + '%' + '</h5></td>'; 
            text += "</tr>"; 
           } 

           return text + "</table>"; 
           } 
          } 

당신이 내 전화 번호가 나는 인쇄 할 소수 자릿수를 존중하지 않는 이유 어떤 생각을 가지고 있습니까? Android OS에서만 사용할 수 있습니다.

답변

1

를 추가해보십시오 형식 툴팁 옵션 : 이미 d3.js에서이 포맷 기능을 사용했습니다

tooltip: { 
    format: { 
     value: function (value) { 
      return d3.format('.4f')(value); 
     } 
    }, 
    ... 
    // your current options 
} 
+0

하지만 안드로이드 휴대 전화가 고장 때문에 불행히도 나는 지금 테스트 할 수 없습니다. .. 귀하의 솔루션/내 솔루션이 괜찮 으면, 나는 대답도 게시 할 것입니다. 고맙습니다! :) –