1 | <?php ob_start('ob_gzhandler') ?> |
---|
2 | <!DOCTYPE html> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <meta http-equiv="X-UA-Compatible" content="chrome=1"> |
---|
6 | <!-- |
---|
7 | /** |
---|
8 | * o------------------------------------------------------------------------------o |
---|
9 | * | This file is part of the RGraph package - you can learn more at: | |
---|
10 | * | | |
---|
11 | * | http://www.rgraph.net | |
---|
12 | * | | |
---|
13 | * | This package is licensed under the RGraph license. For all kinds of business | |
---|
14 | * | purposes there is a small one-time licensing fee to pay and for non | |
---|
15 | * | commercial purposes it is free to use. You can read the full license here: | |
---|
16 | * | | |
---|
17 | * | http://www.rgraph.net/LICENSE.txt | |
---|
18 | * o------------------------------------------------------------------------------o |
---|
19 | */ |
---|
20 | --> |
---|
21 | <title>RGraph: Javascript charts and graph library - Adjusting your charts interactively - Gantt chart</title> |
---|
22 | |
---|
23 | <meta name="keywords" content="rgraph html5 canvas chart adjusting docs " /> |
---|
24 | <meta name="description" content="RGraph: Javascript charts and graph library - Documentation about adjusting your charts - Gantt chart" /> |
---|
25 | |
---|
26 | <meta property="og:title" content="RGraph: Javascript charts and graph library" /> |
---|
27 | <meta property="og:description" content="A charts library based on the HTML5 canvas tag" /> |
---|
28 | <meta property="og:image" content="http://www.rgraph.net/images/logo.png"/> |
---|
29 | |
---|
30 | <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" /> |
---|
31 | <link rel="icon" type="image/png" href="../images/favicon.png"> |
---|
32 | |
---|
33 | <script src="../libraries/RGraph.common.core.js" ></script> |
---|
34 | <script src="../libraries/RGraph.common.adjusting.js" ></script> |
---|
35 | <script src="../libraries/RGraph.gantt.js" ></script> |
---|
36 | <!--[if IE 8]><script src="../excanvas/excanvas.original.js"></script><![endif]--> |
---|
37 | |
---|
38 | <script> |
---|
39 | window.onload = function (e) |
---|
40 | { |
---|
41 | gantt_events = [ |
---|
42 | [31, 28, null, 'Richard'], |
---|
43 | [0, 120, null, 'Bob'], |
---|
44 | [84, 16, null, 'Fred'], |
---|
45 | [35, 45, null, 'Charles'], |
---|
46 | [0, 35, null, 'Kev'], |
---|
47 | [0, 28, null, 'Wayne'], |
---|
48 | [31, 28, null, 'John'] |
---|
49 | ]; |
---|
50 | var gantt = new RGraph.Gantt('myc'); |
---|
51 | gantt.Set('chart.xmax', 120); |
---|
52 | gantt.Set('chart.events', gantt_events); |
---|
53 | gantt.Set('chart.defaultcolor', 'rgba(255,0,0,0.5)'); |
---|
54 | gantt.Set('chart.labels', ['January', 'February', 'March', 'April']); |
---|
55 | //gantt.Set('chart.borders', false); |
---|
56 | gantt.Set('chart.title', 'An adjustable Gantt chart'); |
---|
57 | gantt.Set('chart.adjustable', true); |
---|
58 | gantt.Set('chart.vbars', [ |
---|
59 | [0, 31, 'rgba(230,230,230,0.8)'], |
---|
60 | [59, 31, 'rgba(230,230,230,0.8)'] |
---|
61 | ]); |
---|
62 | gantt.Draw(); |
---|
63 | |
---|
64 | /** |
---|
65 | * This is how to get notified once adjusting has ended |
---|
66 | */ |
---|
67 | RGraph.AddCustomEventListener(gantt, 'onadjustend',function (obj) |
---|
68 | { |
---|
69 | var events = obj.Get('chart.events'); |
---|
70 | var conf = RGraph.Registry.Get('chart.adjusting.gantt'); |
---|
71 | var idx = conf['index']; |
---|
72 | |
---|
73 | cl(gantt.Get('chart.events')[idx]); |
---|
74 | cl(conf); |
---|
75 | |
---|
76 | |
---|
77 | document.getElementById("eventID").value = idx; |
---|
78 | document.getElementById("eventStart").value = events[idx][0]; |
---|
79 | document.getElementById("eventDuration").value = events[idx][1]; |
---|
80 | }); |
---|
81 | |
---|
82 | /** |
---|
83 | * This is how to get notified during the adjusting |
---|
84 | */ |
---|
85 | RGraph.AddCustomEventListener(gantt, 'onadjust',function (obj) |
---|
86 | { |
---|
87 | var events = obj.Get('chart.events'); |
---|
88 | var conf = RGraph.Registry.Get('chart.adjusting.gantt'); |
---|
89 | var idx = conf[0]; |
---|
90 | |
---|
91 | document.getElementById("eventID").value = conf['index']; |
---|
92 | document.getElementById("eventStart").value = events[conf['index']][0]; |
---|
93 | document.getElementById("eventDuration").value = events[conf['index']][1]; |
---|
94 | }); |
---|
95 | } |
---|
96 | </script> |
---|
97 | |
---|
98 | |
---|
99 | <script> |
---|
100 | var _gaq = _gaq || []; |
---|
101 | _gaq.push(['_setAccount', 'UA-54706-2']); |
---|
102 | _gaq.push(['_trackPageview']); |
---|
103 | |
---|
104 | (function() { |
---|
105 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
---|
106 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
---|
107 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
---|
108 | })(); |
---|
109 | </script> |
---|
110 | </head> |
---|
111 | |
---|
112 | <body> |
---|
113 | |
---|
114 | |
---|
115 | <!-- Social networking buttons --> |
---|
116 | <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed"> |
---|
117 | <a title="Bookmark with delicious" href="http://delicious.com/save?jump=close&v=4&noui&jump=close&url=http://www.rgraph.net¬es=RGraph%20is%20a%20HTML5%20based%20javascript%20charts%20library%20supporting%20a%20wide%20range%20of%20different%20charts%20types&title=RGraph:Javascript%20charts%20and%20graphs%20library" target="_blank"><img src="../images/delicious.png" alt="Bookmark with delicious" width="22" height="22" border="0" align="absmiddle" /></a> |
---|
118 | <a href="http://twitter.com/home/?status=RGraph%3A%20Javascript+charts+and+graph+library+http%3A%2F%2Fwww.rgraph.net+%23rgraph+%23html5+%23canvas+%23javascript+%23charts+@_rgraph" target="_blank"><img src="../images/twitter.png" id="twitter_icon" alt="tweet this site" width="22" height="22" border="0" align="absmiddle" /></a> |
---|
119 | </div> |
---|
120 | |
---|
121 | <script> |
---|
122 | // Opera fix |
---|
123 | if (navigator.userAgent.indexOf('Opera') == -1) { |
---|
124 | document.getElementById("social_icons").style.position = 'fixed'; |
---|
125 | } |
---|
126 | </script> |
---|
127 | <!-- Social networking buttons --> |
---|
128 | |
---|
129 | <div id="breadcrumb"> |
---|
130 | <a href="../index.html">RGraph: Javascript charts and graph library</a> |
---|
131 | > |
---|
132 | <a href="index.html">Documentation</a> |
---|
133 | > |
---|
134 | <a href="adjusting.html">Adjusting charts interactively</a> |
---|
135 | > |
---|
136 | Gantt chart |
---|
137 | </div> |
---|
138 | |
---|
139 | <h1>RGraph: <span>Javascript charts and graph library</span> - Adjusting your charts interactively - Gantt chart</h1> |
---|
140 | |
---|
141 | <script> |
---|
142 | if (RGraph.isIE8()) { |
---|
143 | document.write('<div style="background-color: #fee; border: 2px dashed red; padding: 5px"><b>Important</b><br /><br /> Internet Explorer 8 does not natively support the HTML5 canvas tag, so if you want to see the charts, you can either:<ul><li>Install <a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a></li><li>Use ExCanvas. This is provided in the RGraph Archive.</li><li>Use another browser entirely. Your choices are Firefox 3.5+, Chrome 2+, Safari 4+ or Opera 10.5+. </li></ul> <b>Note:</b> Internet Explorer 9 fully supports the canvas tag. Click <a href="http://support.rgraph.net/message/rgraph-in-internet-explorer-9.html" target="_blank">here</a> to see some screenshots.</div>'); |
---|
144 | } |
---|
145 | </script> |
---|
146 | |
---|
147 | <p> |
---|
148 | The Gantt chart can be adjusted by dragging the bars left or right, or the events can be resized if you place the cursor at the |
---|
149 | right edge of the event. To get the details of the bar being dragged you can use the |
---|
150 | <i>onadjustend</i> event, and in that you can look at the RGraph registry - <i>RGraph.Registry.Get('chart.adjusting.gantt')</i> The |
---|
151 | returned array consists of: |
---|
152 | |
---|
153 | <ul> |
---|
154 | <li>The numerical index of the event being adjusted (corresponding to the chart.events array that you set).</li> |
---|
155 | <li>The chart object</li> |
---|
156 | <li>The starting X position of the bar (before the chart was adjusted)</li> |
---|
157 | <li>The starting Y position of the bar (before the chart was adjusted)</li> |
---|
158 | <li>The original numerical value (in relation to your chart.xmax) that the bar started at</li> |
---|
159 | </ul> |
---|
160 | </p> |
---|
161 | |
---|
162 | <p> |
---|
163 | When adjusting is complete the <i>chart.events</i> array is updated. So you can use the numerical index that you find in |
---|
164 | the registry (as above) with the <i>chart.events</i> array to get up-to-date event information. |
---|
165 | </p> |
---|
166 | |
---|
167 | <p> |
---|
168 | <b>Note:</b> |
---|
169 | The Gantt chart uses console.log() to send notifications. Press CTRL+SHIFT+J in Chrome to see the console, or use Firebug in |
---|
170 | Firefox. Other browsers will vary. |
---|
171 | </p> |
---|
172 | |
---|
173 | <canvas id="myc" width="1000" height="250">[No canvas support]</canvas> |
---|
174 | Event ID: <input type="text" id="eventID" readonly /> |
---|
175 | Event start: <input type="text" id="eventStart" readonly /> |
---|
176 | Event duration: <input type="text" id="eventDuration" readonly /> |
---|
177 | |
---|
178 | <pre class="code"> |
---|
179 | <script> |
---|
180 | window.onload = function (e) |
---|
181 | { |
---|
182 | gantt_events = [ |
---|
183 | [31, 28, null, 'Richard'], |
---|
184 | [0, 120, null, 'Bob'], |
---|
185 | [84, 16, null, 'Fred'], |
---|
186 | [35, 45, null, 'Charles'], |
---|
187 | [0, 35, null, 'Kev'], |
---|
188 | ]; |
---|
189 | var gantt = new RGraph.Gantt('myc'); |
---|
190 | gantt.Set('chart.xmax', 120); |
---|
191 | gantt.Set('chart.events', gantt_events); |
---|
192 | gantt.Set('chart.defaultcolor', '#0c0'); |
---|
193 | gantt.Set('chart.labels', ['January', 'February', 'March', 'April']); |
---|
194 | gantt.Set('chart.borders', false); |
---|
195 | gantt.Set('chart.adjustable', true); |
---|
196 | gantt.Draw(); |
---|
197 | |
---|
198 | /** |
---|
199 | * This is how to get notified once adjusting has ended |
---|
200 | */ |
---|
201 | RGraph.AddCustomEventListener(gantt, 'onadjustend',function (obj) |
---|
202 | { |
---|
203 | var idx = RGraph.Registry.Get('chart.adjusting.gantt')[0]; |
---|
204 | |
---|
205 | cl(RGraph.Registry.Get('chart.adjusting.gantt')); |
---|
206 | cl(gantt.Get('chart.events')[idx]); |
---|
207 | }); |
---|
208 | |
---|
209 | /** |
---|
210 | * This is how to get notified during the adjusting |
---|
211 | */ |
---|
212 | RGraph.AddCustomEventListener(gantt, 'onadjust',function (obj) |
---|
213 | { |
---|
214 | var events = obj.Get('chart.events'); |
---|
215 | var conf = RGraph.Registry.Get('chart.adjusting.gantt'); |
---|
216 | var idx = conf[0]; |
---|
217 | |
---|
218 | document.getElementById("eventID").value = conf[0]; |
---|
219 | document.getElementById("eventStart").value = events[conf[0]][0]; |
---|
220 | document.getElementById("eventDuration").value = events[conf[0]][1]; |
---|
221 | }); |
---|
222 | } |
---|
223 | </script> |
---|
224 | </pre> |
---|
225 | |
---|
226 | </body> |
---|
227 | </html> |
---|