gpt4 book ai didi

javascript - 印记 : synchronization example

转载 作者:行者123 更新时间:2023-11-28 10:53:07 25 4
gpt4 key购买 nike

我是一名生物工程师,我不得不承认我没有 js 经验。我正在使用 Dygraph 创建一些图表,并且需要同步它们的缩放,因此我检查了图库中的“同步”示例。它说我必须在您的页面上获取 extras/synchronizer.js 。当我点击它时,我最终会看到一个页面,上面写着:404,这不是您要查找的页面。

另一个问题,当我创建图表时,我收到此错误通知:

XMLHttpRequest cannot load file:///C:/xampp/htdocs/programs/progettoprovaG/averageV.csv. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. dygraph-combined-dev.js:5428 Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/xampp/htdocs/programs/progettoprovaG/averageV.csv'.

顺便说一句,这是我的代码:

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js"></script>
<script type="text/javascript"
src="dygraph-combined-dev.js"></script>
</head>
<body>
<div id="div_average_breath_volume" style="width:600px; height:300px;"></div>
<div id="div_average_breath_impedence" style="width:600px; height:300px;"></div>
<script type="text/javascript">
$(document).ready(function () {
var highlight_start = 55;
var highlight_end = 65;

// grafico del volume + sd
v = new Dygraph(
document.getElementById("div_average_breath_volume"),
"averageV.csv",
{
labelsDivStyles: { 'textAlign': 'right' },
labels: ["s","L"],
errorBars: true,
title: 'average breath',
ylabel: 'volume [L]',
xlabel: 'time [s]',
animatedZooms: true,
underlayCallback: function(canvas, area, v) {
var bottom_left = v.toDomCoords(highlight_start);
var top_right = v.toDomCoords(highlight_end);
var left = bottom_left[0];
var right = top_right[0];
canvas.fillStyle = "rgba(255, 255, 102, 1.0)";
canvas.fillRect(left, area.y, right - left, area.h);
}
}
);
z = new Dygraph(
document.getElementById("div_average_breath_impedence"),
"averageZ.csv",
{
errorBars: true,
labelsDivStyles: { 'textAlign': 'right' },
legend: 'always',
labels: ["s","R","X"],
ylabel: 'impedence [L]',
xlabel: 'time [s]',
animatedZooms: true,
underlayCallback: function(canvas, area, z) {
var bottom_left = z.toDomCoords(highlight_start);
var top_right = z.toDomCoords(highlight_end);
var left = bottom_left[0];
var right = top_right[0];
canvas.fillStyle = "rgba(255, 255, 102, 1.0)";
canvas.fillRect(left, area.y, right - left, area.h);
}
}
);
}
);
</script>
</body>

当我尝试简单地执行 Dygraph 库中的示例时,会发生类似的情况:

Failed to load resource: net::ERR_FILE_NOT_FOUND dygraph-combined-dev.js:5428 XMLHttpRequest cannot load file:///C:/xampp/htdocs/programs/progettoprovaG/twonormals.csv. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. dygraph-combined-dev.js:5428 Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/xampp/htdocs/programs/progettoprovaG/twonormals.csv'.

有人可以帮我吗?

最佳答案

修复跨域请求您需要提供您的文件,例如,运行

python -m SimpleHTTPServer 8000

在包含您的代码的目录中,然后打开

localhost:8000

在浏览器中

关于javascript - 印记 : synchronization example,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29602428/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com