Typica is a free program for professional coffee roasters. https://typica.us
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

chart.xml 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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. output.writeTextElement("h1", TTR("pytdprodcomp", "Previous Year Production Comparison"));
  75. 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."));
  76. output.writeStartElement("table");
  77. output.writeAttribute("style", "page-break-after:auto;");
  78. output.writeAttribute("rules", "groups");
  79. output.writeAttribute("cellpadding", "3px");
  80. output.writeStartElement("thead");
  81. output.writeStartElement("tr");
  82. output.writeTextElement("th", "Coffee");
  83. switch(unitBox.currentIndex) {
  84. case 0:
  85. output.writeTextElement("th", TTR("pytdprodcomp", "Previous (Kg)"));
  86. output.writeTextElement("th", TTR("pytdprodcomp", "Current (Kg)"));
  87. output.writeTextElement("th", TTR("pytdprodcomp", "Change (Kg)"));
  88. break;
  89. case 1:
  90. output.writeTextElement("th", TTR("pytdprodcomp", "Previous (Lb)"));
  91. output.writeTextElement("th", TTR("pytdprodcomp", "Current (Lb)"));
  92. output.writeTextElement("th", TTR("pytdprodcomp", "Change (Lb)"));
  93. break;
  94. }
  95. output.writeEndElement();
  96. output.writeEndElement();
  97. output.writeStartElement("tbody");
  98. var query = new QSqlQuery();
  99. query.exec("START TRANSACTION");
  100. var dateRange = dateSelect.currentRange();
  101. var curStartDate = "'"+dateRange[0]+"'";
  102. var curEndDate = "'"+dateRange[dateRange.length - 1]+"'";
  103. query.exec("SELECT "+curStartDate+"::date - interval '1 year', "+curEndDate+"::date - interval '1 year' + interval '1 day', "+curEndDate+"::date + interval '1 day'");
  104. query.next();
  105. curEndDate = "'"+query.value(2)+"'";
  106. var prevStartDate = "'"+query.value(0)+"'";
  107. var prevEndDate = "'"+query.value(1)+"'";
  108. var transaction_filter;
  109. var approval_filter;
  110. switch(batchType.currentIndex) {
  111. case 0:
  112. transaction_filter = "";
  113. break;
  114. case 1:
  115. transaction_filter = " AND transaction_type = 'ROAST'";
  116. break;
  117. case 2:
  118. transaction_filter = " AND transaction_type = 'SAMPLEROAST'";
  119. break;
  120. }
  121. switch(approval.currentIndex) {
  122. case 0:
  123. approval_filter = "";
  124. break;
  125. case 1:
  126. approval_filter = " AND approval = true";
  127. break;
  128. case 2:
  129. approval_filter = " AND approval = false";
  130. break;
  131. }
  132. 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";
  133. query.exec(q);
  134. 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";
  135. query.exec(q);
  136. query.exec("INSERT INTO previous SELECT roasted_id, 0 FROM current WHERE roasted_id NOT IN (SELECT roasted_id FROM previous)");
  137. query.exec("INSERT INTO current SELECT roasted_id, 0 FROM previous WHERE roasted_id NOT IN (SELECT roasted_id FROM current)");
  138. 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");
  139. 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");
  140. while(query.next())
  141. {
  142. output.writeStartElement("tr");
  143. output.writeTextElement("td", query.value(0));
  144. output.writeTextElement("td", (query.value(1) / conversion).toFixed(2));
  145. output.writeTextElement("td", (query.value(2) / conversion).toFixed(2));
  146. output.writeTextElement("td", (query.value(3) / conversion).toFixed(2));
  147. output.writeEndElement();
  148. }
  149. output.writeEndElement();
  150. output.writeStartElement("tfoot");
  151. output.writeTextElement("th", TTR("pytdprodcomp", "Totals"));
  152. query.exec("SELECT sum(p), sum(c), sum(c-p) FROM comp");
  153. query.next();
  154. output.writeTextElement("td", (query.value(0) / conversion).toFixed(2));
  155. output.writeTextElement("td", (query.value(1) / conversion).toFixed(2));
  156. output.writeTextElement("td", (query.value(2) / conversion).toFixed(2));
  157. output.writeEndElement();
  158. query.exec("ABORT");
  159. output.writeEndElement();
  160. output.writeStartElement("p");
  161. output.writeAttribute("style", "page-break-inside: avoid");
  162. output.writeStartElement("svg");
  163. output.writeAttribute("xmlns", "http://www.w3.org/2000/svg");
  164. output.writeAttribute("width", "7.5in");
  165. output.writeAttribute("height", "6.3in");
  166. output.writeStartElement("g");
  167. output.writeAttribute("transform", "translate(0,470)");
  168. output.writeStartElement("g");
  169. output.writeAttribute("transform", "scale(1,-1)");
  170. output.writeStartElement("line");
  171. output.writeAttribute("x1", "40");
  172. output.writeAttribute("x2", "40");
  173. output.writeAttribute("y1", "0");
  174. output.writeAttribute("y2", "450");
  175. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  176. output.writeEndElement();
  177. output.writeStartElement("line");
  178. output.writeAttribute("x1", "50");
  179. output.writeAttribute("x2", "650");
  180. output.writeAttribute("y1", "-10");
  181. output.writeAttribute("y2", "-10");
  182. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  183. output.writeEndElement();
  184. output.writeStartElement("line");
  185. output.writeAttribute("x1", "660");
  186. output.writeAttribute("x2", "660");
  187. output.writeAttribute("y1", "0");
  188. output.writeAttribute("y2", "450");
  189. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  190. output.writeEndElement();
  191. var q = "SELECT "+curEndDate+"::date - "+curStartDate+"::date";
  192. query.exec(q);
  193. query.next();
  194. var days = query.value(0);
  195. var dates = new Array();
  196. var curpounds = new Array();
  197. var prevpounds = new Array();
  198. var change = new Array();
  199. var avgchange = new Array();
  200. var i;
  201. for(i = 0; i < days; i++)
  202. {
  203. q = "SELECT "+curStartDate+"::date + "+(i+1);
  204. query.exec(q);
  205. query.next();
  206. dates[i] = query.value(0);
  207. q = "SELECT sum(roasted_quantity) FROM roasting_log WHERE time > "+curStartDate+" AND time < '"+dates[i]+"'" + transaction_filter + approval_filter;
  208. query.exec(q);
  209. if(query.next())
  210. {
  211. curpounds[i] = Number(query.value(0));
  212. }
  213. else
  214. {
  215. curpounds[i] = 0;
  216. }
  217. 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;
  218. query.exec(q);
  219. if(query.next())
  220. {
  221. prevpounds[i] = Number(query.value(0));
  222. }
  223. else
  224. {
  225. prevpounds[i] = 0;
  226. }
  227. if(curpounds[i] > 0)
  228. {
  229. change[i] = (curpounds[i] - prevpounds[i])/curpounds[i];
  230. }
  231. else
  232. {
  233. if(prevpounds[i] > 0)
  234. {
  235. change[i] = -1;
  236. }
  237. else
  238. {
  239. change[i] = 0;
  240. }
  241. }
  242. if(i > (parseInt(avgField.text)-2))
  243. {
  244. var sum = 0;
  245. var j;
  246. for(j = 0; j < parseInt(avgField.text); j++)
  247. {
  248. sum += change[i-j];
  249. }
  250. avgchange[i] = sum / parseInt(avgField.text);
  251. }
  252. }
  253. // Calculate the domain of the primary y axis.
  254. var maxy1 = 0;
  255. var increment = 100; // Starting increment is 100 Lb.
  256. if(unitBox.currentIndex == 0) {
  257. increment = 110; // Starting increment is 50 Kg if Kg is requested.
  258. }
  259. while(maxy1 < Math.max(curpounds[days - 1], prevpounds[days - 1]))
  260. {
  261. maxy1 += increment;
  262. }
  263. // Calculate the number of grid lines and loosen spacing if there are too many.
  264. var divisions = maxy1 / increment;
  265. while(divisions > 10) {
  266. increment *= 2;
  267. divisions = maxy1 / increment;
  268. }
  269. // Draw y axis grid lines.
  270. var pos = 0;
  271. while(pos <= maxy1)
  272. {
  273. output.writeStartElement("line");
  274. output.writeAttribute("x1", "35");
  275. output.writeAttribute("x2", "45");
  276. output.writeAttribute("y1", (450/maxy1)*pos);
  277. output.writeAttribute("y2", (450/maxy1)*pos);
  278. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  279. output.writeEndElement();
  280. pos += increment;
  281. }
  282. var n = Math.min.apply(Math, change);
  283. var m = Math.max.apply(Math, change);
  284. var miny2 = 0;
  285. var maxy2;
  286. if(n < 0)
  287. {
  288. while(miny2 > n)
  289. {
  290. miny2 -= 0.1;
  291. }
  292. maxy2 = miny2;
  293. }
  294. else
  295. {
  296. while(miny2 < n)
  297. {
  298. miny2 += 0.1;
  299. }
  300. miny2 -= 0.1;
  301. maxy2 = miny2;
  302. }
  303. while(maxy2 < m)
  304. {
  305. maxy2 += 0.1;
  306. }
  307. var range = maxy2 - miny2;
  308. pos = miny2;
  309. while(pos <= maxy2)
  310. {
  311. output.writeStartElement("line");
  312. output.writeAttribute("x1", "655");
  313. output.writeAttribute("x2", "665");
  314. output.writeAttribute("y1", (pos-miny2)*(4.5/(range*100))*10000);
  315. output.writeAttribute("y2", (pos-miny2)*(4.5/(range*100))*10000);
  316. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  317. output.writeEndElement();
  318. pos += 0.1;
  319. }
  320. pos = 0;
  321. while(pos < days)
  322. {
  323. output.writeStartElement("line");
  324. output.writeAttribute("x1", 50+((600/(days-1))*pos));
  325. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  326. output.writeAttribute("y1", "-5");
  327. output.writeAttribute("y2", "-15");
  328. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  329. output.writeEndElement();
  330. pos += 7;
  331. }
  332. output.writeStartElement("line");
  333. output.writeAttribute("x1", 50+((600/(days-1))*(days-1)));
  334. output.writeAttribute("x2", 50+((600/(days-1))*(days-1)));
  335. output.writeAttribute("y1", "-5");
  336. output.writeAttribute("y2", "-15");
  337. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  338. output.writeEndElement();
  339. pos = 1;
  340. while(pos < days)
  341. {
  342. output.writeStartElement("line");
  343. output.writeAttribute("x1", 50+((600/(days-1))*(pos - 1)));
  344. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  345. output.writeAttribute("y1", (prevpounds[pos-1]/maxy1)*450);
  346. output.writeAttribute("y2", (prevpounds[pos]/maxy1)*450);
  347. output.writeAttribute("style", "stroke:rgb(0,0,0);stroke-width:1;");
  348. output.writeEndElement();
  349. output.writeStartElement("line");
  350. output.writeAttribute("x1", 50+((600/(days-1))*(pos - 1)));
  351. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  352. output.writeAttribute("y1", (curpounds[pos-1]/maxy1)*450);
  353. output.writeAttribute("y2", (curpounds[pos]/maxy1)*450);
  354. output.writeAttribute("style", "stroke:rgb(255,0,0);stroke-width:1;");
  355. output.writeEndElement();
  356. output.writeStartElement("line");
  357. output.writeAttribute("x1", 50+((600/(days-1))*(pos-1)));
  358. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  359. output.writeAttribute("y1", (change[pos-1]-miny2)*(4.5/(range*100))*10000);
  360. output.writeAttribute("y2", (change[pos]-miny2)*(4.5/(range*100))*10000);
  361. output.writeAttribute("style", "stroke:rgb(0,255,0);stroke-width:1;");
  362. output.writeEndElement();
  363. if(pos > (parseInt(avgField.text)-1))
  364. {
  365. output.writeStartElement("line");
  366. output.writeAttribute("x1", 50+((600/(days-1))*(pos-1)));
  367. output.writeAttribute("x2", 50+((600/(days-1))*pos));
  368. output.writeAttribute("y1", (avgchange[pos-1]-miny2)*(4.5/(range*100))*10000);
  369. output.writeAttribute("y2", (avgchange[pos]-miny2)*(4.5/(range*100))*10000);
  370. output.writeAttribute("style", "stroke:rgb(0,0,255);stroke-width:1;");
  371. output.writeEndElement();
  372. }
  373. pos++;
  374. }
  375. output.writeEndElement();
  376. i = 0;
  377. while(i <= maxy1)
  378. {
  379. output.writeStartElement("text");
  380. output.writeAttribute("x", "0");
  381. output.writeAttribute("y", -((450/maxy1)*i)+5);
  382. output.writeAttribute("font-size", "12");
  383. switch(unitBox.currentIndex) {
  384. case 0:
  385. output.writeCharacters((i / 2.2).toFixed(0));
  386. break;
  387. case 1:
  388. default:
  389. output.writeCharacters(i);
  390. break;
  391. }
  392. output.writeEndElement();
  393. i += increment;
  394. }
  395. i = miny2;
  396. var stepSize = 0.1;
  397. while((maxy2 - miny2) / stepSize > 20)
  398. {
  399. stepSize += 0.05;
  400. }
  401. while(i <= maxy2)
  402. {
  403. output.writeStartElement("text");
  404. output.writeAttribute("x", "670");
  405. output.writeAttribute("y", -((i-miny2)*(4.5/(range*100))*10000)+5);
  406. output.writeAttribute("font-size", "12");
  407. output.writeCharacters(Number(i*100).toFixed(0)+"%");
  408. output.writeEndElement();
  409. i += stepSize;
  410. }
  411. i = 0;
  412. while(i <= days-1)
  413. {
  414. output.writeStartElement("text");
  415. output.writeAttribute("x", 45+((600/(days-1))*i));
  416. output.writeAttribute("y", "20");
  417. output.writeAttribute("font-size", "12");
  418. output.writeAttribute("transform", "rotate(90 "+(45+((600/(days-1))*i))+",20)");
  419. q = "SELECT ('"+dates[i]+"'::date - '1 day'::interval)::date";
  420. query.exec(q);
  421. query.next();
  422. var ds = query.value(0);
  423. var parts = ds.split("-");
  424. switch(parts[1])
  425. {
  426. case '01':
  427. ds = TTR("pytdprodcomp", "January ");
  428. break;
  429. case '02':
  430. ds = TTR("pytdprodcomp", "February ");
  431. break;
  432. case '03':
  433. ds = TTR("pytdprodcomp", "March ");
  434. break;
  435. case '04':
  436. ds = TTR("pytdprodcomp", "April ");
  437. break;
  438. case '05':
  439. ds = TTR("pytdprodcomp", "May ");
  440. break;
  441. case '06':
  442. ds = TTR("pytdprodcomp", "June ");
  443. break;
  444. case '07':
  445. ds = TTR("pytdprodcomp", "July ");
  446. break;
  447. case '08':
  448. ds = TTR("pytdprodcomp", "August ");
  449. break;
  450. case '09':
  451. ds = TTR("pytdprodcomp", "September ");
  452. break;
  453. case '10':
  454. ds = TTR("pytdprodcomp", "October ");
  455. break;
  456. case '11':
  457. ds = TTR("pytdprodcomp", "November ");
  458. break;
  459. case '12':
  460. ds = TTR("pytdprodcomp", "December ");
  461. break;
  462. }
  463. ds = ds + Number(parts[2]);
  464. output.writeCharacters(ds);
  465. output.writeEndElement();
  466. if(i == days-1)
  467. {
  468. break;
  469. }
  470. i += 7;
  471. if(i > days-1)
  472. {
  473. i = days - 1;
  474. }
  475. }
  476. query = query.invalidate();
  477. output.writeStartElement("rect");
  478. output.writeAttribute("fill", "rgb(0,0,0)");
  479. output.writeAttribute("x", "45");
  480. output.writeAttribute("y", "110");
  481. output.writeAttribute("width", "24");
  482. output.writeAttribute("height", "12");
  483. output.writeEndElement();
  484. output.writeStartElement("text");
  485. output.writeAttribute("x", "75");
  486. output.writeAttribute("y", "120");
  487. output.writeAttribute("font-size", "12");
  488. switch(unitBox.currentIndex) {
  489. case 0:
  490. output.writeCharacters(TTR("pytdprodcomp", "Previous Year Kg"));
  491. break;
  492. case 1:
  493. output.writeCharacters(TTR("pytdprodcomp", "Previous Year Lb"));
  494. break;
  495. }
  496. output.writeEndElement();
  497. output.writeStartElement("rect");
  498. output.writeAttribute("fill", "rgb(255,0,0)");
  499. output.writeAttribute("x", "195");
  500. output.writeAttribute("y", "110");
  501. output.writeAttribute("width", "24");
  502. output.writeAttribute("height", "12");
  503. output.writeEndElement();
  504. output.writeStartElement("text");
  505. output.writeAttribute("x", "225");
  506. output.writeAttribute("y", "120");
  507. output.writeAttribute("font-size", "12");
  508. switch(unitBox.currentIndex) {
  509. case 0:
  510. output.writeCharacters(TTR("pytdprodcomp", "Current Year Kg"));
  511. break;
  512. case 1:
  513. output.writeCharacters(TTR("pytdprodcomp", "Current Year Lb"));
  514. break;
  515. }
  516. output.writeEndElement();
  517. output.writeStartElement("rect");
  518. output.writeAttribute("fill", "rgb(0,255,0)");
  519. output.writeAttribute("x", "345");
  520. output.writeAttribute("y", "110");
  521. output.writeAttribute("width", "24");
  522. output.writeAttribute("height", "12");
  523. output.writeEndElement();
  524. output.writeStartElement("text");
  525. output.writeAttribute("x", "375");
  526. output.writeAttribute("y", "120");
  527. output.writeAttribute("font-size", "12");
  528. output.writeCharacters(TTR("pytdprodcomp", "% Change"));
  529. output.writeEndElement();
  530. output.writeStartElement("rect");
  531. output.writeAttribute("fill", "rgb(0,0,255)");
  532. output.writeAttribute("x", "495");
  533. output.writeAttribute("y", "110");
  534. output.writeAttribute("width", "24");
  535. output.writeAttribute("height", "12");
  536. output.writeEndElement();
  537. output.writeStartElement("text");
  538. output.writeAttribute("x", "525");
  539. output.writeAttribute("y", "120");
  540. output.writeAttribute("font-size", "12");
  541. output.writeCharacters(TTR("pytdprodcomp", "Average % Change"));
  542. output.writeEndElement();
  543. output.writeEndElement();
  544. output.writeEndElement();
  545. output.writeEndElement();
  546. output.writeEndElement();
  547. output.writeEndElement();
  548. output.writeEndDocument();
  549. view.setContent(buffer);
  550. buffer.close();
  551. }
  552. refresh();
  553. dateSelect.rangeUpdated.connect(function() {
  554. refresh();
  555. });
  556. avgField.editingFinished.connect(function() {
  557. refresh();
  558. });
  559. ]]>
  560. </program>
  561. </window>