我没有错误(最终),但我得到的只是一个没有任何数据的x轴。我遗漏了什么?我从vsCode中的Live Server插件运行此程序。另外,plottable有两个标记:plottable和plottable.js。有没有办法摆脱其中一个而只使用另一个呢?因此,当有更多的Plottable问题时,它们不会展开。
你可以在这里找到图片:https://imgur.com/a/ATiF3tU
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Testing Plottable</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.js" charset="utf-8"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="//unpkg.com/plottable/plottable.js" charset="utf-8"></script>
<script src="index.js"></script>
<link rel="stylesheet" type="text/css" href="//unpkg.com/plottable/plottable.css">
</head>
<body>
<p>testing plottable.js</p>
<div id="example"></div>
</body>
</html>JavaScript
function makeBasicChart() {
var xScale = new Plottable.Scales.Linear();
var yScale = new Plottable.Scales.Linear();
var xAxis = new Plottable.Axes.Numeric(xScale, "bottom");
var yAxis = new Plottable.Axes.Numeric(yScale, "left");
var plot = new Plottable.Plots.Line();
plot.x(function(d) { return d.x; }, xScale);
plot.y(function(d) { return d.y; }, yScale);
var data = [
{ "x": 0, "y": 1 },
{ "x": 1, "y": 2 },
{ "x": 2, "y": 4 },
{ "x": 3, "y": 8 }
];
var dataset = new Plottable.Dataset(data);
plot.addDataset(dataset);
var chart = new Plottable.Components.Table([
[yAxis, plot],
[null, xAxis]
]);
chart.renderTo("div#example");
}
$(document).ready(function() {
makeBasicChart();
});发布于 2018-08-24 21:48:39
plottable.css正在影响渲染。我试着检查元素。带有class=“组件表”和class=“组件轴y轴”的div具有顶部、高度和宽度的样式,需要根据您的要求进行更改。
https://stackoverflow.com/questions/52004836
复制相似问题