SS Tide Chart

In this example below you will see how to do a SS Tide Chart with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by delian7, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright delian7 ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>SS Tide Chart</title>
  
  
  <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Monda'>

      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <!-- visit www.amcharts.com to download -->
<script type="text/javascript" src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script type="text/javascript" src="https://www.amcharts.com/lib/3/serial.js"></script>
<script type="text/javascript" src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div class="container">
  <div class="row">
    <div class="col-lg-12">
      <div class="responsive-container well">
        <div id="chartdiv"></div>
      </div>
    </div>
  </div>
</div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/delian7/ss-tide-chart-NgzNXv */
body {
  padding: 20px;
  background: linear-gradient(to bottom, #171717 2%, #000000);
}
.responsive-container {
  position: relative;
  display: block;
  height: 0;
  overflow: hidden;
  padding-bottom: 60%; /* the higher the bigger the ratio */
}
.responsive-container > div {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}  

/*Downloaded from https://www.codeseek.co/delian7/ss-tide-chart-NgzNXv */
var dataProvider = [
  {
    "time": "1 AM",
    "meters": 0.18,
    "name": "LOW"
  },
  {
    "time": "7 AM",
    "meters": 1.03,
    "name": "HIGH"
  },
  {
    "time": "12 PM",
    "meters": 0.6,
    "name": "LOW"
  },
  {
    "time": "7 PM",
    "meters": 1.66,
    "name": "HIGH"
  }
];
var guideLabel = "Now - " + 2.4 + "ft"
var guideCategory = "12 PM"
var balloonText = "[[value]] meters";
var categoryFieldName = 'time';
var valueFieldName = 'meters';

var chart = AmCharts.makeChart("chartdiv", tideChartOptions());

function tideChartOptions() {
  // COPY EVERYTHING BETWEEN THIS AND THE BELOW MESSAGE

  return {
    "type": "serial",
    "categoryField": categoryFieldName,
    "addClassNames": true,
    "autoMargins": false,
    "marginBottom": 30,
    "marginLeft": -10,
    "marginRight": -10,
    "marginTop": 0,
    "panEventsEnabled": false,
    "sequencedAnimation": false,
    "backgroundAlpha": 0, // will be 0 to not have a background
    "backgroundColor": "#111111",
    "fontFamily": "monda",
    "handDrawScatter": 0,
    "handDrawThickness": 0,
    "precision": 2,
    "tapToActivate": false,
    "touchClickDuration": 2,
    "categoryAxis": {
      "color": "#ffffff",
      "inside": false,
      "guides": [{
        "category": guideCategory,
        "above": true,
        "lineColor": "#FFFFFF",
        "expand": true,
        "label": guideLabel,
        "inside": true,
        "position": "bottom",
        "labelRotation": 90,
        "lineThickness": 3
      }]
    },
    "chartCursor": {
      "enabled": true,
      "balloonPointerOrientation": " vertical",
      "bulletsEnabled": true,
      "bulletSize": 0,
      "categoryBalloonEnabled": false,
      "cursorAlpha": 0.1,
      "cursorColor": "#FFFFFF",
      "fullWidth": true,
      "graphBulletAlpha": 1,
      "graphBulletSize": 1,
      "leaveAfterTouch": false,
      "leaveCursor": true,
      "oneBalloonOnly": true,
      "selectionAlpha": 1,
      "tabIndex": 0,
      "valueLineAlpha": 0.19,
      "zoomable": false,
      "valueZoomable": false
    },
    "graphs": [
      {
        "bullet": "round",
        "bulletBorderAlpha": 1,
        "bulletBorderColor": "#333",
        "bulletColor": "#FFFFFF",
        "bulletHitAreaSize": 10,
        "bulletSize": 6,
        "cursorBulletAlpha": 0,
        "fillAlphas": 1,
        "fillColors": ["#63C9F0", "#3498DB"],
        "fixedColumnWidth": 3,
        "fontSize": 15,
        "gapPeriod": 10,
        "id": "AmGraph-1",
        "labelOffset": 200,
        "legendAlpha": 0,
        "lineColor": "#57D0F9",
        "lineThickness": 4,
        "markerType": "circle",
        "maxBulletSize": 6,
        "minBulletSize": 6,
        "negativeFillColors": "#38D1E5",
        "negativeLineColor": "#57D0F9",
        "periodSpan": 0,
        "showAllValueLabels": true,
        "showBulletsAt": "high",
        "showHandOnHover": true,
        "title": "graph 1",
        "type": "smoothedLine",
        "balloonText": balloonText,
        "valueField": valueFieldName,
      }
    ],
    "valueAxes": [
      {
        "id": "ValueAxis-1",
        "autoGridCount": false,
        "axisThickness": 0,
        "boldLabels": true,
        "centerLabels": true,
        "gridThickness": 0,
        "minHorizontalGap": 3,
        "minVerticalGap": 19
      }
    ],
    "balloon": {
      "borderAlpha": 0,
      "borderColor": "#C96DD8",
      "color": "#1A1A1A",
      "cornerRadius": 3,
      "fillAlpha": 0.95,
      "fixedPosition": false,
      "fontSize": 15,
      "offsetX": 10,
      "offsetY": 10,
      "pointerWidth": 3,
      "shadowAlpha": 0,
      "shadowColor": "#FFFFFF",
      "showBullet": true,
      "verticalPadding": 10
    },
    "dataProvider": dataProvider
  }
  
  
  // COPY EVERYTHING BETWEEN THIS AND THE ABOVE MESSAGE
}

Comments