gpt4 book ai didi

javascript - 使用 D3 库时的 XMLHttpRequest 问题

转载 作者:行者123 更新时间:2023-11-30 16:45:06 25 4
gpt4 key购买 nike

<分区>

我目前正在尝试运行一个名为 metricsgraphics.js 的简单库.它是 d3 库,我对使用它感到非常兴奋,但我在运行它时遇到了一些问题。它看起来像一个使用起来非常简单的库,但我总是出错。我有以下内容:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Testing</title>
<link href="lib/metricsgraphics.css" rel="stylesheet">
</head>
<body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.js"></script>
<script src="lib/metricsgraphics.js"></script>
<script type="text/javascript">
d3.json('data/ufo-sightings', function(data) {
})

d3.json('data/ufo-sightings', function(data) {
data = MG.convert.date(data, 'year');

})

d3.json('data/ufo-sightings', function(data) {
MG.data_graphic({
title: "UFO Sightings",
description: "Yearly UFO sightings from the year 1945 to 2010.",
data: data,
width: 650,
height: 150,
target: '#ufo-sightings',
x_accessor: 'year',
y_accessor: 'sightings',
markers: [{'year': 1964, 'label': '"The Creeping Terror" released'}]
})
})
</script>
</body>

我正在按照他们网站上的指示进行操作。我收到以下两条错误消息

XMLHttpRequest cannot load file:///directory/where/my/data/is. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load file:///directory/where/my/data/is.

谁能帮我解释并提供可能的解决方案?

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