Skip to content

Commit 0fd57ec

Browse files
committed
add Graphs all working
1 parent 25c265e commit 0fd57ec

File tree

13 files changed

+696
-88
lines changed

13 files changed

+696
-88
lines changed

.idea/workspace.xml

Lines changed: 115 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/Charts.js

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
var Charts = function () {
2+
3+
var colors = Theme.chartColors;
4+
5+
return {
6+
vertical: vertical,
7+
horizontal: horizontal,
8+
pie: pie,
9+
donut: donut,
10+
line: line
11+
};
12+
13+
function vertical (target, data) {
14+
var options = {
15+
colors: colors,
16+
17+
grid: {
18+
hoverable: true,
19+
borderWidth: 2
20+
},
21+
bars: {
22+
horizontal: false,
23+
show: true,
24+
align: 'center',
25+
lineWidth: 0,
26+
fillColor: { colors: [ { opacity: 1 }, { opacity: 0.5 } ] }
27+
},
28+
legend: {
29+
show: true
30+
},
31+
32+
tooltip: true,
33+
tooltipOpts: {
34+
content: '%s: %y'
35+
},
36+
};
37+
38+
var el = $(target);
39+
40+
if (el.length) {
41+
$.plot(el, data, options );
42+
}
43+
}
44+
45+
function horizontal (target, data) {
46+
var options = {
47+
colors: colors,
48+
49+
grid: {
50+
hoverable: true,
51+
borderWidth: 2
52+
},
53+
bars: {
54+
horizontal: true,
55+
show: true,
56+
align: 'center',
57+
barWidth: .2,
58+
lineWidth: 0,
59+
fillColor: { colors: [ { opacity: 1 }, { opacity: 1} ] }
60+
},
61+
legend: {
62+
show: true
63+
},
64+
65+
tooltip: true,
66+
tooltipOpts: {
67+
content: '%s: %y'
68+
},
69+
};
70+
71+
var el = $(target);
72+
73+
if (el.length) {
74+
$.plot(el, data, options );
75+
}
76+
}
77+
78+
function pie (target, data) {
79+
var options = {
80+
colors: colors,
81+
82+
series: {
83+
pie: {
84+
show: true,
85+
innerRadius: 0,
86+
stroke: {
87+
width: 4
88+
}
89+
}
90+
},
91+
92+
legend: {
93+
position: 'ne'
94+
},
95+
96+
tooltip: true,
97+
tooltipOpts: {
98+
content: '%s: %y'
99+
},
100+
101+
grid: {
102+
hoverable: true
103+
}
104+
};
105+
106+
var el = $(target);
107+
108+
if (el.length) {
109+
$.plot(el, data, options );
110+
}
111+
}
112+
113+
function donut (target, data) {
114+
var options = {
115+
colors: colors,
116+
117+
series: {
118+
pie: {
119+
show: true,
120+
innerRadius: .5,
121+
stroke: {
122+
width: 4
123+
}
124+
}
125+
},
126+
127+
legend: {
128+
position: 'ne'
129+
},
130+
131+
tooltip: true,
132+
tooltipOpts: {
133+
content: '%s: %y'
134+
},
135+
136+
grid: {
137+
hoverable: true
138+
}
139+
};
140+
141+
var el = $(target);
142+
143+
if (el.length) {
144+
$.plot(el, data, options );
145+
}
146+
}
147+
148+
function line (target, data) {
149+
var options = {
150+
colors: colors,
151+
series: {
152+
lines: {
153+
show: true,
154+
fill: true,
155+
lineWidth: 4,
156+
steps: false,
157+
fillColor: { colors: [{opacity: 0.4}, {opacity: 0}] }
158+
},
159+
points: {
160+
show: true,
161+
radius: 4,
162+
fill: true
163+
}
164+
},
165+
legend: {
166+
position: 'ne'
167+
},
168+
tooltip: true,
169+
tooltipOpts: {
170+
content: '%s: %y'
171+
},
172+
xaxis: { mode: "time" },
173+
grid: { borderWidth: 2, hoverable: true }
174+
};
175+
176+
var el = $(target);
177+
178+
if (el.length) {
179+
$.plot(el, data, options );
180+
}
181+
}
182+
}();

assets/js/Theme.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
var Theme = function () {
2+
3+
var chartColors, validationRules = getValidationRules ();
4+
5+
// Black & Orange
6+
//chartColors = ["#FF9900", "#333", "#777", "#BBB", "#555", "#999", "#CCC"];
7+
8+
// Ocean Breeze
9+
chartColors = ['#94BA65', '#2B4E72', '#2790B0', '#777','#555','#999','#bbb','#ccc','#eee'];
10+
11+
// Fire Starter
12+
//chartColors = ['#750000', '#F90', '#777', '#555','#002646','#999','#bbb','#ccc','#eee'];
13+
14+
// Mean Green
15+
//chartColors = ['#5F9B43', '#DB7D1F', '#BA4139', '#777','#555','#999','#bbb','#ccc','#eee'];
16+
17+
return { init: init, chartColors: chartColors, validationRules: validationRules };
18+
19+
function init () {
20+
enhancedAccordion ();
21+
22+
if ($.fn.lightbox) {
23+
$('.ui-lightbox').lightbox();
24+
}
25+
26+
if ($.fn.cirque) {
27+
$('.ui-cirque').cirque ({ });
28+
}
29+
30+
$('#wrapper').append ('<div class="push"></div>');
31+
}
32+
33+
function enhancedAccordion () {
34+
$('.accordion').on('show', function (e) {
35+
$(e.target).prev('.accordion-heading').parent ().addClass('open');
36+
});
37+
38+
$('.accordion').on('hide', function (e) {
39+
$(this).find('.accordion-toggle').not($(e.target)).parents ('.accordion-group').removeClass('open');
40+
});
41+
42+
$('.accordion').each (function () {
43+
$(this).find ('.accordion-body.in').parent ().addClass ('open');
44+
});
45+
}
46+
47+
function getValidationRules () {
48+
var custom = {
49+
focusCleanup: false,
50+
51+
wrapper: 'div',
52+
errorElement: 'span',
53+
54+
highlight: function(element) {
55+
$(element).parents ('.control-group').removeClass ('success').addClass('error');
56+
},
57+
success: function(element) {
58+
$(element).parents ('.control-group').removeClass ('error').addClass('success');
59+
$(element).parents ('.controls:not(:has(.clean))').find ('div:last').before ('<div class="clean"></div>');
60+
},
61+
errorPlacement: function(error, element) {
62+
error.appendTo(element.parents ('.controls'));
63+
}
64+
65+
};
66+
67+
return custom;
68+
}
69+
70+
}();

assets/js/charts/donut.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$(function () {
2+
3+
var data = [
4+
{ label: "Manufacturing", data: Math.floor (Math.random() * 100 + 650) },
5+
{ label: "Finance", data: Math.floor (Math.random() * 100 + 250) },
6+
{ label: "Energy & Utilities", data: Math.floor (Math.random() * 100 + 50) }
7+
];
8+
9+
Charts.donut ('#donut-chart', data);
10+
11+
});

assets/js/charts/horizontal.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
$(function () {
2+
3+
var ds = [];
4+
var data = [];
5+
6+
ds.push ([[25, 1],[34, 2],[37, 3],[45, 4],[56, 5]]);
7+
ds.push ([[13, 1],[29, 2],[25, 3],[23, 4],[31, 5]]);
8+
ds.push ([[8, 1],[13, 2],[19, 3],[15, 4],[14, 5]]);
9+
10+
data.push ({
11+
data: ds[0],
12+
label: 'Manufacturing',
13+
bars: {
14+
order: 1
15+
}
16+
});
17+
18+
data.push ({
19+
data: ds[1],
20+
label: 'Energy & Utilities',
21+
bars: {
22+
order: 2
23+
}
24+
});
25+
26+
data.push ({
27+
data: ds[2],
28+
label: 'Professional Services',
29+
bars: {
30+
order: 3
31+
}
32+
});
33+
34+
Charts.horizontal ('#horizontal-chart', data);
35+
36+
});

assets/js/charts/line.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$(function () {
2+
3+
var d1 = [3.0, 3.0, 4.2, 4.4, 1.3, 2.9, 2.8, 1.9, 2.1, 3.4, 6.8, 8.1, 7.5, 7.1, 7.5, 9.5, 12.1, 12.4, 10.9, 10.4, 10.9, 9.1, 9.4, 10.5],
4+
d2 = [ 0.6, 1.2, 1.7, 0.7, 2.9, 4.1, 2.6, 3.7, 3.9, 1.7, 2.3, 3.0, 3.3, 4.8, 5.0, 4.8, 5.0, 3.2, 2.0, 2.4, 2.7, 3.5, 3.2, 2.8];
5+
6+
var dt1 = [],
7+
dt2 = [],
8+
st = new Date(2012, 8, 6).getTime();
9+
10+
for( var i = 0; i < d2.length; i++ ) {
11+
dt1.push([st + i * 3600000, parseFloat( (d1[i]).toFixed( 3 ) )]);
12+
dt2.push([st + i * 3600000, parseFloat( (d2[i]).toFixed( 3 ) )]);
13+
}
14+
15+
var data = [{
16+
data: dt1,
17+
label: 'Revenue'
18+
}, {
19+
data: dt2,
20+
label: 'Expenses',
21+
points: { show: false },
22+
lines: { lineWidth: 2, fill: false }
23+
}];
24+
25+
Charts.line ( '#line-chart', data);
26+
27+
});

assets/js/charts/pie.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$(function () {
2+
3+
var data = [
4+
{ label: "Manufacturing", data: Math.floor (Math.random() * 100 + 250) },
5+
{ label: "Finance", data: Math.floor (Math.random() * 100 + 350) },
6+
{ label: "Energy & Utilities", data: Math.floor (Math.random() * 100 + 650) },
7+
{ label: "Advertising & Marketing", data: Math.floor (Math.random() * 100 + 50) },
8+
{ label: "Professional Services", data: Math.floor (Math.random() * 100 + 250) }
9+
];
10+
11+
Charts.pie ('#pie-chart', data);
12+
13+
});

assets/js/charts/vertical.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
$(function () {
2+
3+
var ds = [];
4+
var data = [];
5+
6+
ds.push ([[1,25],[2,34],[3,37],[4,45],[5,56]]);
7+
ds.push ([[1,13],[2,29],[3,25],[4,23],[5,31]]);
8+
ds.push ([[1,8],[2,13],[3,19],[4,15],[5,14]]);
9+
10+
data.push ({
11+
data: ds[0],
12+
label: 'Finance',
13+
bars: {
14+
barWidth: 0.15,
15+
order: 1
16+
}
17+
});
18+
data.push ({
19+
data: ds[1],
20+
label: 'Advertising & Marketing',
21+
bars: {
22+
barWidth: 0.15,
23+
order: 2
24+
}
25+
});
26+
data.push ({
27+
data: ds[2],
28+
label: 'Manufacturing',
29+
bars: {
30+
barWidth: 0.15,
31+
order: 3
32+
}
33+
});
34+
35+
Charts.vertical ('#vertical-chart', data);
36+
37+
});
38+

css/application.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ body {
2727
height: auto;
2828
margin-bottom: 15px;
2929
padding: 7px 9px;
30+
}
31+
.chart-holder {
32+
width: 100%;
33+
height: 325px;
3034
}

0 commit comments

Comments
 (0)