2018年3月7日水曜日

Chart.js使ってみた。

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>
</head>
<body>
<canvas id="myChart"></canvas>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
  type: 'bar',
  data: {
    labels: ['1月', '2月', '3月', '4月', '5月', '6月', '7月','8月', '9月', '10月', '11月', '12月'],
    datasets: [
    {
      label: '売上',
      data: [12, 19, 3, 17, 6, 3, 7, 8, 10, 3, 4, 2],
//背景色
backgroundColor: 'rgba(255,99,132,0.2)',
//枠線の色
borderColor: 'rgba(255,99,132,1)',
//枠線の太さ
borderWidth: 2,
//背景色(ホバー時)
hoverBackgroundColor: 'rgba(255,99,132,0.4)',
//枠線の色(ホバー時)
hoverBorderColor: 'rgba(255,99,132,1.0)',
//枠線の太さ(ホバー時)
hoverBorderWidth: 1
    }, {
      label: '利益',
      data: [2, 29, 5, 5, 2, 3, 10, 9, 4, 6, 3, 2],
//背景色
backgroundColor: 'rgba(79,181,198,0.2)',
//枠線の色
borderColor: 'rgba(99,132,99,1)',
//枠線の太さ
borderWidth: 2,
//背景色(ホバー時)
hoverBackgroundColor: 'rgba(179,181,198,0.4)',
//枠線の色(ホバー時)
hoverBorderColor: 'rgba(179,181,198,1)',
//枠線の太さ(ホバー時)
hoverBorderWidth: 1

    }, {
      label: '契約数',
      data: [12, 19, 15, 51, 33, 12, 43, 12, 43, 84, 30, 21],
//面の表示
fill: false,
//線のカーブ
// lineTension: 0,
//背景色
backgroundColor: 'rgba(179,181,198,0.2)',
//枠線の色
borderColor: 'rgba(179,181,198,1)',
//結合点の枠線の色
pointBorderColor: 'rgba(179,181,198,1)',
//結合点の背景色
pointBackgroundColor: "#fff",
//結合点のサイズ
pointRadius: 5,
//結合点のサイズ(ホバー時)
pointHoverRadius: 8,
//結合点の背景色(ホバー時)
pointHoverBackgroundColor: 'rgba(179,181,198,1)',
//結合点の枠線の色(ホバー時)
pointHoverBorderColor: 'rgba(220,220,220,1)',
//結合点より外でマウスホバーを認識する範囲(ピクセル単位)
pointHitRadius: 15,

type: 'line'
    }]
  },
  options: {
      //軸の設定
      scales: {
          //縦軸の設定
          yAxes: [{
         //目盛りの設定
              ticks: {
                  //開始値を0にする
                  beginAtZero:true,
              }
          }]
      }
  }
});
</script>
</body>
</html>

0 件のコメント:

コメントを投稿

シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service [Unit] Description= stop httpgwd DefaultDependencies=no Before=shutdown.target RefuseManualStart=true ...