使用C3可视化图表 [英] Visualizing a chart using c3

查看:81
本文介绍了使用C3可视化图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重现一些代码,以使用c3生成图表。该脚本虽然不呈现任何内容。为什么? (href中列出的文件在同一文件夹中)

I am trying to reproduce some code to generate a chart using c3. This script does not render anything though. Why? (the files listed in href are in the same folder)

<!DOCTYPE html>
<html>
<head>
  <!-- Load c3.css -->
  <link href="c3.css" rel="stylesheet" type="text/css">

  <!-- Load d3.js and c3.js -->
  <script src="d3.v3.min.js" charset="utf-8"></script>
  <script src="c3.min.js"></script>

  <meta charset="UTF-8">
  <title>title </title>
</head>
<body>
  <div id="chart"></div>
  <script>
  var chart = c3.generate({
    bindto: '#chart',
    data: {
      columns: [
        ['data1', 30, 200, 100, 400, 150, 250],
        ['data2', 50, 20, 10, 40, 15, 25]
      ]
    }
});
</script>
</body>


推荐答案

这是一个可行的示例,因此如果未加载图表可能您未正确引用库C3和D3。

This is a working example so if chart is not loaded probably you are not referencing correctly to the libraries C3 and D3.

在Web控制台中检查(在Chrome 此处),如果缺少库。

Check in the web console (usage in Chrome here) of your browser if libraries are missing.

请检查以下步骤:

  • For C3 installation follow the guide: http://c3js.org/gettingstarted.html
  • For D3 you can user the source remote connection: http://d3js.org/d3.v3.min.js

这篇关于使用C3可视化图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆