chartoptions.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2017
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. // This forms the javascript functions used for the display options
  9. // action pane for PowerPlay Studio.
  10. // The functions are Internet Explorer specific.
  11. var CHART_TYPE_PIE = 1;
  12. var CHART_TYPE_SIMPLEBAR = 2;
  13. var CHART_TYPE_CLUSTEREDBAR = 3;
  14. var CHART_TYPE_MULTILINE = 4;
  15. var CHART_TYPE_STACKEDBAR = 5;
  16. var CHART_TYPE_3DBAR = 6;
  17. var CHART_TYPE_SIMPLELINE = 10;
  18. var CHART_TYPE_SCATTERCHART = 11;
  19. var CHART_TYPE_CORRELATION = 12;
  20. var PERCENTAGE_SCREEN_MIN_VALUE = 10;
  21. var PERCENTAGE_SCREEN_MAX_VALUE = 500;
  22. var currentTab = 1;
  23. var chartOptionsComboBoxes = new Array();
  24. var chartOptionComboBoxIds = new Array();
  25. var chartOptionsSliders = new Array();
  26. var fontArray = new Array();
  27. var seriesArray = new Array();
  28. function init() {
  29. topparent.openActionPane();
  30. topparent.setActionPaneHeight("350");
  31. ContextMenu.initialize(true,false);
  32. removeMessage();
  33. if (!document.getElementById("tab1")) {
  34. displayCommonMessage(strErrorMessageNoChart, MESSAGE_TYPE_INFO, [strColorPickerOK], [function() {topparent.closeActionPane();}]);
  35. } else {
  36. initializeStatsPane();
  37. initializePalettePane();
  38. initializeLabelsPane();
  39. storeOptionsUnderTag(document.body);
  40. initializeOptionValues();
  41. initializePaletteControls();
  42. intitializeBackgroundControls();
  43. changeTolabel(0);
  44. chartDepthChanged();
  45. switchToTab(parseInt(topparent.getGlobal("chartOptionsTab")));
  46. topparent.setGlobal("chartOptionsTab",1);
  47. if (chartType == CHART_TYPE_PIE)
  48. pieLabelOptionsChanged(false);
  49. setTimeout("resize();",1);
  50. }
  51. }
  52. function initializePaletteControls() {
  53. if (chartType == CHART_TYPE_CORRELATION) {
  54. var colorControl = chartOptionValues["COPA_I1"].control;
  55. setPaletteSeriesItem(colorControl,"Palette1");
  56. colorControl = chartOptionValues["COPA_I2"].control;
  57. setPaletteSeriesItem(colorControl,"Palette2");
  58. } else if (chartOptionValues["COPA_I"]) {
  59. var colorControl = chartOptionValues["COPA_I"].control;
  60. setPaletteSeriesItem(colorControl,"Palette");
  61. } else {
  62. populateSeriesDropDown();
  63. updatePalettePreview();
  64. paletteSeriesChanged();
  65. }
  66. }
  67. function populateSeriesDropDown() {
  68. var currentPaletteSelect = document.getElementById("Palette_seriesSelect");
  69. if (currentPaletteSelect) {
  70. var currentComboBox = initComboBox(currentPaletteSelect);
  71. var itemsArray = getSeriesArray();
  72. var itemStr;
  73. for (var i = 0; i < 16; i++) {
  74. if (itemsArray != null && (i < itemsArray.length) && !(itemsArray[i].suppressed)) {
  75. itemStr = seriesLabel + " " + (i + 1) + " (" + itemsArray[i].name + ")";
  76. } else {
  77. itemStr = seriesLabel + " " + (i + 1);
  78. }
  79. currentComboBox.addItem(new cbTextItem(itemStr, "paletteSeriesChanged();", (i == 0)));
  80. }
  81. chartOptionsComboBoxes["Palette_seriesSelect"] = currentComboBox;
  82. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = "Palette_seriesSelect";
  83. }
  84. }
  85. function getSeriesArray() {
  86. var itemsArray = null;
  87. //If there is no series array, then we return a blank array. As no series is passed in from the server.
  88. if (!seriesArray || !(seriesArray.length))
  89. return new Array();
  90. if (chartType == CHART_TYPE_PIE || chartType == CHART_TYPE_SCATTERCHART) {
  91. if (topparent.getChartFrame())
  92. itemsArray = topparent.getChartFrame().legendDataList["c"];
  93. else
  94. itemsArray = topparent.getXtabFrame().legendDataList["c"];
  95. } else if (chartType != CHART_TYPE_CORRELATION) {
  96. if (topparent.getChartFrame())
  97. itemsArray = topparent.getChartFrame().legendDataList["r"];
  98. else
  99. itemsArray = topparent.getXtabFrame().legendDataList["r"];
  100. } else {
  101. itemsArray = seriesArray;
  102. }
  103. return itemsArray;
  104. }
  105. function intitializeBackgroundControls() {
  106. var colorControl;
  107. if (chartType != CHART_TYPE_PIE) {
  108. colorControl = chartOptionValues["COB_B"].control;
  109. initializeGradientSelect("Background_gradientSelect","paletteColorChanged();");
  110. setPaletteSeriesItem(colorControl,"Background");
  111. }
  112. }
  113. function onOk() {
  114. applyOptions(true);
  115. }
  116. function onCancel() {
  117. topparent.clearActionPane();
  118. }
  119. function onApply() {
  120. topparent.setGlobal("chartOptionsTab", currentTab);
  121. applyOptions(false);
  122. }
  123. function isStillCorrectChartType() {
  124. fh = topparent.getXtabFrame().document.fhidden;
  125. if (!fh)
  126. return false;
  127. var dType = fh.Y.value;
  128. if (fh.YS)
  129. dType = fh.YS.value;
  130. return (parseInt(dType) == chartType);
  131. }
  132. function applyOptions(closePane, skipValidation) {
  133. if (isStillCorrectChartType() && (skipValidation || validateFields(closePane))) {
  134. //Set the option values after the validation has been done
  135. setOptionValues();
  136. var cmd = createCommand();
  137. if (cmd != "") {
  138. cmd = "T:" + cmd;
  139. if (closePane)
  140. topparent.getXtabFrame().document.fhidden.ACTPANE.value = "0";
  141. topparent.getXtabFrame().doit(cmd);
  142. }
  143. if (closePane) {
  144. topparent.clearActionPane();
  145. }
  146. }
  147. }
  148. function switchTab(event) {
  149. var eventM = new eventManager(event);
  150. eventM.cancelBubble();
  151. var newTab = eventM.getSrc();
  152. var newTabNo = newTab.getAttribute("number");
  153. switchToTab(newTabNo);
  154. }
  155. function switchToTab(newTabNo) {
  156. if (currentTab != newTabNo) {
  157. var newTab = document.getElementById("tab" + newTabNo);
  158. var oldTab = document.getElementById("tab" + currentTab);
  159. oldTab.className = "ActionPaneTab";
  160. newTab.className = "ActionPaneSelectedTab";
  161. var oldTabBody = document.getElementById("tab_body" + currentTab);
  162. oldTabBody.className = "ActionPaneTabBody";
  163. var newTabBody = document.getElementById("tab_body" + newTabNo);
  164. newTabBody.className = "ActionPaneSelectedTabBody";
  165. currentTab = newTabNo;
  166. if (currentTab == 1) { //General tab
  167. hideSliders();
  168. }
  169. if (newTabNo == 1) { //General tab
  170. resetSliders();
  171. }
  172. //Only necessary for gecko based browsers
  173. if (topparent.nn7)
  174. updatePalettePreview();
  175. clearAllPopups();
  176. }
  177. }
  178. function resize() {
  179. if (currentTab == 1) //General tab
  180. resetSliders();
  181. }
  182. function initializeStatsPane() {
  183. initializeLineSelect("Min_line_type","");
  184. initializeLineSelect("Max_line_type","");
  185. initializeLineSelect("Mean_line_type","");
  186. initializeLineSelect("Stddv_line_type","");
  187. initializeLineSelect("logrg_line_type","");
  188. initializeLineSelect("linrg_line_type","");
  189. initializeLineSelect("cus_line_type","");
  190. initializeSeriesSelect("Min_series","");
  191. initializeSeriesSelect("Max_series","");
  192. initializeSeriesSelect("Mean_series","");
  193. initializeSeriesSelect("Stddv_series","");
  194. initializeSeriesSelect("logrg_series","");
  195. initializeSeriesSelect("linrg_series","");
  196. initializeSeriesSelect("cus_series","");
  197. }
  198. function initializePalettePane() {
  199. notifyColorChange = "paletteColorChanged();";
  200. if (chartType != CHART_TYPE_CORRELATION) {
  201. initializeLineSelect("Palette_lineType","paletteColorChanged();");
  202. initializeMarkerSelect("Palette_markerType","paletteColorChanged();");
  203. } else {
  204. initializeLineSelect("Palette2_lineType","paletteColorChanged();");
  205. initializeMarkerSelect("Palette2_markerType","paletteColorChanged();");
  206. }
  207. }
  208. function initializeLabelsPane() {
  209. var chartLabelSelect = document.getElementById("labelSelect");
  210. if (chartLabelSelect) {
  211. var currentComboBox = initComboBox(chartLabelSelect);
  212. addLabelOptionIfExists(currentComboBox, strLabelGraphTitle, "COL_GT", "labelSelectChanged();");
  213. addLabelOptionIfExists(currentComboBox, strLabelVAxisTitle, "COL_VT", "labelSelectChanged();");
  214. addLabelOptionIfExists(currentComboBox, strLabelVAxisTitle2, "COL_V2T", "labelSelectChanged();");
  215. addLabelOptionIfExists(currentComboBox, strLabelHAxisTitle, "COL_HT", "labelSelectChanged();");
  216. addLabelOptionIfExists(currentComboBox, strLabelVAxisLabels, "COL_VL", "labelSelectChanged();");
  217. addLabelOptionIfExists(currentComboBox, strLabelVAxisLabels2, "COL_V2L", "labelSelectChanged();");
  218. addLabelOptionIfExists(currentComboBox, strLabelHAxisLabels, "COL_HL", "labelSelectChanged();");
  219. addLabelOptionIfExists(currentComboBox, strLabelValueLabels, "COL_VAL", "labelSelectChanged();");
  220. addLabelOptionIfExists(currentComboBox, strLabelPieLabels, "COL_PL", "labelSelectChanged();");
  221. addLabelOptionIfExists(currentComboBox, strLabelLegendLabels, "COL_LL", "labelSelectChanged();");
  222. chartOptionsComboBoxes["labelSelect"] = currentComboBox;
  223. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = "labelSelect";
  224. }
  225. initializeFontSelect("label_font","currentLabelChanged();");
  226. initializeFontSizeSelect("label_size","currentLabelChanged();");
  227. if (fontArray.length <= 1) {
  228. document.getElementById("fontNameSelect").style.visibility = "hidden";
  229. document.getElementById("fontNameLabel").style.visibility = "hidden";
  230. }
  231. if (fontArray.length == 0) {
  232. document.getElementById("fontSizeSelect").style.visibility = "hidden";
  233. document.getElementById("fontDecorationControls").style.visibility = "hidden";
  234. document.getElementById("fontSizeLabel").style.visibility = "hidden";
  235. document.getElementById("fontPreview").style.visibility = "hidden";
  236. }
  237. setLabelPreviewImage();
  238. }
  239. function addLabelOptionIfExists(combobox, str, name, action) {
  240. if (chartOptionValues[name]) {
  241. combobox.addItem(new cbTextItem(str, action, (combobox.numItems() == 0)));
  242. }
  243. }
  244. function paletteColorChanged() {
  245. var colorStoreDOMObj;
  246. if (chartType != CHART_TYPE_CORRELATION) {
  247. var single = true;
  248. if (chartOptionValues["COPA_I"]) { //Single color Palette;
  249. colorStoreDOMObj = chartOptionValues["COPA_I"].control;
  250. } else {
  251. single = false;
  252. colorStoreDOMObj = document.getElementById("chartPaletteSeriesHiddenStore").childNodes[chartOptionsComboBoxes["Palette_seriesSelect"].getSelectedItem()];
  253. }
  254. if (chartType == CHART_TYPE_MULTILINE || chartType == CHART_TYPE_SIMPLELINE || chartType == CHART_TYPE_SCATTERCHART) {
  255. colorStoreDOMObj.setAttribute("lineColor",getColorPickerColor("Palette_color1"));
  256. if (chartOptionsComboBoxes["Palette_lineType"])
  257. colorStoreDOMObj.setAttribute("lineType",(chartOptionsComboBoxes["Palette_lineType"].getSelectedItem()));
  258. colorStoreDOMObj.setAttribute("markerType",chartOptionsComboBoxes["Palette_markerType"].getSelectedItem());
  259. if (chartType == CHART_TYPE_SCATTERCHART) {
  260. if (chartOptionsComboBoxes["Palette_markerType"].getSelectedItem() == 0)
  261. document.getElementById("Palette_colorComponent1").className="colorComponentHidden";
  262. else
  263. document.getElementById("Palette_colorComponent1").className="colorComponentVisible";
  264. }
  265. } else if (document.getElementById("Palette_colorTypeSolid").checked) {
  266. colorStoreDOMObj.setAttribute("solidColor",getColorPickerColor("Palette_color1"));
  267. } else if (document.getElementById("Palette_colorTypePattern").checked) {
  268. colorStoreDOMObj.setAttribute("patternColor1",getColorPickerColor("Palette_color1"));
  269. colorStoreDOMObj.setAttribute("patternColor2",getColorPickerColor("Palette_color2"));
  270. colorStoreDOMObj.setAttribute("pattern",parseInt(getPatternPickerPattern("Palette_pattern")) - 1);
  271. } else {
  272. colorStoreDOMObj.setAttribute("gradientColor1",getColorPickerColor("Palette_color1"));
  273. colorStoreDOMObj.setAttribute("gradientColor2",getColorPickerColor("Palette_color2"));
  274. }
  275. if (!single) {
  276. var itemNo = chartOptionsComboBoxes["Palette_seriesSelect"].getSelectedItem();
  277. updatePalettePreviewItem(itemNo,itemNo + 1,"PalettePreview");
  278. if (chartType == CHART_TYPE_SCATTERCHART)
  279. selectPalettePreviewItem(itemNo,"PalettePreview");
  280. }
  281. } else {
  282. colorStoreDOMObj = chartOptionValues["COPA_I1"].control;
  283. if (document.getElementById("Palette1_colorTypeSolid").checked) {
  284. colorStoreDOMObj.setAttribute("solidColor",getColorPickerColor("Palette1_color1"));
  285. } else if (document.getElementById("Palette1_colorTypePattern").checked) {
  286. colorStoreDOMObj.setAttribute("patternColor1",getColorPickerColor("Palette1_color1"));
  287. colorStoreDOMObj.setAttribute("patternColor2",getColorPickerColor("Palette1_color2"));
  288. colorStoreDOMObj.setAttribute("pattern",parseInt(getPatternPickerPattern("Palette1_pattern")) - 1);
  289. } else {
  290. colorStoreDOMObj.setAttribute("gradientColor1",getColorPickerColor("Palette1_color1"));
  291. colorStoreDOMObj.setAttribute("gradientColor2",getColorPickerColor("Palette1_color2"));
  292. }
  293. colorStoreDOMObj = chartOptionValues["COPA_I2"].control;
  294. colorStoreDOMObj.setAttribute("lineColor",getColorPickerColor("Palette2_color1"));
  295. colorStoreDOMObj.setAttribute("lineType",chartOptionsComboBoxes["Palette2_lineType"].getSelectedItem());
  296. colorStoreDOMObj.setAttribute("markerType",chartOptionsComboBoxes["Palette2_markerType"].getSelectedItem());
  297. }
  298. //Update background
  299. var backControl;
  300. if (chartOptionValues["COB_B"])
  301. backControl = chartOptionValues["COB_B"].control;
  302. if (document.getElementById("Background_colorTypeSolid")) {
  303. if (document.getElementById("Background_colorTypeSolid").checked) {
  304. backControl.setAttribute("solidColor",getColorPickerColor("Background_color1"));
  305. } else if (document.getElementById("Background_colorTypePattern").checked) {
  306. backControl.setAttribute("patternColor1",getColorPickerColor("Background_color1"));
  307. backControl.setAttribute("patternColor2",getColorPickerColor("Background_color2"));
  308. backControl.setAttribute("pattern",parseInt(getPatternPickerPattern("Background_pattern")) - 1);
  309. } else {
  310. backControl.setAttribute("gradientColor1",getColorPickerColor("Background_color1"));
  311. backControl.setAttribute("gradientColor2",getColorPickerColor("Background_color2"));
  312. backControl.setAttribute("gradientType",chartOptionsComboBoxes["Background_gradientSelect"].getSelectedItem());
  313. }
  314. }
  315. currentLabelChanged();
  316. }
  317. function updatePalettePreview() {
  318. if (!document.getElementById("Palette_seriesSelect"))
  319. return;
  320. if (document.getElementById("Palette_seriesSelect"))
  321. for (var i = 0; i < 16; i++) {
  322. updatePalettePreviewItem(i,(i+1),"PalettePreview");
  323. }
  324. var currentSelection = 1;
  325. if (document.getElementById("Palette_seriesSelect"))
  326. currentSelection = chartOptionsComboBoxes["Palette_seriesSelect"].getSelectedItem();
  327. selectPalettePreviewItem(currentSelection,"PalettePreview");
  328. }
  329. function updatePalettePreviewItem(paletteItemNo, previewItemNo, prefix) {
  330. if (!document.getElementById(prefix + "_color1" + previewItemNo))
  331. return;
  332. var colorControl = chartOptionValues["COPA_I" + (paletteItemNo + 1)].control;
  333. //Some browsers add the border around the width specified in Divs, we have to decrease this properly so that it fits
  334. if (document.getElementById(prefix + "_series" + previewItemNo))
  335. resetWidthByBorderAmount(document.getElementById(prefix + "_series" + previewItemNo).firstChild,document.getElementById(prefix + "_series" + previewItemNo).offsetWidth);
  336. if (document.getElementById(prefix + "_color1" + previewItemNo))
  337. resetWidthByBorderAmount(document.getElementById(prefix + "_color1" + previewItemNo).firstChild,document.getElementById(prefix + "_color1" + previewItemNo).offsetWidth);
  338. if (document.getElementById(prefix + "_color2" + previewItemNo))
  339. resetWidthByBorderAmount(document.getElementById(prefix + "_color2" + previewItemNo).firstChild,document.getElementById(prefix + "_color1" + previewItemNo).offsetWidth);
  340. if (document.getElementById(prefix + "_line" + previewItemNo))
  341. resetWidthByBorderAmount(document.getElementById(prefix + "_line" + previewItemNo).firstChild,document.getElementById(prefix + "_color1" + previewItemNo).offsetWidth);
  342. if (document.getElementById(prefix + "_marker" + previewItemNo))
  343. resetWidthByBorderAmount(document.getElementById(prefix + "_marker" + previewItemNo).firstChild,document.getElementById(prefix + "_color1" + previewItemNo).offsetWidth);
  344. if (document.getElementById(prefix + "_pattern" + previewItemNo))
  345. resetWidthByBorderAmount(document.getElementById(prefix + "_pattern" + previewItemNo).firstChild,document.getElementById(prefix + "_color1" + previewItemNo).offsetWidth);
  346. if (parseInt(colorControl.getAttribute("colorType")) == COLOR_TYPE_LINE) {
  347. if (chartType == CHART_TYPE_SCATTERCHART && parseInt(colorControl.getAttribute("markerType")) == 0) {
  348. document.getElementById(prefix + "_color1" + previewItemNo).firstChild.style.backgroundColor = ""
  349. document.getElementById(prefix + "_color1" + previewItemNo).setAttribute("on","false");
  350. } else {
  351. document.getElementById(prefix + "_color1" + previewItemNo).firstChild.style.backgroundColor = "#" + colorControl.getAttribute("lineColor");
  352. document.getElementById(prefix + "_color1" + previewItemNo).setAttribute("on","true");
  353. }
  354. if (document.getElementById(prefix + "_line" + previewItemNo)) {
  355. document.getElementById(prefix + "_line" + previewItemNo).firstChild.style.backgroundImage = "url(" + topparent.getGlobal("menuImagePath") + "line" + (parseInt(colorControl.getAttribute("lineType")) + 1) + ".gif)";
  356. document.getElementById(prefix + "_line" + previewItemNo).firstChild.style.backgroundPosition = "center";
  357. document.getElementById(prefix + "_line" + previewItemNo).firstChild.style.backgroundColor = "#FFFFFF";
  358. document.getElementById(prefix + "_line" + previewItemNo).setAttribute("on","true");
  359. }
  360. document.getElementById(prefix + "_marker" + previewItemNo).firstChild.style.backgroundImage = "url(" + topparent.getGlobal("menuImagePath") + "marker" + colorControl.getAttribute("markerType") + ".gif)";
  361. document.getElementById(prefix + "_marker" + previewItemNo).firstChild.style.backgroundPosition = "center";
  362. document.getElementById(prefix + "_marker" + previewItemNo).firstChild.style.backgroundColor = "#FFFFFF";
  363. document.getElementById(prefix + "_marker" + previewItemNo).setAttribute("on","true");
  364. } else if (parseInt(colorControl.getAttribute("colorType")) == COLOR_TYPE_SOLID) {
  365. document.getElementById(prefix + "_color1" + previewItemNo).firstChild.style.backgroundColor = "#" + colorControl.getAttribute("solidColor");
  366. document.getElementById(prefix + "_color1" + previewItemNo).setAttribute("on","true");
  367. if (document.getElementById(prefix + "_color2" + previewItemNo)) {
  368. document.getElementById(prefix + "_color2" + previewItemNo).firstChild.style.backgroundColor = "";
  369. document.getElementById(prefix + "_color2" + previewItemNo).setAttribute("on","false");
  370. }
  371. if (document.getElementById(prefix + "_pattern" + previewItemNo)) {
  372. document.getElementById(prefix + "_pattern" + previewItemNo).firstChild.style.backgroundImage = "";
  373. document.getElementById(prefix + "_pattern" + previewItemNo).setAttribute("on","false");
  374. }
  375. } else if (parseInt(colorControl.getAttribute("colorType")) == COLOR_TYPE_PATTERN) {
  376. document.getElementById(prefix + "_color1" + previewItemNo).firstChild.style.backgroundColor = "#" + colorControl.getAttribute("patternColor1");
  377. document.getElementById(prefix + "_color1" + previewItemNo).setAttribute("on","true");
  378. if (document.getElementById(prefix + "_color2" + previewItemNo)) {
  379. document.getElementById(prefix + "_color2" + previewItemNo).firstChild.style.backgroundColor = "#" + colorControl.getAttribute("patternColor2");
  380. document.getElementById(prefix + "_color2" + previewItemNo).setAttribute("on","true");
  381. }
  382. if (document.getElementById(prefix + "_pattern" + previewItemNo)) {
  383. document.getElementById(prefix + "_pattern" + previewItemNo).firstChild.style.backgroundImage = getPatternStyle(parseInt(colorControl.getAttribute("pattern")) + 1);
  384. document.getElementById(prefix + "_pattern" + previewItemNo).setAttribute("on","true");
  385. }
  386. } else {
  387. document.getElementById(prefix + "_color1" + previewItemNo).firstChild.style.backgroundColor = "#" + colorControl.getAttribute("gradientColor1");
  388. document.getElementById(prefix + "_color1" + previewItemNo).setAttribute("on","true");
  389. if (document.getElementById(prefix + "_color2" + previewItemNo)) {
  390. document.getElementById(prefix + "_color2" + previewItemNo).firstChild.style.backgroundColor = "#" + colorControl.getAttribute("gradientColor2");
  391. document.getElementById(prefix + "_color2" + previewItemNo).setAttribute("on","true");
  392. }
  393. if (document.getElementById(prefix + "_pattern" + previewItemNo)) {
  394. document.getElementById(prefix + "_pattern" + previewItemNo).firstChild.style.backgroundImage = "";
  395. document.getElementById(prefix + "_pattern" + previewItemNo).setAttribute("on","false");
  396. }
  397. }
  398. }
  399. function selectPalettePreviewItem(itemNo,prefix) {
  400. if (!document.getElementById(prefix + "_color11"))
  401. return;
  402. var colorControl = chartOptionValues["COPA_I" + (itemNo + 1)].control
  403. var numPreviewItems = 1;
  404. if (document.getElementById("Palette_seriesSelect"))
  405. numPreviewItems = 16;
  406. for (var i = 0; i < numPreviewItems; i++) {
  407. if (i == itemNo) {
  408. if (document.getElementById(prefix + "_series" + (i + 1) + "div"))
  409. document.getElementById(prefix + "_series" + (i + 1) + "div").className = "palettePreviewCellDivSelected ChartOptionsLabel";
  410. if (!document.getElementById(prefix + "_marker" + (i + 1) + "div") || document.getElementById(prefix + "_line" + (i + 1) + "div") || chartOptionsComboBoxes["Palette_markerType"].getSelectedItem() != 0)
  411. document.getElementById(prefix + "_color1" + (i + 1) + "div").className = "palettePreviewCellDivSelected";
  412. else
  413. document.getElementById(prefix + "_color1" + (i + 1) + "div").className = "palettePreviewCellDiv";
  414. if (document.getElementById(prefix + "_line" + (i + 1) + "div"))
  415. if (colorControl.getAttribute("colorType") == COLOR_TYPE_LINE)
  416. document.getElementById(prefix + "_line" + (i + 1) + "div").className = "palettePreviewCellDivSelected";
  417. else
  418. document.getElementById(prefix + "_line" + (i + 1) + "div").className = "palettePreviewCellDiv";
  419. if (document.getElementById(prefix + "_marker" + (i + 1) + "div"))
  420. if (colorControl.getAttribute("colorType") == COLOR_TYPE_LINE)
  421. document.getElementById(prefix + "_marker" + (i + 1) + "div").className = "palettePreviewCellDivSelected";
  422. else
  423. document.getElementById(prefix + "_marker" + (i + 1) + "div").className = "palettePreviewCellDiv";
  424. if (document.getElementById(prefix + "_color2" + (i + 1) + "div"))
  425. if (colorControl.getAttribute("colorType") == COLOR_TYPE_PATTERN || colorControl.getAttribute("colorType") == COLOR_TYPE_GRADIENT)
  426. document.getElementById(prefix + "_color2" + (i + 1) + "div").className = "palettePreviewCellDivSelected";
  427. else
  428. document.getElementById(prefix + "_color2" + (i + 1) + "div").className = "palettePreviewCellDiv";
  429. if (document.getElementById(prefix + "_pattern" + (i + 1) + "div"))
  430. if (colorControl.getAttribute("colorType") == COLOR_TYPE_PATTERN)
  431. document.getElementById(prefix + "_pattern" + (i + 1) + "div").className = "palettePreviewCellDivSelected";
  432. else
  433. document.getElementById(prefix + "_pattern" + (i + 1) + "div").className = "palettePreviewCellDiv";
  434. } else {
  435. document.getElementById(prefix + "_color1" + (i + 1) + "div").className = "palettePreviewCellDiv";
  436. document.getElementById(prefix + "_series" + (i + 1) + "div").className = "palettePreviewCellDiv ChartOptionsLabel";
  437. if (document.getElementById(prefix + "_color2" + (i + 1) + "div"))
  438. document.getElementById(prefix + "_color2" + (i + 1) + "div").className = "palettePreviewCellDiv";
  439. if (document.getElementById(prefix + "_pattern" + (i + 1) + "div"))
  440. document.getElementById(prefix + "_pattern" + (i + 1) + "div").className = "palettePreviewCellDiv";
  441. if (document.getElementById(prefix + "_line" + (i + 1) + "div"))
  442. document.getElementById(prefix + "_line" + (i + 1) + "div").className = "palettePreviewCellDiv";
  443. if (document.getElementById(prefix + "_marker" + (i + 1) + "div"))
  444. document.getElementById(prefix + "_marker" + (i + 1) + "div").className = "palettePreviewCellDiv";
  445. }
  446. }
  447. }
  448. function setLabelPreviewImage() {
  449. var image = document.getElementById("labelPreviewImage");
  450. var imageName = "col";
  451. if (chartType == CHART_TYPE_SIMPLEBAR ||
  452. chartType == CHART_TYPE_CLUSTEREDBAR ||
  453. chartType == CHART_TYPE_STACKEDBAR ||
  454. chartType == CHART_TYPE_3DBAR) {
  455. var horizontal = false;
  456. if (chartOptionValues["COGCB_H"]) {
  457. if (chartOptionValues["COGCB_H"].control) {
  458. if (chartOptionValues["COGCB_H"].control.checked)
  459. horizontal = true;
  460. } else if (chartOptionValues["COGCB_H"].details.value)
  461. horizontal = true;
  462. }
  463. if (horizontal)
  464. imageName += "horz";
  465. imageName += "bar";
  466. } else if (chartType == CHART_TYPE_MULTILINE ||
  467. chartType == CHART_TYPE_SIMPLELINE) {
  468. imageName += "line";
  469. } else if (chartType == CHART_TYPE_PIE) {
  470. imageName += "pie";
  471. } else if (chartType == CHART_TYPE_SCATTERCHART) {
  472. imageName += "scatter";
  473. } else if (chartType == CHART_TYPE_CORRELATION) {
  474. imageName += "corr";
  475. }
  476. var options = document.getElementById("labelOptionsHiddenStore");
  477. var option = options.childNodes[chartOptionsComboBoxes["labelSelect"].getSelectedItem()];
  478. var optionName = option.getAttribute("optionName");
  479. if (optionName == "COL_GT")
  480. imageName += "title";
  481. else if (optionName == "COL_VT")
  482. if (chartType == CHART_TYPE_CORRELATION || chartType == CHART_TYPE_SCATTERCHART)
  483. imageName += "measure1title";
  484. else
  485. imageName += "measuretitle";
  486. else if (optionName == "COL_V2T")
  487. imageName += "measure2title";
  488. else if (optionName == "COL_HT")
  489. if (chartType == CHART_TYPE_SCATTERCHART)
  490. imageName += "measure2title";
  491. else
  492. imageName += "cattitle";
  493. else if (optionName == "COL_VL")
  494. if (chartType == CHART_TYPE_CORRELATION || chartType == CHART_TYPE_SCATTERCHART)
  495. imageName += "measure1labels";
  496. else
  497. imageName += "measurelabels";
  498. else if (optionName == "COL_V2L")
  499. imageName += "measure2labels";
  500. else if (optionName == "COL_HL")
  501. if (chartType == CHART_TYPE_SCATTERCHART)
  502. imageName += "measure2labels";
  503. else
  504. imageName += "catlabels";
  505. else if (optionName == "COL_PL")
  506. imageName += "catlabels";
  507. else if (optionName == "COL_VAL")
  508. imageName += "valuelabels";
  509. else if (optionName == "COL_LL")
  510. imageName += "legendlabels";
  511. var imagePath = genericIconPath + imageName + ".png";
  512. document.getElementById("labelPreviewImage").src = imagePath;
  513. }
  514. function paletteSeriesChanged() {
  515. if (!document.getElementById("Palette_seriesSelect"))
  516. return;
  517. var colorControl = document.getElementById("chartPaletteSeriesHiddenStore").childNodes[chartOptionsComboBoxes["Palette_seriesSelect"].getSelectedItem()];
  518. setPaletteSeriesItem(colorControl,"Palette");
  519. selectPalettePreviewItem(chartOptionsComboBoxes["Palette_seriesSelect"].getSelectedItem(),"PalettePreview");
  520. }
  521. function setPaletteSeriesItem(colorControl,prefix) {
  522. if (document.getElementById(prefix + "_colorTypeSolid") && parseInt(colorControl.getAttribute("colorType")) == COLOR_TYPE_SOLID) {
  523. document.getElementById(prefix + "_colorTypeSolid").checked = true;
  524. document.getElementById(prefix + "_colorTypePattern").checked = false;
  525. document.getElementById(prefix + "_colorTypeGradient").checked = false;
  526. } else if (document.getElementById(prefix + "_colorTypePattern") && parseInt(colorControl.getAttribute("colorType")) == COLOR_TYPE_PATTERN) {
  527. document.getElementById(prefix + "_colorTypeSolid").checked = false;
  528. document.getElementById(prefix + "_colorTypePattern").checked = true;
  529. document.getElementById(prefix + "_colorTypeGradient").checked = false;
  530. } else if (document.getElementById(prefix + "_colorTypeGradient")) {
  531. document.getElementById(prefix + "_colorTypeSolid").checked = false;
  532. document.getElementById(prefix + "_colorTypePattern").checked = false;
  533. document.getElementById(prefix + "_colorTypeGradient").checked = true;
  534. }
  535. if (document.getElementById(prefix + "_seriesSelect"))
  536. setColorType(chartOptionsComboBoxes["Palette_seriesSelect"].getSelectedItem() + 1, prefix);
  537. else
  538. setColorType(0,prefix);
  539. }
  540. function initializeLineSelect(comboBoxId,action) {
  541. var currentLineSelect = document.getElementById(comboBoxId);
  542. if (currentLineSelect) {
  543. var currentComboBox = initComboBox(currentLineSelect);
  544. numLines = 5;
  545. for (var i = 1; i <= numLines; i++)
  546. currentComboBox.addItem(new cbRepeatingImageItem(topparent.getGlobal("menuImagePath") + "line" + i + ".gif",action,(i == 1)));
  547. chartOptionsComboBoxes[comboBoxId] = currentComboBox;
  548. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = comboBoxId;
  549. }
  550. }
  551. function initializeMarkerSelect(comboBoxId,action) {
  552. var currentMarkerSelect = document.getElementById(comboBoxId);
  553. if (currentMarkerSelect) {
  554. var currentComboBox = initComboBox(currentMarkerSelect);
  555. numLines = 8;
  556. for (var i = 0; i < numLines; i++)
  557. currentComboBox.addItem(new cbRepeatingImageItem(topparent.getGlobal("menuImagePath") + "marker" + i + ".gif",action,(i == 1)));
  558. chartOptionsComboBoxes[comboBoxId] = currentComboBox;
  559. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = comboBoxId;
  560. }
  561. }
  562. function initializeFontSelect(comboBoxId,action) {
  563. var currentFontSelect = document.getElementById(comboBoxId);
  564. if (currentFontSelect) {
  565. var currentComboBox = initComboBox(currentFontSelect);
  566. for (var i = 0; i < fontArray.length; i++)
  567. currentComboBox.addItem(new cbTextItem(fontArray[i].name, action, (i == 0)));
  568. chartOptionsComboBoxes[comboBoxId] = currentComboBox;
  569. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = comboBoxId;
  570. }
  571. }
  572. function initializeFontSizeSelect(comboBoxId,action) {
  573. var currentFontSizeSelect = document.getElementById(comboBoxId);
  574. if (currentFontSizeSelect) {
  575. var currentComboBox = initComboBox(currentFontSizeSelect);
  576. currentComboBox.addItem(new cbTextItem(strDefault, action, false));
  577. currentComboBox.addItem(new cbTextItem("4", action, false));
  578. currentComboBox.addItem(new cbTextItem("6", action, false));
  579. currentComboBox.addItem(new cbTextItem("7", action, false));
  580. currentComboBox.addItem(new cbTextItem("8", action, false));
  581. currentComboBox.addItem(new cbTextItem("9", action, false));
  582. currentComboBox.addItem(new cbTextItem("10", action, true));
  583. currentComboBox.addItem(new cbTextItem("11", action, true));
  584. currentComboBox.addItem(new cbTextItem("12", action, false));
  585. currentComboBox.addItem(new cbTextItem("13", action, false));
  586. currentComboBox.addItem(new cbTextItem("14", action, false));
  587. currentComboBox.addItem(new cbTextItem("15", action, false));
  588. currentComboBox.addItem(new cbTextItem("16", action, false));
  589. currentComboBox.addItem(new cbTextItem("18", action, false));
  590. currentComboBox.addItem(new cbTextItem("20", action, false));
  591. chartOptionsComboBoxes[comboBoxId] = currentComboBox;
  592. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = comboBoxId;
  593. }
  594. }
  595. function initializeSeriesSelect(comboBoxId,action) {
  596. var currentSeriesSelect = document.getElementById(comboBoxId);
  597. if (currentSeriesSelect) {
  598. var currentComboBox = initComboBox(currentSeriesSelect);
  599. var itemsArray = getSeriesArray();
  600. for (var i = 0; i < itemsArray.length; i++)
  601. currentComboBox.addItem(new cbTextItem(itemsArray[i].name, action, (i == 0)));
  602. chartOptionsComboBoxes[comboBoxId] = currentComboBox;
  603. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = comboBoxId;
  604. }
  605. }
  606. function initializeGradientSelect(comboBoxId,action) {
  607. var currentSeriesSelect = document.getElementById(comboBoxId);
  608. if (currentSeriesSelect) {
  609. var currentComboBox = initComboBox(currentSeriesSelect);
  610. currentComboBox.addItem(new cbImageTextItem(strUp, genericIconPath + "gradup.png", action, true));
  611. currentComboBox.addItem(new cbImageTextItem(strLeft, genericIconPath + "gradleft.png", action, false));
  612. currentComboBox.addItem(new cbImageTextItem(strRight, genericIconPath + "gradright.png", action, false));
  613. currentComboBox.addItem(new cbImageTextItem(strDown, genericIconPath + "graddown.png", action, false));
  614. chartOptionsComboBoxes[comboBoxId] = currentComboBox;
  615. chartOptionComboBoxIds[chartOptionComboBoxIds.length] = comboBoxId;
  616. }
  617. }
  618. function clearAllPopups() {
  619. for (var i = 0; i < chartOptionComboBoxIds.length; i++) {
  620. chartOptionsComboBoxes[chartOptionComboBoxIds[i]].hideDropDown();
  621. }
  622. hideColorPicker();
  623. }
  624. function colorTypeChange(event, idPrefix) {
  625. var itemNo = 1;
  626. if (idPrefix == "Palette" && document.getElementById("Palette_seriesSelect"))
  627. itemNo = parseInt(chartOptionsComboBoxes["Palette_seriesSelect"].getSelectedItem()) + 1;
  628. setColorType(itemNo, idPrefix);
  629. }
  630. function setColorType(itemNo, idPrefix) {
  631. var colorControl;
  632. if (idPrefix == "Background")
  633. colorControl = chartOptionValues["COB_B"].control;
  634. else if (document.getElementById("Palette_seriesSelect"))
  635. colorControl = chartOptionValues["COPA_I" + itemNo].control;
  636. else if (chartType == CHART_TYPE_CORRELATION) {
  637. if (idPrefix == "Palette1")
  638. colorControl = chartOptionValues["COPA_I1"].control;
  639. else
  640. colorControl = chartOptionValues["COPA_I2"].control;
  641. } else
  642. colorControl = chartOptionValues["COPA_I"].control;
  643. if (parseInt(colorControl.getAttribute("colorType")) == COLOR_TYPE_LINE) {
  644. setColorPicker(idPrefix + "_color1",colorControl.getAttribute("lineColor"));
  645. if (chartOptionsComboBoxes[idPrefix + "_lineType"])
  646. chartOptionsComboBoxes[idPrefix + "_lineType"].setSelectedItem(parseInt(colorControl.getAttribute("lineType")));
  647. chartOptionsComboBoxes[idPrefix + "_markerType"].setSelectedItem(parseInt(colorControl.getAttribute("markerType")));
  648. if (chartType == CHART_TYPE_SCATTERCHART) {
  649. if (chartOptionsComboBoxes[idPrefix + "_markerType"].getSelectedItem() == 0)
  650. document.getElementById(idPrefix + "_colorComponent1").className="colorComponentHidden";
  651. else
  652. document.getElementById(idPrefix + "_colorComponent1").className="colorComponentVisible";
  653. }
  654. } else if (!document.getElementById(idPrefix + "_colorTypeSolid") || document.getElementById(idPrefix + "_colorTypeSolid").checked) {
  655. colorControl.setAttribute("colorType",COLOR_TYPE_SOLID);
  656. setColorPicker(idPrefix + "_color1",colorControl.getAttribute("solidColor"));
  657. if (idPrefix == "Background"/* || idPrefix == "LBackground" || idPrefix == "RBackground" || idPrefix == "Floor"*/) {
  658. document.getElementById(idPrefix + "_gradientType").className = "colorComponentHidden";
  659. }
  660. if (document.getElementById(idPrefix + "_colorTypeSolid")) {
  661. document.getElementById(idPrefix + "_colorComponent1").className="colorComponentVisible";
  662. document.getElementById(idPrefix + "_colorComponent2").className="colorComponentHidden";
  663. document.getElementById(idPrefix + "_patternComponent").className="colorComponentHidden";
  664. document.getElementById(idPrefix + "_colorComponent1Label").removeChild(document.getElementById(idPrefix + "_colorComponent1Label").firstChild);
  665. document.getElementById(idPrefix + "_colorComponent1Label").appendChild(document.createTextNode(strColor));
  666. }
  667. } else if (document.getElementById(idPrefix + "_colorTypePattern") && document.getElementById(idPrefix + "_colorTypePattern").checked) {
  668. colorControl.setAttribute("colorType",COLOR_TYPE_PATTERN);
  669. setColorPicker(idPrefix + "_color1",colorControl.getAttribute("patternColor1"));
  670. setColorPicker(idPrefix + "_color2",colorControl.getAttribute("patternColor2"));
  671. setPatternPicker(idPrefix + "_pattern",parseInt(colorControl.getAttribute("pattern")) + 1);
  672. if (idPrefix == "Background"/* || idPrefix == "LBackground" || idPrefix == "RBackground" || idPrefix == "Floor"*/) {
  673. document.getElementById(idPrefix + "_gradientType").className = "colorComponentHidden";
  674. }
  675. document.getElementById(idPrefix + "_colorComponent1").className="colorComponentVisible";
  676. document.getElementById(idPrefix + "_colorComponent2").className="colorComponentVisible";
  677. document.getElementById(idPrefix + "_patternComponent").className="colorComponentVisible";
  678. document.getElementById(idPrefix + "_colorComponent1Label").removeChild(document.getElementById(idPrefix + "_colorComponent1Label").firstChild);
  679. document.getElementById(idPrefix + "_colorComponent1Label").appendChild(document.createTextNode(strForegroundColor));
  680. document.getElementById(idPrefix + "_colorComponent2Label").removeChild(document.getElementById(idPrefix + "_colorComponent2Label").firstChild);
  681. document.getElementById(idPrefix + "_colorComponent2Label").appendChild(document.createTextNode(strBackgroundColor));
  682. } else if (document.getElementById(idPrefix + "_colorTypeGradient")) {
  683. colorControl.setAttribute("colorType",COLOR_TYPE_GRADIENT);
  684. setColorPicker(idPrefix + "_color1",colorControl.getAttribute("gradientColor1"));
  685. setColorPicker(idPrefix + "_color2",colorControl.getAttribute("gradientColor2"));
  686. if (idPrefix == "Background"/* || idPrefix == "LBackground" || idPrefix == "RBackground" || idPrefix == "Floor"*/) {
  687. document.getElementById(idPrefix + "_gradientType").className = "colorComponentVisible";
  688. chartOptionsComboBoxes[idPrefix + "_gradientSelect"].setSelectedItem(parseInt(colorControl.getAttribute("gradientType")));
  689. }
  690. document.getElementById(idPrefix + "_colorComponent1").className="colorComponentVisible";
  691. document.getElementById(idPrefix + "_colorComponent2").className="colorComponentVisible";
  692. document.getElementById(idPrefix + "_patternComponent").className="colorComponentHidden";
  693. document.getElementById(idPrefix + "_colorComponent1Label").removeChild(document.getElementById(idPrefix + "_colorComponent1Label").firstChild);
  694. document.getElementById(idPrefix + "_colorComponent1Label").appendChild(document.createTextNode(strColor1));
  695. document.getElementById(idPrefix + "_colorComponent2Label").removeChild(document.getElementById(idPrefix + "_colorComponent2Label").firstChild);
  696. document.getElementById(idPrefix + "_colorComponent2Label").appendChild(document.createTextNode(strColor2));
  697. }
  698. if (document.getElementById("Palette_seriesSelect") && idPrefix == "Palette") {
  699. updatePalettePreviewItem(itemNo - 1,itemNo,"PalettePreview");
  700. selectPalettePreviewItem(itemNo - 1,"PalettePreview");
  701. }
  702. }
  703. function selectPaletteItemNo(event, itemNo) {
  704. var eventM = new eventManager(event);
  705. eventM.cancelBubble();
  706. if (document.getElementById("Palette_seriesSelect"))
  707. chartOptionsComboBoxes["Palette_seriesSelect"].setSelectedItem((itemNo - 1));
  708. paletteSeriesChanged();
  709. }
  710. function dblClickPaletteItemNo(event, cpId, type) {
  711. var eventM = new eventManager(event);
  712. eventM.cancelBubble();
  713. if (eventM.getSrc().getAttribute("on") != "false")
  714. if (type =="color") {
  715. displayColorPickerObj(document.getElementById(cpId));
  716. } else {
  717. displayPatternPickerObj(document.getElementById(cpId));
  718. }
  719. }
  720. function fontButtonClicked(event) {
  721. var eventM = new eventManager(event);
  722. eventM.cancelBubble();
  723. var button = eventM.getSrc();
  724. toggleButton(button);
  725. }
  726. function toggleButton(button) {
  727. if (button.getAttribute("isdisabled") == "true")
  728. return;
  729. if (button.getAttribute("pressed") == "true") {
  730. setButtonState(button,false);
  731. } else {
  732. setButtonState(button,true);
  733. }
  734. }
  735. function setButtonState(button,pressed) {
  736. if (pressed) {
  737. button.className = "chartOptionsFontButtonPressed";
  738. button.setAttribute("pressed","true");
  739. } else {
  740. button.className = "chartOptionsFontButton";
  741. button.setAttribute("pressed","false");
  742. }
  743. }
  744. function rolloverbutton(button) {
  745. if (button.getAttribute("isdisabled") == "true")
  746. return;
  747. if (button.getAttribute("pressed") == "true") {
  748. button.className = "chartOptionsFontButtonRolloverPressed";
  749. } else {
  750. button.className = "chartOptionsFontButtonRollover";
  751. }
  752. }
  753. function rolloutbutton(button) {
  754. if (button.getAttribute("isdisabled") == "true")
  755. return;
  756. if (button.getAttribute("pressed") == "true") {
  757. button.className = "chartOptionsFontButtonPressed";
  758. } else {
  759. button.className = "chartOptionsFontButton";
  760. }
  761. }
  762. function labelSelectChanged() {
  763. changeTolabel(chartOptionsComboBoxes["labelSelect"].getSelectedItem());
  764. }
  765. function changeTolabel(labelNo) {
  766. var option = document.getElementById("labelOptionsHiddenStore").childNodes[labelNo];
  767. if (chartOptionValues[option.getAttribute("optionName")].details.type == CHART_OPTION_VALUE_TITLE) {
  768. document.getElementById("label_text").parentNode.style.visibility = "visible";
  769. document.getElementById("label_isDefault").parentNode.style.visibility = "visible";
  770. document.getElementById("label_text").value = option.getAttribute("title");
  771. if (option.getAttribute("isdefault") == "true")
  772. document.getElementById("label_isDefault").checked = true;
  773. else
  774. document.getElementById("label_notDefault").checked = true;
  775. } else {
  776. document.getElementById("label_isDefault").parentNode.style.visibility = "hidden";
  777. document.getElementById("label_text").parentNode.style.visibility = "hidden";
  778. }
  779. setButtonState(document.getElementById("label_bold"),option.getAttribute("bold") == "true");
  780. setButtonState(document.getElementById("label_italic"),option.getAttribute("italic") == "true");
  781. setButtonState(document.getElementById("label_underlined"),option.getAttribute("underline") == "true");
  782. var selectedItem = 0;
  783. for (var i = 0; (i < chartOptionsComboBoxes["label_font"].numItems()) && (selectedItem == 0); i++) {
  784. if (chartOptionsComboBoxes["label_font"].getItem(i).text == option.getAttribute("font"))
  785. selectedItem = i;
  786. }
  787. if (chartOptionsComboBoxes["label_font"].numItems())
  788. chartOptionsComboBoxes["label_font"].setSelectedItem(selectedItem);
  789. var fontSizeItem = 0;
  790. switch (parseInt(option.getAttribute("fontSize"))) {
  791. case 0: fontSizeItem = 0; break;
  792. case 4: fontSizeItem = 1; break;
  793. case 6: fontSizeItem = 2; break;
  794. case 7: fontSizeItem = 3; break;
  795. case 8: fontSizeItem = 4; break;
  796. case 9: fontSizeItem = 5; break;
  797. case 10: fontSizeItem = 6; break;
  798. case 11: fontSizeItem = 7; break;
  799. case 12: fontSizeItem = 8; break;
  800. case 13: fontSizeItem = 9; break;
  801. case 14: fontSizeItem = 10; break;
  802. case 15: fontSizeItem = 11; break;
  803. case 16: fontSizeItem = 12; break;
  804. case 18: fontSizeItem = 13; break;
  805. case 20: fontSizeItem = 14; break;
  806. }
  807. chartOptionsComboBoxes["label_size"].setSelectedItem(fontSizeItem);
  808. setColorPicker("label_color",option.getAttribute("color"));
  809. if(fontArray.length)
  810. updateFontOptsButtons();
  811. updateLabelPreview();
  812. if (option.getAttribute("optionName") == "COL_HL") { //Only if this is the horizontal axis labels
  813. document.getElementById("LabelPermissionsDiv").style.visibility = "visible";
  814. } else {
  815. document.getElementById("LabelPermissionsDiv").style.visibility = "hidden";
  816. }
  817. setLabelPreviewImage();
  818. }
  819. function currentLabelChanged() {
  820. var option = document.getElementById("labelOptionsHiddenStore").childNodes[chartOptionsComboBoxes["labelSelect"].getSelectedItem()];
  821. if (chartOptionValues[option.getAttribute("optionName")].details.type == CHART_OPTION_VALUE_TITLE) {
  822. option.setAttribute("title",document.getElementById("label_text").value);
  823. option.setAttribute("isdefault",(document.getElementById("label_isDefault").checked)? "true" : "false" );
  824. }
  825. if (fontArray.length)
  826. option.setAttribute("font",chartOptionsComboBoxes["label_font"].getItem(chartOptionsComboBoxes["label_font"].getSelectedItem()).text);
  827. else
  828. option.setAttribute("font","");
  829. var fontSizes = new Array(0,4,6,7,8,9,10,11,12,13,14,15,16,18,20);
  830. option.setAttribute("fontSize",fontSizes[chartOptionsComboBoxes["label_size"].getSelectedItem()]);
  831. option.setAttribute("color",getColorPickerColor("label_color"));
  832. if(fontArray.length)
  833. updateFontOptsButtons();
  834. option.setAttribute("bold",document.getElementById("label_bold").getAttribute("pressed"));
  835. option.setAttribute("italic",document.getElementById("label_italic").getAttribute("pressed"));
  836. option.setAttribute("underline",document.getElementById("label_underlined").getAttribute("pressed"));
  837. updateLabelPreview();
  838. }
  839. function selectCustomTitleOption() {
  840. if (!document.getElementById("label_notDefault").checked) {
  841. document.getElementById("label_notDefault").checked = true;
  842. document.getElementById("label_isDefault").checked = false;
  843. }
  844. }
  845. function updateLabelPreview() {
  846. var preview = document.getElementById("label_preview");
  847. var option = document.getElementById("labelOptionsHiddenStore").childNodes[chartOptionsComboBoxes["labelSelect"].getSelectedItem()];
  848. preview.style.fontFamily = option.getAttribute("font");
  849. preview.style.color = "#" + option.getAttribute("color");
  850. (option.getAttribute("bold") == "true")? preview.style.fontWeight = "bold" : preview.style.fontWeight = "normal" ;
  851. (option.getAttribute("italic") == "true")? preview.style.fontStyle = "italic" : preview.style.fontStyle = "normal" ;
  852. (option.getAttribute("underline") == "true")? preview.style.textDecoration = "underline" : preview.style.textDecoration = "none" ;
  853. }
  854. function updateFontOptsButtons() {
  855. var fontNo = chartOptionsComboBoxes["label_font"].getSelectedItem();
  856. var bold_button = document.getElementById("label_bold");
  857. var italic_button = document.getElementById("label_italic");
  858. //First check the case that the font is set to both Bold and Italics
  859. if (bold_button.getAttribute("pressed") == "true" && italic_button.getAttribute("pressed") == "true") {
  860. if (!fontArray[fontNo].bolditalic) {
  861. //This font can't be both bold and italics, so if it can be bold simply unpress the italics
  862. //Button and fall through the bold button check.
  863. if (fontArray[fontNo].bold) {
  864. setItalicButtonEnabling(false);
  865. setButtonState(italic_button,false);
  866. } else {
  867. //Otherwise try disabling the Bold button, if the italics button
  868. //also needs disabling, it will be handled by the italics only if statement below.
  869. setBoldButtonEnabling(false);
  870. setButtonState(bold_button,false);
  871. }
  872. }
  873. }
  874. if (bold_button.getAttribute("pressed") == "true" && italic_button.getAttribute("pressed") != "true") {
  875. //Bold button is pressed, but the italics one isn't
  876. if (!fontArray[fontNo].bold) {
  877. //We can't be bold so unpress the button.
  878. setBoldButtonEnabling(false);
  879. setButtonState(bold_button,false);
  880. } else {
  881. //Set the italics buttons enabling appropriately.
  882. setItalicButtonEnabling(fontArray[fontNo].bolditalic);
  883. }
  884. }
  885. if (bold_button.getAttribute("pressed") != "true" && italic_button.getAttribute("pressed") == "true") {
  886. //Italics button is pressed, but the bold one isn't
  887. if (!fontArray[fontNo].italic) {
  888. //We can't be italisized so unpress the button.
  889. setItalicButtonEnabling(false);
  890. setButtonState(italic_button,false);
  891. } else {
  892. //Set the bold buttons enabling appropriately.
  893. setBoldButtonEnabling(fontArray[fontNo].bolditalic);
  894. }
  895. }
  896. if (bold_button.getAttribute("pressed") != "true" && italic_button.getAttribute("pressed") != "true") {
  897. //Neither button is pushed, so just set their enabling approriately.
  898. setBoldButtonEnabling(fontArray[fontNo].bold);
  899. setItalicButtonEnabling(fontArray[fontNo].italic);
  900. }
  901. }
  902. function setBoldButtonEnabling(enabled) {
  903. var button = document.getElementById("label_bold");
  904. if (enabled) {
  905. button.setAttribute("isdisabled","false");
  906. button.src = genericIconPath + "button_bold.gif";
  907. } else {
  908. button.setAttribute("isdisabled","true");
  909. button.src = genericIconPath + "button_bold_no.gif";
  910. }
  911. }
  912. function setItalicButtonEnabling(enabled) {
  913. var button = document.getElementById("label_italic");
  914. if (enabled) {
  915. button.setAttribute("isdisabled","false");
  916. button.src = genericIconPath + "button_italics.gif";
  917. } else {
  918. button.setAttribute("isdisabled","true");
  919. button.src = genericIconPath + "button_italics_no.gif";
  920. }
  921. }
  922. function chartDepthChanged() {
  923. var depthCheck = chartOptionValues["COGCB_UD"];
  924. var barStyle = chartOptionValues["COGCB_S"];
  925. var showMarkers = chartOptionValues["COGCL_SM"];
  926. if (depthCheck && barStyle) {
  927. barStyle.control.disabled = depthCheck.control.checked;
  928. }
  929. if (depthCheck && showMarkers) {
  930. showMarkers.control.disabled = depthCheck.control.checked;
  931. }
  932. }
  933. function getNonLocalizedDecimalVal(val) {
  934. return val.replace(decimalpt,'.');
  935. }
  936. function validatePercentageOfScreenValue(elem) {
  937. var validChars = "/[^0-9" + decimalpt + "\-]/";
  938. if (elem) {
  939. var elemValue = parseFloat(getNonLocalizedDecimalVal(elem.value));
  940. if (isNaN(elemValue))
  941. return false;
  942. if ((!CNumUtil.validateNumField(elem, true, validChars)) || (elemValue < PERCENTAGE_SCREEN_MIN_VALUE) || (elemValue > PERCENTAGE_SCREEN_MAX_VALUE))
  943. return false
  944. elem.value = elemValue;
  945. }
  946. return true;
  947. }
  948. function validateManualScaleValue(elem) {
  949. var validChars = "/[^0-9" + decimalpt + "\-]/";
  950. if (elem) {
  951. var elemValue = parseFloat(getNonLocalizedDecimalVal(elem.value));
  952. if (isNaN(elemValue))
  953. return false;
  954. if (!CNumUtil.validateNumField(elem, true, validChars))
  955. return false
  956. elem.value = elemValue;
  957. }
  958. return true;
  959. }
  960. function validateNumTicksValue(elem) {
  961. var validChars = "/[^0-9\-]/";
  962. if (elem) {
  963. var elemValue = parseInt(getNonLocalizedDecimalVal(elem.value));
  964. if (isNaN(elemValue))
  965. return false;
  966. if (!CNumUtil.validateNumField(elem, true, validChars))
  967. return false
  968. elem.value = elemValue;
  969. }
  970. return true;
  971. }
  972. function validateScaleFactorValue(elem) {
  973. var validChars = "/[^0-9\-]/";
  974. if (elem) {
  975. var elemValue = parseInt(getNonLocalizedDecimalVal(elem.value));
  976. if (isNaN(elemValue) || (elemValue == 0))
  977. return false;
  978. if (!CNumUtil.validateNumField(elem, true, validChars))
  979. return false
  980. elem.value = elemValue;
  981. }
  982. return true;
  983. }
  984. function validateFields(closePane) {
  985. if (chartOptionValues["COGC_FTP"]) {
  986. if (chartOptionValues["COGC_FTP"].control.checked) {
  987. var isValid = true;
  988. if (chartOptionValues["COGC_FTPW"] && chartOptionValues["COGC_FTPW"].control) {
  989. isValid = validatePercentageOfScreenValue(chartOptionValues["COGC_FTPW"].control);
  990. }
  991. if (isValid && chartOptionValues["COGC_FTPH"] && chartOptionValues["COGC_FTPH"].control) {
  992. isValid = validatePercentageOfScreenValue(chartOptionValues["COGC_FTPH"].control);
  993. }
  994. if (!isValid) {
  995. displayCommonMessage(strErrorMessageBadValue, MESSAGE_TYPE_INFO, [strColorPickerOK], [function() {removeMessage();}]);
  996. return false;
  997. }
  998. } else {
  999. chartOptionValues["COGC_FTPW"].control.value = chartOptionValues["COGC_FTPW"].details.value;
  1000. chartOptionValues["COGC_FTPH"].control.value = chartOptionValues["COGC_FTPH"].details.value;
  1001. }
  1002. }
  1003. if (chartOptionValues["COA_MS"]) {
  1004. if (chartOptionValues["COA_MS"].control.checked) {
  1005. var isValid = true;
  1006. if (chartOptionValues["COA_MSI"] && chartOptionValues["COA_MSI"].control) {
  1007. isValid = validateManualScaleValue(chartOptionValues["COA_MSI"].control);
  1008. }
  1009. if (isValid && chartOptionValues["COA_MSA"] && chartOptionValues["COA_MSA"].control) {
  1010. isValid = validateManualScaleValue(chartOptionValues["COA_MSA"].control);
  1011. }
  1012. if (isValid && (parseFloat(chartOptionValues["COA_MSI"].control.value) > parseFloat(chartOptionValues["COA_MSA"].control.value)))
  1013. isValid = false;
  1014. if (!isValid) {
  1015. displayCommonMessage(strErrorMessageBadScaleValue, MESSAGE_TYPE_INFO, [strColorPickerOK], [function() {removeMessage();}]);
  1016. return false;
  1017. }
  1018. } else {
  1019. chartOptionValues["COA_MSI"].control.value = chartOptionValues["COA_MSI"].details.value;
  1020. chartOptionValues["COA_MSA"].control.value = chartOptionValues["COA_MSA"].details.value;
  1021. }
  1022. }
  1023. if (chartOptionValues["COA_MS2"]) {
  1024. if (chartOptionValues["COA_MS2"].control.checked) {
  1025. var isValid = true;
  1026. if (chartOptionValues["COA_MSI2"] && chartOptionValues["COA_MSI2"].control) {
  1027. isValid = validateManualScaleValue(chartOptionValues["COA_MSI2"].control);
  1028. }
  1029. if (isValid && chartOptionValues["COA_MSA2"] && chartOptionValues["COA_MSA2"].control) {
  1030. isValid = validateManualScaleValue(chartOptionValues["COA_MSA2"].control);
  1031. }
  1032. if (isValid && (parseFloat(chartOptionValues["COA_MSI2"].control.value) > parseFloat(chartOptionValues["COA_MSA2"].control.value)))
  1033. isValid = false;
  1034. if (!isValid) {
  1035. displayCommonMessage(strErrorMessageBadScaleValue, MESSAGE_TYPE_INFO, [strColorPickerOK], [function() {removeMessage();}]);
  1036. return false;
  1037. }
  1038. } else {
  1039. chartOptionValues["COA_MSI2"].control.value = chartOptionValues["COA_MSI2"].details.value;
  1040. chartOptionValues["COA_MSA2"].control.value = chartOptionValues["COA_MSA2"].details.value;
  1041. }
  1042. }
  1043. if (chartOptionValues["COA_AT"]) {
  1044. if (chartOptionValues["COA_AT"].control.checked) {
  1045. var isValid = true;
  1046. if (chartOptionValues["COA_NT"] && chartOptionValues["COA_NT"].control) {
  1047. isValid = validateNumTicksValue(chartOptionValues["COA_NT"].control);
  1048. }
  1049. if (!isValid) {
  1050. displayCommonMessage(strErrorMessageBadNumTicks, MESSAGE_TYPE_INFO, [strColorPickerOK], [function() {removeMessage();}]);
  1051. return false;
  1052. }
  1053. } else {
  1054. chartOptionValues["COA_NT"].control.value = chartOptionValues["COA_NT"].details.value;
  1055. }
  1056. }
  1057. if (chartOptionValues["COA_AT2"]) {
  1058. if (chartOptionValues["COA_AT2"].control.checked) {
  1059. var isValid = true;
  1060. if (chartOptionValues["COA_NT2"] && chartOptionValues["COA_NT2"].control) {
  1061. isValid = validateNumTicksValue(chartOptionValues["COA_NT2"].control);
  1062. }
  1063. if (!isValid) {
  1064. displayCommonMessage(strErrorMessageBadNumTicks, MESSAGE_TYPE_INFO, [strColorPickerOK], [function() {removeMessage();}]);
  1065. return false;
  1066. }
  1067. } else {
  1068. chartOptionValues["COA_NT2"].control.value = chartOptionValues["COA_NT2"].details.value;
  1069. }
  1070. }
  1071. if (chartOptionValues["COL_LL"] && isOptionChanged("COL_LL")) {
  1072. if (document.getElementById("COGC_HL") && document.getElementById("COGC_HL").checked) {
  1073. if (closePane)
  1074. displayCommonMessage(strErrorNotEmbeddedLegend, MESSAGE_TYPE_INFO, [strColorPickerOK,strColorPickerCancel], [function () {applyOptions(true,true);},function() {removeMessage();}]);
  1075. else
  1076. displayCommonMessage(strErrorNotEmbeddedLegend, MESSAGE_TYPE_INFO, [strColorPickerOK,strColorPickerCancel], [function () {applyOptions(false,true);},function() {removeMessage();}]);
  1077. return false;
  1078. }
  1079. }
  1080. if (chartOptionValues["COA_MSF"] && chartOptionValues["COA_SF"]) {
  1081. if (chartOptionValues["COA_MSF"].control.checked) {
  1082. if (!validateScaleFactorValue(chartOptionValues["COA_SF"].control)) {
  1083. displayCommonMessage(strErrorBadScalingFactor, MESSAGE_TYPE_INFO, [strColorPickerOK], [function () {removeMessage();}]);
  1084. return false;
  1085. }
  1086. } else {
  1087. chartOptionValues["COA_SF"].control.value = chartOptionValues["COA_SF"].details.value;
  1088. }
  1089. }
  1090. if (chartOptionValues["COA_MSF2"] && chartOptionValues["COA_SF2"]) {
  1091. if (chartOptionValues["COA_MSF2"].control.checked) {
  1092. if (!validateScaleFactorValue(chartOptionValues["COA_SF2"].control)) {
  1093. displayCommonMessage(strErrorBadScalingFactor, MESSAGE_TYPE_INFO, [strColorPickerOK], [function () {removeMessage();}]);
  1094. return false;
  1095. }
  1096. } else {
  1097. chartOptionValues["COA_SF2"].control.value = chartOptionValues["COA_SF2"].details.value;
  1098. }
  1099. }
  1100. return true;
  1101. }
  1102. function resetWidthByBorderAmount(obj,intendedSize) {
  1103. if (obj) {
  1104. if (parseInt(obj.offsetWidth) > intendedSize) {
  1105. obj.style.width = intendedSize - (parseInt(obj.offsetWidth) - intendedSize);
  1106. }
  1107. }
  1108. }
  1109. //this function ensures that the user cannot select the same location for both the
  1110. //Value and Pie label on the pie chart.
  1111. function pieLabelOptionsChanged(event) {
  1112. var eventM = null;
  1113. if (event)
  1114. eventM = new eventManager(event);
  1115. var check_a = chartOptionValues["COP_VP"].control;
  1116. var rad1_a = check_a.parentNode.parentNode.nextSibling.firstChild.nextSibling.firstChild.nextSibling;
  1117. var rad2_a = rad1_a.parentNode.parentNode.nextSibling.firstChild.nextSibling.firstChild.nextSibling;
  1118. var check_b = chartOptionValues["COP_LP"].control;
  1119. var rad1_b = check_b.parentNode.parentNode.nextSibling.firstChild.nextSibling.firstChild.nextSibling;
  1120. var rad2_b = rad1_b.parentNode.parentNode.nextSibling.firstChild.nextSibling.firstChild.nextSibling;
  1121. rad1_b.disabled = false;
  1122. rad2_b.disabled = false;
  1123. rad1_a.disabled = false;
  1124. rad2_a.disabled = false;
  1125. if (check_a.checked && check_b.checked) {
  1126. if (eventM && eventM.getSrc().getAttribute("optionName") == "COP_LP") {
  1127. if (rad1_b.checked) {
  1128. rad1_a.disabled = true;
  1129. rad2_b.disabled = true;
  1130. rad1_a.checked = false;
  1131. rad2_a.checked = true;
  1132. } else {
  1133. rad2_a.disabled = true;
  1134. rad1_b.disabled = true;
  1135. rad2_a.checked = false;
  1136. rad1_a.checked = true;
  1137. }
  1138. } else {
  1139. if (rad1_a.checked) {
  1140. rad1_b.disabled = true;
  1141. rad2_a.disabled = true;
  1142. rad1_b.checked = false;
  1143. rad2_b.checked = true;
  1144. } else {
  1145. rad2_b.disabled = true;
  1146. rad1_a.disabled = true;
  1147. rad2_b.checked = false;
  1148. rad1_b.checked = true;
  1149. }
  1150. }
  1151. }
  1152. }