Skip to content

Cannot read property 'format' of undefined #243

@JakobStaudt

Description

@JakobStaudt

I currently want to write a chrome app that contains a epoch graph.
Heres my index.html:

<html>
<head>
  <meta charset="utf-8">
  <title>Test</title>
  <link href="styles/main.css" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="css/epoch.min.css">
</head>
<body>
  <h1>Test</h1>
  <div id="pie" style="width: 400px; height: 400px"></div>

  <script src="js/d3.js"></script>
  <script src="js/epoch.js"></script>
</body>
</html>

Heres my main.js:

chrome.app.runtime.onLaunched.addListener(function() {
  var screenWidth = screen.availWidth;
  var screenHeight = screen.availHeight;
  var width = 500;
  var height = 300;

  chrome.app.window.create('index.html', {
    id: "helloWorldID",
    outerBounds: {
      width: width,
      height: height,
      left: Math.round((screenWidth-width)/2),
      top: Math.round((screenHeight-height)/2)
    }
  });
});

var pieData = [
  { label: 'Slice 1', value: 10 },
  { label: 'Slice 2', value: 20 },
  { label: 'Slice 3', value: 40 },
  { label: 'Slice 4', value: 30 }
]

$('#pie').epoch({
  type: 'pie',
  data: pieData
});

When I run this, the chart area stays empty and the error "Uncaught TypeError: Cannot read property 'format' of undefined" appears. The line the error occurs at is 429 which contains this:
d3Seconds = d3.time.format('%I:%M:%S %p');
My guess is that the error appears because d3 wasnt properly loaded but I dont know how to fix this as I think I followed the guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions