Google图表在图表标题中添加空格/空白 [英] Google Charts add blank space/whitespaces in Chart Title

查看:45
本文介绍了Google图表在图表标题中添加空格/空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在图表标题中添加空格或空格.我尝试了& nbsp和&#160,但是它不起作用.请提出建议.

How do I add blank space or whitespcaes in the chart title. I tried &nbsp and &#160 but it is not working. Please suggest.

推荐答案

google图表中的标签(标题,图例,轴)将不接受html,
但是您可以使用Unicode字符...

labels in google charts (title, legend, axis) will not accept html,
but you can use Unicode characters...

在这种情况下,请使用不间断空格-> \ u00A0

in this case, use the non-breaking space --> \u00A0

title: 'Begin>\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0<End'

请参阅以下工作摘要...

see following working snippet...

google.charts.load('current', {
  packages:['corechart']
}).then(function () {
  var data = google.visualization.arrayToDataTable([
    ['x', 'y0'],
    [0, 0],
    [1, 2],
    [2, 4],
    [3, 6]
  ]);

  var options = {
    title: 'Begin>\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0<End'
  };

  var container = document.getElementById('chart_div');
  var chart = new google.visualization.ColumnChart(container);

  chart.draw(data, options);
});

<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

这篇关于Google图表在图表标题中添加空格/空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆