Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chart.xml 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <window id="pytdprodcomp">
  2. <reporttitle>Production:->Previous Year Production Comparison</reporttitle>
  3. <layout type="vertical">
  4. <layout type="horizontal">
  5. <label>Batch Type:</label>
  6. <sqldrop id="batchtype" />
  7. <label>Approval:</label>
  8. <sqldrop id="approval" />
  9. <daterange id="dates" initial="19" /><!-- Current Year to Date -->
  10. <label>Days to Average:</label>
  11. <line validator="integer" id="days">7</line>
  12. <label>Weight Unit:</label>
  13. <sqldrop id="unit" />
  14. <stretch />
  15. </layout>
  16. <webview id="report" />
  17. </layout>
  18. <menu name="File">
  19. <item id="print" shortcut="Ctrl+P">Print...</item>
  20. </menu>
  21. <program>
  22. <![CDATA[
  23. this.windowTitle = TTR("pytdprodcomp", "Typica - Previous Year Production Comparison");
  24. var dateSelect = findChildObject(this, 'dates');
  25. dateSelect.removeIndex(23); // Remove Lifetime range
  26. var view = findChildObject(this, 'report');
  27. var printMenu = findChildObject(this, 'print');
  28. printMenu.triggered.connect(function() {
  29. view.print();
  30. });
  31. var avgField = findChildObject(this, 'days');
  32. var unitBox = findChildObject(this, 'unit');
  33. unitBox.addItem(TTR("pytdprodcomp", "Kg"));
  34. unitBox.addItem(TTR("pytdprodcomp", "Lb"));
  35. unitBox.currentIndex = QSettings.value("script/report_unit", 1);
  36. unitBox['currentIndexChanged(int)'].connect(function() {
  37. QSettings.setValue("script/report_unit", unitBox.currentIndex);
  38. refresh();
  39. });
  40. var batchType = findChildObject(this, 'batchtype');
  41. batchType.addItem(TTR("pytdprodcomp", "Any"));
  42. batchType.addItem(TTR("pytdprodcomp", "Production Roasts"));
  43. batchType.addItem(TTR("pytdprodcomp", "Sample Roasts"));
  44. batchType.currentIndex = QSettings.value("script/batchtypefilter", 1);
  45. batchType['currentIndexChanged(int)'].connect(function() {
  46. QSettings.setValue("script/batchtypefilter", batchType.currentIndex);
  47. refresh();
  48. });
  49. var approval = findChildObject(this, 'approval');
  50. approval.addItem(TTR("pytdprodcomp", "Any"));
  51. approval.addItem(TTR("pytdprodcomp", "Approved"));
  52. approval.addItem(TTR("pytdprodcomp", "Not Approved"));
  53. approval.currentIndex = QSettings.value("script/approvalfilter", 1);
  54. approval['currentIndexChanged(int)'].connect(function() {
  55. QSettings.setValue("script/approvalfilter", approval.currentIndex);
  56. refresh();
  57. });
  58. function refresh() {
  59. var conversion = 1;
  60. if(unitBox.currentIndex == 0) {
  61. conversion = 2.2;
  62. }
  63. var buffer = new QBuffer;
  64. buffer.open(3);
  65. var output = new XmlWriter(buffer);
  66. output.writeStartDocument("1.0");
  67. output.writeDTD('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg.dtd">');
  68. output.writeStartElement("html");
  69. output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  70. output.writeStartElement("head");
  71. output.writeTextElement("title", TTR("pytdprodcomp", "Previous Year Production Comparison"));
  72. output.writeEndElement();
  73. output.writeStartElement("body");
  74. var cdt = new Date(Date.now());
  75. output.writeTextElement("p", cdt.toLocaleDateString(TTR("reports", "en-US")) + " " + cdt.toLocaleTimeString(TTR("reports", "en-US")));
  76. output.writeTextElement("h1", TTR("pytdprodcomp", "Previous Year Production Comparison"));
  77. output.writeTextElement("p", TTR("pytdprodcomp", "This report provides an itemized and overall comparison of roasted coffee production for the dates specified with those dates in the previous year. A chart of this data along with percent change and rolling average of the percent change is also produced."));
  78. output.writeStartElement("table");
  79. output.writeAttribute("style", "page-break-after:auto;");
  80. output.writeAttribute("rules", "groups");
  81. output.writeAttribute("cellpadding", "3px");
  82. output.writeStartElement("thead");
  83. output.writeStartElement("tr");
  84. output.writeTextElement("th", "Coffee");
  85. switch(unitBox.currentIndex) {
  86. case 0:
  87. output.writeTextElement("th", TTR("pytdprodcomp", "Previous (Kg)"));
  88. output.writeTextElement("th", TTR("pytdprodcomp", "Current (Kg)"));
  89. output.writeTextElement("th", TTR("pytdprodcomp", "Change (Kg)"));
  90. break;
  91. case 1:
  92. output.writeTextElement("th", TTR("pytdprodcomp", "Previous (Lb)"));
  93. output.writeTextElement("th", TTR("pytdprodcomp", "Current (Lb)"));
  94. output.writeTextElement("th", TTR("pytdprodcomp", "Change (Lb)"));
  95. break;
  96. }
  97. output.writeEndElement();
  98. output.writeEndElement();
  99. output.writeStartElement("tbody");
  100. var query = new QSqlQuery();
  101. query.exec("START TRANSACTION");
  102. var dateRange = dateSelect.currentRange();
  103. var curStartDate = "'"+dateRange[0]+"'";
  104. var curEndDate = "'"+dateRange[dateRange.length - 1]+"'";
  105. query.exec("SELECT "+curStartDate+"::date - interval '1 year', "+curEndDate+"::date - interval '1 year' + interval '1 day', "+curEndDate+"::date + interval '1 day'");
  106. query.next();
  107. curEndDate = "'"+query.value(2)+"'";
  108. var prevStartDate = "'"+query.value(0)+"'";
  109. var prevEndDate = "'"+query.value(1)+"'";
  110. var transaction_filter;
  111. var approval_filter;
  112. switch(batchType.currentIndex) {
  113. case 0:
  114. transaction_filter = "";
  115. break;
  116. case 1:
  117. transaction_filter = " AND transaction_type = 'ROAST'";
  118. break;
  119. case 2:
  120. transaction_filter = " AND transaction_type = 'SAMPLEROAST'";
  121. break;
  122. }
  123. switch(approval.currentIndex) {
  124. case 0:
  125. approval_filter = "";
  126. break;
  127. case 1:
  128. approval_filter = " AND approval = true";
  129. break;
  130. case 2:
  131. approval_filter = " AND approval = false";
  132. break;
  133. }
  134. var q = "CREATE TEMPORARY TABLE previous ON COMMIT DROP AS SELECT roasted_id, sum(roasted_quantity) AS p FROM roasting_log WHERE time > "+prevStartDate+" AND time < "+prevEndDate+" AND roasted_id IS NOT NULL" + transaction_filter + approval_filter + " GROUP BY roasted_id";
  135. query.exec(q);
  136. q = "CREATE TEMPORARY TABLE current ON COMMIT DROP AS SELECT roasted_id, sum(roasted_quantity) AS c FROM roasting_log WHERE time > "+curStartDate+" AND time < "+curEndDate+" AND roasted_id IS NOT NULL" + transaction_filter + approval_filter + " GROUP BY roasted_id";
  137. query.exec(q);
  138. query.exec("INSERT INTO previous SELECT roasted_id, 0 FROM current WHERE roasted_id NOT IN (SELECT roasted_id FROM previous)");
  139. query.exec("INSERT INTO current SELECT roasted_id, 0 FROM previous WHERE roasted_id NOT IN (SELECT roasted_id FROM current)");
  140. query.exec("CREATE TEMPORARY TABLE comp ON COMMIT DROP AS SELECT previous.roasted_id, p, c FROM previous LEFT OUTER JOIN current ON previous.roasted_id = current.roasted_id");
  141. query.exec("SELECT (SELECT name FROM items WHERE id = roasted_id) AS name, p, c, (c-p) FROM comp WHERE p > 0 OR c > 0 ORDER BY name");
  142. while(query.next())
  143. {
  144. output.writeStartElement("tr");
  145. output.writeTextElement("td", query.value(0));
  146. output.writeTextElement("td", (query.value(1) / conversion).toFixed(2));
  147. output.writeTextElement("td", (query.value(2) / conversion).toFixed(2));
  148. output.writeTextElement("td", (query.value(3) / conversion).toFixed(2));
  149. output.writeEndElement();
  150. }
  151. output.writeEndElement();
  152. output.writeStartElement("tfoot");
  153. output.writeTextElement("th", TTR("pytdprodcomp", "Totals"));
  154. query.exec("SELECT sum(p), sum(c), sum(c-p) FROM comp");
  155. query.next();
  156. output.writeTextElement("td", (query.value(0) / conversion).toFixed(2));
  157. output.writeTextElement("td", (query.value(1) / conversion).toFixed(2));
  158. output.writeTextElement("td", (query.value(2) / conversion).toFixed(2));
  159. output.writeEndElement();
  160. query.exec("ABORT");
  161. output.writeEndElement();
  162. output.writeStartElement("p");
  163. output.writeAttribute("style", "page-break-inside: avoid");
  164. output.writeStartElement("svg");
  165. output.writeAttribute("xmlns", "http://www.w3.org/2000/svg");
  166. output.writeAttribute("width", "7.5in");
  167. output.writeAttribute("height", "6.3in");
  168. output.writeStartElement("g");
  169. output.writeAttribute("transform", "translate(0,470)");
  170. output.writeStartElement("g");
  171. output.writeAttribute("transform", "scale(1,-1)");
  172. output.writeStartElement("line");
  173. output.writeAttribute("x1", "40");
  174. output.writeAttribute("x2", "40");
  175. output.writeAttribute("y1", "0");
  176. output.writeAttribute("y2", "450");
  177. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  178. output.writeEndElement();
  179. output.writeStartElement("line");
  180. output.writeAttribute("x1", "50");
  181. output.writeAttribute("x2", "650");
  182. output.writeAttribute("y1", "-10");
  183. output.writeAttribute("y2", "-10");
  184. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  185. output.writeEndElement();
  186. output.writeStartElement("line");
  187. output.writeAttribute("x1", "660");
  188. output.writeAttribute("x2", "660");
  189. output.writeAttribute("y1", "0");
  190. output.writeAttribute("y2", "450");
  191. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  192. output.writeEndElement();
  193. var q = "SELECT "+curEndDate+"::date - "+curStartDate+"::date";
  194. query.exec(q);
  195. query.next();
  196. var days = query.value(0);
  197. var dates = new Array();
  198. var curpounds = new Array();
  199. var prevpounds = new Array();
  200. var change = new Array();
  201. var avgchange = new Array();
  202. var i;
  203. for(i = 0; i < days; i++)
  204. {
  205. q = "SELECT "+curStartDate+"::date + "+(i+1);
  206. query.exec(q);
  207. query.next();
  208. dates[i] = query.value(0);
  209. q = "SELECT sum(roasted_quantity) FROM roasting_log WHERE time > "+curStartDate+" AND time < '"+dates[i]+"'" + transaction_filter + approval_filter;
  210. query.exec(q);
  211. if(query.next())
  212. {
  213. curpounds[i] = Number(query.value(0));
  214. }
  215. else
  216. {
  217. curpounds[i] = 0;
  218. }
  219. q = "SELECT sum(roasted_quantity) FROM roasting_log WHERE time > "+curStartDate+"::date - '1 year'::interval AND time < '"+dates[i]+"'::date - '1 year'::interval" + transaction_filter + approval_filter;
  220. query.exec(q);
  221. if(query.next())
  222. {
  223. prevpounds[i] = Number(query.value(0));
  224. }
  225. else
  226. {
  227. prevpounds[i] = 0;
  228. }
  229. if(curpounds[i] > 0)
  230. {
  231. change[i] = (curpounds[i] - prevpounds[i])/curpounds[i];
  232. }
  233. else
  234. {
  235. if(prevpounds[i] > 0)
  236. {
  237. change[i] = -1;
  238. }
  239. else
  240. {
  241. change[i] = 0;
  242. }
  243. }
  244. if(i > (parseInt(avgField.text)-2))
  245. {
  246. var sum = 0;
  247. var j;
  248. for(j = 0; j < parseInt(avgField.text); j++)
  249. {
  250. sum += change[i-j];
  251. }
  252. avgchange[i] = sum / parseInt(avgField.text);
  253. }
  254. }
  255. // Calculate the domain of the primary y axis.
  256. var maxy1 = 0;
  257. var increment = 100; // Starting increment is 100 Lb.
  258. if(unitBox.currentIndex == 0) {
  259. increment = 110; // Starting increment is 50 Kg if Kg is requested.
  260. }
  261. while(maxy1 < Math.max(curpounds[days - 1], prevpounds[days - 1]))
  262. {
  263. maxy1 += increment;
  264. }
  265. // Calculate the number of grid lines and loosen spacing if there are too many.
  266. var divisions = maxy1 / increment;
  267. while(divisions > 10) {
  268. increment *= 2;
  269. divisions = maxy1 / increment;
  270. }
  271. // Draw y axis grid lines.
  272. var pos = 0;
  273. while(pos <= maxy1)
  274. {
  275. output.writeStartElement("line");
  276. output.writeAttribute("x1", "35");
  277. output.writeAttribute("x2", "45");
  278. output.writeAttribute("y1", (450/maxy1)*pos);
  279. output.writeAttribute("y2", (450/maxy1)*pos);
  280. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  281. output.writeEndElement();
  282. pos += increment;
  283. }
  284. var n = Math.min.apply(Math, change);
  285. var m = Math.max.apply(Math, change);
  286. var miny2 = 0;
  287. var maxy2;
  288. if(n < 0)
  289. {
  290. while(miny2 > n)
  291. {
  292. miny2 -= 0.1;
  293. }
  294. maxy2 = miny2;
  295. }
  296. else
  297. {
  298. while(miny2 < n)
  299. {
  300. miny2 += 0.1;
  301. }
  302. miny2 -= 0.1;
  303. maxy2 = miny2;
  304. }
  305. while(maxy2 < m)
  306. {
  307. maxy2 += 0.1;
  308. }
  309. var range = maxy2 - miny2;
  310. pos = miny2;
  311. while(pos <= maxy2)
  312. {
  313. output.writeStartElement("line");
  314. output.writeAttribute("x1", "655");
  315. output.writeAttribute("x2", "665");
  316. output.writeAttribute("y1", (pos-miny2)*(4.5/(range*100))*10000);
  317. output.writeAttribute("y2", (pos-miny2)*(4.5/(range*100))*10000);
  318. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  319. output.writeEndElement();
  320. pos += 0.1;
  321. }
  322. pos = 0;
  323. while(pos < days)
  324. {
  325. output.writeStartElement("line");
  326. output.writeAttribute("x1", 50+((600/(days-1))*pos));
  327. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  328. output.writeAttribute("y1", "-5");
  329. output.writeAttribute("y2", "-15");
  330. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  331. output.writeEndElement();
  332. pos += 7;
  333. }
  334. output.writeStartElement("line");
  335. output.writeAttribute("x1", 50+((600/(days-1))*(days-1)));
  336. output.writeAttribute("x2", 50+((600/(days-1))*(days-1)));
  337. output.writeAttribute("y1", "-5");
  338. output.writeAttribute("y2", "-15");
  339. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  340. output.writeEndElement();
  341. pos = 1;
  342. while(pos < days)
  343. {
  344. output.writeStartElement("line");
  345. output.writeAttribute("x1", 50+((600/(days-1))*(pos - 1)));
  346. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  347. output.writeAttribute("y1", (prevpounds[pos-1]/maxy1)*450);
  348. output.writeAttribute("y2", (prevpounds[pos]/maxy1)*450);
  349. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  350. output.writeEndElement();
  351. output.writeStartElement("line");
  352. output.writeAttribute("x1", 50+((600/(days-1))*(pos - 1)));
  353. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  354. output.writeAttribute("y1", (curpounds[pos-1]/maxy1)*450);
  355. output.writeAttribute("y2", (curpounds[pos]/maxy1)*450);
  356. output.writeAttribute("style", "stroke:rgb(255,0,0);stroke-width:1;");
  357. output.writeEndElement();
  358. output.writeStartElement("line");
  359. output.writeAttribute("x1", 50+((600/(days-1))*(pos-1)));
  360. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  361. output.writeAttribute("y1", (change[pos-1]-miny2)*(4.5/(range*100))*10000);
  362. output.writeAttribute("y2", (change[pos]-miny2)*(4.5/(range*100))*10000);
  363. output.writeAttribute("style", "stroke:rgb(0,255,0);stroke-width:1;");
  364. output.writeEndElement();
  365. if(pos > (parseInt(avgField.text)-1))
  366. {
  367. output.writeStartElement("line");
  368. output.writeAttribute("x1", 50+((600/(days-1))*(pos-1)));
  369. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  370. output.writeAttribute("y1", (avgchange[pos-1]-miny2)*(4.5/(range*100))*10000);
  371. output.writeAttribute("y2", (avgchange[pos]-miny2)*(4.5/(range*100))*10000);
  372. output.writeAttribute("style", "stroke:rgb(0,0,255);stroke-width:1;");
  373. output.writeEndElement();
  374. }
  375. pos++;
  376. }
  377. output.writeEndElement();
  378. i = 0;
  379. while(i <= maxy1)
  380. {
  381. output.writeStartElement("text");
  382. output.writeAttribute("x", "0");
  383. output.writeAttribute("y", -((450/maxy1)*i)+5);
  384. output.writeAttribute("font-size", "12");
  385. switch(unitBox.currentIndex) {
  386. case 0:
  387. output.writeCharacters((i / 2.2).toFixed(0));
  388. break;
  389. case 1:
  390. default:
  391. output.writeCharacters(i);
  392. break;
  393. }
  394. output.writeEndElement();
  395. i += increment;
  396. }
  397. i = miny2;
  398. var stepSize = 0.1;
  399. while((maxy2 - miny2) / stepSize > 20)
  400. {
  401. stepSize += 0.05;
  402. }
  403. while(i <= maxy2)
  404. {
  405. output.writeStartElement("text");
  406. output.writeAttribute("x", "670");
  407. output.writeAttribute("y", -((i-miny2)*(4.5/(range*100))*10000)+5);
  408. output.writeAttribute("font-size", "12");
  409. output.writeCharacters(Number(i*100).toFixed(0)+"%");
  410. output.writeEndElement();
  411. i += stepSize;
  412. }
  413. i = 0;
  414. while(i <= days-1)
  415. {
  416. output.writeStartElement("text");
  417. output.writeAttribute("x", 45+((600/(days-1))*i));
  418. output.writeAttribute("y", "20");
  419. output.writeAttribute("font-size", "12");
  420. output.writeAttribute("transform", "rotate(90 "+(45+((600/(days-1))*i))+",20)");
  421. q = "SELECT ('"+dates[i]+"'::date - '1 day'::interval)::date";
  422. query.exec(q);
  423. query.next();
  424. var ds = query.value(0);
  425. var parts = ds.split("-");
  426. switch(parts[1])
  427. {
  428. case '01':
  429. ds = TTR("pytdprodcomp", "January ");
  430. break;
  431. case '02':
  432. ds = TTR("pytdprodcomp", "February ");
  433. break;
  434. case '03':
  435. ds = TTR("pytdprodcomp", "March ");
  436. break;
  437. case '04':
  438. ds = TTR("pytdprodcomp", "April ");
  439. break;
  440. case '05':
  441. ds = TTR("pytdprodcomp", "May ");
  442. break;
  443. case '06':
  444. ds = TTR("pytdprodcomp", "June ");
  445. break;
  446. case '07':
  447. ds = TTR("pytdprodcomp", "July ");
  448. break;
  449. case '08':
  450. ds = TTR("pytdprodcomp", "August ");
  451. break;
  452. case '09':
  453. ds = TTR("pytdprodcomp", "September ");
  454. break;
  455. case '10':
  456. ds = TTR("pytdprodcomp", "October ");
  457. break;
  458. case '11':
  459. ds = TTR("pytdprodcomp", "November ");
  460. break;
  461. case '12':
  462. ds = TTR("pytdprodcomp", "December ");
  463. break;
  464. }
  465. ds = ds + Number(parts[2]);
  466. output.writeCharacters(ds);
  467. output.writeEndElement();
  468. if(i == days-1)
  469. {
  470. break;
  471. }
  472. i += 7;
  473. if(i > days-1)
  474. {
  475. i = days - 1;
  476. }
  477. }
  478. query = query.invalidate();
  479. output.writeStartElement("rect");
  480. output.writeAttribute("fill", "rgb(0,0,0)");
  481. output.writeAttribute("x", "45");
  482. output.writeAttribute("y", "110");
  483. output.writeAttribute("width", "24");
  484. output.writeAttribute("height", "12");
  485. output.writeEndElement();
  486. output.writeStartElement("text");
  487. output.writeAttribute("x", "75");
  488. output.writeAttribute("y", "120");
  489. output.writeAttribute("font-size", "12");
  490. switch(unitBox.currentIndex) {
  491. case 0:
  492. output.writeCharacters(TTR("pytdprodcomp", "Previous Year Kg"));
  493. break;
  494. case 1:
  495. output.writeCharacters(TTR("pytdprodcomp", "Previous Year Lb"));
  496. break;
  497. }
  498. output.writeEndElement();
  499. output.writeStartElement("rect");
  500. output.writeAttribute("fill", "rgb(255,0,0)");
  501. output.writeAttribute("x", "195");
  502. output.writeAttribute("y", "110");
  503. output.writeAttribute("width", "24");
  504. output.writeAttribute("height", "12");
  505. output.writeEndElement();
  506. output.writeStartElement("text");
  507. output.writeAttribute("x", "225");
  508. output.writeAttribute("y", "120");
  509. output.writeAttribute("font-size", "12");
  510. switch(unitBox.currentIndex) {
  511. case 0:
  512. output.writeCharacters(TTR("pytdprodcomp", "Current Year Kg"));
  513. break;
  514. case 1:
  515. output.writeCharacters(TTR("pytdprodcomp", "Current Year Lb"));
  516. break;
  517. }
  518. output.writeEndElement();
  519. output.writeStartElement("rect");
  520. output.writeAttribute("fill", "rgb(0,255,0)");
  521. output.writeAttribute("x", "345");
  522. output.writeAttribute("y", "110");
  523. output.writeAttribute("width", "24");
  524. output.writeAttribute("height", "12");
  525. output.writeEndElement();
  526. output.writeStartElement("text");
  527. output.writeAttribute("x", "375");
  528. output.writeAttribute("y", "120");
  529. output.writeAttribute("font-size", "12");
  530. output.writeCharacters(TTR("pytdprodcomp", "% Change"));
  531. output.writeEndElement();
  532. output.writeStartElement("rect");
  533. output.writeAttribute("fill", "rgb(0,0,255)");
  534. output.writeAttribute("x", "495");
  535. output.writeAttribute("y", "110");
  536. output.writeAttribute("width", "24");
  537. output.writeAttribute("height", "12");
  538. output.writeEndElement();
  539. output.writeStartElement("text");
  540. output.writeAttribute("x", "525");
  541. output.writeAttribute("y", "120");
  542. output.writeAttribute("font-size", "12");
  543. output.writeCharacters(TTR("pytdprodcomp", "Average % Change"));
  544. output.writeEndElement();
  545. output.writeEndElement();
  546. output.writeEndElement();
  547. output.writeEndElement();
  548. output.writeEndElement();
  549. output.writeEndElement();
  550. output.writeEndDocument();
  551. view.setContent(buffer);
  552. buffer.close();
  553. }
  554. refresh();
  555. dateSelect.rangeUpdated.connect(function() {
  556. refresh();
  557. });
  558. avgField.editingFinished.connect(function() {
  559. refresh();
  560. });
  561. var notifier = Application.subscribe("roastinglogchange");
  562. notifier.notify.connect(function() {
  563. refresh();
  564. });
  565. ]]>
  566. </program>
  567. </window>