0
我試圖製作electron桌面應用程序,它使用Epoch實時圖表庫。我得到了電子應用程序運行良好,並在基本節點環境中製作了一些Epoch圖表,但是當我嘗試結合電子和時代時,出現了一個錯誤:Uncaught TypeError:$(...)。epoch不是函數。我無法獲得時代圖表庫與電子應用程序工作
我試圖加載的jquery.js,d3.js和從index.html的epoch.js模塊(代碼實施例1)或從JavaScript(代碼示例2)需要它們。打開電子
<!--Code example 1-->
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/d3.min.js"></script>
<script type="text/javascript" src="./js/epoch.min.js"></script>
//Code example 2
var $ = require('jquery');
var d3 = require('d3');
var epoch = require('epoch-charting');
我app.js是以下幾點:
var app = require('app');
var BrowserWindow = require('browser-window');
var mainWindow = null;
app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit();
}
});
app.on('ready', function() {
mainWindow = new BrowserWindow({
width: 600,
height: 300,
'min-width': 500,
'min-height': 200,
'accept-first-mouse': true,
'title-bar-style': 'hidden'
});
mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.openDevTools();
mainWindow.on('closed', function() {
mainWindow = null;
});
});
和index.html:
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<link rel="stylesheet" href="./css/epoch.min.css">
</head>
<body>
<div id="lineChart" class="epoch" style="width: 100%; height: 400px;border:solid 1px #C0C0C0;"></div>
<script>
var $ = require('jquery');
var d3 = require('d3')
var epoch = require('epoch-charting');
var lineChartData = [
{
label: "Series 1",
values: [ {x: 0, y: 100}, {x: 20, y: 1000}]
},
{
label: "Series 2",
values: [ {x: 20, y: 78}, {x: 30, y: 98}]
}
];
$('#lineChart').epoch({
type: 'line',
data: lineChartData
});
</script>
</body>
</html>