You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何设置jqplot水平条形图的pointLabels字体大小?

解决jqPlot水平条形图PointLabels字体大小设置问题

你已经搞定坐标轴字体大小的设置啦,其实pointLabels的字体大小配置很简单,直接在它的配置项里添加fontSize参数就能实现!

把你的代码修改成下面这样,就能让数据标签的字体大小和坐标轴保持一致:

var plot2 = $.jqplot('chart2', [values], {
  seriesDefaults: {
    renderer: $.jqplot.BarRenderer,
    rendererOptions: {
      barDirection: 'horizontal',
      barPadding: 40,
      barMargin: 40,
      barWidth: 10
    },
    pointLabels: {
      show: true,
      location: 'e',
      edgeTolerance: -15,
      formatString: '%s',
      fontSize: '30pt' // 新增这一行,设置数据标签字体大小
    }
  },
  axes: {
    xaxis: {
      tickOptions: { fontSize: '30pt' }
    },
    yaxis: {
      renderer: $.jqplot.CategoryAxisRenderer,
      tickOptions: { fontSize: '30pt' } // 若需要y轴字体统一也可添加
    }
  }
});

额外拓展:

如果之后想要调整数据标签的其他样式,还可以在pointLabels里添加这些参数:

  • fontFamily:设置字体类型,比如'Arial'
  • fontWeight:设置字体粗细,比如'bold'
  • textColor:设置字体颜色,比如'#333'

内容的提问来源于stack exchange,提问作者Prefijo Sustantivo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:43:36