I cannot get Epoch Charts to display output

Viewed 46

I'm trying to create a dashboard that shows some fairly simple data. I thought the simplest way would be to use a web page and a charting tool, Epoch Charts seemed to be a good choice.

I have installed all the relevant dependencies and followed the instructions.

When I create the HTML page, I don't get any error, but I get no chart (just a blank page). I'm running a local host on Apache.

I've tried a lot of different ways of doing this, I just can't figure out why I get nothing at all. I used npm to install jQuery, D3, epoch, etc. in the relevant site directory.

Here's my code:

<!DOCTYPE html>
<html lang="en-US">

<head>
  <meta charset="UTF-8">
  <script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>
  <script src="js/d3.min.js"></script>
  <script src="js/epoch.min.js"></script>
  <link rel="stylesheet" type="text/css" href="css/epoch.min.css">

</head>

<body>
  <div id="area" class="epoch category10" style="height: 200px;"></div>
  <script>
    var data = [{
        label: 'Layer 1',
        values: [{
          x: 0,
          y: 0
        }, {
          x: 1,
          y: 1
        }, {
          x: 2,
          y: 2
        }]
      },
      {
        label: 'Layer 2',
        values: [{
          x: 0,
          y: 0
        }, {
          x: 1,
          y: 1
        }, {
          x: 2,
          y: 4
        }]
      }
    ];

    var areaChartInstance = $('#area').epoch({
      type: 'area',
      data: data,
      axes: ['left', 'right', 'bottom']
    });
  </script>

</body>

</html>

1 Answers

According to the Epoch Changelog, the current version (0.8.4) has been released on October 30th, 2015. Therefore, the issue must be related to incorrect versions of libraries it depends on.

Epoch package.json states that the library depends on d3 v3.4.13. If you really want to use Epoch, make sure, you're using d3 v3, same as I did with your code below.

var data = [
  {
    label: 'Layer 1',
    values: [{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }]
  },
  {
    label: 'Layer 2',
    values: [{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 4 }]
  }
];

var areaChartInstance = $('#area').epoch({
  type: 'area',
  data: data,
  axes: ['left', 'right', 'bottom']
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/epoch/0.8.4/js/epoch.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/epoch/0.8.4/css/epoch.css">
<div id="area" class="epoch" style="height: 200px;"></div>

Related