OLD | NEW |
1 /* | 1 /* ² |
2 * ChartNew.js | 2 * ChartNew.js |
3 * | 3 * |
4 * Vancoppenolle Francois - January 2014 | 4 * Vancoppenolle Francois - January 2014 |
5 * francois.vancoppenolle@favomo.be | 5 * francois.vancoppenolle@favomo.be |
6 * | 6 * |
7 * Source location : http:\\www.favomo.be\graphjs | 7 * Source location : http:\\www.favomo.be\graphjs |
8 * GitHub community : https://github.com/FVANCOP/ChartNew.js | 8 * GitHub community : https://github.com/FVANCOP/ChartNew.js |
9 * | 9 * |
10 * This file is an adaptation of the chart.js source developped by Nick Downie (
2013) | 10 * This file is originally an adaptation of the chart.js source developped by Ni
ck Downie (2013) |
11 * https://github.com/nnnick/Chart.js | 11 * https://github.com/nnnick/Chart.js. But since june 2014, Nick puts a new vers
ion with a |
| 12 * refunded code. Current code of ChartNew.js is no more comparable to the code
of Chart.js |
12 * | 13 * |
13 * new charts | 14 * new charts compared to Chart.js |
14 * | 15 * |
15 * horizontalBar | 16 * horizontalBar |
16 * horizontalStackedBar | 17 * horizontalStackedBar |
17 * | 18 * |
18 * Added items : | 19 * Added items compared to Chart.js: |
19 * | 20 * |
20 * Title | 21 * Title, Subtitle, footnotes, axis labels, unit label |
21 * Subtitle | |
22 * X Axis Label | |
23 * Y Axis Label | |
24 * Unit Label | |
25 * Y Axis on the right and/or the left | 22 * Y Axis on the right and/or the left |
26 * Annotates | |
27 * canvas Border | 23 * canvas Border |
28 * Legend | 24 * Legend |
29 * Footnote | 25 * crossText, crossImage |
30 * crossText | 26 * graphMin, graphMax |
31 * graphMin / graphMax | |
32 * logarithmic y-axis (for line and bar) | 27 * logarithmic y-axis (for line and bar) |
33 * rotateLabels | 28 * rotateLabels |
34 * and lot of others... | 29 * and lot of others... |
35 * | 30 * |
36 */ | 31 */ |
37 // non standard functions; | 32 // non standard functions; |
38 if (typeof String.prototype.trim !== 'function') { | 33 if (typeof String.prototype.trim !== 'function') { |
39 String.prototype.trim = function() { | 34 String.prototype.trim = function() { |
40 return this.replace(/^\s+|\s+$/g, ''); | 35 return this.replace(/^\s+|\s+$/g, ''); |
41 } | 36 } |
(...skipping 23 matching lines...) Expand all Loading... |
65 } | 60 } |
66 var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); | 61 var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); |
67 for (; k < len; k++) { | 62 for (; k < len; k++) { |
68 if (k in t && t[k] === searchElement) { | 63 if (k in t && t[k] === searchElement) { |
69 return k; | 64 return k; |
70 } | 65 } |
71 } | 66 } |
72 return -1; | 67 return -1; |
73 } | 68 } |
74 }; | 69 }; |
75 var charJSPersonalDefaultOptions = {} | 70 var charJSPersonalDefaultOptions = {}; |
76 var charJSPersonalDefaultOptionsLine = {} | 71 var charJSPersonalDefaultOptionsLine = {} ; |
77 var charJSPersonalDefaultOptionsRadar = {} | 72 var charJSPersonalDefaultOptionsRadar = {} ; |
78 var charJSPersonalDefaultOptionsPolarArea = {} | 73 var charJSPersonalDefaultOptionsPolarArea = {} ; |
79 var charJSPersonalDefaultOptionsPie = {} | 74 var charJSPersonalDefaultOptionsPie = {}; |
80 var charJSPersonalDefaultOptionsDoughnut = {} | 75 var charJSPersonalDefaultOptionsDoughnut = {}; |
81 var charJSPersonalDefaultOptionsBar = {} | 76 var charJSPersonalDefaultOptionsBar = {}; |
82 var charJSPersonalDefaultOptionsStackedBar = {} | 77 var charJSPersonalDefaultOptionsStackedBar = {}; |
83 var charJSPersonalDefaultOptionsHorizontalBar = {} | 78 var charJSPersonalDefaultOptionsHorizontalBar = {}; |
84 var charJSPersonalDefaultOptionsHorizontalStackedBar = {} | 79 var charJSPersonalDefaultOptionsHorizontalStackedBar = {}; |
85 ///////// FUNCTIONS THAN CAN BE USED IN THE TEMPLATES //////////////////
///////////////////////// | 80 ///////// FUNCTIONS THAN CAN BE USED IN THE TEMPLATES //////////////////
///////////////////////// |
86 | 81 |
87 function roundToWithThousands(config, num, place) { | 82 function roundToWithThousands(config, num, place) { |
88 var newval = 1 * unFormat(config, num); | 83 var newval = 1 * unFormat(config, num); |
89 if (typeof(newval) == "number" && place != "none") { | 84 if (typeof(newval) == "number" && place != "none") { |
90 if (place <= 0) { | 85 if (place <= 0) { |
91 var roundVal = -place; | 86 var roundVal = -place; |
92 newval = +(Math.round(newval + "e+" + roundVal) + "e-" +
roundVal); | 87 newval = +(Math.round(newval + "e+" + roundVal) + "e-" +
roundVal); |
93 } else { | 88 } else { |
94 var roundVal = place; | 89 var roundVal = place; |
95 var divval = "1e+" + roundVal; | 90 var divval = "1e+" + roundVal; |
96 newval = +(Math.round(newval / divval)) * divval; | 91 newval = +(Math.round(newval / divval)) * divval; |
97 } | 92 } |
98 } | 93 } |
99 newval = fmtChartJS(config, newval, "none"); | 94 newval = fmtChartJS(config, newval, "none"); |
100 return (newval); | 95 return (newval); |
101 }; | 96 }; |
102 | 97 |
103 function unFormat(config, num) { | 98 function unFormat(config, num) { |
104 if ((config.decimalSeparator != "." || config.thousandSeparator != "") &
& typeof(num) == "string") { | 99 if ((config.decimalSeparator != "." || config.thousandSeparator != "") &
& typeof(num) == "string") { |
105 var v1 = "" + num; | 100 var v1 = "" + num; |
106 if (config.thousandSeparator != "") { | 101 if (config.thousandSeparator != "") { |
107 while (v1.indexOf(config.thousandSeparator) >= 0) v1 = "
" + v1.replace(config.thousandSeparator, ""); | 102 while (v1.indexOf(config.thousandSeparator) >= 0) v1 = "
" + v1.replace(config.thousandSeparator, ""); |
108 } | 103 } |
109 if (config.decimalSeparator != ".") v1 = "" + v1.replace(config.
decimalSeparator, ".") | 104 if (config.decimalSeparator != ".") v1 = "" + v1.replace(config.
decimalSeparator, ".") |
110 // v1=fmtChartJS(config,1*roundToWithThousands(1*v1
,place),"none") | |
111 return 1 * v1; | 105 return 1 * v1; |
112 } else { | 106 } else { |
113 return num; | 107 return num; |
114 } | 108 } |
115 }; | 109 }; |
116 ///////// ANNOTATE PART OF THE SCRIPT //////////////////////////////////////////
/ | 110 ///////// ANNOTATE PART OF THE SCRIPT //////////////////////////////////////////
/ |
117 /*******************************************************************************
* | 111 /*******************************************************************************
* |
118 Copyright (C) 1999 Thomas Brattli | 112 Copyright (C) 1999 Thomas Brattli |
119 This script is made by and copyrighted to Thomas Brattli | 113 This script is made by and copyrighted to Thomas Brattli |
120 Visit for more great scripts. This may be used freely as long as this msg is int
act! | 114 Visit for more great scripts. This may be used freely as long as this msg is int
act! |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 if (config.thousandSeparator != "") { | 154 if (config.thousandSeparator != "") { |
161 var part1 = return_value; | 155 var part1 = return_value; |
162 var part2 = ""; | 156 var part2 = ""; |
163 var posdec = part1.indexOf(config.decimalSeparat
or); | 157 var posdec = part1.indexOf(config.decimalSeparat
or); |
164 if (posdec >= 0) { | 158 if (posdec >= 0) { |
165 part2 = part1.substring(posdec + 1, part
1.length); | 159 part2 = part1.substring(posdec + 1, part
1.length); |
166 part2 = part2.split('').reverse().join('
'); // reverse string | 160 part2 = part2.split('').reverse().join('
'); // reverse string |
167 part1 = part1.substring(0, posdec); | 161 part1 = part1.substring(0, posdec); |
168 } | 162 } |
169 part1 = part1.toString().replace(/\B(?=(\d{3})+(
?!\d))/g, config.thousandSeparator); | 163 part1 = part1.toString().replace(/\B(?=(\d{3})+(
?!\d))/g, config.thousandSeparator); |
170 // part2=part2.toString().replace(/\B(?=(\d{3})+
(?!\d))/g, config.thousandSeparator); | |
171 part2 = part2.split('').reverse().join(''); // r
everse string | 164 part2 = part2.split('').reverse().join(''); // r
everse string |
172 return_value = part1 | 165 return_value = part1 |
173 if (part2 != "") return_value = return_value + c
onfig.decimalSeparator + part2; | 166 if (part2 != "") return_value = return_value + c
onfig.decimalSeparator + part2; |
174 } | 167 } |
175 } else return_value = value; | 168 } else return_value = value; |
176 } else if (fmt != "none" && fmt != "notformatted") { | 169 } else if (fmt != "none" && fmt != "notformatted") { |
177 return_value = fmtChartJSPerso(config, value, fmt); | 170 return_value = fmtChartJSPerso(config, value, fmt); |
178 } else { | 171 } else { |
179 return_value = value; | 172 return_value = value; |
180 } | 173 } |
181 return (return_value); | 174 return (return_value); |
182 }; | 175 }; |
183 | 176 |
184 function addParameters2Function(data, fctName, fctList) { | 177 function addParameters2Function(data, fctName, fctList) { |
185 » » var mathFunctions = { | 178 » var mathFunctions = { |
186 » » » mean: { | 179 » » mean: { |
187 » » » » data: data.data, | 180 » » » data: data.data, |
188 » » » » datasetNr: data.v11 | 181 » » » datasetNr: data.v11 |
189 » » » }, | 182 » » }, |
190 » » » varianz: { | 183 » » varianz: { |
191 » » » » data: data.data, | 184 » » » data: data.data, |
192 » » » » datasetNr: data.v11 | 185 » » » datasetNr: data.v11 |
193 » » » }, | 186 » » }, |
194 » » » stddev: { | 187 » » stddev: { |
195 » » » » data: data.data, | 188 » » » data: data.data, |
196 » » » » datasetNr: data.v11 | 189 » » » datasetNr: data.v11 |
197 » » » }, | 190 » » }, |
198 » » » cv: { | 191 » » cv: { |
199 » » » » data: data.data, | 192 » » » data: data.data, |
200 » » » » datasetNr: data.v11 | 193 » » » datasetNr: data.v11 |
201 » » » }, | 194 » » }, |
202 » » » median: { | 195 » » median: { |
203 » » » » data: data.data, | 196 » » » data: data.data, |
204 » » » » datasetNr: data.v11 | 197 » » » datasetNr: data.v11 |
205 » » » } | |
206 » » }; | |
207 » » // difference to current value (v3) | |
208 » » dif = false; | |
209 » » if (fctName.substr(-3) == "Dif") { | |
210 » » » fctName = fctName.substr(0, fctName.length - 3); | |
211 » » » dif = true; | |
212 } | 198 } |
213 » » if (typeof eval(fctName) == "function") { | 199 » }; |
214 » » » var parameter = eval(fctList + "." + fctName); | 200 » // difference to current value (v3) |
215 » » » if (dif) { | 201 » dif = false; |
216 » » » » // difference between v3 (current value) and mat
h function | 202 » if (fctName.substr(-3) == "Dif") { |
217 » » » » return data.v3 - window[fctName](parameter); | 203 » » fctName = fctName.substr(0, fctName.length - 3); |
218 » » » } | 204 » » dif = true; |
219 » » » return window[fctName](parameter); | 205 » } |
| 206 » if (typeof eval(fctName) == "function") { |
| 207 » » var parameter = eval(fctList + "." + fctName); |
| 208 » » if (dif) { |
| 209 » » » // difference between v3 (current value) and math functi
on |
| 210 » » » return data.v3 - window[fctName](parameter); |
220 } | 211 } |
221 » » return; | 212 » » return window[fctName](parameter); |
222 } | 213 } |
223 » //Is a number function | 214 » return; |
| 215 }; |
224 | 216 |
225 function isNumber(n) { | 217 function isNumber(n) { |
226 return !isNaN(parseFloat(n)) && isFinite(n); | 218 return !isNaN(parseFloat(n)) && isFinite(n); |
227 }; | 219 }; |
228 | 220 |
229 function tmplbis(str, data) { | 221 function tmplbis(str, data) { |
230 var mathFunctionList = ["mean", "varianz", "stddev", "cv", "median"]; | 222 var mathFunctionList = ["mean", "varianz", "stddev", "cv", "median"]; |
231 var regexMath = new RegExp('<%=((?:(?:.*?)\\W)??)((?:' + mathFunctionLis
t.join('|') + ')(?:Dif)?)\\(([0-9]*?)\\)(.*?)%>', 'g'); | 223 var regexMath = new RegExp('<%=((?:(?:.*?)\\W)??)((?:' + mathFunctionLis
t.join('|') + ')(?:Dif)?)\\(([0-9]*?)\\)(.*?)%>', 'g'); |
232 while (regexMath.test(str)) { | 224 while (regexMath.test(str)) { |
233 str = str.replace(regexMath, function($0, $1, $2, $3, $4) { | 225 str = str.replace(regexMath, function($0, $1, $2, $3, $4) { |
(...skipping 26 matching lines...) Expand all Loading... |
260 .replace(/[\t]/g, " ") | 252 .replace(/[\t]/g, " ") |
261 .split("<%").join("\t") | 253 .split("<%").join("\t") |
262 .replace(/((^|%>)[^\t]*)'/g, "$1\r") | 254 .replace(/((^|%>)[^\t]*)'/g, "$1\r") |
263 .replace(/\t=(.*?)%>/g, "',$1,'") | 255 .replace(/\t=(.*?)%>/g, "',$1,'") |
264 .split("\t").join("');") | 256 .split("\t").join("');") |
265 .split("%>").join("p.push('") | 257 .split("%>").join("p.push('") |
266 .split("\r").join("\\'") + "');}return p.join('');"); | 258 .split("\r").join("\\'") + "');}return p.join('');"); |
267 // Provide some basic currying to the user | 259 // Provide some basic currying to the user |
268 return data ? fn(data) : fn; | 260 return data ? fn(data) : fn; |
269 }; | 261 }; |
270 /** | 262 if (typeof CanvasRenderingContext2D !== 'undefined') { |
271 * ctx.prototype | 263 » /** |
272 * fillText option for canvas Multiline Support | 264 » * ctx.prototype |
273 * @param text string \n for newline | 265 » * fillText option for canvas Multiline Support |
274 * @param x x position | 266 » * @param text string \n for newline |
275 * @param y y position | 267 » * @param x x position |
276 * @param yLevel = "bottom" => last line has this y-Pos [default], = "middle" =>
the middle line has this y-Pos) | 268 » * @param y y position |
277 * @param lineHeight lineHeight | 269 » * @param yLevel = "bottom" => last line has this y-Pos [default], = "mi
ddle" => the middle line has this y-Pos) |
278 */ | 270 » * @param lineHeight lineHeight |
279 CanvasRenderingContext2D.prototype.fillTextMultiLine = function(text, x, y, yLev
el, lineHeight) { | 271 » */ |
280 » var lines = ("" + text).split("\n"); | 272 » CanvasRenderingContext2D.prototype.fillTextMultiLine = function(text, x,
y, yLevel, lineHeight,horizontal) { |
281 » // if its one line => in the middle | 273 » » var lines = ("" + text).split("\n"); |
282 » // two lines one above the mid one below etc.» | 274 » » // if its one line => in the middle |
283 » if (yLevel == "middle") { | 275 » » // two lines one above the mid one below etc.» |
284 » » y -= ((lines.length - 1) / 2) * lineHeight; | 276 » » if (yLevel == "middle") { |
285 » } else if (yLevel == "bottom") { // default | 277 » » » if(horizontal)y -= ((lines.length - 1) / 2) * lineHeight
; |
286 » » y -= (lines.length - 1) * lineHeight; | 278 » » } else if (yLevel == "bottom") { // default |
287 » } | 279 » » » if(horizontal)y -= (lines.length - 1) * lineHeight; |
288 » for (var i = 0; i < lines.length; i++) { | 280 » » } |
289 » » this.fillText(lines[i], x, y); | 281 » » for (var i = 0; i < lines.length; i++) { |
290 » » y += lineHeight; | 282 » » » this.fillText(lines[i], x, y); |
291 » } | 283 » » » y += lineHeight; |
292 } | 284 » » }» |
293 CanvasRenderingContext2D.prototype.measureTextMultiLine = function(text, lineHei
ght) { | |
294 » var textWidth = 0; | |
295 » var lg; | |
296 » var lines = ("" + text).split("\n"); | |
297 » var textHeight = lines.length * lineHeight; | |
298 » // if its one line => in the middle | |
299 » // two lines one above the mid one below etc.» | |
300 » for (var i = 0; i < lines.length; i++) { | |
301 » » lg = this.measureText(lines[i]).width; | |
302 » » if (lg > textWidth) textWidth = lg; | |
303 » } | |
304 » return { | |
305 » » textWidth: textWidth, | |
306 » » textHeight: textHeight | |
307 }; | 285 }; |
308 } | 286 » CanvasRenderingContext2D.prototype.measureTextMultiLine = function(text,
lineHeight) { |
| 287 » » var textWidth = 0; |
| 288 » » var lg; |
| 289 » » var lines = ("" + text).split("\n"); |
| 290 » » var textHeight = lines.length * lineHeight; |
| 291 » » // if its one line => in the middle |
| 292 » » // two lines one above the mid one below etc.» |
| 293 » » for (var i = 0; i < lines.length; i++) { |
| 294 » » » lg = this.measureText(lines[i]).width; |
| 295 » » » if (lg > textWidth) textWidth = lg; |
| 296 » » } |
| 297 » » return { |
| 298 » » » textWidth: textWidth, |
| 299 » » » textHeight: textHeight |
| 300 » » }; |
| 301 » }; |
| 302 }; |
309 cursorDivCreated = false; | 303 cursorDivCreated = false; |
310 | 304 |
311 function createCursorDiv() { | 305 function createCursorDiv() { |
312 if (cursorDivCreated == false) { | 306 if (cursorDivCreated == false) { |
313 var div = document.createElement('divCursor'); | 307 var div = document.createElement('divCursor'); |
314 div.id = 'divCursor'; | 308 div.id = 'divCursor'; |
315 div.style.position = 'absolute'; | 309 div.style.position = 'absolute'; |
316 document.body.appendChild(div); | 310 document.body.appendChild(div); |
317 cursorDivCreated = true; | 311 cursorDivCreated = true; |
318 } | 312 } |
(...skipping 10 matching lines...) Expand all Loading... |
329 resizeCtx(ctx,newSize.newWidth,newSize.newHeight); | 323 resizeCtx(ctx,newSize.newWidth,newSize.newHeight); |
330 ctx.prevWidth=newSize.newWidth; | 324 ctx.prevWidth=newSize.newWidth; |
331 } | 325 } |
332 ctx.prevWidth=newSize.newWidth; | 326 ctx.prevWidth=newSize.newWidth; |
333 ctx.prevHeight=newSize.newHeight; | 327 ctx.prevHeight=newSize.newHeight; |
334 jsGraphResize[jsGraphResize.length]= [id,ctx.tpchart,ctx,data,config]; | 328 jsGraphResize[jsGraphResize.length]= [id,ctx.tpchart,ctx,data,config]; |
335 }; | 329 }; |
336 | 330 |
337 function initChartResize() { | 331 function initChartResize() { |
338 if(initChartJsResize==false) { | 332 if(initChartJsResize==false) { |
339 » » window.addEventListener("resize", chartJsResize); | 333 » » if (window.addEventListener) { |
| 334 » » » window.addEventListener("resize", chartJsResize); |
| 335 » » } else { |
| 336 » » » window.attachEvent("resize", chartJsResize); |
| 337 » » } |
340 } | 338 } |
341 }; | 339 }; |
342 | 340 |
343 function getMaximumWidth(domNode){ | 341 function getMaximumWidth(domNode){ |
344 var container = domNode.parentNode; | 342 var container = domNode.parentNode; |
345 // TODO = check cross browser stuff with this. | |
346 return container.clientWidth; | 343 return container.clientWidth; |
347 }; | 344 }; |
348 | 345 |
349 function getMaximumHeight(domNode){ | 346 function getMaximumHeight(domNode){ |
350 var container = domNode.parentNode; | 347 var container = domNode.parentNode; |
351 // TODO = check cross browser stuff with this. | |
352 return container.clientHeight; | 348 return container.clientHeight; |
353 }; | 349 }; |
354 | 350 |
355 | 351 |
356 function resizeCtx(ctx,newWidth,newHeight) | 352 function resizeCtx(ctx,newWidth,newHeight) |
357 { | 353 { |
358 » if (window.devicePixelRatio) { // Retina devine | 354 » if (window.devicePixelRatio) { // Retina device |
359 | 355 |
360 ctx.canvas.style.width = newWidth/window.devicePixelRatio + "px"
; | 356 ctx.canvas.style.width = newWidth/window.devicePixelRatio + "px"
; |
361 ctx.canvas.style.height = newHeight/window.devicePixelRatio + "p
x"; | 357 ctx.canvas.style.height = newHeight/window.devicePixelRatio + "p
x"; |
362 ctx.canvas.height = newHeight/window.devicePixelRatio * window.d
evicePixelRatio; | 358 ctx.canvas.height = newHeight/window.devicePixelRatio * window.d
evicePixelRatio; |
363 ctx.canvas.width = newWidth/window.devicePixelRatio * window.dev
icePixelRatio; | 359 ctx.canvas.width = newWidth/window.devicePixelRatio * window.dev
icePixelRatio; |
364 ctx.scale(window.devicePixelRatio, window.devicePixelRatio); | 360 ctx.scale(window.devicePixelRatio, window.devicePixelRatio); |
365 } else { | 361 } else { |
366 ctx.canvas.height = newHeight ; | 362 ctx.canvas.height = newHeight ; |
367 ctx.canvas.width = newWidth; | 363 ctx.canvas.width = newWidth; |
368 } | 364 } |
369 } | 365 }; |
370 | 366 |
371 function resizeGraph(ctx,config) { | 367 function resizeGraph(ctx,config) { |
372 if(typeof config.maintainAspectRatio == "undefined")config.maintainAspec
tRatio=true; | 368 if(typeof config.maintainAspectRatio == "undefined")config.maintainAspec
tRatio=true; |
| 369 if(typeof config.responiveMinWidth == "undefined")config.responsiveMinWi
dth=0; |
| 370 if(typeof config.responsiveMinHeight == "undefined")config.responsiveMi
nHeight=0; |
| 371 if(typeof config.responsiveMaxWidth == "undefined")config.responsiveMax
Width=9999999; |
| 372 if(typeof config.responsiveMaxHeight == "undefined")config.responsiveMa
xHeight=9999999; |
373 var canvas = ctx.canvas; | 373 var canvas = ctx.canvas; |
374 if(typeof ctx.aspectRatio == "undefined") { | 374 if(typeof ctx.aspectRatio == "undefined") { |
375 ctx.aspectRatio = canvas.width / canvas.height; | 375 ctx.aspectRatio = canvas.width / canvas.height; |
376 } | 376 } |
| 377 |
377 var newWidth = getMaximumWidth(canvas); | 378 var newWidth = getMaximumWidth(canvas); |
378 var newHeight = config.maintainAspectRatio ? newWidth / ctx.aspectRatio
: getMaximumHeight(canvas); | 379 var newHeight = config.maintainAspectRatio ? newWidth / ctx.aspectRatio
: getMaximumHeight(canvas); |
| 380 newWidth=Math.min(config.responsiveMaxWidth,Math.max(config.responsiveMi
nWidth,newWidth)); |
| 381 newHeight=Math.min(config.responsiveMaxHeight,Math.max(config.responsive
MinHeight,newHeight)); |
379 return { newWidth : parseInt(newWidth), newHeight : parseInt(newHeight)
}; | 382 return { newWidth : parseInt(newWidth), newHeight : parseInt(newHeight)
}; |
380 }; | 383 }; |
381 | 384 |
382 | 385 |
383 | 386 |
384 function chartJsResize() { | 387 function chartJsResize() { |
385 for (var i=0;i<jsGraphResize.length;i++) { | 388 for (var i=0;i<jsGraphResize.length;i++) { |
386 if(typeof jsGraphResize[i][2].firstPass != "undefined") { | 389 if(typeof jsGraphResize[i][2].firstPass != "undefined") { |
387 if(jsGraphResize[i][2].firstPass == 5)jsGraphResize[i][2
].firstPass=6; | 390 if(jsGraphResize[i][2].firstPass == 5)jsGraphResize[i][2
].firstPass=6; |
388 } | 391 } |
389 subUpdateChart(jsGraphResize[i][2],jsGraphResize[i][3],jsGraphRe
size[i][4]); | 392 subUpdateChart(jsGraphResize[i][2],jsGraphResize[i][3],jsGraphRe
size[i][4]); |
390 } | 393 } |
391 }; | 394 }; |
392 | 395 |
393 function testRedraw(ctx,data,config) { | 396 function testRedraw(ctx,data,config) { |
394 if (ctx.firstPass==2 || ctx.firstPass==4 || ctx.firstPass==9) { | 397 if (ctx.firstPass==2 || ctx.firstPass==4 || ctx.firstPass==9) { |
395 ctx.firstPass=6; | 398 ctx.firstPass=6; |
396 subUpdateChart(ctx,data,config) ; | 399 subUpdateChart(ctx,data,config) ; |
397 return true; | 400 return true; |
398 } else { | 401 } else { |
399 ctx.firstPass=5; | 402 ctx.firstPass=5; |
400 return false; | 403 return false; |
401 } | 404 } |
402 } | 405 }; |
403 | 406 |
404 function updateChart(ctx,data,config,animation,runanimationcompletefunction) { | 407 function updateChart(ctx,data,config,animation,runanimationcompletefunction) { |
405 if (ctx.firstPass==5) | 408 if (ctx.firstPass==5) |
406 { | 409 { |
407 ctx.runanimationcompletefunction=runanimationcompletefunction; | 410 ctx.runanimationcompletefunction=runanimationcompletefunction; |
408 if(animation)ctx.firstPass=0; | 411 if(animation)ctx.firstPass=0; |
409 else if (config.responsive) ctx.firstPass=7; | 412 else if (config.responsive) ctx.firstPass=7; |
410 else ctx.firstPass=7; | 413 else ctx.firstPass=7; |
411 subUpdateChart(ctx,data,config) ; | 414 subUpdateChart(ctx,data,config) ; |
412 | 415 |
413 } | 416 } |
414 } | 417 }; |
415 | 418 |
416 function subUpdateChart(ctx,data,config) { | 419 function subUpdateChart(ctx,data,config) { |
417 // ctx.firstPass==undefined => graph never drawn | 420 // ctx.firstPass==undefined => graph never drawn |
418 // ctx.firstPass==0 => graph is drawn but need to be redrawn with animat
ion | 421 // ctx.firstPass==0 => graph is drawn but need to be redrawn with animat
ion |
419 // ctx.firstPass==1 => graph is drawn with animation | 422 // ctx.firstPass==1 => graph is drawn with animation |
420 // ctx.firstPass==2 => graph is in animation but at the end the graph ne
ed perhaps to be redrawn; | 423 // ctx.firstPass==2 => graph is in animation but at the end the graph ne
ed perhaps to be redrawn; |
421 // ctx.firstPass==3 => graph currently drawing without animation; | 424 // ctx.firstPass==3 => graph currently drawing without animation; |
422 // ctx.firstPass==4 => graph currently drawing without animationb but at
the end, the graph need perhaps to be redrawn; | 425 // ctx.firstPass==4 => graph currently drawing without animationb but at
the end, the graph need perhaps to be redrawn; |
423 // ctx.firstPass==5 => graph is displayed ; | 426 // ctx.firstPass==5 => graph is displayed ; |
424 // ctx.firstPass==6 => graph is displayed but need to be redraw without
animation (because of a resize); | 427 // ctx.firstPass==6 => graph is displayed but need to be redraw without
animation (because of a resize); |
425 // ctx.firstPass==7 => graph is displayed but need to be redraw without
responsivity; | 428 // ctx.firstPass==7 => graph is displayed but need to be redraw without
responsivity; |
426 | |
427 | |
428 if(!dynamicFunction(data, config, ctx)) { return; } | 429 if(!dynamicFunction(data, config, ctx)) { return; } |
429 | 430 |
430 if(typeof ctx.firstPass == "undefined") { | 431 if(typeof ctx.firstPass == "undefined") { |
431 ctx.firstPass=1; | 432 ctx.firstPass=1; |
432 var newSize=resizeGraph(ctx,config); | 433 var newSize=resizeGraph(ctx,config); |
433 if(config.responsive) { | 434 if(config.responsive) { |
434 resizeCtx(ctx,newSize.newWidth,newSize.newHeight); | 435 resizeCtx(ctx,newSize.newWidth,newSize.newHeight); |
435 ctx.prevWidth=newSize.newWidth; | 436 ctx.prevWidth=newSize.newWidth; |
436 ctx.prevHeight=newSize.newHeight; | 437 ctx.prevHeight=newSize.newHeight; |
437 } else { | 438 } else { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 case "StackedBar": | 515 case "StackedBar": |
515 myGraph.StackedBar(data,config); | 516 myGraph.StackedBar(data,config); |
516 break; | 517 break; |
517 case "HorizontalStackedBar": | 518 case "HorizontalStackedBar": |
518 myGraph.HorizontalStackedBar(data,config); | 519 myGraph.HorizontalStackedBar(data,config); |
519 break; | 520 break; |
520 case "Line": | 521 case "Line": |
521 myGraph.Line(data,config); | 522 myGraph.Line(data,config); |
522 break; | 523 break; |
523 } | 524 } |
524 | 525 }; |
525 » | |
526 | |
527 } | |
528 | 526 |
529 | 527 |
530 //Default browsercheck, added to all scripts! | 528 //Default browsercheck, added to all scripts! |
531 function checkBrowser() { | 529 function checkBrowser() { |
532 this.ver = navigator.appVersion | 530 this.ver = navigator.appVersion |
533 this.dom = document.getElementById ? 1 : 0 | 531 this.dom = document.getElementById ? 1 : 0 |
534 this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0; | 532 this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0; |
535 this.ie4 = (document.all && !this.dom) ? 1 : 0; | 533 this.ie4 = (document.all && !this.dom) ? 1 : 0; |
536 this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0; | 534 this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0; |
537 this.ns4 = (document.layers && !this.dom) ? 1 : 0; | 535 this.ns4 = (document.layers && !this.dom) ? 1 : 0; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 var image = ctx.canvas.toDataURL(); | 605 var image = ctx.canvas.toDataURL(); |
608 ctx.putImageData(cvSave, 0, 0); | 606 ctx.putImageData(cvSave, 0, 0); |
609 window.open(image, '_blank'); | 607 window.open(image, '_blank'); |
610 } | 608 } |
611 if (config.savePngOutput == "CurrentWindow") { | 609 if (config.savePngOutput == "CurrentWindow") { |
612 var image = ctx.canvas.toDataURL(); | 610 var image = ctx.canvas.toDataURL(); |
613 ctx.putImageData(cvSave, 0, 0); | 611 ctx.putImageData(cvSave, 0, 0); |
614 window.location.href = image; | 612 window.location.href = image; |
615 } | 613 } |
616 if (config.savePngOutput == "Save") { | 614 if (config.savePngOutput == "Save") { |
617 // document.location.href= ctx.canvas.toDataURL("image/
png").replace("image/png", "image/octet-stream"); | |
618 // ctx.putImageData(cvSave,0,0); | |
619 var image = ctx.canvas.toDataURL(); | 615 var image = ctx.canvas.toDataURL(); |
620 var downloadLink = document.createElement("a"); | 616 var downloadLink = document.createElement("a"); |
621 downloadLink.href = image; | 617 downloadLink.href = image; |
622 downloadLink.download = config.savePngName + ".png"; | 618 downloadLink.download = config.savePngName + ".png"; |
623 document.body.appendChild(downloadLink); | 619 document.body.appendChild(downloadLink); |
624 downloadLink.click(); | 620 downloadLink.click(); |
625 document.body.removeChild(downloadLink); | 621 document.body.removeChild(downloadLink); |
626 } | 622 } |
627 }; | 623 }; |
628 //if (isIE() < 9 && isIE() != false) { | |
629 if (typeof String.prototype.trim !== 'function') { | 624 if (typeof String.prototype.trim !== 'function') { |
630 String.prototype.trim = function() { | 625 String.prototype.trim = function() { |
631 return this.replace(/^\s+|\s+$/g, ''); | 626 return this.replace(/^\s+|\s+$/g, ''); |
632 } | 627 } |
633 }; | 628 }; |
634 //}; | |
635 var dynamicDisplay = new Array(); | 629 var dynamicDisplay = new Array(); |
636 var dynamicDisplayList = new Array(); | 630 var dynamicDisplayList = new Array(); |
637 | 631 |
638 function dynamicFunction(data, config, ctx) { | 632 function dynamicFunction(data, config, ctx) { |
639 | 633 |
| 634 if (isIE() < 9 && isIE() != false) return(true); |
| 635 |
| 636 |
640 if (config.dynamicDisplay) { | 637 if (config.dynamicDisplay) { |
641 if (ctx.canvas.id == "") { | 638 if (ctx.canvas.id == "") { |
642 var cvdate = new Date(); | 639 var cvdate = new Date(); |
643 var cvmillsec = cvdate.getTime(); | 640 var cvmillsec = cvdate.getTime(); |
644 ctx.canvas.id = "Canvas_" + cvmillsec; | 641 ctx.canvas.id = "Canvas_" + cvmillsec; |
645 } | 642 } |
646 if (typeof(dynamicDisplay[ctx.canvas.id]) == "undefined") { | 643 if (typeof(dynamicDisplay[ctx.canvas.id]) == "undefined") { |
647 dynamicDisplayList[dynamicDisplayList["length"]] = ctx.c
anvas.id; | 644 dynamicDisplayList[dynamicDisplayList["length"]] = ctx.c
anvas.id; |
648 dynamicDisplay[ctx.canvas.id] = [ctx, false, false, data
, config, ctx.canvas]; | 645 dynamicDisplay[ctx.canvas.id] = [ctx, false, false, data
, config, ctx.canvas]; |
649 dynamicDisplay[ctx.canvas.id][1] = isScrolledIntoView(ct
x.canvas); | 646 dynamicDisplay[ctx.canvas.id][1] = isScrolledIntoView(ct
x.canvas); |
650 window.onscroll = scrollFunction; | 647 window.onscroll = scrollFunction; |
651 } else if (dynamicDisplay[ctx.canvas.id][2] == false) { | 648 } else if (dynamicDisplay[ctx.canvas.id][2] == false) { |
652 dynamicDisplay[ctx.canvas.id][1] = isScrolledIntoView(ct
x.canvas); | 649 dynamicDisplay[ctx.canvas.id][1] = isScrolledIntoView(ct
x.canvas); |
653 } | 650 } |
654 // if (dynamicDisplay[ctx.canvas.id][1] == false || dynamicDisplay[
ctx.canvas.id][2] == true) { | |
655 if (dynamicDisplay[ctx.canvas.id][1] == false && dynamicDisplay[
ctx.canvas.id][2] == false) { | 651 if (dynamicDisplay[ctx.canvas.id][1] == false && dynamicDisplay[
ctx.canvas.id][2] == false) { |
656 return false; | 652 return false; |
657 } | 653 } |
658 dynamicDisplay[ctx.canvas.id][2] = true; | 654 dynamicDisplay[ctx.canvas.id][2] = true; |
659 } | 655 } |
660 return true; | 656 return true; |
661 }; | 657 }; |
662 | 658 |
663 function isScrolledIntoView(element) { | 659 function isScrolledIntoView(element) { |
664 var xPosition = 0; | 660 var xPosition = 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 annotateDIV.style.color = (config.annotateClassName) ? '' : conf
ig.annotateFontColor; | 710 annotateDIV.style.color = (config.annotateClassName) ? '' : conf
ig.annotateFontColor; |
715 annotateDIV.style.fontFamily = (config.annotateClassName) ? '' :
config.annotateFontFamily; | 711 annotateDIV.style.fontFamily = (config.annotateClassName) ? '' :
config.annotateFontFamily; |
716 annotateDIV.style.fontSize = (config.annotateClassName) ? '' : c
onfig.annotateFontSize + "pt"; | 712 annotateDIV.style.fontSize = (config.annotateClassName) ? '' : c
onfig.annotateFontSize + "pt"; |
717 annotateDIV.style.fontStyle = (config.annotateClassName) ? '' :
config.annotateFontStyle; | 713 annotateDIV.style.fontStyle = (config.annotateClassName) ? '' :
config.annotateFontStyle; |
718 } | 714 } |
719 if (action=="annotate") { | 715 if (action=="annotate") { |
720 show=false; | 716 show=false; |
721 annotateDIV.style.display = show ? '' : 'none'; | 717 annotateDIV.style.display = show ? '' : 'none'; |
722 } | 718 } |
723 canvas_pos = getMousePos(ctx.canvas, event); | 719 canvas_pos = getMousePos(ctx.canvas, event); |
724 » for (i = 0; i < jsGraphAnnotate[ctx.ChartNewId]["length"]; i++) { | 720 » for (var i = 0; i < jsGraphAnnotate[ctx.ChartNewId]["length"]; i++) { |
725 if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "ARC") { | 721 if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "ARC") { |
726 » » » distance = Math.sqrt((canvas_pos.x - jsGraphAnnotate[ctx
.ChartNewId][i][1]) * (canvas_pos.x - jsGraphAnnotate[ctx.ChartNewId][i][1]) + (
canvas_pos.y - jsGraphAnnotate[ctx.ChartNewId][i][2]) * (canvas_pos.y - jsGraphA
nnotate[ctx.ChartNewId][i][2])); | 722 » » » myStatData=jsGraphAnnotate[ctx.ChartNewId][i][3][jsGraph
Annotate[ctx.ChartNewId][i][1]]; |
727 » » » if (distance > jsGraphAnnotate[ctx.ChartNewId][i][3] &&
distance < jsGraphAnnotate[ctx.ChartNewId][i][4]) { | 723 » » » distance = Math.sqrt((canvas_pos.x - myStatData.midPosX)
* (canvas_pos.x - myStatData.midPosX) + (canvas_pos.y - myStatData.midPosY) * (
canvas_pos.y - myStatData.midPosY)); |
728 » » » » angle = Math.acos((canvas_pos.x - jsGraphAnnotat
e[ctx.ChartNewId][i][1]) / distance); | 724 » » » if (distance > myStatData.int_radius && distance < mySta
tData.radiusOffset) { |
729 » » » » if (canvas_pos.y < jsGraphAnnotate[ctx.ChartNewI
d][i][2]) angle = -angle; | 725 » » » » angle = (Math.acos((canvas_pos.x - myStatData.mi
dPosX) / distance) % (2* Math.PI) + 2*Math.PI) % (2*Math.PI); |
730 » » » » while (angle < 0) { | 726 » » » » if (canvas_pos.y < myStatData.midPosY) angle = -
angle; |
731 » » » » » angle += 2 * Math.PI; | 727 » » » » angle = (((angle + 2 * Math.PI) % (2 * Math.PI)
) + 2* Math.PI) % (2* Math.PI) ; |
732 » » » » } | 728 » » » » myStatData.startAngle=(((myStatData.startAngle
+ 2 * Math.PI) % (2 * Math.PI)) + 2* Math.PI) % (2* Math.PI); |
733 » » » » while (angle > 2 * Math.PI) { | 729 » » » » myStatData.endAngle=(((myStatData.endAngle + 2
* Math.PI) % (2 * Math.PI)) + 2* Math.PI) % (2* Math.PI); |
734 » » » » » angle -= 2 * Math.PI; | 730 » » » » if(myStatData.endAngle<myStatData.startAngle)myS
tatData.endAngle+=2 * Math.PI; |
735 » » » » } | 731 » » » » if ((angle > myStatData.startAngle && angle < my
StatData.endAngle) || (angle > myStatData.startAngle - 2 * Math.PI && angle < my
StatData.endAngle - 2 * Math.PI) || (angle > myStatData.startAngle + 2 * Math.PI
&& angle < myStatData.endAngle + 2 * Math.PI)) { |
736 » » » » if (angle < config.startAngle * (Math.PI / 360))
angle += 2 * Math.PI; | 732 » » » » » myStatData.graphPosX = canvas_pos.x; |
737 » » » » if ((angle > jsGraphAnnotate[ctx.ChartNewId][i][
5] && angle < jsGraphAnnotate[ctx.ChartNewId][i][6]) || (angle > jsGraphAnnotate
[ctx.ChartNewId][i][5] - 2 * Math.PI && angle < jsGraphAnnotate[ctx.ChartNewId][
i][6] - 2 * Math.PI) || (angle > jsGraphAnnotate[ctx.ChartNewId][i][5] + 2 * Mat
h.PI && angle < jsGraphAnnotate[ctx.ChartNewId][i][6] + 2 * Math.PI)) { | 733 » » » » » myStatData.graphPosY = canvas_pos.y; |
738 » » » » » v1 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][7], config.fmtV1); // V1=Label | |
739 » » » » » v2 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][8], config.fmtV2); // V2=Data Value | |
740 » » » » » v3 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][9], config.fmtV3); // V3=Cumulated Value | |
741 » » » » » v4 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][10], config.fmtV4); // V4=Total Data Value | |
742 » » » » » v5 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][11], config.fmtV5); // V5=Angle | |
743 » » » » » v6 = fmtChartJS(config, 100 * jsGraphAnn
otate[ctx.ChartNewId][i][8] / jsGraphAnnotate[ctx.ChartNewId][i][10], config.fmt
V6); // v6=Percentage; | |
744 » » » » » v6 = roundToWithThousands(config, v6, co
nfig.roundPct); | |
745 » » » » » v7 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][1], config.fmtV7); // v7=midPointX of arc; | |
746 » » » » » v8 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][2], config.fmtV8); // v8=midPointY of arc; | |
747 » » » » » v9 = fmtChartJS(config, jsGraphAnnotate[
ctx.ChartNewId][i][3], config.fmtV9); // v9=radius Minimum; | |
748 » » » » » v10 = fmtChartJS(config, jsGraphAnnotate
[ctx.ChartNewId][i][4], config.fmtV10); // v10=radius Maximum; | |
749 » » » » » v11 = fmtChartJS(config, jsGraphAnnotate
[ctx.ChartNewId][i][5], config.fmtV11); // v11=start angle; | |
750 » » » » » v12 = fmtChartJS(config, jsGraphAnnotate
[ctx.ChartNewId][i][6], config.fmtV12); // v12=stop angle; | |
751 » » » » » v13 = fmtChartJS(config, jsGraphAnnotate
[ctx.ChartNewId][i][12], config.fmtV13); // v13=position in Data; | |
752 » » » » » graphPosX = canvas_pos.x; | |
753 » » » » » graphPosY = canvas_pos.y; | |
754 onData = true; | 734 onData = true; |
755 if (action == "annotate") { | 735 if (action == "annotate") { |
756 » » » » » » dispString = tmplbis(config.anno
tateLabel, { | 736 » » » » » » dispString = tmplbis(setOptionVa
lue("ANNOTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,con
fig.annotateLabel,jsGraphAnnotate[ctx.ChartNewId][i][12],-1,{otherVal:true}), my
StatData); |
757 » » » » » » » config: config, | |
758 » » » » » » » v1: v1, | |
759 » » » » » » » v2: v2, | |
760 » » » » » » » v3: v3, | |
761 » » » » » » » v4: v4, | |
762 » » » » » » » v5: v5, | |
763 » » » » » » » v6: v6, | |
764 » » » » » » » v7: v7, | |
765 » » » » » » » v8: v8, | |
766 » » » » » » » v9: v9, | |
767 » » » » » » » v10: v10, | |
768 » » » » » » » v11: v11, | |
769 » » » » » » » v12: v12, | |
770 » » » » » » » v13: v13, | |
771 » » » » » » » graphPosX: graphPosX, | |
772 » » » » » » » graphPosY: graphPosY | |
773 » » » » » » }); | |
774 annotateDIV.innerHTML = dispStri
ng; | 737 annotateDIV.innerHTML = dispStri
ng; |
775 show = true; | 738 show = true; |
776 } else { | 739 } else { |
777 » » » » » » funct(event, ctx, config, data,
{ | 740 » » » » » » funct(event, ctx, config, data,
myStatData ); |
778 » » » » » » » v1: v1, | |
779 » » » » » » » v2: v2, | |
780 » » » » » » » v3: v3, | |
781 » » » » » » » v4: v4, | |
782 » » » » » » » v5: v5, | |
783 » » » » » » » v6: v6, | |
784 » » » » » » » v7: v7, | |
785 » » » » » » » v8: v8, | |
786 » » » » » » » v9: v9, | |
787 » » » » » » » v10: v10, | |
788 » » » » » » » v11: v11, | |
789 » » » » » » » v12: v12, | |
790 » » » » » » » v13: v13, | |
791 » » » » » » » graphPosX: graphPosX, | |
792 » » » » » » » graphPosY: graphPosY | |
793 » » » » » » }); | |
794 } | 741 } |
795 if (action == "annotate") { | 742 if (action == "annotate") { |
796 x = bw.ns4 || bw.ns5 ? event.pag
eX : event.x; | 743 x = bw.ns4 || bw.ns5 ? event.pag
eX : event.x; |
797 y = bw.ns4 || bw.ns5 ? event.pag
eY : event.y; | 744 y = bw.ns4 || bw.ns5 ? event.pag
eY : event.y; |
798 if (bw.ie4 || bw.ie5) y = y + ev
al(scrolled); | 745 if (bw.ie4 || bw.ie5) y = y + ev
al(scrolled); |
799 oCursor.moveIt(x + fromLeft, y +
fromTop); | 746 oCursor.moveIt(x + fromLeft, y +
fromTop); |
800 } | 747 } |
801 } | 748 } |
802 } | 749 } |
803 } else if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "RECT") { | 750 } else if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "RECT") { |
804 » » » if (canvas_pos.x > jsGraphAnnotate[ctx.ChartNewId][i][1]
&& canvas_pos.x < jsGraphAnnotate[ctx.ChartNewId][i][3] && canvas_pos.y < jsGra
phAnnotate[ctx.ChartNewId][i][2] && canvas_pos.y > jsGraphAnnotate[ctx.ChartNewI
d][i][4]) { | 751 » » » myStatData=jsGraphAnnotate[ctx.ChartNewId][i][3][jsGraph
Annotate[ctx.ChartNewId][i][1]][jsGraphAnnotate[ctx.ChartNewId][i][2]]; |
805 » » » » v1 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][5], config.fmtV1); // V1=Label1 | 752 » » » |
806 » » » » v2 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][6], config.fmtV2); // V2=Label2 | 753 » » » if (canvas_pos.x > Math.min(myStatData.xPosLeft,myStatDa
ta.xPosRight) && canvas_pos.x < Math.max(myStatData.xPosLeft,myStatData.xPosRigh
t) && canvas_pos.y < Math.max(myStatData.yPosBottom,myStatData.yPosTop) && canva
s_pos.y > Math.min(myStatData.yPosBottom,myStatData.yPosTop)) { |
807 » » » » v3 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][7], config.fmtV3); // V3=Data Value | 754 » » » » myStatData.graphPosX = canvas_pos.x; |
808 » » » » v4 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][8], config.fmtV4); // V4=Cumulated Value | 755 » » » » myStatData.graphPosY = canvas_pos.y; |
809 » » » » v5 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][9], config.fmtV5); // V5=Total Data Value | |
810 » » » » v6 = fmtChartJS(config, 100 * jsGraphAnnotate[ct
x.ChartNewId][i][7] / jsGraphAnnotate[ctx.ChartNewId][i][9], config.fmtV6); // v
6=Percentage; | |
811 » » » » v6 = roundToWithThousands(config, v6, config.rou
ndPct); | |
812 » » » » v7 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][1], config.fmtV7); // v7=top X of rectangle; | |
813 » » » » v8 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][2], config.fmtV8); // v8=top Y of rectangle; | |
814 » » » » v9 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][3], config.fmtV9); // v9=bottom X of rectangle; | |
815 » » » » v10 = fmtChartJS(config, jsGraphAnnotate[ctx.Cha
rtNewId][i][4], config.fmtV10); // v10=bottom Y of rectangle; | |
816 » » » » v11 = fmtChartJS(config, jsGraphAnnotate[ctx.Cha
rtNewId][i][10], config.fmtV11); // v11=position in Dataset; | |
817 » » » » v12 = fmtChartJS(config, jsGraphAnnotate[ctx.Cha
rtNewId][i][11], config.fmtV12); // v12=position in Dataset[v11].Data; | |
818 » » » » graphPosX = canvas_pos.x; | |
819 » » » » graphPosY = canvas_pos.y; | |
820 onData = true; | 756 onData = true; |
821 if (action == "annotate") { | 757 if (action == "annotate") { |
822 » » » » » dispString = tmplbis(config.annotateLabe
l, { | 758 » » » » » dispString = tmplbis(setOptionValue("ANN
OTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.anno
tateLabel,jsGraphAnnotate[ctx.ChartNewId][i][1],jsGraphAnnotate[ctx.ChartNewId][
i][2],{otherVal:true}), myStatData); |
823 » » » » » » config: config, | |
824 » » » » » » v1: v1, | |
825 » » » » » » v2: v2, | |
826 » » » » » » v3: v3, | |
827 » » » » » » v4: v4, | |
828 » » » » » » v5: v5, | |
829 » » » » » » v6: v6, | |
830 » » » » » » v7: v7, | |
831 » » » » » » v8: v8, | |
832 » » » » » » v9: v9, | |
833 » » » » » » v10: v10, | |
834 » » » » » » v11: v11, | |
835 » » » » » » v12: v12, | |
836 » » » » » » graphPosX: graphPosX, | |
837 » » » » » » graphPosY: graphPosY, | |
838 » » » » » » data: data | |
839 » » » » » }); | |
840 annotateDIV.innerHTML = dispString; | 759 annotateDIV.innerHTML = dispString; |
841 show = true; | 760 show = true; |
842 } else { | 761 } else { |
843 » » » » » funct(event, ctx, config, data, { | 762 » » » » » funct(event, ctx, config, data, myStatDa
ta ); |
844 » » » » » » v1: v1, | |
845 » » » » » » v2: v2, | |
846 » » » » » » v3: v3, | |
847 » » » » » » v4: v4, | |
848 » » » » » » v5: v5, | |
849 » » » » » » v6: v6, | |
850 » » » » » » v7: v7, | |
851 » » » » » » v8: v8, | |
852 » » » » » » v9: v9, | |
853 » » » » » » v10: v10, | |
854 » » » » » » v11: v11, | |
855 » » » » » » v12: v12, | |
856 » » » » » » graphPosX: graphPosX, | |
857 » » » » » » graphPosY: graphPosY | |
858 » » » » » }); | |
859 } | 763 } |
860 if (action == "annotate") { | 764 if (action == "annotate") { |
861 x = bw.ns4 || bw.ns5 ? event.pageX : eve
nt.x; | 765 x = bw.ns4 || bw.ns5 ? event.pageX : eve
nt.x; |
862 y = bw.ns4 || bw.ns5 ? event.pageY : eve
nt.y; | 766 y = bw.ns4 || bw.ns5 ? event.pageY : eve
nt.y; |
863 if (bw.ie4 || bw.ie5) y = y + eval(scrol
led); | 767 if (bw.ie4 || bw.ie5) y = y + eval(scrol
led); |
864 oCursor.moveIt(x + fromLeft, y + fromTop
); | 768 oCursor.moveIt(x + fromLeft, y + fromTop
); |
865 } | 769 } |
866 } | 770 } |
867 } else if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "POINT") { | 771 } else if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "POINT") { |
868 » » » distance = Math.sqrt((canvas_pos.x - jsGraphAnnotate[ctx
.ChartNewId][i][1]) * (canvas_pos.x - jsGraphAnnotate[ctx.ChartNewId][i][1]) + (
canvas_pos.y - jsGraphAnnotate[ctx.ChartNewId][i][2]) * (canvas_pos.y - jsGraphA
nnotate[ctx.ChartNewId][i][2])); | 772 » » » myStatData=jsGraphAnnotate[ctx.ChartNewId][i][3][jsGraph
Annotate[ctx.ChartNewId][i][1]][jsGraphAnnotate[ctx.ChartNewId][i][2]]; |
869 » » » if (distance < 10) { | 773 » » » var distance; |
870 » » » » v1 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][3], config.fmtV1); // V1=Label1 | 774 » » » if(config.detectAnnotateOnFullLine) { |
871 » » » » v2 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][4], config.fmtV2); // V2=Label2 | 775 » » » » if(canvas_pos.x < Math.min(myStatData.annotateSt
artPosX,myStatData.annotateEndPosX)-config.pointHitDetectionRadius || canvas_pos
.x > Math.max(myStatData.annotateStartPosX,myStatData.annotateEndPosX)+config.po
intHitDetectionRadius || canvas_pos.y < Math.min(myStatData.annotateStartPosY,my
StatData.annotateEndPosY)-config.pointHitDetectionRadius || canvas_pos.y > Math.
max(myStatData.annotateStartPosY,myStatData.annotateEndPosY)+config.pointHitDete
ctionRadius) { |
872 » » » » v3 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][5], config.fmtV3); // V3=Data Value | 776 » » » » » distance=config.pointHitDetectionRadius+
1; |
873 » » » » v4 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][6], config.fmtV4); // V4=Difference with Previous line | 777 » » » » } else { |
874 » » » » v5 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][7], config.fmtV5); // V5=Difference with next line; | 778 » » » » » if(typeof myStatData.D1A=="undefined") { |
875 » » » » v6 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][8], config.fmtV6); // V6=max; | 779 » » » » » » distance=Math.abs(canvas_pos.x-m
yStatData.posX); |
876 » » » » v7 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][9], config.fmtV7); // V7=Total; | 780 » » » » » } else if(typeof myStatData.D2A=="undefi
ned") { |
877 » » » » v8 = fmtChartJS(config, 100 * jsGraphAnnotate[ct
x.ChartNewId][i][5] / jsGraphAnnotate[ctx.ChartNewId][i][9], config.fmtV8); // v
8=percentage; | 781 » » » » » » distance=Math.abs(canvas_pos.y-m
yStatData.posY); |
878 » » » » v8 = roundToWithThousands(config, v8, config.rou
ndPct); | 782 » » » » » } else { |
879 » » » » v9 = fmtChartJS(config, jsGraphAnnotate[ctx.Char
tNewId][i][1], config.fmtV9); // v9=pos X of point; | 783 » » » » » » var D2B=-myStatData.D2A*canvas_p
os.x+canvas_pos.y; |
880 » » » » v10 = fmtChartJS(config, jsGraphAnnotate[ctx.Cha
rtNewId][i][2], config.fmtV10); // v10=pos Y of point; | 784 » » » » » » var g=-(myStatData.D1B-D2B)/(myS
tatData.D1A-myStatData.D2A); |
881 » » » » v11 = fmtChartJS(config, jsGraphAnnotate[ctx.Cha
rtNewId][i][10], config.fmtV11); // v11=position in Dataset; | 785 » » » » » » var h=myStatData.D2A*g+D2B; |
882 » » » » v12 = fmtChartJS(config, jsGraphAnnotate[ctx.Cha
rtNewId][i][11], config.fmtV12); // v12=position in Dataset[v11].Data; | 786 » » » » » » distance=Math.sqrt((canvas_pos.x
- g) * (canvas_pos.x - g) + (canvas_pos.y - h) * (canvas_pos.y - h)); |
883 » » » » graphPosX = canvas_pos.x; | 787 » » » » » } |
884 » » » » graphPosY = canvas_pos.y; | 788 » » » » » |
| 789 » » » » } |
| 790 » » » » » » » » |
| 791 » » » } else { |
| 792 » » » » distance = Math.sqrt((canvas_pos.x - myStatData.
posX) * (canvas_pos.x - myStatData.posX) + (canvas_pos.y - myStatData.posY) * (c
anvas_pos.y - myStatData.posY)); |
| 793 » » » } |
| 794 » » » if (distance < config.pointHitDetectionRadius) { |
| 795 » » » » myStatData.graphPosX = canvas_pos.x; |
| 796 » » » » myStatData.graphPosY = canvas_pos.y; |
885 onData = true; | 797 onData = true; |
886 if (action == "annotate") { | 798 if (action == "annotate") { |
887 » » » » » dispString = tmplbis(config.annotateLabe
l, { | 799 » » » » » dispString = tmplbis(setOptionValue("ANN
OTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.anno
tateLabel,jsGraphAnnotate[ctx.ChartNewId][i][1],jsGraphAnnotate[ctx.ChartNewId][
i][2],{otherVal:true}), myStatData); |
888 » » » » » » config: config, | |
889 » » » » » » v1: v1, | |
890 » » » » » » v2: v2, | |
891 » » » » » » v3: v3, | |
892 » » » » » » v4: v4, | |
893 » » » » » » v5: v5, | |
894 » » » » » » v6: v6, | |
895 » » » » » » v7: v7, | |
896 » » » » » » v8: v8, | |
897 » » » » » » v9: v9, | |
898 » » » » » » v10: v10, | |
899 » » » » » » v11: v11, | |
900 » » » » » » v12: v12, | |
901 » » » » » » graphPosX: graphPosX, | |
902 » » » » » » graphPosY: graphPosY, | |
903 » » » » » » data: data | |
904 » » » » » }); | |
905 annotateDIV.innerHTML = dispString; | 800 annotateDIV.innerHTML = dispString; |
906 show = true; | 801 show = true; |
907 } else { | 802 } else { |
908 » » » » » funct(event, ctx, config, data, { | 803 » » » » » funct(event, ctx, config, data, myStatDa
ta); |
909 » » » » » » v1: v1, | |
910 » » » » » » v2: v2, | |
911 » » » » » » v3: v3, | |
912 » » » » » » v4: v4, | |
913 » » » » » » v5: v5, | |
914 » » » » » » v6: v6, | |
915 » » » » » » v7: v7, | |
916 » » » » » » v8: v8, | |
917 » » » » » » v9: v9, | |
918 » » » » » » v10: v10, | |
919 » » » » » » v11: v11, | |
920 » » » » » » v12: v12, | |
921 » » » » » » graphPosX: graphPosX, | |
922 » » » » » » graphPosY: graphPosY | |
923 » » » » » }); | |
924 } | 804 } |
925 if (action == "annotate") { | 805 if (action == "annotate") { |
926 x = bw.ns4 || bw.ns5 ? event.pageX : eve
nt.x; | 806 x = bw.ns4 || bw.ns5 ? event.pageX : eve
nt.x; |
927 y = bw.ns4 || bw.ns5 ? event.pageY : eve
nt.y; | 807 y = bw.ns4 || bw.ns5 ? event.pageY : eve
nt.y; |
928 if (bw.ie4 || bw.ie5) y = y + eval(scrol
led); | 808 if (bw.ie4 || bw.ie5) y = y + eval(scrol
led); |
929 oCursor.moveIt(x + fromLeft, y + fromTop
); | 809 oCursor.moveIt(x + fromLeft, y + fromTop
); |
930 } | 810 } |
931 } | 811 } |
932 } | 812 } |
933 if (action == "annotate") { | 813 if (action == "annotate") { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 scaleFontStyle: "normal", | 1015 scaleFontStyle: "normal", |
1136 scaleFontColor: "#666", | 1016 scaleFontColor: "#666", |
1137 scaleShowLabelBackdrop: true, | 1017 scaleShowLabelBackdrop: true, |
1138 scaleBackdropColor: "rgba(255,255,255,0.75)", | 1018 scaleBackdropColor: "rgba(255,255,255,0.75)", |
1139 scaleBackdropPaddingY: 2, | 1019 scaleBackdropPaddingY: 2, |
1140 scaleBackdropPaddingX: 2, | 1020 scaleBackdropPaddingX: 2, |
1141 segmentShowStroke: true, | 1021 segmentShowStroke: true, |
1142 segmentStrokeColor: "#fff", | 1022 segmentStrokeColor: "#fff", |
1143 segmentStrokeWidth: 2, | 1023 segmentStrokeWidth: 2, |
1144 animation: true, | 1024 animation: true, |
| 1025 animationByData : "ByArc", |
1145 animationSteps: 100, | 1026 animationSteps: 100, |
1146 animationEasing: "easeOutBounce", | 1027 animationEasing: "easeOutBounce", |
1147 animateRotate: true, | 1028 animateRotate: true, |
1148 animateScale: false, | 1029 animateScale: false, |
1149 onAnimationComplete: null, | 1030 onAnimationComplete: null, |
1150 annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' +
v6 + ' %)'%>", | 1031 annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' +
v6 + ' %)'%>", |
1151 startAngle: 90 | 1032 startAngle: 90 |
1152 }; | 1033 }; |
1153 chart.PolarArea.defaults = mergeChartConfig(chart.defaults.commo
nOptions, chart.PolarArea.defaults); | 1034 chart.PolarArea.defaults = mergeChartConfig(chart.defaults.commo
nOptions, chart.PolarArea.defaults); |
1154 chart.PolarArea.defaults = mergeChartConfig(chart.PolarArea.defa
ults, charJSPersonalDefaultOptions); | 1035 chart.PolarArea.defaults = mergeChartConfig(chart.PolarArea.defa
ults, charJSPersonalDefaultOptions); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 pointDot: true, | 1081 pointDot: true, |
1201 pointDotRadius: 3, | 1082 pointDotRadius: 3, |
1202 pointDotStrokeWidth: 1, | 1083 pointDotStrokeWidth: 1, |
1203 datasetFill: true, | 1084 datasetFill: true, |
1204 datasetStrokeWidth: 2, | 1085 datasetStrokeWidth: 2, |
1205 animation: true, | 1086 animation: true, |
1206 animationSteps: 60, | 1087 animationSteps: 60, |
1207 animationEasing: "easeOutQuart", | 1088 animationEasing: "easeOutQuart", |
1208 onAnimationComplete: null, | 1089 onAnimationComplete: null, |
1209 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3%>", | 1090 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3%>", |
| 1091 pointHitDetectionRadius : 10, |
1210 startAngle: 90, | 1092 startAngle: 90, |
1211 graphMaximized: false // if true, the graph will not be
centered in the middle of the canvas | 1093 graphMaximized: false // if true, the graph will not be
centered in the middle of the canvas |
1212 }; | 1094 }; |
1213 // merge annotate defaults | 1095 // merge annotate defaults |
1214 chart.Radar.defaults = mergeChartConfig(chart.defaults.commonOpt
ions, chart.Radar.defaults); | 1096 chart.Radar.defaults = mergeChartConfig(chart.defaults.commonOpt
ions, chart.Radar.defaults); |
1215 chart.Radar.defaults = mergeChartConfig(chart.Radar.defaults, ch
arJSPersonalDefaultOptions); | 1097 chart.Radar.defaults = mergeChartConfig(chart.Radar.defaults, ch
arJSPersonalDefaultOptions); |
1216 chart.Radar.defaults = mergeChartConfig(chart.Radar.defaults, ch
arJSPersonalDefaultOptionsRadar); | 1098 chart.Radar.defaults = mergeChartConfig(chart.Radar.defaults, ch
arJSPersonalDefaultOptionsRadar); |
1217 var config = (options) ? mergeChartConfig(chart.Radar.defaults,
options) : chart.Radar.defaults; | 1099 var config = (options) ? mergeChartConfig(chart.Radar.defaults,
options) : chart.Radar.defaults; |
1218 return new Radar(data, config, context); | 1100 return new Radar(data, config, context); |
1219 }; | 1101 }; |
(...skipping 10 matching lines...) Expand all Loading... |
1230 inGraphDataFontSize: 12, | 1112 inGraphDataFontSize: 12, |
1231 inGraphDataFontStyle: "normal", | 1113 inGraphDataFontStyle: "normal", |
1232 inGraphDataFontColor: "#666", | 1114 inGraphDataFontColor: "#666", |
1233 inGraphDataRadiusPosition: 3, | 1115 inGraphDataRadiusPosition: 3, |
1234 inGraphDataAnglePosition: 2, | 1116 inGraphDataAnglePosition: 2, |
1235 inGraphDataMinimumAngle : 0, | 1117 inGraphDataMinimumAngle : 0, |
1236 segmentShowStroke: true, | 1118 segmentShowStroke: true, |
1237 segmentStrokeColor: "#fff", | 1119 segmentStrokeColor: "#fff", |
1238 segmentStrokeWidth: 2, | 1120 segmentStrokeWidth: 2, |
1239 animation: true, | 1121 animation: true, |
| 1122 animationByData : false, |
1240 animationSteps: 100, | 1123 animationSteps: 100, |
1241 animationEasing: "easeOutBounce", | 1124 animationEasing: "easeOutBounce", |
1242 animateRotate: true, | 1125 animateRotate: true, |
1243 animateScale: false, | 1126 animateScale: false, |
1244 onAnimationComplete: null, | 1127 onAnimationComplete: null, |
1245 annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' +
v6 + ' %)'%>", | 1128 annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' +
v6 + ' %)'%>", |
1246 startAngle: 90, | 1129 startAngle: 90, |
1247 radiusScale: 1 | 1130 radiusScale: 1 |
1248 }; | 1131 }; |
1249 // merge annotate defaults | 1132 // merge annotate defaults |
(...skipping 17 matching lines...) Expand all Loading... |
1267 inGraphDataFontStyle: "normal", | 1150 inGraphDataFontStyle: "normal", |
1268 inGraphDataFontColor: "#666", | 1151 inGraphDataFontColor: "#666", |
1269 inGraphDataRadiusPosition: 3, | 1152 inGraphDataRadiusPosition: 3, |
1270 inGraphDataAnglePosition: 2, | 1153 inGraphDataAnglePosition: 2, |
1271 inGraphDataMinimumAngle : 0, | 1154 inGraphDataMinimumAngle : 0, |
1272 segmentShowStroke: true, | 1155 segmentShowStroke: true, |
1273 segmentStrokeColor: "#fff", | 1156 segmentStrokeColor: "#fff", |
1274 segmentStrokeWidth: 2, | 1157 segmentStrokeWidth: 2, |
1275 percentageInnerCutout: 50, | 1158 percentageInnerCutout: 50, |
1276 animation: true, | 1159 animation: true, |
| 1160 animationByData : false, |
1277 animationSteps: 100, | 1161 animationSteps: 100, |
1278 animationEasing: "easeOutBounce", | 1162 animationEasing: "easeOutBounce", |
1279 animateRotate: true, | 1163 animateRotate: true, |
1280 animateScale: false, | 1164 animateScale: false, |
1281 onAnimationComplete: null, | 1165 onAnimationComplete: null, |
1282 annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' +
v6 + ' %)'%>", | 1166 annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' +
v6 + ' %)'%>", |
1283 startAngle: 90, | 1167 startAngle: 90, |
1284 radiusScale: 1 | 1168 radiusScale: 1 |
1285 }; | 1169 }; |
1286 // merge annotate defaults | 1170 // merge annotate defaults |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 showYAxisMin: true, // Show the minimum value on Y axis
(in original version, this minimum is not displayed - it can overlap the X label
s) | 1217 showYAxisMin: true, // Show the minimum value on Y axis
(in original version, this minimum is not displayed - it can overlap the X label
s) |
1334 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; | 1218 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; |
1335 // you can force an integer value between 0 and 180 degr
es | 1219 // you can force an integer value between 0 and 180 degr
es |
1336 logarithmic: false, // can be 'fuzzy',true and false ('f
uzzy' => if the gap between min and maximum is big it's using a logarithmic y-Ax
is scale | 1220 logarithmic: false, // can be 'fuzzy',true and false ('f
uzzy' => if the gap between min and maximum is big it's using a logarithmic y-Ax
is scale |
1337 logarithmic2: false, // can be 'fuzzy',true and false ('
fuzzy' => if the gap between min and maximum is big it's using a logarithmic y-A
xis scale | 1221 logarithmic2: false, // can be 'fuzzy',true and false ('
fuzzy' => if the gap between min and maximum is big it's using a logarithmic y-A
xis scale |
1338 scaleTickSizeLeft: 5, | 1222 scaleTickSizeLeft: 5, |
1339 scaleTickSizeRight: 5, | 1223 scaleTickSizeRight: 5, |
1340 scaleTickSizeBottom: 5, | 1224 scaleTickSizeBottom: 5, |
1341 scaleTickSizeTop: 5, | 1225 scaleTickSizeTop: 5, |
1342 bezierCurve: true, | 1226 bezierCurve: true, |
| 1227 bezierCurveTension : 0.4, |
1343 pointDot: true, | 1228 pointDot: true, |
1344 pointDotRadius: 4, | 1229 pointDotRadius: 4, |
1345 pointDotStrokeWidth: 2, | 1230 pointDotStrokeWidth: 2, |
1346 datasetStrokeWidth: 2, | 1231 datasetStrokeWidth: 2, |
1347 datasetFill: true, | 1232 datasetFill: true, |
1348 animation: true, | 1233 animation: true, |
1349 animationSteps: 60, | 1234 animationSteps: 60, |
1350 animationEasing: "easeOutQuart", | 1235 animationEasing: "easeOutQuart", |
1351 extrapolateMissingData: true, | 1236 extrapolateMissingData: true, |
1352 onAnimationComplete: null, | 1237 onAnimationComplete: null, |
1353 » » » annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3%>" | 1238 » » » annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3%>", |
| 1239 » » » pointHitDetectionRadius : 10 |
1354 }; | 1240 }; |
1355 // merge annotate defaults | 1241 // merge annotate defaults |
1356 chart.Line.defaults = mergeChartConfig(chart.defaults.commonOpti
ons, chart.Line.defaults); | 1242 chart.Line.defaults = mergeChartConfig(chart.defaults.commonOpti
ons, chart.Line.defaults); |
1357 chart.Line.defaults = mergeChartConfig(chart.defaults.xyAxisComm
onOptions, chart.Line.defaults); | 1243 chart.Line.defaults = mergeChartConfig(chart.defaults.xyAxisComm
onOptions, chart.Line.defaults); |
1358 chart.Line.defaults = mergeChartConfig(chart.Line.defaults, char
JSPersonalDefaultOptions); | 1244 chart.Line.defaults = mergeChartConfig(chart.Line.defaults, char
JSPersonalDefaultOptions); |
1359 chart.Line.defaults = mergeChartConfig(chart.Line.defaults, char
JSPersonalDefaultOptionsLine); | 1245 chart.Line.defaults = mergeChartConfig(chart.Line.defaults, char
JSPersonalDefaultOptionsLine); |
1360 var config = (options) ? mergeChartConfig(chart.Line.defaults, o
ptions) : chart.Line.defaults; | 1246 var config = (options) ? mergeChartConfig(chart.Line.defaults, o
ptions) : chart.Line.defaults; |
1361 return new Line(data, config, context); | 1247 return new Line(data, config, context); |
1362 }; | 1248 }; |
1363 this.StackedBar = function(data, options) { | 1249 this.StackedBar = function(data, options) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; | 1285 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; |
1400 // you can force an integer value between 0 and 180 degr
es | 1286 // you can force an integer value between 0 and 180 degr
es |
1401 scaleTickSizeLeft: 5, | 1287 scaleTickSizeLeft: 5, |
1402 scaleTickSizeRight: 5, | 1288 scaleTickSizeRight: 5, |
1403 scaleTickSizeBottom: 5, | 1289 scaleTickSizeBottom: 5, |
1404 scaleTickSizeTop: 5, | 1290 scaleTickSizeTop: 5, |
1405 barShowStroke: true, | 1291 barShowStroke: true, |
1406 barStrokeWidth: 2, | 1292 barStrokeWidth: 2, |
1407 barValueSpacing: 5, | 1293 barValueSpacing: 5, |
1408 barDatasetSpacing: 1, | 1294 barDatasetSpacing: 1, |
| 1295 spaceBetweenBar : 0, |
1409 animation: true, | 1296 animation: true, |
1410 animationSteps: 60, | 1297 animationSteps: 60, |
1411 animationEasing: "easeOutQuart", | 1298 animationEasing: "easeOutQuart", |
1412 onAnimationComplete: null, | 1299 onAnimationComplete: null, |
1413 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + '
(' + v6 + ' %)'%>" | 1300 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + '
(' + v6 + ' %)'%>" |
1414 }; | 1301 }; |
1415 // merge annotate defaults | 1302 // merge annotate defaults |
1416 chart.StackedBar.defaults = mergeChartConfig(chart.defaults.comm
onOptions, chart.StackedBar.defaults); | 1303 chart.StackedBar.defaults = mergeChartConfig(chart.defaults.comm
onOptions, chart.StackedBar.defaults); |
1417 chart.StackedBar.defaults = mergeChartConfig(chart.defaults.xyAx
isCommonOptions, chart.StackedBar.defaults); | 1304 chart.StackedBar.defaults = mergeChartConfig(chart.defaults.xyAx
isCommonOptions, chart.StackedBar.defaults); |
1418 chart.StackedBar.defaults = mergeChartConfig(chart.StackedBar.de
faults, charJSPersonalDefaultOptions); | 1305 chart.StackedBar.defaults = mergeChartConfig(chart.StackedBar.de
faults, charJSPersonalDefaultOptions); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 scaleTickSizeLeft: 5, | 1345 scaleTickSizeLeft: 5, |
1459 scaleTickSizeRight: 5, | 1346 scaleTickSizeRight: 5, |
1460 scaleTickSizeBottom: 5, | 1347 scaleTickSizeBottom: 5, |
1461 scaleTickSizeTop: 5, | 1348 scaleTickSizeTop: 5, |
1462 showYAxisMin: true, // Show the minimum value on Y axis
(in original version, this minimum is not displayed - it can overlap the X label
s) | 1349 showYAxisMin: true, // Show the minimum value on Y axis
(in original version, this minimum is not displayed - it can overlap the X label
s) |
1463 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; | 1350 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; |
1464 barShowStroke: true, | 1351 barShowStroke: true, |
1465 barStrokeWidth: 2, | 1352 barStrokeWidth: 2, |
1466 barValueSpacing: 5, | 1353 barValueSpacing: 5, |
1467 barDatasetSpacing: 1, | 1354 barDatasetSpacing: 1, |
| 1355 spaceBetweenBar : 0, |
1468 animation: true, | 1356 animation: true, |
1469 animationSteps: 60, | 1357 animationSteps: 60, |
1470 animationEasing: "easeOutQuart", | 1358 animationEasing: "easeOutQuart", |
1471 onAnimationComplete: null, | 1359 onAnimationComplete: null, |
1472 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + '
(' + v6 + ' %)'%>", | 1360 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + '
(' + v6 + ' %)'%>", |
1473 reverseOrder: false | 1361 reverseOrder: false |
1474 }; | 1362 }; |
1475 // merge annotate defaults | 1363 // merge annotate defaults |
1476 chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.def
aults.commonOptions, chart.HorizontalStackedBar.defaults); | 1364 chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.def
aults.commonOptions, chart.HorizontalStackedBar.defaults); |
1477 chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.def
aults.xyAxisCommonOptions, chart.HorizontalStackedBar.defaults); | 1365 chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.def
aults.xyAxisCommonOptions, chart.HorizontalStackedBar.defaults); |
(...skipping 16 matching lines...) Expand all Loading... |
1494 inGraphDataFontStyle: "normal", | 1382 inGraphDataFontStyle: "normal", |
1495 inGraphDataFontColor: "#666", | 1383 inGraphDataFontColor: "#666", |
1496 inGraphDataXPosition: 2, | 1384 inGraphDataXPosition: 2, |
1497 inGraphDataYPosition: 3, | 1385 inGraphDataYPosition: 3, |
1498 scaleOverlay: false, | 1386 scaleOverlay: false, |
1499 scaleOverride: false, | 1387 scaleOverride: false, |
1500 scaleOverride2: false, | 1388 scaleOverride2: false, |
1501 scaleSteps: null, | 1389 scaleSteps: null, |
1502 scaleStepWidth: null, | 1390 scaleStepWidth: null, |
1503 scaleStartValue: null, | 1391 scaleStartValue: null, |
| 1392 scaleSteps2: null, |
| 1393 scaleStepWidth2: null, |
| 1394 scaleStartValue2: null, |
1504 scaleLineColor: "rgba(0,0,0,.1)", | 1395 scaleLineColor: "rgba(0,0,0,.1)", |
1505 scaleLineWidth: 1, | 1396 scaleLineWidth: 1, |
1506 scaleShowLabels: true, | 1397 scaleShowLabels: true, |
1507 scaleShowLabels2: true, | 1398 scaleShowLabels2: true, |
1508 scaleLabel: "<%=value%>", | 1399 scaleLabel: "<%=value%>", |
| 1400 scaleLabel2: "<%=value%>", |
1509 scaleFontFamily: "'Arial'", | 1401 scaleFontFamily: "'Arial'", |
1510 scaleFontSize: 12, | 1402 scaleFontSize: 12, |
1511 scaleFontStyle: "normal", | 1403 scaleFontStyle: "normal", |
1512 scaleFontColor: "#666", | 1404 scaleFontColor: "#666", |
1513 scaleShowGridLines: true, | 1405 scaleShowGridLines: true, |
1514 scaleXGridLinesStep: 1, | 1406 scaleXGridLinesStep: 1, |
1515 scaleYGridLinesStep: 1, | 1407 scaleYGridLinesStep: 1, |
1516 scaleGridLineColor: "rgba(0,0,0,.05)", | 1408 scaleGridLineColor: "rgba(0,0,0,.05)", |
1517 scaleGridLineWidth: 1, | 1409 scaleGridLineWidth: 1, |
1518 showYAxisMin: true, // Show the minimum value on Y axis
(in original version, this minimum is not displayed - it can overlap the X label
s) | 1410 showYAxisMin: true, // Show the minimum value on Y axis
(in original version, this minimum is not displayed - it can overlap the X label
s) |
1519 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; | 1411 rotateLabels: "smart", // smart <=> 0 degre if space eno
ugh; otherwise 45 degres if space enough otherwise90 degre; |
1520 // you can force an integer value between 0 and 180 degr
es | 1412 // you can force an integer value between 0 and 180 degr
es |
1521 logarithmic: false, // can be 'fuzzy',true and false ('f
uzzy' => if the gap between min and maximum is big it's using a logarithmic y-Ax
is scale | 1413 logarithmic: false, // can be 'fuzzy',true and false ('f
uzzy' => if the gap between min and maximum is big it's using a logarithmic y-Ax
is scale |
1522 logarithmic2: false, // can be 'fuzzy',true and false ('
fuzzy' => if the gap between min and maximum is big it's using a logarithmic y-A
xis scale | 1414 logarithmic2: false, // can be 'fuzzy',true and false ('
fuzzy' => if the gap between min and maximum is big it's using a logarithmic y-A
xis scale |
1523 scaleTickSizeLeft: 5, | 1415 scaleTickSizeLeft: 5, |
1524 scaleTickSizeRight: 5, | 1416 scaleTickSizeRight: 5, |
1525 scaleTickSizeBottom: 5, | 1417 scaleTickSizeBottom: 5, |
1526 scaleTickSizeTop: 5, | 1418 scaleTickSizeTop: 5, |
1527 barShowStroke: true, | 1419 barShowStroke: true, |
1528 barStrokeWidth: 2, | 1420 barStrokeWidth: 2, |
1529 barValueSpacing: 5, | 1421 barValueSpacing: 5, |
1530 barDatasetSpacing: 1, | 1422 barDatasetSpacing: 1, |
1531 barBorderRadius: 0, | 1423 barBorderRadius: 0, |
| 1424 extrapolateMissingData: true, |
1532 animation: true, | 1425 animation: true, |
1533 animationSteps: 60, | 1426 animationSteps: 60, |
1534 animationEasing: "easeOutQuart", | 1427 animationEasing: "easeOutQuart", |
1535 onAnimationComplete: null, | 1428 onAnimationComplete: null, |
| 1429 pointDot: true, |
| 1430 bezierCurve: true, |
| 1431 bezierCurveTension : 0.4, |
1536 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + '
(' + v6 + ' %)'%>" | 1432 annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2
!='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + '
(' + v6 + ' %)'%>" |
1537 }; | 1433 }; |
1538 // merge annotate defaults | 1434 // merge annotate defaults |
1539 chart.Bar.defaults = mergeChartConfig(chart.defaults.commonOptio
ns, chart.Bar.defaults); | 1435 chart.Bar.defaults = mergeChartConfig(chart.defaults.commonOptio
ns, chart.Bar.defaults); |
1540 chart.Bar.defaults = mergeChartConfig(chart.defaults.xyAxisCommo
nOptions, chart.Bar.defaults); | 1436 chart.Bar.defaults = mergeChartConfig(chart.defaults.xyAxisCommo
nOptions, chart.Bar.defaults); |
1541 chart.Bar.defaults = mergeChartConfig(chart.Bar.defaults, charJS
PersonalDefaultOptions); | 1437 chart.Bar.defaults = mergeChartConfig(chart.Bar.defaults, charJS
PersonalDefaultOptions); |
1542 chart.Bar.defaults = mergeChartConfig(chart.Bar.defaults, charJS
PersonalDefaultOptionsBar); | 1438 chart.Bar.defaults = mergeChartConfig(chart.Bar.defaults, charJS
PersonalDefaultOptionsBar); |
1543 var config = (options) ? mergeChartConfig(chart.Bar.defaults, op
tions) : chart.Bar.defaults; | 1439 var config = (options) ? mergeChartConfig(chart.Bar.defaults, op
tions) : chart.Bar.defaults; |
1544 return new Bar(data, config, context); | 1440 return new Bar(data, config, context); |
1545 }; | 1441 }; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 chart.defaults.commonOptions = { | 1504 chart.defaults.commonOptions = { |
1609 multiGraph: false, | 1505 multiGraph: false, |
1610 clearRect: true, // do not change clearRect options; for interna
l use only | 1506 clearRect: true, // do not change clearRect options; for interna
l use only |
1611 dynamicDisplay: false, | 1507 dynamicDisplay: false, |
1612 graphSpaceBefore: 5, | 1508 graphSpaceBefore: 5, |
1613 graphSpaceAfter: 5, | 1509 graphSpaceAfter: 5, |
1614 canvasBorders: false, | 1510 canvasBorders: false, |
1615 canvasBackgroundColor: "none", | 1511 canvasBackgroundColor: "none", |
1616 canvasBordersWidth: 3, | 1512 canvasBordersWidth: 3, |
1617 canvasBordersColor: "black", | 1513 canvasBordersColor: "black", |
| 1514 zeroValue : 0.0000000001, |
1618 graphTitle: "", | 1515 graphTitle: "", |
1619 graphTitleFontFamily: "'Arial'", | 1516 graphTitleFontFamily: "'Arial'", |
1620 graphTitleFontSize: 24, | 1517 graphTitleFontSize: 24, |
1621 graphTitleFontStyle: "bold", | 1518 graphTitleFontStyle: "bold", |
1622 graphTitleFontColor: "#666", | 1519 graphTitleFontColor: "#666", |
1623 graphTitleSpaceBefore: 5, | 1520 graphTitleSpaceBefore: 5, |
1624 graphTitleSpaceAfter: 5, | 1521 graphTitleSpaceAfter: 5, |
1625 graphSubTitle: "", | 1522 graphSubTitle: "", |
1626 graphSubTitleFontFamily: "'Arial'", | 1523 graphSubTitleFontFamily: "'Arial'", |
1627 graphSubTitleFontSize: 18, | 1524 graphSubTitleFontSize: 18, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 animationStopValue: 1, | 1629 animationStopValue: 1, |
1733 animationCount: 1, | 1630 animationCount: 1, |
1734 animationPauseTime: 5, | 1631 animationPauseTime: 5, |
1735 animationBackward: false, | 1632 animationBackward: false, |
1736 animationStartWithDataset: 1, | 1633 animationStartWithDataset: 1, |
1737 animationStartWithData: 1, | 1634 animationStartWithData: 1, |
1738 animationLeftToRight: false, | 1635 animationLeftToRight: false, |
1739 animationByDataset: false, | 1636 animationByDataset: false, |
1740 defaultStrokeColor: "rgba(220,220,220,1)", | 1637 defaultStrokeColor: "rgba(220,220,220,1)", |
1741 defaultFillColor: "rgba(220,220,220,0.5)", | 1638 defaultFillColor: "rgba(220,220,220,0.5)", |
| 1639 defaultLineWidth : 2, |
1742 mouseDownRight: null, | 1640 mouseDownRight: null, |
1743 mouseDownLeft: null, | 1641 mouseDownLeft: null, |
1744 mouseDownMiddle: null, | 1642 mouseDownMiddle: null, |
1745 mouseMove: null, | 1643 mouseMove: null, |
1746 mouseOut: null, | 1644 mouseOut: null, |
1747 mouseWheel : null, | 1645 mouseWheel : null, |
1748 savePngName: "canvas", | 1646 savePngName: "canvas", |
1749 responsive : false, | 1647 responsive : false, |
1750 » » maintainAspectRatio: true | 1648 » » responsiveMinWidth : 0, |
| 1649 » » responsiveMinHeight : 0, |
| 1650 » » responsiveMaxWidth : 9999999, |
| 1651 » » responsiveMaxHeight : 9999999, |
| 1652 » » maintainAspectRatio: true, |
| 1653 » » pointMarker : "circle" // "circle","cross","plus","diamond","
triangle","square" |
1751 }; | 1654 }; |
1752 chart.defaults.xyAxisCommonOptions = { | 1655 chart.defaults.xyAxisCommonOptions = { |
1753 yAxisMinimumInterval: "none", | 1656 yAxisMinimumInterval: "none", |
1754 yAxisMinimumInterval2: "none", | 1657 yAxisMinimumInterval2: "none", |
1755 yScaleLabelsMinimumWidth: 0, | 1658 yScaleLabelsMinimumWidth: 0, |
1756 xScaleLabelsMinimumWidth: 0, | 1659 xScaleLabelsMinimumWidth: 0, |
1757 yAxisLeft: true, | 1660 yAxisLeft: true, |
1758 yAxisRight: false, | 1661 yAxisRight: false, |
1759 xAxisBottom: true, | 1662 xAxisBottom: true, |
1760 xAxisTop: false, | 1663 xAxisTop: false, |
(...skipping 24 matching lines...) Expand all Loading... |
1785 yAxisUnitFontSize: 8, | 1688 yAxisUnitFontSize: 8, |
1786 yAxisUnitFontStyle: "normal", | 1689 yAxisUnitFontStyle: "normal", |
1787 yAxisUnitFontColor: "#666", | 1690 yAxisUnitFontColor: "#666", |
1788 yAxisUnitSpaceBefore: 5, | 1691 yAxisUnitSpaceBefore: 5, |
1789 yAxisUnitSpaceAfter: 5 | 1692 yAxisUnitSpaceAfter: 5 |
1790 }; | 1693 }; |
1791 var clear = function(c) { | 1694 var clear = function(c) { |
1792 c.clearRect(0, 0, width, height); | 1695 c.clearRect(0, 0, width, height); |
1793 }; | 1696 }; |
1794 | 1697 |
1795 » function setting_new_chart_vars(ctx) { | 1698 » function init_and_start(ctx,data,config) { |
1796 | 1699 |
1797 if (typeof ctx.ChartNewId === typeof undefined) { | 1700 if (typeof ctx.ChartNewId === typeof undefined) { |
1798 ctx.runanimationcompletefunction=true; | 1701 ctx.runanimationcompletefunction=true; |
1799 var cvdate = new Date(); | 1702 var cvdate = new Date(); |
1800 var cvmillsec = cvdate.getTime(); | 1703 var cvmillsec = cvdate.getTime(); |
1801 ctx.ChartNewId = ctx.tpchart + '_' + cvmillsec; | 1704 ctx.ChartNewId = ctx.tpchart + '_' + cvmillsec; |
1802 ctx._eventListeners = {}; | 1705 ctx._eventListeners = {}; |
1803 } | 1706 } |
1804 } | |
1805 | |
1806 var PolarArea = function(data, config, ctx) { | |
1807 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, msr, midPosX, midPosY; | |
1808 | |
1809 ctx.tpchart="PolarArea"; | |
1810 setting_new_chart_vars(ctx); | |
1811 if (!dynamicFunction(data, config, ctx)) { | 1707 if (!dynamicFunction(data, config, ctx)) { |
1812 if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | 1708 if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } |
1813 » » » return; | 1709 » » » return false; |
1814 } | 1710 } |
1815 if(config.responsive && typeof ctx.firstPass == "undefined") { | 1711 if(config.responsive && typeof ctx.firstPass == "undefined") { |
1816 if(!config.multiGraph) { | 1712 if(!config.multiGraph) { |
1817 addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | 1713 addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); |
1818 subUpdateChart(ctx,data,config); | 1714 subUpdateChart(ctx,data,config); |
1819 » » » return; | 1715 » » » return false; |
1820 } else { ctx.firstPass=1; } | 1716 } else { ctx.firstPass=1; } |
1821 } | 1717 } |
1822 | 1718 |
1823 » » var realStartAngle = config.startAngle * (Math.PI / 180) + 2 * M
ath.PI; | 1719 » » if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); |
1824 » » while (config.startAngle < 0) { | 1720 » » else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); |
1825 » » » config.startAngle += 360; | 1721 |
1826 » » } | 1722 » » defMouse(ctx, data, config); |
1827 » » while (config.startAngle > 360) { | 1723 |
1828 » » » config.startAngle -= 360; | 1724 » » setRect(ctx, config); |
1829 » » } | 1725 |
1830 » » while (realStartAngle < 0) { | 1726 » » return true; |
1831 » » » realStartAngle += 2 * Math.PI; | 1727 » } ; |
1832 » » } | 1728 |
1833 » » while (realStartAngle > 2 * Math.PI) { | 1729 » var PolarArea = function(data, config, ctx) { |
1834 » » » realStartAngle -= 2 * Math.PI; | 1730 » » var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, msr, midPosX, midPosY; |
1835 » » } | 1731 » » ctx.tpchart="PolarArea"; |
| 1732 » » |
| 1733 » if (!init_and_start(ctx,data,config)) return; |
| 1734 » » var statData=initPassVariableData_part1(data,config,ctx); |
| 1735 |
| 1736 » » valueBounds = getValueBounds(); |
| 1737 |
1836 config.logarithmic = false; | 1738 config.logarithmic = false; |
1837 config.logarithmic2 = false; | 1739 config.logarithmic2 = false; |
1838 » » if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | 1740 |
1839 » » else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
1840 » » defMouse(ctx, data, config); | |
1841 » » setRect(ctx, config); | |
1842 » » valueBounds = getValueBounds(); | |
1843 //Check and set the scale | 1741 //Check and set the scale |
1844 labelTemplateString = (config.scaleShowLabels) ? config.scaleLab
el : ""; | 1742 labelTemplateString = (config.scaleShowLabels) ? config.scaleLab
el : ""; |
1845 if (!config.scaleOverride) { | 1743 if (!config.scaleOverride) { |
1846 calculatedScale = calculateScale(1, config, valueBounds.
maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minValue, labe
lTemplateString); | 1744 calculatedScale = calculateScale(1, config, valueBounds.
maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minValue, labe
lTemplateString); |
1847 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, false, true, "PolarArea"); | 1745 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, false, true, "PolarArea"); |
1848 } else { | 1746 } else { |
| 1747 var scaleStartValue= setOptionValue("SCALESTARTVALUE",ct
x,data,statData,undefined,config.scaleStartValue,-1,-1,{nullValue : true} ); |
| 1748 var scaleSteps =setOptionValue("SCALESTEPS",ctx,data,sta
tData,undefined,config.scaleSteps,-1,-1,{nullValue : true} ); |
| 1749 var scaleStepWidth = setOptionValue("SCALESTEPWIDTH",ctx
,data,statData,undefined,config.scaleStepWidth,-1,-1,{nullValue : true} ); |
| 1750 |
1849 calculatedScale = { | 1751 calculatedScale = { |
1850 » » » » steps: config.scaleSteps, | 1752 » » » » steps: scaleSteps, |
1851 » » » » stepValue: config.scaleStepWidth, | 1753 » » » » stepValue: scaleStepWidth, |
1852 » » » » graphMin: config.scaleStartValue, | 1754 » » » » graphMin: scaleStartValue, |
1853 » » » » graphMax: config.scaleStartValue + config.scaleS
teps * config.scaleStepWidth, | 1755 » » » » graphMax: scaleStartValue + scaleSteps * scaleSt
epWidth, |
1854 labels: [] | 1756 labels: [] |
1855 } | 1757 } |
1856 » » » populateLabels(1, config, labelTemplateString, calculate
dScale.labels, calculatedScale.steps, config.scaleStartValue, calculatedScale.gr
aphMax, config.scaleStepWidth); | 1758 » » » populateLabels(1, config, labelTemplateString, calculate
dScale.labels, calculatedScale.steps, scaleStartValue, calculatedScale.graphMax,
scaleStepWidth); |
1857 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, false, true, "PolarArea"); | 1759 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, false, true, "PolarArea"); |
1858 } | 1760 } |
| 1761 |
1859 midPosX = msr.leftNotUsableSize + (msr.availableWidth / 2); | 1762 midPosX = msr.leftNotUsableSize + (msr.availableWidth / 2); |
1860 midPosY = msr.topNotUsableSize + (msr.availableHeight / 2); | 1763 midPosY = msr.topNotUsableSize + (msr.availableHeight / 2); |
1861 scaleHop = Math.floor(((Min([msr.availableHeight, msr.availableW
idth]) / 2) - 5) / calculatedScale.steps); | 1764 scaleHop = Math.floor(((Min([msr.availableHeight, msr.availableW
idth]) / 2) - 5) / calculatedScale.steps); |
1862 //Wrap in an animation loop wrapper | 1765 //Wrap in an animation loop wrapper |
1863 if(scaleHop > 0) { | 1766 if(scaleHop > 0) { |
| 1767 initPassVariableData_part2(statData,data,config,ctx,{mid
PosX : midPosX,midPosY : midPosY,int_radius : 0,ext_radius : scaleHop*calculated
Scale.steps, calculatedScale : calculatedScale, scaleHop : scaleHop}); |
1864 animationLoop(config, drawScale, drawAllSegments, ctx, m
sr.clrx, msr.clry, msr.clrwidth, msr.clrheight, midPosX, midPosY, midPosX - ((Mi
n([msr.availableHeight, msr.availableWidth]) / 2) - 5), midPosY + ((Min([msr.ava
ilableHeight, msr.availableWidth]) / 2) - 5), data); | 1768 animationLoop(config, drawScale, drawAllSegments, ctx, m
sr.clrx, msr.clry, msr.clrwidth, msr.clrheight, midPosX, midPosY, midPosX - ((Mi
n([msr.availableHeight, msr.availableWidth]) / 2) - 5), midPosY + ((Min([msr.ava
ilableHeight, msr.availableWidth]) / 2) - 5), data); |
1865 } else { | 1769 } else { |
1866 testRedraw(ctx,data,config); | 1770 testRedraw(ctx,data,config); |
1867 } | 1771 } |
1868 | 1772 |
1869 function drawAllSegments(animationDecimal) { | 1773 function drawAllSegments(animationDecimal) { |
1870 » » » var startAngle = -config.startAngle * (Math.PI / 180) +
2 * Math.PI, | 1774 |
1871 » » » » cumvalue = 0, | 1775 » » » for (var i = 0; i < data.length; i++) { |
1872 » » » » angleStep = 0, | 1776 » » » » var» scaleAnimation = 1, |
1873 » » » » scaleAnimation = 1, | 1777 » » » » » rotateAnimation = 1; |
1874 » » » » rotateAnimation = 1; | 1778 » |
1875 » » » angleStep = 0; | 1779 » » » » if (config.animation) { |
1876 » » » for (var i = 0; i < data.length; i++) | 1780 » » » » » if (config.animateScale) { |
1877 » » » » if (!(typeof(data[i].value) == 'undefined')) ang
leStep++; | 1781 » » » » » » scaleAnimation = animationDecima
l; |
1878 » » » angleStep = (Math.PI * 2) / angleStep; | 1782 » » » » » } |
1879 » » » while (startAngle < 0) { | 1783 » » » » » if (config.animateRotate) { |
1880 » » » » startAngle += 2 * Math.PI; | 1784 » » » » » » rotateAnimation = animationDecim
al; |
1881 » » » } | 1785 » » » » » } |
1882 » » » while (startAngle > 2 * Math.PI) { | |
1883 » » » » startAngle -= 2 * Math.PI; | |
1884 » » » } | |
1885 » » » if (config.animation) { | |
1886 » » » » if (config.animateScale) { | |
1887 » » » » » scaleAnimation = animationDecimal; | |
1888 } | 1786 } |
1889 if (config.animateRotate) { | |
1890 rotateAnimation = animationDecimal; | |
1891 } | |
1892 } | |
1893 if (animationDecimal >= 1) { | |
1894 totvalue = 0; | |
1895 for (var i = 0; i < data.length; i++) | |
1896 if (!(typeof(data[i].value) == 'undefine
d')) totvalue += 1 * data[i].value; | |
1897 } | |
1898 for (var i = 0; i < data.length; i++) { | |
1899 correctedRotateAnimation = animationCorrection(r
otateAnimation, data, config, i, -1, 0).mainVal; | 1787 correctedRotateAnimation = animationCorrection(r
otateAnimation, data, config, i, -1, 0).mainVal; |
1900 if (!(typeof(data[i].value) == 'undefined')) { | 1788 if (!(typeof(data[i].value) == 'undefined')) { |
1901 ctx.beginPath(); | 1789 ctx.beginPath(); |
1902 » » » » » ctx.arc(midPosX, midPosY, scaleAnimation
* calculateOffset(config.logarithmic, 1 * data[i].value, calculatedScale, scale
Hop), startAngle, startAngle + correctedRotateAnimation * angleStep, false); | 1790 » » » » » if(config.animationByData == "ByArc") { |
| 1791 » » » » » » endAngle=statData[i].startAngle+
correctedRotateAnimation*statData[i].segmentAngle; |
| 1792 » » » » » » ctx.arc(midPosX, midPosY, scaleA
nimation * statData[i].radiusOffset, statData[i].startAngle, endAngle, false); |
| 1793 » » » » » } else if(config.animationByData) { |
| 1794 » » » » » » if(statData[i].startAngle-statDa
ta[i].firstAngle < correctedRotateAnimation*2*Math.PI ) { |
| 1795 » » » » » » » endAngle=statData[i].end
Angle; |
| 1796 » » » » » » » if((statData[i].endAngle
-statData[i].firstAngle)> correctedRotateAnimation*2*Math.PI) endAngle=statData[
i].firstAngle+correctedRotateAnimation*2*Math.PI;» » » »
» » » |
| 1797 » » » » » » » ctx.arc(midPosX, midPosY
, scaleAnimation * statData[i].radiusOffset, statData[i].startAngle, endAngle, f
alse); |
| 1798 » » » » » » » |
| 1799 » » » » » » } |
| 1800 » » » » » » else continue; |
| 1801 » » » » » } else { |
| 1802 » » » » » » ctx.arc(midPosX, midPosY, scaleA
nimation * statData[i].radiusOffset, statData[i].firstAngle+correctedRotateAnima
tion * (statData[i].startAngle-statData[i].firstAngle), statData[i].firstAngle+c
orrectedRotateAnimation * (statData[i].endAngle-statData[i].firstAngle)); |
| 1803 » » » » » } |
1903 ctx.lineTo(midPosX, midPosY); | 1804 ctx.lineTo(midPosX, midPosY); |
1904 ctx.closePath(); | 1805 ctx.closePath(); |
1905 » » » » » if (typeof data[i].color == "function")
ctx.fillStyle = data[i].color("COLOR", data, config, i, -1, animationDecimal, da
ta[i].value, "PolarArea", ctx, midPosX, midPosY, 0, scaleAnimation * calculateOf
fset(config.logarithmic, 1 * data[i].value, calculatedScale, scaleHop)); | 1806 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data[i].color,config.defaultFillColor,i,-1,{animationDecimal: ani
mationDecimal, scaleAnimation : scaleAnimation} ); |
1906 » » » » » else ctx.fillStyle = data[i].color; | |
1907 ctx.fill(); | 1807 ctx.fill(); |
1908 startAngle += angleStep; | |
1909 if (config.segmentShowStroke) { | 1808 if (config.segmentShowStroke) { |
1910 ctx.strokeStyle = config.segment
StrokeColor; | 1809 ctx.strokeStyle = config.segment
StrokeColor; |
1911 ctx.lineWidth = config.segmentSt
rokeWidth; | 1810 ctx.lineWidth = config.segmentSt
rokeWidth; |
1912 ctx.stroke(); | 1811 ctx.stroke(); |
1913 } | 1812 } |
1914 } | 1813 } |
1915 } | 1814 } |
1916 » » » if (animationDecimal >= 1) { | 1815 |
1917 » » » » startAngle -= 2*Math.PI; | 1816 |
| 1817 » » » if (animationDecimal >= config.animationStopValue) { |
1918 for (var i = 0; i < data.length; i++) { | 1818 for (var i = 0; i < data.length; i++) { |
1919 if (!(typeof(data[i].value) == 'undefine
d')) { | 1819 if (typeof(data[i].value) == 'undefined'
) continue; |
1920 cumvalue += 1 * data[i].value; | 1820 if (setOptionValue("ANNOTATEDISPLAY",ctx
,data,statData,undefined,config.annotateDisplay,i,-1,{nullValue : true})) { |
1921 startAngle += angleStep; | 1821 jsGraphAnnotate[ctx.ChartNewId][
jsGraphAnnotate[ctx.ChartNewId].length] = ["ARC", i, -1,statData]; |
1922 if (typeof(data[i].title) == "st
ring") lgtxt = data[i].title.trim(); | 1822 } |
1923 else lgtxt = ""; | 1823 if (setOptionValue("INGRAPHDATASHOW",ctx
,data,statData,undefined,config.inGraphDataShow,i,-1,{nullValue : true})) { |
1924 jsGraphAnnotate[ctx.ChartNewId][
jsGraphAnnotate[ctx.ChartNewId].length] = ["ARC", midPosX, midPosY, 0, calculate
Offset(config.logarithmic, 1 * data[i].value, calculatedScale, scaleHop), startA
ngle - angleStep, startAngle, lgtxt, 1 * data[i].value, cumvalue, totvalue, angl
eStep, i]; | 1824 if (setOptionValue("INGRAPHDATAA
NGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{
nullValue : true} ) == 1) posAngle = statData[i].realStartAngle + setOptionValue
("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingA
ngle,i,-1,{nullValue: true }) * (Math.PI / 180); |
1925 if (config.inGraphDataShow) { | 1825 else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 2) posAngle = (2*statData[i].realStartAngle - statDa
ta[i].segmentAngle) / 2 + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statD
ata,undefined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.P
I / 180); |
1926 if (config.inGraphDataAn
glePosition == 1) posAngle = realStartAngle + config.inGraphDataPaddingAngle * (
Math.PI / 180); | 1826 else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 3) posAngle = statData[i].realStartAngle - statData[
i].segmentAngle + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,unde
fined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180)
; |
1927 else if (config.inGraphD
ataAnglePosition == 2) posAngle = realStartAngle - angleStep / 2 + config.inGrap
hDataPaddingAngle * (Math.PI / 180); | 1827 if (setOptionValue("INGRAPHDATAR
ADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition,i,-1
,{nullValue : true} ) == 1) labelRadius = 0 + setOptionValue("INGRAPHDATAPADDING
RADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadius,i,-1,{nullVa
lue: true} ); |
1928 else if (config.inGraphD
ataAnglePosition == 3) posAngle = realStartAngle - angleStep + config.inGraphDat
aPaddingAngle * (Math.PI / 180); | 1828 else if (setOptionValue("INGRAPH
DATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition
,i,-1,{nullValue : true} ) == 2) labelRadius = statData[i].radiusOffset / 2 + se
tOptionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGra
phDataPaddingRadius,i,-1,{nullValue: true} ); |
1929 if (config.inGraphDataRa
diusPosition == 1) labelRadius = 0 + config.inGraphDataPaddingRadius; | 1829 else if (setOptionValue("INGRAPH
DATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition
,i,-1,{nullValue : true} ) == 3) labelRadius = statData[i].radiusOffset + setOpt
ionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDa
taPaddingRadius,i,-1,{nullValue: true} ); |
1930 else if (config.inGraphD
ataRadiusPosition == 2) labelRadius = calculateOffset(config.logarithmic, 1 * da
ta[i].value, calculatedScale, scaleHop) / 2 + config.inGraphDataPaddingRadius; | 1830 else if (setOptionValue("INGRAPH
DATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition
,i,-1,{nullValue : true} ) == 4) labelRadius = scaleHop * calculatedScale.steps
+ setOptionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.i
nGraphDataPaddingRadius,i,-1,{nullValue: true} ); |
1931 else if (config.inGraphD
ataRadiusPosition == 3) labelRadius = calculateOffset(config.logarithmic, 1 * da
ta[i].value, calculatedScale, scaleHop) + config.inGraphDataPaddingRadius; | 1831 ctx.save() |
1932 else if (config.inGraphD
ataRadiusPosition == 4) labelRadius = scaleHop * calculatedScale.steps + config.
inGraphDataPaddingRadius; | 1832 if (setOptionValue("INGRAPHDATAA
LIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{nullValue: true
}) == "off-center") { |
1933 ctx.save() | 1833 if (setOptionValue("INGR
APHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullVa
lue : true} ) == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3
* Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.tex
tAlign = "left"; |
1934 if (config.inGraphDataAl
ign == "off-center") { | 1834 else ctx.textAlign = "ri
ght"; |
1935 if (config.inGra
phDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 *
Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.text
Align = "left"; | 1835 } else if (setOptionValue("INGRA
PHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{nullValue
: true }) == "to-center") { |
1936 else ctx.textAli
gn = "right"; | 1836 if (setOptionValue("INGR
APHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullVa
lue : true} ) == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3
* Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.tex
tAlign = "right"; |
1937 } else if (config.inGrap
hDataAlign == "to-center") { | 1837 else ctx.textAlign = "le
ft"; |
1938 if (config.inGra
phDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 *
Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.text
Align = "right"; | 1838 } else ctx.textAlign = setOption
Value("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-
1,{nullValue: true }); |
1939 else ctx.textAli
gn = "left"; | 1839 if (setOptionValue("INGRAPHDATAV
ALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullValue : tr
ue} ) == "off-center") { |
1940 } else ctx.textAlign = c
onfig.inGraphDataAlign; | 1840 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "top"; |
1941 if (config.inGraphDataVA
lign == "off-center") { | 1841 else ctx.textBaseline =
"bottom"; |
1942 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "top"; | 1842 } else if (setOptionValue("INGRA
PHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullVal
ue : true} ) == "to-center") { |
1943 else ctx.textBas
eline = "bottom"; | 1843 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "bottom"; |
1944 } else if (config.inGrap
hDataVAlign == "to-center") { | 1844 else ctx.textBaseline =
"top"; |
1945 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "bottom"; | 1845 } else ctx.textBaseline = setOpt
ionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlig
n,i,-1,{nullValue : true} ); |
1946 else ctx.textBas
eline = "top"; | 1846 ctx.font = setOptionValue("INGRA
PHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{n
ullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statDat
a,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px ' + setOp
tionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphData
FontFamily,i,-1,{nullValue : true} ); |
1947 } else ctx.textBaseline
= config.inGraphDataVAlign; | 1847 ctx.fillStyle = setOptionValue("
INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,
-1,{nullValue : true} ); |
1948 ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 1848 var dispString = tmplbis(setOpti
onValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-
1,{nullValue : true} ), statData[i]); |
1949 ctx.fillStyle = config.i
nGraphDataFontColor; | 1849 ctx.translate(midPosX + labelRad
ius * Math.cos(posAngle), midPosY - labelRadius * Math.sin(posAngle)); |
1950 var dispString = tmplbis
(config.inGraphDataTmpl, { | 1850 if (setOptionValue("INGRAPHDATAR
OTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : tr
ue} ) == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle); |
1951 config: config, | 1851 else if (setOptionValue("INGRAPH
DATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue
: true} ) == "inRadiusAxisRotateLabels") { |
1952 v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | 1852 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Math.PI) <
3 * Math.PI / 2) ctx.rotate(3 * Math.PI - posAngle); |
1953 v2: fmtChartJS(c
onfig, 1 * data[i].value, config.fmtV2), | 1853 else ctx.rotate(2 * Math
.PI - posAngle); |
1954 v3: fmtChartJS(c
onfig, cumvalue, config.fmtV3), | 1854 } else ctx.rotate(setOptionValue
("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{
nullValue : true} ) * (Math.PI / 180)); |
1955 v4: fmtChartJS(c
onfig, totvalue, config.fmtV4), | 1855 ctx.fillTextMultiLine(dispString
, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData
,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ), true); |
1956 v5: fmtChartJS(c
onfig, angleStep, config.fmtV5), | 1856 ctx.restore(); |
1957 v6: roundToWithT
housands(config, fmtChartJS(config, 100 * data[i].value / totvalue, config.fmtV6
), config.roundPct), | |
1958 v7: fmtChartJS(c
onfig, midPosX, config.fmtV7), | |
1959 v8: fmtChartJS(c
onfig, midPosY, config.fmtV8), | |
1960 v9: fmtChartJS(c
onfig, 0, config.fmtV9), | |
1961 v10: fmtChartJS(
config, calculateOffset(config.logarithmic, 1 * data[i].value, calculatedScale,
scaleHop), config.fmtV10), | |
1962 v11: fmtChartJS(
config, startAngle - angleStep, config.fmtV11), | |
1963 v12: fmtChartJS(
config, angleStep, config.fmtV12), | |
1964 v13: fmtChartJS(
config, i, config.fmtV13), | |
1965 data: data | |
1966 }); | |
1967 ctx.translate(midPosX +
labelRadius * Math.cos(posAngle), midPosY - labelRadius * Math.sin(posAngle)); | |
1968 if (config.inGraphDataRo
tate == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle); | |
1969 else if (config.inGraphD
ataRotate == "inRadiusAxisRotateLabels") { | |
1970 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Ma
th.PI) < 3 * Math.PI / 2) ctx.rotate(3 * Math.PI - posAngle); | |
1971 else ctx.rotate(
2 * Math.PI - posAngle); | |
1972 } else ctx.rotate(config
.inGraphDataRotate * (Math.PI / 180)); | |
1973 ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | |
1974 ctx.restore(); | |
1975 } | |
1976 realStartAngle -= angleStep; | |
1977 } | 1857 } |
1978 } | 1858 } |
1979 } | 1859 } |
1980 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"PolarArea"); | 1860 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"PolarArea"); |
1981 }; | 1861 }; |
1982 | 1862 |
1983 function drawScale() { | 1863 function drawScale() { |
1984 for (var i = 0; i < calculatedScale.steps; i++) { | 1864 for (var i = 0; i < calculatedScale.steps; i++) { |
1985 //If the line object is there | |
1986 if (config.scaleShowLine) { | 1865 if (config.scaleShowLine) { |
1987 ctx.beginPath(); | 1866 ctx.beginPath(); |
1988 ctx.arc(midPosX, midPosY, scaleHop * (i
+ 1), 0, (Math.PI * 2), true); | 1867 ctx.arc(midPosX, midPosY, scaleHop * (i
+ 1), 0, (Math.PI * 2), true); |
1989 ctx.strokeStyle = config.scaleLineColor; | 1868 ctx.strokeStyle = config.scaleLineColor; |
1990 ctx.lineWidth = config.scaleLineWidth; | 1869 ctx.lineWidth = config.scaleLineWidth; |
1991 ctx.stroke(); | 1870 ctx.stroke(); |
1992 } | 1871 } |
1993 if (config.scaleShowLabels) { | 1872 if (config.scaleShowLabels) { |
1994 ctx.textAlign = "center"; | 1873 ctx.textAlign = "center"; |
1995 ctx.font = config.scaleFontStyle + " " +
config.scaleFontSize + "px " + config.scaleFontFamily; | 1874 ctx.font = config.scaleFontStyle + " " +
config.scaleFontSize + "px " + config.scaleFontFamily; |
1996 var label = calculatedScale.labels[i + 1
]; | 1875 var label = calculatedScale.labels[i + 1
]; |
1997 //If the backdrop object is within the f
ont object | |
1998 if (config.scaleShowLabelBackdrop) { | 1876 if (config.scaleShowLabelBackdrop) { |
1999 var textWidth = ctx.measureTextM
ultiLine(label, config.scaleFontSize).textWidth; | 1877 var textWidth = ctx.measureTextM
ultiLine(label, config.scaleFontSize).textWidth; |
2000 ctx.fillStyle = config.scaleBack
dropColor; | 1878 ctx.fillStyle = config.scaleBack
dropColor; |
2001 ctx.beginPath(); | 1879 ctx.beginPath(); |
2002 ctx.rect( | 1880 ctx.rect( |
2003 Math.round(midPosX - tex
tWidth / 2 - config.scaleBackdropPaddingX), //X | 1881 Math.round(midPosX - tex
tWidth / 2 - config.scaleBackdropPaddingX), //X |
2004 Math.round(midPosY - (sc
aleHop * (i + 1)) - config.scaleFontSize * 0.5 - config.scaleBackdropPaddingY),
//Y | 1882 Math.round(midPosY - (sc
aleHop * (i + 1)) - config.scaleFontSize * 0.5 - config.scaleBackdropPaddingY),
//Y |
2005 Math.round(textWidth + (
config.scaleBackdropPaddingX * 2)), //Width | 1883 Math.round(textWidth + (
config.scaleBackdropPaddingX * 2)), //Width |
2006 Math.round(config.scaleF
ontSize + (config.scaleBackdropPaddingY * 2)) //Height | 1884 Math.round(config.scaleF
ontSize + (config.scaleBackdropPaddingY * 2)) //Height |
2007 ); | 1885 ); |
2008 ctx.fill(); | 1886 ctx.fill(); |
2009 } | 1887 } |
2010 ctx.textBaseline = "middle"; | 1888 ctx.textBaseline = "middle"; |
2011 ctx.fillStyle = config.scaleFontColor; | 1889 ctx.fillStyle = config.scaleFontColor; |
2012 » » » » » ctx.fillTextMultiLine(label, midPosX, mi
dPosY - (scaleHop * (i + 1)), ctx.textBaseline, config.scaleFontSize); | 1890 » » » » » ctx.fillTextMultiLine(label, midPosX, mi
dPosY - (scaleHop * (i + 1)), ctx.textBaseline, config.scaleFontSize,true); |
2013 } | 1891 } |
2014 } | 1892 } |
2015 }; | 1893 }; |
2016 | 1894 |
2017 function getValueBounds() { | 1895 function getValueBounds() { |
2018 » » » var upperValue = Number.MIN_VALUE; | 1896 » » » var upperValue = -Number.MAX_VALUE; |
2019 var lowerValue = Number.MAX_VALUE; | 1897 var lowerValue = Number.MAX_VALUE; |
2020 for (var i = 0; i < data.length; i++) { | 1898 for (var i = 0; i < data.length; i++) { |
| 1899 if(typeof data[i].value == "undefined") continue
; |
2021 if (1 * data[i].value > upperValue) { | 1900 if (1 * data[i].value > upperValue) { |
2022 upperValue = 1 * data[i].value; | 1901 upperValue = 1 * data[i].value; |
2023 } | 1902 } |
2024 if (1 * data[i].value < lowerValue) { | 1903 if (1 * data[i].value < lowerValue) { |
2025 lowerValue = 1 * data[i].value; | 1904 lowerValue = 1 * data[i].value; |
2026 } | 1905 } |
2027 }; | 1906 }; |
2028 » » » if (Math.abs(upperValue - lowerValue) < 0.00000001) { | 1907 » » » if(upperValue<lowerValue){upperValue=0;lowerValue=0;} |
2029 » » » » upperValue = Max([upperValue * 2, 1]); | 1908 » » » if (Math.abs(upperValue - lowerValue) < config.zeroValue
) { |
2030 » » » » lowerValue = 0; | 1909 » » » » if(Math.abs(upperValue)< config.zeroValue) upper
Value = .9; |
| 1910 » » » » if(upperValue>0) { |
| 1911 » » » » » upperValue=upperValue*1.1; |
| 1912 » » » » » lowerValue=lowerValue*0.9; |
| 1913 » » » » } else { |
| 1914 » » » » » upperValue=upperValue*0.9; |
| 1915 » » » » » lowerValue=lowerValue*1.1; |
| 1916 » » » » } |
2031 } | 1917 } |
2032 » » » if (!isNaN(config.graphMin)) lowerValue = config.graphMi
n; | 1918 » » » if(typeof config.graphMin=="function") lowerValue= setOp
tionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin,-1,-1,{nullValu
e : true}) |
2033 » » » if (!isNaN(config.graphMax)) upperValue = config.graphMa
x; | 1919 » » » else if (!isNaN(config.graphMin)) lowerValue = config.gr
aphMin; |
| 1920 » » » if(typeof config.graphMax=="function") upperValue= setOp
tionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax,-1,-1,{nullValu
e : true}) |
| 1921 » » » else if (!isNaN(config.graphMax)) upperValue = config.gr
aphMax; |
2034 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); | 1922 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); |
2035 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); | 1923 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); |
2036 return { | 1924 return { |
2037 maxValue: upperValue, | 1925 maxValue: upperValue, |
2038 minValue: lowerValue, | 1926 minValue: lowerValue, |
2039 maxSteps: maxSteps, | 1927 maxSteps: maxSteps, |
2040 minSteps: minSteps | 1928 minSteps: minSteps |
2041 }; | 1929 }; |
2042 }; | 1930 }; |
2043 }; | 1931 }; |
2044 var Radar = function(data, config, ctx) { | 1932 var Radar = function(data, config, ctx) { |
2045 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, msr, midPosX, midPosY; | 1933 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, msr, midPosX, midPosY; |
2046 | 1934 |
2047 ctx.tpchart="Radar"; | 1935 ctx.tpchart="Radar"; |
2048 » » setting_new_chart_vars(ctx); | 1936 » if (!init_and_start(ctx,data,config)) return; |
2049 » » if (!dynamicFunction(data, config, ctx)) { | 1937 » » var statData=initPassVariableData_part1(data,config,ctx); |
2050 » » if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | |
2051 » » » return; | |
2052 » » } | |
2053 » if(config.responsive && typeof ctx.firstPass == "undefined") { | |
2054 » » if(!config.multiGraph) { | |
2055 » » » » addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
2056 » » » subUpdateChart(ctx,data,config); | |
2057 » » » return; | |
2058 » » } else { ctx.firstPass=1; } | |
2059 » » } | |
2060 | 1938 |
2061 » » while (config.startAngle < 0) { | 1939 » » valueBounds = getValueBounds(); |
2062 » » » config.startAngle += 360; | 1940 |
2063 » » } | |
2064 » » while (config.startAngle > 360) { | |
2065 » » » config.startAngle -= 360; | |
2066 » » } | |
2067 config.logarithmic = false; | 1941 config.logarithmic = false; |
2068 config.logarithmic2 = false; | 1942 config.logarithmic2 = false; |
2069 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
2070 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
2071 defMouse(ctx, data, config); | |
2072 //If no labels are defined set to an empty array, so referencing
length for looping doesn't blow up. | 1943 //If no labels are defined set to an empty array, so referencing
length for looping doesn't blow up. |
2073 if (!data.labels) data.labels = []; | 1944 if (!data.labels) data.labels = []; |
2074 setRect(ctx, config); | |
2075 valueBounds = getValueBounds(); | |
2076 //Check and set the scale | 1945 //Check and set the scale |
2077 labelTemplateString = (config.scaleShowLabels) ? config.scaleLab
el : ""; | 1946 labelTemplateString = (config.scaleShowLabels) ? config.scaleLab
el : ""; |
2078 if (!config.scaleOverride) { | 1947 if (!config.scaleOverride) { |
2079 calculatedScale = calculateScale(1, config, valueBounds.
maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minValue, labe
lTemplateString); | 1948 calculatedScale = calculateScale(1, config, valueBounds.
maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minValue, labe
lTemplateString); |
2080 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, true, config.datasetFill, "Radar")
; | 1949 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, true, config.datasetFill, "Radar")
; |
2081 } else { | 1950 } else { |
| 1951 var scaleStartValue= setOptionValue("SCALESTARTVALUE",ct
x,data,statData,undefined,config.scaleStartValue,-1,-1,{nullValue : true} ); |
| 1952 var scaleSteps =setOptionValue("SCALESTEPS",ctx,data,sta
tData,undefined,config.scaleSteps,-1,-1,{nullValue : true} ); |
| 1953 var scaleStepWidth = setOptionValue("SCALESTEPWIDTH",ctx
,data,statData,undefined,config.scaleStepWidth,-1,-1,{nullValue : true} ); |
2082 calculatedScale = { | 1954 calculatedScale = { |
2083 » » » » steps: config.scaleSteps, | 1955 » » » » steps: scaleSteps, |
2084 » » » » stepValue: config.scaleStepWidth, | 1956 » » » » stepValue: scaleStepWidth, |
2085 » » » » graphMin: config.scaleStartValue, | 1957 » » » » graphMin: scaleStartValue, |
2086 » » » » graphMax: config.scaleStartValue + config.scaleS
teps * config.scaleStepWidth, | 1958 » » » » graphMax: scaleStartValue + scaleSteps * scaleSt
epWidth, |
2087 labels: [] | 1959 labels: [] |
2088 } | 1960 } |
2089 » » » populateLabels(1, config, labelTemplateString, calculate
dScale.labels, calculatedScale.steps, config.scaleStartValue, calculatedScale.gr
aphMax, config.scaleStepWidth); | 1961 » » » populateLabels(1, config, labelTemplateString, calculate
dScale.labels, calculatedScale.steps, scaleStartValue, calculatedScale.graphMax,
scaleStepWidth); |
2090 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, true, config.datasetFill, "Radar")
; | 1962 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, null, true, false, false, true, config.datasetFill, "Radar")
; |
2091 } | 1963 } |
2092 | 1964 |
2093 | |
2094 calculateDrawingSizes(); | 1965 calculateDrawingSizes(); |
2095 midPosY = msr.topNotUsableSize + (msr.availableHeight / 2); | 1966 midPosY = msr.topNotUsableSize + (msr.availableHeight / 2); |
2096 scaleHop = maxSize / (calculatedScale.steps); | 1967 scaleHop = maxSize / (calculatedScale.steps); |
2097 //Wrap in an animation loop wrapper | 1968 //Wrap in an animation loop wrapper |
| 1969 initPassVariableData_part2(statData,data,config,ctx,{midPosX : m
idPosX, midPosY : midPosY, calculatedScale: calculatedScale, scaleHop: scaleHop,
maxSize:maxSize}); |
2098 animationLoop(config, drawScale, drawAllDataPoints, ctx, msr.clr
x, msr.clry, msr.clrwidth, msr.clrheight, midPosX, midPosY, midPosX - maxSize, m
idPosY + maxSize, data); | 1970 animationLoop(config, drawScale, drawAllDataPoints, ctx, msr.clr
x, msr.clry, msr.clrwidth, msr.clrheight, midPosX, midPosY, midPosX - maxSize, m
idPosY + maxSize, data); |
2099 //Radar specific functions. | 1971 //Radar specific functions. |
2100 function drawAllDataPoints(animationDecimal) { | 1972 function drawAllDataPoints(animationDecimal) { |
2101 var totvalue = new Array(); | |
2102 var maxvalue = new Array(); | |
2103 var lmaxvalue = new Array(); | |
2104 for (var i = 0; i < data.datasets.length; i++) { | |
2105 lmaxvalue[i] = -999999999; | |
2106 for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
2107 totvalue[j] = 0; | |
2108 maxvalue[j] = -999999999; | |
2109 } | |
2110 } | |
2111 for (var i = 0; i < data.datasets.length; i++) { | |
2112 for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
2113 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | |
2114 totvalue[j] += 1 * data.datasets
[i].data[j]; | |
2115 maxvalue[j] = Max([maxvalue[j],
1 * data.datasets[i].data[j]]); | |
2116 lmaxvalue[i] = Max([lmaxvalue[i]
, 1 * data.datasets[i].data[j]]); | |
2117 } | |
2118 } | |
2119 } | |
2120 var rotationDegree = (2 * Math.PI) / data.datasets[0].da
ta.length; | 1973 var rotationDegree = (2 * Math.PI) / data.datasets[0].da
ta.length; |
2121 ctx.save(); | 1974 ctx.save(); |
2122 //We accept multiple data sets for radar charts, so show
loop through each set | 1975 //We accept multiple data sets for radar charts, so show
loop through each set |
2123 for (var i = 0; i < data.datasets.length; i++) { | 1976 for (var i = 0; i < data.datasets.length; i++) { |
2124 if (animationDecimal >= 1) { | |
2125 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
2126 else lgtxt = ""; | |
2127 } | |
2128 var fPt = -1; | 1977 var fPt = -1; |
2129 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 1978 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
2130 var currentAnimPc = animationCorrection(
animationDecimal, data, config, i, j, 1).animVal; | 1979 var currentAnimPc = animationCorrection(
animationDecimal, data, config, i, j, 1).animVal; |
2131 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; | 1980 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; |
2132 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | 1981 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { |
2133 if (fPt == -1) { | 1982 if (fPt == -1) { |
2134 ctx.beginPath(); | 1983 ctx.beginPath(); |
2135 » » » » » » » ctx.moveTo(midPosX + cur
rentAnimPc * (Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) *
calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale,
scaleHop)), midPosY - currentAnimPc * (Math.sin(config.startAngle * Math.PI / 18
0 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].d
ata[j], calculatedScale, scaleHop))); | 1984 » » » » » » » ctx.moveTo(midPosX + cur
rentAnimPc * statData[i][j].offsetX, midPosY - currentAnimPc * statData[i][j].of
fsetY); |
2136 fPt = j; | 1985 fPt = j; |
2137 } else { | 1986 } else { |
2138 » » » » » » » ctx.lineTo(midPosX + cur
rentAnimPc * (Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) *
calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale,
scaleHop)), midPosY - currentAnimPc * (Math.sin(config.startAngle * Math.PI / 18
0 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].d
ata[j], calculatedScale, scaleHop))); | 1987 » » » » » » » ctx.lineTo(midPosX + cur
rentAnimPc * statData[i][j].offsetX, midPosY - currentAnimPc * statData[i][j].of
fsetY); |
2139 » » » » » » } | |
2140 » » » » » » if (animationDecimal >= 1) { | |
2141 » » » » » » » if (i == 0) divprev = 0; | |
2142 » » » » » » » else divprev = data.data
sets[i].data[j] - data.datasets[i - 1].data[j]; | |
2143 » » » » » » » if (i == data.datasets.l
ength - 1) divnext = 0; | |
2144 » » » » » » » else divnext = data.data
sets[i + 1].data[j] - data.datasets[i].data[j]; | |
2145 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | |
2146 » » » » » » » else lgtxt2 = ""; | |
2147 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["POINT", midPosX + Math.cos(c
onfig.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.
logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop), midPosY - Mat
h.sin(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(
config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop), lgtxt,
lgtxt2, 1 * data.datasets[i].data[j], divprev, divnext, maxvalue[j], totvalue[j
], i, j]; | |
2148 } | 1988 } |
2149 } | 1989 } |
2150 } | 1990 } |
2151 ctx.closePath(); | 1991 ctx.closePath(); |
2152 if (config.datasetFill) { | 1992 if (config.datasetFill) { |
2153 » » » » » if (typeof data.datasets[i].fillColor ==
"function") ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", data, confi
g, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPosY, 0, (config.animatio
nLeftToRight ? 1 : currentAnimPc) * (calculateOffset(config.logarithmic, lmaxval
ue[i], calculatedScale, scaleHop))); | 1993 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data.datasets[i].fillColor,config.defaultFillColor,i,-1,{animatio
nValue : currentAnimPc, midPosX : statData[i][0].midPosX, midPosY : statData[i][
0].midPosY, ext_radius : (config.animationLeftToRight ? 1 : currentAnimPc) * (st
atData[i][0].calculated_offset_max)} ); |
2154 » » » » » else if (typeof data.datasets[i].fillCol
or == "string") ctx.fillStyle = data.datasets[i].fillColor; | |
2155 » » » » » else ctx.fillStyle = config.defaultFillC
olor; | |
2156 } else ctx.fillStyle = "rgba(0,0,0,0)"; | 1994 } else ctx.fillStyle = "rgba(0,0,0,0)"; |
2157 » » » » if (typeof data.datasets[i].strokeColor == "func
tion") ctx.strokeStyle = data.datasets[i].strokeColor("STROKECOLOR", data, confi
g, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPosY, 0, (config.animatio
nLeftToRight ? 1 : currentAnimPc) * (calculateOffset(config.logarithmic, lmaxval
ue[i], calculatedScale, scaleHop))); | 1995 |
2158 » » » » else if (typeof data.datasets[i].strokeColor ==
"string") ctx.strokeStyle = data.datasets[i].strokeColor; | 1996 » » » » ctx.strokeStyle=setOptionValue("STROKECOLOR",ctx
,data,statData,data.datasets[i].strokeColor,config.defaultStrokeColor,i,-1,{null
value : null} ); |
2159 » » » » else ctx.strokeStyle = config.defaultStrokeColor
; | 1997 |
2160 ctx.lineWidth = config.datasetStrokeWidth; | 1998 ctx.lineWidth = config.datasetStrokeWidth; |
2161 ctx.fill(); | 1999 ctx.fill(); |
2162 ctx.stroke(); | 2000 ctx.stroke(); |
2163 if (config.pointDot && (!config.animationLeftToR
ight || (config.animationLeftToRight && animationDecimal >= 1))) { | 2001 if (config.pointDot && (!config.animationLeftToR
ight || (config.animationLeftToRight && animationDecimal >= 1))) { |
2164 ctx.beginPath(); | 2002 ctx.beginPath(); |
2165 » » » » » if (typeof data.datasets[i].pointColor =
= "function") ctx.fillStyle = data.datasets[i].pointColor("POINTCOLOR", data, co
nfig, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPosY, 0, (config.anima
tionLeftToRight ? 1 : currentAnimPc) * (calculateOffset(config.logarithmic, lmax
value[i], calculatedScale, scaleHop))); | 2003 » » » » » ctx.fillStyle=setOptionValue("MARKERFILL
COLOR",ctx,data,statData,data.datasets[i].pointColor,config.defaultStrokeColor,i
,-1,{nullvalue: true} ); |
2166 » » » » » else ctx.fillStyle = data.datasets[i].po
intColor; | 2004 » » » » » ctx.strokeStyle=setOptionValue("MARKERST
ROKESTYLE",ctx,data,statData,data.datasets[i].pointStrokeColor,config.defaultStr
okeColor,i,-1,{nullvalue: true} ); |
2167 » » » » » if (typeof data.datasets[i].pointStrokeC
olor == "function") ctx.strokeStyle = data.datasets[i].pointStrokeColor("POINTST
ROKECOLOR", data, config, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPo
sY, 0, (config.animationLeftToRight ? 1 : currentAnimPc) * (calculateOffset(conf
ig.logarithmic, lmaxvalue[i], calculatedScale, scaleHop))); | 2005 » » » » » ctx.lineWidth=setOptionValue("MARKERLINE
WIDTH",ctx,data,statData,data.datasets[i].pointDotStrokeWidth,config.pointDotStr
okeWidth,i,-1,{nullvalue: true} ); |
2168 » » » » » else ctx.strokeStyle = data.datasets[i].
pointStrokeColor; | 2006 |
2169 » » » » » ctx.lineWidth = config.pointDotStrokeWid
th; | |
2170 for (var k = 0; k < data.datasets[i].dat
a.length; k++) { | 2007 for (var k = 0; k < data.datasets[i].dat
a.length; k++) { |
2171 if (!(typeof(data.datasets[i].da
ta[k]) == 'undefined')) { | 2008 if (!(typeof(data.datasets[i].da
ta[k]) == 'undefined')) { |
2172 ctx.beginPath(); | 2009 ctx.beginPath(); |
2173 » » » » » » » ctx.arc(midPosX + curren
tAnimPc * (Math.cos(config.startAngle * Math.PI / 180 - k * rotationDegree) * ca
lculateOffset(config.logarithmic, data.datasets[i].data[k], calculatedScale, sca
leHop)), midPosY - currentAnimPc * (Math.sin(config.startAngle * Math.PI / 180 -
k * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data
[k], calculatedScale, scaleHop)), config.pointDotRadius, 2 * Math.PI, false); | 2010 » » » » » » » var markerShape=setOptio
nValue("MARKERSHAPE",ctx,data,statData,data.datasets[i].markerShape,config.marke
rShape,i,j,{nullvalue: true} ); |
2174 » » » » » » » ctx.fill(); | 2011 » » » » » » » var markerRadius=setOpti
onValue("MARKERRADIUS",ctx,data,statData,data.datasets[i].pointDotRadius,config.
pointDotRadius,i,j,{nullvalue: true} ); |
2175 » » » » » » » ctx.stroke(); | 2012 » » » » » » » drawMarker(ctx,midPosX +
currentAnimPc * statData[i][k].offsetX, midPosY - currentAnimPc * statData[i][k
].offsetY, markerShape,markerRadius);» » » » » »
» |
2176 } | 2013 } |
2177 } | 2014 } |
2178 } | 2015 } |
2179 } | 2016 } |
2180 ctx.restore(); | 2017 ctx.restore(); |
2181 » » » if (animationDecimal >= 1 && config.inGraphDataShow) { | 2018 » » » if (animationDecimal >= config.animationStopValue) { |
2182 for (var i = 0; i < data.datasets.length; i++) { | 2019 for (var i = 0; i < data.datasets.length; i++) { |
2183 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
2184 else lgtxt = ""; | |
2185 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 2020 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
2186 » » » » » » if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { | 2021 » » » » » » if (typeof(data.datasets[i].data
[j]) == 'undefined') continue; |
2187 » » » » » » » if (i == 0) divprev = 0; | 2022 » » » » » » if (setOptionValue("ANNOTATEDISP
LAY",ctx,data,statData,undefined,config.annotateDisplay,i,j,{nullValue : true}))
{ |
2188 » » » » » » » else divprev = data.data
sets[i].data[j] - data.datasets[i - 1].data[j]; | 2023 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["POINT", i,j,statData]; |
2189 » » » » » » » if (i == data.datasets.l
ength - 1) divnext = 0; | 2024 » » » » » » } |
2190 » » » » » » » else divnext = data.data
sets[i + 1].data[j] - data.datasets[i].data[j]; | 2025 » » » » » » if(setOptionValue("INGRAPHDATASH
OW",ctx,data,statData,undefined,config.inGraphDataShow,i,j,{nullValue : true}))
{ |
2191 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | 2026 |
2192 » » » » » » » else lgtxt2 = ""; | 2027 |
2193 ctx.save(); | 2028 ctx.save(); |
2194 » » » » » » » ctx.textAlign = config.i
nGraphDataAlign; | 2029 » » » » » » » ctx.beginPath(); |
2195 » » » » » » » ctx.textBaseline = confi
g.inGraphDataVAlign; | 2030 » » » » » » » ctx.textAlign = setOptio
nValue("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,
-1,{nullValue: true }); |
2196 » » » » » » » if (config.inGraphDataAl
ign == "off-center") { | 2031 » » » » » » » ctx.textBaseline = setOp
tionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAli
gn,i,-1,{nullValue : true} ); |
2197 » » » » » » » » if (config.inGra
phDataRotate == "inRadiusAxis" || (config.startAngle * Math.PI / 180 - j * rotat
ionDegree + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (config.startAngle
* Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) <= Math.PI
/ 2) ctx.textAlign = "left"; | 2032 » » » » » » » if (setOptionValue("INGR
APHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{nullValu
e: true }) == "off-center") { |
| 2033 » » » » » » » » if (setOptionVal
ue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1
,{nullValue : true} ) == "inRadiusAxis" || (config.startAngle * Math.PI / 180 -
j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (config.s
tartAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) <=
Math.PI / 2) ctx.textAlign = "left"; |
2198 else ctx.textAli
gn = "right"; | 2034 else ctx.textAli
gn = "right"; |
2199 » » » » » » » } else if (config.inGrap
hDataAlign == "to-center") { | 2035 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{n
ullValue: true }) == "to-center") { |
2200 » » » » » » » » if (config.inGra
phDataRotate == "inRadiusAxis" || (config.startAngle * Math.PI / 180 - j * rotat
ionDegree + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (config.startAngle
* Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) < Math.PI /
2) ctx.textAlign = "right"; | 2036 » » » » » » » » if (setOptionVal
ue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1
,{nullValue : true} ) == "inRadiusAxis" || (config.startAngle * Math.PI / 180 -
j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (config.s
tartAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) <
Math.PI / 2) ctx.textAlign = "right"; |
2201 else ctx.textAli
gn = "left"; | 2037 else ctx.textAli
gn = "left"; |
2202 » » » » » » » } else ctx.textAlign = c
onfig.inGraphDataAlign; | 2038 » » » » » » » } else ctx.textAlign = s
etOptionValue("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataA
lign,i,-1,{nullValue: true }); |
2203 » » » » » » » if (config.inGraphDataVA
lign == "off-center") { | 2039 » » » » » » » if (setOptionValue("INGR
APHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullVa
lue : true} ) == "off-center") { |
2204 if ((config.star
tAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > Mat
h.PI) ctx.textBaseline = "bottom"; | 2040 if ((config.star
tAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > Mat
h.PI) ctx.textBaseline = "bottom"; |
2205 else ctx.textBas
eline = "top"; | 2041 else ctx.textBas
eline = "top"; |
2206 » » » » » » » } else if (config.inGrap
hDataVAlign == "to-center") { | 2042 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,
{nullValue : true} ) == "to-center") { |
2207 if ((config.star
tAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > Mat
h.PI) ctx.textBaseline = "top"; | 2043 if ((config.star
tAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > Mat
h.PI) ctx.textBaseline = "top"; |
2208 else ctx.textBas
eline = "bottom"; | 2044 else ctx.textBas
eline = "bottom"; |
2209 » » » » » » » } else ctx.textBaseline
= config.inGraphDataVAlign; | 2045 » » » » » » » } else ctx.textBaseline
= setOptionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphD
ataVAlign,i,-1,{nullValue : true} ); |
2210 » » » » » » » ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 2046 » » » » » » » ctx.font = setOptionValu
e("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle
,i,-1,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data
,statData,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px '
+ setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inG
raphDataFontFamily,i,-1,{nullValue : true} ); |
2211 » » » » » » » ctx.fillStyle = config.i
nGraphDataFontColor; | 2047 » » » » » » » ctx.fillStyle = setOptio
nValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFont
Color,i,-1,{nullValue : true} ); |
2212 var radiusPrt; | 2048 var radiusPrt; |
2213 » » » » » » » if (config.inGraphDataRa
diusPosition == 1) radiusPrt = 0 + config.inGraphDataPaddingRadius; | 2049 » » » » » » » if (setOptionValue("INGR
APHDATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosit
ion,i,-1,{nullValue : true} ) == 1) radiusPrt = 0 + setOptionValue("INGRAPHDATAP
ADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadius,i,-1,{
nullValue: true} ); |
2214 » » » » » » » else if (config.inGraphD
ataRadiusPosition == 2) radiusPrt = (calculateOffset(config.logarithmic, data.da
tasets[i].data[j], calculatedScale, scaleHop)) / 2 + config.inGraphDataPaddingRa
dius; | 2050 » » » » » » » else if (setOptionValue(
"INGRAPHDATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadius
Position,i,-1,{nullValue : true} ) == 2) radiusPrt = (statData[i][j].calculated_
offset) / 2 + setOptionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefi
ned,config.inGraphDataPaddingRadius,i,-1,{nullValue: true} ); |
2215 » » » » » » » else if (config.inGraphD
ataRadiusPosition == 3) radiusPrt = (calculateOffset(config.logarithmic, data.da
tasets[i].data[j], calculatedScale, scaleHop)) + config.inGraphDataPaddingRadius
; | 2051 » » » » » » » else if (setOptionValue(
"INGRAPHDATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadius
Position,i,-1,{nullValue : true} ) == 3) radiusPrt = (statData[i][j].calculated_
offset) + setOptionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,
config.inGraphDataPaddingRadius,i,-1,{nullValue: true} ); |
2216 » » » » » » » ctx.translate(midPosX +
Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) * radiusPrt, mi
dPosY - Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegree) * radiu
sPrt); | 2052 » » » » » » » if(statData[i][j].calcul
ated_offset>0) { |
2217 » » » » » » » if (config.inGraphDataRo
tate == "inRadiusAxis") ctx.rotate(j * rotationDegree); | 2053 » » » » » » » » ctx.translate(mi
dPosX + statData[i][j].offsetX * (radiusPrt/statData[i][j].calculated_offset), m
idPosY - statData[i][j].offsetY * (radiusPrt/statData[i][j].calculated_offset)); |
2218 » » » » » » » else if (config.inGraphD
ataRotate == "inRadiusAxisRotateLabels") { | 2054 » » » » » » » } else { |
| 2055 » » » » » » » » ctx.translate(mi
dPosX, midPosY); |
| 2056 » » » » » » » } |
| 2057 » » » » » » » if (setOptionValue("INGR
APHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullVa
lue : true} ) == "inRadiusAxis") ctx.rotate(j * rotationDegree); |
| 2058 » » » » » » » else if (setOptionValue(
"INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{n
ullValue : true} ) == "inRadiusAxisRotateLabels") { |
2219 if ((j * rotatio
nDegree + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (j * rotationDegree + 2
* Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) ctx.rotate(3 * Math.PI + j * rotat
ionDegree); | 2059 if ((j * rotatio
nDegree + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (j * rotationDegree + 2
* Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) ctx.rotate(3 * Math.PI + j * rotat
ionDegree); |
2220 else ctx.rotate(
2 * Math.PI + j * rotationDegree); | 2060 else ctx.rotate(
2 * Math.PI + j * rotationDegree); |
2221 » » » » » » » } else ctx.rotate(config
.inGraphDataRotate * (Math.PI / 180)); | 2061 » » » » » » » } else ctx.rotate(setOpt
ionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotat
e,i,-1,{nullValue : true} ) * (Math.PI / 180)); |
2222 » » » » » » » var dispString = tmplbis
(config.inGraphDataTmpl, { | 2062 » » » » » » » var dispString = tmplbis
(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphData
Tmpl,i,-1,{nullValue : true} ), statData[i][j]); |
2223 » » » » » » » » config: config, | 2063 » » » » » » » ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,
statData,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ),true); |
2224 » » » » » » » » v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | |
2225 » » » » » » » » v2: fmtChartJS(c
onfig, lgtxt2, config.fmtV2), | |
2226 » » » » » » » » v3: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV3), | |
2227 » » » » » » » » v4: fmtChartJS(c
onfig, divprev, config.fmtV4), | |
2228 » » » » » » » » v5: fmtChartJS(c
onfig, divnext, config.fmtV5), | |
2229 » » » » » » » » v6: fmtChartJS(c
onfig, maxvalue[j], config.fmtV6), | |
2230 » » » » » » » » v7: fmtChartJS(c
onfig, totvalue[j], config.fmtV7), | |
2231 » » » » » » » » v8: roundToWithT
housands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[j]
, config.fmtV8), config.roundPct), | |
2232 » » » » » » » » v9: fmtChartJS(c
onfig, midPosX + Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree
) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScal
e, scaleHop), config.fmtV9), | |
2233 » » » » » » » » v10: fmtChartJS(
config, midPosY - Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegre
e) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedSca
le, scaleHop), config.fmtV10), | |
2234 » » » » » » » » v11: fmtChartJS(
config, i, config.fmtV11), | |
2235 » » » » » » » » v12: fmtChartJS(
config, j, config.fmtV12), | |
2236 » » » » » » » » data: data | |
2237 » » » » » » » }); | |
2238 » » » » » » » ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | |
2239 ctx.restore(); | 2064 ctx.restore(); |
2240 } | 2065 } |
2241 } | 2066 } |
2242 } | 2067 } |
2243 } | 2068 } |
2244 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Radar"); | 2069 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Radar"); |
2245 }; | 2070 }; |
2246 | 2071 |
2247 function drawScale() { | 2072 function drawScale() { |
2248 var rotationDegree = (2 * Math.PI) / data.datasets[0].da
ta.length; | 2073 var rotationDegree = (2 * Math.PI) / data.datasets[0].da
ta.length; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 ctx.beginPath(); | 2111 ctx.beginPath(); |
2287 ctx.rect( | 2112 ctx.rect( |
2288 Math.round(Math.cos(conf
ig.startAngle * Math.PI / 180) * (scaleHop * (i + 1)) - textWidth / 2 - config.s
caleBackdropPaddingX), //X | 2113 Math.round(Math.cos(conf
ig.startAngle * Math.PI / 180) * (scaleHop * (i + 1)) - textWidth / 2 - config.s
caleBackdropPaddingX), //X |
2289 Math.round((-Math.sin(co
nfig.startAngle * Math.PI / 180) * scaleHop * (i + 1)) - config.scaleFontSize *
0.5 - config.scaleBackdropPaddingY), //Y | 2114 Math.round((-Math.sin(co
nfig.startAngle * Math.PI / 180) * scaleHop * (i + 1)) - config.scaleFontSize *
0.5 - config.scaleBackdropPaddingY), //Y |
2290 Math.round(textWidth + (
config.scaleBackdropPaddingX * 2)), //Width | 2115 Math.round(textWidth + (
config.scaleBackdropPaddingX * 2)), //Width |
2291 Math.round(config.scaleF
ontSize + (config.scaleBackdropPaddingY * 2)) //Height | 2116 Math.round(config.scaleF
ontSize + (config.scaleBackdropPaddingY * 2)) //Height |
2292 ); | 2117 ); |
2293 ctx.fill(); | 2118 ctx.fill(); |
2294 } | 2119 } |
2295 ctx.fillStyle = config.scaleFontColor; | 2120 ctx.fillStyle = config.scaleFontColor; |
2296 » » » » » ctx.fillTextMultiLine(calculatedScale.la
bels[i + 1], Math.cos(config.startAngle * Math.PI / 180) * (scaleHop * (i + 1)),
-Math.sin(config.startAngle * Math.PI / 180) * scaleHop * (i + 1), ctx.textBase
line, config.scaleFontSize); | 2121 » » » » » ctx.fillTextMultiLine(calculatedScale.la
bels[i + 1], Math.cos(config.startAngle * Math.PI / 180) * (scaleHop * (i + 1)),
-Math.sin(config.startAngle * Math.PI / 180) * scaleHop * (i + 1), ctx.textBase
line, config.scaleFontSize,true); |
2297 } | 2122 } |
2298 } | 2123 } |
2299 for (var k = 0; k < data.labels.length; k++) { | 2124 for (var k = 0; k < data.labels.length; k++) { |
2300 ctx.font = config.pointLabelFontStyle + " " + co
nfig.pointLabelFontSize + "px " + config.pointLabelFontFamily; | 2125 ctx.font = config.pointLabelFontStyle + " " + co
nfig.pointLabelFontSize + "px " + config.pointLabelFontFamily; |
2301 ctx.fillStyle = config.pointLabelFontColor; | 2126 ctx.fillStyle = config.pointLabelFontColor; |
2302 var opposite = Math.sin((90 - config.startAngle)
* Math.PI / 180 + rotationDegree * k) * (maxSize + config.pointLabelFontSize); | 2127 var opposite = Math.sin((90 - config.startAngle)
* Math.PI / 180 + rotationDegree * k) * (maxSize + config.pointLabelFontSize); |
2303 var adjacent = Math.cos((90 - config.startAngle)
* Math.PI / 180 + rotationDegree * k) * (maxSize + config.pointLabelFontSize); | 2128 var adjacent = Math.cos((90 - config.startAngle)
* Math.PI / 180 + rotationDegree * k) * (maxSize + config.pointLabelFontSize); |
2304 var vangle = (90 - config.startAngle) * Math.PI
/ 180 + rotationDegree * k; | 2129 var vangle = (90 - config.startAngle) * Math.PI
/ 180 + rotationDegree * k; |
2305 while (vangle < 0) vangle = vangle + 2 * Math.PI
; | 2130 while (vangle < 0) vangle = vangle + 2 * Math.PI
; |
2306 while (vangle > 2 * Math.PI) vangle = vangle - 2
* Math.PI; | 2131 while (vangle > 2 * Math.PI) vangle = vangle - 2
* Math.PI; |
2307 if (vangle == Math.PI || vangle == 0) { | 2132 if (vangle == Math.PI || vangle == 0) { |
2308 ctx.textAlign = "center"; | 2133 ctx.textAlign = "center"; |
2309 } else if (vangle > Math.PI) { | 2134 } else if (vangle > Math.PI) { |
2310 ctx.textAlign = "right"; | 2135 ctx.textAlign = "right"; |
2311 } else { | 2136 } else { |
2312 ctx.textAlign = "left"; | 2137 ctx.textAlign = "left"; |
2313 } | 2138 } |
2314 ctx.textBaseline = "middle"; | 2139 ctx.textBaseline = "middle"; |
2315 » » » » ctx.fillTextMultiLine(data.labels[k], opposite,
-adjacent, ctx.textBaseline, config.pointLabelFontSize); | 2140 » » » » ctx.fillTextMultiLine(data.labels[k], opposite,
-adjacent, ctx.textBaseline, config.pointLabelFontSize,true); |
2316 } | 2141 } |
2317 ctx.restore(); | 2142 ctx.restore(); |
2318 }; | 2143 }; |
2319 | 2144 |
2320 function calculateDrawingSizes() { | 2145 function calculateDrawingSizes() { |
2321 var midX, mxlb, maxL, maxR, iter, nbiter, prevMaxSize, p
revMidX; | 2146 var midX, mxlb, maxL, maxR, iter, nbiter, prevMaxSize, p
revMidX; |
2322 var rotationDegree = (2 * Math.PI) / data.datasets[0].da
ta.length; | 2147 var rotationDegree = (2 * Math.PI) / data.datasets[0].da
ta.length; |
2323 var rotateAngle = config.startAngle * Math.PI / 180; | 2148 var rotateAngle = config.startAngle * Math.PI / 180; |
2324 // Compute range for Mid Point of graph | 2149 // Compute range for Mid Point of graph |
2325 ctx.font = config.pointLabelFontStyle + " " + config.poi
ntLabelFontSize + "px " + config.pointLabelFontFamily; | 2150 ctx.font = config.pointLabelFontStyle + " " + config.poi
ntLabelFontSize + "px " + config.pointLabelFontFamily; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 prevMaxSize = maxSize; | 2193 prevMaxSize = maxSize; |
2369 midPosX = midX + msr.rightNotUsableSize; | 2194 midPosX = midX + msr.rightNotUsableSize; |
2370 } | 2195 } |
2371 } | 2196 } |
2372 maxSize = prevMaxSize - config.scaleFontSize / 2; | 2197 maxSize = prevMaxSize - config.scaleFontSize / 2; |
2373 //If the label height is less than 5, set it to 5 so we
don't have lines on top of each other. | 2198 //If the label height is less than 5, set it to 5 so we
don't have lines on top of each other. |
2374 labelHeight = Default(labelHeight, 5); | 2199 labelHeight = Default(labelHeight, 5); |
2375 }; | 2200 }; |
2376 | 2201 |
2377 function getValueBounds() { | 2202 function getValueBounds() { |
2378 » » » var upperValue = Number.MIN_VALUE; | 2203 » » » var upperValue = -Number.MAX_VALUE; |
2379 var lowerValue = Number.MAX_VALUE; | 2204 var lowerValue = Number.MAX_VALUE; |
2380 for (var i = 0; i < data.datasets.length; i++) { | 2205 for (var i = 0; i < data.datasets.length; i++) { |
2381 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 2206 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
| 2207 if(typeof data.datasets[i].data[j]=="und
efined")continue; |
2382 if (1 * data.datasets[i].data[j] > upper
Value) { | 2208 if (1 * data.datasets[i].data[j] > upper
Value) { |
2383 upperValue = 1 * data.datasets[i
].data[j] | 2209 upperValue = 1 * data.datasets[i
].data[j] |
2384 } | 2210 } |
2385 if (1 * data.datasets[i].data[j] < lower
Value) { | 2211 if (1 * data.datasets[i].data[j] < lower
Value) { |
2386 lowerValue = 1 * data.datasets[i
].data[j] | 2212 lowerValue = 1 * data.datasets[i
].data[j] |
2387 } | 2213 } |
2388 } | 2214 } |
2389 } | 2215 } |
2390 » » » if (Math.abs(upperValue - lowerValue) < 0.00000001) { | 2216 » » » if(upperValue<lowerValue){upperValue=0;lowerValue=0;} |
2391 » » » » upperValue = Max([upperValue * 2, 1]); | 2217 » » » if (Math.abs(upperValue - lowerValue) < config.zeroValue
) { |
2392 » » » » lowerValue = 0; | 2218 » » » » if(Math.abs(upperValue)< config.zeroValue){ uppe
rValue = .9;lowerValue=-.9;} |
| 2219 » » » » if(upperValue>0) { |
| 2220 » » » » » upperValue=upperValue*1.1; |
| 2221 » » » » » lowerValue=lowerValue*0.9; |
| 2222 » » » » } else { |
| 2223 » » » » » upperValue=upperValue*0.9; |
| 2224 » » » » » lowerValue=lowerValue*1.1; |
| 2225 » » » » } |
2393 } | 2226 } |
2394 » » » if (!isNaN(config.graphMin)) lowerValue = config.graphMi
n; | 2227 » » » if(typeof config.graphMin=="function") lowerValue= setOp
tionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin,-1,-1,{nullValu
e : true}) |
2395 » » » if (!isNaN(config.graphMax)) upperValue = config.graphMa
x; | 2228 » » » else if (!isNaN(config.graphMin)) lowerValue = config.gr
aphMin; |
| 2229 » » » if(typeof config.graphMax=="function") upperValue= setOp
tionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax,-1,-1,{nullValu
e : true}) |
| 2230 » » » else if (!isNaN(config.graphMax)) upperValue = config.gr
aphMax; |
2396 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); | 2231 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); |
2397 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); | 2232 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); |
2398 return { | 2233 return { |
2399 maxValue: upperValue, | 2234 maxValue: upperValue, |
2400 minValue: lowerValue, | 2235 minValue: lowerValue, |
2401 maxSteps: maxSteps, | 2236 maxSteps: maxSteps, |
2402 minSteps: minSteps | 2237 minSteps: minSteps |
2403 }; | 2238 }; |
2404 » » } | 2239 » » }; |
2405 }; | 2240 }; |
2406 | 2241 |
2407 | 2242 |
2408 var Pie = function(data, config, ctx) { | 2243 var Pie = function(data, config, ctx) { |
2409 | 2244 » » var totvalue = 0; |
2410 » » var segmentTotal = 0; | |
2411 var msr, midPieX, midPieY, pieRadius; | 2245 var msr, midPieX, midPieY, pieRadius; |
2412 | 2246 |
2413 ctx.tpchart="Pie"; | 2247 ctx.tpchart="Pie"; |
2414 » » setting_new_chart_vars(ctx); | 2248 » if (!init_and_start(ctx,data,config)) return; |
2415 » » if (!dynamicFunction(data, config, ctx)) { | 2249 » » var statData=initPassVariableData_part1(data,config,ctx); |
2416 » » if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | |
2417 » » » return; | |
2418 » » } | |
2419 » if(config.responsive && typeof ctx.firstPass == "undefined") { | |
2420 » » if(!config.multiGraph) { | |
2421 » » » » addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
2422 » » » subUpdateChart(ctx,data,config); | |
2423 » » » return; | |
2424 » » } else { ctx.firstPass=1; } | |
2425 » » } | |
2426 | |
2427 » » while (config.startAngle < 0) { | |
2428 » » » config.startAngle += 360; | |
2429 » » } | |
2430 » » while (config.startAngle > 360) { | |
2431 » » » config.startAngle -= 360; | |
2432 » » } | |
2433 config.logarithmic = false; | 2250 config.logarithmic = false; |
2434 config.logarithmic2 = false; | 2251 config.logarithmic2 = false; |
2435 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
2436 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
2437 defMouse(ctx, data, config); | |
2438 //In case we have a canvas that is not a square. Minus 5 pixels
as padding round the edge. | |
2439 setRect(ctx, config); | |
2440 msr = setMeasures(data, config, ctx, height, width, "none", null
, true, false, false, false, true, "Pie"); | 2252 msr = setMeasures(data, config, ctx, height, width, "none", null
, true, false, false, false, true, "Pie"); |
2441 // midPieX = msr.leftNotUsableSize + (msr.availableWidth
/ 2); | |
2442 // midPieY = msr.topNotUsableSize + (msr.availableHeight
/ 2); | |
2443 // pieRadius = Min([msr.availableHeight / 2, msr.availabl
eWidth / 2]) - 5; | |
2444 for (var i = 0; i < data.length; i++) { | |
2445 if (!(typeof(data[i].value) == 'undefined')) segmentTota
l += 1 * data[i].value; | |
2446 } | |
2447 calculateDrawingSize(); | 2253 calculateDrawingSize(); |
2448 if(pieRadius > 0) { | 2254 if(pieRadius > 0) { |
| 2255 initPassVariableData_part2(statData,data,config,ctx,{mid
PosX : midPieX,midPosY : midPieY,int_radius : 0,ext_radius : pieRadius}); |
2449 animationLoop(config, null, drawPieSegments, ctx, msr.cl
rx, msr.clry, msr.clrwidth, msr.clrheight, midPieX, midPieY, midPieX - pieRadius
, midPieY + pieRadius, data); | 2256 animationLoop(config, null, drawPieSegments, ctx, msr.cl
rx, msr.clry, msr.clrwidth, msr.clrheight, midPieX, midPieY, midPieX - pieRadius
, midPieY + pieRadius, data); |
2450 } else { | 2257 } else { |
2451 testRedraw(ctx,data,config); | 2258 testRedraw(ctx,data,config); |
2452 } | 2259 } |
2453 function drawPieSegments(animationDecimal) { | 2260 function drawPieSegments(animationDecimal) { |
2454 » » » var cumulativeAngle = -config.startAngle * (Math.PI / 18
0) + 2 * Math.PI, | 2261 » » » for (var i = 0; i < data.length; i++) { |
2455 » » » » cumvalue = 0, | 2262 » » » » var» scaleAnimation = 1, |
2456 » » » » scaleAnimation = 1, | 2263 » » » » » rotateAnimation = 1; |
2457 » » » » rotateAnimation = 1; | 2264 » |
2458 » » » var realCumulativeAngle = config.startAngle * (Math.PI /
180) + 2 * Math.PI; | 2265 » » » » if (config.animation) { |
2459 » » » while (cumulativeAngle < 0) { | 2266 » » » » » if (config.animateScale) { |
2460 » » » » cumulativeAngle += 2 * Math.PI; | 2267 » » » » » » scaleAnimation = animationDecima
l; |
2461 » » » } | 2268 » » » » » } |
2462 » » » while (cumulativeAngle > 2 * Math.PI) { | 2269 » » » » » if (config.animateRotate) { |
2463 » » » » cumulativeAngle -= 2 * Math.PI; | 2270 » » » » » » rotateAnimation = animationDecim
al; |
2464 » » » } | 2271 » » » » » } |
2465 » » » while (realCumulativeAngle < 0) { | |
2466 » » » » realCumulativeAngle += 2 * Math.PI; | |
2467 » » » } | |
2468 » » » while (realCumulativeAngle > 2 * Math.PI) { | |
2469 » » » » realCumulativeAngle -= 2 * Math.PI; | |
2470 » » » } | |
2471 » » » if (config.animation) { | |
2472 » » » » if (config.animateScale) { | |
2473 » » » » » scaleAnimation = animationDecimal; | |
2474 } | 2272 } |
2475 if (config.animateRotate) { | |
2476 rotateAnimation = animationDecimal; | |
2477 } | |
2478 } | |
2479 if (animationDecimal >= 1) { | |
2480 totvalue = 0; | |
2481 for (var i = 0; i < data.length; i++) | |
2482 if (!(typeof(data[i].value) == 'undefine
d')) totvalue += 1 * data[i].value; | |
2483 } | |
2484 for (var i = 0; i < data.length; i++) { | |
2485 correctedRotateAnimation = animationCorrection(r
otateAnimation, data, config, i, -1, 0).mainVal; | 2273 correctedRotateAnimation = animationCorrection(r
otateAnimation, data, config, i, -1, 0).mainVal; |
2486 » » » » if (!(typeof(data[i].value) == 'undefined')) { | 2274 » » » » if (!(typeof(data[i].value) == 'undefined')&& 1*
data[i].value >=0) { |
2487 » » » » » var segmentAngle = correctedRotateAnimat
ion * ((1 * data[i].value / segmentTotal) * (Math.PI * 2)); | |
2488 » » » » » if (segmentAngle >= Math.PI * 2) segment
Angle = Math.PI * 2 - 0.001; // bug on Android when segmentAngle is >= 2*PI; | |
2489 ctx.beginPath(); | 2275 ctx.beginPath(); |
2490 » » » » » ctx.arc(midPieX, midPieY, scaleAnimation
* pieRadius, cumulativeAngle, cumulativeAngle + segmentAngle); | 2276 » » » » » if(config.animationByData == "ByArc") { |
| 2277 » » » » » » endAngle=statData[i].startAngle+
correctedRotateAnimation*statData[i].segmentAngle; |
| 2278 » » » » » » ctx.arc(midPieX, midPieY, scaleA
nimation * pieRadius, statData[i].startAngle, endAngle); |
| 2279 » » » » » } else if(config.animationByData) { |
| 2280 » » » » » » if(statData[i].startAngle-statDa
ta[i].firstAngle < correctedRotateAnimation*2*Math.PI ) { |
| 2281 » » » » » » » endAngle=statData[i].end
Angle; |
| 2282 » » » » » » » if((statData[i].endAngle
-statData[i].firstAngle)> correctedRotateAnimation*2*Math.PI) endAngle=statData[
i].firstAngle+correctedRotateAnimation*2*Math.PI;» » » »
» » » |
| 2283 » » » » » » » ctx.arc(midPieX, midPieY
, scaleAnimation * pieRadius, statData[i].startAngle, endAngle); |
| 2284 » » » » » » » |
| 2285 » » » » » » } |
| 2286 » » » » » » else continue; |
| 2287 » » » » » } else { |
| 2288 » » » » » » ctx.arc(midPieX, midPieY, scaleA
nimation * pieRadius, statData[i].firstAngle+correctedRotateAnimation * (statDat
a[i].startAngle-statData[i].firstAngle), statData[i].firstAngle+correctedRotateA
nimation * (statData[i].endAngle-statData[i].firstAngle)); |
| 2289 » » » » » } |
2491 ctx.lineTo(midPieX, midPieY); | 2290 ctx.lineTo(midPieX, midPieY); |
2492 ctx.closePath(); | 2291 ctx.closePath(); |
2493 » » » » » if (typeof data[i].color == "function")
ctx.fillStyle = data[i].color("COLOR", data, config, i, -1, animationDecimal, da
ta[i].value, "Pie", ctx, midPieX, midPieY, 0, scaleAnimation * pieRadius); | 2292 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data[i].color,config.defaultFillColor,i,-1,{animationDecimal: ani
mationDecimal, scaleAnimation : scaleAnimation} ); |
2494 » » » » » else ctx.fillStyle = data[i].color; | |
2495 ctx.fill(); | 2293 ctx.fill(); |
2496 cumulativeAngle += segmentAngle; | |
2497 cumvalue += 1 * data[i].value; | |
2498 if (config.segmentShowStroke) { | 2294 if (config.segmentShowStroke) { |
2499 ctx.lineWidth = config.segmentSt
rokeWidth; | 2295 ctx.lineWidth = config.segmentSt
rokeWidth; |
2500 ctx.strokeStyle = config.segment
StrokeColor; | 2296 ctx.strokeStyle = config.segment
StrokeColor; |
2501 ctx.stroke(); | 2297 ctx.stroke(); |
2502 } | 2298 } |
2503 } | 2299 } |
2504 } | 2300 } |
2505 » » » if (animationDecimal >= 1) { | 2301 » » » if (animationDecimal >= config.animationStopValue) { |
2506 » » » » cumulativeAngle-=2*Math.PI; | |
2507 for (var i = 0; i < data.length; i++) { | 2302 for (var i = 0; i < data.length; i++) { |
2508 correctedRotateAnimation = animationCorr
ection(rotateAnimation, data, config, i, -1, 0).mainVal; | 2303 if (typeof(data[i].value) == 'undefined'
|| 1*data[i].value<0) continue; |
2509 if (!(typeof(data[i].value) == 'undefine
d')) { | 2304 if (setOptionValue("ANNOTATEDISPLAY",ctx
,data,statData,undefined,config.annotateDisplay,i,-1,{nullValue : true})) { |
2510 var segmentAngle = correctedRota
teAnimation * ((1 * data[i].value / segmentTotal) * (Math.PI * 2)); | 2305 jsGraphAnnotate[ctx.ChartNewId][
jsGraphAnnotate[ctx.ChartNewId].length] = ["ARC", i,-1,statData]; |
2511 if (segmentAngle >= Math.PI * 2)
segmentAngle = Math.PI * 2 - 0.001; // bug on Android when segmentAngle is >= 2
*PI; | 2306 } |
2512 cumulativeAngle += segmentAngle; | 2307 if (setOptionValue("INGRAPHDATASHOW",ctx
,data,statData,undefined,config.inGraphDataShow,i,-1,{nullValue : true}) && stat
Data[i]["segmentAngle"] >= (Math.PI/180) * setOptionValue("INGRAPHDATAMINIMUMANG
LE",ctx,data,statData,undefined,config.inGraphDataMinimumAngle,i,-1,{nullValue :
true} )) { |
2513 cumvalue += 1 * data[i].value; | 2308 if (setOptionValue("INGRAPHDATAA
NGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{
nullValue : true} ) == 1) posAngle = statData[i].realStartAngle + setOptionValue
("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingA
ngle,i,-1,{nullValue: true }) * (Math.PI / 180); |
2514 if (typeof(data[i].title) == "st
ring") lgtxt = data[i].title.trim(); | 2309 else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 2) posAngle = statData[i].realStartAngle - statData[
i]["segmentAngle"] / 2 + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statDa
ta,undefined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI
/ 180); |
2515 else lgtxt = ""; | 2310 else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 3) posAngle = statData[i].realStartAngle - statData[
i].segmentAngle + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,unde
fined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180)
; |
2516 jsGraphAnnotate[ctx.ChartNewId][
jsGraphAnnotate[ctx.ChartNewId].length] = ["ARC", midPieX, midPieY, 0, pieRadius
, cumulativeAngle - segmentAngle, cumulativeAngle, lgtxt, 1 * data[i].value, cum
value, totvalue, segmentAngle, i]; | 2311 if (setOptionValue("INGRAPHDATAR
ADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition,i,-1
,{nullValue : true} ) == 1) labelRadius = 0 + setOptionValue("INGRAPHDATAPADDING
RADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadius,i,-1,{nullVa
lue: true} ); |
2517 if (config.inGraphDataShow && se
gmentAngle >= (Math.PI/180) * config.inGraphDataMinimumAngle) { | 2312 else if (setOptionValue("INGRAPH
DATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition
,i,-1,{nullValue : true} ) == 2) labelRadius = pieRadius / 2 + setOptionValue("I
NGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRa
dius,i,-1,{nullValue: true} ); |
2518 if (config.inGraphDataAn
glePosition == 1) posAngle = realCumulativeAngle + config.inGraphDataPaddingAngl
e * (Math.PI / 180); | 2313 else if (setOptionValue("INGRAPH
DATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition
,i,-1,{nullValue : true} ) == 3) labelRadius = pieRadius + setOptionValue("INGRA
PHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadius
,i,-1,{nullValue: true} ); |
2519 else if (config.inGraphD
ataAnglePosition == 2) posAngle = realCumulativeAngle - segmentAngle / 2 + confi
g.inGraphDataPaddingAngle * (Math.PI / 180); | 2314 ctx.save(); |
2520 else if (config.inGraphD
ataAnglePosition == 3) posAngle = realCumulativeAngle - segmentAngle + config.in
GraphDataPaddingAngle * (Math.PI / 180); | 2315 if (setOptionValue("INGRAPHDATAA
LIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{nullValue: true
}) == "off-center") { |
2521 if (config.inGraphDataRa
diusPosition == 1) labelRadius = 0 + config.inGraphDataPaddingRadius; | 2316 if (setOptionValue("INGR
APHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullVa
lue : true} ) == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3
* Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.tex
tAlign = "left"; |
2522 else if (config.inGraphD
ataRadiusPosition == 2) labelRadius = pieRadius / 2 + config.inGraphDataPaddingR
adius; | 2317 else ctx.textAlign = "ri
ght"; |
2523 else if (config.inGraphD
ataRadiusPosition == 3) labelRadius = pieRadius + config.inGraphDataPaddingRadiu
s; | 2318 } else if (setOptionValue("INGRA
PHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{nullValue
: true }) == "to-center") { |
2524 ctx.save(); | 2319 if (setOptionValue("INGR
APHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullVa
lue : true} ) == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3
* Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.tex
tAlign = "right"; |
2525 if (config.inGraphDataAl
ign == "off-center") { | 2320 else ctx.textAlign = "le
ft"; |
2526 if (config.inGra
phDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 *
Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.text
Align = "left"; | 2321 } else ctx.textAlign = setOption
Value("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-
1,{nullValue: true }); |
2527 else ctx.textAli
gn = "right"; | 2322 if (setOptionValue("INGRAPHDATAV
ALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullValue : tr
ue} ) == "off-center") { |
2528 } else if (config.inGrap
hDataAlign == "to-center") { | 2323 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "top"; |
2529 if (config.inGra
phDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 *
Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.text
Align = "right"; | 2324 else ctx.textBaseline =
"bottom"; |
2530 else ctx.textAli
gn = "left"; | 2325 } else if (setOptionValue("INGRA
PHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullVal
ue : true} ) == "to-center") { |
2531 } else ctx.textAlign = c
onfig.inGraphDataAlign; | 2326 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "bottom"; |
2532 if (config.inGraphDataVA
lign == "off-center") { | 2327 else ctx.textBaseline =
"top"; |
2533 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "top"; | 2328 } else ctx.textBaseline = setOpt
ionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlig
n,i,-1,{nullValue : true} ); |
2534 else ctx.textBas
eline = "bottom"; | 2329 ctx.font = setOptionValue("INGRA
PHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{n
ullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statDat
a,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px ' + setOp
tionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphData
FontFamily,i,-1,{nullValue : true} ); |
2535 } else if (config.inGrap
hDataVAlign == "to-center") { | 2330 ctx.fillStyle = setOptionValue("
INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,
-1,{nullValue : true} ); |
2536 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "bottom"; | 2331 var dispString = tmplbis(setOpti
onValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-
1,{nullValue : true} ), statData[i]); |
2537 else ctx.textBas
eline = "top"; | 2332 ctx.translate(midPieX + labelRad
ius * Math.cos(posAngle), midPieY - labelRadius * Math.sin(posAngle)); |
2538 } else ctx.textBaseline
= config.inGraphDataVAlign; | 2333 if (setOptionValue("INGRAPHDATAR
OTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : tr
ue} ) == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle); |
2539 ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 2334 else if (setOptionValue("INGRAPH
DATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue
: true} ) == "inRadiusAxisRotateLabels") { |
2540 ctx.fillStyle = config.i
nGraphDataFontColor; | 2335 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Math.PI) <
3 * Math.PI / 2) ctx.rotate(3 * Math.PI - posAngle); |
2541 var dispString = tmplbis
(config.inGraphDataTmpl, { | 2336 else ctx.rotate(2 * Math
.PI - posAngle); |
2542 config: config, | 2337 } else ctx.rotate(setOptionValue
("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{
nullValue : true} ) * (Math.PI / 180)); |
2543 v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | 2338 ctx.fillTextMultiLine(dispString
, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData
,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ),true); |
2544 v2: fmtChartJS(c
onfig, 1 * data[i].value, config.fmtV2), | 2339 ctx.restore(); |
2545 v3: fmtChartJS(c
onfig, cumvalue, config.fmtV3), | |
2546 v4: fmtChartJS(c
onfig, totvalue, config.fmtV4), | |
2547 v5: fmtChartJS(c
onfig, segmentAngle, config.fmtV5), | |
2548 v6: roundToWithT
housands(config, fmtChartJS(config, 100 * data[i].value / totvalue, config.fmtV6
), config.roundPct), | |
2549 v7: fmtChartJS(c
onfig, midPieX, config.fmtV7), | |
2550 v8: fmtChartJS(c
onfig, midPieY, config.fmtV8), | |
2551 v9: fmtChartJS(c
onfig, 0, config.fmtV9), | |
2552 v10: fmtChartJS(
config, pieRadius, config.fmtV10), | |
2553 v11: fmtChartJS(
config, cumulativeAngle - segmentAngle, config.fmtV11), | |
2554 v12: fmtChartJS(
config, cumulativeAngle, config.fmtV12), | |
2555 v13: fmtChartJS(
config, i, config.fmtV13), | |
2556 data: data | |
2557 }); | |
2558 ctx.translate(midPieX +
labelRadius * Math.cos(posAngle), midPieY - labelRadius * Math.sin(posAngle)); | |
2559 if (config.inGraphDataRo
tate == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle); | |
2560 else if (config.inGraphD
ataRotate == "inRadiusAxisRotateLabels") { | |
2561 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Ma
th.PI) < 3 * Math.PI / 2) ctx.rotate(3 * Math.PI - posAngle); | |
2562 else ctx.rotate(
2 * Math.PI - posAngle); | |
2563 } else ctx.rotate(config
.inGraphDataRotate * (Math.PI / 180)); | |
2564 ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | |
2565 ctx.restore(); | |
2566 } | |
2567 realCumulativeAngle -= segmentAn
gle; | |
2568 } | 2340 } |
2569 } | 2341 } |
2570 | 2342 |
2571 } | 2343 } |
2572 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Pie"); | 2344 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Pie"); |
2573 }; | 2345 }; |
2574 | 2346 |
2575 function calculateDrawingSize() { | 2347 function calculateDrawingSize() { |
2576 var lgtxt; | |
2577 var cumulativeAngle = -config.startAngle * (Math.PI / 18
0) + 2 * Math.PI, | |
2578 cumvalue = 0; | |
2579 while (cumulativeAngle < 0) { | |
2580 cumulativeAngle += 2 * Math.PI; | |
2581 } | |
2582 while (cumulativeAngle > 2 * Math.PI) { | |
2583 cumulativeAngle -= 2 * Math.PI; | |
2584 } | |
2585 midPieX = msr.leftNotUsableSize + (msr.availableWidth /
2); | 2348 midPieX = msr.leftNotUsableSize + (msr.availableWidth /
2); |
2586 midPieY = msr.topNotUsableSize + (msr.availableHeight /
2); | 2349 midPieY = msr.topNotUsableSize + (msr.availableHeight /
2); |
2587 pieRadius = Min([msr.availableHeight / 2, msr.availableW
idth / 2]) - 5; | 2350 pieRadius = Min([msr.availableHeight / 2, msr.availableW
idth / 2]) - 5; |
2588 // Computerange Pie Radius | 2351 // Computerange Pie Radius |
2589 » » » if (config.inGraphDataShow && config.inGraphDataRadiusPo
sition == 3 && config.inGraphDataAlign == "off-center" && config.inGraphDataRota
te == 0) { | 2352 » » » if (isBooleanOptionTrue(undefined,config.inGraphDataShow
) && setOptionValue("INGRAPHDATARADIUSPOSITION",ctx,data,statData,undefined,conf
ig.inGraphDataRadiusPosition,0,-1,{nullValue : true} ) == 3 && setOptionValue("I
NGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,0,-1,{nullV
alue: true }) == "off-center" && setOptionValue("INGRAPHDATAROTATE",ctx,data,st
atData,undefined,config.inGraphDataRotate,0,-1,{nullValue : true} ) == 0) { |
2590 » » » » pieRadius = Min([msr.availableHeight / 2, msr.av
ailableWidth / 2]) - config.inGraphDataFontSize - config.inGraphDataPaddingRadiu
s - 5; | 2353 » » » » pieRadius = Min([msr.availableHeight / 2, msr.av
ailableWidth / 2]) - setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,unde
fined,config.inGraphDataFontSize,0,-1,{nullValue : true} ) - setOptionValue("ING
RAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadi
us,0,-1,{nullValue: true} ) - 5; |
2591 » » » » var realCumulativeAngle = config.startAngle * (M
ath.PI / 180) + 2 * Math.PI; | 2354 » » » » var realCumulativeAngle = ((config.startAngle *
(Math.PI / 180) + 2 * Math.PI) % (2*Math.PI) + 2*Math.PI) % (2*Math.PI); |
2592 » » » » while (realCumulativeAngle < 0) { | |
2593 » » » » » realCumulativeAngle += 2 * Math.PI; | |
2594 » » » » } | |
2595 » » » » while (realCumulativeAngle > 2 * Math.PI) { | |
2596 » » » » » realCumulativeAngle -= 2 * Math.PI; | |
2597 » » » » } | |
2598 » » » » var totvalue = 0; | |
2599 » » » » for (var i = 0; i < data.length; i++) | |
2600 » » » » » if (!(typeof(data[i].value) == 'undefine
d')) totvalue += 1 * data[i].value; | |
2601 » » » » ctx.font = config.inGraphDataFontStyle + ' ' + c
onfig.inGraphDataFontSize + 'px ' + config.inGraphDataFontFamily; | |
2602 » » » » var cumvalue = 0; | |
2603 » » » » var posAngle; | |
2604 for (var i = 0; i < data.length; i++) { | 2355 for (var i = 0; i < data.length; i++) { |
2605 » » » » » if (!(typeof(data[i].value) == 'undefine
d')) { | 2356 » » » » » if (!(typeof(data[i].value) == 'undefine
d') && 1*data[i].value>=0) { |
2606 » » » » » » cumvalue += 1 * data[i].value; | 2357 » » » » » » ctx.font = setOptionValue("INGRA
PHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{n
ullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statDat
a,undefined,config.inGraphDataFontSize,0,-1,{nullValue : true} ) + 'px ' + setOp
tionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphData
FontFamily,i,-1,{nullValue : true} ); |
2607 » » » » » » var segmentAngle = (1 * data[i].
value / segmentTotal) * (Math.PI * 2); | 2358 » » » » » » if (setOptionValue("INGRAPHDATAA
NGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{
nullValue : true} ) == 1) posAngle = realCumulativeAngle + setOptionValue("INGRA
PHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingAngle,i,
-1,{nullValue: true }) * (Math.PI / 180); |
2608 » » » » » » cumulativeAngle += segmentAngle; | 2359 » » » » » » else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 2) posAngle = realCumulativeAngle - statData[i].segm
entAngle / 2 + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefin
ed,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180); |
2609 » » » » » » if (config.inGraphDataAnglePosit
ion == 1) posAngle = realCumulativeAngle + config.inGraphDataPaddingAngle * (Mat
h.PI / 180); | 2360 » » » » » » else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 3) posAngle = realCumulativeAngle - statData[i].segm
entAngle + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,c
onfig.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180); |
2610 » » » » » » else if (config.inGraphDataAngle
Position == 2) posAngle = realCumulativeAngle - segmentAngle / 2 + config.inGrap
hDataPaddingAngle * (Math.PI / 180); | 2361 » » » » » » realCumulativeAngle -= statData[
i].segmentAngle; |
2611 » » » » » » else if (config.inGraphDataAngle
Position == 3) posAngle = realCumulativeAngle - segmentAngle + config.inGraphDat
aPaddingAngle * (Math.PI / 180); | 2362 » » » » » » var dispString = tmplbis(setOpti
onValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-
1,{nullValue : true} ), statData[i]); |
2612 » » » » » » realCumulativeAngle -= segmentAn
gle; | |
2613 » » » » » » if (typeof(data[i].title) == "st
ring") lgtxt = data[i].title.trim(); | |
2614 » » » » » » else lgtxt = ""; | |
2615 » » » » » » var dispString = tmplbis(config.
inGraphDataTmpl, { | |
2616 » » » » » » » config: config, | |
2617 » » » » » » » v1: fmtChartJS(config, l
gtxt, config.fmtV1), | |
2618 » » » » » » » v2: fmtChartJS(config, 1
* data[i].value, config.fmtV2), | |
2619 » » » » » » » v3: fmtChartJS(config, c
umvalue, config.fmtV3), | |
2620 » » » » » » » v4: fmtChartJS(config, t
otvalue, config.fmtV4), | |
2621 » » » » » » » v5: fmtChartJS(config, s
egmentAngle, config.fmtV5), | |
2622 » » » » » » » v6: roundToWithThousands
(config, fmtChartJS(config, 100 * data[i].value / totvalue, config.fmtV6), confi
g.roundPct), | |
2623 » » » » » » » v7: fmtChartJS(config, m
idPieX, config.fmtV7), | |
2624 » » » » » » » v8: fmtChartJS(config, m
idPieY, config.fmtV8), | |
2625 » » » » » » » v9: fmtChartJS(config, 0
, config.fmtV9), | |
2626 » » » » » » » v10: fmtChartJS(config,
pieRadius, config.fmtV10), | |
2627 » » » » » » » v11: fmtChartJS(config,
cumulativeAngle - segmentAngle, config.fmtV11), | |
2628 » » » » » » » v12: fmtChartJS(config,
cumulativeAngle, config.fmtV12), | |
2629 » » » » » » » v13: fmtChartJS(config,
i, config.fmtV13), | |
2630 » » » » » » » data: data | |
2631 » » » » » » }); | |
2632 var textMeasurement = ctx.measur
eText(dispString).width; | 2363 var textMeasurement = ctx.measur
eText(dispString).width; |
2633 » » » » » » var MaxRadiusX = Math.abs((msr.a
vailableWidth / 2 - textMeasurement) / Math.cos(posAngle)) - config.inGraphDataP
addingRadius - 5; | 2364 » » » » » » var MaxRadiusX = Math.abs((msr.a
vailableWidth / 2 - textMeasurement) / Math.cos(posAngle)) - setOptionValue("ING
RAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadi
us,i,-1,{nullValue: true} ) - 5; |
2634 if (MaxRadiusX < pieRadius) pieR
adius = MaxRadiusX; | 2365 if (MaxRadiusX < pieRadius) pieR
adius = MaxRadiusX; |
2635 } | 2366 } |
2636 } | 2367 } |
2637 } | 2368 } |
2638 pieRadius = pieRadius * config.radiusScale; | 2369 pieRadius = pieRadius * config.radiusScale; |
2639 }; | 2370 }; |
2640 }; | 2371 }; |
2641 var Doughnut = function(data, config, ctx) { | 2372 var Doughnut = function(data, config, ctx) { |
2642 var segmentTotal = 0; | |
2643 var msr, midPieX, midPieY, doughnutRadius; | 2373 var msr, midPieX, midPieY, doughnutRadius; |
2644 | 2374 |
2645 ctx.tpchart="Doughnut"; | 2375 ctx.tpchart="Doughnut"; |
2646 » » setting_new_chart_vars(ctx); | 2376 » if (!init_and_start(ctx,data,config)) return; |
2647 » » if (!dynamicFunction(data, config, ctx)) { | 2377 » » var statData=initPassVariableData_part1(data,config,ctx); |
2648 » » if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | |
2649 » » » return; | |
2650 » » } | |
2651 » if(config.responsive && typeof ctx.firstPass == "undefined") { | |
2652 » » if(!config.multiGraph) { | |
2653 » » » » addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
2654 » » » subUpdateChart(ctx,data,config); | |
2655 » » » return; | |
2656 » » } else { ctx.firstPass=1; } | |
2657 » » } | |
2658 | 2378 |
2659 » » var realCumulativeAngle = config.startAngle * (Math.PI / 180) +
2 * Math.PI; | 2379 » » var realCumulativeAngle = (((config.startAngle * (Math.PI / 180)
+ 2 * Math.PI) % (2 * Math.PI)) + 2* Math.PI) % (2* Math.PI) ; |
2660 » » while (config.startAngle < 0) { | |
2661 » » » config.startAngle += 360; | |
2662 » » } | |
2663 » » while (config.startAngle > 360) { | |
2664 » » » config.startAngle -= 360; | |
2665 » » } | |
2666 » » while (realCumulativeAngle < 0) { | |
2667 » » » realCumulativeAngle += 2 * Math.PI; | |
2668 » » } | |
2669 » » while (realCumulativeAngle > 2 * Math.PI) { | |
2670 » » » realCumulativeAngle -= 2 * Math.PI; | |
2671 » » } | |
2672 config.logarithmic = false; | 2380 config.logarithmic = false; |
2673 config.logarithmic2 = false; | 2381 config.logarithmic2 = false; |
2674 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
2675 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
2676 defMouse(ctx, data, config); | |
2677 setRect(ctx, config); | |
2678 msr = setMeasures(data, config, ctx, height, width, "none", null
, true, false, false, false, true, "Doughnut"); | 2382 msr = setMeasures(data, config, ctx, height, width, "none", null
, true, false, false, false, true, "Doughnut"); |
2679 calculateDrawingSize(); | 2383 calculateDrawingSize(); |
| 2384 |
2680 var cutoutRadius = doughnutRadius * (config.percentageInnerCutou
t / 100); | 2385 var cutoutRadius = doughnutRadius * (config.percentageInnerCutou
t / 100); |
2681 for (var i = 0; i < data.length; i++) { | |
2682 if (!(typeof(data[i].value) == 'undefined')) segmentTota
l += 1 * data[i].value; | |
2683 } | |
2684 if(doughnutRadius > 0) { | 2386 if(doughnutRadius > 0) { |
| 2387 initPassVariableData_part2(statData,data,config,ctx,{mid
PosX : midPieX,midPosY : midPieY ,int_radius : cutoutRadius ,ext_radius : doughn
utRadius}); |
2685 animationLoop(config, null, drawPieSegments, ctx, msr.cl
rx, msr.clry, msr.clrwidth, msr.clrheight, midPieX, midPieY, midPieX - doughnutR
adius, midPieY + doughnutRadius, data); | 2388 animationLoop(config, null, drawPieSegments, ctx, msr.cl
rx, msr.clry, msr.clrwidth, msr.clrheight, midPieX, midPieY, midPieX - doughnutR
adius, midPieY + doughnutRadius, data); |
2686 } else { | 2389 } else { |
2687 testRedraw(ctx,data,config); | 2390 testRedraw(ctx,data,config); |
2688 } | 2391 } |
2689 | 2392 |
2690 | 2393 |
2691 function drawPieSegments(animationDecimal) { | 2394 function drawPieSegments(animationDecimal) { |
2692 » » » var cumulativeAngle = -config.startAngle * (Math.PI / 18
0) + 2 * Math.PI, | 2395 » » » var cumulativeAngle = (((-config.startAngle * (Math.PI /
180) + 2 * Math.PI) % (2 * Math.PI)) + 2* Math.PI) % (2* Math.PI) ; |
2693 » » » » cumvalue = 0, | 2396 |
2694 » » » » scaleAnimation = 1, | 2397 » » » for (var i = 0; i < data.length; i++) { |
2695 » » » » rotateAnimation = 1; | 2398 » » » » var» scaleAnimation = 1, |
2696 » » » while (cumulativeAngle < 0) { | 2399 » » » » » rotateAnimation = 1; |
2697 » » » » cumulativeAngle += 2 * Math.PI; | 2400 » |
2698 » » » } | 2401 » » » » if (config.animation) { |
2699 » » » while (cumulativeAngle > 2 * Math.PI) { | 2402 » » » » » if (config.animateScale) { |
2700 » » » » cumulativeAngle -= 2 * Math.PI; | 2403 » » » » » » scaleAnimation = animationDecima
l; |
2701 » » » } | 2404 » » » » » } |
2702 » » » if (config.animation) { | 2405 » » » » » if (config.animateRotate) { |
2703 » » » » if (config.animateScale) { | 2406 » » » » » » rotateAnimation = animationDecim
al; |
2704 » » » » » scaleAnimation = animationDecimal; | 2407 » » » » » } |
2705 } | 2408 } |
2706 if (config.animateRotate) { | |
2707 rotateAnimation = animationDecimal; | |
2708 } | |
2709 } | |
2710 if (animationDecimal >= 1) { | |
2711 totvalue = 0; | |
2712 for (var i = 0; i < data.length; i++) | |
2713 if (!(typeof(data[i].value) == 'undefine
d')) totvalue += 1 * data[i].value; | |
2714 } | |
2715 for (var i = 0; i < data.length; i++) { | |
2716 correctedRotateAnimation = animationCorrection(r
otateAnimation, data, config, i, -1, 0).mainVal; | 2409 correctedRotateAnimation = animationCorrection(r
otateAnimation, data, config, i, -1, 0).mainVal; |
2717 » » » » if (!(typeof(data[i].value) == 'undefined')) { | 2410 » » » » if (!(typeof(data[i].value) == 'undefined') && 1
*data[i].value >=0) { |
2718 » » » » » var segmentAngle = correctedRotateAnimat
ion * ((1 * data[i].value / segmentTotal) * (Math.PI * 2)); | |
2719 » » » » » if (segmentAngle >= Math.PI * 2) segment
Angle = Math.PI * 2 - 0.001; // but on Android when segmentAngle is >= 2*PI; | |
2720 ctx.beginPath(); | 2411 ctx.beginPath(); |
2721 » » » » » ctx.arc(midPieX, midPieY, scaleAnimation
* doughnutRadius, cumulativeAngle, cumulativeAngle + segmentAngle, false); | 2412 » » » » » if (config.animationByData == "ByArc") { |
2722 » » » » » ctx.arc(midPieX, midPieY, scaleAnimation
* cutoutRadius, cumulativeAngle + segmentAngle, cumulativeAngle, true); | 2413 » » » » » » endAngle=statData[i].startAngle+
correctedRotateAnimation*statData[i].segmentAngle; |
| 2414 » » » » » » ctx.arc(midPieX, midPieY, scaleA
nimation * doughnutRadius, statData[i].startAngle, endAngle,false); |
| 2415 » » » » » » ctx.arc(midPieX, midPieY, scaleA
nimation * cutoutRadius, endAngle,statData[i].startAngle, true); |
| 2416 » » » » » } else if(config.animationByData) { |
| 2417 » » » » » » if(statData[i].startAngle-statDa
ta[i].firstAngle < correctedRotateAnimation*2*Math.PI ) { |
| 2418 » » » » » » » endAngle=statData[i].end
Angle; |
| 2419 » » » » » » » if((statData[i].endAngle
-statData[i].firstAngle)> correctedRotateAnimation*2*Math.PI) endAngle=statData[
i].firstAngle+correctedRotateAnimation*2*Math.PI;» » » »
» » » |
| 2420 » » » » » » » ctx.arc(midPieX, midPieY
, scaleAnimation * doughnutRadius, statData[i].startAngle, endAngle,false); |
| 2421 » » » » » » » ctx.arc(midPieX, midPieY
, scaleAnimation * cutoutRadius, endAngle,statData[i].startAngle, true); |
| 2422 » » » » » » » |
| 2423 » » » » » » } |
| 2424 » » » » » » else continue; |
| 2425 » » » » » } else { |
| 2426 » » » » » » ctx.arc(midPieX, midPieY, scaleA
nimation * doughnutRadius, statData[i].firstAngle+correctedRotateAnimation * (st
atData[i].startAngle-statData[i].firstAngle), statData[i].firstAngle+correctedRo
tateAnimation * (statData[i].endAngle-statData[i].firstAngle),false); |
| 2427 » » » » » » ctx.arc(midPieX, midPieY, scaleA
nimation * cutoutRadius, statData[i].firstAngle+correctedRotateAnimation * (stat
Data[i].endAngle-statData[i].firstAngle), statData[i].firstAngle+correctedRotate
Animation * (statData[i].startAngle-statData[i].firstAngle), true); |
| 2428 » » » » » } |
2723 ctx.closePath(); | 2429 ctx.closePath(); |
2724 » » » » » if (typeof data[i].color == "function")
ctx.fillStyle = data[i].color("COLOR", data, config, i, -1, animationDecimal, da
ta[i].value, "Doughnut", ctx, midPieX, midPieY, scaleAnimation * cutoutRadius, s
caleAnimation * doughnutRadius); | 2430 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data[i].color,config.defaultFillColor,i,-1,{animationDecimal: ani
mationDecimal, scaleAnimation : scaleAnimation} ); |
2725 » » » » » else ctx.fillStyle = data[i].color; | |
2726 ctx.fill(); | 2431 ctx.fill(); |
2727 cumulativeAngle += segmentAngle; | |
2728 cumvalue += 1 * data[i].value; | |
2729 if (config.segmentShowStroke) { | 2432 if (config.segmentShowStroke) { |
2730 ctx.lineWidth = config.segmentSt
rokeWidth; | 2433 ctx.lineWidth = config.segmentSt
rokeWidth; |
2731 ctx.strokeStyle = config.segment
StrokeColor; | 2434 ctx.strokeStyle = config.segment
StrokeColor; |
2732 ctx.stroke(); | 2435 ctx.stroke(); |
2733 } | 2436 } |
2734 } | 2437 } |
2735 } | 2438 } |
2736 » » » if (animationDecimal >= 1) { | 2439 » » » if (animationDecimal >= config.animationStopValue) { |
2737 » » » » cumulativeAngle-=2*Math.PI; | |
2738 for (var i = 0; i < data.length; i++) { | 2440 for (var i = 0; i < data.length; i++) { |
2739 correctedRotateAnimation = animationCorr
ection(rotateAnimation, data, config, i, -1, 0).mainVal; | 2441 if (typeof(data[i].value) == 'undefined'
|| 1*data[i].value<0) continue; |
2740 if (!(typeof(data[i].value) == 'undefine
d')) { | 2442 if(setOptionValue("ANNOTATEDISPLAY",ctx,
data,statData,undefined,config.annotateDisplay,i,-1,{nullValue : true})) { |
2741 var segmentAngle = correctedRota
teAnimation * ((1 * data[i].value / segmentTotal) * (Math.PI * 2)); | 2443 jsGraphAnnotate[ctx.ChartNewId][
jsGraphAnnotate[ctx.ChartNewId].length] = ["ARC", i,-1,statData]; |
2742 if (segmentAngle >= Math.PI * 2)
segmentAngle = Math.PI * 2 - 0.001; // but on Android when segmentAngle is >= 2
*PI; | 2444 } |
2743 cumulativeAngle += segmentAngle; | 2445 if (setOptionValue("INGRAPHDATASHOW",ctx
,data,statData,undefined,config.inGraphDataShow,i,-1,{nullValue : true}) && stat
Data[i].segmentAngle >= (Math.PI/180) * setOptionValue("INGRAPHDATAMINIMUMANGLE"
,ctx,data,statData,undefined,config.inGraphDataMinimumAngle,i,-1,{nullValue : tr
ue} )) { |
2744 cumvalue += 1 * data[i].value; | 2446 if (setOptionValue("INGRAPHDATAA
NGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{
nullValue : true} ) == 1) posAngle = statData[i].realStartAngle + setOptionValue
("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingA
ngle,i,-1,{nullValue: true }) * (Math.PI / 180); |
2745 if (typeof(data[i].title) == "st
ring") lgtxt = data[i].title.trim(); | 2447 else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 2) posAngle = statData[i].realStartAngle- statData[i
].segmentAngle / 2 + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,u
ndefined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 1
80); |
2746 else lgtxt = ""; | 2448 else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 3) posAngle = statData[i].realStartAngle - statData[
i].segmentAngle + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,unde
fined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180)
; |
2747 jsGraphAnnotate[ctx.ChartNewId][
jsGraphAnnotate[ctx.ChartNewId].length] = ["ARC", midPieX, midPieY, cutoutRadius
, doughnutRadius, cumulativeAngle - segmentAngle, cumulativeAngle, lgtxt, 1 * da
ta[i].value, cumvalue, totvalue, segmentAngle, i]; | 2449 if (setOptionValue("INGRAPHDATAR
ADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition,i,-1
,{nullValue : true} ) == 1) labelRadius = cutoutRadius + setOptionValue("INGRAPH
DATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadius,i
,-1,{nullValue: true} ); |
2748 if (config.inGraphDataShow && se
gmentAngle >= (Math.PI/180) * config.inGraphDataMinimumAngle) { | 2450 else if (setOptionValue("INGRAPH
DATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition
,i,-1,{nullValue : true} ) == 2) labelRadius = cutoutRadius + (doughnutRadius -
cutoutRadius) / 2 + setOptionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,
undefined,config.inGraphDataPaddingRadius,i,-1,{nullValue: true} ); |
2749 if (config.inGraphDataAn
glePosition == 1) posAngle = realCumulativeAngle + config.inGraphDataPaddingAngl
e * (Math.PI / 180); | 2451 else if (setOptionValue("INGRAPH
DATARADIUSPOSITION",ctx,data,statData,undefined,config.inGraphDataRadiusPosition
,i,-1,{nullValue : true} ) == 3) labelRadius = doughnutRadius + setOptionValue("
INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingR
adius,i,-1,{nullValue: true} ); |
2750 else if (config.inGraphD
ataAnglePosition == 2) posAngle = realCumulativeAngle - segmentAngle / 2 + confi
g.inGraphDataPaddingAngle * (Math.PI / 180); | 2452 ctx.save(); |
2751 else if (config.inGraphD
ataAnglePosition == 3) posAngle = realCumulativeAngle - segmentAngle + config.in
GraphDataPaddingAngle * (Math.PI / 180); | 2453 if (setOptionValue("INGRAPHDATAA
LIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{nullValue: true
}) == "off-center") { |
2752 if (config.inGraphDataRa
diusPosition == 1) labelRadius = cutoutRadius + config.inGraphDataPaddingRadius; | 2454 if (setOptionValue("INGR
APHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullVa
lue : true} ) == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3
* Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.tex
tAlign = "left"; |
2753 else if (config.inGraphD
ataRadiusPosition == 2) labelRadius = cutoutRadius + (doughnutRadius - cutoutRad
ius) / 2 + config.inGraphDataPaddingRadius; | 2455 else ctx.textAlign = "ri
ght"; |
2754 else if (config.inGraphD
ataRadiusPosition == 3) labelRadius = doughnutRadius + config.inGraphDataPadding
Radius; | 2456 } else if (setOptionValue("INGRA
PHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-1,{nullValue
: true }) == "to-center") { |
2755 ctx.save(); | 2457 if (setOptionValue("INGR
APHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullVa
lue : true} ) == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3
* Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.tex
tAlign = "right"; |
2756 if (config.inGraphDataAl
ign == "off-center") { | 2458 else ctx.textAlign = "le
ft"; |
2757 if (config.inGra
phDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 *
Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.text
Align = "left"; | 2459 } else ctx.textAlign = setOption
Value("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,-
1,{nullValue: true }); |
2758 else ctx.textAli
gn = "right"; | 2460 if (setOptionValue("INGRAPHDATAV
ALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullValue : tr
ue} ) == "off-center") { |
2759 } else if (config.inGrap
hDataAlign == "to-center") { | 2461 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "top"; |
2760 if (config.inGra
phDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 *
Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.text
Align = "right"; | 2462 else ctx.textBaseline =
"bottom"; |
2761 else ctx.textAli
gn = "left"; | 2463 } else if (setOptionValue("INGRA
PHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullVal
ue : true} ) == "to-center") { |
2762 } else ctx.textAlign = c
onfig.inGraphDataAlign; | 2464 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "bottom"; |
2763 if (config.inGraphDataVA
lign == "off-center") { | 2465 else ctx.textBaseline =
"top"; |
2764 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "top"; | 2466 } else ctx.textBaseline = setOpt
ionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlig
n,i,-1,{nullValue : true} ); |
2765 else ctx.textBas
eline = "bottom"; | 2467 ctx.font = setOptionValue("INGRA
PHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{n
ullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statDat
a,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px ' + setOp
tionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphData
FontFamily,i,-1,{nullValue : true} ); |
2766 } else if (config.inGrap
hDataVAlign == "to-center") { | 2468 ctx.fillStyle = setOptionValue("
INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,
-1,{nullValue : true} ); |
2767 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "bottom"; | 2469 var dispString = tmplbis(setOpti
onValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-
1,{nullValue : true} ), statData[i]); |
2768 else ctx.textBas
eline = "top"; | 2470 ctx.translate(midPieX + labelRad
ius * Math.cos(posAngle), midPieY - labelRadius * Math.sin(posAngle)); |
2769 } else ctx.textBaseline
= config.inGraphDataVAlign; | 2471 if (setOptionValue("INGRAPHDATAR
OTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : tr
ue} ) == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle); |
2770 ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 2472 else if (setOptionValue("INGRAPH
DATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue
: true} ) == "inRadiusAxisRotateLabels") { |
2771 ctx.fillStyle = config.i
nGraphDataFontColor; | 2473 if ((posAngle + 2 * Math
.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Math.PI) <
3 * Math.PI / 2) ctx.rotate(3 * Math.PI - posAngle); |
2772 var dispString = tmplbis
(config.inGraphDataTmpl, { | 2474 else ctx.rotate(2 * Math
.PI - posAngle); |
2773 config: config, | 2475 } else ctx.rotate(setOptionValue
("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{
nullValue : true} ) * (Math.PI / 180)); |
2774 v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | 2476 ctx.fillTextMultiLine(dispString
, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData
,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ),true); |
2775 v2: fmtChartJS(c
onfig, 1 * data[i].value, config.fmtV2), | 2477 ctx.restore(); |
2776 v3: fmtChartJS(c
onfig, cumvalue, config.fmtV3), | |
2777 v4: fmtChartJS(c
onfig, totvalue, config.fmtV4), | |
2778 v5: fmtChartJS(c
onfig, segmentAngle, config.fmtV5), | |
2779 v6: roundToWithT
housands(config, fmtChartJS(config, 100 * data[i].value / totvalue, config.fmtV6
), config.roundPct), | |
2780 v7: fmtChartJS(c
onfig, midPieX, config.fmtV7), | |
2781 v8: fmtChartJS(c
onfig, midPieY, config.fmtV8), | |
2782 v9: fmtChartJS(c
onfig, cutoutRadius, config.fmtV9), | |
2783 v10: fmtChartJS(
config, doughnutRadius, config.fmtV10), | |
2784 v11: fmtChartJS(
config, cumulativeAngle - segmentAngle, config.fmtV11), | |
2785 v12: fmtChartJS(
config, cumulativeAngle, config.fmtV12), | |
2786 v13: fmtChartJS(
config, i, config.fmtV13) | |
2787 }); | |
2788 ctx.translate(midPieX +
labelRadius * Math.cos(posAngle), midPieY - labelRadius * Math.sin(posAngle)); | |
2789 if (config.inGraphDataRo
tate == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle); | |
2790 else if (config.inGraphD
ataRotate == "inRadiusAxisRotateLabels") { | |
2791 if ((posAngle +
2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Ma
th.PI) < 3 * Math.PI / 2) ctx.rotate(3 * Math.PI - posAngle); | |
2792 else ctx.rotate(
2 * Math.PI - posAngle); | |
2793 } else ctx.rotate(config
.inGraphDataRotate * (Math.PI / 180)); | |
2794 ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | |
2795 ctx.restore(); | |
2796 } | |
2797 realCumulativeAngle -= segmentAn
gle; | |
2798 } | 2478 } |
2799 } | 2479 } |
2800 } | 2480 } |
2801 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Doughnut"); | 2481 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Doughnut"); |
2802 }; | 2482 }; |
2803 | 2483 |
2804 function calculateDrawingSize() { | 2484 function calculateDrawingSize() { |
2805 var lgtxt; | |
2806 var cumulativeAngle = -config.startAngle * (Math.PI / 18
0) + 2 * Math.PI, | |
2807 cumvalue = 0; | |
2808 while (cumulativeAngle < 0) { | |
2809 cumulativeAngle += 2 * Math.PI; | |
2810 } | |
2811 while (cumulativeAngle > 2 * Math.PI) { | |
2812 cumulativeAngle -= 2 * Math.PI; | |
2813 } | |
2814 midPieX = msr.leftNotUsableSize + (msr.availableWidth /
2); | 2485 midPieX = msr.leftNotUsableSize + (msr.availableWidth /
2); |
2815 midPieY = msr.topNotUsableSize + (msr.availableHeight /
2); | 2486 midPieY = msr.topNotUsableSize + (msr.availableHeight /
2); |
2816 doughnutRadius = Min([msr.availableHeight / 2, msr.avail
ableWidth / 2]) - 5; | 2487 doughnutRadius = Min([msr.availableHeight / 2, msr.avail
ableWidth / 2]) - 5; |
2817 // Computerange Pie Radius | 2488 // Computerange Pie Radius |
2818 » » » if (config.inGraphDataShow && config.inGraphDataRadiusPo
sition == 3 && config.inGraphDataAlign == "off-center" && config.inGraphDataRota
te == 0) { | 2489 » » » if (isBooleanOptionTrue(undefined,config.inGraphDataShow
) && setOptionValue("INGRAPHDATARADIUSPOSITION",ctx,data,statData,undefined,conf
ig.inGraphDataRadiusPosition,0,-1,{nullValue : true} ) == 3 && setOptionValue("I
NGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,0,-1,{nullV
alue: true }) == "off-center" && setOptionValue("INGRAPHDATAROTATE",ctx,data,st
atData,undefined,config.inGraphDataRotate,0,-1,{nullValue : true} ) == 0) { |
2819 » » » » doughnutRadius = Min([msr.availableHeight / 2, m
sr.availableWidth / 2]) - config.inGraphDataFontSize - config.inGraphDataPadding
Radius - 5; | 2490 » » » » doughnutRadius = Min([msr.availableHeight / 2, m
sr.availableWidth / 2]) - setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData
,undefined,config.inGraphDataFontSize,0,-1,{nullValue : true} ) - setOptionValue
("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddin
gRadius,0,-1,{nullValue: true} ) - 5; |
2820 » » » » var realCumulativeAngle = config.startAngle * (M
ath.PI / 180) + 2 * Math.PI; | 2491 » » » » var realCumulativeAngle = (((config.startAngle *
(Math.PI / 180) + 2 * Math.PI) % (2 * Math.PI)) + 2* Math.PI) % (2* Math.PI) ; |
2821 » » » » while (realCumulativeAngle < 0) { | |
2822 » » » » » realCumulativeAngle += 2 * Math.PI; | |
2823 » » » » } | |
2824 » » » » while (realCumulativeAngle > 2 * Math.PI) { | |
2825 » » » » » realCumulativeAngle -= 2 * Math.PI; | |
2826 » » » » } | |
2827 » » » » var totvalue = 0; | |
2828 » » » » for (var i = 0; i < data.length; i++) | |
2829 » » » » » if (!(typeof(data[i].value) == 'undefine
d')) totvalue += 1 * data[i].value; | |
2830 » » » » ctx.font = config.inGraphDataFontStyle + ' ' + c
onfig.inGraphDataFontSize + 'px ' + config.inGraphDataFontFamily; | |
2831 var posAngle; | 2492 var posAngle; |
2832 var cumulativeAngle = 0; | |
2833 for (var i = 0; i < data.length; i++) { | 2493 for (var i = 0; i < data.length; i++) { |
2834 » » » » » if (!(typeof(data[i].value) == 'undefine
d')) { | 2494 » » » » » if (!(typeof(data[i].value) == 'undefine
d') && 1*data[i].value>=0) { |
2835 » » » » » » cumvalue += 1 * data[i].value; | 2495 » » » » » » ctx.font = setOptionValue("INGRA
PHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{n
ullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statDat
a,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px ' + setOp
tionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphData
FontFamily,i,-1,{nullValue : true} ); |
2836 » » » » » » var segmentAngle = (1 * data[i].
value / segmentTotal) * (Math.PI * 2); | 2496 » » » » » » if (setOptionValue("INGRAPHDATAA
NGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{
nullValue : true} ) == 1) posAngle = realCumulativeAngle + setOptionValue("INGRA
PHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingAngle,i,
-1,{nullValue: true }) * (Math.PI / 180); |
2837 » » » » » » cumulativeAngle += segmentAngle; | 2497 » » » » » » else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 2) posAngle = realCumulativeAngle - statData[i].segm
entAngle / 2 + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefin
ed,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180); |
2838 » » » » » » if (config.inGraphDataAnglePosit
ion == 1) posAngle = realCumulativeAngle + config.inGraphDataPaddingAngle * (Mat
h.PI / 180); | 2498 » » » » » » else if (setOptionValue("INGRAPH
DATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i
,-1,{nullValue : true} ) == 3) posAngle = realCumulativeAngle - statData[i].segm
entAngle + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,c
onfig.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180); |
2839 » » » » » » else if (config.inGraphDataAngle
Position == 2) posAngle = realCumulativeAngle - segmentAngle / 2 + config.inGrap
hDataPaddingAngle * (Math.PI / 180); | 2499 » » » » » » realCumulativeAngle -= statData[
i].segmentAngle; |
2840 » » » » » » else if (config.inGraphDataAngle
Position == 3) posAngle = realCumulativeAngle - segmentAngle + config.inGraphDat
aPaddingAngle * (Math.PI / 180); | 2500 » » » » » » var dispString = tmplbis(setOpti
onValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-
1,{nullValue : true} ), statData[i]); |
2841 » » » » » » realCumulativeAngle -= segmentAn
gle; | |
2842 » » » » » » if (typeof(data[i].title) == "st
ring") lgtxt = data[i].title.trim(); | |
2843 » » » » » » else lgtxt = ""; | |
2844 » » » » » » var dispString = tmplbis(config.
inGraphDataTmpl, { | |
2845 » » » » » » » config: config, | |
2846 » » » » » » » v1: fmtChartJS(config, l
gtxt, config.fmtV1), | |
2847 » » » » » » » v2: fmtChartJS(config, 1
* data[i].value, config.fmtV2), | |
2848 » » » » » » » v3: fmtChartJS(config, c
umvalue, config.fmtV3), | |
2849 » » » » » » » v4: fmtChartJS(config, t
otvalue, config.fmtV4), | |
2850 » » » » » » » v5: fmtChartJS(config, s
egmentAngle, config.fmtV5), | |
2851 » » » » » » » v6: roundToWithThousands
(config, fmtChartJS(config, 100 * data[i].value / totvalue, config.fmtV6), confi
g.roundPct), | |
2852 » » » » » » » v7: fmtChartJS(config, m
idPieX, config.fmtV7), | |
2853 » » » » » » » v8: fmtChartJS(config, m
idPieY, config.fmtV8), | |
2854 » » » » » » » v9: fmtChartJS(config, c
utoutRadius, config.fmtV9), | |
2855 » » » » » » » v10: fmtChartJS(config,
doughnutRadius, config.fmtV10), | |
2856 » » » » » » » v11: fmtChartJS(config,
cumulativeAngle - segmentAngle, config.fmtV11), | |
2857 » » » » » » » v12: fmtChartJS(config,
cumulativeAngle, config.fmtV12), | |
2858 » » » » » » » v13: fmtChartJS(config,
i, config.fmtV13), | |
2859 » » » » » » » data: data | |
2860 » » » » » » }); | |
2861 var textMeasurement = ctx.measur
eText(dispString).width; | 2501 var textMeasurement = ctx.measur
eText(dispString).width; |
2862 » » » » » » var MaxRadiusX = Math.abs((msr.a
vailableWidth / 2 - textMeasurement) / Math.cos(posAngle)) - config.inGraphDataP
addingRadius - 5; | 2502 » » » » » » var MaxRadiusX = Math.abs((msr.a
vailableWidth / 2 - textMeasurement) / Math.cos(posAngle)) - setOptionValue("ING
RAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadi
us,i,-1,{nullValue: true} ) - 5; |
2863 if (MaxRadiusX < doughnutRadius)
doughnutRadius = MaxRadiusX; | 2503 if (MaxRadiusX < doughnutRadius)
doughnutRadius = MaxRadiusX; |
2864 } | 2504 } |
2865 } | 2505 } |
2866 } | 2506 } |
2867 doughnutRadius = doughnutRadius * config.radiusScale; | 2507 doughnutRadius = doughnutRadius * config.radiusScale; |
2868 }; | 2508 }; |
2869 }; | 2509 }; |
2870 var Line = function(data, config, ctx) { | 2510 var Line = function(data, config, ctx) { |
2871 var maxSize, scaleHop, scaleHop2, calculatedScale, calculatedSca
le2, labelHeight, scaleHeight, valueBounds, labelTemplateString, labelTemplateSt
ring2; | 2511 var maxSize, scaleHop, scaleHop2, calculatedScale, calculatedSca
le2, labelHeight, scaleHeight, valueBounds, labelTemplateString, labelTemplateSt
ring2; |
2872 var valueHop, widestXLabel, xAxisLength, yAxisPosX, xAxisPosY, r
otateLabels = 0, | 2512 var valueHop, widestXLabel, xAxisLength, yAxisPosX, xAxisPosY, r
otateLabels = 0, |
2873 msr; | 2513 msr; |
2874 var zeroY = 0; | 2514 var zeroY = 0; |
2875 var zeroY2 = 0; | 2515 var zeroY2 = 0; |
2876 var offsets = []; | |
2877 ctx.tpchart="Line"; | 2516 ctx.tpchart="Line"; |
2878 » » setting_new_chart_vars(ctx); | 2517 » if (!init_and_start(ctx,data,config)) return; |
2879 » » if (!dynamicFunction(data, config, ctx)) { | 2518 » » var statData=initPassVariableData_part1(data,config,ctx); |
2880 » » if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | |
2881 » » » return; | |
2882 » » } | |
2883 » if(config.responsive && typeof ctx.firstPass == "undefined") { | |
2884 » » if(!config.multiGraph) { | |
2885 » » » » addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
2886 » » » subUpdateChart(ctx,data,config); | |
2887 » » » return; | |
2888 » » } else { ctx.firstPass=1; } | |
2889 » » } | |
2890 | |
2891 // adapt data when length is 1; | 2519 // adapt data when length is 1; |
2892 var mxlgt = 0; | 2520 var mxlgt = 0; |
2893 » » for (var i = 0; i < data.datasets.length; i++) mxlgt = Max([mxlg
t, data.datasets[i].data.length]); | 2521 » » for (var i = 0; i < data.datasets.length; i++) {statData[i][0].t
pchart="Line";mxlgt = Max([mxlgt, data.datasets[i].data.length]);} |
2894 if (mxlgt == 1) { | 2522 if (mxlgt == 1) { |
2895 if (typeof(data.labels[0]) == "string") data.labels = ["
", data.labels[0], ""]; | 2523 if (typeof(data.labels[0]) == "string") data.labels = ["
", data.labels[0], ""]; |
2896 for (var i = 0; i < data.datasets.length; i++) { | 2524 for (var i = 0; i < data.datasets.length; i++) { |
2897 if (typeof(data.datasets[i].data[0] != "undefine
d")) data.datasets[i].data = [undefined, data.datasets[i].data[0], undefined]; | 2525 if (typeof(data.datasets[i].data[0] != "undefine
d")) data.datasets[i].data = [undefined, data.datasets[i].data[0], undefined]; |
2898 } | 2526 } |
2899 } | 2527 } |
2900 | |
2901 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
2902 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
2903 defMouse(ctx, data, config); | |
2904 setRect(ctx, config); | |
2905 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], false, false, true, true, config.datasetFill, "Line"); | 2528 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], false, false, true, true, config.datasetFill, "Line"); |
2906 valueBounds = getValueBounds(); | 2529 valueBounds = getValueBounds(); |
2907 // true or fuzzy (error for negativ values (included 0)) | 2530 // true or fuzzy (error for negativ values (included 0)) |
2908 if (config.logarithmic !== false) { | 2531 if (config.logarithmic !== false) { |
2909 if (valueBounds.minValue <= 0) { | 2532 if (valueBounds.minValue <= 0) { |
2910 config.logarithmic = false; | 2533 config.logarithmic = false; |
2911 } | 2534 } |
2912 } | 2535 } |
2913 if (config.logarithmic2 !== false) { | 2536 if (config.logarithmic2 !== false) { |
2914 if (valueBounds.minValue2 <= 0) { | 2537 if (valueBounds.minValue2 <= 0) { |
(...skipping 11 matching lines...) Expand all Loading... |
2926 config.logarithmic2 = false; | 2549 config.logarithmic2 = false; |
2927 } | 2550 } |
2928 //Check and set the scale | 2551 //Check and set the scale |
2929 labelTemplateString = (config.scaleShowLabels) ? config.scaleLab
el : ""; | 2552 labelTemplateString = (config.scaleShowLabels) ? config.scaleLab
el : ""; |
2930 labelTemplateString2 = (config.scaleShowLabels2) ? config.scaleL
abel2 : ""; | 2553 labelTemplateString2 = (config.scaleShowLabels2) ? config.scaleL
abel2 : ""; |
2931 if (!config.scaleOverride) { | 2554 if (!config.scaleOverride) { |
2932 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { | 2555 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { |
2933 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); | 2556 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); |
2934 } | 2557 } |
2935 } else { | 2558 } else { |
| 2559 var scaleStartValue= setOptionValue("SCALESTARTVALUE",ct
x,data,statData,undefined,config.scaleStartValue,-1,-1,{nullValue : true} ); |
| 2560 var scaleSteps =setOptionValue("SCALESTEPS",ctx,data,sta
tData,undefined,config.scaleSteps,-1,-1,{nullValue : true} ); |
| 2561 var scaleStepWidth = setOptionValue("SCALESTEPWIDTH",ctx
,data,statData,undefined,config.scaleStepWidth,-1,-1,{nullValue : true} ); |
2936 calculatedScale = { | 2562 calculatedScale = { |
2937 » » » » steps: config.scaleSteps, | 2563 » » » » steps: scaleSteps, |
2938 » » » » stepValue: config.scaleStepWidth, | 2564 » » » » stepValue: scaleStepWidth, |
2939 » » » » graphMin: config.scaleStartValue, | 2565 » » » » graphMin: scaleStartValue, |
2940 » » » » graphMax: config.scaleStartValue + config.scaleS
teps * config.scaleStepWidth, | 2566 » » » » graphMax: scaleStartValue + scaleSteps * scaleSt
epWidth, |
2941 labels: [] | 2567 labels: [] |
2942 } | 2568 } |
2943 » » » populateLabels(1, config, labelTemplateString, calculate
dScale.labels, calculatedScale.steps, config.scaleStartValue, calculatedScale.gr
aphMax, config.scaleStepWidth); | 2569 » » » populateLabels(1, config, labelTemplateString, calculate
dScale.labels, calculatedScale.steps, scaleStartValue, calculatedScale.graphMax,
scaleStepWidth); |
2944 } | 2570 } |
2945 | 2571 |
2946 if (valueBounds.dbAxis) { | 2572 if (valueBounds.dbAxis) { |
2947 if (!config.scaleOverride2) { | 2573 if (!config.scaleOverride2) { |
2948 if(valueBounds.maxSteps>0 && valueBounds.minStep
s>0) { | 2574 if(valueBounds.maxSteps>0 && valueBounds.minStep
s>0) { |
2949 calculatedScale2 = calculateScale(2, con
fig, valueBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue2, valueBou
nds.minValue2, labelTemplateString); | 2575 calculatedScale2 = calculateScale(2, con
fig, valueBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue2, valueBou
nds.minValue2, labelTemplateString); |
2950 } | 2576 } |
2951 } else { | 2577 } else { |
| 2578 var scaleStartValue2= setOptionValue("SCALESTART
VALUE2",ctx,data,statData,undefined,config.scaleStartValue2,-1,-1,{nullValue : t
rue} ); |
| 2579 var scaleSteps2 =setOptionValue("SCALESTEPS2",ct
x,data,statData,undefined,config.scaleSteps2,-1,-1,{nullValue : true} ); |
| 2580 var scaleStepWidth2 = setOptionValue("SCALESTEPW
IDTH2",ctx,data,statData,undefined,config.scaleStepWidth2,-1,-1,{nullValue : tru
e} ); |
| 2581 |
2952 calculatedScale2 = { | 2582 calculatedScale2 = { |
2953 » » » » » steps: config.scaleSteps2, | 2583 » » » » » steps: scaleSteps2, |
2954 » » » » » stepValue: config.scaleStepWidth2, | 2584 » » » » » stepValue: scaleStepWidth2, |
2955 » » » » » graphMin: config.scaleStartValue2, | 2585 » » » » » graphMin: scaleStartValue2, |
2956 » » » » » graphMax: config.scaleStartValue2 + conf
ig.scaleSteps2 * config.scaleStepWidth2, | 2586 » » » » » graphMax: scaleStartValue2 + scaleSteps2
* scaleStepWidth2, |
2957 labels: [] | 2587 labels: [] |
2958 } | 2588 } |
2959 » » » » populateLabels(2, config, labelTemplateString2,
calculatedScale2.labels, calculatedScale2.steps, config.scaleStartValue2, calcul
atedScale2.graphMax, config.scaleStepWidth2); | 2589 » » » » populateLabels(2, config, labelTemplateString2,
calculatedScale2.labels, calculatedScale2.steps, scaleStartValue2, calculatedSca
le2.graphMax, scaleStepWidth2); |
2960 } | 2590 } |
2961 } else { | 2591 } else { |
2962 calculatedScale2 = { | 2592 calculatedScale2 = { |
2963 steps: 0, | 2593 steps: 0, |
2964 stepValue: 0, | 2594 stepValue: 0, |
2965 graphMin: 0, | 2595 graphMin: 0, |
2966 graphMax: 0, | 2596 graphMax: 0, |
2967 labels: null | 2597 labels: null |
2968 } | 2598 } |
2969 } | 2599 } |
(...skipping 13 matching lines...) Expand all Loading... |
2983 msr.clrheight+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); | 2613 msr.clrheight+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); |
2984 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; | 2614 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; |
2985 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; | 2615 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; |
2986 drawLabels(); | 2616 drawLabels(); |
2987 if (valueBounds.minValue < 0) { | 2617 if (valueBounds.minValue < 0) { |
2988 zeroY = calculateOffset(config.logarithmic, 0, c
alculatedScale, scaleHop); | 2618 zeroY = calculateOffset(config.logarithmic, 0, c
alculatedScale, scaleHop); |
2989 } | 2619 } |
2990 if (valueBounds.minValue2 < 0) { | 2620 if (valueBounds.minValue2 < 0) { |
2991 zeroY2 = calculateOffset(config.logarithmic2, 0,
calculatedScale2, scaleHop2); | 2621 zeroY2 = calculateOffset(config.logarithmic2, 0,
calculatedScale2, scaleHop2); |
2992 } | 2622 } |
2993 » » » for (var i = 0; i < data.datasets.length; i++) { | 2623 » » » initPassVariableData_part2(statData,data,config,ctx,{ |
2994 » » » » offsets[i] = []; | 2624 » » » » xAxisPosY : xAxisPosY, |
2995 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | 2625 » » » » yAxisPosX : yAxisPosX, |
2996 » » » » » if (data.datasets[i].axis == 2) { | 2626 » » » » valueHop : valueHop, |
2997 » » » » » » offsets[i][j] = (calculateOffset
(config.logarithmic2, data.datasets[i].data[j], calculatedScale2, scaleHop2) - z
eroY2); | 2627 » » » » nbValueHop : data.labels.length - 1, |
2998 » » » » » } else { | 2628 » » » » scaleHop : scaleHop, |
2999 » » » » » » offsets[i][j] = (calculateOffset
(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop) - zero
Y); | 2629 » » » » zeroY : zeroY, |
3000 » » » » » } | 2630 » » » » calculatedScale : calculatedScale, |
3001 » » » » } | 2631 » » » » logarithmic : config.logarithmic, |
3002 » » » } | 2632 » » » » scaleHop2: scaleHop2, |
| 2633 » » » » zeroY2: zeroY2, |
| 2634 » » » » msr : msr, |
| 2635 » » » » calculatedScale2: calculatedScale2, |
| 2636 » » » » logarithmic2: config.logarithmic2} ); |
3003 animationLoop(config, drawScale, drawLines, ctx, msr.clr
x, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xA
xisPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); | 2637 animationLoop(config, drawScale, drawLines, ctx, msr.clr
x, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xA
xisPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); |
3004 } else { | 2638 } else { |
3005 testRedraw(ctx,data,config); | 2639 testRedraw(ctx,data,config); |
3006 } | 2640 } |
3007 | 2641 |
3008 | 2642 |
3009 function drawLines(animPc) { | 2643 function drawLines(animPc) { |
3010 » » » drawLinesDataset(1, animPc, data, config, ctx, offsets,
{ | 2644 » » |
3011 » » » » xAxisPosY: xAxisPosY, | 2645 » » » drawLinesDataset(animPc, data, config, ctx, statData,{xA
xisPosY : xAxisPosY,yAxisPosX : yAxisPosX, valueHop : valueHop, nbValueHop : dat
a.labels.length - 1 }); |
3012 » » » » yAxisPosX: yAxisPosX, | |
3013 » » » » valueHop: valueHop, | |
3014 » » » » nbValueHop: data.labels.length - 1, | |
3015 » » » » scaleHop: scaleHop, | |
3016 » » » » zeroY: zeroY, | |
3017 » » » » calculatedScale: calculatedScale, | |
3018 » » » » logarithmic: config.logarithmic | |
3019 » » » }); | |
3020 » » » drawLinesDataset(2, animPc, data, config, ctx, offsets,
{ | |
3021 » » » » xAxisPosY: xAxisPosY, | |
3022 » » » » yAxisPosX: yAxisPosX, | |
3023 » » » » valueHop: valueHop, | |
3024 » » » » nbValueHop: data.labels.length - 1, | |
3025 » » » » scaleHop: scaleHop2, | |
3026 » » » » zeroY: zeroY2, | |
3027 » » » » calculatedScale: calculatedScale2, | |
3028 » » » » logarithmic: config.logarithmic2 | |
3029 » » » }); | |
3030 | |
3031 | |
3032 if (animPc >= 1) { | 2646 if (animPc >= 1) { |
3033 if (typeof drawMath == "function") { | 2647 if (typeof drawMath == "function") { |
3034 drawMath(ctx, config, data, msr, { | 2648 drawMath(ctx, config, data, msr, { |
3035 xAxisPosY: xAxisPosY, | 2649 xAxisPosY: xAxisPosY, |
3036 yAxisPosX: yAxisPosX, | 2650 yAxisPosX: yAxisPosX, |
3037 valueHop: valueHop, | 2651 valueHop: valueHop, |
3038 scaleHop: scaleHop, | 2652 scaleHop: scaleHop, |
3039 zeroY: zeroY, | 2653 zeroY: zeroY, |
3040 calculatedScale: calculatedScale
, | 2654 calculatedScale: calculatedScale
, |
3041 » » » » » » calculateOffset: calculateOffset | 2655 » » » » » » calculateOffset: calculateOffset
, |
| 2656 » » » » » » statData : statData |
| 2657 |
3042 }); | 2658 }); |
3043 } | 2659 } |
3044 } | 2660 } |
3045 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Line"); | 2661 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Line"); |
3046 }; | 2662 }; |
3047 | 2663 |
3048 function drawScale() { | 2664 function drawScale() { |
3049 //X axis line | 2665 //X axis line |
3050 // if the xScale should be drawn | 2666 // if the xScale should be drawn |
3051 if (config.drawXScaleLine !== false) { | 2667 if (config.drawXScaleLine !== false) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 } else { | 2740 } else { |
3125 ctx.textAlign = "center"; | 2741 ctx.textAlign = "center"; |
3126 } | 2742 } |
3127 ctx.fillStyle = config.scaleFontColor; | 2743 ctx.fillStyle = config.scaleFontColor; |
3128 if (config.xAxisBottom) { | 2744 if (config.xAxisBottom) { |
3129 for (var i = 0; i < data.labels.length;
i++) { | 2745 for (var i = 0; i < data.labels.length;
i++) { |
3130 ctx.save(); | 2746 ctx.save(); |
3131 if (msr.rotateLabels > 0) { | 2747 if (msr.rotateLabels > 0) { |
3132 ctx.translate(yAxisPosX
+ i * valueHop - msr.highestXLabel / 2, msr.xLabelPos); | 2748 ctx.translate(yAxisPosX
+ i * valueHop - msr.highestXLabel / 2, msr.xLabelPos); |
3133 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); | 2749 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); |
3134 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize); | 2750 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize,true); |
3135 } else { | 2751 } else { |
3136 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + i * valueHop, ms
r.xLabelPos, ctx.textBaseline, config.scaleFontSize); | 2752 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + i * valueHop, ms
r.xLabelPos, ctx.textBaseline, config.scaleFontSize,true); |
3137 } | 2753 } |
3138 ctx.restore(); | 2754 ctx.restore(); |
3139 } | 2755 } |
3140 } | 2756 } |
3141 } | 2757 } |
3142 //Y Labels | 2758 //Y Labels |
3143 ctx.textAlign = "right"; | 2759 ctx.textAlign = "right"; |
3144 ctx.textBaseline = "middle"; | 2760 ctx.textBaseline = "middle"; |
3145 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { | 2761 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { |
3146 if (config.scaleShowLabels) { | 2762 if (config.scaleShowLabels) { |
3147 if (config.yAxisLeft) { | 2763 if (config.yAxisLeft) { |
3148 ctx.textAlign = "right"; | 2764 ctx.textAlign = "right"; |
3149 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRi
ght), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline, config.scaleFontSize); | 2765 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRi
ght), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline, config.scaleFontSize,t
rue); |
3150 } | 2766 } |
3151 if (config.yAxisRight && !valueBounds.db
Axis) { | 2767 if (config.yAxisRight && !valueBounds.db
Axis) { |
3152 ctx.textAlign = "left"; | 2768 ctx.textAlign = "left"; |
3153 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight
+ config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline,
config.scaleFontSize); | 2769 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight
+ config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline,
config.scaleFontSize,true); |
3154 } | 2770 } |
3155 } | 2771 } |
3156 } | 2772 } |
3157 if (config.yAxisRight && valueBounds.dbAxis) { | 2773 if (config.yAxisRight && valueBounds.dbAxis) { |
3158 for (var j = ((config.showYAxisMin) ? -1 : 0); j
< calculatedScale2.steps; j++) { | 2774 for (var j = ((config.showYAxisMin) ? -1 : 0); j
< calculatedScale2.steps; j++) { |
3159 if (config.scaleShowLabels) { | 2775 if (config.scaleShowLabels) { |
3160 ctx.textAlign = "left"; | 2776 ctx.textAlign = "left"; |
3161 » » » » » » ctx.fillTextMultiLine(calculated
Scale2.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRigh
t + config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop2), ctx.textBaseline
, config.scaleFontSize); | 2777 » » » » » » ctx.fillTextMultiLine(calculated
Scale2.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRigh
t + config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop2), ctx.textBaseline
, config.scaleFontSize,true); |
3162 } | 2778 } |
3163 } | 2779 } |
3164 } | 2780 } |
3165 }; | 2781 }; |
3166 | 2782 |
3167 function getValueBounds() { | 2783 function getValueBounds() { |
3168 » » » var upperValue = Number.MIN_VALUE; | 2784 » » » var upperValue = -Number.MAX_VALUE; |
3169 var lowerValue = Number.MAX_VALUE; | 2785 var lowerValue = Number.MAX_VALUE; |
3170 » » » var upperValue2 = Number.MIN_VALUE; | 2786 » » » var upperValue2 = -Number.MAX_VALUE; |
3171 var lowerValue2 = Number.MAX_VALUE; | 2787 var lowerValue2 = Number.MAX_VALUE; |
3172 var secondAxis = false; | 2788 var secondAxis = false; |
3173 var firstAxis = false; | 2789 var firstAxis = false; |
3174 for (var i = 0; i < data.datasets.length; i++) { | 2790 for (var i = 0; i < data.datasets.length; i++) { |
3175 var mathFctName = data.datasets[i].drawMathDevia
tion; | 2791 var mathFctName = data.datasets[i].drawMathDevia
tion; |
3176 var mathValueHeight = 0; | 2792 var mathValueHeight = 0; |
3177 if (typeof eval(mathFctName) == "function") { | 2793 if (typeof eval(mathFctName) == "function") { |
3178 var parameter = { | 2794 var parameter = { |
3179 data: data, | 2795 data: data, |
3180 datasetNr: i | 2796 datasetNr: i |
3181 }; | 2797 }; |
3182 mathValueHeight = window[mathFctName](pa
rameter); | 2798 mathValueHeight = window[mathFctName](pa
rameter); |
3183 } | 2799 } |
3184 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 2800 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
| 2801 if(typeof data.datasets[i].data[j] == "u
ndefined") continue; |
3185 if (data.datasets[i].axis == 2) { | 2802 if (data.datasets[i].axis == 2) { |
3186 secondAxis = true; | 2803 secondAxis = true; |
3187 if (1 * data.datasets[i].data[j]
+ mathValueHeight > upperValue2) { | 2804 if (1 * data.datasets[i].data[j]
+ mathValueHeight > upperValue2) { |
3188 upperValue2 = 1 * data.d
atasets[i].data[j] + mathValueHeight | 2805 upperValue2 = 1 * data.d
atasets[i].data[j] + mathValueHeight |
3189 }; | 2806 }; |
3190 if (1 * data.datasets[i].data[j]
- mathValueHeight < lowerValue2) { | 2807 if (1 * data.datasets[i].data[j]
- mathValueHeight < lowerValue2) { |
3191 lowerValue2 = 1 * data.d
atasets[i].data[j] - mathValueHeight | 2808 lowerValue2 = 1 * data.d
atasets[i].data[j] - mathValueHeight |
3192 }; | 2809 }; |
3193 } else { | 2810 } else { |
3194 firstAxis = true; | 2811 firstAxis = true; |
3195 if (1 * data.datasets[i].data[j]
+ mathValueHeight > upperValue) { | 2812 if (1 * data.datasets[i].data[j]
+ mathValueHeight > upperValue) { |
3196 upperValue = 1 * data.da
tasets[i].data[j] + mathValueHeight | 2813 upperValue = 1 * data.da
tasets[i].data[j] + mathValueHeight |
3197 }; | 2814 }; |
3198 if (1 * data.datasets[i].data[j]
- mathValueHeight < lowerValue) { | 2815 if (1 * data.datasets[i].data[j]
- mathValueHeight < lowerValue) { |
3199 lowerValue = 1 * data.da
tasets[i].data[j] - mathValueHeight | 2816 lowerValue = 1 * data.da
tasets[i].data[j] - mathValueHeight |
3200 }; | 2817 }; |
3201 } | 2818 } |
3202 } | 2819 } |
3203 }; | 2820 }; |
3204 » » » if (Math.abs(upperValue - lowerValue) < 0.00000001) { | 2821 » » » if(upperValue<lowerValue){upperValue=0;lowerValue=0;} |
3205 » » » » upperValue = Max([upperValue * 2, 1]); | 2822 » » » if (Math.abs(upperValue - lowerValue) < config.zeroValue
) { |
3206 » » » » lowerValue = 0; | 2823 » » » » if(Math.abs(upperValue)< config.zeroValue) upper
Value = .9; |
| 2824 » » » » if(upperValue>0) { |
| 2825 » » » » » upperValue=upperValue*1.1; |
| 2826 » » » » » lowerValue=lowerValue*0.9; |
| 2827 » » » » } else { |
| 2828 » » » » » upperValue=upperValue*0.9; |
| 2829 » » » » » lowerValue=lowerValue*1.1; |
| 2830 » » » » } |
| 2831 » » » » |
3207 } | 2832 } |
3208 » » » if (!isNaN(config.graphMin)) lowerValue = config.graphMi
n; | 2833 » » » if(typeof config.graphMin=="function")lowerValue= setOpt
ionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin,-1,-1,{nullValue
: true}) |
3209 » » » if (!isNaN(config.graphMax)) upperValue = config.graphMa
x; | 2834 » » » else if (!isNaN(config.graphMin)) lowerValue = config.gr
aphMin; |
| 2835 » » » if(typeof config.graphMax=="function") upperValue= setOp
tionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax,-1,-1,{nullValu
e : true}) |
| 2836 » » » else if (!isNaN(config.graphMax)) upperValue = config.gr
aphMax; |
| 2837 |
3210 if (secondAxis) { | 2838 if (secondAxis) { |
3211 » » » » if (Math.abs(upperValue2 - lowerValue2) < 0.0000
0001) { | 2839 » » » » if(upperValue2<lowerValue2){upperValue2=0;lowerV
alue2=0;} |
3212 » » » » » upperValue2 = Max([upperValue2 * 2, 1]); | 2840 » » » » if (Math.abs(upperValue2 - lowerValue2) < config
.zeroValue) { |
3213 » » » » » lowerValue2 = 0; | 2841 » » » » » if(Math.abs(upperValue2)< config.zeroVal
ue) upperValue2 = .9; |
| 2842 » » » » » if(upperValue2>0) { |
| 2843 » » » » » » upperValue2=upperValue2*1.1; |
| 2844 » » » » » » lowerValue2=lowerValue2*0.9; |
| 2845 » » » » » } else { |
| 2846 » » » » » » upperValue2=upperValue2*0.9; |
| 2847 » » » » » » lowerValue2=lowerValue2*1.1; |
| 2848 » » » » » } |
3214 } | 2849 } |
3215 » » » » if (!isNaN(config.graphMin2)) lowerValue2 = conf
ig.graphMin2; | 2850 » » » » if(typeof config.graphMin2=="function")lowerValu
e2= setOptionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin2,-1,-1
,{nullValue : true}) |
3216 » » » » if (!isNaN(config.graphMax2)) upperValue2 = conf
ig.graphMax2; | 2851 » » » » else if (!isNaN(config.graphMin2)) lowerValue2 =
config.graphMin2; |
| 2852 » » » » if(typeof config.graphMax2=="function") upperVal
ue2= setOptionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax2,-1,-
1,{nullValue : true}) |
| 2853 » » » » else if (!isNaN(config.graphMax2)) upperValue2 =
config.graphMax2; |
3217 } | 2854 } |
| 2855 |
3218 if (!firstAxis && secondAxis) { | 2856 if (!firstAxis && secondAxis) { |
3219 upperValue = upperValue2; | 2857 upperValue = upperValue2; |
3220 lowerValue = lowerValue2; | 2858 lowerValue = lowerValue2; |
3221 } | 2859 } |
| 2860 |
3222 labelHeight = config.scaleFontSize; | 2861 labelHeight = config.scaleFontSize; |
3223 scaleHeight = msr.availableHeight; | 2862 scaleHeight = msr.availableHeight; |
3224 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); | 2863 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); |
3225 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); | 2864 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); |
3226 return { | 2865 return { |
3227 maxValue: upperValue, | 2866 maxValue: upperValue, |
3228 minValue: lowerValue, | 2867 minValue: lowerValue, |
3229 maxValue2: upperValue2, | 2868 maxValue2: upperValue2, |
3230 minValue2: lowerValue2, | 2869 minValue2: lowerValue2, |
3231 dbAxis: secondAxis, | 2870 dbAxis: secondAxis, |
3232 maxSteps: maxSteps, | 2871 maxSteps: maxSteps, |
3233 minSteps: minSteps | 2872 minSteps: minSteps |
3234 }; | 2873 }; |
3235 }; | 2874 }; |
3236 }; | 2875 }; |
3237 var StackedBar = function(data, config, ctx) { | 2876 var StackedBar = function(data, config, ctx) { |
3238 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPo
sX, xAxisPosY, barWidth, rotateLabels = 0, | 2877 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPo
sX, xAxisPosY, barWidth, rotateLabels = 0, |
3239 msr; | 2878 msr; |
3240 ctx.tpchart="StackedBar"; | 2879 ctx.tpchart="StackedBar"; |
3241 » » setting_new_chart_vars(ctx); | 2880 » if (!init_and_start(ctx,data,config)) return; |
3242 » » if (!dynamicFunction(data, config, ctx)) { | 2881 » » var statData=initPassVariableData_part1(data,config,ctx); |
3243 » » if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | |
3244 » » » return; | |
3245 » » } | |
3246 » if(config.responsive && typeof ctx.firstPass == "undefined") { | |
3247 » » if(!config.multiGraph) { | |
3248 » » » » addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
3249 » » » subUpdateChart(ctx,data,config); | |
3250 » » » return; | |
3251 » » } else { ctx.firstPass=1; } | |
3252 » » } | |
3253 | 2882 |
3254 config.logarithmic = false; | 2883 config.logarithmic = false; |
3255 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
3256 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
3257 defMouse(ctx, data, config); | |
3258 setRect(ctx, config); | |
3259 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, false, true, true, true, "StackedBar"); | 2884 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, false, true, true, true, "StackedBar"); |
3260 valueBounds = getValueBounds(); | 2885 valueBounds = getValueBounds(); |
3261 | 2886 |
3262 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { | 2887 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { |
3263 //Check and set the scale | 2888 //Check and set the scale |
3264 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; | 2889 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; |
3265 if (!config.scaleOverride) { | 2890 if (!config.scaleOverride) { |
3266 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); | 2891 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); |
3267 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, false, true, true, true, "StackedBar"); | 2892 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, false, true, true, true, "StackedBar"); |
3268 } else { | 2893 } else { |
| 2894 var scaleStartValue= setOptionValue("SCALESTARTV
ALUE",ctx,data,statData,undefined,config.scaleStartValue,-1,-1,{nullValue : true
} ); |
| 2895 var scaleSteps =setOptionValue("SCALESTEPS",ctx,
data,statData,undefined,config.scaleSteps,-1,-1,{nullValue : true} ); |
| 2896 var scaleStepWidth = setOptionValue("SCALESTEPWI
DTH",ctx,data,statData,undefined,config.scaleStepWidth,-1,-1,{nullValue : true}
); |
| 2897 |
3269 calculatedScale = { | 2898 calculatedScale = { |
3270 » » » » » steps: config.scaleSteps, | 2899 » » » » » steps: scaleSteps, |
3271 » » » » » stepValue: config.scaleStepWidth, | 2900 » » » » » stepValue: scaleStepWidth, |
3272 » » » » » graphMin: config.scaleStartValue, | 2901 » » » » » graphMin: scaleStartValue, |
3273 labels: [] | 2902 labels: [] |
3274 } | 2903 } |
3275 for (var i = 0; i <= calculatedScale.steps; i++)
{ | 2904 for (var i = 0; i <= calculatedScale.steps; i++)
{ |
3276 if (labelTemplateString) { | 2905 if (labelTemplateString) { |
3277 calculatedScale.labels.push(tmpl
(labelTemplateString, { | 2906 calculatedScale.labels.push(tmpl
(labelTemplateString, { |
3278 » » » » » » » value: fmtChartJS(config
, 1 * ((config.scaleStartValue + (config.scaleStepWidth * i)).toFixed(getDecimal
Places(config.scaleStepWidth))), config.fmtYLabel) | 2907 » » » » » » » value: fmtChartJS(config
, 1 * ((scaleStartValue + (scaleStepWidth * i)).toFixed(getDecimalPlaces(scaleSt
epWidth))), config.fmtYLabel) |
3279 })); | 2908 })); |
3280 } | 2909 } |
3281 } | 2910 } |
3282 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, false, true, true, true, "StackedBar"); | 2911 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, false, true, true, true, "StackedBar"); |
3283 } | 2912 } |
3284 | 2913 |
3285 var prevHeight=msr.availableHeight; | 2914 var prevHeight=msr.availableHeight; |
3286 | 2915 |
3287 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; | 2916 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; |
3288 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; | 2917 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; |
3289 scaleHop = Math.floor(msr.availableHeight / calculatedSc
ale.steps); | 2918 scaleHop = Math.floor(msr.availableHeight / calculatedSc
ale.steps); |
3290 valueHop = Math.floor(msr.availableWidth / (data.labels.
length)); | 2919 valueHop = Math.floor(msr.availableWidth / (data.labels.
length)); |
3291 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / data.labels.length); | 2920 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / data.labels.length); |
3292 msr.clrwidth = msr.clrwidth - (msr.availableWidth - ((da
ta.labels.length) * valueHop)); | 2921 msr.clrwidth = msr.clrwidth - (msr.availableWidth - ((da
ta.labels.length) * valueHop)); |
3293 msr.availableWidth = (data.labels.length) * valueHop; | 2922 msr.availableWidth = (data.labels.length) * valueHop; |
3294 msr.availableHeight = (calculatedScale.steps) * scaleHop
; | 2923 msr.availableHeight = (calculatedScale.steps) * scaleHop
; |
3295 msr.xLabelPos+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); | 2924 msr.xLabelPos+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); |
3296 msr.clrheight+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); | 2925 msr.clrheight+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); |
3297 | 2926 |
3298 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; | 2927 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; |
3299 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; | 2928 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; |
3300 barWidth = (valueHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * data.datasets.length -
1) - (config.barStrokeWidth / 2) - 1); | 2929 barWidth = (valueHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * data.datasets.length -
1) - (config.barStrokeWidth / 2) - 1); |
3301 if(barWidth>=0 && barWidth<=1)barWidth=1; | 2930 if(barWidth>=0 && barWidth<=1)barWidth=1; |
3302 if(barWidth<0 && barWidth>=-1)barWidth=-1; | 2931 if(barWidth<0 && barWidth>=-1)barWidth=-1; |
3303 | 2932 |
3304 drawLabels(); | 2933 drawLabels(); |
| 2934 initPassVariableData_part2(statData,data,config,ctx,{ |
| 2935 calculatedScale : calculatedScale, |
| 2936 scaleHop : scaleHop, |
| 2937 valueHop : valueHop, |
| 2938 yAxisPosX : yAxisPosX, |
| 2939 xAxisPosY : xAxisPosY, |
| 2940 barWidth : barWidth |
| 2941 }); |
3305 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); | 2942 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); |
3306 } else { | 2943 } else { |
3307 testRedraw(ctx,data,config); | 2944 testRedraw(ctx,data,config); |
3308 } | 2945 } |
3309 function drawBars(animPc) { | 2946 function drawBars(animPc) { |
3310 ctx.lineWidth = config.barStrokeWidth; | 2947 ctx.lineWidth = config.barStrokeWidth; |
3311 var tempp = new Array(data.datasets.length); | |
3312 var tempn = new Array(data.datasets.length); | |
3313 var cumvalue = new Array(); | |
3314 var totvalue = new Array(); | |
3315 for (var i = 0; i < data.datasets.length; i++) { | 2948 for (var i = 0; i < data.datasets.length; i++) { |
3316 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 2949 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
3317 cumvalue[j] = 0; | |
3318 totvalue[j] = 0; | |
3319 } | |
3320 } | |
3321 for (var i = 0; i < data.datasets.length; i++) { | |
3322 for (var j = 0; j < data.datasets[i].data.length
; j++) | |
3323 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | |
3324 totvalue[j] += 1 * data.datasets
[i].data[j]; | |
3325 } | |
3326 } | |
3327 for (var i = 0; i < data.datasets.length; i++) { | |
3328 if (animPc >= 1) { | |
3329 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
3330 else lgtxt = ""; | |
3331 } | |
3332 for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
3333 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; | 2950 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; |
3334 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; | 2951 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; |
3335 » » » » » if (i == 0) { | 2952 » » » » » if ((typeof data.datasets[i].data[j] ==
'undefined') || 1*data.datasets[i].data[j] == 0 ) continue; |
3336 » » » » » » tempp[j]=0; | 2953 » » » » » if(config.animationByDataset) { |
3337 » » » » » » tempn[j]=0; | 2954 » » » » » » var botBar=statData[i][j].yPosBo
ttom; |
3338 » » » » » » zeroY= calculateOffset(config.l
ogarithmic, 0 , calculatedScale, scaleHop); | 2955 » » » » » » var topBar=statData[i][j].yPosTo
p; |
| 2956 » » » » » » topBar=botBar+currentAnimPc*(top
Bar-botBar); |
| 2957 » » » » » } else { |
| 2958 » » » » » » var botBar=statData[statData[i][
j].firstNotMissing][j].yPosBottom - currentAnimPc*(statData[statData[i][j].first
NotMissing][j].yPosBottom-statData[i][j].yPosBottom); |
| 2959 » » » » » » var topBar=statData[statData[i][
j].firstNotMissing][j].yPosBottom - currentAnimPc*(statData[statData[i][j].first
NotMissing][j].yPosBottom-statData[i][j].yPosTop); |
3339 } | 2960 } |
3340 » » » » » var barOffset = yAxisPosX + config.barVa
lueSpacing + valueHop * j; | 2961 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data.datasets[i].fillColor,config.defaultFillColor,i,j,{animation
Value: currentAnimPc, xPosLeft : statData[i][j].xPosLeft, yPosBottom : botBar, x
PosRight : statData[i][j].xPosRight, yPosTop : topBar} ); |
3341 » » » » » if (!(typeof(data.datasets[i].data[j]) =
= 'undefined') && 1*data.datasets[i].data[j] != 0 ) { | 2962 » » » » » ctx.strokeStyle=setOptionValue("STROKECO
LOR",ctx,data,statData,data.datasets[i].strokeColor,config.defaultStrokeColor,i,
j,{nullvalue : null} ); |
3342 » » » » » » if (1*data.datasets[i].data[j]<0
) { | |
3343 » » » » » » » var botval=tempp[j]; | |
3344 » » » » » » » var topval=tempp[j]+1*da
ta.datasets[i].data[j] ; | |
3345 » » » » » » } else { | |
3346 » » » » » » » var botval=tempn[j]; | |
3347 » » » » » » » var topval=tempn[j]+1*da
ta.datasets[i].data[j] ; | |
3348 » » » » » » } | |
3349 » » » » » » if(config.animationByDataset) { | |
3350 » » » » » » » var botBar=xAxisPosY - c
alculateOffset(config.logarithmic, botval , calculatedScale, scaleHop); | |
3351 » » » » » » » var topBar=xAxisPosY -
calculateOffset(config.logarithmic, topval , calculatedScale, scaleHop); | |
3352 » » » » » » » topBar=botBar+currentAni
mPc*(topBar-botBar); | |
3353 » » » » » » } else { | |
3354 » » » » » » » var botBar=xAxisPosY -
calculateOffset(config.logarithmic, currentAnimPc* botval , calculatedScale, sca
leHop); | |
3355 » » » » » » » var topBar=xAxisPosY -
calculateOffset(config.logarithmic, currentAnimPc*topval , calculatedScale, scal
eHop); | |
3356 » » » » » » » | |
3357 » » » » » » } | |
3358 » » » » » » ctx.fillStyle = config.defaultFi
llColor; | |
3359 » » » » » » if (typeof data.datasets[i].fill
Color == "function") ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", dat
a, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "StackedBar", ctx,
barOffset, botBar , barOffset + barWidth, topBar); | |
3360 » » » » » » else if (typeof(data.datasets[i]
.fillColor) == "string") { | |
3361 » » » » » » » ctx.fillStyle = data.dat
asets[i].fillColor; | |
3362 » » » » » » } else if (typeof(data.datasets[
i].fillColor) == "object") { | |
3363 » » » » » » » if (typeof(data.datasets
[i].fillColor[0]) == "string") { | |
3364 » » » » » » » » ctx.fillStyle =
data.datasets[i].fillColor[Min([data.datasets[i].fillColor.length - 1, j])]; | |
3365 » » » » » » » } | |
3366 » » » » » » } | |
3367 » » » » » » ctx.strokeStyle = config.default
StrokeColor; | |
3368 » » » » » » if (typeof data.datasets[i].stro
keColor == "function") ctx.strokeStyle = data.datasets[i].strokeColor("STROKECOL
OR", data, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "StackedBa
r", ctx, barOffset, botBar, barOffset + barwidth, topBar); | |
3369 » » » » » » else if (typeof(data.datasets[i]
.strokeColor) == "string") { | |
3370 » » » » » » » ctx.strokeStyle = data.d
atasets[i].strokeColor; | |
3371 » » » » » » } else if (typeof(data.datasets[
i].strokeColor) == "object") { | |
3372 » » » » » » » if (typeof(data.datasets
[i].strokeColor[0]) == "string") { | |
3373 » » » » » » » » ctx.strokeStyle
= data.datasets[i].strokeColor[Min([data.datasets[i].strokeColor.length - 1, j])
]; | |
3374 » » » » » » » } | |
3375 » » » » » » } | |
3376 | 2963 |
3377 » » » » » » if(currentAnimPc !=0) { | 2964 » » » » » if(currentAnimPc !=0 && botBar!=topBar)
{ |
3378 » » » » » » » ctx.beginPath(); | 2965 » » » » » » ctx.beginPath(); |
3379 » » » » » » » ctx.moveTo(barOffset, bo
tBar); | 2966 » » » » » » ctx.moveTo(statData[i][j].xPosLe
ft, botBar); |
3380 » » » » » » » ctx.lineTo(barOffset, to
pBar); | 2967 » » » » » » ctx.lineTo(statData[i][j].xPosLe
ft, topBar); |
3381 » » » » » » » ctx.lineTo(barOffset + b
arWidth, topBar); | 2968 » » » » » » ctx.lineTo(statData[i][j].xPosRi
ght, topBar); |
3382 » » » » » » » ctx.lineTo(barOffset + b
arWidth, botBar); | 2969 » » » » » » ctx.lineTo(statData[i][j].xPosRi
ght, botBar); |
3383 » » » » » » » if (config.barShowStroke
) ctx.stroke(); | 2970 » » » » » » if (config.barShowStroke) ctx.st
roke(); |
3384 » » » » » » » ctx.closePath(); | 2971 » » » » » » ctx.closePath(); |
3385 » » » » » » » ctx.fill(); | 2972 » » » » » » ctx.fill(); |
3386 » » » » » » » cumvalue[j] += 1 * data.
datasets[i].data[j]; | |
3387 » » » » » » » if (animPc >= 1) { | |
3388 » » » » » » » » if (typeof(data.
labels[j]) == "string") lgtxt2 = data.labels[j].trim(); | |
3389 » » » » » » » » else lgtxt2 = ""
; | |
3390 //» » » » » » » » jsGraphAnnotate[
ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", barOffset, xA
xisPosY - yStart[j] + 1, barOffset + barWidth, barheight , lgtxt, lgtxt2, 1 * da
ta.datasets[i].data[j], cumvalue[j], totvalue[j], i, j]; | |
3391 » » » » » » » » if (1*data.datas
ets[i].data[j]<0) { | |
3392 » » » » » » » » » jsGraphA
nnotate[ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", barOf
fset, topBar, barOffset + barWidth, botBar , lgtxt, lgtxt2, 1 * data.datasets[i]
.data[j], cumvalue[j], totvalue[j], i, j]; | |
3393 » » » » » » » » } else { | |
3394 » » » » » » » » » jsGraphA
nnotate[ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", barOf
fset, botBar, barOffset + barWidth, topBar , lgtxt, lgtxt2, 1 * data.datasets[i]
.data[j], cumvalue[j], totvalue[j], i, j]; | |
3395 » » » » » » » » } | |
3396 » » » » » » » } | |
3397 » » » » » » } | |
3398 » » » » » » if (1*data.datasets[i].data[j]<0
) { | |
3399 » » » » » » » tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; | |
3400 » » » » » » } else { | |
3401 » » » » » » » tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; | |
3402 » » » » » » } | |
3403 } | 2973 } |
3404 } | 2974 } |
3405 } | 2975 } |
3406 » » » if (animPc >= 1 && config.inGraphDataShow) { | 2976 » » » if (animPc >= config.animationStopValue) { |
3407 » » » » var yPos = 0, | 2977 » » » » var » yPos = 0, |
3408 xPos = 0; | 2978 xPos = 0; |
3409 for (var i = 0; i < data.datasets.length; i++) { | 2979 for (var i = 0; i < data.datasets.length; i++) { |
3410 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 2980 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
3411 » » » » » » cumvalue[j] = 0; | 2981 » » » » » » if (typeof(data.datasets[i].data
[j]) == 'undefined') continue; |
3412 » » » » » } | 2982 » » » » » » if(setOptionValue("ANNOTATEDISPL
AY",ctx,data,statData,undefined,config.annotateDisplay,i,j,{nullValue : true}))
{ |
3413 » » » » } | 2983 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", i, j, statData]; |
3414 » » » » for (var i = 0; i < data.datasets.length; i++) { | |
3415 » » » » » if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
3416 » » » » » else lgtxt = ""; | |
3417 » » » » » for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | |
3418 » » » » » » if (i == 0) { | |
3419 » » » » » » » tempp[j]=0; | |
3420 » » » » » » » tempn[j]=0; | |
3421 » » » » » » » zeroY= calculateOffset(
config.logarithmic, 0 , calculatedScale, scaleHop); | |
3422 } | 2984 } |
3423 » » » » » » if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { | 2985 » » » » » » if(setOptionValue("INGRAPHDATASH
OW",ctx,data,statData,undefined,config.inGraphDataShow,i,j,{nullValue : true}))
{ |
3424 » » » » » » » if (1*data.datasets[i].d
ata[j]<0) { | |
3425 » » » » » » » » var botval=tempp
[j]; | |
3426 » » » » » » » » var topval=tempp
[j]+1*data.datasets[i].data[j] ; | |
3427 » » » » » » » } else { | |
3428 » » » » » » » » var botval=tempn
[j]; | |
3429 » » » » » » » » var topval=tempn
[j]+1*data.datasets[i].data[j] ; | |
3430 » » » » » » » } | |
3431 » » » » » » » var botBar=xAxisPosY - c
alculateOffset(config.logarithmic, botval , calculatedScale, scaleHop); | |
3432 » » » » » » » var topBar=xAxisPosY -
calculateOffset(config.logarithmic, topval , calculatedScale, scaleHop); | |
3433 ctx.save(); | 2986 ctx.save(); |
3434 » » » » » » » ctx.textAlign = config.i
nGraphDataAlign; | 2987 » » » » » » » ctx.textAlign = setOptio
nValue("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,
j,{nullValue: true }); |
3435 » » » » » » » ctx.textBaseline = confi
g.inGraphDataVAlign; | 2988 » » » » » » » ctx.textBaseline = setOp
tionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAli
gn,i,j,{nullValue : true} ); |
3436 » » » » » » » ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 2989 » » » » » » » ctx.font = setOptionValu
e("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle
,i,j,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,
statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ) + 'px ' +
setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGra
phDataFontFamily,i,j,{nullValue : true} ); |
3437 » » » » » » » ctx.fillStyle = config.i
nGraphDataFontColor; | 2990 » » » » » » » ctx.fillStyle = setOptio
nValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFont
Color,i,j,{nullValue : true} ); |
3438 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | 2991 » » » » » » » var dispString = tmplbis
(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphData
Tmpl,i,j,{nullValue : true} ), statData[i][j]); |
3439 » » » » » » » else lgtxt2 = ""; | |
3440 » » » » » » » cumvalue[j] += 1 + data.
datasets[i].data[j]; | |
3441 » » » » » » » var dispString = tmplbis
(config.inGraphDataTmpl, { | |
3442 » » » » » » » » config: config, | |
3443 » » » » » » » » v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | |
3444 » » » » » » » » v2: fmtChartJS(c
onfig, lgtxt2, config.fmtV2), | |
3445 » » » » » » » » v3: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV3), | |
3446 » » » » » » » » v4: fmtChartJS(c
onfig, cumvalue[j], config.fmtV4), | |
3447 » » » » » » » » v5: fmtChartJS(c
onfig, totvalue[j], config.fmtV5), | |
3448 » » » » » » » » v6: roundToWithT
housands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[j]
, config.fmtV6), config.roundPct), | |
3449 » » » » » » » » v7: fmtChartJS(c
onfig, barOffset, config.fmtV7), | |
3450 » » » » » » » » v8: fmtChartJS(c
onfig, xAxisPosY, config.fmtV8), | |
3451 » » » » » » » » v9: fmtChartJS(c
onfig, barOffset + barWidth, config.fmtV9), | |
3452 » » » » » » » » v10: fmtChartJS(
config, xAxisPosY - calculateOffset(config.logarithmic, data.datasets[i].data[j]
, calculatedScale, scaleHop) + (config.barStrokeWidth / 2), config.fmtV10), | |
3453 » » » » » » » » v11: fmtChartJS(
config, i, config.fmtV11), | |
3454 » » » » » » » » v12: fmtChartJS(
config, j, config.fmtV12), | |
3455 » » » » » » » » data: data | |
3456 » » » » » » » }); | |
3457 » » » » » » » var barOffset = yAxisPos
X + config.barValueSpacing + valueHop * j; | |
3458 ctx.beginPath(); | 2992 ctx.beginPath(); |
3459 ctx.beginPath(); | 2993 ctx.beginPath(); |
3460 yPos = 0; | 2994 yPos = 0; |
3461 xPos = 0; | 2995 xPos = 0; |
3462 » » » » » » » if (config.inGraphDataXP
osition == 1) { | 2996 » » » » » » » if (setOptionValue("INGR
APHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition,i,j,{n
ullValue : true} ) == 1) { |
3463 » » » » » » » » xPos = barOffset
+ config.inGraphDataPaddingX; | 2997 » » » » » » » » xPos = statData[
i][j].xPosLeft + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefine
d,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
3464 » » » » » » » } else if (config.inGrap
hDataXPosition == 2) { | 2998 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 2) { |
3465 » » » » » » » » xPos = barOffset
+ barWidth / 2 + config.inGraphDataPaddingX; | 2999 » » » » » » » » xPos = statData[
i][j].xPosLeft + barWidth / 2 + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,st
atData,undefined,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
3466 » » » » » » » } else if (config.inGrap
hDataXPosition == 3) { | 3000 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 3) { |
3467 » » » » » » » » xPos = barOffset
+ barWidth + config.inGraphDataPaddingX; | 3001 » » » » » » » » xPos = statData[
i][j].xPosLeft+ barWidth + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statDat
a,undefined,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
3468 } | 3002 } |
3469 » » » » » » » if (config.inGraphDataYP
osition == 1) { | 3003 » » » » » » » if (setOptionValue("INGR
APHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition,i,j,{n
ullValue : true} ) == 1) { |
3470 » » » » » » » » yPos = botBar -
config.inGraphDataPaddingY; | 3004 » » » » » » » » yPos = statData[
i][j].yPosBottom - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefi
ned,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
3471 » » » » » » » } else if (config.inGrap
hDataYPosition == 2) { | 3005 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 2) { |
3472 » » » » » » » » yPos = topBar -
(botbar-topbar)/2 - config.inGraphDataPaddingY; | 3006 » » » » » » » » yPos = (statData
[i][j].yPosTop + statData[i][j].yPosBottom)/2 - setOptionValue("INGRAPHDATAPADDI
NGY",ctx,data,statData,undefined,config.inGraphDataPaddingY,i,j,{nullValue : tru
e} ); |
3473 » » » » » » » } else if (config.inGrap
hDataYPosition == 3) { | 3007 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 3) { |
3474 » » » » » » » » yPos = topBar -
config.inGraphDataPaddingY; | 3008 » » » » » » » » yPos = statData[
i][j].yPosTop - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined
,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
3475 } | 3009 } |
3476 if(yPos>msr.topNotUsable
Size) { | 3010 if(yPos>msr.topNotUsable
Size) { |
3477 ctx.translate(xP
os, yPos); | 3011 ctx.translate(xP
os, yPos); |
3478 » » » » » » » » ctx.rotate(confi
g.inGraphDataRotate * (Math.PI / 180)); | 3012 » » » » » » » » ctx.rotate(setOp
tionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRota
te,i,j,{nullValue : true} ) * (Math.PI / 180)); |
3479 » » » » » » » » ctx.fillTextMult
iLine(dispString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | 3013 » » » » » » » » ctx.fillTextMult
iLine(dispString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",c
tx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),t
rue); |
3480 } | 3014 } |
3481 ctx.restore(); | 3015 ctx.restore(); |
3482 if (1*data.datasets[i].d
ata[j]<0) { | |
3483 tempp[j]=tempp[j
]+1*data.datasets[i].data[j] ; | |
3484 } else { | |
3485 tempn[j]=tempn[j
]+1*data.datasets[i].data[j] ; | |
3486 } | |
3487 } | 3016 } |
3488 } | 3017 } |
3489 } | 3018 } |
3490 } | 3019 } |
3491 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"StackedBar"); | 3020 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"StackedBar"); |
3492 }; | 3021 }; |
3493 | 3022 |
3494 function drawScale() { | 3023 function drawScale() { |
3495 //X axis line
| 3024 //X axis line
|
3496 ctx.lineWidth = config.scaleLineWidth; | 3025 ctx.lineWidth = config.scaleLineWidth; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3545 ctx.save(); | 3074 ctx.save(); |
3546 ctx.textAlign = "right"; | 3075 ctx.textAlign = "right"; |
3547 } else { | 3076 } else { |
3548 ctx.textAlign = "center"; | 3077 ctx.textAlign = "center"; |
3549 } | 3078 } |
3550 ctx.fillStyle = config.scaleFontColor; | 3079 ctx.fillStyle = config.scaleFontColor; |
3551 if (config.xAxisBottom) { | 3080 if (config.xAxisBottom) { |
3552 for (var i = 0; i < data.labels.length;
i++) { | 3081 for (var i = 0; i < data.labels.length;
i++) { |
3553 ctx.save(); | 3082 ctx.save(); |
3554 if (msr.rotateLabels > 0) { | 3083 if (msr.rotateLabels > 0) { |
3555 » » » » » » » ctx.translate(yAxisPosX
+ i * valueHop + (barWidth / 2) - msr.highestXLabel / 2, msr.xLabelPos); | 3084 » » » » » » » ctx.translate(yAxisPosX
+ config.barValueSpacing + i * valueHop + (barWidth / 2) - msr.highestXLabel / 2
, msr.xLabelPos); |
3556 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); | 3085 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); |
3557 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize); | 3086 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize,true); |
3558 } else { | 3087 } else { |
3559 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + i * valueHop + (
barWidth / 2), msr.xLabelPos, ctx.textBaseline, config.scaleFontSize); | 3088 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + config.barValueS
pacing + i * valueHop + (barWidth / 2), msr.xLabelPos, ctx.textBaseline, config.
scaleFontSize,true); |
3560 } | 3089 } |
3561 ctx.restore(); | 3090 ctx.restore(); |
3562 } | 3091 } |
3563 } | 3092 } |
3564 } | 3093 } |
3565 //Y axis | 3094 //Y axis |
3566 ctx.textAlign = "right"; | 3095 ctx.textAlign = "right"; |
3567 ctx.textBaseline = "middle"; | 3096 ctx.textBaseline = "middle"; |
3568 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { | 3097 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { |
3569 if (config.scaleShowLabels) { | 3098 if (config.scaleShowLabels) { |
3570 if (config.yAxisLeft) { | 3099 if (config.yAxisLeft) { |
3571 ctx.textAlign = "right"; | 3100 ctx.textAlign = "right"; |
3572 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRi
ght), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline, config.scaleFontSize); | 3101 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRi
ght), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline, config.scaleFontSize,t
rue); |
3573 } | 3102 } |
3574 if (config.yAxisRight) { | 3103 if (config.yAxisRight) { |
3575 ctx.textAlign = "left"; | 3104 ctx.textAlign = "left"; |
3576 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight
+ config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline,
config.scaleFontSize); | 3105 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight
+ config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline,
config.scaleFontSize,true); |
3577 } | 3106 } |
3578 } | 3107 } |
3579 } | 3108 } |
3580 }; | 3109 }; |
3581 | 3110 |
3582 function getValueBounds() { | 3111 function getValueBounds() { |
3583 » » » var upperValue = Number.MIN_VALUE; | 3112 » » » var upperValue = -Number.MAX_VALUE; |
3584 var lowerValue = Number.MAX_VALUE; | 3113 var lowerValue = Number.MAX_VALUE; |
3585 var minvl = new Array(data.datasets.length); | 3114 var minvl = new Array(data.datasets.length); |
3586 var maxvl = new Array(data.datasets.length); | 3115 var maxvl = new Array(data.datasets.length); |
3587 for (var i = 0; i < data.datasets.length; i++) { | 3116 for (var i = 0; i < data.datasets.length; i++) { |
3588 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3117 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
3589 var k = i; | 3118 var k = i; |
3590 var tempp = 0; | 3119 var tempp = 0; |
3591 var tempn = 0; | 3120 var tempn = 0; |
3592 if (!(typeof(data.datasets[0].data[j]) =
= 'undefined')) { | 3121 if (!(typeof(data.datasets[0].data[j]) =
= 'undefined')) { |
3593 if(1 * data.datasets[0].data[j]
> 0) { | 3122 if(1 * data.datasets[0].data[j]
> 0) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3625 }; | 3154 }; |
3626 if (tempn < lowe
rValue) { | 3155 if (tempn < lowe
rValue) { |
3627 lowerVal
ue = tempn; | 3156 lowerVal
ue = tempn; |
3628 }; | 3157 }; |
3629 } | 3158 } |
3630 } | 3159 } |
3631 k--; | 3160 k--; |
3632 } | 3161 } |
3633 } | 3162 } |
3634 }; | 3163 }; |
3635 » » » // AJOUT CHANGEMENT | 3164 » » » if(typeof config.graphMin=="function")lowerValue= setOpt
ionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin,-1,-1,{nullValue
: true}) |
3636 | 3165 » » » else if (!isNaN(config.graphMin)) lowerValue = config.gr
aphMin; |
3637 » » » if (!isNaN(config.graphMin)) lowerValue = config.graphMi
n; | 3166 » » » if(typeof config.graphMax=="function") upperValue= setOp
tionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax,-1,-1,{nullValu
e : true}) |
3638 » » » if (!isNaN(config.graphMax)) upperValue = config.graphMa
x; | 3167 » » » else if (!isNaN(config.graphMax)) upperValue = config.gr
aphMax; |
3639 » » » if (Math.abs(upperValue - lowerValue) < 0.00000001) { | 3168 » » » if(upperValue<lowerValue){upperValue=0;lowerValue=0;} |
3640 » » » » upperValue = Max([upperValue * 2, 1]); | 3169 » » » if (Math.abs(upperValue - lowerValue) < config.zeroValue
) { |
3641 » » » » lowerValue = 0; | 3170 » » » » if(Math.abs(upperValue)< config.zeroValue) upper
Value = .9; |
| 3171 » » » » if(upperValue>0) { |
| 3172 » » » » » upperValue=upperValue*1.1; |
| 3173 » » » » » lowerValue=lowerValue*0.9; |
| 3174 » » » » } else { |
| 3175 » » » » » upperValue=upperValue*0.9; |
| 3176 » » » » » lowerValue=lowerValue*1.1; |
| 3177 » » » » } |
3642 } | 3178 } |
3643 labelHeight = config.scaleFontSize; | 3179 labelHeight = config.scaleFontSize; |
3644 scaleHeight = msr.availableHeight; | 3180 scaleHeight = msr.availableHeight; |
3645 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); | 3181 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); |
3646 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); | 3182 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); |
3647 return { | 3183 return { |
3648 maxValue: upperValue, | 3184 maxValue: upperValue, |
3649 minValue: lowerValue, | 3185 minValue: lowerValue, |
3650 maxSteps: maxSteps, | 3186 maxSteps: maxSteps, |
3651 minSteps: minSteps | 3187 minSteps: minSteps |
3652 }; | 3188 }; |
3653 }; | 3189 }; |
3654 }; | 3190 }; |
3655 /** | 3191 /** |
3656 * Reverse the data structure for horizontal charts | 3192 * Reverse the data structure for horizontal charts |
3657 * - reverse labels and every array inside datasets | 3193 * - reverse labels and every array inside datasets |
3658 * @param {object} data datasets and labels for the chart | 3194 * @param {object} data datasets and labels for the chart |
3659 * @return return the reversed data | 3195 * @return return the reversed data |
3660 */ | 3196 */ |
3661 function reverseData(data) { | 3197 function reverseData(data) { |
3662 data.labels = data.labels.reverse(); | 3198 data.labels = data.labels.reverse(); |
3663 for (var i = 0; i < data.datasets.length; i++) { | 3199 for (var i = 0; i < data.datasets.length; i++) { |
3664 for (var key in data.datasets[i]) { | 3200 for (var key in data.datasets[i]) { |
3665 if (Array.isArray(data.datasets[i][key])) { | 3201 if (Array.isArray(data.datasets[i][key])) { |
3666 data.datasets[i][key] = data.datasets[i]
[key].reverse(); | 3202 data.datasets[i][key] = data.datasets[i]
[key].reverse(); |
3667 } | 3203 } |
3668 } | 3204 } |
3669 } | 3205 } |
3670 return data; | 3206 return data; |
3671 » } | 3207 » }; |
3672 var HorizontalStackedBar = function(data, config, ctx) { | 3208 var HorizontalStackedBar = function(data, config, ctx) { |
3673 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPo
sX, xAxisPosY, barWidth, rotateLabels = 0, | 3209 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPo
sX, xAxisPosY, barWidth, rotateLabels = 0, |
3674 msr; | 3210 msr; |
3675 | 3211 |
3676 ctx.tpchart="HorizontalStackedBar"; | |
3677 setting_new_chart_vars(ctx); | |
3678 | |
3679 if (!dynamicFunction(data, config, ctx)) { | |
3680 if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | |
3681 return; | |
3682 } | |
3683 if(config.responsive && typeof ctx.firstPass == "undefined") { | |
3684 if(!config.multiGraph) { | |
3685 addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
3686 subUpdateChart(ctx,data,config); | |
3687 return; | |
3688 } else { ctx.firstPass=1; } | |
3689 } | |
3690 | |
3691 if (config.reverseOrder && typeof ctx.reversed == "undefined") { | 3212 if (config.reverseOrder && typeof ctx.reversed == "undefined") { |
3692 ctx.reversed=true; | 3213 ctx.reversed=true; |
3693 data = reverseData(data); | 3214 data = reverseData(data); |
3694 } | 3215 } |
3695 | 3216 |
| 3217 ctx.tpchart="HorizontalStackedBar"; |
| 3218 if (!init_and_start(ctx,data,config)) return; |
| 3219 var statData=initPassVariableData_part1(data,config,ctx); |
3696 | 3220 |
3697 config.logarithmic = false; | 3221 config.logarithmic = false; |
3698 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
3699 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
3700 defMouse(ctx, data, config); | |
3701 setRect(ctx, config); | |
3702 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, true, true, true, true, "HorizontalStackedBar"); | 3222 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, true, true, true, true, "HorizontalStackedBar"); |
3703 valueBounds = getValueBounds(); | 3223 valueBounds = getValueBounds(); |
3704 | 3224 |
3705 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { | 3225 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { |
3706 //Check and set the scale | 3226 //Check and set the scale |
3707 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; | 3227 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; |
3708 if (!config.scaleOverride) { | 3228 if (!config.scaleOverride) { |
3709 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); | 3229 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); |
3710 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalStack
edBar"); | 3230 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalStack
edBar"); |
3711 } else { | 3231 } else { |
| 3232 var scaleStartValue= setOptionValue("SCALESTARTV
ALUE",ctx,data,statData,undefined,config.scaleStartValue,-1,-1,{nullValue : true
} ); |
| 3233 var scaleSteps =setOptionValue("SCALESTEPS",ctx,
data,statData,undefined,config.scaleSteps,-1,-1,{nullValue : true} ); |
| 3234 var scaleStepWidth = setOptionValue("SCALESTEPWI
DTH",ctx,data,statData,undefined,config.scaleStepWidth,-1,-1,{nullValue : true}
); |
| 3235 |
3712 calculatedScale = { | 3236 calculatedScale = { |
3713 » » » » » steps: config.scaleSteps, | 3237 » » » » » steps: scaleSteps, |
3714 » » » » » stepValue: config.scaleStepWidth, | 3238 » » » » » stepValue: scaleStepWidth, |
3715 » » » » » graphMin: config.scaleStartValue, | 3239 » » » » » graphMin: scaleStartValue, |
3716 labels: [] | 3240 labels: [] |
3717 } | 3241 } |
3718 for (var i = 0; i <= calculatedScale.steps; i++)
{ | 3242 for (var i = 0; i <= calculatedScale.steps; i++)
{ |
3719 if (labelTemplateString) { | 3243 if (labelTemplateString) { |
3720 calculatedScale.labels.push(tmpl
(labelTemplateString, { | 3244 calculatedScale.labels.push(tmpl
(labelTemplateString, { |
3721 » » » » » » » value: fmtChartJS(config
, 1 * ((config.scaleStartValue + (config.scaleStepWidth * i)).toFixed(getDecimal
Places(config.scaleStepWidth))), config.fmtYLabel) | 3245 » » » » » » » value: fmtChartJS(config
, 1 * ((scaleStartValue + (scaleStepWidth * i)).toFixed(getDecimalPlaces(scaleSt
epWidth))), config.fmtYLabel) |
3722 })); | 3246 })); |
3723 } | 3247 } |
3724 } | 3248 } |
3725 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalStack
edBar"); | 3249 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalStack
edBar"); |
3726 } | 3250 } |
3727 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; | 3251 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; |
3728 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; | 3252 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; |
3729 scaleHop = Math.floor(msr.availableHeight / data.labels.
length); | 3253 scaleHop = Math.floor(msr.availableHeight / data.labels.
length); |
3730 valueHop = Math.floor(msr.availableWidth / (calculatedSc
ale.steps)); | 3254 valueHop = Math.floor(msr.availableWidth / (calculatedSc
ale.steps)); |
3731 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / (calculatedScale.steps)); | 3255 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / (calculatedScale.steps)); |
3732 msr.clrwidth = msr.clrwidth - (msr.availableWidth - (cal
culatedScale.steps * valueHop)); | 3256 msr.clrwidth = msr.clrwidth - (msr.availableWidth - (cal
culatedScale.steps * valueHop)); |
3733 msr.availableWidth = (calculatedScale.steps) * valueHop; | 3257 msr.availableWidth = (calculatedScale.steps) * valueHop; |
3734 msr.availableHeight = (data.labels.length) * scaleHop; | 3258 msr.availableHeight = (data.labels.length) * scaleHop; |
3735 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; | 3259 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; |
3736 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; | 3260 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; |
3737 barWidth = (scaleHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * data.datasets.length -
1) - (config.barStrokeWidth / 2) - 1); | 3261 barWidth = (scaleHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * data.datasets.length -
1) - (config.barStrokeWidth / 2) - 1); |
3738 if(barWidth>=0 && barWidth<=1)barWidth=1; | 3262 if(barWidth>=0 && barWidth<=1)barWidth=1; |
3739 if(barWidth<0 && barWidth>=-1)barWidth=-1; | 3263 if(barWidth<0 && barWidth>=-1)barWidth=-1; |
3740 drawLabels(); | 3264 drawLabels(); |
| 3265 zeroY= HorizontalCalculateOffset(0 , calculatedScale, s
caleHop); |
| 3266 initPassVariableData_part2(statData,data,config,ctx,{ |
| 3267 yAxisPosX : yAxisPosX, |
| 3268 xAxisPosY : xAxisPosY, |
| 3269 barWidth : barWidth, |
| 3270 zeroY : zeroY, |
| 3271 scaleHop : scaleHop, |
| 3272 valueHop : valueHop, |
| 3273 calculatedScale : calculatedScale |
| 3274 }); |
| 3275 |
3741 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); | 3276 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); |
3742 } else { | 3277 } else { |
3743 testRedraw(ctx,data,config); | 3278 testRedraw(ctx,data,config); |
3744 } | 3279 } |
3745 function HorizontalCalculateOffset(val, calculatedScale, scaleHo
p) { | 3280 function HorizontalCalculateOffset(val, calculatedScale, scaleHo
p) { |
3746 var outerValue = calculatedScale.steps * calculatedScale
.stepValue; | 3281 var outerValue = calculatedScale.steps * calculatedScale
.stepValue; |
3747 var adjustedValue = val - calculatedScale.graphMin; | 3282 var adjustedValue = val - calculatedScale.graphMin; |
3748 var scalingFactor = CapValue(adjustedValue / outerValue,
1, 0); | 3283 var scalingFactor = CapValue(adjustedValue / outerValue,
1, 0); |
3749 return (scaleHop * calculatedScale.steps) * scalingFacto
r; | 3284 return (scaleHop * calculatedScale.steps) * scalingFacto
r; |
3750 }; | 3285 }; |
3751 | 3286 |
3752 function drawBars(animPc) { | 3287 function drawBars(animPc) { |
3753 ctx.lineWidth = config.barStrokeWidth; | 3288 ctx.lineWidth = config.barStrokeWidth; |
3754 var tempp = new Array(data.datasets.length); | |
3755 var tempn = new Array(data.datasets.length); | |
3756 var cumvalue = new Array(); | |
3757 var totvalue = new Array(); | |
3758 for (var i = 0; i < data.datasets.length; i++) { | 3289 for (var i = 0; i < data.datasets.length; i++) { |
3759 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3290 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
3760 cumvalue[j] = 0; | |
3761 totvalue[j] = 0; | |
3762 } | |
3763 } | |
3764 for (var i = 0; i < data.datasets.length; i++) { | |
3765 for (var j = 0; j < data.datasets[i].data.length
; j++) | |
3766 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | |
3767 totvalue[j] += 1 * data.datasets
[i].data[j]; | |
3768 } | |
3769 } | |
3770 for (var i = 0; i < data.datasets.length; i++) { | |
3771 if (animPc >= 1) { | |
3772 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
3773 else lgtxt = ""; | |
3774 } | |
3775 for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
3776 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; | 3291 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; |
3777 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; | 3292 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; |
3778 » » » » » if (i == 0) { | 3293 » » » » » if ((typeof(data.datasets[i].data[j]) ==
'undefined') || 1*data.datasets[i].data[j] == 0 ) continue; |
3779 » » » » » » tempp[j]=0; | 3294 » » » » » if(config.animationByDataset) { |
3780 » » » » » » tempn[j]=0; | 3295 » » » » » » var leftBar= statData[i][j].xPos
Left; |
3781 » » » » » » zeroY= HorizontalCalculateOffse
t(0 , calculatedScale, scaleHop); | 3296 » » » » » » var rightBar= statData[i][j].xPo
sRight; |
| 3297 » » » » » » rightBar=leftBar+currentAnimPc*(
rightBar-leftBar); |
| 3298 » » » » » } else { |
| 3299 » » » » » » var leftBar=statData[statData[i]
[j].firstNotMissing][j].xPosLeft + currentAnimPc*(statData[i][j].xPosLeft-statDa
ta[statData[i][j].firstNotMissing][j].xPosLeft); |
| 3300 » » » » » » var rightBar=statData[statData[i
][j].firstNotMissing][j].xPosLeft + currentAnimPc*(statData[i][j].xPosRight-stat
Data[statData[i][j].firstNotMissing][j].xPosLeft); |
3782 } | 3301 } |
3783 » » » » » var barOffset = xAxisPosY + config.barVa
lueSpacing - scaleHop * (j + 1); | 3302 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data.datasets[i].fillColor,config.defaultFillColor,i,j,{animation
Value: currentAnimPc, xPosLeft : leftBar, yPosBottom : statData[i][j].yPosBottom
, xPosRight : rightBar, yPosTop : statData[i][j].yPosBottom} ); |
3784 » » » » » if (!(typeof(data.datasets[i].data[j]) =
= 'undefined') && 1*data.datasets[i].data[j] != 0 ) { | 3303 |
3785 » » » » » » if (1*data.datasets[i].data[j]<0
) { | 3304 » » » » » ctx.strokeStyle=setOptionValue("STROKECO
LOR",ctx,data,statData,data.datasets[i].strokeColor,config.defaultStrokeColor,i,
j,{nullvalue : null} ); |
3786 » » » » » » » var botval=tempp[j]; | 3305 |
3787 » » » » » » » var topval=tempp[j]+1*da
ta.datasets[i].data[j] ; | 3306 » » » » » if(currentAnimPc !=0 && statData[i][j].x
PosLeft!=statData[i][j].xPosRight ) { |
3788 » » » » » » } else { | 3307 » » » » » » ctx.beginPath(); |
3789 » » » » » » » var botval=tempn[j]; | 3308 » » » » » » ctx.moveTo(leftBar, statData[i][
j].yPosTop); |
3790 » » » » » » » var topval=tempn[j]+1*da
ta.datasets[i].data[j] ; | 3309 » » » » » » ctx.lineTo(rightBar, statData[i]
[j].yPosTop); |
3791 » » » » » » } | 3310 » » » » » » ctx.lineTo(rightBar, statData[i]
[j].yPosBottom); |
3792 » » » » » » if(config.animationByDataset) { | 3311 » » » » » » ctx.lineTo(leftBar, statData[i][
j].yPosBottom); |
3793 » » » » » » » var botBar=yAxisPosX + H
orizontalCalculateOffset(botval , calculatedScale, valueHop); | 3312 » » » » » » ctx.lineTo(leftBar, statData[i][
j].yPosTop); |
3794 » » » » » » » var topBar=yAxisPosX + H
orizontalCalculateOffset(topval , calculatedScale, valueHop); | 3313 » » » » » » if (config.barShowStroke) ctx.st
roke(); |
3795 » » » » » » » topBar=botBar+currentAni
mPc*(topBar-botBar); | 3314 » » » » » » ctx.closePath(); |
3796 » » » » » » } else { | 3315 » » » » » » ctx.fill(); |
3797 » » » » » » » var botBar=yAxisPosX + H
orizontalCalculateOffset( currentAnimPc* botval , calculatedScale, valueHop); | |
3798 » » » » » » » var topBar=yAxisPosX + H
orizontalCalculateOffset( currentAnimPc*topval , calculatedScale, valueHop); | |
3799 » » » » » » » | |
3800 » » » » » » } | |
3801 » » » » » » ctx.fillStyle = config.defaultFi
llColor; | |
3802 » » » » » » if (typeof data.datasets[i].fill
Color == "function") ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", dat
a, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "HorizontalStacked
Bar", ctx, botBar, barOffset, topBar, barOffset + barWidth); | |
3803 » » » » » » else if (typeof(data.datasets[i]
.fillColor) == "string") { | |
3804 » » » » » » » ctx.fillStyle = data.dat
asets[i].fillColor; | |
3805 » » » » » » } else if (typeof(data.datasets[
i].fillColor) == "object") { | |
3806 » » » » » » » if (typeof(data.datasets
[i].fillColor[0]) == "string") { | |
3807 » » » » » » » » ctx.fillStyle =
data.datasets[i].fillColor[Min([data.datasets[i].fillColor.length - 1, j])]; | |
3808 » » » » » » » } | |
3809 » » » » » » } | |
3810 » » » » » » ctx.strokeStyle = config.default
StrokeColor; | |
3811 » » » » » » if (typeof data.datasets[i].stro
keColor == "function") ctx.strokeStyle = data.datasets[i].strokeColor("STROKECOL
OR", data, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], ctx, "Hori
zontalStackedBar", ctx, botBar, barOffset, topBar, barOffset + barWidth); | |
3812 » » » » » » else if (typeof(data.datasets[i]
.strokeColor) == "string") { | |
3813 » » » » » » » ctx.strokeStyle = data.d
atasets[i].strokeColor; | |
3814 » » » » » » } else if (typeof(data.datasets[
i].strokeColor) == "object") { | |
3815 » » » » » » » if (typeof(data.datasets
[i].strokeColor[0]) == "string") { | |
3816 » » » » » » » » ctx.strokeStyle
= data.datasets[i].strokeColor[Min([data.datasets[i].strokeColor.length - 1, j])
]; | |
3817 » » » » » » » } | |
3818 » » » » » » } | |
3819 » » » » » » if(currentAnimPc !=0) { | |
3820 » » » » » » » ctx.beginPath(); | |
3821 » » » » » » » ctx.moveTo(botBar, barOf
fset); | |
3822 » » » » » » » ctx.lineTo(topBar, barOf
fset); | |
3823 » » » » » » » ctx.lineTo(topBar, barOf
fset + barWidth); | |
3824 » » » » » » » ctx.lineTo(botBar, barOf
fset + barWidth); | |
3825 » » » » » » » ctx.lineTo(botBar, barOf
fset); | |
3826 » » » » » » » if (config.barShowStroke
) ctx.stroke(); | |
3827 » » » » » » » ctx.closePath(); | |
3828 » » » » » » » ctx.fill(); | |
3829 » » » » » » » cumvalue[j] += 1 * data.
datasets[i].data[j]; | |
3830 » » » » » » » if (animPc >= 1) { | |
3831 » » » » » » » » if (typeof(data.
labels[j]) == "string") lgtxt2 = data.labels[j].trim(); | |
3832 » » » » » » » » else lgtxt2 = ""
; | |
3833 » » » » » » » » if (1*data.datas
ets[i].data[j]<0) { | |
3834 » » » » » » » » » jsGraphA
nnotate[ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", topBa
r, barOffset + barWidth, botBar, barOffset, lgtxt, lgtxt2, 1 * data.datasets[i].
data[j], cumvalue[j], totvalue[j], i, j]; | |
3835 » » » » » » » » } else { | |
3836 » » » » » » » » » jsGraphA
nnotate[ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", botBa
r, barOffset + barWidth, topBar, barOffset, lgtxt, lgtxt2, 1 * data.datasets[i].
data[j], cumvalue[j], totvalue[j], i, j]; | |
3837 » » » » » » » » } | |
3838 » » » » » » » } | |
3839 » » » » » » } | |
3840 » » » » » » if (1*data.datasets[i].data[j]<0
) { | |
3841 » » » » » » » tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; | |
3842 » » » » » » } else { | |
3843 » » » » » » » tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; | |
3844 » » » » » » } | |
3845 } | 3316 } |
3846 } | 3317 } |
3847 } | 3318 } |
3848 » » » if (animPc >= 1 && config.inGraphDataShow) { | 3319 » » » if (animPc >= config.animationStopValue) { |
3849 var yPos = 0, | 3320 var yPos = 0, |
3850 xPos = 0; | 3321 xPos = 0; |
3851 for (var i = 0; i < data.datasets.length; i++) { | 3322 for (var i = 0; i < data.datasets.length; i++) { |
3852 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 3323 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
3853 » » » » » » cumvalue[j] = 0; | 3324 » » » » » » if ((typeof(data.datasets[i].dat
a[j]) == 'undefined')) continue; |
3854 » » » » » } | 3325 » » » » » » if (setOptionValue("ANNOTATEDISP
LAY",ctx,data,statData,undefined,config.annotateDisplay,i,j,{nullValue : true}))
{ |
3855 » » » » } | 3326 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", i ,j, statData]; |
3856 » » » » for (var i = 0; i < data.datasets.length; i++) { | |
3857 » » » » » if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
3858 » » » » » else lgtxt = ""; | |
3859 » » » » » for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | |
3860 » » » » » » if (i == 0) { | |
3861 » » » » » » » tempp[j]=0; | |
3862 » » » » » » » tempn[j]=0; | |
3863 » » » » » » » zeroY= HorizontalCalcul
ateOffset(0 , calculatedScale, scaleHop); | |
3864 } | 3327 } |
3865 » » » » » » if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { | 3328 » » » » » » if(setOptionValue("INGRAPHDATASH
OW",ctx,data,statData,undefined,config.inGraphDataShow,i,j,{nullValue : true}))
{ |
3866 » » » » » » » if (1*data.datasets[i].d
ata[j]<0) { | |
3867 » » » » » » » » var botval=tempp
[j]; | |
3868 » » » » » » » » var topval=tempp
[j]+1*data.datasets[i].data[j] ; | |
3869 » » » » » » » } else { | |
3870 » » » » » » » » var botval=tempn
[j]; | |
3871 » » » » » » » » var topval=tempn
[j]+1*data.datasets[i].data[j] ; | |
3872 » » » » » » » } | |
3873 » » » » » » » var botBar=yAxisPosX + H
orizontalCalculateOffset(botval , calculatedScale, valueHop); | |
3874 » » » » » » » var topBar=yAxisPosX + H
orizontalCalculateOffset(topval , calculatedScale, valueHop); | |
3875 ctx.save(); | 3329 ctx.save(); |
3876 » » » » » » » ctx.textAlign = config.i
nGraphDataAlign; | 3330 » » » » » » » ctx.textAlign = setOptio
nValue("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,
j,{nullValue: true }); |
3877 » » » » » » » ctx.textBaseline = confi
g.inGraphDataVAlign; | 3331 » » » » » » » ctx.textBaseline = setOp
tionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAli
gn,i,j,{nullValue : true} ); |
3878 » » » » » » » ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 3332 » » » » » » » ctx.font = setOptionValu
e("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle
,i,j,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,
statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ) + 'px ' +
setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGra
phDataFontFamily,i,j,{nullValue : true} ); |
3879 » » » » » » » ctx.fillStyle = config.i
nGraphDataFontColor; | 3333 » » » » » » » ctx.fillStyle = setOptio
nValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFont
Color,i,j,{nullValue : true} ); |
3880 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | 3334 » » » » » » » var dispString = tmplbis
(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphData
Tmpl,i,j,{nullValue : true} ),statData[i][j]); |
3881 » » » » » » » else lgtxt2 = ""; | |
3882 » » » » » » » var barOffset = xAxisPos
Y + config.barValueSpacing - scaleHop * (j + 1); | |
3883 » » » » » » » cumvalue[j] += data.data
sets[i].data[j]; | |
3884 » » » » » » » var dispString = tmplbis
(config.inGraphDataTmpl, { | |
3885 » » » » » » » » config: config, | |
3886 » » » » » » » » v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | |
3887 » » » » » » » » v2: fmtChartJS(c
onfig, lgtxt2, config.fmtV2), | |
3888 » » » » » » » » v3: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV3), | |
3889 » » » » » » » » v4: fmtChartJS(c
onfig, cumvalue[j], config.fmtV4), | |
3890 » » » » » » » » v5: fmtChartJS(c
onfig, totvalue[j], config.fmtV5), | |
3891 » » » » » » » » v6: roundToWithT
housands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[j]
, config.fmtV6), config.roundPct), | |
3892 » » » » » » » » v7: fmtChartJS(c
onfig, yAxisPosX, config.fmtV7), | |
3893 » » » » » » » » v8: fmtChartJS(c
onfig, barOffset + barWidth, config.fmtV8), | |
3894 » » » » » » » » v9: fmtChartJS(c
onfig, yAxisPosX + HorizontalCalculateOffset(data.datasets[i].data[j], calculate
dScale, valueHop) + (config.barStrokeWidth / 2), config.fmtV9), | |
3895 » » » » » » » » v10: fmtChartJS(
config, barOffset, config.fmtV10), | |
3896 » » » » » » » » v11: fmtChartJS(
config, i, config.fmtV11), | |
3897 » » » » » » » » v12: fmtChartJS(
config, j, config.fmtV12), | |
3898 » » » » » » » » data: data | |
3899 » » » » » » » }); | |
3900 ctx.beginPath(); | 3335 ctx.beginPath(); |
3901 yPos = 0; | 3336 yPos = 0; |
3902 xPos = 0; | 3337 xPos = 0; |
3903 » » » » » » » if (config.inGraphDataXP
osition == 1) { | 3338 » » » » » » » if (setOptionValue("INGR
APHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition,i,j,{n
ullValue : true} ) == 1) { |
3904 » » » » » » » » xPos = botBar +
config.inGraphDataPaddingX; | 3339 » » » » » » » » xPos = statData[
i][j].xPosLeft + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefine
d,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
3905 » » » » » » » } else if (config.inGrap
hDataXPosition == 2) { | 3340 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 2) { |
3906 » » » » » » » » xPos = botBar +
(topBar-botBar)/2 + config.inGraphDataPaddingX; | 3341 » » » » » » » » xPos = statData[
i][j].xPosLeft + (statData[i][j].xPosRight-statData[i][j].xPosLeft)/2 + setOptio
nValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefined,config.inGraphDataPaddi
ngX,i,j,{nullValue : true} ); |
3907 » » » » » » » } else if (config.inGrap
hDataXPosition == 3) { | 3342 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 3) { |
3908 » » » » » » » » xPos = topBar +
config.inGraphDataPaddingX; | 3343 » » » » » » » » xPos = statData[
i][j].xPosRight + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefin
ed,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
3909 } | 3344 } |
3910 » » » » » » » if (config.inGraphDataYP
osition == 1) { | 3345 » » » » » » » if (setOptionValue("INGR
APHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition,i,j,{n
ullValue : true} ) == 1) { |
3911 » » » » » » » » yPos = barOffset
+ barWidth - config.inGraphDataPaddingY; | 3346 » » » » » » » » yPos = statData[
i][j].yPosBottom - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefi
ned,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
3912 » » » » » » » } else if (config.inGrap
hDataYPosition == 2) { | 3347 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 2) { |
3913 » » » » » » » » yPos = barOffset
+ barWidth / 2 - config.inGraphDataPaddingY; | 3348 » » » » » » » » yPos = statData[
i][j].yPosBottom - barWidth / 2 - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,
statData,undefined,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
3914 » » » » » » » } else if (config.inGrap
hDataYPosition == 3) { | 3349 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 3) { |
3915 » » » » » » » » yPos = barOffset
- config.inGraphDataPaddingY; | 3350 » » » » » » » » yPos = statData[
i][j].yPosTop - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined
,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
3916 } | 3351 } |
3917 if(xPos<=msr.availableWi
dth+msr.leftNotUsableSize) { | 3352 if(xPos<=msr.availableWi
dth+msr.leftNotUsableSize) { |
3918 ctx.translate(xP
os, yPos); | 3353 ctx.translate(xP
os, yPos); |
3919 » » » » » » » » ctx.rotate(confi
g.inGraphDataRotate * (Math.PI / 180)); | 3354 » » » » » » » » ctx.rotate(setOp
tionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRota
te,i,j,{nullValue : true} ) * (Math.PI / 180)); |
3920 » » » » » » » » ctx.fillTextMult
iLine(dispString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | 3355 » » » » » » » » ctx.fillTextMult
iLine(dispString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",c
tx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),t
rue); |
3921 ctx.restore(); | 3356 ctx.restore(); |
3922 } | 3357 } |
3923 if (1*data.datasets[i].d
ata[j]<0) { | |
3924 tempp[j]=tempp[j
]+1*data.datasets[i].data[j] ; | |
3925 } else { | |
3926 tempn[j]=tempn[j
]+1*data.datasets[i].data[j] ; | |
3927 } | |
3928 } | 3358 } |
3929 } | 3359 } |
3930 } | 3360 } |
3931 } | 3361 } |
3932 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"HorizontalStackedBar"); | 3362 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"HorizontalStackedBar"); |
3933 }; | 3363 }; |
3934 | 3364 |
3935 function drawScale() { | 3365 function drawScale() { |
3936 //X axis line
| 3366 //X axis line
|
3937 ctx.lineWidth = config.scaleLineWidth; | 3367 ctx.lineWidth = config.scaleLineWidth; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3990 } else { | 3420 } else { |
3991 ctx.textAlign = "center"; | 3421 ctx.textAlign = "center"; |
3992 } | 3422 } |
3993 ctx.fillStyle = config.scaleFontColor; | 3423 ctx.fillStyle = config.scaleFontColor; |
3994 if (config.xAxisBottom) { | 3424 if (config.xAxisBottom) { |
3995 for (var i = ((config.showYAxisMin) ? -1
: 0); i < calculatedScale.steps; i++) { | 3425 for (var i = ((config.showYAxisMin) ? -1
: 0); i < calculatedScale.steps; i++) { |
3996 ctx.save(); | 3426 ctx.save(); |
3997 if (msr.rotateLabels > 0) { | 3427 if (msr.rotateLabels > 0) { |
3998 ctx.translate(yAxisPosX
+ (i + 1) * valueHop - msr.highestXLabel / 2, msr.xLabelPos); | 3428 ctx.translate(yAxisPosX
+ (i + 1) * valueHop - msr.highestXLabel / 2, msr.xLabelPos); |
3999 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); | 3429 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); |
4000 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], 0, 0, ctx.textBaseline, config.scaleFontSize); | 3430 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], 0, 0, ctx.textBaseline, config.scaleFontSize,true); |
4001 } else { | 3431 } else { |
4002 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], yAxisPosX + ((i + 1) * valueHop), msr.xLabelPos, ct
x.textBaseline, config.scaleFontSize); | 3432 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], yAxisPosX + ((i + 1) * valueHop), msr.xLabelPos, ct
x.textBaseline, config.scaleFontSize,true); |
4003 } | 3433 } |
4004 ctx.restore(); | 3434 ctx.restore(); |
4005 } | 3435 } |
4006 } | 3436 } |
4007 } | 3437 } |
4008 //Y axis | 3438 //Y axis |
4009 ctx.textAlign = "right"; | 3439 ctx.textAlign = "right"; |
4010 ctx.textBaseline = "middle"; | 3440 ctx.textBaseline = "middle"; |
4011 for (var j = 0; j < data.labels.length; j++) { | 3441 for (var j = 0; j < data.labels.length; j++) { |
4012 if (config.yAxisLeft) { | 3442 if (config.yAxisLeft) { |
4013 ctx.textAlign = "right"; | 3443 ctx.textAlign = "right"; |
4014 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX - (config.scaleTickSizeLeft + conf
ig.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop) + barWidth / 2, ctx.textBa
seline, config.scaleFontSize); | 3444 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX - (config.scaleTickSizeLeft + conf
ig.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop) + barWidth / 2, ctx.textBa
seline, config.scaleFontSize,true); |
4015 } | 3445 } |
4016 if (config.yAxisRight) { | 3446 if (config.yAxisRight) { |
4017 ctx.textAlign = "left"; | 3447 ctx.textAlign = "left"; |
4018 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX + msr.availableWidth + (config.sca
leTickSizeRight + config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop) + ba
rWidth / 2, ctx.textBaseline, config.scaleFontSize); | 3448 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX + msr.availableWidth + (config.sca
leTickSizeRight + config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop) + ba
rWidth / 2, ctx.textBaseline, config.scaleFontSize,true); |
4019 } | 3449 } |
4020 } | 3450 } |
4021 }; | 3451 }; |
4022 | 3452 |
4023 function getValueBounds() { | 3453 function getValueBounds() { |
4024 » » » var upperValue = Number.MIN_VALUE; | 3454 » » » var upperValue = -Number.MAX_VALUE; |
4025 var lowerValue = Number.MAX_VALUE; | 3455 var lowerValue = Number.MAX_VALUE; |
4026 var minvl = new Array(data.datasets.length); | 3456 var minvl = new Array(data.datasets.length); |
4027 var maxvl = new Array(data.datasets.length); | 3457 var maxvl = new Array(data.datasets.length); |
4028 for (var i = 0; i < data.datasets.length; i++) { | 3458 for (var i = 0; i < data.datasets.length; i++) { |
4029 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3459 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
4030 var k = i; | 3460 var k = i; |
4031 var tempp = 0; | 3461 var tempp = 0; |
4032 var tempn = 0; | 3462 var tempn = 0; |
4033 if (!(typeof(data.datasets[0].data[j]) =
= 'undefined')) { | 3463 if (!(typeof(data.datasets[0].data[j]) =
= 'undefined')) { |
4034 if(1 * data.datasets[0].data[j]
> 0) { | 3464 if(1 * data.datasets[0].data[j]
> 0) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4066 }; | 3496 }; |
4067 if (tempn < lowe
rValue) { | 3497 if (tempn < lowe
rValue) { |
4068 lowerVal
ue = tempn; | 3498 lowerVal
ue = tempn; |
4069 }; | 3499 }; |
4070 } | 3500 } |
4071 } | 3501 } |
4072 k--; | 3502 k--; |
4073 } | 3503 } |
4074 } | 3504 } |
4075 }; | 3505 }; |
4076 » » » // AJOUT CHANGEMENT | 3506 » » » if(typeof config.graphMin=="function")lowerValue= setOpt
ionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin,-1,-1,{nullValue
: true}) |
4077 | 3507 » » » else if (!isNaN(config.graphMin)) lowerValue = config.gr
aphMin; |
4078 » » » if (!isNaN(config.graphMin)) lowerValue = config.graphMi
n; | 3508 » » » if(typeof config.graphMax=="function") upperValue= setOp
tionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax,-1,-1,{nullValu
e : true}) |
4079 » » » if (!isNaN(config.graphMax)) upperValue = config.graphMa
x; | 3509 » » » else if (!isNaN(config.graphMax)) upperValue = config.gr
aphMax; |
4080 » » » if (Math.abs(upperValue - lowerValue) < 0.00000001) { | 3510 » » » if(upperValue<lowerValue){upperValue=0;lowerValue=0;} |
4081 » » » » upperValue = Max([upperValue * 2, 1]); | 3511 » » » if (Math.abs(upperValue - lowerValue) < config.zeroValue
) { |
4082 » » » » lowerValue = 0; | 3512 » » » » if(Math.abs(upperValue)< config.zeroValue) upper
Value = .9; |
| 3513 » » » » if(upperValue>0) { |
| 3514 » » » » » upperValue=upperValue*1.1; |
| 3515 » » » » » lowerValue=lowerValue*0.9; |
| 3516 » » » » } else { |
| 3517 » » » » » upperValue=upperValue*0.9; |
| 3518 » » » » » lowerValue=lowerValue*1.1; |
| 3519 » » » » } |
4083 } | 3520 } |
4084 labelHeight = config.scaleFontSize; | 3521 labelHeight = config.scaleFontSize; |
4085 scaleHeight = msr.availableHeight; | 3522 scaleHeight = msr.availableHeight; |
4086 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); | 3523 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); |
4087 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); | 3524 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); |
4088 return { | 3525 return { |
4089 maxValue: upperValue, | 3526 maxValue: upperValue, |
4090 minValue: lowerValue, | 3527 minValue: lowerValue, |
4091 maxSteps: maxSteps, | 3528 maxSteps: maxSteps, |
4092 minSteps: minSteps | 3529 minSteps: minSteps |
4093 }; | 3530 }; |
4094 | 3531 |
4095 | 3532 |
4096 }; | 3533 }; |
4097 }; | 3534 }; |
4098 var Bar = function(data, config, ctx) { | 3535 var Bar = function(data, config, ctx) { |
4099 » » var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPo
sX, xAxisPosY, barWidth, rotateLabels = 0, | 3536 » » var maxSize, scaleHop, scaleHop2, calculatedScale, calculatedSca
le2, labelHeight, scaleHeight, valueBounds, labelTemplateString, labelTemplateSt
ring2, valueHop, widestXLabel, xAxisLength, yAxisPosX, xAxisPosY, barWidth, rota
teLabels = 0, |
4100 msr; | 3537 msr; |
4101 » » var offsets = []; | 3538 » |
4102 » » | |
4103 ctx.tpchart="Bar"; | 3539 ctx.tpchart="Bar"; |
4104 » » setting_new_chart_vars(ctx); | 3540 » if (!init_and_start(ctx,data,config)) return; |
| 3541 » » var statData=initPassVariableData_part1(data,config,ctx); |
4105 | 3542 |
4106 » » if (!dynamicFunction(data, config, ctx)) { | 3543 » » var nrOfBars = data.datasets.length; |
4107 » » if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | 3544 » » for (var i = 0; i < data.datasets.length; i++) { |
4108 » » » return; | 3545 » » » if (data.datasets[i].type == "Line") { statData[i][0].tp
chart="Line";nrOfBars--;} |
4109 » » } | 3546 » » » else statData[i][0].tpchart="Bar";» |
4110 » if(config.responsive && typeof ctx.firstPass == "undefined") { | 3547 » » } |
4111 » » if(!config.multiGraph) { | |
4112 » » » » addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
4113 » » » subUpdateChart(ctx,data,config); | |
4114 » » » return; | |
4115 » » } else { ctx.firstPass=1; } | |
4116 » » } | |
4117 | 3548 |
4118 » » // for BarLineCharts | 3549 |
4119 » » var nrOfBars = data.datasets.length; | |
4120 » » var nrOfLines = 0; | |
4121 » » var lineDatasets = []; | |
4122 » » var barDatasets = []; | |
4123 » » for (var i = 0; i < data.datasets.length; i++) { | |
4124 » » » if (data.datasets[i].type == "Line") { | |
4125 » » » » nrOfLines++; | |
4126 » » » » lineDatasets.push(i); | |
4127 » » » } else { | |
4128 » » » » barDatasets.push(i); | |
4129 » » » } | |
4130 » » } | |
4131 // change the order (at first all bars then the lines) (form of
BubbleSort) | 3550 // change the order (at first all bars then the lines) (form of
BubbleSort) |
4132 var bufferDataset, l = 0; | 3551 var bufferDataset, l = 0; |
4133 » » for (var i = data.datasets.length - 1; i >= 0; i--) { | 3552 » » |
4134 » » » if (lineDatasets.indexOf(i) >= 0) { | |
4135 » » » » l++; | |
4136 » » » » for (var b = i; b < data.datasets.length - l; b+
+) { | |
4137 » » » » » bufferDataset = data.datasets[b + 1]; | |
4138 » » » » » data.datasets[b + 1] = data.datasets[b]; | |
4139 » » » » » data.datasets[b] = bufferDataset; | |
4140 » » » » } | |
4141 » » » } | |
4142 » » } | |
4143 » » nrOfBars -= nrOfLines; | |
4144 | 3553 |
4145 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
4146 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
4147 defMouse(ctx, data, config); | |
4148 setRect(ctx, config); | |
4149 | |
4150 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, false, true, true, true, "Bar"); | 3554 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, false, true, true, true, "Bar"); |
4151 valueBounds = getValueBounds(); | 3555 valueBounds = getValueBounds(); |
4152 | 3556 » » if(valueBounds.minValue<=0)config.logarithmic=false; |
4153 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { | 3557 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { |
4154 | 3558 |
4155 // true or fuzzy (error for negativ values (included 0)) | 3559 // true or fuzzy (error for negativ values (included 0)) |
4156 if (config.logarithmic !== false) { | 3560 if (config.logarithmic !== false) { |
4157 if (valueBounds.minValue <= 0) { | 3561 if (valueBounds.minValue <= 0) { |
4158 config.logarithmic = false; | 3562 config.logarithmic = false; |
4159 } | 3563 } |
4160 } | 3564 } |
| 3565 if (config.logarithmic2 !== false) { |
| 3566 if (valueBounds.minValue2 <= 0) { |
| 3567 config.logarithmic2 = false; |
| 3568 } |
| 3569 } |
4161 // Check if logarithmic is meanigful | 3570 // Check if logarithmic is meanigful |
4162 var OrderOfMagnitude = calculateOrderOfMagnitude(Math.po
w(10, calculateOrderOfMagnitude(valueBounds.maxValue) + 1)) - calculateOrderOfMa
gnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.minValue))); | 3571 var OrderOfMagnitude = calculateOrderOfMagnitude(Math.po
w(10, calculateOrderOfMagnitude(valueBounds.maxValue) + 1)) - calculateOrderOfMa
gnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.minValue))); |
4163 if ((config.logarithmic == 'fuzzy' && OrderOfMagnitude <
4) || config.scaleOverride) { | 3572 if ((config.logarithmic == 'fuzzy' && OrderOfMagnitude <
4) || config.scaleOverride) { |
4164 config.logarithmic = false; | 3573 config.logarithmic = false; |
4165 } | 3574 } |
| 3575 // Check if logarithmic is meanigful |
| 3576 var OrderOfMagnitude2 = calculateOrderOfMagnitude(Math.p
ow(10, calculateOrderOfMagnitude(valueBounds.maxValue2) + 1)) - calculateOrderOf
Magnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.minValue2))); |
| 3577 if ((config.logarithmic2 == 'fuzzy' && OrderOfMagnitude2
< 4) || config.scaleOverride2) { |
| 3578 config.logarithmic2 = false; |
| 3579 } |
| 3580 |
4166 //Check and set the scale | 3581 //Check and set the scale |
4167 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; | 3582 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; |
| 3583 labelTemplateString2 = (config.scaleShowLabels2) ? confi
g.scaleLabel2 : ""; |
4168 if (!config.scaleOverride) { | 3584 if (!config.scaleOverride) { |
4169 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); | 3585 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); |
4170 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, false, true, true, true, "Bar"); | |
4171 } else { | 3586 } else { |
| 3587 var scaleStartValue= setOptionValue("SCALESTARTV
ALUE",ctx,data,statData,undefined,config.scaleStartValue,-1,-1,{nullValue : true
} ); |
| 3588 var scaleSteps =setOptionValue("SCALESTEPS",ctx,
data,statData,undefined,config.scaleSteps,-1,-1,{nullValue : true} ); |
| 3589 var scaleStepWidth = setOptionValue("SCALESTEPWI
DTH",ctx,data,statData,undefined,config.scaleStepWidth,-1,-1,{nullValue : true}
); |
| 3590 |
4172 calculatedScale = { | 3591 calculatedScale = { |
4173 » » » » » steps: config.scaleSteps, | 3592 » » » » » steps: scaleSteps, |
4174 » » » » » stepValue: config.scaleStepWidth, | 3593 » » » » » stepValue: scaleStepWidth, |
4175 » » » » » graphMin: config.scaleStartValue, | 3594 » » » » » graphMin: scaleStartValue, |
4176 » » » » » graphMax: config.scaleStartValue + confi
g.scaleSteps * config.scaleStepWidth, | 3595 » » » » » graphMax: scaleStartValue + scaleSteps *
scaleStepWidth, |
4177 labels: [] | 3596 labels: [] |
4178 } | 3597 } |
4179 » » » » populateLabels(1, config, labelTemplateString, c
alculatedScale.labels, calculatedScale.steps, config.scaleStartValue, calculated
Scale.graphMax, config.scaleStepWidth); | 3598 » » » » populateLabels(1, config, labelTemplateString, c
alculatedScale.labels, calculatedScale.steps, scaleStartValue, calculatedScale.g
raphMax, scaleStepWidth); |
4180 » » » » msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, false, true, true, true, "Bar"); | |
4181 } | 3599 } |
| 3600 if (valueBounds.dbAxis) { |
| 3601 if (!config.scaleOverride2) { |
| 3602 calculatedScale2 = calculateScale(2, con
fig, valueBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue2, valueBou
nds.minValue2, labelTemplateString); |
| 3603 } else { |
| 3604 var scaleStartValue2= setOptionValue("SC
ALESTARTVALUE2",ctx,data,statData,undefined,config.scaleStartValue2,-1,-1,{nullV
alue : true} ); |
| 3605 var scaleSteps2 =setOptionValue("SCALEST
EPS2",ctx,data,statData,undefined,config.scaleSteps2,-1,-1,{nullValue : true} ); |
| 3606 var scaleStepWidth2 = setOptionValue("SC
ALESTEPWIDTH2",ctx,data,statData,undefined,config.scaleStepWidth2,-1,-1,{nullVal
ue : true} ); |
| 3607 |
| 3608 calculatedScale2 = { |
| 3609 steps: scaleSteps2, |
| 3610 stepValue: scaleStepWidth2, |
| 3611 graphMin: scaleStartValue2, |
| 3612 graphMax: scaleStartValue2 + sca
leSteps2 * scaleStepWidth2, |
| 3613 labels: [] |
| 3614 } |
| 3615 populateLabels(2, config, labelTemplateS
tring2, calculatedScale2.labels, calculatedScale2.steps, scaleStartValue2, calcu
latedScale2.graphMax, scaleStepWidth2); |
| 3616 } |
| 3617 } else { |
| 3618 calculatedScale2 = { |
| 3619 steps: 0, |
| 3620 stepValue: 0, |
| 3621 graphMin: 0, |
| 3622 graphMax: 0, |
| 3623 labels: null |
| 3624 } |
| 3625 } |
| 3626 msr = setMeasures(data, config, ctx, height, width, calc
ulatedScale.labels, calculatedScale2.labels, true, false, true, true, true, "Bar
"); |
4182 | 3627 |
4183 var prevHeight=msr.availableHeight; | 3628 var prevHeight=msr.availableHeight; |
4184 | 3629 |
4185 | |
4186 | |
4187 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; | 3630 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; |
4188 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; | 3631 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; |
4189 scaleHop = Math.floor(msr.availableHeight / calculatedSc
ale.steps); | 3632 scaleHop = Math.floor(msr.availableHeight / calculatedSc
ale.steps); |
| 3633 scaleHop2 = Math.floor(msr.availableHeight / calculatedS
cale2.steps); |
4190 valueHop = Math.floor(msr.availableWidth / (data.labels.
length)); | 3634 valueHop = Math.floor(msr.availableWidth / (data.labels.
length)); |
4191 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / data.labels.length); | 3635 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / data.labels.length); |
4192 msr.clrwidth = msr.clrwidth - (msr.availableWidth - ((da
ta.labels.length) * valueHop)); | 3636 msr.clrwidth = msr.clrwidth - (msr.availableWidth - ((da
ta.labels.length) * valueHop)); |
4193 msr.availableWidth = (data.labels.length) * valueHop; | 3637 msr.availableWidth = (data.labels.length) * valueHop; |
4194 msr.availableHeight = (calculatedScale.steps) * scaleHop
; | 3638 msr.availableHeight = (calculatedScale.steps) * scaleHop
; |
4195 msr.xLabelPos+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); | 3639 msr.xLabelPos+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); |
4196 msr.clrheight+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); | 3640 msr.clrheight+=(config.scaleTickSizeBottom + config.scal
eTickSizeTop - (prevHeight-msr.availableHeight)); |
4197 | 3641 |
4198 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; | 3642 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; |
4199 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; | 3643 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; |
4200 barWidth = (valueHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * nrOfBars - 1) - ((conf
ig.barStrokeWidth / 2) * nrOfBars - 1)) / nrOfBars; | 3644 barWidth = (valueHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * nrOfBars - 1) - ((conf
ig.barStrokeWidth / 2) * nrOfBars - 1)) / nrOfBars; |
4201 if(barWidth>=0 && barWidth<=1)barWidth=1; | 3645 if(barWidth>=0 && barWidth<=1)barWidth=1; |
4202 if(barWidth<0 && barWidth>=-1)barWidth=-1; | 3646 if(barWidth<0 && barWidth>=-1)barWidth=-1; |
4203 var zeroY = 0; | 3647 var zeroY = 0; |
| 3648 var zeroY2 = 0; |
4204 if (valueBounds.minValue < 0) { | 3649 if (valueBounds.minValue < 0) { |
4205 var zeroY = calculateOffset(config.logarithmic,
0, calculatedScale, scaleHop); | 3650 var zeroY = calculateOffset(config.logarithmic,
0, calculatedScale, scaleHop); |
4206 } | 3651 } |
4207 » » » for (var i = 0; i < data.datasets.length; i++) { | 3652 » » » if (valueBounds.minValue2 < 0) { |
4208 » » » » offsets[i] = []; | 3653 » » » » var zeroY2 = calculateOffset(config.logarithmic2
, 0, calculatedScale2, scaleHop2); |
4209 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
4210 » » » » » offsets[i][j] = (calculateOffset(config.
logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop) - zeroY); | |
4211 » » » » } | |
4212 } | 3654 } |
| 3655 initPassVariableData_part2(statData,data,config,ctx,{ |
| 3656 msr: msr, |
| 3657 yAxisPosX : yAxisPosX, |
| 3658 xAxisPosY : xAxisPosY, |
| 3659 valueHop : valueHop, |
| 3660 barWidth : barWidth, |
| 3661 zeroY : zeroY, |
| 3662 zeroY2 : zeroY2, |
| 3663 calculatedScale : calculatedScale, |
| 3664 calculatedScale2 : calculatedScale2, |
| 3665 scaleHop : scaleHop, |
| 3666 scaleHop2 : scaleHop2 |
| 3667 }); |
4213 drawLabels(); | 3668 drawLabels(); |
4214 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); | 3669 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); |
4215 } else { | 3670 } else { |
4216 testRedraw(ctx,data,config); | 3671 testRedraw(ctx,data,config); |
4217 } | 3672 } |
| 3673 |
4218 function drawBars(animPc) { | 3674 function drawBars(animPc) { |
4219 var t1, t2, t3; | 3675 var t1, t2, t3; |
4220 » » » var cumvalue = new Array(); | 3676 |
4221 » » » var totvalue = new Array(); | 3677 |
| 3678 » » » ctx.lineWidth = config.barStrokeWidth; |
4222 for (var i = 0; i < data.datasets.length; i++) { | 3679 for (var i = 0; i < data.datasets.length; i++) { |
4223 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3680 » » » » if(data.datasets[i].type=="Line") continue; |
4224 » » » » » cumvalue[j] = 0; | |
4225 » » » » » totvalue[j] = 0; | |
4226 » » » » } | |
4227 » » » } | |
4228 » » » for (var i = 0; i < data.datasets.length; i++) { | |
4229 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3681 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
4230 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | 3682 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { |
4231 » » » » » » totvalue[j] += 1 * data.datasets
[i].data[j]; | 3683 » » » » » » var currentAnimPc = animationCor
rection(animPc, data, config, i, j, 1).animVal; |
| 3684 » » » » » » if (currentAnimPc > 1) currentAn
imPc = currentAnimPc - 1; |
| 3685 » » » » » » var barHeight = currentAnimPc *
(statData[i][j].barHeight) + (config.barStrokeWidth / 2); |
| 3686 » » » » » » ctx.fillStyle=setOptionValue("CO
LOR",ctx,data,statData,data.datasets[i].fillColor,config.defaultFillColor,i,j,{a
nimationValue: currentAnimPc, xPosLeft : statData[i][j].xPosLeft, yPosBottom : s
tatData[i][j].yPosBottom, xPosRight : statData[i][j].xPosLeft+barWidth, yPosTop
: statData[i][j].yPosBottom-barHeight} ); |
| 3687 » » » » » » ctx.strokeStyle=setOptionValue("
STROKECOLOR",ctx,data,statData,data.datasets[i].strokeColor,config.defaultStroke
Color,i,j,{nullvalue : null} ); |
| 3688 » » » » » » roundRect(ctx, statData[i][j].xP
osLeft, statData[i][j].yPosBottom, barWidth, barHeight, config.barShowStroke, co
nfig.barBorderRadius); |
4232 } | 3689 } |
4233 } | 3690 } |
4234 } | 3691 } |
4235 » » » ctx.lineWidth = config.barStrokeWidth; | 3692 » » » drawLinesDataset(animPc, data, config, ctx, statData,{xA
xisPosY : xAxisPosY,yAxisPosX : yAxisPosX, valueHop : valueHop, nbValueHop : dat
a.labels.length }); |
4236 » » » for (var i = 0; i < data.datasets.length; i++) { | 3693 |
4237 » » » » if (data.datasets[i].type == "Line") { | 3694 » » » if (animPc >= config.animationStopValue) { |
4238 » » » » » var lineData = { | 3695 |
4239 » » » » » » datasets: [], | |
4240 » » » » » » labels: data.labels | |
4241 » » » » » }; | |
4242 » » » » » lineData.datasets.push(data.datasets[i])
; | |
4243 » » » » » lineConfig = mergeChartConfig(config, { | |
4244 » » » » » » datasetFill: data.datasets[i].fi
ll | |
4245 » » » » » }); | |
4246 » » » » » drawLinesDataset(1, animPc, lineData, li
neConfig, ctx, offsets, { | |
4247 » » » » » » xAxisPosY: xAxisPosY, | |
4248 » » » » » » yAxisPosX: yAxisPosX + config.ba
rValueSpacing + | |
4249 » » » » » » » (barWidth + config.barDa
tasetSpacing / 2 + config.barStrokeWidth) * nrOfBars / 2, | |
4250 » » » » » » valueHop: valueHop, | |
4251 » » » » » » scaleHop: scaleHop, | |
4252 » » » » » » nbValueHop: data.labels.length, | |
4253 » » » » » » zeroY: zeroY, | |
4254 » » » » » » calculatedScale: calculatedScale
, | |
4255 » » » » » » logarithmic: config.logarithmic | |
4256 » » » » » }); | |
4257 » » » » » continue; // next dataset | |
4258 » » » » } | |
4259 » » » » if (animPc >= 1) { | |
4260 » » » » » if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
4261 » » » » » else lgtxt = ""; | |
4262 » » » » } | |
4263 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
4264 » » » » » var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; | |
4265 » » » » » if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; | |
4266 » » » » » var barOffset = yAxisPosX + config.barVa
lueSpacing + valueHop * j + barWidth * i + config.barDatasetSpacing * i + config
.barStrokeWidth * i; | |
4267 » » » » » var barHeight = currentAnimPc * (calcula
teOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedScale, scal
eHop) - zeroY) + (config.barStrokeWidth / 2); | |
4268 » » » » » ctx.fillStyle = config.defaultFillColor; | |
4269 » » » » » if (typeof data.datasets[i].fillColor ==
"function") { | |
4270 » » » » » » ctx.fillStyle = data.datasets[i]
.fillColor("FILLCOLOR", data, config, i, j, currentAnimPc, 1 * data.datasets[i].
data[j], "Bar", ctx, barOffset, xAxisPosY - zeroY , barOffset + barWidth, xAxisP
osY - zeroY - barHeight); | |
4271 » » » » » } else if (typeof(data.datasets[i].fillC
olor) == "string") { | |
4272 » » » » » » ctx.fillStyle = data.datasets[i]
.fillColor; | |
4273 » » » » » } else if (typeof(data.datasets[i].fillC
olor) == "object") { | |
4274 » » » » » » if (typeof(data.datasets[i].fill
Color[0]) == "string") { | |
4275 » » » » » » » ctx.fillStyle = data.dat
asets[i].fillColor[Min([data.datasets[i].fillColor.length - 1, j])]; | |
4276 » » » » » » } | |
4277 » » » » » } | |
4278 » » » » » ctx.strokeStyle = config.defaultStrokeCo
lor; | |
4279 » » » » » if (typeof data.datasets[i].strokeColor
== "function") { | |
4280 » » » » » » ctx.strokeStyle = data.datasets[
i].strokeColor("STROKECOLOR", data, config, i, j, CurrentAnimPc, 1 * data.datase
ts[i].data[j], "Bar", ctx, barOffset, xAxisPosY - zeroY - barHeight, barOffset +
barWidth, xAxisPosY - zeroY); | |
4281 » » » » » } else if (typeof(data.datasets[i].strok
eColor) == "string") { | |
4282 » » » » » » ctx.strokeStyle = data.datasets[
i].strokeColor; | |
4283 » » » » » } else if (typeof(data.datasets[i].strok
eColor) == "object") { | |
4284 » » » » » » if (typeof(data.datasets[i].stro
keColor[0]) == "string") { | |
4285 » » » » » » » ctx.strokeStyle = data.d
atasets[i].strokeColor[Min([data.datasets[i].strokeColor.length - 1, j])]; | |
4286 » » » » » » } | |
4287 » » » » » } | |
4288 » » » » » if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | |
4289 » » » » » » roundRect(ctx, barOffset, xAxisP
osY - zeroY, barWidth, barHeight, config.barShowStroke, config.barBorderRadius); | |
4290 » » » » » » cumvalue[j] += 1 * data.datasets
[i].data[j]; | |
4291 » » » » » » if (animPc >= 1) { | |
4292 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | |
4293 » » » » » » » else lgtxt2 = ""; | |
4294 » » » » » » » t1 = xAxisPosY - zeroY; | |
4295 » » » » » » » t2 = xAxisPosY - calcula
teOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedScale, scal
eHop) + (config.barStrokeWidth / 2); | |
4296 » » » » » » » if (t1 < t2) { | |
4297 » » » » » » » » t3 = t1; | |
4298 » » » » » » » » t1 = t2; | |
4299 » » » » » » » » t2 = t3 | |
4300 » » » » » » » } | |
4301 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", barOffset, t1, barOff
set + barWidth, t2, lgtxt, lgtxt2, | |
4302 » » » » » » » » 1 * data.dataset
s[i].data[j], cumvalue[j], totvalue[j], i, j | |
4303 » » » » » » » ]; | |
4304 » » » » » » } | |
4305 » » » » » } | |
4306 » » » » } | |
4307 » » » } | |
4308 » » » if (animPc >= 1 && config.inGraphDataShow) { | |
4309 for (var i = 0; i < data.datasets.length; i++) { | 3696 for (var i = 0; i < data.datasets.length; i++) { |
4310 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 3697 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
4311 » » » » » » cumvalue[j] = 0; | 3698 » » » » » » if (typeof(data.datasets[i].data
[j]) == 'undefined') continue; |
4312 » » » » » } | 3699 » » » » » » if (data.datasets[i].type == "Li
ne") continue; |
4313 » » » » } | 3700 » » » » » » if(setOptionValue("ANNOTATEDISPL
AY",ctx,data,statData,undefined,config.annotateDisplay,i,j,{nullValue : true})) |
4314 » » » » for (var i = 0; i < data.datasets.length; i++) { | 3701 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", i , j, statData]; |
4315 » » » » » if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | 3702 » » » » » » if(setOptionValue("INGRAPHDATASH
OW",ctx,data,statData,undefined,config.inGraphDataShow,i,j,{nullValue : true}))
{ |
4316 » » » » » else lgtxt = ""; | |
4317 » » » » » for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | |
4318 » » » » » » if (data.datasets[i].type == "Li
ne") { // no inGraphDataShow for lines again (is inside drawLinesDataset) | |
4319 » » » » » » » continue; | |
4320 » » » » » » } | |
4321 » » » » » » if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { | |
4322 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | |
4323 ctx.save(); | 3703 ctx.save(); |
4324 » » » » » » » ctx.textAlign = config.i
nGraphDataAlign; | 3704 » » » » » » » ctx.textAlign = setOptio
nValue("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,
j,{nullValue: true }); |
4325 » » » » » » » ctx.textBaseline = confi
g.inGraphDataVAlign; | 3705 » » » » » » » ctx.textBaseline = setOp
tionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAli
gn,i,j,{nullValue : true} ); |
4326 » » » » » » » ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 3706 » » » » » » » ctx.font = setOptionValu
e("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle
,i,j,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,
statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ) + 'px ' +
setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGra
phDataFontFamily,i,j,{nullValue : true} ); |
4327 » » » » » » » ctx.fillStyle = config.i
nGraphDataFontColor; | 3707 » » » » » » » ctx.fillStyle = setOptio
nValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFont
Color,i,j,{nullValue : true} ); |
4328 » » » » » » » var barOffset = yAxisPos
X + config.barValueSpacing + valueHop * j + barWidth * i + config.barDatasetSpac
ing * i + config.barStrokeWidth * i; | 3708 » » » » » » » t1 = statData[i][j].yPos
Bottom; |
4329 » » » » » » » t1 = xAxisPosY - zeroY; | 3709 » » » » » » » t2 = statData[i][j].yPos
Top; |
4330 » » » » » » » t2 = xAxisPosY - calcula
teOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedScale, scal
eHop) + (config.barStrokeWidth / 2); | |
4331 ctx.beginPath(); | 3710 ctx.beginPath(); |
4332 var yPos = 0, | 3711 var yPos = 0, |
4333 xPos = 0; | 3712 xPos = 0; |
4334 » » » » » » » if (config.inGraphDataXP
osition == 1) { | 3713 » » » » » » » if (setOptionValue("INGR
APHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition,i,j,{n
ullValue : true} ) == 1) { |
4335 » » » » » » » » xPos = barOffset
+ config.inGraphDataPaddingX; | 3714 » » » » » » » » xPos = statData[
i][j].xPosLeft + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefine
d,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
4336 » » » » » » » } else if (config.inGrap
hDataXPosition == 2) { | 3715 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 2) { |
4337 » » » » » » » » xPos = barOffset
+ barWidth / 2 + config.inGraphDataPaddingX; | 3716 » » » » » » » » xPos = statData[
i][j].xPosLeft + barWidth / 2 + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,st
atData,undefined,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
4338 » » » » » » » } else if (config.inGrap
hDataXPosition == 3) { | 3717 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 3) { |
4339 » » » » » » » » xPos = barOffset
+ barWidth + config.inGraphDataPaddingX; | 3718 » » » » » » » » xPos = statData[
i][j].xPosLeft + barWidth + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statDa
ta,undefined,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
4340 } | 3719 } |
4341 » » » » » » » if (config.inGraphDataYP
osition == 1) { | 3720 » » » » » » » if (setOptionValue("INGR
APHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition,i,j,{n
ullValue : true} ) == 1) { |
4342 » » » » » » » » yPos = xAxisPosY
- zeroY - config.inGraphDataPaddingY; | 3721 » » » » » » » » yPos = statData[
i][j].yPosBottom - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefi
ned,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
4343 » » » » » » » } else if (config.inGrap
hDataYPosition == 2) { | 3722 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 2) { |
4344 » » » » » » » » yPos = xAxisPosY
- (calculateOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculated
Scale, scaleHop) + | 3723 » » » » » » » » yPos = (statData
[i][j].yPosBottom+statData[i][j].yPosTop)/2 - setOptionValue("INGRAPHDATAPADDING
Y",ctx,data,statData,undefined,config.inGraphDataPaddingY,i,j,{nullValue : true}
); |
4345 » » » » » » » » » (config.
barStrokeWidth / 2)) / 2 - config.inGraphDataPaddingY; | 3724 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 3) { |
4346 » » » » » » » } else if (config.inGrap
hDataYPosition == 3) { | 3725 » » » » » » » » yPos = statData[
i][j].yPosTop - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined
,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
4347 » » » » » » » » yPos = xAxisPosY
- calculateOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedS
cale, scaleHop) + | |
4348 » » » » » » » » » (config.
barStrokeWidth / 2) - config.inGraphDataPaddingY; | |
4349 } | 3726 } |
4350 ctx.translate(xPos, yPos
); | 3727 ctx.translate(xPos, yPos
); |
4351 » » » » » » » cumvalue[j] += 1 * data.
datasets[i].data[j]; | 3728 » » » » » » » var dispString = tmplbis
(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphData
Tmpl,i,j,{nullValue : true} ), statData[i][j]); |
4352 » » » » » » » var dispString = tmplbis
(config.inGraphDataTmpl, { | 3729 » » » » » » » ctx.rotate(setOptionValu
e("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,j,{
nullValue : true} ) * (Math.PI / 180)); |
4353 » » » » » » » » config: config, | 3730 » » » » » » » ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,
statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),true); |
4354 » » » » » » » » v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | |
4355 » » » » » » » » v2: fmtChartJS(c
onfig, lgtxt2, config.fmtV2), | |
4356 » » » » » » » » v3: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV3), | |
4357 » » » » » » » » v4: fmtChartJS(c
onfig, cumvalue[j], config.fmtV4), | |
4358 » » » » » » » » v5: fmtChartJS(c
onfig, totvalue[j], config.fmtV5), | |
4359 » » » » » » » » v6: roundToWithT
housands(config, fmtChartJS(config, | |
4360 » » » » » » » » » 100 * da
ta.datasets[i].data[j] / totvalue[j], config.fmtV6), config.roundPct), | |
4361 » » » » » » » » v7: fmtChartJS(c
onfig, barOffset, config.fmtV7), | |
4362 » » » » » » » » v8: fmtChartJS(c
onfig, t1, config.fmtV8), | |
4363 » » » » » » » » v9: fmtChartJS(c
onfig, barOffset + barWidth, config.fmtV9), | |
4364 » » » » » » » » v10: fmtChartJS(
config, t2, config.fmtV10), | |
4365 » » » » » » » » v11: fmtChartJS(
config, i, config.fmtV11), | |
4366 » » » » » » » » v12: fmtChartJS(
config, j, config.fmtV12), | |
4367 » » » » » » » » data: data | |
4368 » » » » » » » }); | |
4369 » » » » » » » ctx.rotate(config.inGrap
hDataRotate * (Math.PI / 180)); | |
4370 » » » » » » » ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | |
4371 ctx.restore(); | 3731 ctx.restore(); |
4372 } | 3732 } |
4373 } | 3733 } |
4374 } | 3734 } |
4375 } | 3735 } |
4376 » » » if (animPc >= 1) { | 3736 » » » if (animPc >= 1 && typeof drawMath == "function") { |
4377 » » » » if (typeof drawMath == "function") { | 3737 » » » » drawMath(ctx, config, data, msr, { |
4378 » » » » » drawMath(ctx, config, data, msr, { | 3738 » » » » » xAxisPosY: xAxisPosY, |
4379 » » » » » » xAxisPosY: xAxisPosY, | 3739 » » » » » yAxisPosX: yAxisPosX, |
4380 » » » » » » yAxisPosX: yAxisPosX, | 3740 » » » » » valueHop: valueHop, |
4381 » » » » » » valueHop: valueHop, | 3741 » » » » » scaleHop: scaleHop, |
4382 » » » » » » scaleHop: scaleHop, | 3742 » » » » » zeroY: zeroY, |
4383 » » » » » » zeroY: zeroY, | 3743 » » » » » calculatedScale: calculatedScale, |
4384 » » » » » » calculatedScale: calculatedScale
, | 3744 » » » » » calculateOffset: calculateOffset, |
4385 » » » » » » calculateOffset: calculateOffset
, | 3745 » » » » » barWidth: barWidth |
4386 » » » » » » barWidth: barWidth | 3746 » » » » }); |
4387 » » » » » }); | |
4388 » » » » } | |
4389 } | 3747 } |
4390 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Bar"); | 3748 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"Bar"); |
4391 }; | 3749 }; |
4392 | 3750 |
4393 function roundRect(ctx, x, y, w, h, stroke, radius) { | 3751 function roundRect(ctx, x, y, w, h, stroke, radius) { |
4394 ctx.beginPath(); | 3752 ctx.beginPath(); |
4395 ctx.moveTo(x + radius, y); | 3753 ctx.moveTo(x + radius, y); |
4396 ctx.lineTo(x + w - radius, y); | 3754 ctx.lineTo(x + w - radius, y); |
4397 ctx.quadraticCurveTo(x + w, y, x + w, y); | 3755 ctx.quadraticCurveTo(x + w, y, x + w, y); |
4398 ctx.lineTo(x + w, y - h + radius); | 3756 ctx.lineTo(x + w, y - h + radius); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4465 ctx.textAlign = "center"; | 3823 ctx.textAlign = "center"; |
4466 } | 3824 } |
4467 ctx.fillStyle = config.scaleFontColor; | 3825 ctx.fillStyle = config.scaleFontColor; |
4468 if (config.xAxisBottom) { | 3826 if (config.xAxisBottom) { |
4469 for (var i = 0; i < data.labels.length;
i++) { | 3827 for (var i = 0; i < data.labels.length;
i++) { |
4470 ctx.save(); | 3828 ctx.save(); |
4471 if (msr.rotateLabels > 0) { | 3829 if (msr.rotateLabels > 0) { |
4472 | 3830 |
4473 ctx.translate(yAxisPosX
+ i * valueHop + (valueHop / 2) - msr.highestXLabel / 2, msr.xLabelPos); | 3831 ctx.translate(yAxisPosX
+ i * valueHop + (valueHop / 2) - msr.highestXLabel / 2, msr.xLabelPos); |
4474 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); | 3832 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); |
4475 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize); | 3833 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize,true); |
4476 } else { | 3834 } else { |
4477 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + i * valueHop + (
valueHop / 2), msr.xLabelPos, ctx.textBaseline, config.scaleFontSize); | 3835 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + i * valueHop + (
valueHop / 2), msr.xLabelPos, ctx.textBaseline, config.scaleFontSize,true); |
4478 } | 3836 } |
4479 ctx.restore(); | 3837 ctx.restore(); |
4480 } | 3838 } |
4481 } | 3839 } |
4482 } | 3840 } |
4483 //Y axis | 3841 //Y axis |
4484 ctx.textAlign = "right"; | 3842 ctx.textAlign = "right"; |
4485 ctx.textBaseline = "middle"; | 3843 ctx.textBaseline = "middle"; |
4486 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { | 3844 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { |
4487 if (config.scaleShowLabels) { | 3845 if (config.scaleShowLabels) { |
4488 if (config.yAxisLeft) { | 3846 if (config.yAxisLeft) { |
4489 ctx.textAlign = "right"; | 3847 ctx.textAlign = "right"; |
4490 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRi
ght), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline, config.scaleFontSize); | 3848 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRi
ght), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline, config.scaleFontSize,t
rue); |
4491 } | 3849 } |
4492 » » » » » if (config.yAxisRight) { | 3850 » » » » » if (config.yAxisRight && !valueBounds.db
Axis) { |
4493 ctx.textAlign = "left"; | 3851 ctx.textAlign = "left"; |
4494 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight
+ config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline,
config.scaleFontSize); | 3852 » » » » » » ctx.fillTextMultiLine(calculated
Scale.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight
+ config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop), ctx.textBaseline,
config.scaleFontSize,true); |
| 3853 » » » » » } |
| 3854 » » » » } |
| 3855 » » » } |
| 3856 » » » if (config.yAxisRight && valueBounds.dbAxis) { |
| 3857 » » » » for (var j = ((config.showYAxisMin) ? -1 : 0); j
< calculatedScale2.steps; j++) { |
| 3858 » » » » » if (config.scaleShowLabels) { |
| 3859 » » » » » » ctx.textAlign = "left"; |
| 3860 » » » » » » ctx.fillTextMultiLine(calculated
Scale2.labels[j + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRigh
t + config.yAxisSpaceRight), xAxisPosY - ((j + 1) * scaleHop2), ctx.textBaseline
, config.scaleFontSize,true); |
4495 } | 3861 } |
4496 } | 3862 } |
4497 } | 3863 } |
4498 }; | 3864 }; |
4499 | 3865 |
4500 function getValueBounds() { | 3866 function getValueBounds() { |
4501 » » » var upperValue = Number.MIN_VALUE; | 3867 » » » var upperValue = -Number.MAX_VALUE; |
4502 var lowerValue = Number.MAX_VALUE; | 3868 var lowerValue = Number.MAX_VALUE; |
| 3869 var upperValue2 = -Number.MAX_VALUE; |
| 3870 var lowerValue2 = Number.MAX_VALUE; |
| 3871 var secondAxis = false; |
| 3872 var firstAxis = false; |
| 3873 |
4503 for (var i = 0; i < data.datasets.length; i++) { | 3874 for (var i = 0; i < data.datasets.length; i++) { |
4504 var mathFctName = data.datasets[i].drawMathDevia
tion; | 3875 var mathFctName = data.datasets[i].drawMathDevia
tion; |
4505 var mathValueHeight = 0; | 3876 var mathValueHeight = 0; |
4506 if (typeof eval(mathFctName) == "function") { | 3877 if (typeof eval(mathFctName) == "function") { |
4507 var parameter = { | 3878 var parameter = { |
4508 data: data, | 3879 data: data, |
4509 datasetNr: i | 3880 datasetNr: i |
4510 }; | 3881 }; |
4511 mathValueHeight = window[mathFctName](pa
rameter); | 3882 mathValueHeight = window[mathFctName](pa
rameter); |
4512 } | 3883 } |
4513 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3884 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
4514 » » » » » if (1 * data.datasets[i].data[j] + mathV
alueHeight > upperValue) { | 3885 » » » » » if(typeof data.datasets[i].data[j]=="und
efined")continue; |
4515 » » » » » » upperValue = 1 * data.datasets[i
].data[j] + mathValueHeight | 3886 » » » » » if (data.datasets[i].axis == 2) { |
4516 » » » » » }; | 3887 » » » » » » secondAxis = true; |
4517 » » » » » if (1 * data.datasets[i].data[j] - mathV
alueHeight < lowerValue) { | 3888 » » » » » » if (1 * data.datasets[i].data[j]
+ mathValueHeight > upperValue2) { |
4518 » » » » » » lowerValue = 1 * data.datasets[i
].data[j] - mathValueHeight | 3889 » » » » » » » upperValue2 = 1 * data.d
atasets[i].data[j] + mathValueHeight; |
4519 » » » » » }; | 3890 » » » » » » }; |
| 3891 » » » » » » if (1 * data.datasets[i].data[j]
- mathValueHeight < lowerValue2) { |
| 3892 » » » » » » » lowerValue2 = 1 * data.d
atasets[i].data[j] - mathValueHeight; |
| 3893 » » » » » » }; |
| 3894 » » » » » } else { |
| 3895 » » » » » » firstAxis=true; |
| 3896 » » » » » » if (1 * data.datasets[i].data[j]
+ mathValueHeight > upperValue) { |
| 3897 » » » » » » » upperValue = 1 * data.da
tasets[i].data[j] + mathValueHeight; |
| 3898 » » » » » » }; |
| 3899 » » » » » » if (1 * data.datasets[i].data[j]
- mathValueHeight < lowerValue) { |
| 3900 » » » » » » » lowerValue = 1 * data.da
tasets[i].data[j] - mathValueHeight; |
| 3901 » » » » » » }; |
| 3902 » » » » » } |
4520 } | 3903 } |
4521 }; | 3904 }; |
4522 » » » if (Math.abs(upperValue - lowerValue) < 0.00000001) { | 3905 » » » if(upperValue<lowerValue){upperValue=0;lowerValue=0;} |
4523 » » » » upperValue = Max([upperValue * 2, 1]); | 3906 » » » if (Math.abs(upperValue - lowerValue) < config.zeroValue
) { |
4524 » » » » lowerValue = 0; | 3907 » » » » if(Math.abs(upperValue)< config.zeroValue) upper
Value = .9; |
| 3908 » » » » if(upperValue>0) { |
| 3909 » » » » » upperValue=upperValue*1.1; |
| 3910 » » » » » lowerValue=lowerValue*0.9; |
| 3911 » » » » } else { |
| 3912 » » » » » upperValue=upperValue*0.9; |
| 3913 » » » » » lowerValue=lowerValue*1.1; |
| 3914 » » » » } |
4525 } | 3915 } |
4526 » » » // AJOUT CHANGEMENT | 3916 » » » if(typeof config.graphMin=="function")lowerValue= setOpt
ionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin,-1,-1,{nullValue
: true}) |
4527 » » » if (!isNaN(config.graphMin)) lowerValue = config.graphMi
n; | 3917 » » » else if (!isNaN(config.graphMin)) lowerValue = config.gr
aphMin; |
4528 » » » if (!isNaN(config.graphMax)) upperValue = config.graphMa
x; | 3918 » » » if(typeof config.graphMax=="function") upperValue= setOp
tionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax,-1,-1,{nullValu
e : true}) |
| 3919 » » » else if (!isNaN(config.graphMax)) upperValue = config.gr
aphMax; |
| 3920 |
| 3921 » » » if (secondAxis) { |
| 3922 » » » » if(upperValue2<lowerValue2){upperValue2=0;lowerV
alue2=0;} |
| 3923 » » » » if (Math.abs(upperValue2 - lowerValue2) < config
.zeroValue) { |
| 3924 » » » » » if(Math.abs(upperValue2)< config.zeroVal
ue) upperValue2 = .9; |
| 3925 » » » » » if(upperValue2>0) { |
| 3926 » » » » » » upperValue2=upperValue2*1.1; |
| 3927 » » » » » » lowerValue2=lowerValue2*0.9; |
| 3928 » » » » » } else { |
| 3929 » » » » » » upperValue2=upperValue2*0.9; |
| 3930 » » » » » » lowerValue2=lowerValue2*1.1; |
| 3931 » » » » » } |
| 3932 » » » » } |
| 3933 » » » » if(typeof config.graphMin2=="function")lowerValu
e2= setOptionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin2,-1,-1
,{nullValue : true}) |
| 3934 » » » » else if (!isNaN(config.graphMin2)) lowerValue2 =
config.graphMin2; |
| 3935 » » » » if(typeof config.graphMax2=="function") upperVal
ue2= setOptionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax2,-1,-
1,{nullValue : true}) |
| 3936 » » » » else if (!isNaN(config.graphMax2)) upperValue2 =
config.graphMax2; |
| 3937 » » » } |
| 3938 » » » if (!firstAxis && secondAxis) { |
| 3939 » » » » upperValue = upperValue2; |
| 3940 » » » » lowerValue = lowerValue2; |
| 3941 » » » } |
| 3942 |
4529 labelHeight = config.scaleFontSize; | 3943 labelHeight = config.scaleFontSize; |
4530 scaleHeight = msr.availableHeight; | 3944 scaleHeight = msr.availableHeight; |
4531 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); | 3945 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); |
4532 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); | 3946 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); |
4533 return { | 3947 return { |
4534 maxValue: upperValue, | 3948 maxValue: upperValue, |
4535 minValue: lowerValue, | 3949 minValue: lowerValue, |
| 3950 maxValue2: upperValue2, |
| 3951 minValue2: lowerValue2, |
| 3952 dbAxis: secondAxis, |
4536 maxSteps: maxSteps, | 3953 maxSteps: maxSteps, |
4537 minSteps: minSteps | 3954 minSteps: minSteps |
4538 }; | 3955 }; |
4539 }; | 3956 }; |
4540 }; | 3957 }; |
| 3958 |
4541 var HorizontalBar = function(data, config, ctx) { | 3959 var HorizontalBar = function(data, config, ctx) { |
4542 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPo
sX, xAxisPosY, barWidth, rotateLabels = 0, | 3960 var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight
, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPo
sX, xAxisPosY, barWidth, rotateLabels = 0, |
4543 msr; | 3961 msr; |
4544 ctx.tpchart="HorizontalBar"; | 3962 ctx.tpchart="HorizontalBar"; |
4545 » » setting_new_chart_vars(ctx); | 3963 » if (!init_and_start(ctx,data,config)) return; |
4546 | 3964 » » var statData=initPassVariableData_part1(data,config,ctx); |
4547 » » if (!dynamicFunction(data, config, ctx)) { | |
4548 » » if(config.responsive && typeof ctx.firstPass == "undefin
ed") { if(!config.multiGraph) { addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); } } | |
4549 » » » return; | |
4550 » » } | |
4551 » if(config.responsive && typeof ctx.firstPass == "undefined") { | |
4552 » » if(!config.multiGraph) { | |
4553 » » » » addResponsiveChart(ctx.ChartNewId,ctx,data,confi
g); | |
4554 » » » subUpdateChart(ctx,data,config); | |
4555 » » » return; | |
4556 » » } else { ctx.firstPass=1; } | |
4557 » » } | |
4558 | 3965 |
4559 if (config.reverseOrder && typeof ctx.reversed == "undefined") { | 3966 if (config.reverseOrder && typeof ctx.reversed == "undefined") { |
4560 ctx.reversed=true; | 3967 ctx.reversed=true; |
4561 data = reverseData(data); | 3968 data = reverseData(data); |
4562 } | 3969 } |
4563 | |
4564 if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGra
phAnnotate[ctx.ChartNewId] = new Array(); | |
4565 else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); | |
4566 | |
4567 defMouse(ctx, data, config); | |
4568 setRect(ctx, config); | |
4569 | |
4570 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, true, true, true, true, "StackedBar"); | 3970 msr = setMeasures(data, config, ctx, height, width, "nihil", [""
], true, true, true, true, true, "StackedBar"); |
4571 valueBounds = getValueBounds(); | 3971 valueBounds = getValueBounds(); |
4572 | 3972 » » if(valueBounds.minValue<=0)config.logarithmic=false; |
4573 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { | 3973 if(valueBounds.maxSteps>0 && valueBounds.minSteps>0) { |
| 3974 if (config.logarithmic !== false) { |
| 3975 if (valueBounds.minValue <= 0) { |
| 3976 config.logarithmic = false; |
| 3977 } |
| 3978 } |
4574 //Check and set the scale | 3979 //Check and set the scale |
4575 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; | 3980 labelTemplateString = (config.scaleShowLabels) ? config.
scaleLabel : ""; |
4576 if (!config.scaleOverride) { | 3981 if (!config.scaleOverride) { |
4577 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); | 3982 calculatedScale = calculateScale(1, config, valu
eBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minVal
ue, labelTemplateString); |
4578 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalBar")
; | 3983 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalBar")
; |
4579 } else { | 3984 } else { |
| 3985 var scaleStartValue= setOptionValue("SCALESTARTV
ALUE",ctx,data,statData,undefined,config.scaleStartValue,-1,-1,{nullValue : true
} ); |
| 3986 var scaleSteps =setOptionValue("SCALESTEPS",ctx,
data,statData,undefined,config.scaleSteps,-1,-1,{nullValue : true} ); |
| 3987 var scaleStepWidth = setOptionValue("SCALESTEPWI
DTH",ctx,data,statData,undefined,config.scaleStepWidth,-1,-1,{nullValue : true}
); |
| 3988 |
4580 calculatedScale = { | 3989 calculatedScale = { |
4581 » » » » » steps: config.scaleSteps, | 3990 » » » » » steps: scaleSteps, |
4582 » » » » » stepValue: config.scaleStepWidth, | 3991 » » » » » stepValue: scaleStepWidth, |
4583 » » » » » graphMin: config.scaleStartValue, | 3992 » » » » » graphMin: scaleStartValue, |
4584 » » » » » graphMax: config.scaleStartValue + confi
g.scaleSteps * config.scaleStepWidth, | 3993 » » » » » graphMax: scaleStartValue + scaleSteps *
scaleStepWidth, |
4585 labels: [] | 3994 labels: [] |
4586 } | 3995 } |
4587 » » » » populateLabels(1, config, labelTemplateString, c
alculatedScale.labels, calculatedScale.steps, config.scaleStartValue, calculated
Scale.graphMax, config.scaleStepWidth); | 3996 » » » » populateLabels(1, config, labelTemplateString, c
alculatedScale.labels, calculatedScale.steps, scaleStartValue, calculatedScale.g
raphMax, scaleStepWidth); |
4588 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalBar")
; | 3997 msr = setMeasures(data, config, ctx, height, wid
th, calculatedScale.labels, null, true, true, true, true, true, "HorizontalBar")
; |
4589 } | 3998 } |
4590 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; | 3999 msr.availableHeight = msr.availableHeight - config.scale
TickSizeBottom - config.scaleTickSizeTop; |
4591 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; | 4000 msr.availableWidth = msr.availableWidth - config.scaleTi
ckSizeLeft - config.scaleTickSizeRight; |
4592 scaleHop = Math.floor(msr.availableHeight / data.labels.
length); | 4001 scaleHop = Math.floor(msr.availableHeight / data.labels.
length); |
4593 valueHop = Math.floor(msr.availableWidth / (calculatedSc
ale.steps)); | 4002 valueHop = Math.floor(msr.availableWidth / (calculatedSc
ale.steps)); |
4594 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / calculatedScale.steps); | 4003 if (valueHop == 0 || config.fullWidthGraph) valueHop = (
msr.availableWidth / calculatedScale.steps); |
4595 msr.clrwidth = msr.clrwidth - (msr.availableWidth - (cal
culatedScale.steps * valueHop)); | 4004 msr.clrwidth = msr.clrwidth - (msr.availableWidth - (cal
culatedScale.steps * valueHop)); |
4596 msr.availableWidth = (calculatedScale.steps) * valueHop; | 4005 msr.availableWidth = (calculatedScale.steps) * valueHop; |
4597 msr.availableHeight = (data.labels.length) * scaleHop; | 4006 msr.availableHeight = (data.labels.length) * scaleHop; |
4598 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; | 4007 yAxisPosX = msr.leftNotUsableSize + config.scaleTickSize
Left; |
4599 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; | 4008 xAxisPosY = msr.topNotUsableSize + msr.availableHeight +
config.scaleTickSizeTop; |
4600 barWidth = (scaleHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * data.datasets.length -
1) - ((config.barStrokeWidth / 2) * data.datasets.length - 1)) / data.datasets.
length; | 4009 barWidth = (scaleHop - config.scaleGridLineWidth * 2 - (
config.barValueSpacing * 2) - (config.barDatasetSpacing * data.datasets.length -
1) - ((config.barStrokeWidth / 2) * data.datasets.length - 1)) / data.datasets.
length; |
4601 if(barWidth>=0 && barWidth<=1)barWidth=1; | 4010 if(barWidth>=0 && barWidth<=1)barWidth=1; |
4602 if(barWidth<0 && barWidth>=-1)barWidth=-1; | 4011 if(barWidth<0 && barWidth>=-1)barWidth=-1; |
4603 var zeroY = 0; | 4012 var zeroY = 0; |
4604 if (valueBounds.minValue < 0) { | 4013 if (valueBounds.minValue < 0) { |
4605 var zeroY = calculateOffset(config.logarithmic,
0, calculatedScale, valueHop); | 4014 var zeroY = calculateOffset(config.logarithmic,
0, calculatedScale, valueHop); |
4606 } | 4015 } |
4607 drawLabels(); | 4016 drawLabels(); |
| 4017 initPassVariableData_part2(statData,data,config,ctx,{ |
| 4018 yAxisPosX : yAxisPosX, |
| 4019 xAxisPosY : xAxisPosY, |
| 4020 barWidth : barWidth, |
| 4021 zeroY : zeroY, |
| 4022 scaleHop : scaleHop, |
| 4023 valueHop : valueHop, |
| 4024 calculatedScale : calculatedScale |
| 4025 }); |
4608 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); | 4026 animationLoop(config, drawScale, drawBars, ctx, msr.clrx
, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAx
isPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); |
4609 } else { | 4027 } else { |
4610 testRedraw(ctx,data,config); | 4028 testRedraw(ctx,data,config); |
4611 } | 4029 } |
4612 | 4030 |
4613 function drawBars(animPc) { | 4031 function drawBars(animPc) { |
4614 var cumvalue = new Array(); | |
4615 var totvalue = new Array(); | |
4616 for (var i = 0; i < data.datasets.length; i++) { | 4032 for (var i = 0; i < data.datasets.length; i++) { |
4617 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 4033 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
4618 » » » » » cumvalue[j] = 0; | 4034 » » » » » ctx.lineWidth = config.barStrokeWidth; |
4619 » » » » » totvalue[j] = 0; | |
4620 » » » » } | |
4621 » » » } | |
4622 » » » for (var i = 0; i < data.datasets.length; i++) { | |
4623 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) | |
4624 » » » » » if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) totvalue[j] += 1 * data.datasets[i].data[j]; | |
4625 » » » } | |
4626 » » » ctx.lineWidth = config.barStrokeWidth; | |
4627 » » » for (var i = 0; i < data.datasets.length; i++) { | |
4628 » » » » if (animPc >= 1) { | |
4629 » » » » » if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | |
4630 » » » » » else lgtxt = ""; | |
4631 » » » » } | |
4632 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
4633 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; | 4035 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; |
4634 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; | 4036 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; |
4635 » » » » » var barOffset = xAxisPosY + config.barVa
lueSpacing - scaleHop * (j + 1) + barWidth * i + config.barDatasetSpacing * i +
config.barStrokeWidth * i; | 4037 » » » » » var barHeight = currentAnimPc * statData
[i][j].barWidth + (config.barStrokeWidth / 2); |
4636 » » » » » var barHeight = currentAnimPc * (calcula
teOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedScale, valu
eHop) - zeroY) + (config.barStrokeWidth / 2); | 4038 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data.datasets[i].fillColor,config.defaultFillColor,i,j,{animation
Value: currentAnimPc, xPosLeft : statData[i][j].xPosLeft, yPosBottom : statData[
i][j].yPosBottom, xPosRight : statData[i][j].xPosLeft+barHeight, yPosTop : statD
ata[i][j].yPosBottom} ); |
4637 » » » » » ctx.fillStyle = config.defaultFillColor; | 4039 » » » » » ctx.strokeStyle=setOptionValue("STROKECO
LOR",ctx,data,statData,data.datasets[i].strokeColor,config.defaultStrokeColor,i,
j,{nullvalue : null} ); |
4638 » » » » » if (typeof data.datasets[i].fillColor ==
"function") ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", data, confi
g, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "HorizontalBar", ctx, yAxi
sPosX+zeroY, barOffset, yAxisPosX + zeroY + barHeight, barOffset + barWidth); | 4040 |
4639 » » » » » else if (typeof(data.datasets[i].fillCol
or) == "string") { | |
4640 » » » » » » ctx.fillStyle = data.datasets[i]
.fillColor; | |
4641 » » » » » } else if (typeof(data.datasets[i].fillC
olor) == "object") { | |
4642 » » » » » » if (typeof(data.datasets[i].fill
Color[0]) == "string") { | |
4643 » » » » » » » ctx.fillStyle = data.dat
asets[i].fillColor[Min([data.datasets[i].fillColor.length - 1, j])]; | |
4644 » » » » » » } | |
4645 » » » » » } | |
4646 » » » » » ctx.strokeStyle = config.defaultStrokeCo
lor; | |
4647 » » » » » if (typeof data.datasets[i].strokeColor
== "function") ctx.strokeStyle = data.datasets[i].strokeColor("STROKECOLOR", dat
a, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "HorizontalBar", c
tx, yAxisPosX, barOffset, yAxisPosX + barHeight, barOffset + barWidth); | |
4648 » » » » » else if (typeof(data.datasets[i].strokeC
olor) == "string") { | |
4649 » » » » » » ctx.strokeStyle = data.datasets[
i].strokeColor; | |
4650 » » » » » } else if (typeof(data.datasets[i].strok
eColor) == "object") { | |
4651 » » » » » » if (typeof(data.datasets[i].stro
keColor[0]) == "string") { | |
4652 » » » » » » » ctx.strokeStyle = data.d
atasets[i].strokeColor[Min([data.datasets[i].strokeColor.length - 1, j])]; | |
4653 » » » » » » } | |
4654 » » » » » } | |
4655 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | 4041 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { |
4656 » » » » » » roundRect(ctx, barOffset, yAxisP
osX+zeroY, barWidth, barHeight, config.barShowStroke, config.barBorderRadius, 0)
; | 4042 » » » » » » roundRect(ctx, statData[i][j].yP
osTop, statData[i][j].xPosLeft , barWidth, barHeight, config.barShowStroke, conf
ig.barBorderRadius, 0); |
4657 » » » » » » cumvalue[j] += 1 * data.datasets
[i].data[j]; | |
4658 » » » » » » if (animPc >= 1) { | |
4659 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | |
4660 » » » » » » » else lgtxt2 = ""; | |
4661 » » » » » » » t1 = yAxisPosX + zeroY; | |
4662 » » » » » » » t2 = yAxisPosX + calcula
teOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedScale, valu
eHop) + (config.barStrokeWidth / 2) | |
4663 » » » » » » » if (t1 > t2) { | |
4664 » » » » » » » » t3 = t1; | |
4665 » » » » » » » » t1 = t2; | |
4666 » » » » » » » » t2 = t3 | |
4667 » » » » » » » } | |
4668 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", t1, barOffset + barWi
dth, t2, barOffset, lgtxt, lgtxt2, 1 * data.datasets[i].data[j], cumvalue[j], to
tvalue[j], i, j]; | |
4669 » » » » » » } | |
4670 } | 4043 } |
4671 } | 4044 } |
4672 } | 4045 } |
4673 » » » if (animPc >= 1 && config.inGraphDataShow) { | 4046 » » » if (animPc >= config.animationStopValue) { |
4674 for (var i = 0; i < data.datasets.length; i++) { | 4047 for (var i = 0; i < data.datasets.length; i++) { |
4675 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 4048 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
4676 » » » » » » cumvalue[j] = 0; | 4049 » » » » » » if (typeof(data.datasets[i].data
[j]) == 'undefined') continue; |
4677 » » » » » } | 4050 » » » » » » if(setOptionValue("ANNOTATEDISPL
AY",ctx,data,statData,undefined,config.annotateDisplay,i,j,{nullValue : true}))
{ |
4678 » » » » } | 4051 » » » » » » » jsGraphAnnotate[ctx.Char
tNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", i ,j ,statData]; |
4679 » » » » for (var i = 0; i < data.datasets.length; i++) { | 4052 »» » » } |
4680 » » » » » if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | 4053 »» » » if(setOptionValue("INGRAPHDATASH
OW",ctx,data,statData,undefined,config.inGraphDataShow,i,j,{nullValue : true}))
{ |
4681 » » » » » else lgtxt = ""; | |
4682 » » » » » for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | |
4683 » » » » » » if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { | |
4684 » » » » » » » if (typeof(data.labels[j
]) == "string") lgtxt2 = data.labels[j].trim(); | |
4685 ctx.save(); | 4054 ctx.save(); |
4686 » » » » » » » ctx.textAlign = config.i
nGraphDataAlign; | 4055 » » » » » » » ctx.textAlign = setOptio
nValue("INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,
j,{nullValue: true }); |
4687 » » » » » » » ctx.textBaseline = confi
g.inGraphDataVAlign; | 4056 » » » » » » » ctx.textBaseline = setOp
tionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAli
gn,i,j,{nullValue : true} ); |
4688 » » » » » » » ctx.font = config.inGrap
hDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFo
ntFamily; | 4057 » » » » » » » ctx.font = setOptionValu
e("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle
,i,j,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,
statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ) + 'px ' +
setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGra
phDataFontFamily,i,j,{nullValue : true} ); |
4689 » » » » » » » ctx.fillStyle = config.i
nGraphDataFontColor; | 4058 » » » » » » » ctx.fillStyle = setOptio
nValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFont
Color,i,j,{nullValue : true} ); |
4690 » » » » » » » var barOffset = xAxisPos
Y + config.barValueSpacing - scaleHop * (j + 1) + barWidth * i + config.barDatas
etSpacing * i + config.barStrokeWidth * i; | |
4691 » » » » » » » t1 = yAxisPosX + zeroY; | |
4692 » » » » » » » t2 = yAxisPosX + calcula
teOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedScale, valu
eHop) + (config.barStrokeWidth / 2) | |
4693 » » » » » » » if (t1 > t2) { | |
4694 » » » » » » » » t3 = t1; | |
4695 » » » » » » » » t1 = t2; | |
4696 » » » » » » » » t2 = t3 | |
4697 » » » » » » » } | |
4698 ctx.beginPath(); | 4059 ctx.beginPath(); |
4699 var yPos = 0, | 4060 var yPos = 0, |
4700 xPos = 0; | 4061 xPos = 0; |
4701 » » » » » » » if (config.inGraphDataYP
osition == 1) { | 4062 » » » » » » » if (setOptionValue("INGR
APHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition,i,j,{n
ullValue : true} ) == 1) { |
4702 » » » » » » » » yPos = barOffset
- config.inGraphDataPaddingY + barWidth; | 4063 » » » » » » » » yPos = statData[
i][j].yPosTop - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined
,config.inGraphDataPaddingY,i,j,{nullValue : true} ) + barWidth; |
4703 » » » » » » » } else if (config.inGrap
hDataYPosition == 2) { | 4064 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 2) { |
4704 » » » » » » » » yPos = barOffset
+ barWidth / 2 - config.inGraphDataPaddingY; | 4065 » » » » » » » » yPos = statData[
i][j].yPosTop + barWidth / 2 - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,sta
tData,undefined,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
4705 » » » » » » » } else if (config.inGrap
hDataYPosition == 3) { | 4066 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition
,i,j,{nullValue : true} ) == 3) { |
4706 » » » » » » » » yPos = barOffset
- config.inGraphDataPaddingY; | 4067 » » » » » » » » yPos = statData[
i][j].yPosTop - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined
,config.inGraphDataPaddingY,i,j,{nullValue : true} ); |
4707 } | 4068 } |
4708 » » » » » » » if (config.inGraphDataXP
osition == 1) { | 4069 » » » » » » » if (setOptionValue("INGR
APHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition,i,j,{n
ullValue : true} ) == 1) { |
4709 » » » » » » » » xPos = yAxisPosX
+ zeroY + config.inGraphDataPaddingX; | 4070 » » » » » » » » xPos = statData[
i][j].xPosLeft + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefine
d,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
4710 » » » » » » » } else if (config.inGrap
hDataXPosition == 2) { | 4071 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 2) { |
4711 » » » » » » » » xPos = yAxisPosX
+ (calculateOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculated
Scale, valueHop) + (config.barStrokeWidth / 2)) / 2 + config.inGraphDataPaddingX
; | 4072 » » » » » » » » xPos = (statData
[i][j].xPosLeft+statData[i][j].xPosRight)/2 + setOptionValue("INGRAPHDATAPADDING
X",ctx,data,statData,undefined,config.inGraphDataPaddingX,i,j,{nullValue : true}
); |
4712 » » » » » » » } else if (config.inGrap
hDataXPosition == 3) { | 4073 » » » » » » » } else if (setOptionValu
e("INGRAPHDATAXPOSITION",ctx,data,statData,undefined,config.inGraphDataXPosition
,i,j,{nullValue : true} ) == 3) { |
4713 » » » » » » » » xPos = yAxisPosX
+ calculateOffset(config.logarithmic, 1 * data.datasets[i].data[j], calculatedS
cale, valueHop) + (config.barStrokeWidth / 2) + config.inGraphDataPaddingX; | 4074 » » » » » » » » xPos = statData[
i][j].xPosRight + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefin
ed,config.inGraphDataPaddingX,i,j,{nullValue : true} ); |
4714 } | 4075 } |
4715 ctx.translate(xPos, yPos
); | 4076 ctx.translate(xPos, yPos
); |
4716 » » » » » » » cumvalue[j] += 1 * data.
datasets[i].data[j]; | 4077 » » » » » » » var dispString = tmplbis
(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphData
Tmpl,i,j,{nullValue : true} ), statData[i][j]); |
4717 » » » » » » » var dispString = tmplbis
(config.inGraphDataTmpl, { | 4078 » » » » » » » ctx.rotate(setOptionValu
e("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,j,{
nullValue : true} ) * (Math.PI / 180)); |
4718 » » » » » » » » config: config, | 4079 » » » » » » » ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,
statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),true); |
4719 » » » » » » » » v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), | |
4720 » » » » » » » » v2: fmtChartJS(c
onfig, lgtxt2, config.fmtV2), | |
4721 » » » » » » » » v3: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV3), | |
4722 » » » » » » » » v4: fmtChartJS(c
onfig, cumvalue[j], config.fmtV4), | |
4723 » » » » » » » » v5: fmtChartJS(c
onfig, totvalue[j], config.fmtV5), | |
4724 » » » » » » » » v6: roundToWithT
housands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[j]
, config.fmtV6), config.roundPct), | |
4725 » » » » » » » » v7: fmtChartJS(c
onfig, t1, config.fmtV7), | |
4726 » » » » » » » » v8: fmtChartJS(c
onfig, barOffset + barWidth, config.fmtV8), | |
4727 » » » » » » » » v9: fmtChartJS(c
onfig, t2, config.fmtV9), | |
4728 » » » » » » » » v10: fmtChartJS(
config, barOffset, config.fmtV10), | |
4729 » » » » » » » » v11: fmtChartJS(
config, i, config.fmtV11), | |
4730 » » » » » » » » v12: fmtChartJS(
config, j, config.fmtV12), | |
4731 » » » » » » » » data: data | |
4732 » » » » » » » }); | |
4733 » » » » » » » ctx.rotate(config.inGrap
hDataRotate * (Math.PI / 180)); | |
4734 » » » » » » » ctx.fillTextMultiLine(di
spString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | |
4735 ctx.restore(); | 4080 ctx.restore(); |
4736 } | 4081 } |
4737 } | 4082 } |
4738 } | 4083 } |
4739 } | 4084 } |
4740 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"HorizontalBar"); | 4085 if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,dat
a,config,ctx,"HorizontalBar"); |
4741 }; | 4086 }; |
4742 | 4087 |
4743 function roundRect(ctx, x, y, w, h, stroke, radius, zeroY) { | 4088 function roundRect(ctx, x, y, w, h, stroke, radius, zeroY) { |
4744 ctx.beginPath(); | 4089 ctx.beginPath(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4814 } else { | 4159 } else { |
4815 ctx.textAlign = "center"; | 4160 ctx.textAlign = "center"; |
4816 } | 4161 } |
4817 ctx.fillStyle = config.scaleFontColor; | 4162 ctx.fillStyle = config.scaleFontColor; |
4818 if (config.xAxisBottom) { | 4163 if (config.xAxisBottom) { |
4819 for (var i = ((config.showYAxisMin) ? -1
: 0); i < calculatedScale.steps; i++) { | 4164 for (var i = ((config.showYAxisMin) ? -1
: 0); i < calculatedScale.steps; i++) { |
4820 ctx.save(); | 4165 ctx.save(); |
4821 if (msr.rotateLabels > 0) { | 4166 if (msr.rotateLabels > 0) { |
4822 ctx.translate(yAxisPosX
+ (i + 1) * valueHop - msr.highestXLabel / 2, msr.xLabelPos); | 4167 ctx.translate(yAxisPosX
+ (i + 1) * valueHop - msr.highestXLabel / 2, msr.xLabelPos); |
4823 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); | 4168 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); |
4824 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], 0, 0, ctx.textBaseline, config.scaleFontSize); | 4169 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], 0, 0, ctx.textBaseline, config.scaleFontSize,true); |
4825 } else { | 4170 } else { |
4826 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], yAxisPosX + (i + 1) * valueHop, msr.xLabelPos, ctx.
textBaseline, config.scaleFontSize); | 4171 » » » » » » » ctx.fillTextMultiLine(ca
lculatedScale.labels[i + 1], yAxisPosX + (i + 1) * valueHop, msr.xLabelPos, ctx.
textBaseline, config.scaleFontSize,true); |
4827 } | 4172 } |
4828 ctx.restore(); | 4173 ctx.restore(); |
4829 } | 4174 } |
4830 } | 4175 } |
4831 } | 4176 } |
4832 //Y axis | 4177 //Y axis |
4833 ctx.textAlign = "right"; | 4178 ctx.textAlign = "right"; |
4834 ctx.textBaseline = "middle"; | 4179 ctx.textBaseline = "middle"; |
4835 for (var j = 0; j < data.labels.length; j++) { | 4180 for (var j = 0; j < data.labels.length; j++) { |
4836 if (config.yAxisLeft) { | 4181 if (config.yAxisLeft) { |
4837 ctx.textAlign = "right"; | 4182 ctx.textAlign = "right"; |
4838 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX - (config.scaleTickSizeLeft + conf
ig.yAxisSpaceRight), xAxisPosY - (j * scaleHop) - scaleHop / 2, ctx.textBaseline
, config.scaleFontSize); | 4183 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX - (config.scaleTickSizeLeft + conf
ig.yAxisSpaceRight), xAxisPosY - (j * scaleHop) - scaleHop / 2, ctx.textBaseline
, config.scaleFontSize,true); |
4839 } | 4184 } |
4840 if (config.yAxisRight) { | 4185 if (config.yAxisRight) { |
4841 ctx.textAlign = "left"; | 4186 ctx.textAlign = "left"; |
4842 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX + msr.availableWidth + (config.sca
leTickSizeRight + config.yAxisSpaceRight), xAxisPosY - (j * scaleHop) - scaleHop
/ 2, ctx.textBaseline, config.scaleFontSize); | 4187 » » » » » ctx.fillTextMultiLine(fmtChartJS(config,
data.labels[j], config.fmtXLabel), yAxisPosX + msr.availableWidth + (config.sca
leTickSizeRight + config.yAxisSpaceRight), xAxisPosY - (j * scaleHop) - scaleHop
/ 2, ctx.textBaseline, config.scaleFontSize,true); |
4843 } | 4188 } |
4844 } | 4189 } |
4845 }; | 4190 }; |
4846 | 4191 |
4847 function getValueBounds() { | 4192 function getValueBounds() { |
4848 » » » var upperValue = Number.MIN_VALUE; | 4193 » » » var upperValue = -Number.MAX_VALUE; |
4849 var lowerValue = Number.MAX_VALUE; | 4194 var lowerValue = Number.MAX_VALUE; |
4850 for (var i = 0; i < data.datasets.length; i++) { | 4195 for (var i = 0; i < data.datasets.length; i++) { |
4851 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 4196 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
| 4197 if(typeof data.datasets[i].data[j]=="und
efined")continue; |
4852 if (1 * data.datasets[i].data[j] > upper
Value) { | 4198 if (1 * data.datasets[i].data[j] > upper
Value) { |
4853 upperValue = 1 * data.datasets[i
].data[j] | 4199 upperValue = 1 * data.datasets[i
].data[j] |
4854 }; | 4200 }; |
4855 if (1 * data.datasets[i].data[j] < lower
Value) { | 4201 if (1 * data.datasets[i].data[j] < lower
Value) { |
4856 lowerValue = 1 * data.datasets[i
].data[j] | 4202 lowerValue = 1 * data.datasets[i
].data[j] |
4857 }; | 4203 }; |
4858 } | 4204 } |
4859 }; | 4205 }; |
4860 » » » if (Math.abs(upperValue - lowerValue) < 0.00000001) { | 4206 » » » if(upperValue<lowerValue){upperValue=0;lowerValue=0;} |
4861 » » » » upperValue = Max([upperValue * 2, 1]); | 4207 » » » if (Math.abs(upperValue - lowerValue) < config.zeroValue
) { |
4862 » » » » lowerValue = 0; | 4208 » » » » if(Math.abs(upperValue)< config.zeroValue) upper
Value = .9; |
| 4209 » » » » if(upperValue>0) { |
| 4210 » » » » » upperValue=upperValue*1.1; |
| 4211 » » » » » lowerValue=lowerValue*0.9; |
| 4212 » » » » } else { |
| 4213 » » » » » upperValue=upperValue*0.9; |
| 4214 » » » » » lowerValue=lowerValue*1.1; |
| 4215 » » » » } |
4863 } | 4216 } |
4864 // AJOUT CHANGEMENT | 4217 // AJOUT CHANGEMENT |
4865 » » » if (!isNaN(config.graphMin)) lowerValue = config.graphMi
n; | 4218 » » » if(typeof config.graphMin=="function")lowerValue= setOpt
ionValue("GRAPHMIN",ctx,data,statData,undefined,config.graphMin,-1,-1,{nullValue
: true}) |
4866 » » » if (!isNaN(config.graphMax)) upperValue = config.graphMa
x; | 4219 » » » else if (!isNaN(config.graphMin)) lowerValue = config.gr
aphMin; |
| 4220 » » » if(typeof config.graphMax=="function") upperValue= setOp
tionValue("GRAPHMAX",ctx,data,statData,undefined,config.graphMax,-1,-1,{nullValu
e : true}) |
| 4221 » » » else if (!isNaN(config.graphMax)) upperValue = config.gr
aphMax; |
4867 | 4222 |
4868 labelHeight = config.scaleFontSize; | 4223 labelHeight = config.scaleFontSize; |
4869 scaleHeight = msr.availableHeight; | 4224 scaleHeight = msr.availableHeight; |
4870 | 4225 |
4871 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); | 4226 var maxSteps = Math.floor((scaleHeight / (labelHeight *
0.66))); |
4872 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); | 4227 var minSteps = Math.floor((scaleHeight / labelHeight * 0
.5)); |
4873 return { | 4228 return { |
4874 maxValue: upperValue, | 4229 maxValue: upperValue, |
4875 minValue: lowerValue, | 4230 minValue: lowerValue, |
4876 maxSteps: maxSteps, | 4231 maxSteps: maxSteps, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4985 function calculateScale(axis, config, maxSteps, minSteps, maxValue, minV
alue, labelTemplateString) { | 4340 function calculateScale(axis, config, maxSteps, minSteps, maxValue, minV
alue, labelTemplateString) { |
4986 var graphMin, graphMax, graphRange, stepValue, numberOfSteps, va
lueRange, rangeOrderOfMagnitude, decimalNum; | 4341 var graphMin, graphMax, graphRange, stepValue, numberOfSteps, va
lueRange, rangeOrderOfMagnitude, decimalNum; |
4987 var logarithmic, yAxisMinimumInterval; | 4342 var logarithmic, yAxisMinimumInterval; |
4988 if (axis == 2) { | 4343 if (axis == 2) { |
4989 logarithmic = config.logarithmic2; | 4344 logarithmic = config.logarithmic2; |
4990 yAxisMinimumInterval = config.yAxisMinimumInterval2; | 4345 yAxisMinimumInterval = config.yAxisMinimumInterval2; |
4991 } else { | 4346 } else { |
4992 logarithmic = config.logarithmic; | 4347 logarithmic = config.logarithmic; |
4993 yAxisMinimumInterval = config.yAxisMinimumInterval; | 4348 yAxisMinimumInterval = config.yAxisMinimumInterval; |
4994 } | 4349 } |
| 4350 |
4995 if (!logarithmic) { // no logarithmic scale | 4351 if (!logarithmic) { // no logarithmic scale |
4996 valueRange = maxValue - minValue; | 4352 valueRange = maxValue - minValue; |
4997 rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueR
ange); | 4353 rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueR
ange); |
4998 » » » graphMin = Math.floor(minValue / (1 * Math.pow(10, range
OrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); | 4354 » » » if(Math.abs(minValue)>config.zeroValue)graphMin = Math.f
loor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeO
rderOfMagnitude); |
4999 » » » graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeO
rderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); | 4355 » » » else graphMin=0; |
| 4356 » » » if(Math.abs(maxValue)>config.zeroValue)graphMax = Math.c
eil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOr
derOfMagnitude); |
| 4357 » » » else graphMax=0; |
5000 if (typeof yAxisMinimumInterval == "number") { | 4358 if (typeof yAxisMinimumInterval == "number") { |
5001 » » » » graphMin = graphMin - (graphMin % yAxisMinimumIn
terval); | 4359 » » » » if(graphMax>=0) { |
5002 » » » » while (graphMin > minValue) graphMin = graphMin
- yAxisMinimumInterval; | 4360 » » » » » graphMin = graphMin - (graphMin % yAxisM
inimumInterval); |
5003 » » » » if (graphMax % yAxisMinimumInterval > 0.0000001
&& graphMax % yAxisMinimumInterval < yAxisMinimumInterval - 0.0000001) { | 4361 » » » » » while (graphMin > minValue) graphMin = g
raphMin - yAxisMinimumInterval; |
5004 » » » » » graphMax = roundScale(config, (1 + Math.
floor(graphMax / yAxisMinimumInterval)) * yAxisMinimumInterval); | 4362 » » » » » if (graphMax % yAxisMinimumInterval > co
nfig.zeroValue && graphMax % yAxisMinimumInterval < yAxisMinimumInterval - confi
g.zeroValue) { |
| 4363 » » » » » » graphMax = roundScale(config, (1
+ Math.floor(graphMax / yAxisMinimumInterval)) * yAxisMinimumInterval); |
| 4364 » » » » » } |
| 4365 » » » » » while (graphMax < maxValue) graphMax = g
raphMax + yAxisMinimumInterval; |
5005 } | 4366 } |
5006 while (graphMax < maxValue) graphMax = graphMax
+ yAxisMinimumInterval; | |
5007 } | 4367 } |
5008 } else { // logarithmic scale | 4368 } else { // logarithmic scale |
| 4369 if(minValue==maxValue)maxValue=maxValue+1; |
| 4370 if(minValue==0)minValue=0.01; |
5009 var minMag = calculateOrderOfMagnitude(minValue); | 4371 var minMag = calculateOrderOfMagnitude(minValue); |
5010 var maxMag = calculateOrderOfMagnitude(maxValue) + 1; | 4372 var maxMag = calculateOrderOfMagnitude(maxValue) + 1; |
5011 graphMin = Math.pow(10, minMag); | 4373 graphMin = Math.pow(10, minMag); |
5012 graphMax = Math.pow(10, maxMag); | 4374 graphMax = Math.pow(10, maxMag); |
5013 rangeOrderOfMagnitude = maxMag - minMag; | 4375 rangeOrderOfMagnitude = maxMag - minMag; |
5014 } | 4376 } |
5015 graphRange = graphMax - graphMin; | 4377 graphRange = graphMax - graphMin; |
5016 stepValue = Math.pow(10, rangeOrderOfMagnitude); | 4378 stepValue = Math.pow(10, rangeOrderOfMagnitude); |
5017 numberOfSteps = Math.round(graphRange / stepValue); | 4379 numberOfSteps = Math.round(graphRange / stepValue); |
5018 if (!logarithmic) { // no logarithmic scale | 4380 if (!logarithmic) { // no logarithmic scale |
(...skipping 12 matching lines...) Expand all Loading... |
5031 stepValue *= 2; | 4393 stepValue *= 2; |
5032 numberOfSteps = Math.round(graphRange /
stepValue); | 4394 numberOfSteps = Math.round(graphRange /
stepValue); |
5033 } | 4395 } |
5034 } | 4396 } |
5035 | 4397 |
5036 if (typeof yAxisMinimumInterval == "number") { | 4398 if (typeof yAxisMinimumInterval == "number") { |
5037 if (stepValue < yAxisMinimumInterval) { | 4399 if (stepValue < yAxisMinimumInterval) { |
5038 stepValue = yAxisMinimumInterval; | 4400 stepValue = yAxisMinimumInterval; |
5039 numberOfSteps = Math.round(graphRange /
stepValue); | 4401 numberOfSteps = Math.round(graphRange /
stepValue); |
5040 } | 4402 } |
5041 » » » » if (stepValue % yAxisMinimumInterval > 0.0000001
&& stepValue % yAxisMinimumInterval < yAxisMinimumInterval - 0.0000001) { | 4403 » » » » if (stepValue % yAxisMinimumInterval > config.ze
roValue && stepValue % yAxisMinimumInterval < yAxisMinimumInterval - config.zero
Value) { |
5042 » » » » » if ((2 * stepValue) % yAxisMinimumInterv
al < 0.0000001 || (2 * stepValue) % yAxisMinimumInterval > yAxisMinimumInterval
- 0.0000001) { | 4404 » » » » » if ((2 * stepValue) % yAxisMinimumInterv
al < config.zeroValue || (2 * stepValue) % yAxisMinimumInterval > yAxisMinimumIn
terval - config.zeroValue) { |
5043 stepValue = 2 * stepValue; | 4405 stepValue = 2 * stepValue; |
5044 numberOfSteps = Math.round(graph
Range / stepValue); | 4406 numberOfSteps = Math.round(graph
Range / stepValue); |
5045 } else { | 4407 } else { |
5046 stepValue = roundScale(config, (
1 + Math.floor(stepValue / yAxisMinimumInterval)) * yAxisMinimumInterval); | 4408 stepValue = roundScale(config, (
1 + Math.floor(stepValue / yAxisMinimumInterval)) * yAxisMinimumInterval); |
5047 numberOfSteps = Math.round(graph
Range / stepValue); | 4409 numberOfSteps = Math.round(graph
Range / stepValue); |
5048 } | 4410 } |
5049 } | 4411 } |
5050 } | 4412 } |
5051 } else { // logarithmic scale | 4413 } else { // logarithmic scale |
5052 numberOfSteps = rangeOrderOfMagnitude; // so scale is 10
,100,1000,... | 4414 numberOfSteps = rangeOrderOfMagnitude; // so scale is 10
,100,1000,... |
5053 } | 4415 } |
5054 var labels = []; | 4416 var labels = []; |
5055 populateLabels(1, config, labelTemplateString, labels, numberOfS
teps, graphMin, graphMax, stepValue); | 4417 populateLabels(1, config, labelTemplateString, labels, numberOfS
teps, graphMin, graphMax, stepValue); |
5056 return { | 4418 return { |
5057 steps: numberOfSteps, | 4419 steps: numberOfSteps, |
5058 stepValue: stepValue, | 4420 stepValue: stepValue, |
5059 graphMin: graphMin, | 4421 graphMin: graphMin, |
5060 labels: labels, | 4422 labels: labels, |
5061 maxValue: maxValue | 4423 maxValue: maxValue |
5062 } | 4424 } |
5063 }; | 4425 }; |
5064 | 4426 |
5065 function calculateScaleOld(config, maxSteps, minSteps, maxValue, minValu
e, labelTemplateString) { | |
5066 var graphMin, graphMax, graphRange, stepValue, numberOfSteps, va
lueRange, rangeOrderOfMagnitude, decimalNum; | |
5067 if (!config.logarithmic) { // no logarithmic scale | |
5068 valueRange = maxValue - minValue; | |
5069 rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueR
ange); | |
5070 graphMin = Math.floor(minValue / (1 * Math.pow(10, range
OrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); | |
5071 graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeO
rderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); | |
5072 if (typeof config.yAxisMinimumInterval == "number") { | |
5073 graphMin = graphMin - (graphMin % config.yAxisMi
nimumInterval); | |
5074 while (graphMin > minValue) graphMin = graphMin
- config.yAxisMinimumInterval; | |
5075 if (graphMax % config.yAxisMinimumInterval > 0.0
000001 && graphMax % config.yAxisMinimumInterval < config.yAxisMinimumInterval -
0.0000001) { | |
5076 graphMax = roundScale(config, (1 + Math.
floor(graphMax / config.yAxisMinimumInterval)) * config.yAxisMinimumInterval); | |
5077 } | |
5078 while (graphMax < maxValue) graphMax = graphMax
+ config.yAxisMinimumInterval; | |
5079 } | |
5080 } else { // logarithmic scale | |
5081 var minMag = calculateOrderOfMagnitude(minValue); | |
5082 var maxMag = calculateOrderOfMagnitude(maxValue) + 1; | |
5083 graphMin = Math.pow(10, minMag); | |
5084 graphMax = Math.pow(10, maxMag); | |
5085 rangeOrderOfMagnitude = maxMag - minMag; | |
5086 } | |
5087 graphRange = graphMax - graphMin; | |
5088 stepValue = Math.pow(10, rangeOrderOfMagnitude); | |
5089 numberOfSteps = Math.round(graphRange / stepValue); | |
5090 if (!config.logarithmic) { // no logarithmic scale | |
5091 //Compare number of steps to the max and min for that si
ze graph, and add in half steps if need be. | |
5092 var stopLoop = false; | |
5093 while (!stopLoop && (numberOfSteps < minSteps || numberO
fSteps > maxSteps)) { | |
5094 if (numberOfSteps < minSteps) { | |
5095 if (typeof config.yAxisMinimumInterval =
= "number") { | |
5096 if (stepValue / 2 < config.yAxis
MinimumInterval) stopLoop = true; | |
5097 } | |
5098 if (!stopLoop) { | |
5099 stepValue /= 2; | |
5100 numberOfSteps = Math.round(graph
Range / stepValue); | |
5101 } | |
5102 } else { | |
5103 stepValue *= 2; | |
5104 numberOfSteps = Math.round(graphRange /
stepValue); | |
5105 } | |
5106 } | |
5107 if (typeof config.yAxisMinimumInterval == "number") { | |
5108 if (stepValue < config.yAxisMinimumInterval) { | |
5109 stepValue = config.yAxisMinimumInterval; | |
5110 numberOfSteps = Math.round(graphRange /
stepValue); | |
5111 } | |
5112 if (stepValue % config.yAxisMinimumInterval > 0.
0000001 && stepValue % config.yAxisMinimumInterval < config.yAxisMinimumInterval
- 0.0000001) { | |
5113 if ((2 * stepValue) % config.yAxisMinimu
mInterval < 0.0000001 || (2 * stepValue) % config.yAxisMinimumInterval > config.
yAxisMinimumInterval - 0.0000001) { | |
5114 stepValue = 2 * stepValue; | |
5115 numberOfSteps = Math.round(graph
Range / stepValue); | |
5116 } else { | |
5117 stepValue = roundScale(config, (
1 + Math.floor(stepValue / config.yAxisMinimumInterval)) * config.yAxisMinimumIn
terval); | |
5118 numberOfSteps = Math.round(graph
Range / stepValue); | |
5119 } | |
5120 } | |
5121 } | |
5122 } else { // logarithmic scale | |
5123 numberOfSteps = rangeOrderOfMagnitude; // so scale is 10
,100,1000,... | |
5124 } | |
5125 var labels = []; | |
5126 populateLabels(1, config, labelTemplateString, labels, numberOfS
teps, graphMin, graphMax, stepValue); | |
5127 return { | |
5128 steps: numberOfSteps, | |
5129 stepValue: stepValue, | |
5130 graphMin: graphMin, | |
5131 labels: labels, | |
5132 maxValue: maxValue | |
5133 } | |
5134 }; | |
5135 | |
5136 function roundScale(config, value) { | 4427 function roundScale(config, value) { |
5137 var scldec = 0; | 4428 var scldec = 0; |
5138 var sscl = "" + config.yAxisMinimumInterval; | 4429 var sscl = "" + config.yAxisMinimumInterval; |
5139 if (sscl.indexOf(".") > 0) { | 4430 if (sscl.indexOf(".") > 0) { |
5140 scldec = sscl.substr(sscl.indexOf(".")).length; | 4431 scldec = sscl.substr(sscl.indexOf(".")).length; |
5141 } | 4432 } |
5142 return (Math.round(value * Math.pow(10, scldec)) / Math.pow(10,
scldec)); | 4433 return (Math.round(value * Math.pow(10, scldec)) / Math.pow(10,
scldec)); |
5143 » } | 4434 » } ; |
5144 | 4435 |
5145 function calculateOrderOfMagnitude(val) { | 4436 function calculateOrderOfMagnitude(val) { |
| 4437 if (val==0)return 0; |
5146 return Math.floor(Math.log(val) / Math.LN10); | 4438 return Math.floor(Math.log(val) / Math.LN10); |
5147 }; | 4439 }; |
5148 //Populate an array of all the labels by interpolating the string. | 4440 //Populate an array of all the labels by interpolating the string. |
5149 function populateLabels(axis, config, labelTemplateString, labels, numbe
rOfSteps, graphMin, graphMax, stepValue) { | 4441 function populateLabels(axis, config, labelTemplateString, labels, numbe
rOfSteps, graphMin, graphMax, stepValue) { |
5150 var logarithmic; | 4442 var logarithmic; |
5151 if (axis == 2) { | 4443 if (axis == 2) { |
5152 logarithmic = config.logarithmic2; | 4444 logarithmic = config.logarithmic2; |
5153 fmtYLabel = config.fmtYLabel2; | 4445 fmtYLabel = config.fmtYLabel2; |
5154 } else { | 4446 } else { |
5155 logarithmic = config.logarithmic; | 4447 logarithmic = config.logarithmic; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5199 } | 4491 } |
5200 if (isNumber(minValue)) { | 4492 if (isNumber(minValue)) { |
5201 if (valueToCap < minValue) { | 4493 if (valueToCap < minValue) { |
5202 return minValue; | 4494 return minValue; |
5203 } | 4495 } |
5204 } | 4496 } |
5205 return valueToCap; | 4497 return valueToCap; |
5206 }; | 4498 }; |
5207 | 4499 |
5208 function getDecimalPlaces(num) { | 4500 function getDecimalPlaces(num) { |
5209 » » var numberOfDecimalPlaces; | 4501 » » var match = (''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); |
5210 » » if (num % 1 != 0) { | 4502 » » if (!match) { |
5211 » » » return num.toString().split(".")[1].length | |
5212 » » } else { | |
5213 return 0; | 4503 return 0; |
5214 } | 4504 } |
| 4505 return Math.max( |
| 4506 0, |
| 4507 (match[1] ? match[1].length : 0) - (match[2] ? +match[2]
: 0) |
| 4508 ); |
5215 }; | 4509 }; |
5216 | 4510 |
5217 function mergeChartConfig(defaults, userDefined) { | 4511 function mergeChartConfig(defaults, userDefined) { |
5218 var returnObj = {}; | 4512 var returnObj = {}; |
5219 for (var attrname in defaults) { | 4513 for (var attrname in defaults) { |
5220 returnObj[attrname] = defaults[attrname]; | 4514 returnObj[attrname] = defaults[attrname]; |
5221 } | 4515 } |
5222 for (var attrname in userDefined) { | 4516 for (var attrname in userDefined) { |
5223 returnObj[attrname] = userDefined[attrname]; | 4517 returnObj[attrname] = userDefined[attrname]; |
5224 } | 4518 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5278 break; | 4572 break; |
5279 case -2: | 4573 case -2: |
5280 txtposx += context.canvas.width
/ 2; | 4574 txtposx += context.canvas.width
/ 2; |
5281 if (textAlign == "default") text
Align = "center"; | 4575 if (textAlign == "default") text
Align = "center"; |
5282 break; | 4576 break; |
5283 case 3: | 4577 case 3: |
5284 txtposx += txtposx + 2 * posX -
borderX; | 4578 txtposx += txtposx + 2 * posX -
borderX; |
5285 if (textAlign == "default") text
Align = "left"; | 4579 if (textAlign == "default") text
Align = "left"; |
5286 break; | 4580 break; |
5287 case 4: | 4581 case 4: |
5288 // posX=width; | |
5289 txtposx += context.canvas.width; | 4582 txtposx += context.canvas.width; |
5290 if (textAlign == "default") text
Align = "right"; | 4583 if (textAlign == "default") text
Align = "right"; |
5291 break; | 4584 break; |
5292 default: | 4585 default: |
5293 txtposx += posX; | 4586 txtposx += posX; |
5294 if (textAlign == "default") text
Align = "center"; | 4587 if (textAlign == "default") text
Align = "center"; |
5295 break; | 4588 break; |
5296 } | 4589 } |
5297 switch (1 * config.crossTextRelativePosY[Min([i,
config.crossTextRelativePosY.length - 1])]) { | 4590 switch (1 * config.crossTextRelativePosY[Min([i,
config.crossTextRelativePosY.length - 1])]) { |
5298 case 0: | 4591 case 0: |
(...skipping 24 matching lines...) Expand all Loading... |
5323 if (textBaseline == "default") t
extBaseline = "middle"; | 4616 if (textBaseline == "default") t
extBaseline = "middle"; |
5324 break; | 4617 break; |
5325 } | 4618 } |
5326 ctx.textAlign = textAlign; | 4619 ctx.textAlign = textAlign; |
5327 ctx.textBaseline = textBaseline; | 4620 ctx.textBaseline = textBaseline; |
5328 ctx.translate(1 * txtposx, 1 * txtposy); | 4621 ctx.translate(1 * txtposx, 1 * txtposy); |
5329 ctx.rotate(Math.PI * config.crossTextAngle[Min([
i, config.crossTextAngle.length - 1])] / 180); | 4622 ctx.rotate(Math.PI * config.crossTextAngle[Min([
i, config.crossTextAngle.length - 1])] / 180); |
5330 if (config.crossText[i].substring(0, 1) == "%")
{ | 4623 if (config.crossText[i].substring(0, 1) == "%")
{ |
5331 if (typeof config.crossTextFunction == "
function") disptxt = config.crossTextFunction(i, config.crossText[i], ctx, confi
g, posX, posY, borderX, borderY, overlay, data, animPC); | 4624 if (typeof config.crossTextFunction == "
function") disptxt = config.crossTextFunction(i, config.crossText[i], ctx, confi
g, posX, posY, borderX, borderY, overlay, data, animPC); |
5332 } else disptxt = config.crossText[i]; | 4625 } else disptxt = config.crossText[i]; |
5333 » » » » ctx.fillTextMultiLine(disptxt, 0, 0, ctx.textBas
eline, config.crossTextFontSize[Min([i, config.crossTextFontSize.length - 1])]); | 4626 » » » » ctx.fillTextMultiLine(disptxt, 0, 0, ctx.textBas
eline, config.crossTextFontSize[Min([i, config.crossTextFontSize.length - 1])],t
rue); |
5334 ctx.stroke(); | 4627 ctx.stroke(); |
5335 ctx.restore(); | 4628 ctx.restore(); |
5336 } | 4629 } |
5337 } | 4630 } |
5338 }; | 4631 }; |
5339 | 4632 |
5340 function dispCrossImage(ctx, config, posX, posY, borderX, borderY, overl
ay, data, animPC, cntiter) { | 4633 function dispCrossImage(ctx, config, posX, posY, borderX, borderY, overl
ay, data, animPC, cntiter) { |
5341 var i, disptxt, imageposx, imageposy, imageAlign, imageBaseline; | 4634 var i, disptxt, imageposx, imageposy, imageAlign, imageBaseline; |
5342 for (i = 0; i < config.crossImage.length; i++) { | 4635 for (i = 0; i < config.crossImage.length; i++) { |
5343 if (typeof config.crossImage[i] != "undefined" && config
.crossImageOverlay[Min([i, config.crossImageOverlay.length - 1])] == overlay &&
((cntiter == -1 && config.crossImageIter[Min([i, config.crossImageIter.length -
1])] == "background") || (cntiter == 1 && config.crossImageIter[Min([i, config.c
rossImageIter.length - 1])] == "first") || config.crossImageIter[Min([i, config.
crossImageIter.length - 1])] == cntiter || (cntiter != -1 && config.crossImageIt
er[Min([i, config.crossImageIter.length - 1])] == "all") || (animPC == 1 && conf
ig.crossImageIter[Min([i, config.crossImageIter.length - 1])] == "last"))) { | 4636 if (typeof config.crossImage[i] != "undefined" && config
.crossImageOverlay[Min([i, config.crossImageOverlay.length - 1])] == overlay &&
((cntiter == -1 && config.crossImageIter[Min([i, config.crossImageIter.length -
1])] == "background") || (cntiter == 1 && config.crossImageIter[Min([i, config.c
rossImageIter.length - 1])] == "first") || config.crossImageIter[Min([i, config.
crossImageIter.length - 1])] == cntiter || (cntiter != -1 && config.crossImageIt
er[Min([i, config.crossImageIter.length - 1])] == "all") || (animPC == 1 && conf
ig.crossImageIter[Min([i, config.crossImageIter.length - 1])] == "last"))) { |
(...skipping 17 matching lines...) Expand all Loading... |
5361 break; | 4654 break; |
5362 case -2: | 4655 case -2: |
5363 imageposx += context.canvas.widt
h / 2; | 4656 imageposx += context.canvas.widt
h / 2; |
5364 if (imageAlign == "default") ima
geAlign = "center"; | 4657 if (imageAlign == "default") ima
geAlign = "center"; |
5365 break; | 4658 break; |
5366 case 3: | 4659 case 3: |
5367 imageposx += imageposx + 2 * pos
X - borderX; | 4660 imageposx += imageposx + 2 * pos
X - borderX; |
5368 if (imageAlign == "default") ima
geAlign = "left"; | 4661 if (imageAlign == "default") ima
geAlign = "left"; |
5369 break; | 4662 break; |
5370 case 4: | 4663 case 4: |
5371 // posX=width; | |
5372 imageposx += context.canvas.widt
h; | 4664 imageposx += context.canvas.widt
h; |
5373 if (imageAlign == "default") ima
geAlign = "right"; | 4665 if (imageAlign == "default") ima
geAlign = "right"; |
5374 break; | 4666 break; |
5375 default: | 4667 default: |
5376 imageposx += posX; | 4668 imageposx += posX; |
5377 if (imageAlign == "default") ima
geAlign = "center"; | 4669 if (imageAlign == "default") ima
geAlign = "center"; |
5378 break; | 4670 break; |
5379 } | 4671 } |
5380 switch (1 * config.crossImageRelativePosY[Min([i
, config.crossImageRelativePosY.length - 1])]) { | 4672 switch (1 * config.crossImageRelativePosY[Min([i
, config.crossImageRelativePosY.length - 1])]) { |
5381 case 0: | 4673 case 0: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5428 break; | 4720 break; |
5429 case "middle": | 4721 case "middle": |
5430 imageposy -= (imageHeight / 2); | 4722 imageposy -= (imageHeight / 2); |
5431 break; | 4723 break; |
5432 default: | 4724 default: |
5433 break; | 4725 break; |
5434 } | 4726 } |
5435 ctx.translate(1 * imageposx, 1 * imageposy); | 4727 ctx.translate(1 * imageposx, 1 * imageposy); |
5436 ctx.rotate(Math.PI * config.crossImageAngle[Min(
[i, config.crossImageAngle.length - 1])] / 180); | 4728 ctx.rotate(Math.PI * config.crossImageAngle[Min(
[i, config.crossImageAngle.length - 1])] / 180); |
5437 ctx.drawImage(config.crossImage[i], 0, 0); | 4729 ctx.drawImage(config.crossImage[i], 0, 0); |
5438 // ctx.stroke(); | |
5439 ctx.restore(); | 4730 ctx.restore(); |
5440 } | 4731 } |
5441 } | 4732 } |
5442 }; | 4733 }; |
5443 //**********************************************************************
****************** | 4734 //**********************************************************************
****************** |
5444 function setMeasures(data, config, ctx, height, width, ylabels, ylabels2
, reverseLegend, reverseAxis, drawAxis, drawLegendOnData, legendBox, typegraph)
{ | 4735 function setMeasures(data, config, ctx, height, width, ylabels, ylabels2
, reverseLegend, reverseAxis, drawAxis, drawLegendOnData, legendBox, typegraph)
{ |
5445 if (config.canvasBackgroundColor != "none") ctx.canvas.style.bac
kground = config.canvasBackgroundColor; | 4736 if (config.canvasBackgroundColor != "none") ctx.canvas.style.bac
kground = config.canvasBackgroundColor; |
5446 var borderWidth = 0; | 4737 var borderWidth = 0; |
5447 var xAxisLabelPos = 0; | 4738 var xAxisLabelPos = 0; |
5448 var graphTitleHeight = 0; | 4739 var graphTitleHeight = 0; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5536 if (widestYLabel2 < config.yScaleLabelsMinimumWidth) { | 4827 if (widestYLabel2 < config.yScaleLabelsMinimumWidth) { |
5537 widestYLabel2 = config.yScaleLabelsMinimumWidth; | 4828 widestYLabel2 = config.yScaleLabelsMinimumWidth; |
5538 } | 4829 } |
5539 } | 4830 } |
5540 // yAxisLabel | 4831 // yAxisLabel |
5541 leftNotUsableSize = borderWidth + config.spaceLeft | 4832 leftNotUsableSize = borderWidth + config.spaceLeft |
5542 rightNotUsableSize = borderWidth + config.spaceRight; | 4833 rightNotUsableSize = borderWidth + config.spaceRight; |
5543 if (drawAxis) { | 4834 if (drawAxis) { |
5544 if (typeof(config.yAxisLabel) != "undefined") { | 4835 if (typeof(config.yAxisLabel) != "undefined") { |
5545 if (config.yAxisLabel.trim() != "") { | 4836 if (config.yAxisLabel.trim() != "") { |
5546 » » » » » yAxisLabelWidth = (config.yAxisFontSize
+ config.yAxisLabelSpaceLeft + config.yAxisLabelSpaceRight); | 4837 » » » » » yAxisLabelWidth = config.yAxisFontSize *
(config.yAxisLabel.split("\n").length || 1) + config.yAxisLabelSpaceLeft + conf
ig.yAxisLabelSpaceRight; |
5547 yAxisLabelPosLeft = borderWidth + config
.spaceLeft + config.yAxisLabelSpaceLeft + config.yAxisFontSize; | 4838 yAxisLabelPosLeft = borderWidth + config
.spaceLeft + config.yAxisLabelSpaceLeft + config.yAxisFontSize; |
5548 yAxisLabelPosRight = width - borderWidth
- config.spaceRight - config.yAxisLabelSpaceLeft - config.yAxisFontSize; | 4839 yAxisLabelPosRight = width - borderWidth
- config.spaceRight - config.yAxisLabelSpaceLeft - config.yAxisFontSize; |
5549 } | 4840 } |
5550 } | 4841 } |
5551 if (config.yAxisLeft) { | 4842 if (config.yAxisLeft) { |
5552 if (reverseAxis == false) leftNotUsableSize = bo
rderWidth + config.spaceLeft + yAxisLabelWidth + widestYLabel + config.yAxisSpac
eLeft + config.yAxisSpaceRight; | 4843 if (reverseAxis == false) leftNotUsableSize = bo
rderWidth + config.spaceLeft + yAxisLabelWidth + widestYLabel + config.yAxisSpac
eLeft + config.yAxisSpaceRight; |
5553 else leftNotUsableSize = borderWidth + config.sp
aceLeft + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxisS
paceRight; | 4844 else leftNotUsableSize = borderWidth + config.sp
aceLeft + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxisS
paceRight; |
5554 } | 4845 } |
5555 if (config.yAxisRight) { | 4846 if (config.yAxisRight) { |
5556 if (reverseAxis == false) rightNotUsableSize = b
orderWidth + config.spaceRight + yAxisLabelWidth + widestYLabel2 + config.yAxisS
paceLeft + config.yAxisSpaceRight; | 4847 if (reverseAxis == false) rightNotUsableSize = b
orderWidth + config.spaceRight + yAxisLabelWidth + widestYLabel2 + config.yAxisS
paceLeft + config.yAxisSpaceRight; |
5557 else rightNotUsableSize = borderWidth + config.s
paceRight + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxi
sSpaceRight; | 4848 else rightNotUsableSize = borderWidth + config.s
paceRight + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxi
sSpaceRight; |
5558 } | 4849 } |
5559 } | 4850 } |
5560 availableWidth = width - leftNotUsableSize - rightNotUsableSize; | 4851 availableWidth = width - leftNotUsableSize - rightNotUsableSize; |
5561 // Title | 4852 // Title |
5562 if (config.graphTitle.trim() != "") { | 4853 if (config.graphTitle.trim() != "") { |
5563 » » » graphTitleHeight = (config.graphTitleFontSize + config.g
raphTitleSpaceBefore + config.graphTitleSpaceAfter); | 4854 » » » graphTitleHeight = config.graphTitleFontSize * (config.g
raphTitle.split("\n").length || 1) + config.graphTitleSpaceBefore + config.graph
TitleSpaceAfter; |
5564 graphTitlePosY = borderWidth + config.spaceTop + graphTi
tleHeight - config.graphTitleSpaceAfter; | 4855 graphTitlePosY = borderWidth + config.spaceTop + graphTi
tleHeight - config.graphTitleSpaceAfter; |
5565 } | 4856 } |
5566 // subTitle | 4857 // subTitle |
5567 if (config.graphSubTitle.trim() != "") { | 4858 if (config.graphSubTitle.trim() != "") { |
5568 » » » graphSubTitleHeight = (config.graphSubTitleFontSize + co
nfig.graphSubTitleSpaceBefore + config.graphSubTitleSpaceAfter); | 4859 » » » graphSubTitleHeight = config.graphSubTitleFontSize * (co
nfig.graphSubTitle.split("\n").length || 1) + config.graphSubTitleSpaceBefore +
config.graphSubTitleSpaceAfter; |
5569 graphSubTitlePosY = borderWidth + config.spaceTop + grap
hTitleHeight + graphSubTitleHeight - config.graphSubTitleSpaceAfter; | 4860 graphSubTitlePosY = borderWidth + config.spaceTop + grap
hTitleHeight + graphSubTitleHeight - config.graphSubTitleSpaceAfter; |
5570 } | 4861 } |
5571 // yAxisUnit | 4862 // yAxisUnit |
5572 if (drawAxis) { | 4863 if (drawAxis) { |
5573 if (config.yAxisUnit.trim() != "") { | 4864 if (config.yAxisUnit.trim() != "") { |
5574 » » » » yAxisUnitHeight = (config.yAxisUnitFontSize + co
nfig.yAxisUnitSpaceBefore + config.yAxisUnitSpaceAfter); | 4865 » » » » yAxisUnitHeight = config.yAxisUnitFontSize * (co
nfig.yAxisUnit.split("\n").length || 1) + config.yAxisUnitSpaceBefore + config.y
AxisUnitSpaceAfter; |
5575 yAxisUnitPosY = borderWidth + config.spaceTop +
graphTitleHeight + graphSubTitleHeight + yAxisUnitHeight - config.yAxisUnitSpace
After; | 4866 yAxisUnitPosY = borderWidth + config.spaceTop +
graphTitleHeight + graphSubTitleHeight + yAxisUnitHeight - config.yAxisUnitSpace
After; |
5576 } | 4867 } |
5577 } | 4868 } |
5578 topNotUsableSize = borderWidth + config.spaceTop + graphTitleHei
ght + graphSubTitleHeight + yAxisUnitHeight + config.graphSpaceBefore; | 4869 topNotUsableSize = borderWidth + config.spaceTop + graphTitleHei
ght + graphSubTitleHeight + yAxisUnitHeight + config.graphSpaceBefore; |
5579 // footNote | 4870 // footNote |
5580 if (typeof(config.footNote) != "undefined") { | 4871 if (typeof(config.footNote) != "undefined") { |
5581 if (config.footNote.trim() != "") { | 4872 if (config.footNote.trim() != "") { |
5582 » » » » footNoteHeight = (config.footNoteFontSize + conf
ig.footNoteSpaceBefore + config.footNoteSpaceAfter); | 4873 » » » » footNoteHeight = config.footNoteFontSize * (conf
ig.footNote.split("\n").length || 1) + config.footNoteSpaceBefore + config.footN
oteSpaceAfter; |
5583 footNotePosY = height - config.spaceBottom - bor
derWidth - config.footNoteSpaceAfter; | 4874 footNotePosY = height - config.spaceBottom - bor
derWidth - config.footNoteSpaceAfter; |
5584 } | 4875 } |
5585 } | 4876 } |
5586 | 4877 |
5587 // xAxisLabel | 4878 // xAxisLabel |
5588 if (drawAxis) { | 4879 if (drawAxis) { |
5589 if (typeof(config.xAxisLabel) != "undefined") { | 4880 if (typeof(config.xAxisLabel) != "undefined") { |
5590 if (config.xAxisLabel.trim() != "") { | 4881 if (config.xAxisLabel.trim() != "") { |
5591 » » » » » xAxisLabelHeight = (config.xAxisFontSize
+ config.xAxisLabelSpaceBefore + config.xAxisLabelSpaceAfter); | 4882 » » » » » xAxisLabelHeight = config.xAxisFontSize
* (config.xAxisLabel.split("\n").length || 1) + config.xAxisLabelSpaceBefore + c
onfig.xAxisLabelSpaceAfter; |
5592 xAxisLabelPos = height - borderWidth - c
onfig.spaceBottom - footNoteHeight - config.xAxisLabelSpaceAfter; | 4883 xAxisLabelPos = height - borderWidth - c
onfig.spaceBottom - footNoteHeight - config.xAxisLabelSpaceAfter; |
5593 } | 4884 } |
5594 } | 4885 } |
5595 } | 4886 } |
5596 | 4887 |
5597 bottomNotUsableHeightWithoutXLabels = borderWidth + config.space
Bottom + footNoteHeight + xAxisLabelHeight + config.graphSpaceAfter; | 4888 bottomNotUsableHeightWithoutXLabels = borderWidth + config.space
Bottom + footNoteHeight + xAxisLabelHeight + config.graphSpaceAfter; |
5598 | 4889 |
5599 // compute space for Legend | 4890 // compute space for Legend |
5600 if (typeof(config.legend) != "undefined") { | 4891 if (typeof(config.legend) != "undefined") { |
5601 if (config.legend == true) { | 4892 if (config.legend == true) { |
(...skipping 27 matching lines...) Expand all Loading... |
5629 availableLegendWidth = available
Width- config.legendSpaceLeftText - config.legendSpaceRightText; | 4920 availableLegendWidth = available
Width- config.legendSpaceLeftText - config.legendSpaceRightText; |
5630 } else { | 4921 } else { |
5631 availableLegendWidth = width - c
onfig.spaceLeft - config.spaceRight - 2 * (borderWidth) - config.legendSpaceLeft
Text - config.legendSpaceRightText; | 4922 availableLegendWidth = width - c
onfig.spaceLeft - config.spaceRight - 2 * (borderWidth) - config.legendSpaceLeft
Text - config.legendSpaceRightText; |
5632 } | 4923 } |
5633 if (config.legendBorders == true) availa
bleLegendWidth -= 2 * (config.legendBordersWidth) - config.legendBordersSpaceLef
t - config.legendBordersSpaceRight; | 4924 if (config.legendBorders == true) availa
bleLegendWidth -= 2 * (config.legendBordersWidth) - config.legendBordersSpaceLef
t - config.legendBordersSpaceRight; |
5634 maxLegendOnLine = Min([Math.floor((avail
ableLegendWidth + config.legendSpaceBetweenTextHorizontal) / (widestLegend + con
fig.legendSpaceBetweenTextHorizontal)),config.maxLegendCols]); | 4925 maxLegendOnLine = Min([Math.floor((avail
ableLegendWidth + config.legendSpaceBetweenTextHorizontal) / (widestLegend + con
fig.legendSpaceBetweenTextHorizontal)),config.maxLegendCols]); |
5635 nbLegendLines = Math.ceil(nbeltLegend /
maxLegendOnLine); | 4926 nbLegendLines = Math.ceil(nbeltLegend /
maxLegendOnLine); |
5636 nbLegendCols = Math.ceil(nbeltLegend / n
bLegendLines); | 4927 nbLegendCols = Math.ceil(nbeltLegend / n
bLegendLines); |
5637 | 4928 |
5638 var legendHeight = nbLegendLines * (conf
ig.legendFontSize + config.legendSpaceBetweenTextVertical) - config.legendSpaceB
etweenTextVertical + config.legendSpaceBeforeText + config.legendSpaceAfterText; | 4929 var legendHeight = nbLegendLines * (conf
ig.legendFontSize + config.legendSpaceBetweenTextVertical) - config.legendSpaceB
etweenTextVertical + config.legendSpaceBeforeText + config.legendSpaceAfterText; |
5639 if (config.legendBorders == true) { | |
5640 // legendHeight += 2 * config.legen
dBordersWidth + config.legendBordersSpaceBefore + config.legendBordersSpaceAfter
; | |
5641 } | |
5642 | 4930 |
5643 switch (config.legendPosY) { | 4931 switch (config.legendPosY) { |
5644 case 0: | 4932 case 0: |
5645 xFirstLegendTextPos = co
nfig.spaceLeft + (width - config.spaceLeft - config.spaceRight - nbLegendCols *
(widestLegend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBet
weenTextHorizontal) / 2; | 4933 xFirstLegendTextPos = co
nfig.spaceLeft + (width - config.spaceLeft - config.spaceRight - nbLegendCols *
(widestLegend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBet
weenTextHorizontal) / 2; |
5646 spaceLegendHeight = lege
ndHeight; | 4934 spaceLegendHeight = lege
ndHeight; |
5647 if (config.legendBorders
== true) { | 4935 if (config.legendBorders
== true) { |
5648 yLegendBorderPos
= topNotUsableSize + config.legendBordersSpaceBefore + (config.legendBordersWid
th/2); | 4936 yLegendBorderPos
= topNotUsableSize + config.legendBordersSpaceBefore + (config.legendBordersWid
th/2); |
5649 yFirstLegendText
Pos = yLegendBorderPos + (config.legendBordersWidth/2) + config.legendSpaceBefo
reText+config.legendFontSize; | 4937 yFirstLegendText
Pos = yLegendBorderPos + (config.legendBordersWidth/2) + config.legendSpaceBefo
reText+config.legendFontSize; |
5650 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; | 4938 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; |
5651 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); | 4939 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); |
(...skipping 28 matching lines...) Expand all Loading... |
5680 yFirstLegendTextPos = to
pNotUsableSize + (height - topNotUsableSize - bottomNotUsableHeightWithoutXLabel
s - spaceLegendHeight) /2 + config.legendSpaceBeforeText+config.legendFontSize; | 4968 yFirstLegendTextPos = to
pNotUsableSize + (height - topNotUsableSize - bottomNotUsableHeightWithoutXLabel
s - spaceLegendHeight) /2 + config.legendSpaceBeforeText+config.legendFontSize; |
5681 if (config.legendBorders
== true) { | 4969 if (config.legendBorders
== true) { |
5682 yFirstLegendText
Pos += config.legendBordersSpaceBefore - config.legendBordersSpaceAfter; | 4970 yFirstLegendText
Pos += config.legendBordersSpaceBefore - config.legendBordersSpaceAfter; |
5683 yLegendBorderPos
= yFirstLegendTextPos - config.legendSpaceBeforeText - config.legendFontSize -
(config.legendBordersWidth /2 ); | 4971 yLegendBorderPos
= yFirstLegendTextPos - config.legendSpaceBeforeText - config.legendFontSize -
(config.legendBordersWidth /2 ); |
5684 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; | 4972 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; |
5685 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); | 4973 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); |
5686 legendBorderHeig
ht = Math.ceil(spaceLegendHeight - config.legendBordersWidth) - config.legendBor
dersSpaceBefore - config.legendBordersSpaceAfter; | 4974 legendBorderHeig
ht = Math.ceil(spaceLegendHeight - config.legendBordersWidth) - config.legendBor
dersSpaceBefore - config.legendBordersSpaceAfter; |
5687 legendBorderWidt
h = Math.ceil(nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizo
ntal)) - config.legendSpaceBetweenTextHorizontal + config.legendBordersWidth + c
onfig.legendSpaceRightText + config.legendSpaceLeftText; | 4975 legendBorderWidt
h = Math.ceil(nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizo
ntal)) - config.legendSpaceBetweenTextHorizontal + config.legendBordersWidth + c
onfig.legendSpaceRightText + config.legendSpaceLeftText; |
5688 } | 4976 } |
5689 break; | 4977 break; |
| 4978 case -2: |
| 4979 spaceLegendHeight = lege
ndHeight; |
| 4980 xFirstLegendTextPos = co
nfig.spaceLeft + (width - config.spaceLeft - config.spaceRight - nbLegendCols *
(widestLegend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBet
weenTextHorizontal) / 2; |
| 4981 yFirstLegendTextPos = (h
eight - spaceLegendHeight) /2 + config.legendSpaceBeforeText+config.legendFontSi
ze; |
| 4982 if (config.legendBorders
== true) { |
| 4983 yFirstLegendText
Pos += config.legendBordersSpaceBefore - config.legendBordersSpaceAfter; |
| 4984 yLegendBorderPos
= yFirstLegendTextPos - config.legendSpaceBeforeText - config.legendFontSize -
(config.legendBordersWidth /2 ); |
| 4985 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; |
| 4986 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); |
| 4987 legendBorderHeig
ht = Math.ceil(spaceLegendHeight - config.legendBordersWidth) - config.legendBor
dersSpaceBefore - config.legendBordersSpaceAfter; |
| 4988 legendBorderWidt
h = Math.ceil(nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizo
ntal)) - config.legendSpaceBetweenTextHorizontal + config.legendBordersWidth + c
onfig.legendSpaceRightText + config.legendSpaceLeftText; |
| 4989 } |
| 4990 break; |
5690 case 3: | 4991 case 3: |
5691 spaceLegendHeight = lege
ndHeight; | 4992 spaceLegendHeight = lege
ndHeight; |
5692 xFirstLegendTextPos = co
nfig.spaceLeft + (width - config.spaceLeft - config.spaceRight - nbLegendCols *
(widestLegend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBet
weenTextHorizontal) / 2; | 4993 xFirstLegendTextPos = co
nfig.spaceLeft + (width - config.spaceLeft - config.spaceRight - nbLegendCols *
(widestLegend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBet
weenTextHorizontal) / 2; |
5693 availableHeight = height
- topNotUsableSize - bottomNotUsableHeightWithoutXLabels; | 4994 availableHeight = height
- topNotUsableSize - bottomNotUsableHeightWithoutXLabels; |
5694 yFirstLegendTextPos = to
pNotUsableSize + availableHeight - spaceLegendHeight + config.legendSpaceBeforeT
ext+config.legendFontSize; | 4995 yFirstLegendTextPos = to
pNotUsableSize + availableHeight - spaceLegendHeight + config.legendSpaceBeforeT
ext+config.legendFontSize; |
5695 if (config.legendBorders
== true) { | 4996 if (config.legendBorders
== true) { |
5696 yFirstLegendText
Pos -= (config.legendBordersSpaceAfter+config.legendBordersWidth); | 4997 yFirstLegendText
Pos -= (config.legendBordersSpaceAfter+config.legendBordersWidth); |
5697 yLegendBorderPos
= yFirstLegendTextPos - config.legendSpaceBeforeText - config.legendFontSize -
(config.legendBordersWidth /2 ); | 4998 yLegendBorderPos
= yFirstLegendTextPos - config.legendSpaceBeforeText - config.legendFontSize -
(config.legendBordersWidth /2 ); |
5698 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; | 4999 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; |
5699 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); | 5000 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); |
5700 legendBorderHeig
ht = Math.ceil(spaceLegendHeight - config.legendBordersWidth) - config.legendBor
dersSpaceBefore - config.legendBordersSpaceAfter; | 5001 legendBorderHeig
ht = Math.ceil(spaceLegendHeight - config.legendBordersWidth) - config.legendBor
dersSpaceBefore - config.legendBordersSpaceAfter; |
5701 legendBorderWidt
h = Math.ceil(nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizo
ntal)) - config.legendSpaceBetweenTextHorizontal + config.legendBordersWidth + c
onfig.legendSpaceRightText + config.legendSpaceLeftText; | 5002 legendBorderWidt
h = Math.ceil(nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizo
ntal)) - config.legendSpaceBetweenTextHorizontal + config.legendBordersWidth + c
onfig.legendSpaceRightText + config.legendSpaceLeftText; |
5702 } | 5003 } |
5703 break; | 5004 break; |
5704 default: | 5005 default: |
5705 spaceLegendHeight = lege
ndHeight; | 5006 spaceLegendHeight = lege
ndHeight; |
5706 yFirstLegendTextPos = he
ight - borderWidth - config.spaceBottom - footNoteHeight - spaceLegendHeight + c
onfig.legendSpaceBeforeText + config.legendFontSize; | 5007 yFirstLegendTextPos = he
ight - borderWidth - config.spaceBottom - footNoteHeight - spaceLegendHeight + c
onfig.legendSpaceBeforeText + config.legendFontSize; |
5707 xFirstLegendTextPos = co
nfig.spaceLeft + (width - config.spaceLeft - config.spaceRight - nbLegendCols *
(widestLegend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBet
weenTextHorizontal) / 2; | 5008 xFirstLegendTextPos = co
nfig.spaceLeft + (width - config.spaceLeft - config.spaceRight - nbLegendCols *
(widestLegend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBet
weenTextHorizontal) / 2; |
5708 if (config.legendBorders
== true) { | 5009 if (config.legendBorders
== true) { |
5709 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; | 5010 spaceLegendHeigh
t += 2 * config.legendBordersWidth + config.legendBordersSpaceBefore + config.le
gendBordersSpaceAfter; |
5710 yFirstLegendText
Pos -= (config.legendBordersWidth + config.legendBordersSpaceAfter); | 5011 yFirstLegendText
Pos -= (config.legendBordersWidth + config.legendBordersSpaceAfter); |
5711 yLegendBorderPos
= Math.floor(height - borderWidth - config.spaceBottom - footNoteHeight - space
LegendHeight + (config.legendBordersWidth / 2) + config.legendBordersSpaceBefore
); | 5012 yLegendBorderPos
= Math.floor(height - borderWidth - config.spaceBottom - footNoteHeight - space
LegendHeight + (config.legendBordersWidth / 2) + config.legendBordersSpaceBefore
); |
5712 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); | 5013 xLegendBorderPos
= Math.floor(xFirstLegendTextPos - config.legendSpaceLeftText - (config.legendB
ordersWidth / 2)); |
5713 legendBorderHeig
ht = Math.ceil(spaceLegendHeight - config.legendBordersWidth) - config.legendBor
dersSpaceBefore - config.legendBordersSpaceAfter; | 5014 legendBorderHeig
ht = Math.ceil(spaceLegendHeight - config.legendBordersWidth) - config.legendBor
dersSpaceBefore - config.legendBordersSpaceAfter; |
5714 legendBorderWidt
h = Math.ceil(nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizo
ntal)) - config.legendSpaceBetweenTextHorizontal + config.legendBordersWidth + c
onfig.legendSpaceRightText + config.legendSpaceLeftText; | 5015 legendBorderWidt
h = Math.ceil(nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizo
ntal)) - config.legendSpaceBetweenTextHorizontal + config.legendBordersWidth + c
onfig.legendSpaceRightText + config.legendSpaceLeftText; |
5715 } | 5016 } |
5716 xAxisLabelPos -= spaceLe
gendHeight; | 5017 xAxisLabelPos -= spaceLe
gendHeight; |
5717 // xLabelPos -= spaceLegend
Height; | |
5718 bottomNotUsableHeightWit
houtXLabels +=spaceLegendHeight; | 5018 bottomNotUsableHeightWit
houtXLabels +=spaceLegendHeight; |
5719 break; | 5019 break; |
5720 } | 5020 } |
5721 var fullLegendWidth=config.legendSpaceRi
ghtText + nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizontal
) - config.legendSpaceBetweenTextHorizontal +config.legendSpaceLeftText; | 5021 var fullLegendWidth=config.legendSpaceRi
ghtText + nbLegendCols * (widestLegend + config.legendSpaceBetweenTextHorizontal
) - config.legendSpaceBetweenTextHorizontal +config.legendSpaceLeftText; |
5722 if (config.legendBorders == true) { | 5022 if (config.legendBorders == true) { |
5723 fullLegendWidth+=2*config.legend
BordersWidth+config.legendBordersSpaceLeft+config.legendBordersSpaceRight; | 5023 fullLegendWidth+=2*config.legend
BordersWidth+config.legendBordersSpaceLeft+config.legendBordersSpaceRight; |
5724 } | 5024 } |
5725 | 5025 |
5726 switch (config.legendPosX) { | 5026 switch (config.legendPosX) { |
5727 case 0: | 5027 case 0: |
5728 xFirstLegendTextPos = co
nfig.spaceLeft + config.canvasBorders * config.canvasBordersWidth + config.legen
dSpaceLeftText; | 5028 xFirstLegendTextPos = co
nfig.spaceLeft + config.canvasBorders * config.canvasBordersWidth + config.legen
dSpaceLeftText; |
5729 if (config.legendBorders
== true) { | 5029 if (config.legendBorders
== true) { |
5730 » » » » » » » » xFirstLegendText
Pos += config.legendBordersWidth+config.legendBordersSpaceLeft; | 5030 » » » » » » » » xFirstLegendText
Pos += (config.legendBordersWidth/2)+config.legendBordersSpaceLeft; |
5731 xLegendBorderPos
= config.spaceLeft + config.canvasBorders * config.canvasBordersWidth + config.
legendBordersSpaceLeft; | 5031 xLegendBorderPos
= config.spaceLeft + config.canvasBorders * config.canvasBordersWidth + config.
legendBordersSpaceLeft; |
5732 } | 5032 } |
5733 » » » » » » » if(config.legendPosY>=1
&& config.legendPosY <=3) { | 5033 » » » » » » » if((config.legendPosY>=1
&& config.legendPosY <=3) || config.legendPosY==-2) { |
5734 leftNotUsableSiz
e+=fullLegendWidth; | 5034 leftNotUsableSiz
e+=fullLegendWidth; |
5735 yAxisLabelPosLef
t+=fullLegendWidth; | 5035 yAxisLabelPosLef
t+=fullLegendWidth; |
5736 } | 5036 } |
5737 break; | 5037 break; |
5738 case 1: | 5038 case 1: |
5739 xFirstLegendTextPos = le
ftNotUsableSize + config.legendSpaceLeftText; | 5039 xFirstLegendTextPos = le
ftNotUsableSize + config.legendSpaceLeftText; |
5740 if (config.legendBorders
== true) { | 5040 if (config.legendBorders
== true) { |
5741 xLegendBorderPos
= xFirstLegendTextPos; | 5041 xLegendBorderPos
= xFirstLegendTextPos; |
5742 » » » » » » » » xFirstLegendText
Pos += config.legendBordersWidth+config.legendBordersSpaceLeft; | 5042 » » » » » » » » xFirstLegendText
Pos += (config.legendBordersWidth/2) +config.legendBordersSpaceLeft; |
5743 } | 5043 } |
5744 break; | 5044 break; |
5745 case 2: | 5045 case 2: |
5746 xFirstLegendTextPos = le
ftNotUsableSize + (width - rightNotUsableSize - leftNotUsableSize)/2 - (config.l
egendSpaceLeftText-config.legendSpaceRightText) - (nbLegendCols * (widestLegend
+ config.legendSpaceBetweenTextHorizontal) - config.legendSpaceBetweenTextHorizo
ntal) / 2; | 5046 xFirstLegendTextPos = le
ftNotUsableSize + (width - rightNotUsableSize - leftNotUsableSize)/2 - (config.l
egendSpaceLeftText-config.legendSpaceRightText) - (nbLegendCols * (widestLegend
+ config.legendSpaceBetweenTextHorizontal) - config.legendSpaceBetweenTextHorizo
ntal) / 2; |
5747 if (config.legendBorders
== true) { | 5047 if (config.legendBorders
== true) { |
5748 » » » » » » » » xFirstLegendText
Pos -= (config.legendBordersWidth + config.legendBordersSpaceRight); | 5048 » » » » » » » » xFirstLegendText
Pos -= ((config.legendBordersWidth/2) + config.legendBordersSpaceRight); |
5749 xLegendBorderPos
= xFirstLegendTextPos - config.legendBordersWidth/2 - config.legendSpaceLeftTex
t ; | 5049 xLegendBorderPos
= xFirstLegendTextPos - config.legendBordersWidth/2 - config.legendSpaceLeftTex
t ; |
5750 } | 5050 } |
5751 break; | 5051 break; |
5752 case 3: | 5052 case 3: |
5753 | 5053 |
5754 xFirstLegendTextPos = wi
dth - rightNotUsableSize - config.legendSpaceRightText - nbLegendCols * (widestL
egend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBetweenText
Horizontal / 2; | 5054 xFirstLegendTextPos = wi
dth - rightNotUsableSize - config.legendSpaceRightText - nbLegendCols * (widestL
egend + config.legendSpaceBetweenTextHorizontal) + config.legendSpaceBetweenText
Horizontal / 2; |
5755 if (config.legendBorders
== true) { | 5055 if (config.legendBorders
== true) { |
5756 » » » » » » » » xFirstLegendText
Pos -= (config.legendBordersWidth + config.legendBordersSpaceRight); | 5056 » » » » » » » » xFirstLegendText
Pos -= ((config.legendBordersWidth/2) + config.legendBordersSpaceRight); |
5757 xLegendBorderPos
= xFirstLegendTextPos - config.legendBordersWidth/2 - config.legendSpaceLeftTex
t ; | 5057 xLegendBorderPos
= xFirstLegendTextPos - config.legendBordersWidth/2 - config.legendSpaceLeftTex
t ; |
5758 } | 5058 } |
5759 break; | 5059 break; |
5760 case 4: | 5060 case 4: |
5761 xFirstLegendTextPos = wi
dth - config.spaceRight - config.canvasBorders * config.canvasBordersWidth - con
fig.legendSpaceRightText - nbLegendCols * (widestLegend + config.legendSpaceBetw
eenTextHorizontal) + config.legendSpaceBetweenTextHorizontal / 2; | 5061 xFirstLegendTextPos = wi
dth - config.spaceRight - config.canvasBorders * config.canvasBordersWidth - con
fig.legendSpaceRightText - nbLegendCols * (widestLegend + config.legendSpaceBetw
eenTextHorizontal) + config.legendSpaceBetweenTextHorizontal / 2; |
5762 if (config.legendBorders
== true) { | 5062 if (config.legendBorders
== true) { |
5763 » » » » » » » » xFirstLegendText
Pos -= (config.legendBordersWidth+config.legendBordersSpaceRight); | 5063 » » » » » » » » xFirstLegendText
Pos -= ((config.legendBordersWidth/2)+config.legendBordersSpaceRight); |
5764 xLegendBorderPos
= xFirstLegendTextPos - config.legendBordersSpaceLeft - config.legendBordersWid
th/2; | 5064 xLegendBorderPos
= xFirstLegendTextPos - config.legendBordersSpaceLeft - config.legendBordersWid
th/2; |
5765 } | 5065 } |
5766 » » » » » » » if(config.legendPosY>=1
&& config.legendPosY <=3) { | 5066 » » » » » » » if((config.legendPosY>=1
&& config.legendPosY <=3) || config.legendPosY==-2) { |
5767 rightNotUsableSi
ze+=fullLegendWidth; | 5067 rightNotUsableSi
ze+=fullLegendWidth; |
5768 yAxisLabelPosRig
ht-=fullLegendWidth; | 5068 yAxisLabelPosRig
ht-=fullLegendWidth; |
5769 } | 5069 } |
5770 break; | 5070 break; |
5771 | 5071 |
5772 default: | 5072 default: |
5773 break; | 5073 break; |
5774 } | 5074 } |
5775 if(config.legendBorders==true) { | 5075 if(config.legendBorders==true) { |
5776 yLegendBorderPos+=config.legendY
Padding; | 5076 yLegendBorderPos+=config.legendY
Padding; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5844 } | 5144 } |
5845 // Draw Graph Title | 5145 // Draw Graph Title |
5846 if (graphTitleHeight > 0) { | 5146 if (graphTitleHeight > 0) { |
5847 ctx.save(); | 5147 ctx.save(); |
5848 ctx.beginPath(); | 5148 ctx.beginPath(); |
5849 ctx.font = config.graphTitleFontStyle + " " + co
nfig.graphTitleFontSize + "px " + config.graphTitleFontFamily; | 5149 ctx.font = config.graphTitleFontStyle + " " + co
nfig.graphTitleFontSize + "px " + config.graphTitleFontFamily; |
5850 ctx.fillStyle = config.graphTitleFontColor; | 5150 ctx.fillStyle = config.graphTitleFontColor; |
5851 ctx.textAlign = "center"; | 5151 ctx.textAlign = "center"; |
5852 ctx.textBaseline = "bottom"; | 5152 ctx.textBaseline = "bottom"; |
5853 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphTitlePosY); | 5153 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphTitlePosY); |
5854 » » » » ctx.fillText(config.graphTitle, 0, 0); | 5154 » » » » ctx.fillTextMultiLine(config.graphTitle, 0, 0, c
tx.textBaseline, config.graphTitleFontSize,true); |
5855 ctx.stroke(); | 5155 ctx.stroke(); |
5856 ctx.restore(); | 5156 ctx.restore(); |
5857 } | 5157 } |
5858 // Draw Graph Sub-Title | 5158 // Draw Graph Sub-Title |
5859 if (graphSubTitleHeight > 0) { | 5159 if (graphSubTitleHeight > 0) { |
5860 ctx.save(); | 5160 ctx.save(); |
5861 ctx.beginPath(); | 5161 ctx.beginPath(); |
5862 ctx.font = config.graphSubTitleFontStyle + " " +
config.graphSubTitleFontSize + "px " + config.graphSubTitleFontFamily; | 5162 ctx.font = config.graphSubTitleFontStyle + " " +
config.graphSubTitleFontSize + "px " + config.graphSubTitleFontFamily; |
5863 ctx.fillStyle = config.graphSubTitleFontColor; | 5163 ctx.fillStyle = config.graphSubTitleFontColor; |
5864 ctx.textAlign = "center"; | 5164 ctx.textAlign = "center"; |
5865 ctx.textBaseline = "bottom"; | 5165 ctx.textBaseline = "bottom"; |
5866 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphSubTitlePosY); | 5166 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphSubTitlePosY); |
5867 » » » » ctx.fillText(config.graphSubTitle, 0, 0); | 5167 » » » » ctx.fillTextMultiLine(config.graphSubTitle, 0, 0
, ctx.textBaseline, config.graphSubTitleFontSize,true); |
5868 ctx.stroke(); | 5168 ctx.stroke(); |
5869 ctx.restore(); | 5169 ctx.restore(); |
5870 } | 5170 } |
5871 // Draw Y Axis Unit | 5171 // Draw Y Axis Unit |
5872 if (yAxisUnitHeight > 0) { | 5172 if (yAxisUnitHeight > 0) { |
5873 if (config.yAxisLeft) { | 5173 if (config.yAxisLeft) { |
5874 ctx.save(); | 5174 ctx.save(); |
5875 ctx.beginPath(); | 5175 ctx.beginPath(); |
5876 ctx.font = config.yAxisUnitFontStyle + "
" + config.yAxisUnitFontSize + "px " + config.yAxisUnitFontFamily; | 5176 ctx.font = config.yAxisUnitFontStyle + "
" + config.yAxisUnitFontSize + "px " + config.yAxisUnitFontFamily; |
5877 ctx.fillStyle = config.yAxisUnitFontColo
r; | 5177 ctx.fillStyle = config.yAxisUnitFontColo
r; |
5878 ctx.textAlign = "center"; | 5178 ctx.textAlign = "center"; |
5879 ctx.textBaseline = "bottom"; | 5179 ctx.textBaseline = "bottom"; |
5880 ctx.translate(leftNotUsableSize, yAxisUn
itPosY); | 5180 ctx.translate(leftNotUsableSize, yAxisUn
itPosY); |
5881 » » » » » ctx.fillText(config.yAxisUnit, 0, 0); | 5181 » » » » » ctx.fillTextMultiLine(config.yAxisUnit,
0, 0, ctx.textBaseline, config.yAxisUnitFontSize,true); |
5882 ctx.stroke(); | 5182 ctx.stroke(); |
5883 ctx.restore(); | 5183 ctx.restore(); |
5884 } | 5184 } |
5885 if (config.yAxisRight) { | 5185 if (config.yAxisRight) { |
5886 if (config.yAxisUnit2 == '') config.yAxi
sUnit2 = config.yAxisUnit; | 5186 if (config.yAxisUnit2 == '') config.yAxi
sUnit2 = config.yAxisUnit; |
5887 ctx.save(); | 5187 ctx.save(); |
5888 ctx.beginPath(); | 5188 ctx.beginPath(); |
5889 ctx.font = config.yAxisUnitFontStyle + "
" + config.yAxisUnitFontSize + "px " + config.yAxisUnitFontFamily; | 5189 ctx.font = config.yAxisUnitFontStyle + "
" + config.yAxisUnitFontSize + "px " + config.yAxisUnitFontFamily; |
5890 ctx.fillStyle = config.yAxisUnitFontColo
r; | 5190 ctx.fillStyle = config.yAxisUnitFontColo
r; |
5891 ctx.textAlign = "center"; | 5191 ctx.textAlign = "center"; |
5892 ctx.textBaseline = "bottom"; | 5192 ctx.textBaseline = "bottom"; |
5893 ctx.translate(width - rightNotUsableSize
, yAxisUnitPosY); | 5193 ctx.translate(width - rightNotUsableSize
, yAxisUnitPosY); |
5894 » » » » » ctx.fillText(config.yAxisUnit2, 0, 0); | 5194 » » » » » ctx.fillTextMultiLine(config.yAxisUnit2,
0, 0, ctx.textBaseline, config.yAxisUnitFontSize,true); |
5895 ctx.stroke(); | 5195 ctx.stroke(); |
5896 ctx.restore(); | 5196 ctx.restore(); |
5897 } | 5197 } |
5898 } | 5198 } |
5899 // Draw Y Axis Label | 5199 // Draw Y Axis Label |
5900 if (yAxisLabelWidth > 0) { | 5200 if (yAxisLabelWidth > 0) { |
5901 if (config.yAxisLeft) { | 5201 if (config.yAxisLeft) { |
5902 ctx.save(); | 5202 ctx.save(); |
5903 ctx.beginPath(); | 5203 ctx.beginPath(); |
5904 ctx.font = config.yAxisFontStyle + " " +
config.yAxisFontSize + "px " + config.yAxisFontFamily; | 5204 ctx.font = config.yAxisFontStyle + " " +
config.yAxisFontSize + "px " + config.yAxisFontFamily; |
5905 ctx.fillStyle = config.yAxisFontColor; | 5205 ctx.fillStyle = config.yAxisFontColor; |
5906 ctx.textAlign = "center"; | 5206 ctx.textAlign = "center"; |
5907 ctx.textBaseline = "bottom"; | 5207 ctx.textBaseline = "bottom"; |
5908 ctx.translate(yAxisLabelPosLeft, topNotU
sableSize + (availableHeight / 2)); | 5208 ctx.translate(yAxisLabelPosLeft, topNotU
sableSize + (availableHeight / 2)); |
5909 ctx.rotate(-(90 * (Math.PI / 180))); | 5209 ctx.rotate(-(90 * (Math.PI / 180))); |
5910 » » » » » ctx.fillText(config.yAxisLabel, 0, 0); | 5210 » » » » » ctx.fillTextMultiLine(config.yAxisLabel,
0, 0, ctx.textBaseline, config.yAxisFontSize,false); |
5911 ctx.stroke(); | 5211 ctx.stroke(); |
5912 ctx.restore(); | 5212 ctx.restore(); |
5913 } | 5213 } |
5914 if (config.yAxisRight) { | 5214 if (config.yAxisRight) { |
5915 if (config.yAxisLabel2 == '') config.yAx
isLabel2 = config.yAxisLabel; | 5215 if (config.yAxisLabel2 == '') config.yAx
isLabel2 = config.yAxisLabel; |
5916 ctx.save(); | 5216 ctx.save(); |
5917 ctx.beginPath(); | 5217 ctx.beginPath(); |
5918 ctx.font = config.yAxisFontStyle + " " +
config.yAxisFontSize + "px " + config.yAxisFontFamily; | 5218 ctx.font = config.yAxisFontStyle + " " +
config.yAxisFontSize + "px " + config.yAxisFontFamily; |
5919 ctx.fillStyle = config.yAxisFontColor; | 5219 ctx.fillStyle = config.yAxisFontColor; |
5920 ctx.textAlign = "center"; | 5220 ctx.textAlign = "center"; |
5921 ctx.textBaseline = "bottom"; | 5221 ctx.textBaseline = "bottom"; |
5922 ctx.translate(yAxisLabelPosRight, topNot
UsableSize + (availableHeight / 2)); | 5222 ctx.translate(yAxisLabelPosRight, topNot
UsableSize + (availableHeight / 2)); |
5923 ctx.rotate(+(90 * (Math.PI / 180))); | 5223 ctx.rotate(+(90 * (Math.PI / 180))); |
5924 » » » » » ctx.fillText(config.yAxisLabel2, 0, 0); | 5224 » » » » » ctx.fillTextMultiLine(config.yAxisLabel2
, 0, 0, ctx.textBaseline, config.yAxisFontSize,false); |
5925 ctx.stroke(); | 5225 ctx.stroke(); |
5926 ctx.restore(); | 5226 ctx.restore(); |
5927 } | 5227 } |
5928 } | 5228 } |
5929 // Draw X Axis Label | 5229 // Draw X Axis Label |
5930 if (xAxisLabelHeight > 0) { | 5230 if (xAxisLabelHeight > 0) { |
5931 if (config.xAxisBottom) { | 5231 if (config.xAxisBottom) { |
5932 ctx.save(); | 5232 ctx.save(); |
5933 ctx.beginPath(); | 5233 ctx.beginPath(); |
5934 ctx.font = config.xAxisFontStyle + " " +
config.xAxisFontSize + "px " + config.xAxisFontFamily; | 5234 ctx.font = config.xAxisFontStyle + " " +
config.xAxisFontSize + "px " + config.xAxisFontFamily; |
5935 ctx.fillStyle = config.xAxisFontColor; | 5235 ctx.fillStyle = config.xAxisFontColor; |
5936 ctx.textAlign = "center"; | 5236 ctx.textAlign = "center"; |
5937 ctx.textBaseline = "bottom"; | 5237 ctx.textBaseline = "bottom"; |
5938 ctx.translate(leftNotUsableSize + (avail
ableWidth / 2), xAxisLabelPos); | 5238 ctx.translate(leftNotUsableSize + (avail
ableWidth / 2), xAxisLabelPos); |
5939 » » » » » ctx.fillText(config.xAxisLabel, 0, 0); | 5239 » » » » » ctx.fillTextMultiLine(config.xAxisLabel,
0, 0, ctx.textBaseline, config.xAxisFontSize,true); |
5940 ctx.stroke(); | 5240 ctx.stroke(); |
5941 ctx.restore(); | 5241 ctx.restore(); |
5942 } | 5242 } |
5943 } | 5243 } |
5944 // Draw Legend | 5244 // Draw Legend |
5945 | 5245 |
5946 if (nbeltLegend > 1 || (nbeltLegend == 1 && config.showS
ingleLegend)) { | 5246 if (nbeltLegend > 1 || (nbeltLegend == 1 && config.showS
ingleLegend)) { |
5947 var legendMsr={dispLegend : true, xLegendBorderP
os : xLegendBorderPos, | 5247 var legendMsr={dispLegend : true, xLegendBorderP
os : xLegendBorderPos, |
5948 yLegendBorderPos : yLegendBorderPos,
legendBorderWidth : legendBorderWidth, legendBorderHeight : legendBorderHeight, | 5248 yLegendBorderPos : yLegendBorderPos,
legendBorderWidth : legendBorderWidth, legendBorderHeight : legendBorderHeight, |
5949 nbLegendCols: nbLegendCols, xFirstLeg
endTextPos : xFirstLegendTextPos , yFirstLegendTextPos : yFirstLegendTextPos, | 5249 nbLegendCols: nbLegendCols, xFirstLeg
endTextPos : xFirstLegendTextPos , yFirstLegendTextPos : yFirstLegendTextPos, |
5950 drawLegendOnData : drawLegendOnData,
reverseLegend : reverseLegend, legendBox : legendBox, widestLegend : widestLegen
d }; | 5250 drawLegendOnData : drawLegendOnData,
reverseLegend : reverseLegend, legendBox : legendBox, widestLegend : widestLegen
d }; |
5951 » » » » if(config.legendPosY==0 || config.legendPosY==4)
{ | 5251 » » » » if(config.legendPosY==0 || config.legendPosY==4
|| config.legendPosX==0 || config.legendPosX==4) { |
| 5252 |
5952 drawLegend(legendMsr,data,config,ctx,typ
egraph); | 5253 drawLegend(legendMsr,data,config,ctx,typ
egraph); |
5953 var legendMsr={dispLegend : false}; | 5254 var legendMsr={dispLegend : false}; |
5954 } | 5255 } |
5955 } else { | 5256 } else { |
5956 var legendMsr={dispLegend : false }; | 5257 var legendMsr={dispLegend : false }; |
5957 } | 5258 } |
5958 // Draw FootNote | 5259 // Draw FootNote |
5959 if (config.footNote.trim() != "") { | 5260 if (config.footNote.trim() != "") { |
5960 ctx.save(); | 5261 ctx.save(); |
5961 ctx.font = config.footNoteFontStyle + " " + conf
ig.footNoteFontSize + "px " + config.footNoteFontFamily; | 5262 ctx.font = config.footNoteFontStyle + " " + conf
ig.footNoteFontSize + "px " + config.footNoteFontFamily; |
5962 ctx.fillStyle = config.footNoteFontColor; | 5263 ctx.fillStyle = config.footNoteFontColor; |
5963 ctx.textAlign = "center"; | 5264 ctx.textAlign = "center"; |
5964 ctx.textBaseline = "bottom"; | 5265 ctx.textBaseline = "bottom"; |
5965 ctx.translate(leftNotUsableSize + (availableWidt
h / 2), footNotePosY); | 5266 ctx.translate(leftNotUsableSize + (availableWidt
h / 2), footNotePosY); |
5966 » » » » ctx.fillText(config.footNote, 0, 0); | 5267 » » » » ctx.fillTextMultiLine(config.footNote, 0, 0, ctx
.textBaseline, config.footNoteFontSize,true); |
5967 ctx.stroke(); | 5268 ctx.stroke(); |
5968 ctx.restore(); | 5269 ctx.restore(); |
5969 } | 5270 } |
5970 } | 5271 } |
5971 clrx = leftNotUsableSize; | 5272 clrx = leftNotUsableSize; |
5972 clrwidth = availableWidth; | 5273 clrwidth = availableWidth; |
5973 clry = topNotUsableSize; | 5274 clry = topNotUsableSize; |
5974 clrheight = availableHeight; | 5275 clrheight = availableHeight; |
5975 return { | 5276 return { |
5976 leftNotUsableSize: leftNotUsableSize, | 5277 leftNotUsableSize: leftNotUsableSize, |
(...skipping 10 matching lines...) Expand all Loading... |
5987 highestYLabel: highestYLabel, | 5288 highestYLabel: highestYLabel, |
5988 rotateLabels: rotateLabels, | 5289 rotateLabels: rotateLabels, |
5989 xLabelPos: xLabelPos, | 5290 xLabelPos: xLabelPos, |
5990 clrx: clrx, | 5291 clrx: clrx, |
5991 clry: clry, | 5292 clry: clry, |
5992 clrwidth: clrwidth, | 5293 clrwidth: clrwidth, |
5993 clrheight: clrheight, | 5294 clrheight: clrheight, |
5994 legendMsr : legendMsr | 5295 legendMsr : legendMsr |
5995 }; | 5296 }; |
5996 }; | 5297 }; |
5997 » // Function for additionalLine (BarLine|Line) | 5298 |
5998 » function drawLinesDataset(axis, animPc, data, config, ctx, offsets, vars
) { | 5299 » // Function for drawing lines (BarLine|Line) |
5999 » » var xAxisPosY = vars.xAxisPosY; | 5300 |
6000 » » var yAxisPosX = vars.yAxisPosX; | 5301 » function drawLinesDataset(animPc, data, config, ctx, statData,vars) { |
6001 » » var valueHop = vars.valueHop; | 5302 » » var y1,y2,y3,diffnb,diffnbj,fact; |
6002 » » var nbValueHop = vars.nbValueHop; | 5303 » » var pts=[]; |
6003 » » var scaleHop = vars.scaleHop; | 5304 |
6004 » » var zeroY = vars.zeroY; | |
6005 » » var calculatedScale = vars.calculatedScale; | |
6006 » » var logarithmic = vars.logarithmic; | |
6007 » » var currentAnimPc = animationCorrection(animPc, data, config, 0,
0, 0); | |
6008 » » var totvalue = new Array(); | |
6009 » » var maxvalue = new Array(); | |
6010 » » var lmaxvalue = new Array(); | |
6011 » » var lminvalue = new Array(); | |
6012 for (var i = 0; i < data.datasets.length; i++) { | 5305 for (var i = 0; i < data.datasets.length; i++) { |
6013 » » » lmaxvalue[i] = -999999999; | 5306 » » » if(statData[i][0].tpchart!="Line")continue; |
6014 » » » lminvalue[i] = 999999999; | 5307 » » » if (statData[i].length == 0) continue; |
6015 » » » if ((axis == 2 && data.datasets[i].axis == 2) || (axis !
= 2 && data.datasets[i].axis != 2)) { | 5308 » » » if (statData[i][0].firstNotMissing == -1) continue; |
6016 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | 5309 |
6017 » » » » » totvalue[j] = 0; | 5310 » » » ctx.save(); |
6018 » » » » » maxvalue[j] = -999999999; | 5311 » » » ctx.beginPath(); |
6019 » » » » } | 5312 |
6020 » » » } | 5313 » » » prevAnimPc={ mainVal:0 , subVal : 0,animVal : 0 }; |
6021 » » } | 5314 » » » var firstpt=-1; |
6022 » » currentAnimPc.mainVal = 1; | 5315 » » » var lastxPos=-1; |
6023 » » for (var i = 0; i < data.datasets.length; i++) { | 5316 » » » for (var j = statData[i][0].firstNotMissing; j <= statDa
ta[i][0].lastNotMissing; j++) { |
6024 » » » if ((axis == 2 && data.datasets[i].axis == 2) || (axis !
= 2 && data.datasets[i].axis != 2)) { | 5317 » » » » if(prevAnimPc.animVal==0 && j>statData[i][0].fir
stNotMissing) continue;» |
6025 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | 5318 » » » » var currentAnimPc = animationCorrection(animPc,
data, config, i, j, 0); |
6026 » » » » » totvalue[j] += data.datasets[i].data[j]; | 5319 » » » » if (currentAnimPc.mainVal == 0 && (prevAnimPc.m
ainVal > 0 && firstpt !=-1)) { |
6027 » » » » » maxvalue[j] = Max([maxvalue[j], data.dat
asets[i].data[j]]); | 5320 » » » » » ctx.stroke(); |
6028 » » » » » lmaxvalue[i] = Max([lmaxvalue[i], yPos(i
, j)]); | 5321 » » » » » if(config.extrapolateMissingData) { |
6029 » » » » » lminvalue[i] = Min([lminvalue[i], yPos(i
, j)]); | 5322 » » » » » » y1=statData[i][statData[i][j].pr
evNotMissing].yAxisPos - prevAnimPc.mainVal*statData[i][statData[i][j].prevNotMi
ssing].yPosOffset;» » » » » |
6030 » » » » } | 5323 » » » » » » y2=statData[i][j].yAxisPos - pre
vAnimPc.mainVal*statData[i][statData[i][j-1].nextNotMissing].yPosOffset; |
6031 » » » } | 5324 » » » » » » diffnb=statData[i][j-1].nextNotM
issing-statData[i][j].prevNotMissing; |
6032 » » } | 5325 » » » » » » diffnbj=(j-1)-statData[i][j].pre
vNotMissing; |
6033 » » for (var i = 0; i < data.datasets.length; i++) { | 5326 » » » » » » fact=(diffnbj+prevAnimPc.subVal)
/diffnb; |
6034 » » » if ((axis == 2 && data.datasets[i].axis == 2) || (axis !
= 2 && data.datasets[i].axis != 2)) { | 5327 » » » » » » y3=y1+fact*(y2-y1);» »
» » » |
6035 » » » » var prevpt = -1; | 5328 » » » » » » traceLine(pts,ctx,statData[i][j-
1].xPos + prevAnimPc.subVal*(statData[i][j].xPos-statData[i][j-1].xPos) , y3,con
fig,data,statData,i); |
6036 » » » » var frstpt = -1; | 5329 » » » » » » closebz(pts,ctx,config,i); |
6037 » » » » if (typeof data.datasets[i].strokeColor == "func
tion") { | |
6038 » » » » » ctx.strokeStyle = data.datasets[i].strok
eColor("STROKECOLOR", data, config, i, -1, animPc, -1, "Line", ctx, yAxisPosX, l
maxvalue[i], yAxisPosX + valueHop * (data.datasets[i].data.length - 1), lmaxvalu
e[i] - ((config.animationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * (lmaxvalu
e[i] - lminvalue[i])); | |
6039 » » » » } else if (typeof data.datasets[i].strokeColor =
= "string") { | |
6040 » » » » » ctx.strokeStyle = data.datasets[i].strok
eColor; | |
6041 » » » » } else ctx.strokeStyle = config.defaultStrokeCol
or; | |
6042 » » » » ctx.lineWidth = config.datasetStrokeWidth; | |
6043 » » » » ctx.beginPath(); | |
6044 » » » » var prevAnimPc; | |
6045 » » » » var prevXpos; | |
6046 » » » » prevAnimPc = 0; | |
6047 » » » » prevnotempty = 0; | |
6048 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { | |
6049 » » » » » var xposj = xPos(i, j, data); | |
6050 » » » » » currentAnimPc = animationCorrection(anim
Pc, data, config, i, j, 0); | |
6051 » » » » » if (currentAnimPc.mainVal == 0 && prevAn
imPc > 0) { | |
6052 ctx.stroke(); | 5330 ctx.stroke(); |
6053 ctx.strokeStyle = "rgba(0,0,0,0)
"; | 5331 ctx.strokeStyle = "rgba(0,0,0,0)
"; |
6054 » » » » » » // ctx.lineWidth =0.01;
| 5332 » » » » » » if(config.datasetFill) { |
6055 » » » » » » ctx.lineTo(prevXpos, xAxisPosY -
zeroY); | 5333 » » » » » » » ctx.lineTo(statData[i][j
-1].xPos + prevAnimPc.subVal*(statData[i][j].xPos-statData[i][j-1].xPos) , statD
ata[i][j].yAxisPos ); |
6056 » » » » » } | 5334 » » » » » » » ctx.lineTo(statData[i][f
irstpt].xPos, statData[i][firstpt].xAxisPosY-statData[i][0].zeroY); |
6057 » » » » » prevAnimPc = currentAnimPc.mainVal; | 5335 » » » » » » » ctx.closePath(); |
6058 » » » » » if (currentAnimPc.mainVal >= 1) { | 5336 » » » » » » » ctx.fillStyle=setOptionV
alue("COLOR",ctx,data,statData,data.datasets[i].fillColor,config.defaultFillColo
r,i,j,{animationValue: currentAnimPc.mainVal, xPosLeft : statData[i][0].xPos, yP
osBottom : Math.max(statData[i][0].yAxisPos,statData[i][0].yAxisPos- ((config.an
imationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * statData[i][0].lminvalue_of
fset), xPosRight : statData[i][data.datasets[i].data.length-1].xPos, yPosTop : M
ath.min(statData[i][0].yAxisPos, statData[i][0].yAxisPos - ((config.animationLef
tToRight) ? 1 : 1*currentAnimPc.mainVal) * statData[i][0].lmaxvalue_offset)} ); |
6059 » » » » » » if (typeof(data.datasets[i].titl
e) == "string") lgtxt = data.datasets[i].title.trim(); | 5337 » » » » » » » ctx.fill(); |
6060 » » » » » » else lgtxt = ""; | 5338 » » » » » » » firstpt=-1; |
6061 » » » » » } | 5339 » » » » » » } |
| 5340 » » » » » } else if (!(typeof statData[i][j].value
== "undefined")) { |
| 5341 » » » » » » traceLine(pts,ctx,statData[i][j-
1].xPos + prevAnimPc.subVal*(statData[i][j].xPos-statData[i][j-1].xPos) , statDa
ta[i][j].yAxisPos - prevAnimPc.mainVal*statData[i][statData[i][j-1].nextNotMissi
ng].yPosOffset,config,data,statData,i); |
| 5342 » » » » » » closebz(pts,ctx,config,i); |
| 5343 » » » » » » ctx.stroke(); |
| 5344 » » » » » » ctx.strokeStyle = "rgba(0,0,0,0)
"; |
| 5345 » » » » » » if(config.datasetFill) { |
| 5346 » » » » » » » ctx.lineTo(statData[i][j
-1].xPos + prevAnimPc.subVal*(statData[i][j].xPos-statData[i][j-1].xPos) , statD
ata[i][j].yAxisPos ); |
| 5347 » » » » » » » ctx.lineTo(statData[i][f
irstpt].xPos, statData[i][firstpt].xAxisPosY-statData[i][0].zeroY); |
| 5348 » » » » » » » ctx.closePath(); |
| 5349 » » » » » » » ctx.fillStyle=setOptionV
alue("COLOR",ctx,data,statData,data.datasets[i].fillColor,config.defaultFillColo
r,i,j,{animationValue: currentAnimPc.mainVal, xPosLeft : statData[i][0].xPos, yP
osBottom : Math.max(statData[i][0].yAxisPos,statData[i][0].yAxisPos- ((config.an
imationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * statData[i][0].lminvalue_of
fset), xPosRight : statData[i][data.datasets[i].data.length-1].xPos, yPosTop : M
ath.min(statData[i][0].yAxisPos, statData[i][0].yAxisPos - ((config.animationLef
tToRight) ? 1 : 1*currentAnimPc.mainVal) * statData[i][0].lmaxvalue_offset)} ); |
| 5350 » » » » » » » ctx.fill(); |
| 5351 » » » » » » } |
| 5352 » » » » » } |
| 5353 » » » » » prevAnimPc = currentAnimPc; |
| 5354 » » » » » continue; |
| 5355 » » » » } else if(currentAnimPc.totVal ==0) { |
| 5356 » » » » » ctx.stroke(); |
| 5357 » » » » » ctx.strokeStyle = "rgba(0,0,0,0)"; |
| 5358 » » » » } else { |
| 5359 » » » » » ctx.stroke(); |
| 5360 » » » » » ctx.strokeStyle=setOptionValue("STROKECO
LOR",ctx,data,statData,data.datasets[i].strokeColor,config.defaultStrokeColor,i,
j,{nullvalue : null} ); |
| 5361 » » » » } |
| 5362 » » » » |
| 5363 » » » » prevAnimPc = currentAnimPc; |
| 5364 |
| 5365 » » » » switch(typeof data.datasets[i].data[j]) { |
| 5366 » » » » » case "undefined" : |
| 5367 » » » » » » » if (!config.extrapolateM
issingData) { |
| 5368 » » » » » » » » if(firstpt==-1)
continue; |
| 5369 » » » » » » » » closebz(pts,ctx,
config,i); |
| 5370 » » » » » » » » ctx.stroke(); |
| 5371 » » » » » » » » if (config.datas
etFill && firstpt != -1) { |
| 5372 » » » » » » » » » lastxPos
=-1; |
| 5373 » » » » » » » » » ctx.stro
keStyle = "rgba(0,0,0,0)"; |
| 5374 » » » » » » » » » ctx.line
To(statData[i][j-1].xPos, statData[i][j-1].yAxisPos); |
| 5375 » » » » » » » » » ctx.line
To(statData[i][firstpt].xPos, statData[i][firstpt].yAxisPos); |
| 5376 » » » » » » » » » ctx.clos
ePath(); |
| 5377 » » » » » » » » » ctx.fill
Style=setOptionValue("COLOR",ctx,data,statData,data.datasets[i].fillColor,config
.defaultFillColor,i,j,{animationValue: currentAnimPc.mainVal, xPosLeft : statDat
a[i][0].xPos, yPosBottom : Math.max(statData[i][0].yAxisPos,statData[i][0].yAxis
Pos- ((config.animationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * statData[i]
[0].lminvalue_offset), xPosRight : statData[i][data.datasets[i].data.length-1].x
Pos, yPosTop : Math.min(statData[i][0].yAxisPos, statData[i][0].yAxisPos - ((con
fig.animationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * statData[i][0].lmaxva
lue_offset)} ); |
| 5378 » » » » » » » » » ctx.fill
(); |
| 5379 » » » » » » » » } |
| 5380 » » » » » » » » ctx.beginPath(); |
| 5381 » » » » » » » » prevAnimPc={ mai
nVal:0 , subVal : 0 }; |
| 5382 » » » » » » » » firstpt=-1; |
| 5383 » » » » » » » } else if (currentAnimPc
.subVal > 0) { |
| 5384 » » » » » » » » lastxPos=statDat
a[i][j].xPos + currentAnimPc.subVal*(statData[i][j+1].xPos-statData[i][j].xPos); |
| 5385 » » » » » » » » y1=statData[i][s
tatData[i][j+1].prevNotMissing].yAxisPos - statData[i][statData[i][j+1].prevNotM
issing].yPosOffset;» » » » » |
| 5386 » » » » » » » » y2=statData[i][s
tatData[i][j].nextNotMissing].yAxisPos - statData[i][statData[i][j].nextNotMissi
ng].yPosOffset; |
| 5387 » » » » » » » » diffnb=statData[
i][j].nextNotMissing-statData[i][j+1].prevNotMissing; |
| 5388 » » » » » » » » diffnbj=(j)-stat
Data[i][j+1].prevNotMissing; |
| 5389 » » » » » » » » fact=(diffnbj+pr
evAnimPc.subVal)/diffnb; |
| 5390 » » » » » » » » var y3=y1+fact*(
y2-y1);»» » » » |
| 5391 » » » » » » » » traceLine(pts,ct
x,statData[i][j].xPos + currentAnimPc.subVal*(statData[i][j+1].xPos-statData[i][
j].xPos), y3,config,data,statData,i); |
| 5392 » » » » » » » } |
| 5393 » » » » » » » break; |
| 5394 » » » » » default : |
| 5395 » » » » » » ctx.lineWidth = config.datasetSt
rokeWidth; |
| 5396 » » » » » » if (firstpt==-1) { |
| 5397 » » » » » » » firstpt=j; |
| 5398 » » » » » » » ctx.beginPath(); |
| 5399 » » » » » » » ctx.moveTo(statData[i][j
].xPos, statData[i][j].yAxisPos - currentAnimPc.mainVal * statData[i][j].yPosOff
set); |
| 5400 » » » » » » » initbz(pts,statData[i][j
].xPos, statData[i][j].yAxisPos - currentAnimPc.mainVal * statData[i][j].yPosOff
set,i);»» » » » » » |
| 5401 » » » » » » » lastxPos=statData[i][j].
xPos; |
| 5402 » » » » » » } else { |
| 5403 » » » » » » » lastxPos=statData[i][j].
xPos; |
| 5404 » » » » » » » traceLine(pts,ctx,statDa
ta[i][j].xPos, statData[i][j].yAxisPos - currentAnimPc.mainVal * statData[i][j].
yPosOffset,config,data,statData,i); |
| 5405 » » » » » » } |
| 5406 » » » » » » |
| 5407 » » » » » » if (currentAnimPc.subVal > 0 &&
statData[i][j].nextNotMissing !=-1 && (config.extrapolateMissing || statData[i][
j].nextNotMissing==j+1)) { |
| 5408 » » » » » » » lastxPos=statData[i][j].
xPos + currentAnimPc.subVal*(statData[i][j+1].xPos-statData[i][j].xPos); |
| 5409 » » » » » » » var y1=statData[i][statD
ata[i][j+1].prevNotMissing].yAxisPos - statData[i][statData[i][j+1].prevNotMissi
ng].yPosOffset;»» » » » |
| 5410 » » » » » » » var y2=statData[i][statD
ata[i][j].nextNotMissing].yAxisPos - statData[i][statData[i][j].nextNotMissing].
yPosOffset; |
| 5411 » » » » » » » var y3=y1+currentAnimPc.
subVal*(y2-y1);»» » » » |
| 5412 » » » » » » » traceLine(pts,ctx,statDa
ta[i][j].xPos + currentAnimPc.subVal*(statData[i][j+1].xPos-statData[i][j].xPos)
, y3,config,data,statData,i); |
| 5413 » » » » » » } |
| 5414 » » » » » » break |
| 5415 » » » » } |
| 5416 » » » } |
| 5417 » » » closebz(pts,ctx,config,i); |
| 5418 » » » ctx.stroke(); |
| 5419 » » » if (config.datasetFill) { |
| 5420 » » » » if (firstpt>=0 ) { |
| 5421 » » » » » ctx.strokeStyle = "rgba(0,0,0,0)"; |
| 5422 » » » » » ctx.lineTo(lastxPos, statData[i][0].xAxi
sPosY-statData[i][0].zeroY); |
| 5423 » » » » » ctx.lineTo(statData[i][firstpt].xPos, st
atData[i][firstpt].xAxisPosY-statData[i][0].zeroY); |
| 5424 » » » » » ctx.closePath(); |
| 5425 » » » » » ctx.fillStyle=setOptionValue("COLOR",ctx
,data,statData,data.datasets[i].fillColor,config.defaultFillColor,i,-1,{animatio
nValue: currentAnimPc.mainVal, xPosLeft : statData[i][0].xPos, yPosBottom : Math
.max(statData[i][0].yAxisPos,statData[i][0].yAxisPos- ((config.animationLeftToRi
ght) ? 1 : 1*currentAnimPc.mainVal) * statData[i][0].lminvalue_offset), xPosRigh
t : statData[i][data.datasets[i].data.length-1].xPos, yPosTop : Math.min(statDat
a[i][0].yAxisPos, statData[i][0].yAxisPos - ((config.animationLeftToRight) ? 1 :
1*currentAnimPc.mainVal) * statData[i][0].lmaxvalue_offset)} ); |
| 5426 » » » » » ctx.fill(); |
| 5427 » » » » } |
| 5428 » » » } |
| 5429 » » » ctx.restore(); |
| 5430 » » » if (config.pointDot && animPc >= 1) { |
| 5431 » » » » for (var j = 0; j < data.datasets[i].data.length
; j++) { |
6062 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { | 5432 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined')) { |
6063 » » » » » » prevXpos = xPos(i, j, data); | 5433 » » » » » » var currentAnimPc = animationCor
rection(animPc, data, config, i, j, 0); |
6064 » » » » » » if (prevpt == -1) { | 5434 » » » » » » if (currentAnimPc.mainVal > 0 ||
!config.animationLeftToRight) { |
6065 » » » » » » » ctx.moveTo(xposj, yPos(i
, j)); | |
6066 » » » » » » » frstpt = j; | |
6067 » » » » » » } else { | |
6068 » » » » » » » if (config.bezierCurve)
{ | |
6069 » » » » » » » » ctx.bezierCurveT
o(xPos(i, j - (j - prevpt) / 2, data), yPos(i, prevpt), xPos(i, j - (j - prevpt)
/ 2, data), yPos(i, j), xPos(i, j, data), yPos(i, j)); | |
6070 » » » » » » » } else { | |
6071 » » » » » » » » ctx.lineTo(xPos(
i, j, data), yPos(i, j)); | |
6072 » » » » » » » } | |
6073 » » » » » » } | |
6074 » » » » » » if ((typeof(data.datasets[i].dat
a[j + 1]) !== 'undefined') || (true == config.extrapolateMissingData)) { | |
6075 » » » » » » » if (currentAnimPc.subVal
> 0) { | |
6076 » » » » » » » » // next not miss
ing value | |
6077 » » » » » » » » nxtnotmiss = -1; | |
6078 » » » » » » » » for (t = j + 1;
t < data.datasets[i].data["length"] && nxtnotmiss == -1; t++) { | |
6079 » » » » » » » » » if (!(ty
peof(data.datasets[i].data[t]) == 'undefined')) nxtnotmiss = t; | |
6080 » » » » » » » » } | |
6081 » » » » » » » » if (nxtnotmiss !
= -1) { | |
6082 » » » » » » » » » prevXpos
= xPos(i, j + currentAnimPc.subVal, data); | |
6083 » » » » » » » » » if (conf
ig.bezierCurve) { | |
6084 » » » » » » » » » »
ctx.bezierCurveTo(xPos(i, j + currentAnimPc.subVal / 2, data), yPos(i, j), xPos(
i, j + currentAnimPc.subVal / 2, data), yPos(i, nxtnotmiss), xPos(i, j + current
AnimPc.subVal, data), yPos(i, nxtnotmiss)); | |
6085 » » » » » » » » » } else { | |
6086 » » » » » » » » » »
ctx.lineTo(xPos(i, j + currentAnimPc.subVal, data), yPos(i, j + 1)); | |
6087 » » » » » » » » » } | |
6088 » » » » » » » » } | |
6089 » » » » » » » } | |
6090 » » » » » » » prevpt = j; | |
6091 » » » » » » » if (animPc >= 1) { | |
6092 » » » » » » » » if (i == 0) divp
rev = data.datasets[i].data[j]; | |
6093 » » » » » » » » else divprev = d
ata.datasets[i].data[j] - data.datasets[i - 1].data[j]; | |
6094 » » » » » » » » if (i == data.da
tasets.length - 1) divnext = data.datasets[i].data[j]; | |
6095 » » » » » » » » else divnext = d
ata.datasets[i].data[j] - data.datasets[i + 1].data[j]; | |
6096 » » » » » » » » lgtxt2 = ""; | |
6097 » » » » » » » » if (typeof data.
datasets[i].xPos != "undefined") { | |
6098 » » » » » » » » » if (!(ty
peof data.datasets[i].xPos[j] == "undefined")) lgtxt2 = data.datasets[i].xPos[j]
; | |
6099 » » » » » » » » } | |
6100 » » » » » » » » if (lgtxt2 == ""
&& !(typeof(data.labels[j]) == "undefined")) lgtxt2 = data.labels[j]; | |
6101 » » » » » » » » if (typeof lgtxt
2 == "string") lgtxt2 = lgtxt2.trim(); | |
6102 » » » » » » » » jsGraphAnnotate[
ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["POINT", xPos(i, j, d
ata), yPos(i, j), lgtxt, lgtxt2, 1 * data.datasets[i].data[j], divprev, divnext,
maxvalue[j], totvalue[j], i, j]; | |
6103 » » » » » » » » if (config.inGra
phDataShow) { | |
6104 » » » » » » » » » ctx.save
(); | |
6105 » » » » » » » » » ctx.text
Align = config.inGraphDataAlign; | |
6106 » » » » » » » » » ctx.text
Baseline = config.inGraphDataVAlign; | |
6107 » » » » » » » » » ctx.font
= config.inGraphDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + conf
ig.inGraphDataFontFamily; | |
6108 » » » » » » » » » ctx.fill
Style = config.inGraphDataFontColor; | |
6109 » » » » » » » » » var dotX
= yAxisPosX + (valueHop * k), | |
6110 » » » » » » » » » »
dotY = xAxisPosY - currentAnimPc.mainVal * (calculateOffset(logarithmic, data.da
tasets[i].data[j], calculatedScale, scaleHop)), | |
6111 » » » » » » » » » »
paddingTextX = config.inGraphDataPaddingX, | |
6112 » » » » » » » » » »
paddingTextY = config.inGraphDataPaddingY; | |
6113 » » » » » » » » » var disp
String = tmplbis(config.inGraphDataTmpl, { | |
6114 » » » » » » » » » »
config: config, | |
6115 » » » » » » » » » »
v1: fmtChartJS(config, lgtxt, config.fmtV1), | |
6116 » » » » » » » » » »
v2: fmtChartJS(config, lgtxt2, config.fmtV2), | |
6117 » » » » » » » » » »
v3: fmtChartJS(config, 1 * data.datasets[i].data[j], config.fmtV3), | |
6118 » » » » » » » » » »
v4: fmtChartJS(config, divprev, config.fmtV4), | |
6119 » » » » » » » » » »
v5: fmtChartJS(config, divnext, config.fmtV5), | |
6120 » » » » » » » » » »
v6: fmtChartJS(config, maxvalue[j], config.fmtV6), | |
6121 » » » » » » » » » »
v7: fmtChartJS(config, totvalue[j], config.fmtV7), | |
6122 » » » » » » » » » »
v8: roundToWithThousands(config, fmtChartJS(config, 100 * data.datasets[i].data[
j] / totvalue[j], config.fmtV8), config.roundPct), | |
6123 » » » » » » » » » »
v9: fmtChartJS(config, yAxisPosX + (valueHop * k), config.fmtV9), | |
6124 » » » » » » » » » »
v10: fmtChartJS(config, xAxisPosY - (calculateOffset(logarithmic, data.datasets[
i].data[j], calculatedScale, scaleHop)), config.fmtV10), | |
6125 » » » » » » » » » »
v11: fmtChartJS(config, i, config.fmtV11), | |
6126 » » » » » » » » » »
v12: fmtChartJS(config, j, config.fmtV12), | |
6127 » » » » » » » » » »
data: data | |
6128 » » » » » » » » » }); | |
6129 » » » » » » » » » ctx.tran
slate(xPos(i, j, data) + paddingTextX, yPos(i, j) - paddingTextY); | |
6130 » » » » » » » » » ctx.rota
te(config.inGraphDataRotate * (Math.PI / 180)); | |
6131 » » » » » » » » » ctx.fill
TextMultiLine(dispString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | |
6132 » » » » » » » » » ctx.rest
ore(); | |
6133 » » » » » » » » } | |
6134 » » » » » » » } | |
6135 » » » » » » } | |
6136 » » » » » } else { | |
6137 » » » » » » if (false == config.extrapolateM
issingData) { | |
6138 » » » » » » » ctx.stroke(); | |
6139 » » » » » » » if (config.datasetFill)
{ | |
6140 » » » » » » » » ctx.lineTo(prevX
pos, xAxisPosY - zeroY); | |
6141 » » » » » » » » ctx.lineTo(xPos(
i, frstpt, data), xAxisPosY - zeroY); | |
6142 » » » » » » » » ctx.lineTo(xPos(
i, frstpt, data), yPos(i, frstpt)); | |
6143 » » » » » » » » ctx.closePath(); | |
6144 » » » » » » » » if (typeof data.
datasets[i].fillColor == "function") ctx.fillStyle = data.datasets[i].fillColor(
"FILLCOLOR", data, config, i, -1, currentAnimPc.mainVal, -1, "Line", ctx, yAxisP
osX, lmaxvalue[i], yAxisPosX + valueHop * (data.datasets[i].data.length - 1), lm
axvalue[i] - ((config.animationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * (lm
axvalue[i] - lminvalue[i])); | |
6145 » » » » » » » » else if (typeof
data.datasets[i].fillColor == "string") ctx.fillStyle = data.datasets[i].fillCol
or; | |
6146 » » » » » » » » else ctx.fillSty
le = config.defaultFillColor; | |
6147 » » » » » » » » ctx.fill(); | |
6148 » » » » » » » } | |
6149 ctx.beginPath(); | 5435 ctx.beginPath(); |
6150 prevpt = -1; | 5436 ctx.fillStyle=setOptionV
alue("MARKERFILLCOLOR",ctx,data,statData,data.datasets[i].pointColor,config.defa
ultStrokeColor,i,j,{nullvalue: true} ); |
6151 frstpt = -1; | 5437 ctx.strokeStyle=setOptio
nValue("MARKERSTROKESTYLE",ctx,data,statData,data.datasets[i].pointStrokeColor,c
onfig.defaultStrokeColor,i,j,{nullvalue: true} ); |
6152 prevAnimPc = 0; | 5438 ctx.lineWidth=setOptionV
alue("MARKERLINEWIDTH",ctx,data,statData,data.datasets[i].pointDotStrokeWidth,co
nfig.pointDotStrokeWidth,i,j,{nullvalue: true} ); |
6153 prevnotempty = 0; | 5439 var markerShape=setOptio
nValue("MARKERSHAPE",ctx,data,statData,data.datasets[i].markerShape,config.marke
rShape,i,j,{nullvalue: true} ); |
6154 } else { | 5440 var markerRadius=setOpti
onValue("MARKERRADIUS",ctx,data,statData,data.datasets[i].pointDotRadius,config.
pointDotRadius,i,j,{nullvalue: true} ); |
6155 if (currentAnimPc.subVal
> 0) { | 5441 drawMarker(ctx, statData
[i][j].xPos , statData[i][j].yAxisPos - currentAnimPc.mainVal * statData[i][j].y
PosOffset, markerShape,markerRadius);
|
6156 nxtnotmiss = -1; | 5442 } |
6157 for (t = j + 1;
t < data.datasets[i].data["length"] && nxtnotmiss == -1; t++) { | 5443 } |
6158 if (!(ty
peof(data.datasets[i].data[t]) == 'undefined')) nxtnotmiss = t; | 5444 } |
6159 } | 5445 } |
6160 if ((typeof(data
.datasets[i].data[j]) !== 'undefined') || (true == config.extrapolateMissingData
)) { | 5446 |
6161 if (nxtn
otmiss != -1) { | 5447 if (animPc >= config.animationStopValue) { |
6162
prevXpos = xPos(i, j + currentAnimPc.subVal, data); | 5448 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
6163
if (config.bezierCurve) { | 5449 if (typeof(data.datasets[i].data[j]) ==
'undefined') continue; |
6164
ctx.bezierCurveTo(xPos(i, prevpt + (j + currentAnimPc.subVal - prevpt) /
2, data), yPos(i, prevpt), xPos(i, prevpt + (j + currentAnimPc.subVal - prevpt)
/ 2, data), yPos(i, nxtnotmiss), xPos(i, j + currentAnimPc.subVal, data), yPos(
i, nxtnotmiss)); | 5450 if(setOptionValue("ANNOTATEDISPLAY",ctx,
data,statData,undefined,config.annotateDisplay,i,j,{nullValue : true})) { |
6165
} else { | 5451 jsGraphAnnotate[ctx.ChartNewId][
jsGraphAnnotate[ctx.ChartNewId].length] = ["POINT", i, j, statData]; |
6166
ctx.lineTo(xPos(i, j + currentAnimPc.subVal, data), yPos(i, j + 1)); | 5452 } |
6167
} | 5453 if (setOptionValue("INGRAPHDATASHOW",ctx
,data,statData,undefined,config.inGraphDataShow,i,j,{nullValue : true})) { |
6168 } | 5454 ctx.save(); |
6169 } | 5455 ctx.textAlign = setOptionValue("
INGRAPHDATAALIGN",ctx,data,statData,undefined,config.inGraphDataAlign,i,j,{nullV
alue: true }); |
6170 } | 5456 ctx.textBaseline = setOptionValu
e("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,j,{
nullValue : true} ); |
6171 } | 5457 ctx.font = setOptionValue("INGRA
PHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,j,{nu
llValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData
,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ) + 'px ' + setOpti
onValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphDataFo
ntFamily,i,j,{nullValue : true} ); |
6172 } | 5458 ctx.fillStyle = setOptionValue("
INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,
j,{nullValue : true} ); |
6173 } | 5459 var paddingTextX = setOptionValu
e("INGRAPHDATAPADDINGX",ctx,data,statData,undefined,config.inGraphDataPaddingX,i
,j,{nullValue : true} ), |
6174 ctx.stroke(); | 5460 paddingTextY = setOption
Value("INGRAPHDATAPADDINGY",ctx,data,statData,undefined,config.inGraphDataPaddin
gY,i,j,{nullValue : true} ); |
6175 if (config.datasetFill) { | 5461 var dispString = tmplbis(setOpti
onValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j
,{nullValue : true} ), statData[i][j]); |
6176 // ctx.line
To(yAxisPosX + (valueHop * (data.datasets[i].data.length - 1)), xAxisPosY - zero
Y); | 5462 ctx.translate(statData[i][j].xPo
s + paddingTextX, statData[i][j].yAxisPos - currentAnimPc.mainVal * statData[i][
j].yPosOffset - paddingTextY); |
6177 ctx.lineTo(prevXpos, xAxisPosY - zeroY); | 5463 ctx.rotate(setOptionValue("INGRA
PHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,j,{nullValu
e : true} ) * (Math.PI / 180)); |
6178 ctx.lineTo(xPos(i, frstpt, data), xAxisP
osY - zeroY); | 5464 ctx.fillTextMultiLine(dispString
, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData
,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),true); |
6179 ctx.lineTo(xPos(i, frstpt, data), yPos(i
, frstpt)); | 5465 ctx.restore(); |
6180 ctx.closePath(); | 5466 } |
6181 if (typeof data.datasets[i].fillColor ==
"function") { ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", data, con
fig, i, -1, currentAnimPc.mainVal, -1, "Line", ctx, yAxisPosX, lmaxvalue[i], yAx
isPosX + valueHop * (data.datasets[i].data.length - 1), lmaxvalue[i] - ((config.
animationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * (lmaxvalue[i] - lminvalue
[i])); } | 5467 } |
6182 else if (typeof data.datasets[i].fillCol
or == "string") ctx.fillStyle = data.datasets[i].fillColor; | 5468 } |
6183 else ctx.fillStyle = config.defaultFillC
olor; | 5469 }; |
6184 ctx.fill(); | 5470 |
6185 } else { | 5471 |
6186 ctx.closePath(); | 5472 |
6187 } | 5473 function initbz(pts,xpos,ypos,i) { |
6188 if (config.pointDot) { | 5474 if (setOptionValue("BEZIERCURVE",ctx,data,statData,undef
ined,config.bezierCurve,i,-1,{nullValue : true})) { |
6189 if (typeof data.datasets[i].pointColor =
= "function") ctx.fillStyle = data.datasets[i].pointColor("POINTCOLOR", data, co
nfig, i, -1, animPc, -1, "Line", ctx, yAxisPosX, lmaxvalue[i], yAxisPosX + value
Hop * (data.datasets[i].data.length - 1), lmaxvalue[i] - ((config.animationLeftT
oRight) ? 1 : 1*currentAnimPc.mainVal) * (lmaxvalue[i] - lminvalue[i])); | 5475 pts.length=0; |
6190 else ctx.fillStyle = data.datasets[i].po
intColor; | 5476 pts.push(xpos);pts.push(ypos); |
6191 if (typeof data.datasets[i].pointStrokeC
olor == "function") ctx.strokeStyle = data.datasets[i].pointStrokeColor("POINTST
ROKECOLOR", data, config, i, -1, animPc, -1, "Line", ctx, yAxisPosX, lmaxvalue[i
], yAxisPosX + valueHop * (data.datasets[i].data.length - 1), lmaxvalue[i] - ((c
onfig.animationLeftToRight) ? 1 : 1*currentAnimPc.mainVal) * (lmaxvalue[i] - lmi
nvalue[i])); | 5477 } |
6192 else ctx.strokeStyle = data.datasets[i].
pointStrokeColor; | 5478 } ; |
6193 ctx.lineWidth = config.pointDotStrokeWid
th; | 5479 |
6194 for (var k = 0; k < data.datasets[i].dat
a.length; k++) { | 5480 function traceLine(pts,ctx,xpos,ypos,config,data,statData,i) { |
6195 if (!(typeof(data.datasets[i].da
ta[k]) == 'undefined')) { | 5481 if (setOptionValue("BEZIERCURVE",ctx,data,statData,undef
ined,config.bezierCurve,i,-1,{nullValue : true})) { |
6196 var currentAnimPc = anim
ationCorrection(animPc, data, config, i, k, 0); | 5482 pts.push(xpos); pts.push(ypos); |
6197 if (currentAnimPc.mainVa
l > 0 || !config.animationLeftToRight) { | 5483 } else { |
6198 ctx.beginPath(); | 5484 ctx.lineTo(xpos,ypos); |
6199 ctx.arc(xPos(i,
k, data), yPos(i, k), config.pointDotRadius, 0, Math.PI * 2, true); | 5485 } |
6200 ctx.fill(); | 5486 } ; |
6201 ctx.stroke(); | 5487 |
6202 } | 5488 function closebz(pts,ctx,config,i){ |
6203 } | 5489 |
6204 } | 5490 if(setOptionValue("BEZIERCURVE",ctx,data,statData,undefi
ned,config.bezierCurve,i,-1,{nullValue : true})) { |
6205 } | 5491 minimumpos= statData[i][0].xAxisPosY; |
6206 } | 5492 maximumpos= statData[i][0].xAxisPosY - statData[
i][0].calculatedScale.steps*statData[i][0].scaleHop; |
6207 }; | 5493 drawSpline(ctx,pts,setOptionValue("BEZIERCURVETE
NSION",ctx,data,statData,undefined,config.bezierCurveTension,i,-1,{nullValue : t
rue}),minimumpos,maximumpos); |
6208 | 5494 pts.length=0; |
6209 function yPos(dataSet, iteration) { | 5495 } |
6210 return xAxisPosY - zeroY - currentAnimPc.mainVal * (calc
ulateOffset(logarithmic, data.datasets[dataSet].data[iteration], calculatedScale
, scaleHop) - zeroY); | 5496 }; |
6211 }; | 5497 |
6212 | 5498 //Props to Rob Spencer at scaled innovation for his post on spli
ning between points |
6213 function xPos(ival, iteration, data) { | 5499 //http://scaledinnovation.com/analytics/splines/aboutSplines.htm
l |
6214 if (typeof data.datasets[ival].xPos == "object") { | 5500 |
6215 if (!(typeof data.datasets[ival].xPos[Math.floor
(iteration + 0.0001)] == "undefined")) { | 5501 function getControlPoints(x0,y0,x1,y1,x2,y2,t){ |
6216 var width = valueHop * nbValueHop; | 5502 // x0,y0,x1,y1 are the coordinates of the end (knot) pt
s of this segment |
6217 var deb = (typeof data.xBegin != "undefi
ned") ? data.xBegin : 1 * data.labels[0]; | 5503 // x2,y2 is the next knot -- not connected here but nee
ded to calculate p2 |
6218 var fin = (typeof data.xEnd != "undefine
d") ? data.xEnd : 1 * data.labels[data.labels.length - 1]; | 5504 // p1 is the control point calculated here, from x1 bac
k toward x0. |
6219 if (fin <= deb) fin = deb + 100; | 5505 // p2 is the next control point, calculated here and re
turned to become the |
6220 if (1 * data.datasets[ival].xPos[Math.fl
oor(iteration + 0.0001)] >= deb && data.datasets[ival].xPos[Math.floor(iteration
+ 0.0001)] <= fin) { | 5506 // next segment's p1. |
6221 var p1 = yAxisPosX + width * ((1
* data.datasets[ival].xPos[Math.floor(iteration + 0.0001)] - deb) / (fin - deb)
); | 5507 // t is the 'tension' which controls how far the contro
l points spread. |
6222 var p2 = p1; | 5508 |
6223 if (Math.abs(iteration - Math.fl
oor(iteration + 0.0001)) > 0.0001) { | 5509 // Scaling factors: distances from this knot to the pre
vious and following knots. |
6224 var tt = iteration + Mat
h.floor(iteration + 0.0001); | 5510 var d01=Math.sqrt(Math.pow(x1-x0,2)+Math.pow(y1-y0,2)); |
6225 var p2 = xPos(ival, Math
.ceil(iteration - 0.0001), data); | 5511 var d12=Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2)); |
6226 } | 5512 |
6227 return p1 + (iteration - Math.fl
oor(iteration + 0.0001)) * (p2 - p1); | 5513 var fa=t*d01/(d01+d12); |
6228 } | 5514 var fb=t-fa; |
6229 } | 5515 |
6230 } | 5516 var p1x=x1+fa*(x0-x2); |
6231 return yAxisPosX + (valueHop * iteration); | 5517 var p1y=y1+fa*(y0-y2); |
6232 }; | 5518 |
| 5519 var p2x=x1-fb*(x0-x2); |
| 5520 var p2y=y1-fb*(y0-y2); |
| 5521 |
| 5522 return [p1x,p1y,p2x,p2y] |
| 5523 }; |
| 5524 |
| 5525 function drawSpline(ctx,pts,t,minimumpos,maximumpos){ |
| 5526 var cp=[]; // array of control points, as x0,y0,x1,y1,
... |
| 5527 var n=pts.length; |
| 5528 |
| 5529 pts.push(2*pts[n-2]-pts[n-4]); |
| 5530 pts.push(2*pts[n-1]-pts[n-3]); |
| 5531 |
| 5532 if (n==4){ |
| 5533 ctx.moveTo(pts[0],pts[1]); |
| 5534 ctx.lineTo(pts[2],pts[3]); |
| 5535 return; |
| 5536 } |
| 5537 // Draw an open curve, not connected at the ends |
| 5538 for(var ti=0;ti<n-2;ti+=2){ |
| 5539 cp=cp.concat(getControlPoints(pts[ti],pts[ti+1],
pts[ti+2],pts[ti+3],pts[ti+4],pts[ti+5],t)); |
| 5540 } |
| 5541 // For first is a simple quadratics. |
| 5542 |
| 5543 ctx.beginPath(); |
| 5544 ctx.strokeStyle=setOptionValue("STROKECOLOR",ctx,data,st
atData,data.datasets[i].strokeColor,config.defaultStrokeColor,i,j,{nullvalue : n
ull} ); |
| 5545 ctx.lineWidth = config.datasetStrokeWidth; |
| 5546 ctx.moveTo(pts[0],pts[1]); |
| 5547 ctx.quadraticCurveTo(cp[0],Math.max(Math.min(cp[1],minim
umpos),maximumpos),pts[2],pts[3]); |
| 5548 |
| 5549 for(var ti=2;ti<pts.length-3;ti+=2){ |
| 5550 y1=Math.max(Math.min(cp[2*ti-1],minimumpos),maxi
mumpos); |
| 5551 y2=Math.max(Math.min(cp[2*ti+1],minimumpos),maxi
mumpos); |
| 5552 ctx.bezierCurveTo(cp[2*ti-2],y1,cp[2*ti],y2,pts[
ti+2],pts[ti+3]); |
| 5553 } |
| 5554 ctx.stroke(); |
| 5555 }; |
| 5556 |
| 5557 |
6233 }; | 5558 }; |
6234 | 5559 |
6235 function log10(val) { | 5560 function log10(val) { |
6236 return Math.log(val) / Math.LN10; | 5561 return Math.log(val) / Math.LN10; |
6237 }; | 5562 }; |
6238 | 5563 |
6239 function setRect(ctx, config) { | 5564 function setRect(ctx, config) { |
6240 if (config.clearRect) { | 5565 if (config.clearRect) { |
6241 if (!config.multiGraph) { | 5566 if (!config.multiGraph) { |
6242 clear(ctx); | 5567 clear(ctx); |
(...skipping 10 matching lines...) Expand all Loading... |
6253 ctx.lineTo(0, ctx.canvas.height); | 5578 ctx.lineTo(0, ctx.canvas.height); |
6254 ctx.lineTo(ctx.canvas.width, ctx.canvas.height); | 5579 ctx.lineTo(ctx.canvas.width, ctx.canvas.height); |
6255 ctx.lineTo(ctx.canvas.width, 0); | 5580 ctx.lineTo(ctx.canvas.width, 0); |
6256 ctx.lineTo(0, 0); | 5581 ctx.lineTo(0, 0); |
6257 ctx.stroke(); | 5582 ctx.stroke(); |
6258 ctx.fill(); | 5583 ctx.fill(); |
6259 } | 5584 } |
6260 }; | 5585 }; |
6261 | 5586 |
6262 function defMouse(ctx, data, config) { | 5587 function defMouse(ctx, data, config) { |
6263 » » if (config.annotateDisplay == true) { | 5588 » » var todoannotate=false; |
| 5589 » » if(typeof config.annotateDisplay=="function") { todoannotate=tru
e; |
| 5590 » » } else if(typeof config.annotateDisplay == "object") { |
| 5591 » » » for(var j=0;j<config.annotateDisplay.length;j++) if (con
fig.annotateDisplay[j]) todoannotate=true; |
| 5592 » » } else todoannotage=config.annotateDisplay; |
| 5593 » » |
| 5594 » » if (isBooleanOptionTrue(undefined,config.annotateDisplay)) { |
6264 if (cursorDivCreated == false) oCursor = new makeCursorO
bj('divCursor'); | 5595 if (cursorDivCreated == false) oCursor = new makeCursorO
bj('divCursor'); |
6265 if (isIE() < 9 && isIE() != false) ctx.canvas.attachEven
t("on" + config.annotateFunction.split(' ')[0], function(event) { | 5596 if (isIE() < 9 && isIE() != false) ctx.canvas.attachEven
t("on" + config.annotateFunction.split(' ')[0], function(event) { |
6266 if ((config.annotateFunction.split(' ')[1] == "l
eft" && event.which == 1) || | 5597 if ((config.annotateFunction.split(' ')[1] == "l
eft" && event.which == 1) || |
6267 (config.annotateFunction.split(' ')[1] =
= "middle" && event.which == 2) || | 5598 (config.annotateFunction.split(' ')[1] =
= "middle" && event.which == 2) || |
6268 (config.annotateFunction.split(' ')[1] =
= "right" && event.which == 3) || | 5599 (config.annotateFunction.split(' ')[1] =
= "right" && event.which == 3) || |
6269 (typeof(config.annotateFunction.split('
')[1]) != "string")) doMouseAction(config, ctx, event, data, "annotate", config.
mouseDownRight) | 5600 (typeof(config.annotateFunction.split('
')[1]) != "string")) doMouseAction(config, ctx, event, data, "annotate", config.
mouseDownRight) |
6270 }); | 5601 }); |
6271 else ctx.canvas.addEventListener(config.annotateFunction
.split(' ')[0], function(event) { | 5602 else ctx.canvas.addEventListener(config.annotateFunction
.split(' ')[0], function(event) { |
6272 if ((config.annotateFunction.split(' ')[1] == "l
eft" && event.which == 1) || | 5603 if ((config.annotateFunction.split(' ')[1] == "l
eft" && event.which == 1) || |
6273 (config.annotateFunction.split(' ')[1] =
= "middle" && event.which == 2) || | 5604 (config.annotateFunction.split(' ')[1] =
= "middle" && event.which == 2) || |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6328 | 5659 |
6329 add_event_listener("mousedown", config.mouseDownLeft, function(e
) { return e.which == 1; }); | 5660 add_event_listener("mousedown", config.mouseDownLeft, function(e
) { return e.which == 1; }); |
6330 add_event_listener("mousedown", config.mouseDownMiddle, function
(e) { return e.which == 2; }); | 5661 add_event_listener("mousedown", config.mouseDownMiddle, function
(e) { return e.which == 2; }); |
6331 add_event_listener("mousedown", config.mouseDownRight, function(
e) { return e.which == 3; }); | 5662 add_event_listener("mousedown", config.mouseDownRight, function(
e) { return e.which == 3; }); |
6332 add_event_listener("mousemove", config.mouseMove); | 5663 add_event_listener("mousemove", config.mouseMove); |
6333 add_event_listener("mouseout", config.mouseOut); | 5664 add_event_listener("mouseout", config.mouseOut); |
6334 add_event_listener("mousewheel", config.mouseWheel); | 5665 add_event_listener("mousewheel", config.mouseWheel); |
6335 }; | 5666 }; |
6336 }; | 5667 }; |
6337 | 5668 |
| 5669 |
| 5670 |
6338 function animationCorrection(animationValue, data, config, vdata, vsubdata, addo
ne) { | 5671 function animationCorrection(animationValue, data, config, vdata, vsubdata, addo
ne) { |
6339 var animValue = animationValue; | 5672 var animValue = animationValue; |
6340 var animSubValue = 0; | 5673 var animSubValue = 0; |
6341 if (vsubdata != -1) { | 5674 if (vsubdata != -1) { |
6342 if (animValue < 1 && (vdata < (config.animationStartWithDataset
- 1) && (config.animationStartWithDataset - 1) != -1)) { | 5675 if (animValue < 1 && (vdata < (config.animationStartWithDataset
- 1) && (config.animationStartWithDataset - 1) != -1)) { |
6343 animValue = 1; | 5676 animValue = 1; |
6344 } | 5677 } |
6345 if (animValue < 1 && (vsubdata < (config.animationStartWithData
- 1) && (config.animationStartWithData - 1) != -1)) { | 5678 if (animValue < 1 && (vsubdata < (config.animationStartWithData
- 1) && (config.animationStartWithData - 1) != -1)) { |
6346 animValue = 1; | 5679 animValue = 1; |
6347 } | 5680 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6430 nbcols++; | 5763 nbcols++; |
6431 if (nbcols == legendMsr.nbLegendCols) { | 5764 if (nbcols == legendMsr.nbLegendCols) { |
6432 nbcols = 0; | 5765 nbcols = 0; |
6433 xpos = legendMsr.xFirstLegendTextPos; | 5766 xpos = legendMsr.xFirstLegendTextPos; |
6434 ypos += config.legendFontSize + config.l
egendSpaceBetweenTextVertical; | 5767 ypos += config.legendFontSize + config.l
egendSpaceBetweenTextVertical; |
6435 } else { | 5768 } else { |
6436 xpos += legendMsr.widestLegend + config.
legendSpaceBetweenTextHorizontal; | 5769 xpos += legendMsr.widestLegend + config.
legendSpaceBetweenTextHorizontal; |
6437 } | 5770 } |
6438 ctx.save(); | 5771 ctx.save(); |
6439 ctx.beginPath(); | 5772 ctx.beginPath(); |
6440 » » » » if (legendMsr.drawLegendOnData) { | 5773 » » » » var lgdbox=legendMsr.legendBox; |
6441 » » » » » if (typeof data.datasets[orderi].strokeC
olor == "function") ctx.strokeStyle = data.datasets[orderi].strokeColor("STROKEC
OLOR", data, config, orderi, -1, 1, -1, typegraph, ctx, -1, -1, -1, -1); | 5774 » » » » if(ctx.tpchart=="Bar") if (data.datasets[orderi]
.type=="Line" && !config.datasetFill) lgdbox=false; |
6442 » » » » » else if (typeof data.datasets[orderi].st
rokeColor == "string") ctx.strokeStyle = data.datasets[orderi].strokeColor; | 5775 » » » » if (lgdbox) { |
6443 » » » » » else ctx.strokeStyle = config.defaultStr
okeColor; | 5776 » » » » » ctx.lineWidth = config.datasetStrokeWidt
h; |
6444 » » » » } else { | 5777 » » » » » ctx.beginPath(); |
6445 » » » » » if (typeof data[orderi].color == "functi
on") ctx.strokeStyle = data[orderi].color("COLOR", data, config, orderi, -1, 1,
data[orderi].value, typegraph, ctx, 1, 1, 1, 1); | 5778 » » » » » if (legendMsr.drawLegendOnData) { |
6446 » » » » » else if (typeof data[orderi].color == "s
tring") ctx.strokeStyle = data[orderi].color; | 5779 » » » » » » ctx.strokeStyle=setOptionValue("
LEGENDSTROKECOLOR",ctx,data,undefined,data.datasets[orderi].strokeColor,config.d
efaultFillColor,orderi,-1,{animationValue: 1, xPosLeft : xpos, yPosBottom : ypos
, xPosRight : xpos + config.legendBlockSize, yPosTop : ypos - config.legendFontS
ize} ); |
6447 » » » » » else ctx.strokeStyle = config.defaultStr
okeColor; | 5780 » » » » » } else { |
6448 » » » » } | 5781 » » » » » » ctx.strokeStyle=setOptionValue("
LEGENDSTROKECOLOR",ctx,data,undefined,data[orderi].strokeColor,config.defaultFil
lColor,orderi,-1,{animationValue: 1, xPosLeft : xpos, yPosBottom : ypos, xPosRig
ht : xpos + config.legendBlockSize, yPosTop : ypos - config.legendFontSize} ); |
6449 » » » » if (legendMsr.legendBox) { | 5782 » » » » » } |
6450 » » » » » ctx.lineWidth = 1; | |
6451 ctx.moveTo(xpos, ypos); | 5783 ctx.moveTo(xpos, ypos); |
6452 ctx.lineTo(xpos + config.legendBlockSize
, ypos); | 5784 ctx.lineTo(xpos + config.legendBlockSize
, ypos); |
6453 ctx.lineTo(xpos + config.legendBlockSize
, ypos - config.legendFontSize); | 5785 ctx.lineTo(xpos + config.legendBlockSize
, ypos - config.legendFontSize); |
6454 ctx.lineTo(xpos, ypos - config.legendFon
tSize); | 5786 ctx.lineTo(xpos, ypos - config.legendFon
tSize); |
6455 ctx.lineTo(xpos, ypos); | 5787 ctx.lineTo(xpos, ypos); |
6456 ctx.closePath(); | 5788 ctx.closePath(); |
| 5789 ctx.stroke(); |
| 5790 |
6457 if (legendMsr.drawLegendOnData) { | 5791 if (legendMsr.drawLegendOnData) { |
6458 » » » » » » if (typeof data.datasets[orderi]
.fillColor == "function") ctx.fillStyle = data.datasets[orderi].fillColor("LEGEN
DFILLCOLOR", data, config, orderi, -1, 1, -1, typegraph, ctx, xpos, ypos, xpos +
config.legendBlockSize, ypos - config.legendFontSize); | 5792 » » » » » » ctx.fillStyle=setOptionValue("LE
GENDFILLCOLOR",ctx,data,undefined,data.datasets[orderi].fillColor,config.default
FillColor,orderi,-1,{animationValue: 1, xPosLeft : xpos, yPosBottom : ypos, xPos
Right : xpos + config.legendBlockSize, yPosTop : ypos - config.legendFontSize} )
; |
6459 » » » » » » else if (typeof data.datasets[or
deri].fillColor == "string") ctx.fillStyle = data.datasets[orderi].fillColor; | |
6460 » » » » » » else ctx.fillStyle = config.defa
ultFillColor; | |
6461 } else { | 5793 } else { |
6462 » » » » » » if (typeof data[orderi].color ==
"function") ctx.fillStyle = data[orderi].color("LEGENDFILLCOLOR", data, config,
orderi, -1, 1, -1, typegraph, ctx, xpos, ypos - config.legendFontSize, xpos + c
onfig.legendBlockSize, ypos); | 5794 » » » » » » ctx.fillStyle=setOptionValue("LE
GENDFILLCOLOR",ctx,data,undefined,data[orderi].color,config.defaultFillColor,ord
eri,-1,{animationValue: 1, xPosLeft : xpos, yPosBottom : ypos, xPosRight : xpos
+ config.legendBlockSize, yPosTop : ypos - config.legendFontSize} ); |
6463 » » » » » » else if (typeof data[orderi].col
or == "string") ctx.fillStyle = data[orderi].color; | |
6464 » » » » » » else ctx.fillStyle = config.defa
ultFillColor; | |
6465 } | 5795 } |
6466 ctx.fill(); | 5796 ctx.fill(); |
6467 } else { | 5797 } else { |
6468 ctx.lineWidth = config.legendColorIndica
torStrokeWidth ? | 5798 ctx.lineWidth = config.legendColorIndica
torStrokeWidth ? |
6469 config.legendColorIndicatorStrok
eWidth : config.datasetStrokeWidth; | 5799 config.legendColorIndicatorStrok
eWidth : config.datasetStrokeWidth; |
6470 if (config.legendColorIndicatorStrokeWid
th && config.legendColorIndicatorStrokeWidth > config.legendFontSize) { | 5800 if (config.legendColorIndicatorStrokeWid
th && config.legendColorIndicatorStrokeWidth > config.legendFontSize) { |
6471 ctx.lineWidth = config.legendFon
tSize; | 5801 ctx.lineWidth = config.legendFon
tSize; |
6472 } | 5802 } |
| 5803 if (legendMsr.drawLegendOnData) { |
| 5804 ctx.strokeStyle=setOptionValue("
LEGENDSTROKECOLOR",ctx,data,undefined,data.datasets[orderi].strokeColor,config.d
efaultFillColor,orderi,-1,{animationValue: 1, xPosLeft : xpos, yPosBottom : ypos
, xPosRight : xpos + config.legendBlockSize, yPosTop : ypos - config.legendFontS
ize} ); |
| 5805 } else { |
| 5806 ctx.strokeStyle=setOptionValue("
LEGENDSTROKECOLOR",ctx,data,undefined,data[orderi].strokeColor,config.defaultFil
lColor,orderi,-1,{animationValue: 1, xPosLeft : xpos, yPosBottom : ypos, xPosRig
ht : xpos + config.legendBlockSize, yPosTop : ypos - config.legendFontSize} ); |
| 5807 } |
| 5808 |
6473 ctx.moveTo(xpos + 2, ypos - (config.lege
ndFontSize / 2)); | 5809 ctx.moveTo(xpos + 2, ypos - (config.lege
ndFontSize / 2)); |
6474 ctx.lineTo(xpos + 2 + config.legendBlock
Size, ypos - (config.legendFontSize / 2)); | 5810 ctx.lineTo(xpos + 2 + config.legendBlock
Size, ypos - (config.legendFontSize / 2)); |
| 5811 ctx.stroke(); |
| 5812 |
| 5813 ctx.fill(); |
| 5814 |
| 5815 if(config.pointDot) { |
| 5816 ctx.beginPath(); |
| 5817 ctx.fillStyle=setOptionValue("LE
GENDMARKERFILLCOLOR",ctx,data,undefined,data.datasets[orderi].pointColor,config.
defaultStrokeColor,orderi,-1,{nullvalue: true} ); |
| 5818 ctx.strokeStyle=setOptionValue("
LEGENDMARKERSTROKESTYLE",ctx,data,undefined,data.datasets[orderi].pointStrokeCol
or,config.defaultStrokeColor,orderi,-1,{nullvalue: true} ); |
| 5819 ctx.lineWidth=setOptionValue("LE
GENDMARKERLINEWIDTH",ctx,data,undefined,data.datasets[orderi].pointDotStrokeWidt
h,config.pointDotStrokeWidth,orderi,-1,{nullvalue: true} ); |
| 5820 |
| 5821 var markerShape=setOptionValue("
LEGENDMARKERSHAPE",ctx,data,undefined,data.datasets[orderi].markerShape,config.m
arkerShape,orderi,-1,{nullvalue: true} ); |
| 5822 var markerRadius=setOptionValue(
"LEGENDMARKERRADIUS",ctx,data,undefined,data.datasets[orderi].pointDotRadius,con
fig.pointDotRadius,orderi,-1,{nullvalue: true} ); |
| 5823 drawMarker(ctx,xpos + 2 + config
.legendBlockSize/2, ypos - (config.legendFontSize / 2), markerShape,markerRadius
); |
| 5824 } |
| 5825 ctx.fill(); |
| 5826 |
6475 } | 5827 } |
6476 ctx.stroke(); | |
6477 ctx.restore(); | 5828 ctx.restore(); |
6478 ctx.save(); | 5829 ctx.save(); |
6479 ctx.beginPath(); | 5830 ctx.beginPath(); |
6480 ctx.font = config.legendFontStyle + " " + config
.legendFontSize + "px " + config.legendFontFamily; | 5831 ctx.font = config.legendFontStyle + " " + config
.legendFontSize + "px " + config.legendFontFamily; |
6481 ctx.fillStyle = config.legendFontColor; | 5832 ctx.fillStyle = config.legendFontColor; |
6482 ctx.textAlign = "left"; | 5833 ctx.textAlign = "left"; |
6483 ctx.textBaseline = "bottom"; | 5834 ctx.textBaseline = "bottom"; |
6484 ctx.translate(xpos + config.legendBlockSize + co
nfig.legendSpaceBetweenBoxAndText, ypos); | 5835 ctx.translate(xpos + config.legendBlockSize + co
nfig.legendSpaceBetweenBoxAndText, ypos); |
6485 ctx.fillText(lgtxt, 0, 0); | 5836 ctx.fillText(lgtxt, 0, 0); |
6486 ctx.stroke(); | |
6487 ctx.restore(); | 5837 ctx.restore(); |
6488 } | 5838 } |
6489 } | 5839 } |
6490 } | 5840 } |
6491 }; | 5841 }; |
| 5842 |
| 5843 function drawMarker(ctx,xpos,ypos,marker,markersize) { |
| 5844 switch (marker) { |
| 5845 case "square": |
| 5846 ctx.rect(xpos-markersize,ypos-markersize,2*markersize,2*
markersize); |
| 5847 ctx.stroke(); |
| 5848 ctx.fill(); |
| 5849 break; |
| 5850 case "triangle": |
| 5851 pointA_x=0; |
| 5852 pointA_y=2/3*markersize; |
| 5853 ctx.moveTo(xpos,ypos-pointA_y); |
| 5854 ctx.lineTo(xpos+pointA_y*Math.sin(4/3),ypos+pointA_y*Mat
h.cos(4/3)); |
| 5855 ctx.lineTo(xpos-pointA_y*Math.sin(4/3),ypos+pointA_y*Mat
h.cos(4/3)); |
| 5856 ctx.lineTo(xpos,ypos-pointA_y); |
| 5857 ctx.stroke(); |
| 5858 ctx.fill(); |
| 5859 break; |
| 5860 case "diamond": |
| 5861 ctx.moveTo(xpos, ypos+markersize); |
| 5862 ctx.lineTo(xpos+markersize, ypos); |
| 5863 ctx.lineTo(xpos, ypos-markersize); |
| 5864 ctx.lineTo(xpos-markersize, ypos); |
| 5865 ctx.lineTo(xpos, ypos+markersize); |
| 5866 ctx.stroke(); |
| 5867 ctx.fill(); |
| 5868 break; |
| 5869 case "plus": |
| 5870 ctx.moveTo(xpos, ypos-markersize); |
| 5871 ctx.lineTo(xpos, ypos+markersize); |
| 5872 ctx.moveTo(xpos-markersize, ypos); |
| 5873 ctx.lineTo(xpos+markersize, ypos); |
| 5874 ctx.stroke(); |
| 5875 break; |
| 5876 case "cross": |
| 5877 ctx.moveTo(xpos-markersize, ypos-markersize); |
| 5878 ctx.lineTo(xpos+markersize, ypos+markersize); |
| 5879 ctx.moveTo(xpos-markersize, ypos+markersize); |
| 5880 ctx.lineTo(xpos+markersize, ypos-markersize); |
| 5881 ctx.stroke(); |
| 5882 break; |
| 5883 case "circle": |
| 5884 default: |
| 5885 ctx.arc(xpos, ypos, markersize, 0, 2*Math.PI * 1, true); |
| 5886 ctx.stroke(); |
| 5887 ctx.fill(); |
| 5888 break; |
| 5889 } |
| 5890 }; |
| 5891 |
| 5892 function initPassVariableData_part1(data,config,ctx) { |
| 5893 |
| 5894 switch(ctx.tpchart) { |
| 5895 case "Pie" : |
| 5896 case "Doughnut" : |
| 5897 case "PolarArea" : |
| 5898 |
| 5899 var result=[]; |
| 5900 var lgtxt,totvalue,cumvalue,segmentAngle,cumulativeAngle,realCum
ulativeAngle; |
| 5901 |
| 5902 cumulativeAngle = (((-config.startAngle * (Math.PI / 180) + 2 *
Math.PI) % (2 * Math.PI)) + 2* Math.PI) % (2* Math.PI) ; |
| 5903 realCumulativeAngle = (((config.startAngle * (Math.PI / 180) + 2
* Math.PI) % (2 * Math.PI)) + 2* Math.PI) % (2* Math.PI) ; |
| 5904 |
| 5905 startAngle=cumulativeAngle; |
| 5906 totvalue = 0; |
| 5907 notemptyval=0; |
| 5908 var firstNotMissing = -1; |
| 5909 var lastNotMissing = -1; |
| 5910 var prevNotMissing = -1; |
| 5911 var mxvalue=-Number.MAX_VALUE; |
| 5912 var mnvalue=Number.MAX_VALUE; |
| 5913 for (var i = 0; i < data.length; i++) { |
| 5914 if(ctx.tpchart != "PolarArea" && 1*data[i].value<0)conti
nue; |
| 5915 if (!(typeof(data[i].value) == 'undefined')) { |
| 5916 if(firstNotMissing==-1)firstNotMissing=i; |
| 5917 mxvalue=Math.max(mxvalue,1*data[i].value); |
| 5918 mnvalue=Math.min(mnvalue,1*data[i].value); |
| 5919 notemptyval++; |
| 5920 totvalue += 1 * data[i].value; |
| 5921 lastNotMissing=i; |
| 5922 } |
| 5923 } |
| 5924 |
| 5925 cumvalue=0; |
| 5926 var prevMissing=-1; |
| 5927 for(i=0;i<data.length;i++) { |
| 5928 if (typeof(data[i].title) == "string") lgtxt = data[i].t
itle.trim(); |
| 5929 else lgtxt = ""; |
| 5930 if (!(typeof(data[i].value) == 'undefined') && (ctx.tpch
art == "PolarArea" || 1*data[i].value>=0)) { |
| 5931 if(ctx.tpchart=="PolarArea") { if(notemptyval>0)
segmentAngle= (Math.PI *2)/notemptyval; else segmentAngle=0; } |
| 5932 else segmentAngle = (1 * data[i].value / totvalu
e) * (Math.PI * 2); |
| 5933 if (segmentAngle >= Math.PI * 2) segmentAngle =
Math.PI * 2 - 0.001; // bug on Android when segmentAngle is >= 2*PI; |
| 5934 cumvalue += 1 * data[i].value; |
| 5935 result[i]= { |
| 5936 config: config, |
| 5937 v1: fmtChartJS(config, lgtxt, config.fmt
V1), |
| 5938 v2: fmtChartJS(config, 1 * data[i].value
, config.fmtV2), |
| 5939 v3: fmtChartJS(config, cumvalue, config.
fmtV3), |
| 5940 v4: fmtChartJS(config, totvalue, config.
fmtV4), |
| 5941 v5: fmtChartJS(config, segmentAngle, con
fig.fmtV5), |
| 5942 v6: roundToWithThousands(config, fmtChar
tJS(config, 100 * data[i].value / totvalue, config.fmtV6), config.roundPct), |
| 5943 v7 : 0, |
| 5944 v8 : 0, |
| 5945 v9 : 0, |
| 5946 v10 : 0, |
| 5947 v11: fmtChartJS(config, cumulativeAngle
- segmentAngle, config.fmtV11), |
| 5948 v12: fmtChartJS(config, cumulativeAngle,
config.fmtV12), |
| 5949 v13: fmtChartJS(config, i, config.fmtV13
), |
| 5950 lgtxt: lgtxt, |
| 5951 datavalue: 1 * data[i].value, |
| 5952 cumvalue: cumvalue, |
| 5953 totvalue: totvalue, |
| 5954 segmentAngle: segmentAngle, |
| 5955 firstAngle : startAngle, |
| 5956 pctvalue: 100 * data[i].value / totvalue
, |
| 5957 startAngle: cumulativeAngle, |
| 5958 realStartAngle : realCumulativeAngle, |
| 5959 endAngle: cumulativeAngle+segmentAngle, |
| 5960 maxvalue : mxvalue, |
| 5961 minvalue : mnvalue, |
| 5962 i: i, |
| 5963 firstNotMissing : firstNotMissing, |
| 5964 lastNotMissing : lastNotMissing, |
| 5965 prevNotMissing : prevNotMissing, |
| 5966 prevMissing : prevMissing, |
| 5967 nextNotMissing : -1, |
| 5968 radiusOffset : 0, |
| 5969 midPosX : 0, |
| 5970 midPosY : 0, |
| 5971 int_radius : 0, |
| 5972 ext_radius : 0, |
| 5973 data: data |
| 5974 }; |
| 5975 cumulativeAngle += segmentAngle; |
| 5976 realCumulativeAngle -= segmentAngle; |
| 5977 if(prevNotMissing != -1) result[prevNotMissing].
nextNotMissing=i; |
| 5978 prevNotMissing = i; |
| 5979 } else { |
| 5980 result[i]={ |
| 5981 v1:lgtxt, |
| 5982 maxvalue : mxvalue, |
| 5983 minvalue : mnvalue, |
| 5984 i: i, |
| 5985 firstNotMissing : firstNotMissing, |
| 5986 lastNotMissing : lastNotMissing, |
| 5987 prevNotMissing : prevNotMissing |
| 5988 }; |
| 5989 prevMissing=i; |
| 5990 } |
| 5991 } |
| 5992 break; |
| 5993 case "Bar" : |
| 5994 case "Line" : |
| 5995 case "HorizontalBar" : |
| 5996 case "StackedBar" : |
| 5997 case "HorizontalStackedBar" : |
| 5998 case "Radar" : |
| 5999 var axis; |
| 6000 var result=[]; |
| 6001 var mxvalue=[]; |
| 6002 mxvalue[0]=[]; |
| 6003 mxvalue[1]=[]; |
| 6004 var mnvalue=[]; |
| 6005 mnvalue[0]=[]; |
| 6006 mnvalue[1]=[]; |
| 6007 var cumvalue=[]; |
| 6008 cumvalue[0]=[]; |
| 6009 cumvalue[1]=[]; |
| 6010 var totvalue=[]; |
| 6011 totvalue[0]=[]; |
| 6012 totvalue[1]=[]; |
| 6013 var lmaxvalue=[]; |
| 6014 lmaxvalue[0]=[]; |
| 6015 lmaxvalue[1]=[]; |
| 6016 var lminvalue=[]; |
| 6017 lminvalue[0]=[]; |
| 6018 lminvalue[1]=[]; |
| 6019 var lgtxt,lgtxt2,tp; |
| 6020 var prevpos=[]; |
| 6021 var firstNotMissingi=[]; |
| 6022 var lastNotMissingi=[]; |
| 6023 var firstNotMissingj=[]; |
| 6024 var lastNotMissingj=[]; |
| 6025 prevpos[0]=[]; |
| 6026 prevpos[1]=[]; |
| 6027 for (var i = 0; i < data.datasets.length; i++) { |
| 6028 // BUG when all data are missing ! |
| 6029 if (typeof data.datasets[i].xPos != "undefined" && tpdra
w(ctx,data.datasets[i])=="Line") { |
| 6030 for(var j=data.datasets[i].data.length;j<data.da
tasets[i].xPos.length;j++)data.datasets[i].data.push(undefined); |
| 6031 } else { |
| 6032 for(var j=data.datasets[i].data.length;j<data.la
bels.length;j++)data.datasets[i].data.push(undefined); |
| 6033 } |
| 6034 |
| 6035 |
| 6036 if(data.datasets[i].axis == 2) axis=0;else axis=1; |
| 6037 result[i]=[]; |
| 6038 lmaxvalue[0][i]=-Number.MAX_VALUE; |
| 6039 lmaxvalue[1][i]=-Number.MAX_VALUE; |
| 6040 lminvalue[0][i]=Number.MAX_VALUE; |
| 6041 lminvalue[1][i]=Number.MAX_VALUE; |
| 6042 firstNotMissingi[i]=-1; |
| 6043 lastNotMissingi[i]=-1; |
| 6044 for (var j = 0; j < data.datasets[i].data.length; j++) { |
| 6045 |
| 6046 if(typeof firstNotMissingj[j]== "undefined"){ |
| 6047 firstNotMissingj[j]=-1; |
| 6048 lastNotMissingj[j]=-1; |
| 6049 totvalue[0][j] = 0; |
| 6050 mxvalue[0][j]=-Number.MAX_VALUE; |
| 6051 mnvalue[0][j]=Number.MAX_VALUE; |
| 6052 totvalue[1][j] = 0; |
| 6053 mxvalue[1][j]=-Number.MAX_VALUE; |
| 6054 mnvalue[1][j]=Number.MAX_VALUE; |
| 6055 } |
| 6056 if (!(typeof data.datasets[i].data[j] == 'undefi
ned')) { |
| 6057 if(firstNotMissingi[i]==-1)firstNotMissi
ngi[i]=j; |
| 6058 lastNotMissingi[i]=j; |
| 6059 if(firstNotMissingj[j]==-1)firstNotMissi
ngj[j]=i; |
| 6060 lastNotMissingj[j]=i; |
| 6061 totvalue[axis][j] += 1 * data.datasets[i
].data[j]; |
| 6062 mxvalue[axis][j] =Math.max(mxvalue[axis]
[j],1 * data.datasets[i].data[j]); |
| 6063 mnvalue[axis][j] =Math.min(mnvalue[axis]
[j],1 * data.datasets[i].data[j]); |
| 6064 lmaxvalue[axis][i] =Math.max(lmaxvalue[a
xis][i],1 * data.datasets[i].data[j]); |
| 6065 lminvalue[axis][i] =Math.min(lminvalue[a
xis][i],1 * data.datasets[i].data[j]); |
| 6066 } |
| 6067 } |
| 6068 } |
| 6069 |
| 6070 for (var i = 0; i < data.datasets.length; i++) { |
| 6071 if(data.datasets[i].axis == 2) axis=0;else axis=1; |
| 6072 if (typeof(data.datasets[i].title) == "string") lgtxt =
data.datasets[i].title.trim(); |
| 6073 else lgtxt = ""; |
| 6074 var prevnotemptyj=-1; |
| 6075 var prevemptyj=-1; |
| 6076 for (var j = 0; j < data.datasets[i].data.length; j++) { |
| 6077 |
| 6078 if(typeof cumvalue[0][j]== "undefined"){cumvalue
[0][j] = 0; prevpos[0][j]=-1;cumvalue[1][j] = 0; prevpos[1][j]=-1; } |
| 6079 lgtxt2 = ""; |
| 6080 if (typeof data.datasets[i].xPos != "undefined")
{ |
| 6081 if (!(typeof data.datasets[i].xPos[j] ==
"undefined")) lgtxt2 = data.datasets[i].xPos[j]; |
| 6082 } |
| 6083 if (lgtxt2 == "" && !(typeof(data.labels[j]) ==
"undefined")) lgtxt2 = data.labels[j]; |
| 6084 if (typeof lgtxt2 == "string") lgtxt2 = lgtxt2.t
rim(); |
| 6085 |
| 6086 if (!(typeof(data.datasets[i].data[j]) == 'undef
ined')) { |
| 6087 cumvalue[axis][j]+=1*data.datasets[i].da
ta[j]; |
| 6088 switch(tpdraw(ctx,data.datasets[i])) { |
| 6089 case "Bar" : |
| 6090 case "StackedBar" : |
| 6091 case "HorizontalBar" : |
| 6092 case "HorizontalStackedBar" : |
| 6093 |
| 6094 result[i][j]= { |
| 6095 config: config, |
| 6096 v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), |
| 6097 v2: fmtChartJS(c
onfig, lgtxt2, config.fmtV2), |
| 6098 v3: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV3), |
| 6099 v4: fmtChartJS(c
onfig, cumvalue[axis][j], config.fmtV4), |
| 6100 v5: fmtChartJS(c
onfig, totvalue[axis][j], config.fmtV5), |
| 6101 v6: roundToWithT
housands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[ax
is][j], config.fmtV6), config.roundPct), |
| 6102 v11: fmtChartJS(
config, i, config.fmtV11), |
| 6103 v12: fmtChartJS(
config, j, config.fmtV12), |
| 6104 lgtxt: lgtxt, |
| 6105 lgtxt2: lgtxt2, |
| 6106 datavalue: 1 * d
ata.datasets[i].data[j], |
| 6107 cumvalue: cumval
ue[axis][j], |
| 6108 totvalue: totval
ue[axis][j], |
| 6109 pctvalue: 100 *
data.datasets[i].data[j] / totvalue[axis][j], |
| 6110 maxvalue : mxval
ue[axis][j], |
| 6111 minvalue : mnval
ue[axis][j], |
| 6112 lmaxvalue : lmax
value[axis][i], |
| 6113 lminvalue : lmin
value[axis][i], |
| 6114 firstNotMissing
: firstNotMissingj[j], |
| 6115 lastNotMissing :
lastNotMissingj[j], |
| 6116 prevNotMissing :
prevnotemptyj, |
| 6117 prevMissing : pr
evemptyj, |
| 6118 nextNotMissing :
-1, |
| 6119 j: j, |
| 6120 i: i, |
| 6121 data: data |
| 6122 }; |
| 6123 break; |
| 6124 case "Line" : |
| 6125 case "Radar" : |
| 6126 result[i][j]= { |
| 6127 config: config, |
| 6128 v1: fmtChartJS(c
onfig, lgtxt, config.fmtV1), |
| 6129 v2: fmtChartJS(c
onfig, lgtxt2, config.fmtV2), |
| 6130 v3: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV3), |
| 6131 v5: fmtChartJS(c
onfig, 1 * data.datasets[i].data[j], config.fmtV5), |
| 6132 v6: fmtChartJS(c
onfig, mxvalue[axis][j], config.fmtV7), |
| 6133 v7: fmtChartJS(c
onfig, totvalue[axis][j], config.fmtV6), |
| 6134 v8: roundToWithT
housands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[ax
is][j], config.fmtV8), config.roundPct), |
| 6135 v11: fmtChartJS(
config, i, config.fmtV11), |
| 6136 v12: fmtChartJS(
config, j, config.fmtV12), |
| 6137 lgtxt: lgtxt, |
| 6138 lgtxt2: lgtxt2, |
| 6139 datavalue: 1 * d
ata.datasets[i].data[j], |
| 6140 diffnext: 1 * da
ta.datasets[i].data[j], |
| 6141 pctvalue: 100 *
data.datasets[i].data[j] / totvalue[axis][j], |
| 6142 totvalue : totva
lue[axis][j], |
| 6143 cumvalue: cumval
ue[axis][j], |
| 6144 maxvalue : mxval
ue[axis][j], |
| 6145 minvalue : mnval
ue[axis][j], |
| 6146 lmaxvalue : lmax
value[axis][i], |
| 6147 lminvalue : lmin
value[axis][i], |
| 6148 lminvalue : lmin
value[axis][i], |
| 6149 firstNotMissing
: firstNotMissingi[i], |
| 6150 lastNotMissing :
lastNotMissingi[i], |
| 6151 prevNotMissing :
prevnotemptyj, |
| 6152 prevMissing : pr
evemptyj, |
| 6153 nextNotMissing :
-1, |
| 6154 j: j, |
| 6155 i: i, |
| 6156 data: data |
| 6157 }; |
| 6158 if(prevpos[axis][j]>=0){ |
| 6159 result[i][j].v4=
fmtChartJS(config, (prevpos[axis][j] != -1 ? 1 * data.datasets[i].data[j]-result
[prevpos[axis][j]][j].datavalue : 1 * data.datasets[i].data[j]), config.fmtV4); |
| 6160 result[i][j].dif
fprev=(prevpos[axis][j] != -1 ? 1 * data.datasets[i].data[j]-result[prevpos[axis
][j]][j].datavalue : 1 * data.datasets[i].data[j]); |
| 6161 result[prevpos[a
xis][j]][j].diffnext=data.datasets[prevpos[axis][j]].data[j] - data.datasets[i].
data[j]; |
| 6162 result[prevpos[a
xis][j]][j].v5=result[prevpos[axis][j]][j].diffnext; |
| 6163 } else { |
| 6164 result[i][j].v4=
1 * data.datasets[i].data[j]; |
| 6165 |
| 6166 } |
| 6167 prevpos[axis][j]=i; |
| 6168 break; |
| 6169 default: |
| 6170 break; |
| 6171 } |
| 6172 if(!(typeof(data.datasets[i].data[j]) ==
'undefined')) { |
| 6173 if(prevnotemptyj!= -1) {for(k=pr
evnotemptyj;k<j;k++) result[i][k].nextNotMissing=j;} |
| 6174 prevnotemptyj=j; |
| 6175 } |
| 6176 } else { |
| 6177 prevemptyj=j; |
| 6178 switch(tpdraw(ctx,data.datasets[i])) { |
| 6179 case "Bar" : |
| 6180 case "StackedBar" : |
| 6181 case "HorizontalBar" : |
| 6182 case "HorizontalStackedBar" : |
| 6183 result[i][j] ={ |
| 6184 v1:lgtxt, |
| 6185 lmaxvalue : lmax
value[axis][i], |
| 6186 lminvalue : lmin
value[axis][i], |
| 6187 firstNotMissing
: firstNotMissingj[j], |
| 6188 lastNotMissing :
lastNotMissingj[j], |
| 6189 prevNotMissing :
prevnotemptyj, |
| 6190 prevMissing : pr
evemptyj, |
| 6191 }; |
| 6192 break; |
| 6193 case "Line" : |
| 6194 case "Radar" : |
| 6195 result[i][j] ={ |
| 6196 v1:lgtxt, |
| 6197 lmaxvalue : lmax
value[axis][i], |
| 6198 lminvalue : lmin
value[axis][i], |
| 6199 firstNotMissing
: firstNotMissingi[i], |
| 6200 lastNotMissing :
lastNotMissingi[i], |
| 6201 prevNotMissing :
prevnotemptyj, |
| 6202 prevMissing : pr
evemptyj, |
| 6203 }; |
| 6204 break; |
| 6205 } |
| 6206 } |
| 6207 } |
| 6208 } |
| 6209 break; |
| 6210 default: |
| 6211 break; |
| 6212 } |
| 6213 |
| 6214 |
| 6215 return result; |
| 6216 |
| 6217 }; |
| 6218 |
| 6219 function initPassVariableData_part2(statData,data,config,ctx,othervars) { |
| 6220 |
| 6221 var realbars=0; |
| 6222 |
| 6223 switch(ctx.tpchart) { |
| 6224 case "Pie" : |
| 6225 case "Doughnut" : |
| 6226 case "PolarArea" : |
| 6227 for(i=0;i<data.length;i++) { |
| 6228 statData[i].v7= fmtChartJS(config, othervars.midPosX, co
nfig.fmtV7); |
| 6229 statData[i].v8= fmtChartJS(config, othervars.midPosY, co
nfig.fmtV8), |
| 6230 statData[i].v9= fmtChartJS(config, othervars.int_radius,
config.fmtV9); |
| 6231 statData[i].v10= fmtChartJS(config, othervars.ext_radius
, config.fmtV10); |
| 6232 if(ctx.tpchart=="PolarArea") { |
| 6233 statData[i].radiusOffset= calculateOffset(config
.logarithmic, 1 * data[i].value, othervars.calculatedScale, othervars.scaleHop); |
| 6234 statData[i].v10= fmtChartJS(config, statData[i].
radiusOffset, config.fmtV10); |
| 6235 } |
| 6236 else { |
| 6237 statData[i].v10= fmtChartJS(config, othervars.ex
t_radius, config.fmtV10); |
| 6238 statData[i].radiusOffset=othervars.ext_radius; |
| 6239 } |
| 6240 statData[i].midPosX= othervars.midPosX; |
| 6241 statData[i].midPosY= othervars.midPosY; |
| 6242 statData[i].int_radius= othervars.int_radius; |
| 6243 statData[i].ext_radius= othervars.ext_radius; |
| 6244 } |
| 6245 break; |
| 6246 case "Radar" : |
| 6247 case "Line" : |
| 6248 case "Bar" : |
| 6249 case "StackedBar" : |
| 6250 case "HorizontalBar" : |
| 6251 case "HorizontalStackedBar" : |
| 6252 var tp; |
| 6253 var tempp = new Array(data.datasets.length); |
| 6254 var tempn = new Array(data.datasets.length); |
| 6255 for (var i = 0; i < data.datasets.length; i++) { |
| 6256 switch(tpdraw(ctx,data.datasets[i])) { |
| 6257 case "Line" : |
| 6258 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
| 6259 |
| 6260 statData[i][j].xAxisPosY = other
vars.xAxisPosY; |
| 6261 statData[i][j].yAxisPosX = other
vars.yAxisPosX; |
| 6262 statData[i][j].valueHop = otherv
ars.valueHop; |
| 6263 statData[i][j].nbValueHop = othe
rvars.nbValueHop; |
| 6264 if (data.datasets[i].axis == 2)
{ |
| 6265 statData[i][j].scaleHop
= othervars.scaleHop2; |
| 6266 statData[i][j].zeroY = o
thervars.zeroY2; |
| 6267 statData[i][j].calculate
dScale = othervars.calculatedScale2; |
| 6268 statData[i][j].logarithm
ic = othervars.logarithmic2; |
| 6269 } else { |
| 6270 statData[i][j].scaleHop
= othervars.scaleHop; |
| 6271 statData[i][j].zeroY = o
thervars.zeroY; |
| 6272 statData[i][j].calculate
dScale = othervars.calculatedScale; |
| 6273 statData[i][j].logarithm
ic = othervars.logarithmic; |
| 6274 } |
| 6275 statData[i][j].xPos=xPos(i,j,dat
a,othervars.yAxisPosX,othervars.valueHop,othervars.nbValueHop); |
| 6276 statData[i][j].yAxisPos=othervar
s.xAxisPosY - statData[i][j].zeroY; |
| 6277 if(ctx.tpchart=="Bar") { |
| 6278 statData[i][j].xPos+=(ot
hervars.valueHop/2); |
| 6279 statData[i][j].yAxisPosX
+= (othervars.valueHop/2); |
| 6280 } |
| 6281 if(j==0) { |
| 6282 statData[i][j].lmaxvalue
_offset=calculateOffset(statData[i][j].logarithmic, statData[i][j].lmaxvalue, st
atData[i][j].calculatedScale, statData[i][j].scaleHop) - statData[i][j].zeroY; |
| 6283 statData[i][j].lminvalue
_offset=calculateOffset(statData[i][j].logarithmic, statData[i][j].lminvalue, st
atData[i][j].calculatedScale, statData[i][j].scaleHop) - statData[i][j].zeroY; |
| 6284 } else { |
| 6285 statData[i][j].lmaxvalue
_offset=statData[i][0].lmaxvalue_offset; |
| 6286 statData[i][j].lminvalue
_offset=statData[i][0].lminvalue_offset; |
| 6287 } |
| 6288 |
| 6289 if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { |
| 6290 statData[i][j].yPosOffse
t= calculateOffset(statData[i][j].logarithmic, data.datasets[i].data[j], statDat
a[i][j].calculatedScale, statData[i][j].scaleHop) - statData[i][j].zeroY; |
| 6291 statData[i][j].posY=stat
Data[i][j].yAxisPos - statData[i][j].yPosOffset; |
| 6292 } |
| 6293 statData[i][j].posX=statData[i][
j].xPos; |
| 6294 statData[i][j].v9= statData[i][j
].xPos; |
| 6295 statData[i][j].v10=statData[i][j
].posY; |
| 6296 |
| 6297 statData[i][j].annotateStartPosX
= statData[i][j].xPos; |
| 6298 statData[i][j].annotateEndPosX =
statData[i][j].xPos; |
| 6299 statData[i][j].annotateStartPosY
= othervars.xAxisPosY; |
| 6300 statData[i][j].annotateEndPosY =
othervars.xAxisPosY-othervars.msr.availableHeight; |
| 6301 statData[i][j].D1A=undefined; |
| 6302 statData[i][j].D1B=undefined; |
| 6303 } |
| 6304 break; |
| 6305 case "Radar" : |
| 6306 var rotationDegree = (2 * Math.PI) / dat
a.datasets[0].data.length; |
| 6307 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
| 6308 statData[i][j].midPosX = otherv
ars.midPosX; |
| 6309 statData[i][j].midPosY = otherv
ars.midPosY; |
| 6310 statData[i][j].int_radius= 0; |
| 6311 statData[i][j].ext_radius= other
vars.maxSize; |
| 6312 statData[i][j].radiusOffset= oth
ervars.maxSize; |
| 6313 statData[i][j].calculated_offset
= calculateOffset(config.logarithmic, data.datasets[i].data[j], othervars.calcul
atedScale, othervars.scaleHop); |
| 6314 statData[i][j].offsetX=Math.cos(
config.startAngle * Math.PI / 180 - j * rotationDegree) * statData[i][j].calcula
ted_offset; |
| 6315 statData[i][j].offsetY=Math.sin(
config.startAngle * Math.PI / 180 - j * rotationDegree) * statData[i][j].calcula
ted_offset; |
| 6316 statData[i][j].v9=statData[i][j]
.midPosX + statData[i][j].offsetX; |
| 6317 statData[i][j].v10=statData[i][j
].midPosY - statData[i][j].offsetY; |
| 6318 statData[i][j].posX=statData[i][
j].midPosX + statData[i][j].offsetX; |
| 6319 statData[i][j].posY=statData[i][
j].midPosY - statData[i][j].offsetY; |
| 6320 if(j==0)statData[i][j].calculate
d_offset_max=calculateOffset(config.logarithmic, statData[i][j].lmaxvalue, other
vars.calculatedScale, othervars.scaleHop); |
| 6321 else statData[i][j].calculate
d_offset_max=statData[0][j].calculated_offset_max; |
| 6322 statData[i][j].annotateStartPosX
= othervars.midPosX; |
| 6323 statData[i][j].annotateEndPosX =
othervars.midPosX+Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegr
ee) * othervars.maxSize; |
| 6324 statData[i][j].annotateStartPosY
= othervars.midPosY; |
| 6325 statData[i][j].annotateEndPosY =
othervars.midPosY-Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegr
ee) * othervars.maxSize; |
| 6326 if(Math.abs(statData[i][j].annot
ateStartPosX-statData[i][j].annotateEndPosX)<config.zeroValue) { |
| 6327 statData[i][j].D1A=undef
ined; |
| 6328 statData[i][j].D1B=undef
ined; |
| 6329 statData[i][j].D2A=0; |
| 6330 } else { |
| 6331 statData[i][j].D1A=(stat
Data[i][j].annotateStartPosY-statData[i][j].annotateEndPosY)/(statData[i][j].ann
otateStartPosX-statData[i][j].annotateEndPosX); |
| 6332 statData[i][j].D1B=-stat
Data[i][j].D1A*statData[i][j].annotateStartPosX+statData[i][j].annotateStartPosY
; |
| 6333 if(Math.abs(statData[i][
j].D1A)>=config.zeroValue)statData[i][j].D2A=-(1/statData[i][j].D1A); |
| 6334 else statData[i][j].D2A=
undefined; |
| 6335 } |
| 6336 |
| 6337 } |
| 6338 break; |
| 6339 case "Bar" : |
| 6340 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
| 6341 statData[i][j].xPosLeft= otherva
rs.yAxisPosX + config.barValueSpacing + othervars.valueHop * j + othervars.barWi
dth * realbars + config.barDatasetSpacing * realbars + config.barStrokeWidth * r
ealbars; |
| 6342 statData[i][j].xPosRight = statD
ata[i][j].xPosLeft + othervars.barWidth; |
| 6343 statData[i][j].yPosBottom =other
vars.xAxisPosY - othervars.zeroY |
| 6344 statData[i][j].barHeight=calcula
teOffset(config.logarithmic, 1 * data.datasets[i].data[j], othervars.calculatedS
cale, othervars.scaleHop) - othervars.zeroY; |
| 6345 if (data.datasets[i].axis == 2)
{ |
| 6346 statData[i][j].yPosBotto
m =othervars.xAxisPosY - othervars.zeroY2; |
| 6347 statData[i][j].barHeight
=calculateOffset(config.logarithmic2, 1 * data.datasets[i].data[j], othervars.ca
lculatedScale2, othervars.scaleHop2) - othervars.zeroY2; |
| 6348 } else { |
| 6349 statData[i][j].yPosBotto
m =othervars.xAxisPosY - othervars.zeroY |
| 6350 statData[i][j].barHeight
=calculateOffset(config.logarithmic, 1 * data.datasets[i].data[j], othervars.cal
culatedScale, othervars.scaleHop) - othervars.zeroY; |
| 6351 } |
| 6352 statData[i][j].yPosTop = statDat
a[i][j].yPosBottom - statData[i][j].barHeight + (config.barStrokeWidth / 2); |
| 6353 statData[i][j].v7=statData[i][j]
.xPosLeft; |
| 6354 statData[i][j].v8=statData[i][j]
.yPosBottom; |
| 6355 statData[i][j].v9=statData[i][j]
.xPosRight; |
| 6356 statData[i][j].v10=statData[i][j
].yPosTop; |
| 6357 |
| 6358 } |
| 6359 realbars++; |
| 6360 break; |
| 6361 case "StackedBar" : |
| 6362 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
| 6363 if (typeof tempp[j]=="undefined"
) { |
| 6364 tempp[j]=0; |
| 6365 tempn[j]=0; |
| 6366 zeroY= calculateOffset(
config.logarithmic, 0 , othervars.calculatedScale, othervars.scaleHop); |
| 6367 } |
| 6368 if ((typeof data.datasets[i].dat
a[j] == 'undefined')) continue; |
| 6369 statData[i][j].xPosLeft= otherva
rs.yAxisPosX + config.barValueSpacing + othervars.valueHop * j; |
| 6370 if (1*data.datasets[i].data[j]<0
) { |
| 6371 statData[i][j].botval=te
mpn[j]; |
| 6372 statData[i][j].topval=te
mpn[j]+1*data.datasets[i].data[j] ; |
| 6373 tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; |
| 6374 } else { |
| 6375 statData[i][j].botval=te
mpp[j]; |
| 6376 statData[i][j].topval=te
mpp[j]+1*data.datasets[i].data[j] ; |
| 6377 tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; |
| 6378 } |
| 6379 statData[i][j].xPosRight = statD
ata[i][j].xPosLeft + othervars.barWidth; |
| 6380 statData[i][j].botOffset = calcu
lateOffset(config.logarithmic, statData[i][j].botval , othervars.calculatedScale
, othervars.scaleHop); |
| 6381 statData[i][j].topOffset = calcu
lateOffset(config.logarithmic, statData[i][j].topval , othervars.calculatedScale
, othervars.scaleHop); |
| 6382 statData[i][j].yPosBottom =other
vars.xAxisPosY - statData[i][j].botOffset; |
| 6383 statData[i][j].yPosTop = otherva
rs.xAxisPosY - statData[i][j].topOffset; |
| 6384 // treat spaceBetweenBar |
| 6385 if(config.spaceBetweenBar > 0) |
| 6386 { |
| 6387 if(1*data.datasets[i].da
ta[j]<0) { |
| 6388 statData[i][j].y
PosBottom+=config.spaceBetweenBar; |
| 6389 if(tempn[j]==1*d
ata.datasets[i].data[j])statData[i][j].yPosBottom-=(config.spaceBetweenBar/2); |
| 6390 if(statData[i][j
].yPosTop<statData[i][j].yPosBottom)statData[i][j].yPosBottom=statData[i][j].yPo
sTop; |
| 6391 } else if (1*data.datase
ts[i].data[j]>0) { |
| 6392 statData[i][j].y
PosBottom-=config.spaceBetweenBar; |
| 6393 if(tempp[j]==1*d
ata.datasets[i].data[j])statData[i][j].yPosBottom+=(config.spaceBetweenBar/2); |
| 6394 if(statData[i][j
].yPosTop>statData[i][j].yPosBottom)statData[i][j].yPosBottom=statData[i][j].yPo
sTop; |
| 6395 } |
| 6396 } |
| 6397 statData[i][j].v7=statData[i][j]
.xPosLeft; |
| 6398 statData[i][j].v8=statData[i][j]
.yPosBottom; |
| 6399 statData[i][j].v9=statData[i][j]
.xPosRight; |
| 6400 statData[i][j].v10=statData[i][j
].yPosTop; |
| 6401 } |
| 6402 break; |
| 6403 case "HorizontalBar" : |
| 6404 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
| 6405 statData[i][j].xPosLeft= otherva
rs.yAxisPosX + othervars.zeroY; |
| 6406 statData[i][j].yPosTop=othervars
.xAxisPosY + config.barValueSpacing - othervars.scaleHop * (j + 1) + othervars.b
arWidth * i + config.barDatasetSpacing * i + config.barStrokeWidth * i; |
| 6407 statData[i][j].yPosBottom=statDa
ta[i][j].yPosTop+othervars.barWidth; |
| 6408 statData[i][j].barWidth = calcul
ateOffset(config.logarithmic, 1 * data.datasets[i].data[j], othervars.calculated
Scale, othervars.valueHop) - othervars.zeroY; |
| 6409 statData[i][j].xPosRight = statD
ata[i][j].xPosLeft + statData[i][j].barWidth; |
| 6410 |
| 6411 statData[i][j].v7=statData[i][j]
.xPosLeft; |
| 6412 statData[i][j].v8=statData[i][j]
.yPosBottom; |
| 6413 statData[i][j].v9=statData[i][j]
.xPosRight; |
| 6414 statData[i][j].v10=statData[i][j
].yPosTop; |
| 6415 } |
| 6416 break; |
| 6417 case "HorizontalStackedBar" : |
| 6418 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
| 6419 if (i == 0) { |
| 6420 tempp[j]=0; |
| 6421 tempn[j]=0; |
| 6422 } |
| 6423 if ((typeof(data.datasets[i].dat
a[j]) == 'undefined') || 1*data.datasets[i].data[j] == 0 ) continue; |
| 6424 |
| 6425 statData[i][j].xPosLeft= otherva
rs.yAxisPosX + config.barValueSpacing + othervars.valueHop * j; |
| 6426 if (1*data.datasets[i].data[j]<0
) { |
| 6427 statData[i][j].leftval=t
empn[j]; |
| 6428 statData[i][j].rightval=
tempn[j]+1*data.datasets[i].data[j] ; |
| 6429 tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; |
| 6430 } else { |
| 6431 statData[i][j].leftval=t
empp[j]; |
| 6432 statData[i][j].rightval=
tempp[j]+1*data.datasets[i].data[j] ; |
| 6433 tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; |
| 6434 } |
| 6435 statData[i][j].rightOffset = Hor
izontalCalculateOffset(statData[i][j].rightval , othervars.calculatedScale, othe
rvars.valueHop); |
| 6436 statData[i][j].leftOffset = Hor
izontalCalculateOffset(statData[i][j].leftval , othervars.calculatedScale, other
vars.valueHop); |
| 6437 statData[i][j].xPosRight = other
vars.yAxisPosX + statData[i][j].rightOffset; |
| 6438 statData[i][j].xPosLeft = other
vars.yAxisPosX + statData[i][j].leftOffset; |
| 6439 statData[i][j].yPosTop =othervar
s.xAxisPosY + config.barValueSpacing - othervars.scaleHop * (j + 1); |
| 6440 statData[i][j].yPosBottom = stat
Data[i][j].yPosTop+othervars.barWidth; |
| 6441 // treat spaceBetweenBar |
| 6442 if(config.spaceBetweenBar > 0) |
| 6443 { |
| 6444 if(1*data.datasets[i].da
ta[j]<0) { |
| 6445 statData[i][j].x
PosLeft-=config.spaceBetweenBar; |
| 6446 if(tempn[j]==1*d
ata.datasets[i].data[j])statData[i][j].xPosLeft+=(config.spaceBetweenBar/2); |
| 6447 if(statData[i][j
].xPosLeft<statData[i][j].xPosRight)statData[i][j].xPosLeft=statData[i][j].xPosR
ight; |
| 6448 } else if (1*data.datase
ts[i].data[j]>0) { |
| 6449 statData[i][j].x
PosLeft+=config.spaceBetweenBar; |
| 6450 if(tempp[j]==1*d
ata.datasets[i].data[j])statData[i][j].xPosLeft-=(config.spaceBetweenBar/2); |
| 6451 if(statData[i][j
].xPosLeft>statData[i][j].xPosRight)statData[i][j].xPosLeft=statData[i][j].xPosR
ight; |
| 6452 } |
| 6453 } |
| 6454 |
| 6455 statData[i][j].v7=statData[i][j]
.xPosLeft; |
| 6456 statData[i][j].v8=statData[i][j]
.yPosBottom; |
| 6457 statData[i][j].v9=statData[i][j]
.xPosRight; |
| 6458 statData[i][j].v10=statData[i][j
].yPosTop; |
| 6459 } |
| 6460 break; |
| 6461 default : |
| 6462 break; |
| 6463 } |
| 6464 } |
| 6465 |
| 6466 } ; |
| 6467 |
| 6468 |
| 6469 |
| 6470 function xPos(ival, iteration, data,yAxisPosX,valueHop,nbValueHop) { |
| 6471 if (typeof data.datasets[ival].xPos == "object") { |
| 6472 if (!(typeof data.datasets[ival].xPos[Math.floor(iterati
on + config.zeroValue)] == "undefined")) { |
| 6473 var width = valueHop * nbValueHop; |
| 6474 var deb = (typeof data.xBegin != "undefined") ?
data.xBegin : 1 * data.labels[0]; |
| 6475 var fin = (typeof data.xEnd != "undefined") ? da
ta.xEnd : 1 * data.labels[data.labels.length - 1]; |
| 6476 if (fin <= deb) fin = deb + 100; |
| 6477 if (1 * data.datasets[ival].xPos[Math.floor(iter
ation + config.zeroValue)] >= deb && data.datasets[ival].xPos[Math.floor(iterati
on + config.zeroValue)] <= fin) { |
| 6478 var p1 = yAxisPosX + width * ((1 * data.
datasets[ival].xPos[Math.floor(iteration + config.zeroValue)] - deb) / (fin - de
b)); |
| 6479 var p2 = p1; |
| 6480 if (Math.abs(iteration - Math.floor(iter
ation + config.zeroValue)) > config.zeroValue) { |
| 6481 var tt = iteration + Math.floor(
iteration + config.zeroValue); |
| 6482 var p2 = xPos(ival, Math.ceil(it
eration - config.zeroValue), data); |
| 6483 } |
| 6484 return p1 + (iteration - Math.floor(iter
ation + config.zeroValue)) * (p2 - p1); |
| 6485 } |
| 6486 } |
| 6487 } |
| 6488 return yAxisPosX + (valueHop * iteration); |
| 6489 }; |
| 6490 |
| 6491 |
| 6492 function calculateOrderOfMagnitude(val) { |
| 6493 return Math.floor(Math.log(val) / Math.LN10); |
| 6494 }; |
| 6495 |
| 6496 function calculateOffset(logarithmic, val, calculatedScale, scaleHop) { |
| 6497 if (!logarithmic) { // no logarithmic scale |
| 6498 var outerValue = calculatedScale.steps * calculatedScale
.stepValue; |
| 6499 var adjustedValue = val - calculatedScale.graphMin; |
| 6500 var scalingFactor = CapValue(adjustedValue / outerValue,
1, 0); |
| 6501 return (scaleHop * calculatedScale.steps) * scalingFacto
r; |
| 6502 } else { // logarithmic scale |
| 6503 return CapValue(log10(val) * scaleHop - calculateOrderOf
Magnitude(calculatedScale.graphMin) * scaleHop, undefined, 0); |
| 6504 } |
| 6505 }; |
| 6506 |
| 6507 function HorizontalCalculateOffset(val, calculatedScale, scaleHop) { |
| 6508 var outerValue = calculatedScale.steps * calculatedScale.stepVal
ue; |
| 6509 var adjustedValue = val - calculatedScale.graphMin; |
| 6510 var scalingFactor = CapValue(adjustedValue / outerValue, 1, 0); |
| 6511 return (scaleHop * calculatedScale.steps) * scalingFactor; |
| 6512 }; |
| 6513 |
| 6514 //Apply cap a value at a high or low number |
| 6515 function CapValue(valueToCap, maxValue, minValue) { |
| 6516 if (isNumber(maxValue)) { |
| 6517 if (valueToCap > maxValue) { |
| 6518 return maxValue; |
| 6519 } |
| 6520 } |
| 6521 if (isNumber(minValue)) { |
| 6522 if (valueToCap < minValue) { |
| 6523 return minValue; |
| 6524 } |
| 6525 } |
| 6526 return valueToCap; |
| 6527 }; |
| 6528 function log10(val) { |
| 6529 return Math.log(val) / Math.LN10; |
| 6530 }; |
| 6531 }; |
| 6532 |
| 6533 function isBooleanOptionTrue(optionVar,defaultvalue) { |
| 6534 if(typeof optionvar == "undefined") { |
| 6535 if(typeof defaultvalue=="function") return true; |
| 6536 else if(typeof defaultvalue == "object") { |
| 6537 for(var j=0;j<defaultvalue.length;j++) if (defaultvalue[
j])return true; |
| 6538 return false; |
| 6539 } |
| 6540 else return defaultvalue; |
| 6541 } |
| 6542 if(typeof optionvar=="function") return true; |
| 6543 else if(typeof optionvar == "object") { |
| 6544 for(var j=0;j<optionvar.length;j++) if (optionvar[j])ret
urn true; |
| 6545 return false; |
| 6546 } else return optionvar; |
| 6547 }; |
| 6548 |
| 6549 function setOptionValue(reference,ctx,data,statData,optionvar,defaultvalue,posi,
posj,othervars) { |
| 6550 |
| 6551 if(typeof optionvar == "undefined") { |
| 6552 if(typeof defaultvalue=="function") return defaultvalue(referenc
e,ctx,data,statData,posi,posj,othervars); |
| 6553 else if(typeof defaultvalue == "object") return defaultvalue[Mat
h.min(defaultvalue.length-1,Math.max(0,posi))]; |
| 6554 else return defaultvalue; |
| 6555 } |
| 6556 if(typeof optionvar=="function") return optionvar(reference,ctx,data,sta
tData,posi,posj,othervars); |
| 6557 else if(typeof optionvar == "object") return optionvar[Math.min(optionva
r.length-1,Math.max(0,posi))]; |
| 6558 else return optionvar; |
| 6559 }; |
| 6560 |
| 6561 function tpdraw(ctx,dataval) { |
| 6562 switch(ctx.tpchart) { |
| 6563 case "Bar" : |
| 6564 if (dataval.type=="Line") { tp="Line";} |
| 6565 else {tp=ctx.tpchart;} |
| 6566 break; |
| 6567 default : |
| 6568 tp=ctx.tpchart; |
| 6569 break; |
| 6570 } |
| 6571 return tp; |
| 6572 }; |
| 6573 |
| 6574 |
OLD | NEW |