【问题标题】:C3.js tootltip fontC3.js 工具提示字体
【发布时间】:2017-06-02 19:18:15
【问题描述】:

我在 `c3js 中尝试了这个示例。

Demo

有谁知道如何增加 Tooltip 内容(标题和值)的字体大小?

任何帮助将不胜感激。

【问题讨论】:

    标签: javascript d3.js c3.js


    【解决方案1】:

    您可以将自定义font-size 设置为tspan 元素:

    tspan {
        font-size: 20px;
    }
    

    【讨论】:

      【解决方案2】:

      覆盖以下选择器的字体值:

      .c3-tooltip th {
        /* for the header */
      }
      
      .c3-tooltip td.name {
        /* for the title cells */
      }
      
      .c3-tooltip td.value {
        /* for the value cells */
      }
      

      示例

      var chart = c3.generate({
          data: {
              columns: [
                  ['data1', 30000, 20000, 10000, 40000, 15000, 250000],
                  ['data2', 100, 200, 100, 40, 150, 250]
              ],
              axes: {
                  data2: 'y2'
              }
          },
          axis : {
              y : {
                  tick: {
                      format: d3.format("s")
                  }
              },
              y2: {
                  show: true,
                  tick: {
                      format: d3.format("$")
                  }
              }
          },
          tooltip: {
              format: {
                  title: function (d) { return 'Data ' + d; },
                  value: function (value, ratio, id) {
                      var format = id === 'data1' ? d3.format(',') : d3.format('$');
                      return format(value);
                  }
      //            value: d3.format(',') // apply this format to both y and y2
              }
          }
      });
      .c3-tooltip th {
        /* for the header */
        color: red !important;
      }
      
      .c3-tooltip td.name {
        /* for the title cells */
        color: green;
      }
      
      .c3-tooltip td.value {
        /* for the value cells */
        color: blue;
      }
      <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.12/c3.min.css" rel="stylesheet"/>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.12/c3.min.js"></script>
      <div id='chart'></div>

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多