如何使用JSON本地文件创建ApexCharts(JavaScript)?
正如标题所说,我想使用我已经事先下载的JSON数据创建ApexChart,
我已经在Internet中搜索了JSON数据使用:
const df = require('data/processed.json');
我已经试图将其称为df ['like'],为y和df ['name'],因为
我想念的东西吗? 或打电话给专栏不会这样做? 我还尝试了DF.Liked和DF.Name,BTW
const df= require('data/processed.json');
var options = {
chart: {
height: 230,
type: 'line',
toolbar: {
show: false,
},
},
dataLabels: {
enabled: false
},
stroke: {
width: 2,
curve: 'smooth'
},
series: {
name: 'Liked',
data: df['liked']
},
legend: {
position: 'top',
},
xaxis: {
type: 'string',
data: df['name'],
axisBorder: {
show: false,
},
label: {
style: {
color: '#ccc'
}
},
},
yaxis: {
show: true,
// min: 10,
// max: 70,
labels: {
style: {
color: '#ccc'
}
}
},
colors: ['#73b4ff', '#59e0c5'],
fill: {
type: 'gradient',
gradient: {
shade: 'light',
gradientToColors: ['#4099ff', '#2ed8b6'],
shadeIntensity: 0.5,
type: 'horizontal',
opacityFrom: 1,
opacityTo: 1,
stops: [0, 100]
},
},
markers: {
size: 5,
colors: ['#4099ff', '#2ed8b6'],
opacity: 0.9,
strokeWidth: 2,
hover: {
size: 7,
}
},
grid: {
borderColor: '#cccccc3b',
}
}
var chart = new ApexCharts(document.querySelector("#unique-visitor-chart"), options);
chart.render();
enter code here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用:
的文档
关于获取方式 将在您的JSON上捕获所有数据,并在您的
const df
中使用返回:)如果要使用
require()
查看: https://requirejs.org/注意:尝试使用很多
console.log()
调试您的JS应用程序。try to use :
A documentation about fetch
This way will catch all data on your json and pu it in your
const df
by using the return :)If you want to use
require()
look about : https://requirejs.org/NOTE : Try to use a lot
console.log()
to debug your js app.