-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchart.html
More file actions
executable file
·180 lines (178 loc) · 5.26 KB
/
Copy pathchart.html
File metadata and controls
executable file
·180 lines (178 loc) · 5.26 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html>
<head>
<title>Charts</title>
<script language="javascript" type="text/javascript" src="plot/jquery.min.js"></script>
<script type="text/javascript" src="plot/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="plot/jquery.jqplot.js"></script>
<script class="include" type="text/javascript" src="plot/plugins/jqplot.barRenderer.min.js"></script>
<script class="include" type="text/javascript" src="plot/plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script class="include" type="text/javascript" src="plot/plugins/jqplot.pieRenderer.min.js"></script>
<script class="include" type="text/javascript" src="plot/plugins/jqplot.donutRenderer.min.js"></script>
<link rel="stylesheet" type="text/css" href="plot/jquery.jqplot.css" />
<link rel="stylesheet" type="text/css" href="chart.css" />
</head>
<body>
<div>
<button id="save">Save</button>
<div id="chartdiv" style="height:400px;width:300px;"></div>
<div id="options">
<select id="choose">
<option value="vertical">Vertical Bar</option>
<option value="horizontal">Horizontal Bar</option>
<option value="line">Line</option>
<option value="area">Area</option>
<option value="pie">pie</option>
<option value="donut">Donut</option>
</select>
<button id="plot">Plot</button
</div>
<div id="table" style="height:400px;width:300px;">
<button id="ok">Ok</button>
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("#save").click(function(){
$("#chartdiv").jqplotSaveImage();
});
var rows = 5;
var columns = 2;
var valueArray = [];
var nameArray = [];
var Title = "";
$("#ok").click(function(){
for(var i=1;i<rows;i++){
valueArray.push(parseInt($("#"+(i+1)+"_2 > input").val()));
}
for(var i=1;i<rows;i++){
nameArray.push($("#"+(i+1)+"_1 > input").val());
}
Title = $("#1_1 > input").val();
});
$("#plot").click(function(){
value = $("#choose").val();
if(value == "vertical") vertical();
else if(value == "horizontal") horizontal();
else if(value == "line") line();
else if(value == "pie") pie();
else if(value == "donut") donut();
else if(value == "area") area();
});
function vertical(){
$("#chartdiv").empty();
$.jqplot.config.enablePlugins = true;
var data = [valueArray];
plot1 = $.jqplot('chartdiv', data, {
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
pointLabels: { show: true },
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: nameArray
}
},
title: Title,
highlighter: { show: false }
});
}
function horizontal(){
$("#chartdiv").empty();
$.jqplot.config.enablePlugins = true;
plot1 = $.jqplot('chartdiv', [valueArray], {
title: Title,
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
pointLabels: { show: true },
rendererOptions: {
barDirection: 'horizontal'
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: nameArray
}
},
highlighter: { show: false }
});
}
function line(){
$("#chartdiv").empty();
plot1 = $.jqplot('chartdiv', [valueArray],{
title: Title
});
}
function pie(){
$("#chartdiv").empty();
plot1 = $.jqplot('chartdiv',[valueArray],{
title: Title,
seriesDefaults:{
renderer:$.jqplot.PieRenderer,
trendline:{ show:false },
rendererOptions: { padding: 8, showDataLabels: true }
}
});
}
function donut(){
$("#chartdiv").empty();
plot1 = $.jqplot('chartdiv',[valueArray],{
title: Title,
seriesDefaults:{
renderer:$.jqplot.DonutRenderer,
trendline:{ show:false },
rendererOptions: { padding: 8, showDataLabels: true }
}
});
}
function area(){
$("#chartdiv").empty();
$.jqplot.config.enablePlugins = true;
plot1 = $.jqplot('chartdiv', [valueArray], {
title: Title,
seriesDefaults:{
pointLabels: { show: true },
fill: true
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: nameArray
}
},
highlighter: { show: false }
});
}
//generate table for sample Data 1
var elem = '<table><tr><th></th>';
for(var i=0;i<columns;i++)
{
elem = elem + '<th>'+String.fromCharCode(65+i)+'</th>';
}
elem = elem + '</tr>';
for(var i=0;i<rows;i++){
elem = elem + '<tr><td>'+(i+1)+'</td>';
for(var j = 0;j<columns;j++){
var txt = ""+(i+1)+"_"+(j+1);
elem = elem + '<td id="'+txt+'""></td>';
}
elem = elem + '</tr>';
}
elem = elem + '</table>';
$("#table").append(elem);
for(var i=1;i<rows;i++){
elem = '<input type="text" placeholder="Item '+(i)+'" value="'+(String.fromCharCode(97+i))+'">';
$("#"+(i+1)+"_1").append(elem);
}
for(var i = 1;i<rows;i++){
elem = '<input type="number" placeholder="'+(i)+'" value="'+(i+1)+'">';
$("#"+(i+1)+"_2").append(elem);
}
$("#1_2").append('<input type="text" placeholder="Year 1">');
$("#1_1").append('<input type="text" placeholder="Title">');
});
</script>
</html>