TypeError:undefined不是对象(评估' M.layout.force')

时间:2016-07-13 20:52:16

标签: javascript d3.js jsnetworkx

我是JSNetworkX的新手。我使用jsnetworkx.org中的示例创建了一个图表,但我只能记录它,我无法显示它。

所以这是<?php namespace App\Http\Controllers; use Request; use Auth; use Sentinel; use App\Feed; use App\Http\Requests; use App\Blog; use App\Http\Controllers\Controller; use App\Comment; class FeedsController extends Controller { public function index() { // $comments = Comment::latest()->get(); $feeds = Feed::with('comments', 'user')->where('user_id', Sentinel::getUser()->id)->latest()->get(); $blogs = Blog::latest()->simplePaginate(5); $blogs->setPath('blog'); return view('action.index', compact('feeds', 'blogs')); } public function store(Requests\CreateFeedRequest $request) { $request->merge( [ 'user_id' => Sentinel::getuser()->id] ); Feed::create($request->all()); return redirect('home'); } public function storecomment(Requests\CommentRequest $request, Feed $feed) { $comment = new Comment; $comment->user_id =Sentinel::getuser()->id; $comment->feed_id = $request->feed_id; $comment->comment = $request->comment; $comment->save(); return redirect('/home'); } } 文件:

index.html

这是用<html> <head> <script src="https://d3js.org/d3.v4.js"></script> <script src="jsnetworkx.js"></script> </head> <body> <script src = "script.js"></script> </body> </html> 编写的代码:

script.js

这是输出: [0,1,2,3,4,5]

这是我得到的错误:

  

JSNetworkX错误 - TypeError:undefined不是对象(评估&#39; M.layout.force&#39;)

1 个答案:

答案 0 :(得分:0)

问题包括最新版本的D3.js.

更改

<script src="https://d3js.org/d3.v4.js"></script>

<script src="https://d3js.org/d3.v3.js"></script>

会修复它。