123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="chart-doughnut-01">
<canvas id="chart-doughnut-01" height="215" width="215"></canvas>
<div class="data">
85%
</div>
</div>

<div class="section02">
<div class="chart-bar-01">
<canvas id="chart-bar-01" width="484" height="185"></canvas>
<div class="data">
<ul>
<li>2,842</li>
<li>4,961</li>
<li>6,569</li>
<li>7,571</li>
<li>8,274</li>
<li>7,581</li>
</ul>
</div>
</div>

<div class="section03">
<div class="chart-xbar-01">
<div class="data-01" style="width:94%"></div>
</div>

<div class="chart-xbar-01">
<div class="data-02" style="width:15%"></div>
</div>

<div class="chart-xbar-01">
<div class="data-01" style="width:23%"></div>
</div>

<div class="chart-xbar-01">
<div class="data-01" style="width:37%"></div>
</div>

</div>

</body>
</html>
            
          
!
            
              /*  これは消してください */
body {
	padding-top: 1000px;
}
.section02 {
	margin-top: 500px;
}
.section03 {
	margin: 500px 0 1000px;
}
/*  これは消してください */


.chart-doughnut-01 {
	position: relative;
	width: 215px;
	height: 215px;
	display: inline-block;
}
.chart-doughnut-01 .data {
	display: none;
	position: absolute;
	top: 0;
	bottom: 0;
	right: 0;
	left: 0;
	margin: auto;
	width: 90px;
	height: 55px;
  font-size: 56px;
  font-weight: bold;
}
.chart-bar-01 {
	position: relative;
	display: inline-block;
}
.chart-bar-01 .data {
	display: none;
	position: absolute;
	top: 0px;
	left: 46px;
}
.chart-bar-01 .data li {
	list-style: none;
	font-size: 15px;
	font-family: Century Gothic;
}
.chart-bar-01 .data li span {
	font-size: 12px;
	margin-left: 2px;
}

.chart-bar-01 .data li:first-child {
	position: absolute;
	top: 95px;
	left: 15px;
	width: 52px;
}
.chart-bar-01 .data li:nth-child(2) {
    position: absolute;
    top: 62px;
    left: 86px;
    width: 52px;
}
.chart-bar-01 .data li:nth-child(3) {
    position: absolute;
    top: 37px;
    left: 158px;
    width: 52px;
}
.chart-bar-01 .data li:nth-child(4) {
    position: absolute;
    top: 20px;
    left: 229px;
    width: 52px;
}
.chart-bar-01 .data li:nth-child(5) {
    position: absolute;
    top: 12px;
    left: 300px;
    width: 52px;
}
.chart-bar-01 .data li:nth-child(6) {
    position: absolute;
    top: 20px;
    left: 372px;
    width: 52px;
}

.chart-xbar-01 {
  margin-bottom: 20px;
  width: 360px;
  height: 40px;
  background: #ccc;
  position: relative;
}
.chart-xbar-01.active [class^="data-"] {
  height: 40px;
  animation: anime1 1s 1 ease;
  background: #ff8603
}
@-webkit-keyframes anime1 {
  0% {width: 0px;}
}
@keyframes anime1 {
  0% {width: 0px;}
}
            
          
!
            
              $(function(){
  'use strict';
  (function(){
    var $win = $(window);
    var position01 = $('.chart-doughnut-01').offset().top - ($win.height() / 3 * 2);// ドーナツグラフのy軸
    var position02 = $('.chart-bar-01').offset().top - ($win.height() / 3 * 2);// 縦軸棒グラフのy軸
    var position03 = $('.chart-xbar-01').offset().top - ($win.height() / 3 * 2);// 横軸棒グラフのy軸
    var flag = null;
    var flag02 = null;


  //ドーナッツ1
  var doughnutData = [
    {
      value: 85,
      color:'#ff8603'
    },
    {
      value : 15,
      color : '#eee'
    }
  ];

  var options = {
      // セグメントの枠線の表示
      segmentShowStroke : true,
      // セグメントの枠線の色
      segmentStrokeColor : '#fff',
      // セグメントの枠線の太さ
      segmentStrokeWidth : 0,
      // 中央の円のカットの大きさ ( パーセント )
      percentageInnerCutout : 72,
      // アニメーション終了後に実行する処理
      onAnimationComplete : function() {
        $('.chart-doughnut-01 .data').fadeIn();
      }
  };

  //棒グラフ1(青)
  var barChartData = {
      labels : ['1月', '2月', '3月', '4月', '5月', '6月'],
      datasets : [
          {
              fillColor : '#257dcf',
              strokeColor : 'rgba(0, 0, 0, 1)',
              data : [2842, 4961, 6569, 7571, 8274, 7581]
          }
      ]
  };

  // オプション
  var options02 = {
      // X, Y 軸ラインが棒グラフの値の上にかぶさるようにするか
      scaleOverlay : true,
      // 値の開始値などを自分で設定するか
      scaleOverride : true,
      // 以下の 3 オプションは scaleOverride: true の時に使用
      // Y 軸の値のステップ数
      // e.g. 10 なら Y 軸の値は 10 個表示される
      scaleSteps : 5,
      // Y 軸の値のステップする大きさ
      // e.g. 10 なら 0, 10, 20, 30 のように増えていく
      scaleStepWidth : 2000,
      // Y 軸の値の始まりの値
      scaleStartValue : 0,
      // X, Y 軸ラインの色
      scaleLineColor : '#444',
      // X, Y 軸ラインの幅
      scaleLineWidth : 1,
      // ラベルの表示 ( Y 軸の値 )
      scaleShowLabels : true,
      // ラベルの表示フォーマット ( Y 軸の値 )
      scaleLabel : '<%=value%>',
      // X, Y 軸値のフォント
      scaleFontFamily : '"Century Gothic"',
      // X, Y 軸値のフォントサイズ
      scaleFontSize : 12,
      // X, Y 軸値のフォントスタイル, normal, italic など
      scaleFontStyle : 'normal',
      // X, Y 軸値の文字色
      scaleFontColor : '#666',
      // グリッドライン ( Y 軸の横ライン ) の表示
      scaleShowGridLines : true,
      // グリッドラインの色
      scaleGridLineColor : 'rgba(0, 0, 0, .05)',
      // グリッドラインの幅
      scaleGridLineWidth : 1,
      // 棒グラフの値部分の枠線の表示
      barShowStroke : true,
      // 棒グラフの値部分の枠線の幅
      barStrokeWidth : 0,
      // 棒グラフの値と値のスペース ( 違う X 値のものと )
      barValueSpacing : 14,
      // 棒グラフの値と値のスペース ( 同じ X 値のものと )
      barDatasetSpacing : 1,
      // 表示の時のアニメーション
      animation : true,
      // アニメーションの速度 ( ステップ数 )
      animationSteps : 60,
      // アニメーションの種類
      animationEasing : 'easeOutQuad',
      // アニメーション終了後に実行する処理
      onAnimationComplete : function() {
        $('.chart-bar-01 .data').fadeIn();
      }
  };

      $win.scroll(function(){
          if($(this).scrollTop() > position01 && flag === null){
            flag = 1;
        var myDoughnut = new Chart(document.getElementById('chart-doughnut-01').getContext('2d')).Doughnut(doughnutData, options);
          }
      if($(this).scrollTop() > position02 && flag02 === null){
            flag02 = 1;
        var chart = new Chart(document.getElementById('chart-bar-01').getContext('2d')).Bar(barChartData, options02);
          }
      if($(this).scrollTop() > position03){
         $('.chart-xbar-01').addClass('active');
          }
      });

  })();
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console