Google 图表工具 - 更改 xAxis 的语言

发布于 2024-12-17 02:29:37 字数 51 浏览 3 评论 0原文

如何将语言(例如法国、波兰语、utf-8)更改(定义)为 vAxis 和 Y 轴标题?

How to change (define) language (f.ex. france, polish, utf-8) to vAxis
and YAxis titles?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

当爱已成负担 2024-12-24 02:29:37

使用 php 的 json_encode 对字符串进行编码以使用 UTF-8 字符编码:

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Year');
        data.addColumn('number', 'Sales');
        data.addColumn('number', 'Expenses');
        data.addRows(4);
        data.setValue(0, 0, '2004');
        data.setValue(0, 1, 1000);
        data.setValue(0, 2, 400);
        data.setValue(1, 0, '2005');
        data.setValue(1, 1, 1170);
        data.setValue(1, 2, 460);
        data.setValue(2, 0, '2006');
        data.setValue(2, 1, 860);
        data.setValue(2, 2, 580);
        data.setValue(3, 0, '2007');
        data.setValue(3, 1, 1030);
        data.setValue(3, 2, 540);

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, {width: 400, height: 240, title: <?= json_encode("żźćńąśłęó ŻŹĆŃĄŚŁĘÓ"); ?>,
        vAxis: {title:<?= json_encode("żźćńąśłęó ŻŹĆŃĄŚŁĘÓ"); ?>},
        hAxis: {title:<?= json_encode("żźćńąśłęó ŻŹĆŃĄŚŁĘÓ"); ?>}
        }

        );
      }
    </script>
  </head>

  <body>
    <div id="chart_div"></div>
  </body>
</html>

Encode your strings with with php's json_encode to use UTF-8 character encodings:

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Year');
        data.addColumn('number', 'Sales');
        data.addColumn('number', 'Expenses');
        data.addRows(4);
        data.setValue(0, 0, '2004');
        data.setValue(0, 1, 1000);
        data.setValue(0, 2, 400);
        data.setValue(1, 0, '2005');
        data.setValue(1, 1, 1170);
        data.setValue(1, 2, 460);
        data.setValue(2, 0, '2006');
        data.setValue(2, 1, 860);
        data.setValue(2, 2, 580);
        data.setValue(3, 0, '2007');
        data.setValue(3, 1, 1030);
        data.setValue(3, 2, 540);

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, {width: 400, height: 240, title: <?= json_encode("żźćńąśłęó ŻŹĆŃĄŚŁĘÓ"); ?>,
        vAxis: {title:<?= json_encode("żźćńąśłęó ŻŹĆŃĄŚŁĘÓ"); ?>},
        hAxis: {title:<?= json_encode("żźćńąśłęó ŻŹĆŃĄŚŁĘÓ"); ?>}
        }

        );
      }
    </script>
  </head>

  <body>
    <div id="chart_div"></div>
  </body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文