Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sv translation
languageja

BellaDati charts.jsライブラリは、あなたのWebページ上で直接BellaDati JSONチャートデータをレンダリングできる。

Tip

あなたはGitHubの上でこの例https://github.com/BellaDati/belladati-charts/tree/master/exampleを見つけることができる

前提条件

BellaDati-charts.jsは以下のjavascriptのライブラリを要求する。

ステップバイステップ

  1. ページ内のライブラリを要求したリンク

    Code Block
    themeEclipse
    languagexml
    <head>
    ...
       <script src="http://code.jquery.com/jquery-1.7.1.js"></script>
       <script src="http://rawgit.com/DmitryBaranovskiy/raphael/v2.1.4/raphael-min.js"></script>
       <script src="http://rawgit.com/BellaDati/belladati-charts/master/belladati-charts-min.js"></script>
    ...
    <head>
  2. JSON形式でチャートデータを定義または取得

  3. チャートがレンダリングされるコンテナを定義

    Code Block
    themeEclipse
    languagexml
    <div id="chart" style="width: 500px; height: 400px; border: 1px solid silver"></div>
  4. Render the chart by executing Charts.createAndRender("container_id", "json_chart_data");を実行することで、チャートをレンダリングする。


    Code Block
    themeEclipse
    languagejs
    var $container = $("#chart");
    var chart = Charts.createAndRender("chart", getChartData());
    chart.resize($container.width(), $container.height());

Example

例えば

ここですべて一緒です。HTMLサンプルファイルをダウンロードするためにクリックするAnd here it is all-together. Click to download a sample HTML file.

Code Block
themeEclipse
languagexml
collapsetrue
<html>
    <head>
        <title>BellaDati charts.js test page</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script src="http://code.jquery.com/jquery-1.7.1.js"></script>
        <script src="http://rawgit.com/DmitryBaranovskiy/raphael/v2.1.4/raphael-min.js"></script>
        <script src="http://rawgit.com/BellaDati/belladati-charts/master/belladati-charts-min.js"></script>
    <head>
 
    <body>
      Test chart
      <div id="chart" style="width: 500px; height: 400px; border: 1px solid silver">
      </div>
 
	  <script>
        var $container = $("#chart");
        var chart = Charts.createAndRender("chart", getChartData());
        chart.resize($container.width(), $container.height());
 
        function getChartData() {
          return {
            "x_axis": {
              "colour": "#86bbca",
              "grid-colour": "#c1d8df",
              "steps": 0,
              "labels": {
                "colour": "#484848",
                "labels": [
                  "I / 2011",
                  "II / 2011",
                  "III / 2011"
                ]
              }
            },
            "y_axis": {
              "colour": "#86bbca",
              "grid-colour": "#c1d8df",
              "steps": 25,
              "min": 0,
              "max": 100,
              "labels": {
                "colour": "#484848",
                "labels": [
                  {
                    "text": "0",
                    "y": 0
                  },
                  {
                    "text": "25",
                    "y": 25
                  },
                  {
                    "text": "50",
                    "y": 50
                  },
                  {
                    "text": "75",
                    "y": 75
                  },
                  {
                    "text": "100",
                    "y": 100
                  }
                ]
              }
            },
            "bg_colour": "#ffffff",
            "is_decimal_separator_comma": 1,
            "is_thousand_separator_disabled": 1,
            "chartId": "chart_1964",
            "elements": [
              {
                "type": "bar_glass",
                "text": "ga:newVisits (avg)",
                "values": [
                  {
                    "top": "11.5",
                    "tip": "I / 2011 (ga:newVisits (avg))<br>11,5",
                    "label": "11,5",
                  },
                  {
                    "top": "16.032967032967033",
                    "tip": "II / 2011 (ga:newVisits (avg))<br>16,03297",
                    "label": "16,03297",
                  },
                  {
                    "top": "16.75",
                    "tip": "III / 2011 (ga:newVisits (avg))<br>16,75",
                    "label": "16,75",
                  }
                ],
                "colour": "#19527d"
              },
              {
                "type": "bar_glass",
                "text": "ga:newVisits (max)",
                "values": [
                  {
                    "top": "32",
                    "tip": "I / 2011 (ga:newVisits (max))<br>32",
                    "label": "32",
                  },
                  {
                    "top": "57",
                    "tip": "II / 2011 (ga:newVisits (max))<br>57",
                    "label": "57",
                  },
                  {
                    "top": "82",
                    "tip": "III / 2011 (ga:newVisits (max))<br>82",
                    "label": "82",
                  }
                ],
                "colour": "#f4b800"
              }
            ],
            "tooltip": {
              "mouse": "2",
              "shadow": true,
              "stroke": 1,
              "colour": "#484848",
              "background": "#ffffff"
            },
            "options": {}
          };
        }
      </script>
	</body>
</html>