cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <div ng-app="dataDashApp">
  <div ng-controller="dataDashController">
    <nav class="navbar navbar-default">
      <div class="container">
        <div class="navbar-header">
          JogTracker
        </div>

      </div>
    </nav>

    <div class="container">
      <div class="row">
        <div class="col-sm-2">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Jogs By Month</h3>
            </div>
            <div class="panel-body">
              <ul class="by-month">
                <li ng-repeat="data in monthsJogged" ng-if="data.count > 0">{{data.month}} - {{data.count}}</li>
              </ul>
            </div>
          </div>
        </div>
        <div class="col-sm-10">

          <div class="row">
            <div class="col-sm-12">
              <div class="panel panel-default">
                <div class="panel-heading">
                  <h3 class="panel-title">Last 10 Jogs - <span class="key distance"></span>Distance & <span class="key time"></span>Time</h3>
                </div>
                <div class="panel-body">
                  <table class="bar-chart">
                    <tr ng-repeat="run in data | limitTo:-10">
                      <td class="legend" ng-style="{left:$index * 10 +'%'}">{{run.date | date}} </td>
                      <td ng-style="{ left:$index * 10 +'%', height: (run.time / maxTime) * 300 + 'px'}" class="time" ng-class="{highlight: run.time === maxTime}" ><span>
              
                        {{run.time | number}} Minutes</span></td>
                      <td ng-style="{ left:$index * 10 +'%', height: (run.distance / maxDistance) * 300 + 'px'}" class="distance" ng-class="{highlight: run.distance === maxDistance}"
                          >  <span>
                      
                        {{run.distance}} Miles
                      </span></td>
                    </tr>             
                  </table>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-md-6">
              <div class="panel panel-default">
                <div class="panel-heading">
                  <h3 class="panel-title">Pace</h3>
                </div>
                <div class="panel-body line-chart">
                <div class="line-legend-min">
                {{minPace | number:2}}
                  </div>
                  <div class="line-legend-max">
                {{maxPace | number:2}}
                  </div>

                  <svg>
                    <line ng-repeat="run in data" x1="{{($index - 1) / data.length * 100}}%"  x2="{{$index / data.length * 100}}%" y1="{{data[$index - 1].relPace * 200}}" y2="{{run.relPace * 200}}">
                  
                    </line>
                  </svg>
                </div>
              </div>
            </div>
            <div class="col-md-6">
              <div class="panel panel-default">
                <div class="panel-heading">
                  <h3 class="panel-title">Total Jogs ({{total}}) -  Split by Days</h3>
                </div>
                <div class="panel-body">
                  <div class="pie" style="background: 
                conic-gradient(
                yellowgreen {{monday / total * 100}}%, 
                gold 0 {{(monday + tuesday) / total * 100}}%, 
                silver 0 {{(monday + tuesday + wednesday) / total * 100}}%,
                lightblue 0 {{(monday + tuesday + wednesday + thursday) / total * 100}}%,
                orange 0 {{(monday + tuesday + wednesday + thursday + friday) / total * 100}}%,
                tomato 0 {{(monday + tuesday + wednesday + thursday + friday + saturday) / total * 100}}%,
                navy 0 {{(monday + tuesday + wednesday + thursday + friday + saturday + sunday) / total * 100}}%
                
                );"></div>
                  <table class="pie-table">
    <tr>
      <td style="background:yellowgreen; color:white;">Monday</td>
      <td>{{monday}}</td>
    </tr>
    <tr>
      <td style="background:gold; color:white;">Tuesday</td>
      <td>{{tuesday}}</td>
    </tr>
    <tr>
      <td style="background:silver; color:white;">Wednesday</td>
      <td>{{wednesday}}</td>
    </tr>
    <tr>
      <td style="background:lightblue; color:white;">Thursday</td>
      <td>{{thursday}}</td>
    </tr>
    <tr>
      <td style="background:orange; color:white;">Friday</td>
      <td>{{friday}}</td>
    </tr>
    <tr>
      <td style="background:tomato; color:white;">Saturday</td>
      <td>{{saturday}}</td>
    </tr>
    <tr>
      <td style="background:navy; color:white;">Sunday</td>
      <td>{{sunday}}</td>
    </tr>
  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
            
          
!
            
              $lightblue: #B9D7D9;
$lightbluecomp: complement($lightblue);
$midblue: #668284;
$midbluecomp: complement($midblue);
$orange: #CC5D4C;
$turqoise: #05676E;


ul {
  list-style-type:none;
  margin:0;
  padding:0;

  li {
    text-transform: capitalize;
  }
}

.navbar {
  border-radius:0;
  background:$turqoise;
  color:white;
  font-weight:bold;
  font-size:2.3em;
  border:none;
  padding:10px;
}

// Sidebar

.by-month {
  font-size:1.3em;
  color:$midblue;

  li {
    margin: 10px 0;
  }
}

// Bar Chart
.bar-chart {
  display:block;
  height:300px;
  width:98%;
  position:relative;
  border-left:1px solid $midblue;
  border-bottom:1px solid $midblue;
  margin-left:2%;
  margin-bottom:50px;

  td {
    position:absolute;
    width:20px;
    bottom:0;
    margin-left:10px;
    display:block;

    span {
      position:absolute;
      left:25px;
      bottom:0;
      padding:5px;
      color:white;
      transform:rotate(-90deg);
      transform-origin:bottom left;
      width:300px;
    }
    
  }

  .legend {
    bottom:-40px;
    font-size:0.8em;
    width:50px;
  }
  
 /* .pace {
    height:30px;
    overflow:hidden;
    display:none;
    span {
      transform:rotate(0deg);
      background:$turqoise;
      width:100px;
      border-radius:5px;
      left:45px;
      z-index:0;
      
    }
  }*/

  .distance {
    background:$lightblue;

    &.highlight {
      background: $lightbluecomp;
    }
  }

  .time {
    background:$midblue;
    margin-left:30px;

    &.highlight {
      background: $midbluecomp;
    }
  }



}

.key {
  display:inline-block;
  width:15px;
  height:15px;
  margin-right:5px;

  &.distance {
    background:$lightblue;
  }

  &.time {
    background:$midblue;
  }
}
// Line Chart

.line-chart {

  position:relative;

  &:before {
    content:"Minutes per Mile";
    display:block;
    position:absolute;
    bottom:20px;
    left:30px;
    width:200px;
    transform:rotate(-90deg);
    transform-origin: bottom left;
    text-align:center;
  }

  .line-legend-max {
    position:absolute;
    bottom:20px;
    font-size:0.7em;
    left:1%;
  }
  .line-legend-min {
    position:absolute;
    top:15px;
    font-size:0.7em;
    left:1%;
  }
}

svg {
  margin-left:4%;
  height:200px;
  width:96%;
  border-left:1px solid $midblue;
  border-bottom:1px solid $midblue;

  line {
    stroke:$turqoise;
    stroke-width:3px;
  }
}

// Pie Chart

.pie {
  margin:0;
  border-radius: 50%; 
  width:200px; 
  height:200px;
  float:left;
}

table.pie-table {
  text-align:center;
  margin:0 3% 0 10px;
  width:120px;
  height:60px;
  float:right;

  td {
    padding:4px;
    background:#eee;
  }
}


            
          
!
            
              (function() {
  var app = angular.module('dataDashApp', []);

  app.controller('dataDashController', function($scope) {
      // Data
      $scope.data = [{
        distance: 3.24,
        time: 34,
        date: new Date("May 01, 2015")
      }, {
        distance: 4.24,
        time: 38,
        date: new Date("May 12, 2015")
      }, {
        distance: 3.67,
        time: 37,
        date: new Date("May 23, 2015")
      }, {
        distance: 6.50,
        time: 59,
        date: new Date("June 02, 2015")
      }, {
        distance: 5.64,
        time: 52,
        date: new Date("June 12, 2015")
      }, {
        distance: 4.90,
        time: 45,
        date: new Date("June 22, 2015")
      }, {
        distance: 3.6,
        time: 33,
        date: new Date("July 07, 2015")
      }, {
        distance: 8.56,
        time: 81,
        date: new Date("July 17, 2015")
      }, {
        distance: 9.34,
        time: 92,
        date: new Date("July 31, 2015")
      }, {
        distance: 10.1,
        time: 98,
        date: new Date("August 11, 2015")
      }, {
        distance: 7.56,
        time: 59,
        date: new Date("August 27, 2015")
      }, {
        distance: 9.3,
        time: 84,
        date: new Date("August 31, 2015")
      }, {
        distance: 6.7,
        time: 54,
        date: new Date("September 2, 2015")
      }, {
        distance: 11.43,
        time: 108,
        date: new Date("September 12, 2015")
      }, {
        distance: 4.5,
        time: 34,
        date: new Date("September 22, 2015")
      }, {
        distance: 13.1,
        time: 128,
        date: new Date("October 18, 2015")
      }, {
        distance: 6.4,
        time: 58,
        date: new Date("October 26, 2015")
      }]

      console.log($scope.data)
        // Count days & months

      $scope.daysJogged = [{
        day: 'Sunday',
        count: 0
      }, {
        day: 'Monday',
        count: 0
      }, {
        day: 'Tuesday',
        count: 0
      }, {
        day: 'Wednesday',
        count: 0
      }, {
        day: 'Thursday',
        count: 0
      }, {
        day: 'Friday',
        count: 0
      }, {
        day: 'Saturday',
        count: 0
      }]

      $scope.monthsJogged = [{
        month: 'January',
        count: 0
      }, {
        month: 'February',
        count: 0
      }, {
        month: 'March',
        count: 0
      }, {
        month: 'April',
        count: 0
      }, {
        month: 'May',
        count: 0
      }, {
        month: 'June',
        count: 0
      }, {
        month: 'July',
        count: 0
      }, {
        month: 'August',
        count: 0
      }, {
        month: 'September',
        count: 0
      }, {
        month: 'October',
        count: 0
      }, {
        month: 'November',
        count: 0
      }, {
        month: 'December',
        count: 0
      }];

      $scope.total = 0;

      // For Loop to count
      for (var i = 0; i < $scope.data.length; i++) {
        // Count total activites
        $scope.total++;
        // Set pace
        $scope.data[i].pace = $scope.data[i].time / $scope.data[i].distance;
        // Get Day number
        var day = $scope.data[i].date.getDay();
        // Increase Day count
        $scope.daysJogged[day].count++;
        // Get Month number
        var month = $scope.data[i].date.getMonth();
        // Increase Month Count
        $scope.monthsJogged[month].count++;
        

      };

      // Maximum Distance
      $scope.maxDistance = Math.max.apply(Math, $scope.data.map(function(o) {
          return o.distance;
        }))
        // Maximum Time
      $scope.maxTime = Math.max.apply(Math, $scope.data.map(function(o) {
          return o.time;
        }))
        // Maximum Pace
      $scope.maxPace = Math.max.apply(Math, $scope.data.map(function(o) {
          return o.pace;
        }))
        //Minimum Pace
      $scope.minPace = Math.min.apply(Math, $scope.data.map(function(o) {
        return o.pace;
      }))

      // Nicenames for day counts

      $scope.monday = $scope.daysJogged[1].count;

      $scope.tuesday = $scope.daysJogged[2].count;

      $scope.wednesday = $scope.daysJogged[3].count;

      $scope.thursday = $scope.daysJogged[4].count;

      $scope.friday = $scope.daysJogged[5].count;

      $scope.saturday = $scope.daysJogged[6].count;

      $scope.sunday = $scope.daysJogged[0].count;

      // Get the relative pace in the range

      for (var j = 0; j < $scope.data.length; j++) {
        var item = $scope.data[j];
        item.relPace = (item.pace - $scope.minPace) / ($scope.maxPace - $scope.minPace);

      }

    }) // End Controller

})();
            
          
!
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.
Loading ..................

Console