简体   繁体   中英

how to restrict the Y- axis and X-axis values in vis.js

在此处输入图片说明

I am trying to draw a graph its all working good but i am getting this issue the Y-axis has occupied majority of my graph area and moreover the x-axis values start from some where how to get those values from where the graph begins how can i achieve this here is my html file
PS the black line is line drawn in pinta of ubuntu it has nothing to do with the graph.

<!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>

Looks like the main issue here is some round-off errors popping up in the vertical axis (like 0.44999999999999996 instead of 0.55 ). You can open an issue for that in the issues section of the project: https://github.com/almende/vis/issues

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM