如何限制vis.js中的Y轴和X轴值

时间:2016-01-08 07:17:13

标签: javascript html css vis.js

enter image description here

我正在尝试绘制一个图表,它的所有工作正常,但我得到这个问题,Y轴占据了我的图形区域的大部分,而且x轴值从一些如何从哪里获取那些值开始图表开始我怎样才能实现这一目标 这是我的html文件
P.S黑线是在ubuntu的pinta中绘制的,它与图形无关。

<!DOCTYPE HTML>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>Graph2d | Basic Example</title>

<style type="text/css">
body, html {
  font-family: sans-serif;
}
</style>

<script src="../../dist/vis.js"></script>
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script></head>
<body>
<div id="visualization"></div>
<script type="text/javascript">
 var a=['10','20','30'];
 var container = document.getElementById('visualization');
 var str= [{"y":0.5344999999999999,"x":"2016-01-07 03:00:06.525036"},{"y":0.4541666666666668,"x":"2016-01-07 04:45:55.669235"},{"y":0.5185000000000001,"x":"2016-01-07 06:08:02.645683"}];
console.log(typeof(str));
var dataset = new vis.DataSet(str);
var options = {
start: '2015-06-10',
end: '2014-06-18'
 };
 var graph2d = new vis.Graph2d(container, dataset, options);
</script>
</body>
 </html>

1 个答案:

答案 0 :(得分:1)

这里看起来主要的问题是在垂直轴上弹出一些舍入错误(例如0.44999999999999996而不是0.55)。您可以在项目的“问题”部分中为此打开问题:https://github.com/almende/vis/issues