我对JavaScript
世界相当陌生,所以请容忍我。我遇到了JavaScript
库Arquero
,我想在一个独立的html文件中使用它。根据文档的说法,这似乎是可能的。它们给出了一个简短的示例代码(参见下面),它将用于Node.js环境(至少我是这样理解的),但我无法在浏览器中再现它。我应该如何在普通的html中构造这个脚本?
// <script src="https://cdn.jsdelivr.net/npm/arquero@latest"></script> // this is to reference the Arquero library
import { all, desc, op, table } from 'arquero';
// Average hours of sunshine per month, from https://usclimatedata.com/.
const dt = table({
'Seattle': [69,108,178,207,253,268,312,281,221,142,72,52],
'Chicago': [135,136,187,215,281,311,318,283,226,193,113,106],
'San Francisco': [165,182,251,281,314,330,300,272,267,243,189,156]
});
// Sorted differences between Seattle and Chicago.
// Table expressions use arrow function syntax.
dt.derive({
month: d => op.row_number(),
diff: d => d.Seattle - d.Chicago
})
.select('month', 'diff')
.orderby(desc('diff'))
.print();
发布于 2022-05-19 07:36:07
正如文档所指定的那样:
Arquero将被导入到
aq
全局对象中。
因此,要使用这些函数,您需要在它们的前缀加上aq
。
// Average hours of sunshine per month, from https://usclimatedata.com/.
const dt = aq.table({
'Seattle': [69,108,178,207,253,268,312,281,221,142,72,52],
'Chicago': [135,136,187,215,281,311,318,283,226,193,113,106],
'San Francisco': [165,182,251,281,314,330,300,272,267,243,189,156]
});
// Sorted differences between Seattle and Chicago.
// Table expressions use arrow function syntax.
dt.derive({
month: d => aq.op.row_number(),
diff: d => d.Seattle - d.Chicago
})
.select('month', 'diff')
.orderby(aq.desc('diff'))
.print();
<script src="https://cdn.jsdelivr.net/npm/arquero@latest"></script>
https://stackoverflow.com/questions/72300366
复制相似问题