1

在此处输入图像描述

我正在尝试使用 [titleFontSize: 12..] 和各种组合来减小字体大小。但不工作。我用于 [valueFontSize: ..] 和 [labelFontSize: ..]

如何更改标题、值和标签的字体大小?

代码:

<script src="js/raphael-2.1.4.min.js"></script>
<script src="js/justgage.js">

<script type="text/javascript">
  var gD = new JustGage({
    id: "jgDownload",
    value: 67,
    decimals: 2,
    min: 0,
    max: 1000,
    title: "Download",
    titleFontSize: 12,
    titlePosition: "below",
    titleFontColor: "red",
    titleFontFamily: "Georgia",
    titlePosition: "below",
    valueFontColor: "blue",
    valueFontFamily: "Georgia"
    label: "Mbps",
    lableFontSize: "10px",
    width: 300,
    height: 200,
    relativeGaugeSize: true,
    levelColors: [
          "#E63454",
          "#AC001F",
          "#F6AD37",
          "#B87200",
          "#24A081",
          "#007759",
          "#026071",
          "#015C71"
        ],
    pointer: true,
    counter: true,    
  });
</script>

var gD = new JustGage({
  id: "jgDownload",
  value: 67,
  decimals: 2,
  min: 0,
  max: 1000,
  title: "Download",
  titleFontSize: "5px",
  titlePosition: "below",
  valueFontFamily: "Georgia",
  valueFontSize: "5px",
  label: "Mbps",
  width: 300,
  height: 200,
  relativeGaugeSize: true,
  levelColors: [
    "#E63454",
    "#AC001F",
    "#F6AD37",
    "#B87200",
    "#24A081",
    "#007759",
    "#026071",
    "#015C71"
  ],
  pointer: true,
  counter: true,
});
#divDownloadOuter {
  width: 50%;
  clear: both;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.4/raphael-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/justgage/1.2.2/justgage.js"></script>
<div id="divDownloadOuter">
  <div id="jgDownload"></div>
</div>

JSFiddle:链接

4

3 回答 3

4

尝试使用 titleMinFontSize。它会起作用的。

titleMinFontSize: 20,

检查此链接以获取其他属性。

于 2016-06-07T09:45:09.527 回答
3

使用 CSS 的解决方案:

/* Title */
#jgDownload text:nth-child(6) tspan{
  font-size: 0.8em !important;  
}

/* Value */
#jgDownload text:nth-child(7) tspan{
  font-size: 0.5em !important;  
}

/* Label */
#jgDownload text:nth-child(8) tspan, #jgDownload text:nth-child(9) tspan, #jgDownload text:nth-child(10) tspan{
  font-size: 0.9em !important;  
}

使用示例检查此链接:https ://jsfiddle.net/amitshahc/gf0gm69j/5/

于 2016-06-08T03:18:06.843 回答
1

为了让它与 justGage v1.2.2 一起工作,我使用了以下内容:

/* Value */
#jgDownload > svg:nth-child(1) > text:nth-child(6) {
    font-size: 0.8em !important;
}

('text:nth-child' 值指示要更改的元素,即 text:nth-child(8) 和 text:nth-child(9) 表示标签)

对我温柔一点,因为这是我的第一篇文章!

于 2017-01-22T14:14:31.433 回答