forked from keisuke-osone/e2d3-v0.3-0208
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart.html
162 lines (150 loc) · 5.95 KB
/
chart.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title></title>
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" type="text/javascript"></script>
<link href="css/bootstrap.v3.2.e2d3.min.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="e2d3-navi-header-area">
<div id="e2d3-chart-header">
<i class="a-pointer fa fa-2x fa-refresh e2d3-tooltip" style="color: #FFFFFF" id="e2d3-btn-redraw" data-toggle="tooltip" data-placement="right" title="Click when you change selected area"></i>
</div>
</div>
<div id="e2d3-global-navi">
<a class="a-pointer e2d3-link-index" style="color: #FFFFFF"><i class="fa fa-2x fa-home" title="Home"></i></a>
</div>
<div id="e2d3-chart-area" class="container-fluid"></div>
<div id="e2d3-footer"><hr />Powered by E2D3.</div>
<script src="js/e2d3.js?0.3.2.4" type="text/javascript"></script>
<script src="js/jquery.v2.min.js" type="text/javascript"></script>
<script src="js/jquery.e2d3.js" type="text/javascript"></script>
<script src="js/bootstrap.v3.2.min.js" type="text/javascript"></script>
<script src="js/d3.min.js"></script>
<script type="text/javascript">
/**
* Global
*/
var e2d3BindId = 'e2d3BindId';
var e2d3BindData;
var baseUrl;
var windowSize = $(window).width();
$(window).on("resize", function () {
windowSize = $(this).width();
});
var e2d3FlagDateStr = Date.now();
/**
* on load
*/
// init();
$(document).ready(function(){
e2d3.initialize(function () {
/**
* check bind
*/
try{
//console.log(e2d3BindId);
e2d3.getBindDataById(e2d3BindId,function(e2d3BindData){
console.log('chart.html: Check binding is exist.');
console.log(e2d3BindData);
init(e2d3BindData);
});
}catch (e){
//location.href = 'index.html';
console.log(e);
}
});
});
function init(bind) {
/**
* Load script
*/
var hash = location.hash.split('/');
var demo = (hash[2] === 'demo') ? hash[2] : false;
console.log("is Demo : " + demo + ": hash : " + hash);
var ul = $('<ul>').addClass('list-inline');
$('#e2d3-chart-header').append(ul);
if (hash[0] && demo) {
baseUrl = 'contrib/' + hash[1];
var sampleData;
d3.text(baseUrl + '/data.csv?' + e2d3FlagDateStr, function (csv) {
var data = d3.csv.parseRows(csv);
console.log("Csv loaded.");
console.log(csv);
if (bind) {
console.log("Begin is bind case.");
e2d3.releaseBindDataById({
id: e2d3BindId,
isDataDelete: true
}, function () {
showError('データをすべて削除し、セル「A1」を選択して、Drawボタンを押してください。 <a class="btn btn-default e2d3-button-draw">Draw</a>', { color: "danger", stay: true });
// data delete
$(document).on('click', ".e2d3-button-draw", function () {
$(".e2d3-alert").remove();
e2d3.json2Excel(data, function (result) {
if (result) {
e2d3.setBindData(
{ id: e2d3BindId, is_prompt: 0 }
, function (binding) {
if (binding) {
e2d3GetMainScript(baseUrl,binding);
}
});
}
});
});
});
} else {
console.log("Begin is not bind case.");
e2d3.json2Excel(data, function (result) {
if (result) {
e2d3.setBindData(
{ id: e2d3BindId, is_prompt: 0 }
, function (binding) {
if (binding) {
e2d3GetMainScript(baseUrl,binding);
}
});
}
});
}
});
} else {
location.href = "index.html";
}
//home
}
//
function e2d3GetMainScript(baseUrl, binding) {
console.log("Begin main script.");
console.log(baseUrl);
$.getScript(baseUrl + '/main.js?123', function () {
console.log(baseUrl);
$('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: baseUrl + '/main.css'
}).appendTo('head');
$(document).on("click", ".e2d3-link-index", function () {
e2d3.removeChangeEvent(e2d3BindId, e2d3Update, function () {
location.href = "index.html";
})
})
$(document).on('click', "#e2d3-btn-redraw", function () {
console.log('Begin redraw data');
e2d3.setBindData(
{ id: e2d3BindId, is_prompt: 0 }
, function (binding) {
e2d3Update();
});
});
e2d3Show();
});
}
</script>
</body>
</html>