diff options
author | randommonk <randommonk@gmail.com> | 2018-01-04 22:52:54 +0000 |
---|---|---|
committer | randommonk <randommonk@gmail.com> | 2018-01-04 23:06:03 +0000 |
commit | dfc4e20b8e9ca57340e24143539498fb82527697 (patch) | |
tree | 50cdec1c1e650e6ca8f0d055b401b2c893e43124 /html | |
parent | 66b162b5f01c996fd8a5cd4e570e31f8483cdffa (diff) |
Bumped version to 4.3. Added jpgraph stats developed by killerEye
Diffstat (limited to 'html')
139 files changed, 75924 insertions, 15 deletions
diff --git a/html/import.php b/html/import.php index f811d92..c2bcfe6 100755 --- a/html/import.php +++ b/html/import.php @@ -740,6 +740,7 @@ $t0info, $t1info, $t2info, $t3info, $t0score, $t1score, $t2score, $t3score);"; echo "Done\n";
if ($html) echo'</td></tr>';
+ include('import/import_renderer-preconfig.php');
$updategameinfo = false;
if (count($ignored_players) > 0) {
@@ -757,6 +758,30 @@ $t0info, $t1info, $t2info, $t3info, $t0score, $t1score, $t2score, $t3score);"; mysql_query("UPDATE uts_match SET gameinfo = '$gameinfo' WHERE id = '$matchid'");
$updategameinfo = false;
}
+ if ($gamename == "Domination" || $gamename == "Domination (insta)" ) {
+ if ($html) echo '<tr><td class="smheading" align="left" width="350">';
+ echo "Generating dom graphs: ";
+ if ($html) echo '</td><td class="grey" align="left" width="200">';
+ include("import/import_renderer-dom.php");
+ echo "Done\n";
+ if ($html) echo'</td></tr>';
+ }
+ else if ($gamename == "Tournament DeathMatch" || $gamename == "Tournament DeathMatch (insta)" || $gamename == "Tournament Team Game" || $gamename == "Tournament Team Game (insta)" ) {
+ if ($html) echo '<tr><td class="smheading" align="left" width="350">';
+ echo "Generating dm graphs: ";
+ if ($html) echo '</td><td class="grey" align="left" width="200">';
+ include("import/import_renderer-dm.php");
+ echo "Done\n";
+ if ($html) echo'</td></tr>';
+ }
+ else if ($gamename == "Capture the Flag" || $gamename == "Capture the Flag (insta)" ) {
+ if ($html) echo '<tr><td class="smheading" align="left" width="350">';
+ echo "Generating ctf graphs: ";
+ if ($html) echo '</td><td class="grey" align="left" width="200">';
+ include("import/import_renderer-ctf.php");
+ echo "Done\n";
+ if ($html) echo'</td></tr>';
+ }
}
}
diff --git a/html/import/import_domscreens.php b/html/import/import_domscreens.php new file mode 100644 index 0000000..de8a379 --- /dev/null +++ b/html/import/import_domscreens.php @@ -0,0 +1,26 @@ + +<?php + include_once('includes/domstats.php'); + + $safe_uid = mysql_real_escape_string($uid); + + // Get relevant info + $playerinfo = getPlayerTeam($uid); + $playernames = $playerinfo[0]; + $playerteams = $playerinfo[1]; + + $gameinfo = getGameStartEndRatio($uid); + $time_gamestart = $gameinfo[0]; + $time_gameend = $gameinfo[1]; + $time_ratio_correction = $gameinfo[2]; + + $tableTempIdom = generateTempTable($safe_uid); + $ampTimes = generateAmpTimes($safe_uid); + renderDataTotal($safe_uid,$tableTempIdom); + renderDataCPs($safe_uid,$tableTempIdom); + renderDataPickups($safe_uid); + renderAmpBars($safe_uid,$tableTempIdom); + + // drop table + mysql_query("DROP TABLE $tableTempIdom") or die(mysql_error()); +?>
\ No newline at end of file diff --git a/html/import/import_renderer-ctf.php b/html/import/import_renderer-ctf.php new file mode 100644 index 0000000..3e49bf5 --- /dev/null +++ b/html/import/import_renderer-ctf.php @@ -0,0 +1,30 @@ + +<?php + include_once('includes/renderer-dm.php'); + include_once('includes/renderer-ctf.php'); + + // Only run script if at least 5 minutes were played + if(($time_gameend-$time_gamestart)>300 && count(array_unique($playernames))>=2) { + + try { + $safe_uid = mysql_real_escape_string($uid); + + prepCTFdata($safe_uid); + + renderScoreGraph($safe_uid); + + // Get relevant data + list($datafrags, $derivfrags, $topFraggers,$counter,$datafragsteam,$derivfragsteam,$topTeams) = parseDMdata($safe_uid); + + renderFragBarsTeams($datafragsteam,$derivfragsteam,$topTeams,$counter); + + if($playernumberofteams == 2) + renderDataPickups($safe_uid); + + } catch (Exception $e) { + + // Do nothing, but simply do not block import + + } + } +?>
\ No newline at end of file diff --git a/html/import/import_renderer-dm.php b/html/import/import_renderer-dm.php new file mode 100644 index 0000000..e680bbf --- /dev/null +++ b/html/import/import_renderer-dm.php @@ -0,0 +1,31 @@ + +<?php + include_once('includes/renderer-dm.php'); + + + // Only run script if at least 5 minutes were played + if(($time_gameend-$time_gamestart)>300 && count(array_unique($playernames))>=2) { + + try { + $safe_uid = mysql_real_escape_string($uid); + + // Get relevant data + list($datafrags, $derivfrags, $topFraggers,$counter,$datafragsteam,$derivfragsteam,$topTeams) = parseDMdata($safe_uid); + + if($playernumberofteams > 1 && count(array_unique($playernames)) > 3 &&($gamename == "Tournament Team Game" || $gamename == "Tournament Team Game (insta)" || $gamename == "2v2v2v2 iTDM")) + renderFragBarsTeams($datafragsteam,$derivfragsteam,$topTeams,$counter); + + renderFragBars($datafrags, $derivfrags, $topFraggers,$counter); + + if(count($playernames) == 2) + renderDataPickups($safe_uid,false,($playerteams[$topFraggers[0]]==0),$topFraggers); + else if($playernumberofteams == 2) + renderDataPickups($safe_uid); + + } catch (Exception $e) { + + // Do nothing, but simply do not block import + + } + } +?>
\ No newline at end of file diff --git a/html/import/import_renderer-dom.php b/html/import/import_renderer-dom.php new file mode 100644 index 0000000..d680d49 --- /dev/null +++ b/html/import/import_renderer-dom.php @@ -0,0 +1,32 @@ + +<?php + include_once('includes/renderer-dom.php'); + include_once('includes/renderer-dm.php'); + + // Only run script if at least 5 minutes were played + if(($time_gameend-$time_gamestart)>300 && count(array_unique($playernames))>=8) { + + $tableTempIdom = generateTempTable($safe_uid); + $ampTimes = generateAmpTimes($safe_uid); + + try { + + renderDataTotal($safe_uid,$tableTempIdom); + renderDataCPs($safe_uid,$tableTempIdom); + + renderDataPickups($safe_uid); + renderAmpBars($safe_uid,$tableTempIdom); + + list($datafrags, $derivfrags, $topFraggers,$counter,$datafragsteam,$derivfragsteam,$topTeams) = parseDMdata($safe_uid); + renderFragBarsTeams($datafragsteam,$derivfragsteam,$topTeams,$counter); + + } catch (Exception $e) { + + // Do nothing, but simply do not block import + + } + + // drop table + mysql_query("DROP TABLE $tableTempIdom") or die(mysql_error()); + } +?>
\ No newline at end of file diff --git a/html/import/import_renderer-preconfig.php b/html/import/import_renderer-preconfig.php new file mode 100644 index 0000000..bb83526 --- /dev/null +++ b/html/import/import_renderer-preconfig.php @@ -0,0 +1,17 @@ +<?php + require_once 'includes/renderer-general-import.php'; + + $safe_uid = mysql_real_escape_string($uid); + + // Get relevant info + $playerinfo = getPlayerTeam($uid); + $playernames = $playerinfo[0]; + $playerteams = $playerinfo[1]; + $playernumberofteams = $playerinfo[2]; + + $time_gameinfo = getGameStartEndRatio($uid); + $time_gamestart = $time_gameinfo[0]; + $time_gameend = $time_gameinfo[1]; + $time_ratio_correction = $time_gameinfo[2]; + +?>
\ No newline at end of file diff --git a/html/includes/config.php b/html/includes/config.php index 7b086f6..2e52f98 100755 --- a/html/includes/config.php +++ b/html/includes/config.php @@ -16,7 +16,8 @@ $import_homedir = ''; // Use the MySQL temporary tables feature?
// Available since MySQL 3.23 - requires CREATE TEMPORARY TABLE privilege since 4.0.2
-$import_use_temporary_tables = true; // set to true if available
+// No longer supported from utstats version 4.3 onwards. Left here for historical purposes.
+$import_use_temporary_tables = false; // Do not set to true unless all jpgraph import changes have been disabled.
// Use temporary heap tables?
// This will (at any cost) keep the entire table in RAM and may speed and/or fuck things up
@@ -183,4 +184,62 @@ $ftp_passive[$i] = true; // Use passive transfer mode for this connection? $ftp_delete[$i] = true; // Delete logs after download?
*/
+// This section is for stats graphs as of version 4.3
+$renderer_folder = "renderings";
+$renderer_width = 350;
+$renderer_heigth = 250;
+$renderer_color['team'][0][0] = '#ff3333'; // team red color 1
+$renderer_color['team'][0][1] = '#cc0000'; // team red color 2
+$renderer_color['team'][1][0] = '#0080ff'; // team blue color 1
+$renderer_color['team'][1][1] = '#0000cc'; // team blue color 2
+$renderer_color['team'][2][0] = '#88d8b0'; // team green color 1
+$renderer_color['team'][2][1] = '#009f50'; // team green color 2
+$renderer_color['team'][3][0] = '#ffeead'; // team gold color 1
+$renderer_color['team'][3][1] = '#e5b021'; // team gold color 2
+$renderer_color['player'][0][0] = '#a7d848'; // player 1 color 1
+$renderer_color['player'][0][1] = '#98be44'; // player 1 color 2
+$renderer_color['player'][1][0] = '#6ccdd0'; // player 2 color 1
+$renderer_color['player'][1][1] = '#66af9f'; // player 2 color 2
+$renderer_color['player'][2][0] = '#ffce59'; // player 3 color 1
+$renderer_color['player'][2][1] = '#ffa65a'; // player 3 color 2
+$renderer_color['player'][3][0] = '#fba263'; // player 4 color 1
+$renderer_color['player'][3][1] = '#eb7254'; // player 4 color 2
+$renderer_color['player'][4][0] = '#fb6370 '; // player 5 color 1
+$renderer_color['player'][4][1] = '#fb6363'; // player 5 color 2
+$renderer_color['background'] = '#262626';// background color 1
+$renderer_color['band'][0] = '#666666';// band color 1
+$renderer_color['band'][1] = '#515151';// band color 2
+$renderer_color['heading'] = '#bbdeff';// font heading
+$renderer_color['font'] = '#999999';// font other
+$renderer_color['amp'] = '#aa02db';// color amp
+$renderer_color_transparancy = 0.3;// color amp
+
+define("TIMERATIO", 1.09863333333333333333333333333333333333333333333333333333333);
+
+define("RENDERER_CHARTTYPE_LINE", "line");
+define("RENDERER_CHARTTYPE_COLUMN", "column");
+define("RENDERER_CHARTTYPE_BAR", "bar");
+define("RENDERER_CHARTTYPE_LINESTEP", "linestep");
+define("RENDERER_CHARTTYPE_LINECOLUMN", "linecolumn");
+define("RENDERER_CHARTTYPE_LINESTEPCOLUMN", "linestepcolumn");
+define("RENDERER_CHARTTYPE_RADAR", "radar");
+
+define("RENDERER_CHART_CTF_TEAMSCORE", 10);
+define("RENDERER_CHART_CTF_GRABBREAKDOWN", 11);
+
+define("RENDERER_CHART_DOM_SCOREDERIV", 21);
+
+define("RENDERER_CHART_FRAGS_TEAMSCORE", 90);
+define("RENDERER_CHART_FRAGS_TEAMDERIV", 91);
+define("RENDERER_CHART_FRAGS_TEAMNORMAL", 92);
+define("RENDERER_CHART_FRAGS_PLAYERSCORE", 93);
+define("RENDERER_CHART_FRAGS_PLAYERDERIV", 94);
+define("RENDERER_CHART_FRAGS_PLAYERNORMAL", 95);
+define("RENDERER_CHART_FRAGS_PLAYERSCORE5", 96);
+define("RENDERER_CHART_FRAGS_PLAYERNORMAL5", 97);
+
+define("RENDERER_CHART_ITEMS_TEAMPICKUPS", 100);
+define("RENDERER_CHART_ITEMS_PLAYERPICKUPS", 101);
+define("RENDERER_CHART_ITEMS_AMPRUNS", 102);
+
?>
diff --git a/html/includes/css/themes/tooltipster-light.css b/html/includes/css/themes/tooltipster-light.css new file mode 100644 index 0000000..945aa69 --- /dev/null +++ b/html/includes/css/themes/tooltipster-light.css @@ -0,0 +1,12 @@ +.tooltipster-light { + border-radius: 5px; + border: 1px solid #cccccc; + background: #ededed; + color: #666666; +} +.tooltipster-light .tooltipster-content { + font-family: Arial, sans-serif; + font-size: 14px; + line-height: 16px; + padding: 8px 10px; +}
\ No newline at end of file diff --git a/html/includes/css/themes/tooltipster-noir.css b/html/includes/css/themes/tooltipster-noir.css new file mode 100644 index 0000000..548b245 --- /dev/null +++ b/html/includes/css/themes/tooltipster-noir.css @@ -0,0 +1,12 @@ +.tooltipster-noir { + border-radius: 0px; + border: 3px solid #2c2c2c; + background: #fff; + color: #2c2c2c; +} +.tooltipster-noir .tooltipster-content { + font-family: 'Georgia', serif; + font-size: 14px; + line-height: 16px; + padding: 8px 10px; +}
\ No newline at end of file diff --git a/html/includes/css/themes/tooltipster-punk.css b/html/includes/css/themes/tooltipster-punk.css new file mode 100644 index 0000000..0b7362c --- /dev/null +++ b/html/includes/css/themes/tooltipster-punk.css @@ -0,0 +1,12 @@ +.tooltipster-punk { + border-radius: 5px; + border-bottom: 3px solid #f71169; + background: #2a2a2a; + color: #fff; +} +.tooltipster-punk .tooltipster-content { + font-family: 'Courier', monospace; + font-size: 14px; + line-height: 16px; + padding: 8px 10px; +}
\ No newline at end of file diff --git a/html/includes/css/themes/tooltipster-shadow.css b/html/includes/css/themes/tooltipster-shadow.css new file mode 100644 index 0000000..e869c5e --- /dev/null +++ b/html/includes/css/themes/tooltipster-shadow.css @@ -0,0 +1,12 @@ +.tooltipster-shadow { + border-radius: 5px; + background: #fff; + box-shadow: 0px 0px 14px rgba(0,0,0,0.3); + color: #2c2c2c; +} +.tooltipster-shadow .tooltipster-content { + font-family: 'Arial', sans-serif; + font-size: 14px; + line-height: 16px; + padding: 8px 10px; +}
\ No newline at end of file diff --git a/html/includes/css/tooltipster.css b/html/includes/css/tooltipster.css new file mode 100644 index 0000000..14c70d0 --- /dev/null +++ b/html/includes/css/tooltipster.css @@ -0,0 +1,283 @@ +/* This is the default Tooltipster theme (feel free to modify or duplicate and create multiple themes!): */ +.tooltipster-default { + border-radius: 5px; + border: 1px solid #1e1e1e; + background: -webkit-linear-gradient(#3b383b, #1e1e1e); /* For Safari 5.1 to 6.0 */ + background: -o-linear-gradient(#3b383b, #1e1e1e); /* For Opera 11.1 to 12.0 */ + background: -moz-linear-gradient(#3b383b, #1e1e1e); /* For Firefox 3.6 to 15 */ + background: linear-gradient(#3b383b, #1e1e1e); /* Standard syntax */ + color: #fff; + cursor: pointer; + -webkit-box-shadow: 10px 10px 26px -10px rgba(0,0,0,0.75); + -moz-box-shadow: 10px 10px 26px -10px rgba(0,0,0,0.75); + box-shadow: 10px 10px 26px -10px rgba(0,0,0,0.75); + max-width: 400px; +} + +/* Use this next selector to style things like font-size and line-height: */ +.tooltipster-default .tooltipster-content { + font-family: GothamLight, sans-serif; + font-size: 14px; + line-height: 16px; + padding: 8px 10px; + overflow: hidden; +} + +/* This next selector defines the color of the border on the outside of the arrow. This will automatically match the color and size of the border set on the main tooltip styles. Set display: none; if you would like a border around the tooltip but no border around the arrow */ +.tooltipster-default .tooltipster-arrow .tooltipster-arrow-border { + /* border-color: ... !important; */ +} + + +/* If you're using the icon option, use this next selector to style them */ +.tooltipster-icon { + cursor: pointer; + margin-left: 4px; +} + + + + + + + + +/* This is the base styling required to make all Tooltipsters work */ +.tooltipster-base { + padding: 0; + font-size: 0; + line-height: 0; + position: absolute; + left: 0; + top: 0; + z-index: 9999999; + pointer-events: none; + width: auto; + overflow: visible; + +} +.tooltipster-base .tooltipster-content { + overflow: hidden; +} + + +/* These next classes handle the styles for the little arrow attached to the tooltip. By default, the arrow will inherit the same colors and border as what is set on the main tooltip itself. */ +.tooltipster-arrow { + display: block; + text-align: center; + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + z-index: -1; +} +.tooltipster-arrow span, .tooltipster-arrow-border { + display: block; + width: 0; + height: 0; + position: absolute; +} +.tooltipster-arrow-top span, .tooltipster-arrow-top-right span, .tooltipster-arrow-top-left span { + border-left: 8px solid transparent !important; + border-right: 8px solid transparent !important; + border-top: 8px solid; + bottom: -7px; +} +.tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-top-left .tooltipster-arrow-border { + border-left: 9px solid transparent !important; + border-right: 9px solid transparent !important; + border-top: 9px solid; + bottom: -7px; +} + +.tooltipster-arrow-bottom span, .tooltipster-arrow-bottom-right span, .tooltipster-arrow-bottom-left span { + border-left: 8px solid transparent !important; + border-right: 8px solid transparent !important; + border-bottom: 8px solid; + top: -7px; +} +.tooltipster-arrow-bottom .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border { + border-left: 9px solid transparent !important; + border-right: 9px solid transparent !important; + border-bottom: 9px solid; + top: -7px; +} +.tooltipster-arrow-top span, .tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-bottom span, .tooltipster-arrow-bottom .tooltipster-arrow-border { + left: 0; + right: 0; + margin: 0 auto; +} +.tooltipster-arrow-top-left span, .tooltipster-arrow-bottom-left span { + left: 6px; +} +.tooltipster-arrow-top-left .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border { + left: 5px; +} +.tooltipster-arrow-top-right span, .tooltipster-arrow-bottom-right span { + right: 6px; +} +.tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border { + right: 5px; +} +.tooltipster-arrow-left span, .tooltipster-arrow-left .tooltipster-arrow-border { + border-top: 8px solid transparent !important; + border-bottom: 8px solid transparent !important; + border-left: 8px solid; + top: 50%; + margin-top: -7px; + right: -7px; +} +.tooltipster-arrow-left .tooltipster-arrow-border { + border-top: 9px solid transparent !important; + border-bottom: 9px solid transparent !important; + border-left: 9px solid; + margin-top: -8px; +} +.tooltipster-arrow-right span, .tooltipster-arrow-right .tooltipster-arrow-border { + border-top: 8px solid transparent !important; + border-bottom: 8px solid transparent !important; + border-right: 8px solid; + top: 50%; + margin-top: -7px; + left: -7px; +} +.tooltipster-arrow-right .tooltipster-arrow-border { + border-top: 9px solid transparent !important; + border-bottom: 9px solid transparent !important; + border-right: 9px solid; + margin-top: -8px; +} + + +/* Some CSS magic for the awesome animations - feel free to make your own custom animations and reference it in your Tooltipster settings! */ + +.tooltipster-fade { + opacity: 0; + -webkit-transition-property: opacity; + -moz-transition-property: opacity; + -o-transition-property: opacity; + -ms-transition-property: opacity; + transition-property: opacity; +} +.tooltipster-fade-show { + opacity: 1; +} + +.tooltipster-grow { + -webkit-transform: scale(0,0); + -moz-transform: scale(0,0); + -o-transform: scale(0,0); + -ms-transform: scale(0,0); + transform: scale(0,0); + -webkit-transition-property: -webkit-transform; + -moz-transition-property: -moz-transform; + -o-transition-property: -o-transform; + -ms-transition-property: -ms-transform; + transition-property: transform; + -webkit-backface-visibility: hidden; +} +.tooltipster-grow-show { + -webkit-transform: scale(1,1); + -moz-transform: scale(1,1); + -o-transform: scale(1,1); + -ms-transform: scale(1,1); + transform: scale(1,1); + -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); +} + +.tooltipster-swing { + opacity: 0; + -webkit-transform: rotateZ(4deg); + -moz-transform: rotateZ(4deg); + -o-transform: rotateZ(4deg); + -ms-transform: rotateZ(4deg); + transform: rotateZ(4deg); + -webkit-transition-property: -webkit-transform, opacity; + -moz-transition-property: -moz-transform; + -o-transition-property: -o-transform; + -ms-transition-property: -ms-transform; + transition-property: transform; +} +.tooltipster-swing-show { + opacity: 1; + -webkit-transform: rotateZ(0deg); + -moz-transform: rotateZ(0deg); + -o-transform: rotateZ(0deg); + -ms-transform: rotateZ(0deg); + transform: rotateZ(0deg); + -webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 1); + -webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4); + -moz-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4); + -ms-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4); + -o-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4); + transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4); +} + +.tooltipster-fall { + top: 0; + -webkit-transition-property: top; + -moz-transition-property: top; + -o-transition-property: top; + -ms-transition-property: top; + transition-property: top; + -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); +} +.tooltipster-fall-show { +} +.tooltipster-fall.tooltipster-dying { + -webkit-transition-property: all; + -moz-transition-property: all; + -o-transition-property: all; + -ms-transition-property: all; + transition-property: all; + top: 0px !important; + opacity: 0; +} + +.tooltipster-slide { + left: -40px; + -webkit-transition-property: left; + -moz-transition-property: left; + -o-transition-property: left; + -ms-transition-property: left; + transition-property: left; + -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); + transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15); +} +.tooltipster-slide.tooltipster-slide-show { +} +.tooltipster-slide.tooltipster-dying { + -webkit-transition-property: all; + -moz-transition-property: all; + -o-transition-property: all; + -ms-transition-property: all; + transition-property: all; + left: 0px !important; + opacity: 0; +} + + +/* CSS transition for when contenting is changing in a tooltip that is still open. The only properties that will NOT transition are: width, height, top, and left */ +.tooltipster-content-changing { + opacity: 0.5; + -webkit-transform: scale(1.1, 1.1); + -moz-transform: scale(1.1, 1.1); + -o-transform: scale(1.1, 1.1); + -ms-transform: scale(1.1, 1.1); + transform: scale(1.1, 1.1); +} diff --git a/html/includes/domstats.php b/html/includes/domstats.php new file mode 100644 index 0000000..dbdd3f7 --- /dev/null +++ b/html/includes/domstats.php @@ -0,0 +1,719 @@ +<?php +require_once 'jpgraph/jpgraph.php'; +require_once 'jpgraph/jpgraph_scatter.php'; +require_once 'jpgraph/jpgraph_mgraph.php'; +require_once 'jpgraph/jpgraph_bar.php'; +require_once 'jpgraph/jpgraph_line.php'; +require_once 'jpgraph/jpgraph_radar.php'; + +/* +Retrieve player names & player teams +Pretty much utstats code re-used +@return $playernames, $playerteams (arrays based on pid) +*/ +function getPlayerTeam($uid) { + + $playernames = array(); + $playerteams = array(); + + // Get List of Player IDs and Process What They Have Done + $sql_player = "SELECT DISTINCT col4 FROM uts_temp_$uid WHERE col1 = 'player' AND col2 = 'rename' AND col4 <> ''"; + $q_player = mysql_query($sql_player) or die(mysql_error()); + + while ($r_player = mysql_fetch_array($q_player)) { + $playerid = $r_player[col4]; + + // Get players last name used + $r_player2 = small_query("SELECT col3 FROM uts_temp_$uid WHERE col1 = 'player' AND col2 = 'rename' AND col4 = $playerid ORDER BY id DESC LIMIT 0,1"); + $playername = addslashes($r_player2[col3]); + + // Get players last team + $r_player3 = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'player' AND col2 = 'TeamChange' AND col3 = $playerid AND col4 != 255 ORDER BY id DESC LIMIT 0,1"); + $playerteam = $r_player3[col4]; + + $playernames[$playerid] = $playername; + $playerteams[$playerid] = $playerteam; + } + + return array($playernames,$playerteams); + +} + +/* +Get time game starts, game ends, and ratio compared to real time +@return $time_gamestart, $time_gameend, $time_ratio_correction (difference in ut time & real time, typically 110%) +*/ +function getGameStartEndRatio($uid) { + + // gather game start & end time + $q_logdom = mysql_query("SELECT col0 FROM uts_temp_$uid WHERE col1='game_start' OR col1='game_end' ORDER BY id ASC")or die(mysql_error()); + + $time_gamestart = mysql_result($q_logdom,0); + $time_gameend = mysql_result($q_logdom,1); + $time_ratio_correction = ($time_gameend-$time_gamestart)/1200; + + return array($time_gamestart, $time_gameend, $time_ratio_correction); +} + +/* +Helper function to create the temporary table used for dom stats +*/ +function createEmptyTempTable($table_name) { + + $sqlCreateTable = " + CREATE TEMPORARY TABLE `$table_name` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cp` varchar(254) NOT NULL, + `teamid` int(11) NOT NULL, + `playerid` int(11) NOT NULL, + `playername` varchar(254) NOT NULL, + `start` float NOT NULL, + `end` float NOT NULL, + `time` float NOT NULL, + `scoret0` float NOT NULL, + `scoret1` float NOT NULL, + `realTimeEnd` float NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM + "; + mysql_query($sqlCreateTable) or die(mysql_error()); +} + +/* +Create & populate the dom stats table +@return name of temporary table +*/ +function generateTempTable($uid) { + global $playernames; + global $playerteams; + global $time_gamestart; + global $time_gameend; + global $time_ratio_correction; + + $tempTableName = "uts_tempidom_".$uid; + + createEmptyTempTable($tempTableName); + + // iterate over cp's. also capture game-end event as a quick hack to also do final iteration over final cp + $q_logdom = mysql_query("SELECT * FROM uts_temp_$uid WHERE col1='controlpoint_capture' OR col1='game_end' ORDER BY col1, col2, id ASC")or die(mysql_error()); + + $prev_time = 0; + + // dynamicly create insert query to populate the table in 1 go, instead of multiple database calls + $insertQuery = "INSERT INTO $tempTableName (cp, teamid, playerid, playername, start, end, time,scoret0,scoret1,realTimeEnd) VALUES"; + + // basically loop over all capture events per CP. Each time calculate how long the previous owner had the point and translate this to dom points + while($r_logdom = mysql_fetch_array($q_logdom)) { + $points[0] = 0; + $points[1] = 0; + $ticks[0] = 0; + $ticks[1] = 0; + + $start_time = $prev_time; + + $r_cp = $r_logdom['col2']; + $r_time = $r_logdom['col0']; + + // skip first capture event - no dom points given at start of map since no-one has cp + if($prev_time > 0) { + + // if switching to other cp + if($prev_cp != $r_cp) { + $end_time = $time_gameend; // take game end time to calculate time cp was taken, since it's the last time it's taken + extra tick for end time + + } else { + $end_time = $r_time; + } + + $time_diff = ($end_time - $start_time); + + // point has to be yours for at least a second before it starts to add points + if($time_diff >= 1) { + + // after this second, it will start to add points during each time the timer runs (= each second) + // thus, first run of timer is ceil of start time + // also, floor of end time since having the point after the timer ran, but not until the next tick = no points + // timing in log does not account for gamespeed, typically 1.1 ratio, which is corrected in these times + // test was done to save the actual tick times based upon the dom_points stats event (happens each 5 ticks), but this doesn't result in significant better results to be worth the effort + + // save amount of timer 'ticks' that generate a score of 0.2 + $ticks[$r_teamid] = (floor($end_time/$time_ratio_correction)-ceil($start_time/$time_ratio_correction)); + + } + + // if no tick happened, insert the event with 0 points + if($ticks[$r_teamid]==0) { + + $realTimeEnd=($start_time-$time_gamestart)/$time_ratio_correction/60; + $insertQuery .= " ('$prev_cp', '$r_teamid', '$r_pid', '$r_pname', '$start_time', '$end_time', '$time_diff', '".$points[0]."', '".$points[1]."', '$realTimeEnd'),"; + + // if ticks happened, insert each seperate tick as an event + } else { + + for($i=1;($ticks[$r_teamid]+1-$i) > 0;$i++) { + + $realTimeEnd=($start_time+$time_diff/$ticks[$r_teamid]*$i-$time_gamestart)/$time_ratio_correction/60; + $points[$r_teamid] = 0.2; + + $insertQuery .= " ('$prev_cp', '$r_teamid', '$r_pid', '$r_pname', '$start_time', '$end_time', '$time_diff', '".$points[0]."', '".$points[1]."', '$realTimeEnd'),"; + + } + } + + } + + // save data for current capture event + $prev_time = $r_time; + $prev_cp = $r_cp; + + $r_event = $r_logdom['col1']; + $r_pid = $r_logdom['col3']; + $r_teamid = mysql_real_escape_string($playerteams[$r_pid]); + $r_pname = mysql_real_escape_string($playernames[$r_pid]); + + } + + // populate table + $insertQuery = rtrim($insertQuery,","); + mysql_query($insertQuery) or die(mysql_error()); + + return $tempTableName; + +} + +/* +Generate times when amp was taken +@return $amps[$team][$start_time,$end_time, $pid] +*/ +function generateAmpTimes($uid) { + global $playernames; + global $playerteams; + global $time_gamestart; + global $time_gameend; + global $time_ratio_correction; + + $amps = array(); + $prev_time = array(); + + // Get activate & deactivate times & players + $q_amps = mysql_query("SELECT col0,col1,col3 FROM uts_temp_$uid WHERE col2='Damage Amplifier' AND (col1='item_activate' OR col1='item_deactivate') ORDER BY id ASC"); + while($r_amps = mysql_fetch_array($q_amps)) { + $time = ($r_amps[0]-$time_gamestart)/$time_ratio_correction/60; + $event = $r_amps[1]; + $pid = $r_amps[2]; + + // If amp is deactivated, calculate the time it was used + if($event == "item_deactivate") { + $amps[$playerteams[$pid]][] = array($prev_time[$pid], $time,$pid); + $prev_time[$pid] = 0; + + // If amp is activated & none yet acquired, save the time of the start of this amp run + } else if($prev_time[$pid] == 0) { + $prev_time[$pid] = $time; + } + } + + return $amps; +} + +/* +Function to render the chart with amp runs +*/ +function renderAmpBars($uid,$tempTableName) { + global $playernames; + global $ampTimes; + global $matchid; + global $domimage_color; + global $domimages_folder; + global $domimage_width; + global $domimage_heigth; + + // Iterate over amp runs + for($i=0;$i<2;$i++) { + foreach ($ampTimes[$i] as $ampTaken) { + $ampStart = $ampTaken[0]; + $ampEnd = $ampTaken[1]; + $pid = $ampTaken[2]; + + // Only save amp runs longer than 20seconds + if($ampEnd > ($ampStart+.33)) { + + // Get scores during amprun + $q_scoresDuringAmp = mysql_query("SELECT SUM(scoret0),SUM(scoret1) FROM $tempTableName WHERE realTimeEnd > $ampStart AND realTimeEnd < $ampEnd"); + $r_scoresDuringAmps = mysql_fetch_array($q_scoresDuringAmp); + + $netPoints = $r_scoresDuringAmps[$i] - $r_scoresDuringAmps[1-$i]; + + // Process time for readable label + $totalTime = $ampEnd-$ampStart; + $totalTimeMinutes = floor($totalTime); + $totalTimeSeconds = round(($totalTime-$totalTimeMinutes)*60,0); + + $timeLabel = ""; + if($totalTimeMinutes>0) { $timeLabel .= $totalTimeMinutes."m"; } + if($totalTimeSeconds>0) { $timeLabel .= $totalTimeSeconds."s"; } + + $playerName = $playernames[$pid]; + + $ampRun['start'] = $ampStart; + $ampRun['label'] = substr($playerName,0,15)." (".$timeLabel.")"; + $ampRun['points'] = $netPoints; + $ampRun['team'] = $i; + + $data[] = $ampRun; + } + } + } + + if(count($data)>0) { + + // Sort ampruns not on teams, but on start time, to make sure they are plotted chronocologicstic + $data = array_sort($data,'start'); + + $maxValue=0; + // Process the ampruns to map it to 2 differnt bar plots per team + foreach ($data as $ampRun) { + $labels[] = $ampRun['label']; + $values[$ampRun['team']][] = $ampRun['points']; + + $posValue = $ampRun['points']>0? $ampRun['points'] : $ampRun['points']*-1; + + if($posValue>$maxValue) + $maxValue = $posValue; + + // Add 0 value for other team to ensure only 1 bar is plotted each time (either team 0 or team 1) + $values[1-$ampRun['team']][] = 0; + } + + $tickInterval = $maxValue>15?10:5; + $maxValue = $tickInterval*ceil($maxValue/$tickInterval); + + // Create the graph + // Some commands to enable horizontal bars & moved axis for proper formatting + $graph = new Graph($domimage_width+8,$domimage_heigth+8); + $graph->SetScale('textlin',$maxValue*-1,$maxValue); + $graph->SetTickDensity(TICKD_SPARSE); + $graph->Set90AndMargin('20','15','30','30'); + $graph->SetMarginColor($domimage_color['background']); + $graph->SetColor($domimage_color['background']); + $graph->SetFrame(true,$domimage_color['background'],0); + $graph->ygrid->SetFill(true,$domimage_color['band'][0],$domimage_color['band'][1]); + $graph->ygrid->SetColor($domimage_color['background']); + + $graph->title->Set('Net Score Amp Runs'); + $graph->title->SetFont(FF_VERDANA,FS_BOLD); + $graph->title->SetColor($domimage_color['heading']); + + $graph->xaxis->SetPos('min'); + $graph->xaxis->SetTickLabels($labels); + $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,7); + $graph->xaxis->SetColor($domimage_color['font']); + $graph->xaxis->SetLabelAlign('left','center'); + $graph->xaxis->SetColor($domimage_color['background'],$domimage_color['font']); + + $graph->yaxis->SetPos('max'); + $graph->yaxis->SetLabelAlign('center','top'); + $graph->yaxis->SetLabelSide(SIDE_RIGHT); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->scale->ticks->set($tickInterval); + $graph->yaxis->SetColor($domimage_color['background'],$domimage_color['font']); + + if(count($values[0])>0) { + $b1plot = new BarPlot($values[0]); + $graph->Add($b1plot); + $b1plot->SetFillGradient($domimage_color['team'][0][0],$domimage_color['team'][0][1],GRAD_HOR); + $b1plot->SetColor($domimage_color['team'][0][0]); + + } if(count($values[1])>0) { + $b2plot = new BarPlot($values[1]); + $graph->Add($b2plot); + $b2plot->SetFillGradient($domimage_color['team'][1][0],$domimage_color['team'][1][1],GRAD_HOR); + $b2plot->SetColor($domimage_color['team'][1][0]); + } + + $graph->Stroke($domimages_folder."/".$matchid."-ampruns.png"); + } +} + +/* +Generate the chart with pickups +*/ +function renderDataPickups($uid) { + global $matchid; + global $domimage_color; + global $domimages_folder; + global $domimage_width; + global $domimage_heigth; + + $q_pickups = mysql_query("SELECT SUM(pu_belt), SUM(pu_keg), SUM(pu_pads), SUM(pu_armour), SUM(pu_amp) FROM uts_player as p WHERE matchid = $matchid GROUP BY team") or die(mysql_error()); + + while($r_pickups = mysql_fetch_row($q_pickups)) { + $preData[] = $r_pickups; + } + + $anyPickupDone = false; + + // Process data to convert these to percentages + // Normal numbers don't plot nicely (fe. pads getting much higher pickups due to lower spawn time + for($i=0;$i<5;$i++) { + if($preData[0][$i]>0) { + $data[0][$i] = round($preData[0][$i]/($preData[0][$i]+$preData[1][$i])*100,0); + $data[1][$i] = 100-$data[0][$i]; + $anyPickupDone = true; + } else if($preData[1][$i]>0) { + $data[0][$i] = 0; + $data[1][$i] = 100; + $anyPickupDone = true; + } else { + $data[0][$i] = 0; + $data[1][$i] = 0; + } + } + + if($anyPickupDone) { + // Plot radargraph + $titles = array('belt','keg','pads','armour','amp'); + $graph = new RadarGraph ($domimage_width+8,$domimage_heigth+8); + $graph->SetScale('lin',0,100); + $graph->yscale->ticks->Set(25,5); + $graph->setMargin(30,30,30,30); + $graph->SetMarginColor($domimage_color['background']); + $graph->SetColor($domimage_color['background']); + $graph->SetFrame(true,$domimage_color['background'],0); + $graph->title->Set('Pickups %'); + $graph->title->SetFont(FF_VERDANA,FS_BOLD); + $graph->title->SetColor($domimage_color['heading']); + $graph->HideTickMarks(); + $graph->axis->HideLabels(); + + $graph->SetTitles($titles); + $graph->axis->title->SetFont(FF_VERDANA,FS_NORMAL,8); + $graph->axis->title->SetColor($domimage_color['font']); + $graph->grid->Show(true,true); + $graph->grid->SetLineStyle('dashed'); + + // Seperate plot within radar per team + $plot1 = new RadarPlot($data[0]); + $plot2 = new RadarPlot($data[1]); + $graph->Add($plot1); + $graph->Add($plot2); + + $plot1->SetFillColor($domimage_color['team'][0][0].'@0.5'); + $plot1->SetColor($domimage_color['team'][0][0]); + $plot1->SetLineWeight(2); + $plot2->SetFillColor($domimage_color['team'][1][0].'@0.5'); + $plot2->SetColor($domimage_color['team'][1][0]); + $plot2->SetLineWeight(2); + + $graph->Stroke($domimages_folder."/".$matchid."-pickups.png"); + } +} + +/* +Render dom points over time & net rate of change per minute over all cp's +*/ +function renderDataTotal($uid,$tempTableName) { + $query = "SELECT t.realTimeEnd,@t0sum := @t0sum + t.scoret0 AS cumulScoret0,@t1sum := @t1sum + t.scoret1 AS cumulScoret1 FROM $tempTableName t JOIN (SELECT @t0sum := 0) r JOIN (SELECT @t1sum := 0) s ORDER BY realTimeEnd ASC"; + $appex = "total"; + + renderData($uid,$tempTableName,$query,$appex,"Total score",""); +} + +/* +Render dom points over time & net rate of change per minute per cp +*/ +function renderDataCPs($uid,$tempTableName) { + $q_cps = mysql_query("SELECT DISTINCT(cp) FROM $tempTableName"); + + $i=0; + while($r_cps = mysql_fetch_array($q_cps)) { + $r_cp = $r_cps[0]; + $query = "SELECT t.realTimeEnd,@t0sum := @t0sum + t.scoret0 AS cumulScoret0,@t1sum := @t1sum + t.scoret1 AS cumulScoret1 FROM $tempTableName t JOIN (SELECT @t0sum := 0) r JOIN (SELECT @t1sum := 0) s WHERE t.CP = '$r_cp' ORDER BY realTimeEnd ASC"; + $appex = "cp".$i++; + renderData($uid,$tempTableName,$query,$appex,"Score CP ".$r_cp,$r_cp); + + } +} + +/* +Render dom points over time & net rate of change per minute +*/ +function renderData($uid,$tempTableName,$query,$appex,$title,$cp) { + global $matchid; + global $domimage_color; + global $domimages_folder; + global $domimage_width; + global $domimage_heigth; + + // Use helper function to parse the data into different datasets for charts + list($datax,$datay1,$datay2,$derivx,$derivy1,$derivy2) = parseData($query); + + // If this is a cp plot, ensure enough space for plotting the names underneath + if(strlen($cp)>0) { + + $g1heigth = $domimage_heigth*.65; + $g2heigth = $domimage_heigth*.35; + $g2marginlow = 50; + + // Else, use all space + } else { + + $g1heigth = $domimage_heigth*.75; + $g2heigth = $domimage_heigth*.25; + $g2marginlow = 10; + + } + + // Dom points over time per team + $graph1 = createGraph($title,$domimage_width,$g1heigth,array(30,10,30,30),"linlin"); + $sp11 = generateScatterLink($datax, $datay1,$domimage_color['team'][0][0],'FCallbackRedAmp'); + $sp12 = generateScatterLink($datax, $datay2,$domimage_color['team'][1][0],'FCallbackBlueAmp'); + $graph1->Add($sp11); + $graph1->Add($sp12); + + // Net rate of change per minute + $graph2 = createGraph("",$domimage_width,$g2heigth,array(30,10,5,$g2marginlow),"linlin"); + $graph2->xaxis->HideLabels(); + + $b1plot = new BarPlot($derivy1,$derivx); + $b2plot = new BarPlot($derivy2,$derivx); + + $graph2->Add($b1plot); + $graph2->Add($b2plot); + + $b1plot->SetFillGradient($domimage_color['team'][0][0],$domimage_color['team'][0][1],GRAD_HOR); + $b1plot->SetColor($domimage_color['team'][0][0]); + $b1plot->SetWidth(0.85); + $b2plot->SetFillGradient($domimage_color['team'][1][0],$domimage_color['team'][1][1],GRAD_HOR); + $b2plot->SetColor($domimage_color['team'][1][0]); + $b2plot->SetWidth(0.85); + + // If this is a cp plot, render the names + if(strlen($cp) > 0) { + renderNamesCP($tempTableName,$cp,$graph2,$domimage_width,$g2heigth); + } + + // Combine both graphs into one + $mgraph = new MGraph(); + $xpos1=0;$ypos1=0; + $xpos2=0;$ypos2=$g1heigth; + $mgraph->Add($graph1,$xpos1,$ypos1); + $mgraph->Add($graph2,$xpos2,$ypos2); + $mgraph->SetFillColor($domimage_color['background']); + + $gdImgHandler = $mgraph->Stroke(_IMG_HANDLER); + + $fileName = $domimages_folder."/".$matchid."-".$appex.".png"; + $mgraph->Stroke($fileName); +} + +/* +Helper function to parse the data for the main renderData +*/ +function parseData($query) { + $q_result = mysql_query($query) or die(mysql_error()); + + $prevx = 0; + $prevy1 = 0; + $prevy2 = 0; + $smallcounter = 1/3; + $counter = 1; + + while($data = mysql_fetch_array($q_result)) { + + // Prep data for dom points over time + // Only save the data each $smallcounter interval, to optimize rendering time + if($data[0]>=$smallcounter) { + + $datax[] = $data[0]; + $datay1[] = $data[1]; + $datay2[] = $data[2]; + + $smallcounter+=1/3; + } + + // Prep data for net change over time + // Only save the data each integer interval, since we want the value per minute + // Start at 0.5, to ensure proper alignment with graph above (cheap hack) + if($data[0]>=$counter) { + $derivx[] = $counter-1; + + $derivy1pre = $data[1]-$prevy1; + $derivy2pre = $data[2]-$prevy2; + + $derivy1post = $derivy1pre-$derivy2pre; + $derivy2post = $derivy2pre-$derivy1pre; + + $derivy1[] = $derivy1post>0 ? $derivy1post : 0; + $derivy2[] = $derivy2post>0 ? $derivy2post : 0; + + $prevy1 = $data[1]; + $prevy2 = $data[2]; + + $counter++; + } + } + + return array($datax,$datay1,$datay2,$derivx,$derivy1,$derivy2); +} + +/* +Render the names of players that played the cp +*/ +function renderNamesCP($tempTableName,$appex,$graph,$width,$height) { + global $domimage_color; + + $appex = mysql_real_escape_string($appex); + + $q_namesPerCP = mysql_query("SELECT playername, COUNT( playername ) AS cplayer, MAX( teamid ) AS tid, AVG( realTimeEnd ) AS ati FROM $tempTableName WHERE cp = '$appex' GROUP BY playername ORDER BY tid,ati") or die(mysql_error()); + + $yTeam[0][0] = 45; + $yTeam[0][1] = 35; + $yTeam[1][0] = 20; + $yTeam[1][1] = 10; + $prevTeam = -1; + + while($r_namesPerCP = mysql_fetch_array($q_namesPerCP)) { + $playerName = substr($r_namesPerCP[0],0,20); + $timesTouched = $r_namesPerCP[1]; + $teamid = $r_namesPerCP[2]; + $avgTime = $r_namesPerCP[3]; + + // Only plot the playername if he touched the cp at least 60 times + if(strlen($playerName)>0 && $timesTouched > 60) { + + $txt = new Text($playerName); + + // Names per team can be plotted on 2 different heights to ensure it doesn't become a mess on one line + // This bit of code ensures height is flipped each time + if($teamid == $prevTeam) { + $ypos = $height-$yTeam[$teamid][1]; + $prevTeam = -1; + } else { + $ypos = $height-$yTeam[$teamid][0]; + $prevTeam = $teamid; + } + + $color = $domimage_color['team'][$teamid][0]; + + // Plot name at average time, minus 25 (hack assuming most names are around 50 pixels) + $txt->SetPos($width/20*$avgTime-25,$ypos); + + $txt->SetColor($color); + $txt->SetFont(FF_VERDANA,FS_NORMAL,8); + $graph->AddText($txt); + } + + $prevAvgTime = $avgTime; + } + +} + +/* +Helper function to generate the graph object +*/ +function createGraph($title,$width,$height,$margin,$scale) { + global $domimage_color; + + $graph = new Graph($width,$height); + + $graph->SetScale($scale); + $graph->SetMargin($margin[0],$margin[1],$margin[2],$margin[3]); + $graph->SetMarginColor($domimage_color['background']); + $graph->SetColor($domimage_color['background']); + $graph->SetFrame(true,$domimage_color['background'],0); + + $graph->ygrid->SetFill(true,$domimage_color['band'][0],$domimage_color['band'][1]); + $graph->ygrid->SetColor($domimage_color['background']); + + $graph->yaxis->SetColor($domimage_color['background'],$domimage_color['font']); + $graph->xaxis->SetColor($domimage_color['background'],$domimage_color['font']); + + if(strlen($title)>0) { + $graph->title->Set($title); + $graph->title->SetFont(FF_VERDANA,FS_BOLD); + $graph->title->SetColor($domimage_color['heading']); + } + return $graph; +} + +/* +Helper function to generate the scatter plots +*/ +function generateScatterLink($datax, $datay, $color,$callback) { + $sp = new ScatterPlot($datay,$datax); + + $sp->link->Show(); + $sp->link->SetStyle('solid'); + $sp->link->SetWeight(3); + $sp->link->SetColor($color); + + if(strlen($callback) > 0) + $sp->mark->SetCallbackYX($callback); + + $sp->mark->SetType(MARK_FILLEDCIRCLE); + + return $sp; +} + +/* +Format functions for scatterplot to format based on team and whether amp was taken +*/ +function FCallbackRedAmp($bVal,$aVal) { + return FCallbackAmp($aVal,0); +} + +function FCallbackBlueAmp($bVal,$aVal) { + return FCallbackAmp($aVal,1); +} + +function FCallbackAmp($aVal, $team) { + global $ampTimes; + global $domimage_color; + + $size = 1; + $color = $domimage_color['team'][$team][0]; + + foreach ($ampTimes[$team] as $ampTaken) { + + if($aVal > $ampTaken[0] && $aVal < $ampTaken[1]) { + + $color = $domimage_color['amp']; + $size = 3; + break; + } + } + + return array($size,$color,$color); +} + +/* +Helper function to sort array on key, based on solution from the interwebs +*/ +function array_sort($array, $on) { + $new_array = array(); + $sortable_array = array(); + + if (count($array) > 0) { + foreach ($array as $k => $v) { + if (is_array($v)) { + foreach ($v as $k2 => $v2) { + if ($k2 == $on) { + $sortable_array[$k] = $v2; + } + } + } else { + $sortable_array[$k] = $v; + } + } + + asort($sortable_array); + + foreach ($sortable_array as $k => $v) { + $new_array[$k] = $array[$k]; + } + } + + return $new_array; +} +?>
\ No newline at end of file diff --git a/html/includes/encoding.php b/html/includes/encoding.php new file mode 100644 index 0000000..a559a3b --- /dev/null +++ b/html/includes/encoding.php @@ -0,0 +1,304 @@ +<?php +/* +Copyright (c) 2008 Sebastián Grignoli +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of copyright holders nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ +/** + * @author "Sebastián Grignoli" <grignoli@gmail.com> + * @package Encoding + * @version 2.0 + * @link https://github.com/neitanod/forceutf8 + * @example https://github.com/neitanod/forceutf8 + * @license Revised BSD + */ +namespace ForceUTF8; +class Encoding { + const ICONV_TRANSLIT = "TRANSLIT"; + const ICONV_IGNORE = "IGNORE"; + const WITHOUT_ICONV = ""; + protected static $win1252ToUtf8 = array( + 128 => "\xe2\x82\xac", + 130 => "\xe2\x80\x9a", + 131 => "\xc6\x92", + 132 => "\xe2\x80\x9e", + 133 => "\xe2\x80\xa6", + 134 => "\xe2\x80\xa0", + 135 => "\xe2\x80\xa1", + 136 => "\xcb\x86", + 137 => "\xe2\x80\xb0", + 138 => "\xc5\xa0", + 139 => "\xe2\x80\xb9", + 140 => "\xc5\x92", + 142 => "\xc5\xbd", + 145 => "\xe2\x80\x98", + 146 => "\xe2\x80\x99", + 147 => "\xe2\x80\x9c", + 148 => "\xe2\x80\x9d", + 149 => "\xe2\x80\xa2", + 150 => "\xe2\x80\x93", + 151 => "\xe2\x80\x94", + 152 => "\xcb\x9c", + 153 => "\xe2\x84\xa2", + 154 => "\xc5\xa1", + 155 => "\xe2\x80\xba", + 156 => "\xc5\x93", + 158 => "\xc5\xbe", + 159 => "\xc5\xb8" + ); + protected static $brokenUtf8ToUtf8 = array( + "\xc2\x80" => "\xe2\x82\xac", + "\xc2\x82" => "\xe2\x80\x9a", + "\xc2\x83" => "\xc6\x92", + "\xc2\x84" => "\xe2\x80\x9e", + "\xc2\x85" => "\xe2\x80\xa6", + "\xc2\x86" => "\xe2\x80\xa0", + "\xc2\x87" => "\xe2\x80\xa1", + "\xc2\x88" => "\xcb\x86", + "\xc2\x89" => "\xe2\x80\xb0", + "\xc2\x8a" => "\xc5\xa0", + "\xc2\x8b" => "\xe2\x80\xb9", + "\xc2\x8c" => "\xc5\x92", + "\xc2\x8e" => "\xc5\xbd", + "\xc2\x91" => "\xe2\x80\x98", + "\xc2\x92" => "\xe2\x80\x99", + "\xc2\x93" => "\xe2\x80\x9c", + "\xc2\x94" => "\xe2\x80\x9d", + "\xc2\x95" => "\xe2\x80\xa2", + "\xc2\x96" => "\xe2\x80\x93", + "\xc2\x97" => "\xe2\x80\x94", + "\xc2\x98" => "\xcb\x9c", + "\xc2\x99" => "\xe2\x84\xa2", + "\xc2\x9a" => "\xc5\xa1", + "\xc2\x9b" => "\xe2\x80\xba", + "\xc2\x9c" => "\xc5\x93", + "\xc2\x9e" => "\xc5\xbe", + "\xc2\x9f" => "\xc5\xb8" + ); + protected static $utf8ToWin1252 = array( + "\xe2\x82\xac" => "\x80", + "\xe2\x80\x9a" => "\x82", + "\xc6\x92" => "\x83", + "\xe2\x80\x9e" => "\x84", + "\xe2\x80\xa6" => "\x85", + "\xe2\x80\xa0" => "\x86", + "\xe2\x80\xa1" => "\x87", + "\xcb\x86" => "\x88", + "\xe2\x80\xb0" => "\x89", + "\xc5\xa0" => "\x8a", + "\xe2\x80\xb9" => "\x8b", + "\xc5\x92" => "\x8c", + "\xc5\xbd" => "\x8e", + "\xe2\x80\x98" => "\x91", + "\xe2\x80\x99" => "\x92", + "\xe2\x80\x9c" => "\x93", + "\xe2\x80\x9d" => "\x94", + "\xe2\x80\xa2" => "\x95", + "\xe2\x80\x93" => "\x96", + "\xe2\x80\x94" => "\x97", + "\xcb\x9c" => "\x98", + "\xe2\x84\xa2" => "\x99", + "\xc5\xa1" => "\x9a", + "\xe2\x80\xba" => "\x9b", + "\xc5\x93" => "\x9c", + "\xc5\xbe" => "\x9e", + "\xc5\xb8" => "\x9f" + ); + static function toUTF8($text){ + /** + * Function \ForceUTF8\Encoding::toUTF8 + * + * This function leaves UTF8 characters alone, while converting almost all non-UTF8 to UTF8. + * + * It assumes that the encoding of the original string is either Windows-1252 or ISO 8859-1. + * + * It may fail to convert characters to UTF-8 if they fall into one of these scenarios: + * + * 1) when any of these characters: ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß + * are followed by any of these: ("group B") + * ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶•¸¹º»¼½¾¿ + * For example: %ABREPRESENT%C9%BB. «REPRESENTÉ» + * The "«" (%AB) character will be converted, but the "É" followed by "»" (%C9%BB) + * is also a valid unicode character, and will be left unchanged. + * + * 2) when any of these: àáâãäåæçèéêëìíîï are followed by TWO chars from group B, + * 3) when any of these: ðñòó are followed by THREE chars from group B. + * + * @name toUTF8 + * @param string $text Any string. + * @return string The same string, UTF8 encoded + * + */ + if(is_array($text)) + { + foreach($text as $k => $v) + { + $text[$k] = self::toUTF8($v); + } + return $text; + } elseif(is_string($text)) { + if ( function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload')) & 2) { + $max = mb_strlen($text,'8bit'); + } else { + $max = strlen($text); + } + $buf = ""; + for($i = 0; $i < $max; $i++){ + $c1 = $text{$i}; + if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already + $c2 = $i+1 >= $max? "\x00" : $text{$i+1}; + $c3 = $i+2 >= $max? "\x00" : $text{$i+2}; + $c4 = $i+3 >= $max? "\x00" : $text{$i+3}; + if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8 + if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already + $buf .= $c1 . $c2; + $i++; + } else { //not valid UTF8. Convert it. + $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc2 = ($c1 & "\x3f") | "\x80"; + $buf .= $cc1 . $cc2; + } + } elseif($c1 >= "\xe0" & $c1 <= "\xef"){ //looks like 3 bytes UTF8 + if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf"){ //yeah, almost sure it's UTF8 already + $buf .= $c1 . $c2 . $c3; + $i = $i + 2; + } else { //not valid UTF8. Convert it. + $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc2 = ($c1 & "\x3f") | "\x80"; + $buf .= $cc1 . $cc2; + } + } elseif($c1 >= "\xf0" & $c1 <= "\xf7"){ //looks like 4 bytes UTF8 + if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf"){ //yeah, almost sure it's UTF8 already + $buf .= $c1 . $c2 . $c3 . $c4; + $i = $i + 3; + } else { //not valid UTF8. Convert it. + $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc2 = ($c1 & "\x3f") | "\x80"; + $buf .= $cc1 . $cc2; + } + } else { //doesn't look like UTF8, but should be converted + $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc2 = (($c1 & "\x3f") | "\x80"); + $buf .= $cc1 . $cc2; + } + } elseif(($c1 & "\xc0") == "\x80"){ // needs conversion + if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases + $buf .= self::$win1252ToUtf8[ord($c1)]; + } else { + $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc2 = (($c1 & "\x3f") | "\x80"); + $buf .= $cc1 . $cc2; + } + } else { // it doesn't need conversion + $buf .= $c1; + } + } + return $buf; + } else { + return $text; + } + } + static function toWin1252($text, $option = self::WITHOUT_ICONV) { + if(is_array($text)) { + foreach($text as $k => $v) { + $text[$k] = self::toWin1252($v, $option); + } + return $text; + } elseif(is_string($text)) { + return static::utf8_decode($text, $option); + } else { + return $text; + } + } + static function toISO8859($text) { + return self::toWin1252($text); + } + static function toLatin1($text) { + return self::toWin1252($text); + } + static function fixUTF8($text, $option = self::WITHOUT_ICONV){ + if(is_array($text)) { + foreach($text as $k => $v) { + $text[$k] = self::fixUTF8($v, $option); + } + return $text; + } + $last = ""; + while($last <> $text){ + $last = $text; + $text = self::toUTF8(static::utf8_decode($text, $option)); + } + $text = self::toUTF8(static::utf8_decode($text, $option)); + return $text; + } + static function UTF8FixWin1252Chars($text){ + // If you received an UTF-8 string that was converted from Windows-1252 as it was ISO8859-1 + // (ignoring Windows-1252 chars from 80 to 9F) use this function to fix it. + // See: http://en.wikipedia.org/wiki/Windows-1252 + return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text); + } + static function removeBOM($str=""){ + if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { + $str=substr($str, 3); + } + return $str; + } + public static function normalizeEncoding($encodingLabel) + { + $encoding = strtoupper($encodingLabel); + $encoding = preg_replace('/[^a-zA-Z0-9\s]/', '', $encoding); + $equivalences = array( + 'ISO88591' => 'ISO-8859-1', + 'ISO8859' => 'ISO-8859-1', + 'ISO' => 'ISO-8859-1', + 'LATIN1' => 'ISO-8859-1', + 'LATIN' => 'ISO-8859-1', + 'UTF8' => 'UTF-8', + 'UTF' => 'UTF-8', + 'WIN1252' => 'ISO-8859-1', + 'WINDOWS1252' => 'ISO-8859-1' + ); + if(empty($equivalences[$encoding])){ + return 'UTF-8'; + } + return $equivalences[$encoding]; + } + public static function encode($encodingLabel, $text) + { + $encodingLabel = self::normalizeEncoding($encodingLabel); + if($encodingLabel == 'UTF-8') return Encoding::toUTF8($text); + if($encodingLabel == 'ISO-8859-1') return Encoding::toLatin1($text); + } + protected static function utf8_decode($text, $option) + { + if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) { + $o = utf8_decode( + str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text)) + ); + } else { + $o = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text); + } + return $o; + } +}
\ No newline at end of file diff --git a/html/includes/footer.php b/html/includes/footer.php index be5e38c..9e3a6de 100755 --- a/html/includes/footer.php +++ b/html/includes/footer.php @@ -7,7 +7,7 @@ <!-- Please leave this bit in, its the least you can do with all the work we have done :) -->
<p>
<a href="https://github.com/sn3p/utstats" target="_blank">
- UTStats Beta 4.2.8</a> © 2005 azazel, AnthraX and toa + UTStats Beta 4.3.0</a> © 2005 azazel, AnthraX and toa </p> </td>
diff --git a/html/includes/ftptimestamp.php b/html/includes/ftptimestamp.php index 5b6994a..c19396a 100755 --- a/html/includes/ftptimestamp.php +++ b/html/includes/ftptimestamp.php @@ -1 +1 @@ -1112804209
\ No newline at end of file +1512939605
\ No newline at end of file diff --git a/html/includes/header.php b/html/includes/header.php index c4f96a6..26fdcf3 100755 --- a/html/includes/header.php +++ b/html/includes/header.php @@ -36,12 +36,27 @@ echo' <meta http-equiv="Content-Type" content="text/html; CHARSET=iso-8859-1">
<link rel="icon" href="images/favicon.ico" type="image/ico">
<link rel="stylesheet" href="style.css">
+ <script type="text/javascript" src="includes/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
<!--
var ol_fgclass="dark"; var ol_bgclass="darkbox"; var ol_textfontclass="dark"; var ol_captionfontclass="hlheading";
-->
</script>
<script type="text/javascript" src="includes/overlib_mini.js"><!-- overLIB (c) Erik Bosrup --></script>
+<script type="text/javascript" src="includes/js/adapters/standalone-framework.js"></script>
+<script type="text/javascript" src="includes/js/highcharts.js"></script>
+<script type="text/javascript" src="includes/js/highcharts-more.js"></script>
+<script type="text/javascript" src="includes/js/highcharts-functions.js"></script>
+<script type="text/javascript" src="includes/js/themes/dark-blue.js"></script>
+<script type="text/javascript" src="./includes/js/clickrows.js"></script>
+<link rel="stylesheet" type="text/css" href="includes/css/tooltipster.css" >
+<script type="text/javascript" src="includes/js/jquery.tooltipster.min.js"></script>
+<script type="text/javascript">
+ $(document).ready(function() {
+ $(".tooltip").tooltipster();
+ });
+ </script>
+
</head>
<body>
diff --git a/html/includes/js/adapters/standalone-framework.js b/html/includes/js/adapters/standalone-framework.js new file mode 100644 index 0000000..d41dde7 --- /dev/null +++ b/html/includes/js/adapters/standalone-framework.js @@ -0,0 +1,18 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + + Standalone Highcharts Framework + + License: MIT License +*/ +var HighchartsAdapter=function(){function p(c){function b(b,a,d){b.removeEventListener(a,d,!1)}function d(b,a,d){d=b.HCProxiedMethods[d.toString()];b.detachEvent("on"+a,d)}function a(a,c){var f=a.HCEvents,i,g,k,j;if(a.removeEventListener)i=b;else if(a.attachEvent)i=d;else return;c?(g={},g[c]=!0):g=f;for(j in g)if(f[j])for(k=f[j].length;k--;)i(a,j,f[j][k])}c.HCExtended||Highcharts.extend(c,{HCExtended:!0,HCEvents:{},bind:function(b,a){var d=this,c=this.HCEvents,g;if(d.addEventListener)d.addEventListener(b, +a,!1);else if(d.attachEvent){g=function(b){b.target=b.srcElement||window;a.call(d,b)};if(!d.HCProxiedMethods)d.HCProxiedMethods={};d.HCProxiedMethods[a.toString()]=g;d.attachEvent("on"+b,g)}c[b]===s&&(c[b]=[]);c[b].push(a)},unbind:function(c,h){var f,i;c?(f=this.HCEvents[c]||[],h?(i=HighchartsAdapter.inArray(h,f),i>-1&&(f.splice(i,1),this.HCEvents[c]=f),this.removeEventListener?b(this,c,h):this.attachEvent&&d(this,c,h)):(a(this,c),this.HCEvents[c]=[])):(a(this),this.HCEvents={})},trigger:function(b, +a){var d=this.HCEvents[b]||[],c=d.length,g,k,j;k=function(){a.defaultPrevented=!0};for(g=0;g<c;g++){j=d[g];if(a.stopped)break;a.preventDefault=k;a.target=this;if(!a.type)a.type=b;j.call(this,a)===!1&&a.preventDefault()}}});return c}var s,l=document,q=[],m=[],r,n={},o;Math.easeInOutSine=function(c,b,d,a){return-d/2*(Math.cos(Math.PI*c/a)-1)+b};return{init:function(c){if(!l.defaultView)this._getStyle=function(b,d){var a;return b.style[d]?b.style[d]:(d==="opacity"&&(d="filter"),a=b.currentStyle[d.replace(/\-(\w)/g, +function(b,a){return a.toUpperCase()})],d==="filter"&&(a=a.replace(/alpha\(opacity=([0-9]+)\)/,function(b,a){return a/100})),a===""?1:a)},this.adapterRun=function(b,d){var a={width:"clientWidth",height:"clientHeight"}[d];if(a)return b.style.zoom=1,b[a]-2*parseInt(HighchartsAdapter._getStyle(b,"padding"),10)};if(!Array.prototype.forEach)this.each=function(b,d){for(var a=0,c=b.length;a<c;a++)if(d.call(b[a],b[a],a,b)===!1)return a};if(!Array.prototype.indexOf)this.inArray=function(b,d){var a,c=0;if(d)for(a= +d.length;c<a;c++)if(d[c]===b)return c;return-1};if(!Array.prototype.filter)this.grep=function(b,d){for(var a=[],c=0,h=b.length;c<h;c++)d(b[c],c)&&a.push(b[c]);return a};o=function(b,c,a){this.options=c;this.elem=b;this.prop=a};o.prototype={update:function(){var b;b=this.paths;var d=this.elem,a=d.element;if(n[this.prop])n[this.prop](this);else b&&a?d.attr("d",c.step(b[0],b[1],this.now,this.toD)):d.attr?a&&d.attr(this.prop,this.now):(b={},b[this.prop]=this.now+this.unit,Highcharts.css(d,b));this.options.step&& +this.options.step.call(this.elem,this.now,this)},custom:function(b,c,a){var e=this,h=function(a){return e.step(a)},f;this.startTime=+new Date;this.start=b;this.end=c;this.unit=a;this.now=this.start;this.pos=this.state=0;h.elem=this.elem;h()&&m.push(h)===1&&(r=setInterval(function(){for(f=0;f<m.length;f++)m[f]()||m.splice(f--,1);m.length||clearInterval(r)},13))},step:function(b){var c=+new Date,a;a=this.options;var e=this.elem,h;if(e.stopAnimation||e.attr&&!e.element)a=!1;else if(b||c>=a.duration+ +this.startTime){this.now=this.end;this.pos=this.state=1;this.update();b=this.options.curAnim[this.prop]=!0;for(h in a.curAnim)a.curAnim[h]!==!0&&(b=!1);b&&a.complete&&a.complete.call(e);a=!1}else e=c-this.startTime,this.state=e/a.duration,this.pos=a.easing(e,0,1,a.duration),this.now=this.start+(this.end-this.start)*this.pos,this.update(),a=!0;return a}};this.animate=function(b,d,a){var e,h="",f,i,g;b.stopAnimation=!1;if(typeof a!=="object"||a===null)e=arguments,a={duration:e[2],easing:e[3],complete:e[4]}; +if(typeof a.duration!=="number")a.duration=400;a.easing=Math[a.easing]||Math.easeInOutSine;a.curAnim=Highcharts.extend({},d);for(g in d)i=new o(b,a,g),f=null,g==="d"?(i.paths=c.init(b,b.d,d.d),i.toD=d.d,e=0,f=1):b.attr?e=b.attr(g):(e=parseFloat(HighchartsAdapter._getStyle(b,g))||0,g!=="opacity"&&(h="px")),f||(f=d[g]),i.custom(e,f,h)}},_getStyle:function(c,b){return window.getComputedStyle(c,void 0).getPropertyValue(b)},addAnimSetter:function(c,b){n[c]=b},getScript:function(c,b){var d=l.getElementsByTagName("head")[0], +a=l.createElement("script");a.type="text/javascript";a.src=c;a.onload=b;d.appendChild(a)},inArray:function(c,b){return b.indexOf?b.indexOf(c):q.indexOf.call(b,c)},adapterRun:function(c,b){return parseInt(HighchartsAdapter._getStyle(c,b),10)},grep:function(c,b){return q.filter.call(c,b)},map:function(c,b){for(var d=[],a=0,e=c.length;a<e;a++)d[a]=b.call(c[a],c[a],a,c);return d},offset:function(c){var b=document.documentElement,c=c.getBoundingClientRect();return{top:c.top+(window.pageYOffset||b.scrollTop)- +(b.clientTop||0),left:c.left+(window.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}},addEvent:function(c,b,d){p(c).bind(b,d)},removeEvent:function(c,b,d){p(c).unbind(b,d)},fireEvent:function(c,b,d,a){var e;l.createEvent&&(c.dispatchEvent||c.fireEvent)?(e=l.createEvent("Events"),e.initEvent(b,!0,!0),e.target=c,Highcharts.extend(e,d),c.dispatchEvent?c.dispatchEvent(e):c.fireEvent(b,e)):c.HCExtended===!0&&(d=d||{},c.trigger(b,d));d&&d.defaultPrevented&&(a=null);a&&a(d)},washMouseEvent:function(c){return c}, +stop:function(c){c.stopAnimation=!0},each:function(c,b){return Array.prototype.forEach.call(c,b)}}}(); diff --git a/html/includes/js/adapters/standalone-framework.src.js b/html/includes/js/adapters/standalone-framework.src.js new file mode 100644 index 0000000..f403b0d --- /dev/null +++ b/html/includes/js/adapters/standalone-framework.src.js @@ -0,0 +1,603 @@ +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * + * Standalone Highcharts Framework + * + * License: MIT License + */ + + +/*global Highcharts */ +var HighchartsAdapter = (function () { + +var UNDEFINED, + doc = document, + emptyArray = [], + timers = [], + timerId, + animSetters = {}, + Fx; + +Math.easeInOutSine = function (t, b, c, d) { + return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; +}; + + + +/** + * Extend given object with custom events + */ +function augment(obj) { + function removeOneEvent(el, type, fn) { + el.removeEventListener(type, fn, false); + } + + function IERemoveOneEvent(el, type, fn) { + fn = el.HCProxiedMethods[fn.toString()]; + el.detachEvent('on' + type, fn); + } + + function removeAllEvents(el, type) { + var events = el.HCEvents, + remove, + types, + len, + n; + + if (el.removeEventListener) { + remove = removeOneEvent; + } else if (el.attachEvent) { + remove = IERemoveOneEvent; + } else { + return; // break on non-DOM events + } + + + if (type) { + types = {}; + types[type] = true; + } else { + types = events; + } + + for (n in types) { + if (events[n]) { + len = events[n].length; + while (len--) { + remove(el, n, events[n][len]); + } + } + } + } + + if (!obj.HCExtended) { + Highcharts.extend(obj, { + HCExtended: true, + + HCEvents: {}, + + bind: function (name, fn) { + var el = this, + events = this.HCEvents, + wrappedFn; + + // handle DOM events in modern browsers + if (el.addEventListener) { + el.addEventListener(name, fn, false); + + // handle old IE implementation + } else if (el.attachEvent) { + + wrappedFn = function (e) { + e.target = e.srcElement || window; // #2820 + fn.call(el, e); + }; + + if (!el.HCProxiedMethods) { + el.HCProxiedMethods = {}; + } + + // link wrapped fn with original fn, so we can get this in removeEvent + el.HCProxiedMethods[fn.toString()] = wrappedFn; + + el.attachEvent('on' + name, wrappedFn); + } + + + if (events[name] === UNDEFINED) { + events[name] = []; + } + + events[name].push(fn); + }, + + unbind: function (name, fn) { + var events, + index; + + if (name) { + events = this.HCEvents[name] || []; + if (fn) { + index = HighchartsAdapter.inArray(fn, events); + if (index > -1) { + events.splice(index, 1); + this.HCEvents[name] = events; + } + if (this.removeEventListener) { + removeOneEvent(this, name, fn); + } else if (this.attachEvent) { + IERemoveOneEvent(this, name, fn); + } + } else { + removeAllEvents(this, name); + this.HCEvents[name] = []; + } + } else { + removeAllEvents(this); + this.HCEvents = {}; + } + }, + + trigger: function (name, args) { + var events = this.HCEvents[name] || [], + target = this, + len = events.length, + i, + preventDefault, + fn; + + // Attach a simple preventDefault function to skip default handler if called + preventDefault = function () { + args.defaultPrevented = true; + }; + + for (i = 0; i < len; i++) { + fn = events[i]; + + // args is never null here + if (args.stopped) { + return; + } + + args.preventDefault = preventDefault; + args.target = target; + + // If the type is not set, we're running a custom event (#2297). If it is set, + // we're running a browser event, and setting it will cause en error in + // IE8 (#2465). + if (!args.type) { + args.type = name; + } + + + + // If the event handler return false, prevent the default handler from executing + if (fn.call(this, args) === false) { + args.preventDefault(); + } + } + } + }); + } + + return obj; +} + + +return { + + /** + * Initialize the adapter. This is run once as Highcharts is first run. + */ + init: function (pathAnim) { + + /** + * Compatibility section to add support for legacy IE. This can be removed if old IE + * support is not needed. + */ + if (!doc.defaultView) { + this._getStyle = function (el, prop) { + var val; + if (el.style[prop]) { + return el.style[prop]; + } else { + if (prop === 'opacity') { + prop = 'filter'; + } + /*jslint unparam: true*/ + val = el.currentStyle[prop.replace(/\-(\w)/g, function (a, b) { return b.toUpperCase(); })]; + if (prop === 'filter') { + val = val.replace( + /alpha\(opacity=([0-9]+)\)/, + function (a, b) { + return b / 100; + } + ); + } + /*jslint unparam: false*/ + return val === '' ? 1 : val; + } + }; + this.adapterRun = function (elem, method) { + var alias = { width: 'clientWidth', height: 'clientHeight' }[method]; + + if (alias) { + elem.style.zoom = 1; + return elem[alias] - 2 * parseInt(HighchartsAdapter._getStyle(elem, 'padding'), 10); + } + }; + } + + if (!Array.prototype.forEach) { + this.each = function (arr, fn) { // legacy + var i = 0, + len = arr.length; + for (; i < len; i++) { + if (fn.call(arr[i], arr[i], i, arr) === false) { + return i; + } + } + }; + } + + if (!Array.prototype.indexOf) { + this.inArray = function (item, arr) { + var len, + i = 0; + + if (arr) { + len = arr.length; + + for (; i < len; i++) { + if (arr[i] === item) { + return i; + } + } + } + + return -1; + }; + } + + if (!Array.prototype.filter) { + this.grep = function (elements, callback) { + var ret = [], + i = 0, + length = elements.length; + + for (; i < length; i++) { + if (!!callback(elements[i], i)) { + ret.push(elements[i]); + } + } + + return ret; + }; + } + + //--- End compatibility section --- + + + /** + * Start of animation specific code + */ + Fx = function (elem, options, prop) { + this.options = options; + this.elem = elem; + this.prop = prop; + }; + Fx.prototype = { + + update: function () { + var styles, + paths = this.paths, + elem = this.elem, + elemelem = elem.element; // if destroyed, it is null + + // Animation setter defined from outside + if (animSetters[this.prop]) { + animSetters[this.prop](this); + + // Animating a path definition on SVGElement + } else if (paths && elemelem) { + elem.attr('d', pathAnim.step(paths[0], paths[1], this.now, this.toD)); + + // Other animations on SVGElement + } else if (elem.attr) { + if (elemelem) { + elem.attr(this.prop, this.now); + } + + // HTML styles + } else { + styles = {}; + styles[this.prop] = this.now + this.unit; + Highcharts.css(elem, styles); + } + + if (this.options.step) { + this.options.step.call(this.elem, this.now, this); + } + + }, + custom: function (from, to, unit) { + var self = this, + t = function (gotoEnd) { + return self.step(gotoEnd); + }, + i; + + this.startTime = +new Date(); + this.start = from; + this.end = to; + this.unit = unit; + this.now = this.start; + this.pos = this.state = 0; + + t.elem = this.elem; + + if (t() && timers.push(t) === 1) { + timerId = setInterval(function () { + + for (i = 0; i < timers.length; i++) { + if (!timers[i]()) { + timers.splice(i--, 1); + } + } + + if (!timers.length) { + clearInterval(timerId); + } + }, 13); + } + }, + + step: function (gotoEnd) { + var t = +new Date(), + ret, + done, + options = this.options, + elem = this.elem, + i; + + if (elem.stopAnimation || (elem.attr && !elem.element)) { // #2616, element including flag is destroyed + ret = false; + + } else if (gotoEnd || t >= options.duration + this.startTime) { + this.now = this.end; + this.pos = this.state = 1; + this.update(); + + this.options.curAnim[this.prop] = true; + + done = true; + for (i in options.curAnim) { + if (options.curAnim[i] !== true) { + done = false; + } + } + + if (done) { + if (options.complete) { + options.complete.call(elem); + } + } + ret = false; + + } else { + var n = t - this.startTime; + this.state = n / options.duration; + this.pos = options.easing(n, 0, 1, options.duration); + this.now = this.start + ((this.end - this.start) * this.pos); + this.update(); + ret = true; + } + return ret; + } + }; + + /** + * The adapter animate method + */ + this.animate = function (el, prop, opt) { + var start, + unit = '', + end, + fx, + args, + name; + + el.stopAnimation = false; // ready for new + + if (typeof opt !== 'object' || opt === null) { + args = arguments; + opt = { + duration: args[2], + easing: args[3], + complete: args[4] + }; + } + if (typeof opt.duration !== 'number') { + opt.duration = 400; + } + opt.easing = Math[opt.easing] || Math.easeInOutSine; + opt.curAnim = Highcharts.extend({}, prop); + + for (name in prop) { + fx = new Fx(el, opt, name); + end = null; + + if (name === 'd') { + fx.paths = pathAnim.init( + el, + el.d, + prop.d + ); + fx.toD = prop.d; + start = 0; + end = 1; + } else if (el.attr) { + start = el.attr(name); + } else { + start = parseFloat(HighchartsAdapter._getStyle(el, name)) || 0; + if (name !== 'opacity') { + unit = 'px'; + } + } + + if (!end) { + end = prop[name]; + } + fx.custom(start, end, unit); + } + }; + }, + + /** + * Internal method to return CSS value for given element and property + */ + _getStyle: function (el, prop) { + return window.getComputedStyle(el, undefined).getPropertyValue(prop); + }, + + /** + * Add an animation setter for a specific property + */ + addAnimSetter: function (prop, fn) { + animSetters[prop] = fn; + }, + + /** + * Downloads a script and executes a callback when done. + * @param {String} scriptLocation + * @param {Function} callback + */ + getScript: function (scriptLocation, callback) { + // We cannot assume that Assets class from mootools-more is available so instead insert a script tag to download script. + var head = doc.getElementsByTagName('head')[0], + script = doc.createElement('script'); + + script.type = 'text/javascript'; + script.src = scriptLocation; + script.onload = callback; + + head.appendChild(script); + }, + + /** + * Return the index of an item in an array, or -1 if not found + */ + inArray: function (item, arr) { + return arr.indexOf ? arr.indexOf(item) : emptyArray.indexOf.call(arr, item); + }, + + + /** + * A direct link to adapter methods + */ + adapterRun: function (elem, method) { + return parseInt(HighchartsAdapter._getStyle(elem, method), 10); + }, + + /** + * Filter an array + */ + grep: function (elements, callback) { + return emptyArray.filter.call(elements, callback); + }, + + /** + * Map an array + */ + map: function (arr, fn) { + var results = [], i = 0, len = arr.length; + + for (; i < len; i++) { + results[i] = fn.call(arr[i], arr[i], i, arr); + } + + return results; + }, + + /** + * Get the element's offset position, corrected by overflow:auto. Loosely based on jQuery's offset method. + */ + offset: function (el) { + var docElem = document.documentElement, + box = el.getBoundingClientRect(); + + return { + top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), + left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0) + }; + }, + + /** + * Add an event listener + */ + addEvent: function (el, type, fn) { + augment(el).bind(type, fn); + }, + + /** + * Remove event added with addEvent + */ + removeEvent: function (el, type, fn) { + augment(el).unbind(type, fn); + }, + + /** + * Fire an event on a custom object + */ + fireEvent: function (el, type, eventArguments, defaultFunction) { + var e; + + if (doc.createEvent && (el.dispatchEvent || el.fireEvent)) { + e = doc.createEvent('Events'); + e.initEvent(type, true, true); + e.target = el; + + Highcharts.extend(e, eventArguments); + + if (el.dispatchEvent) { + el.dispatchEvent(e); + } else { + el.fireEvent(type, e); + } + + } else if (el.HCExtended === true) { + eventArguments = eventArguments || {}; + el.trigger(type, eventArguments); + } + + if (eventArguments && eventArguments.defaultPrevented) { + defaultFunction = null; + } + + if (defaultFunction) { + defaultFunction(eventArguments); + } + }, + + washMouseEvent: function (e) { + return e; + }, + + + /** + * Stop running animation + */ + stop: function (el) { + el.stopAnimation = true; + }, + + /** + * Utility for iterating over an array. Parameters are reversed compared to jQuery. + * @param {Array} arr + * @param {Function} fn + */ + each: function (arr, fn) { // modern browsers + return Array.prototype.forEach.call(arr, fn); + } +}; +}()); diff --git a/html/includes/js/clickrows.js b/html/includes/js/clickrows.js new file mode 100644 index 0000000..fb9fda2 --- /dev/null +++ b/html/includes/js/clickrows.js @@ -0,0 +1,8 @@ + +$(document).ready(function($) { + $(".clickableRow").click(function() { + if(event.which == 1) { + window.document.location = $(this).attr("href"); + } + }); +}); diff --git a/html/includes/js/clocks.js b/html/includes/js/clocks.js new file mode 100644 index 0000000..7f17b42 --- /dev/null +++ b/html/includes/js/clocks.js @@ -0,0 +1,561 @@ +//<![CDATA[ + +$(function () { + + /** + * Get the current time + */ + function getNow() { + var now = new Date(); + var gmt_offset = now.getTimezoneOffset( ) / 60; + var est = gmt_offset + 5; + + return { + hours: now.getHours() - est + now.getMinutes() / 60, + minutes: now.getMinutes() * 12 / 60 + now.getSeconds() * 12 / 3600, + seconds: now.getSeconds() * 12 / 60 + }; + } + + /** + * Pad numbers + */ + function pad(number, length) { + // Create an array of the remaining length + 1 and join it with 0\'s + return new Array((length || 2) + 1 - String(number).length).join(0) + number; + } + + var now = getNow(); + + // Create the chart + $(\'.column-right\').highcharts({ + + chart: { + type: \'gauge\', + plotBackgroundColor: null, + plotBackgroundImage: null, + plotBorderWidth: 0, + plotShadow: false, + height: 200 + }, + + credits: { + enabled: false + }, + + title: { + text: \'EST\' + }, + + pane: { + background: [{ + // default background + }, { + // reflex for supported browsers + backgroundColor: \'#1e1e1e\' ? { + radialGradient: { + cx: 0.5, + cy: -0.4, + r: 1.9 + }, + stops: [ + [0.5, \'rgba(81, 81, 81, 0.8)\'], + [0.5, \'rgba(59, 56, 59, 0.8)\'] + ] + } : null + }] + }, + + yAxis: { + + + labels: { + distance: -20, + + style: { + color: \'#848484\' + } + }, + min: 0, + max: 12, + lineWidth: 0, + showFirstLabel: false, + + minorTickInterval: \'auto\', + minorTickWidth: 1, + minorTickLength: 5, + minorTickPosition: \'inside\', + minorGridLineWidth: 0, + minorTickColor: \'#2e2e2e\', + + tickInterval: 1, + tickWidth: 2, + tickPosition: \'inside\', + tickLength: 10, + tickColor: \'#fff\', + title: { + text: \'\', + style: { + color: \'#fff\', + fontWeight: \'normal\', + fontSize: \'8px\', + lineHeight: \'10px\' + }, + y: 10 + } + }, + + tooltip: { + formatter: function () { + return this.series.chart.tooltipText; + } + }, + + series: [{ + data: [{ + id: \'hour\', + y: now.hours, + dial: { + radius: \'60%\', + baseWidth: 4, + baseLength: \'95%\', + rearLength: 0 + } + }, { + id: \'minute\', + y: now.minutes, + dial: { + baseLength: \'95%\', + rearLength: 0 + } + }, { + id: \'second\', + y: now.seconds, + dial: { + radius: \'100%\', + baseWidth: 1, + rearLength: \'20%\' + } + }], + animation: false, + dataLabels: { + enabled: false + } + }] + }, + + // Move + function (chart) { + setInterval(function () { + + now = getNow(); + + var hour = chart.get(\'hour\'), + minute = chart.get(\'minute\'), + second = chart.get(\'second\'), + // run animation unless we\'re wrapping around from 59 to 0 + animation = now.seconds === 0 ? + false : + { + easing: \'easeOutElastic\' + }; + + // Cache the tooltip text + chart.tooltipText = + pad(Math.floor(now.hours), 2) + \':\' + + pad(Math.floor(now.minutes * 5), 2) + \':\' + + pad(now.seconds * 5, 2); + + hour.update(now.hours, true, animation); + minute.update(now.minutes, true, animation); + second.update(now.seconds, true, animation); + + }, 1000); + + }); +}); + +// Extend jQuery with some easing (copied from jQuery UI) +$.extend($.easing, { + easeOutElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; + } +}); + +$(function () { + + /** + * Get the current time + */ + function getNow() { + var now = new Date(); + var gmt_offset = now.getTimezoneOffset( ) / 60; + var est = gmt_offset + 5; + var cet = gmt_offset - 1; + + return { + hours: now.getHours() - cet + now.getMinutes() / 60, + minutes: now.getMinutes() * 12 / 60 + now.getSeconds() * 12 / 3600, + seconds: now.getSeconds() * 12 / 60 + }; + } + + /** + * Pad numbers + */ + function pad(number, length) { + // Create an array of the remaining length + 1 and join it with 0\'s + return new Array((length || 2) + 1 - String(number).length).join(0) + number; + } + + var now = getNow(); + + // Create the chart + $(\'.column-center\').highcharts({ + + chart: { + type: \'gauge\', + plotBackgroundColor: null, + plotBackgroundImage: null, + plotBorderWidth: 0, + plotShadow: false, + height: 200 + }, + + credits: { + enabled: false + }, + + title: { + text: \'CET\' + }, + + pane: { + background: [{ + // default background + }, { + // reflex for supported browsers + backgroundColor: Highcharts.svg ? { + radialGradient: { + cx: 0.5, + cy: -0.4, + r: 1.9 + }, + stops: [ + [0.5, \'rgba(81, 81, 81, 0.8)\'], + [0.5, \'rgba(59, 56, 59, 0.8)\'] + ] + } : null + }] + }, + + yAxis: { + + + labels: { + distance: -20, + + style: { + color: \'#848484\' + } + }, + min: 0, + max: 12, + lineWidth: 0, + showFirstLabel: false, + + minorTickInterval: \'auto\', + minorTickWidth: 1, + minorTickLength: 5, + minorTickPosition: \'inside\', + minorGridLineWidth: 0, + minorTickColor: \'#2e2e2e\', + + tickInterval: 1, + tickWidth: 2, + tickPosition: \'inside\', + tickLength: 10, + tickColor: \'#fff\', + title: { + text: \'\', + style: { + color: \'#fff\', + fontWeight: \'normal\', + fontSize: \'8px\', + lineHeight: \'10px\' + }, + y: 10 + } + }, + + tooltip: { + formatter: function () { + return this.series.chart.tooltipText; + } + }, + + series: [{ + data: [{ + id: \'hour\', + y: now.hours, + dial: { + radius: \'60%\', + baseWidth: 4, + baseLength: \'95%\', + rearLength: 0 + } + }, { + id: \'minute\', + y: now.minutes, + dial: { + baseLength: \'95%\', + rearLength: 0 + } + }, { + id: \'second\', + y: now.seconds, + dial: { + radius: \'100%\', + baseWidth: 1, + rearLength: \'20%\' + } + }], + animation: false, + dataLabels: { + enabled: false + } + }] + }, + + // Move + function (chart) { + setInterval(function () { + + now = getNow(); + + var hour = chart.get(\'hour\'), + minute = chart.get(\'minute\'), + second = chart.get(\'second\'), + // run animation unless we\'re wrapping around from 59 to 0 + animation = now.seconds === 0 ? + false : + { + easing: \'easeOutElastic\' + }; + + // Cache the tooltip text + chart.tooltipText = + pad(Math.floor(now.hours), 2) + \':\' + + pad(Math.floor(now.minutes * 5), 2) + \':\' + + pad(now.seconds * 5, 2); + + hour.update(now.hours, true, animation); + minute.update(now.minutes, true, animation); + second.update(now.seconds, true, animation); + + }, 1000); + + }); +}); + +// Extend jQuery with some easing (copied from jQuery UI) +$.extend($.easing, { + easeOutElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; + } +}); + +$(function () { + + /** + * Get the current time + */ + function getNow() { + var now = new Date(); + var gmt_offset = now.getTimezoneOffset( ) / 60; + var est = gmt_offset + 5; + + return { + hours: now.getHours() + now.getMinutes() / 60, + minutes: now.getMinutes() * 12 / 60 + now.getSeconds() * 12 / 3600, + seconds: now.getSeconds() * 12 / 60 + }; + } + + /** + * Pad numbers + */ + function pad(number, length) { + // Create an array of the remaining length + 1 and join it with 0\'s + return new Array((length || 2) + 1 - String(number).length).join(0) + number; + } + + var now = getNow(); + + // Create the chart + $(\'.column-left\').highcharts({ + + chart: { + type: \'gauge\', + plotBackgroundColor: null, + plotBackgroundImage: null, + plotBorderWidth: 0, + plotShadow: false, + height: 200 + }, + + credits: { + enabled: false + }, + + title: { + text: \'Your time\' + }, + + pane: { + background: [{ + // default background + }, { + // reflex for supported browsers + backgroundColor: Highcharts.svg ? { + radialGradient: { + cx: 0.5, + cy: -0.4, + r: 1.9 + }, + stops: [ + [0.5, \'rgba(81, 81, 81, 0.8)\'], + [0.5, \'rgba(59, 56, 59, 0.8)\'] + ] + } : null + }] + }, + + yAxis: { + + + labels: { + distance: -20, + + style: { + color: \'#848484\' + } + }, + min: 0, + max: 12, + lineWidth: 0, + showFirstLabel: false, + + minorTickInterval: \'auto\', + minorTickWidth: 1, + minorTickLength: 5, + minorTickPosition: \'inside\', + minorGridLineWidth: 0, + minorTickColor: \'#2e2e2e\', + + tickInterval: 1, + tickWidth: 2, + tickPosition: \'inside\', + tickLength: 10, + tickColor: \'#fff\', + title: { + text: \'\', + style: { + color: \'#fff\', + fontWeight: \'normal\', + fontSize: \'8px\', + lineHeight: \'10px\' + }, + y: 10 + } + }, + + tooltip: { + formatter: function () { + return this.series.chart.tooltipText; + } + }, + + series: [{ + data: [{ + id: \'hour\', + y: now.hours, + dial: { + radius: \'60%\', + baseWidth: 4, + baseLength: \'95%\', + rearLength: 0 + } + }, { + id: \'minute\', + y: now.minutes, + dial: { + baseLength: \'95%\', + rearLength: 0 + } + }, { + id: \'second\', + y: now.seconds, + dial: { + radius: \'100%\', + baseWidth: 1, + rearLength: \'20%\' + } + }], + animation: false, + dataLabels: { + enabled: false + } + }] + }, + + // Move + function (chart) { + setInterval(function () { + + now = getNow(); + + var hour = chart.get(\'hour\'), + minute = chart.get(\'minute\'), + second = chart.get(\'second\'), + // run animation unless we\'re wrapping around from 59 to 0 + animation = now.seconds === 0 ? + false : + { + easing: \'easeOutElastic\' + }; + + // Cache the tooltip text + chart.tooltipText = + pad(Math.floor(now.hours), 2) + \':\' + + pad(Math.floor(now.minutes * 5), 2) + \':\' + + pad(now.seconds * 5, 2); + + hour.update(now.hours, true, animation); + minute.update(now.minutes, true, animation); + second.update(now.seconds, true, animation); + + }, 1000); + + }); +}); + +// Extend jQuery with some easing (copied from jQuery UI) +$.extend($.easing, { + easeOutElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; + } +}); +//]]> diff --git a/html/includes/js/highcharts-3d.js b/html/includes/js/highcharts-3d.js new file mode 100644 index 0000000..c622493 --- /dev/null +++ b/html/includes/js/highcharts-3d.js @@ -0,0 +1,45 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + + (c) 2009-2013 Torstein Hønsi + + License: www.highcharts.com/license +*/ +(function(d){function x(f,a,b,c){var e,g,j;b*=t;a*=t;var i=[],h,k,o;b*=-1;h=c.x;k=c.y;o=(c.z===0?1.0E-4:c.z)*(c.vd||25);o=Math.max(500,o);var q=l(b),n=m(b),r=l(a),s=m(a),p,v,u;d.each(f,function(a){p=a.x-h;v=a.y-k;u=a.z||0;e=n*p-q*u;g=-q*r*p-n*r*u+s*v;j=q*s*p+n*s*u+r*v;e=e*((o-j)/o)+h;g=g*((o-j)/o)+k;i.push({x:z(e),y:z(g),z:z(j)})});return i}function A(f){return f!==void 0&&f!==null}function w(f,a,b,c,e,g,d,i){var h=[];return g>e&&g-e>n/2+1.0E-4?(h=h.concat(w(f,a,b,c,e,e+n/2,d,i)),h=h.concat(w(f,a, +b,c,e+n/2,g,d,i))):g<e&&e-g>n/2+1.0E-4?(h=h.concat(w(f,a,b,c,e,e-n/2,d,i)),h=h.concat(w(f,a,b,c,e-n/2,g,d,i))):(h=g-e,["C",f+b*m(e)-b*B*h*l(e)+d,a+c*l(e)+c*B*h*m(e)+i,f+b*m(g)+b*B*h*l(g)+d,a+c*l(g)-c*B*h*m(g)+i,f+b*m(g)+d,a+c*l(g)+i])}function D(f){if(this.chart.is3d()){var a=this.chart.options.plotOptions.column.grouping;a!==void 0&&!a&&this.group.zIndex!==void 0&&this.group.attr({zIndex:this.group.zIndex*10});var b=this.options,c=this.options.states;this.borderWidth=b.borderWidth=b.edgeWidth||1; +d.each(this.data,function(a){if(a.y!==null)a=a.pointAttr,this.borderColor=d.pick(b.edgeColor,a[""].fill),a[""].stroke=this.borderColor,a.hover.stroke=d.pick(c.hover.edgeColor,this.borderColor),a.select.stroke=d.pick(c.select.edgeColor,this.borderColor)})}f.apply(this,[].slice.call(arguments,1))}var n=Math.PI,t=n/180,l=Math.sin,m=Math.cos,z=Math.round,B=4*(Math.sqrt(2)-1)/3/(n/2);d.SVGRenderer.prototype.toLinePath=function(f,a){var b=[];d.each(f,function(a){b.push("L",a.x,a.y)});b[0]="M";a&&b.push("Z"); +return b};d.SVGRenderer.prototype.cuboid=function(f){var a=this.g(),f=this.cuboidPath(f);a.front=this.path(f[0]).attr({zIndex:f[3],"stroke-linejoin":"round"}).add(a);a.top=this.path(f[1]).attr({zIndex:f[4],"stroke-linejoin":"round"}).add(a);a.side=this.path(f[2]).attr({zIndex:f[5],"stroke-linejoin":"round"}).add(a);a.fillSetter=function(a){var c=d.Color(a).brighten(0.1).get(),e=d.Color(a).brighten(-0.1).get();this.front.attr({fill:a});this.top.attr({fill:c});this.side.attr({fill:e});this.color=a; +return this};a.opacitySetter=function(a){this.front.attr({opacity:a});this.top.attr({opacity:a});this.side.attr({opacity:a});return this};a.attr=function(a){a.shapeArgs||A(a.x)?(a=this.renderer.cuboidPath(a.shapeArgs||a),this.front.attr({d:a[0],zIndex:a[3]}),this.top.attr({d:a[1],zIndex:a[4]}),this.side.attr({d:a[2],zIndex:a[5]})):d.SVGElement.prototype.attr.call(this,a);return this};a.animate=function(a,c,e){A(a.x)&&A(a.y)?(a=this.renderer.cuboidPath(a),this.front.attr({zIndex:a[3]}).animate({d:a[0]}, +c,e),this.top.attr({zIndex:a[4]}).animate({d:a[1]},c,e),this.side.attr({zIndex:a[5]}).animate({d:a[2]},c,e)):a.opacity?(this.front.animate(a,c,e),this.top.animate(a,c,e),this.side.animate(a,c,e)):d.SVGElement.prototype.animate.call(this,a,c,e);return this};a.destroy=function(){this.front.destroy();this.top.destroy();this.side.destroy();return null};a.attr({zIndex:-f[3]});return a};d.SVGRenderer.prototype.cuboidPath=function(d){var a=d.x,b=d.y,c=d.z,e=d.height,g=d.width,j=d.depth,i=d.alpha,h=d.beta, +a=[{x:a,y:b,z:c},{x:a+g,y:b,z:c},{x:a+g,y:b+e,z:c},{x:a,y:b+e,z:c},{x:a,y:b+e,z:c+j},{x:a+g,y:b+e,z:c+j},{x:a+g,y:b,z:c+j},{x:a,y:b,z:c+j}],a=x(a,i,h,d.origin),d=["M",a[0].x,a[0].y,"L",a[7].x,a[7].y,"L",a[6].x,a[6].y,"L",a[1].x,a[1].y,"Z"],b=["M",a[3].x,a[3].y,"L",a[2].x,a[2].y,"L",a[5].x,a[5].y,"L",a[4].x,a[4].y,"Z"],c=["M",a[1].x,a[1].y,"L",a[2].x,a[2].y,"L",a[5].x,a[5].y,"L",a[6].x,a[6].y,"Z"],e=["M",a[0].x,a[0].y,"L",a[7].x,a[7].y,"L",a[4].x,a[4].y,"L",a[3].x,a[3].y,"Z"];return[["M",a[0].x,a[0].y, +"L",a[1].x,a[1].y,"L",a[2].x,a[2].y,"L",a[3].x,a[3].y,"Z"],a[7].y<a[1].y?d:a[4].y>a[2].y?b:[],a[6].x>a[1].x?c:a[7].x<a[0].x?e:[],(a[0].z+a[1].z+a[2].z+a[3].z)/4,h>0?(a[0].z+a[7].z+a[6].z+a[1].z)/4:(a[3].z+a[2].z+a[5].z+a[4].z)/4,i>0?(a[1].z+a[2].z+a[5].z+a[6].z)/4:(a[0].z+a[7].z+a[4].z+a[3].z)/4]};d.SVGRenderer.prototype.arc3d=function(f){f.alpha*=t;f.beta*=t;var a=this.g(),b=this.arc3dPath(f),c=a.renderer,e=b.zTop*100;a.shapeArgs=f;a.top=c.path(b.top).attr({zIndex:b.zTop}).add(a);a.side1=c.path(b.side2).attr({zIndex:b.zSide2}); +a.side2=c.path(b.side1).attr({zIndex:b.zSide1});a.inn=c.path(b.inn).attr({zIndex:b.zInn});a.out=c.path(b.out).attr({zIndex:b.zOut});a.fillSetter=function(a){this.color=a;var b=d.Color(a).brighten(-0.1).get();this.side1.attr({fill:b});this.side2.attr({fill:b});this.inn.attr({fill:b});this.out.attr({fill:b});this.top.attr({fill:a});return this};a.translateXSetter=function(a){this.out.attr({translateX:a});this.inn.attr({translateX:a});this.side1.attr({translateX:a});this.side2.attr({translateX:a});this.top.attr({translateX:a})}; +a.translateYSetter=function(a){this.out.attr({translateY:a});this.inn.attr({translateY:a});this.side1.attr({translateY:a});this.side2.attr({translateY:a});this.top.attr({translateY:a})};a.animate=function(a,b,c){A(a.end)||A(a.start)?(this._shapeArgs=this.shapeArgs,d.SVGElement.prototype.animate.call(this,{_args:a},{duration:b,step:function(){var a=arguments[1],b=a.elem,c=b._shapeArgs,e=a.end,a=a.pos,c=d.merge(c,{x:c.x+(e.x-c.x)*a,y:c.y+(e.y-c.y)*a,r:c.r+(e.r-c.r)*a,innerR:c.innerR+(e.innerR-c.innerR)* +a,start:c.start+(e.start-c.start)*a,end:c.end+(e.end-c.end)*a}),e=b.renderer.arc3dPath(c);b.shapeArgs=c;b.top.attr({d:e.top,zIndex:e.zTop});b.inn.attr({d:e.inn,zIndex:e.zInn});b.out.attr({d:e.out,zIndex:e.zOut});b.side1.attr({d:e.side1,zIndex:e.zSide1});b.side2.attr({d:e.side2,zIndex:e.zSide2})}},c)):d.SVGElement.prototype.animate.call(this,a,b,c);return this};a.destroy=function(){this.top.destroy();this.out.destroy();this.inn.destroy();this.side1.destroy();this.side2.destroy();d.SVGElement.prototype.destroy.call(this)}; +a.hide=function(){this.top.hide();this.out.hide();this.inn.hide();this.side1.hide();this.side2.hide()};a.show=function(){this.top.show();this.out.show();this.inn.show();this.side1.show();this.side2.show()};a.zIndex=e;a.attr({zIndex:e});return a};d.SVGRenderer.prototype.arc3dPath=function(d){var a=d.x,b=d.y,c=d.start,e=d.end-1.0E-5,g=d.r,j=d.innerR,i=d.depth,h=d.alpha,k=d.beta,o=m(c),q=l(c),d=m(e),y=l(e),r=g*m(k),s=g*m(h),p=j*m(k);j*=m(h);var v=i*l(k),u=i*l(h),i=["M",a+r*o,b+s*q],i=i.concat(w(a,b, +r,s,c,e,0,0)),i=i.concat(["L",a+p*d,b+j*y]),i=i.concat(w(a,b,p,j,e,c,0,0)),i=i.concat(["Z"]),k=k>0?n/2:0,h=h>0?0:n/2,k=c>-k?c:e>-k?-k:c,t=e<n-h?e:c<n-h?n-h:e,h=["M",a+r*m(k),b+s*l(k)],h=h.concat(w(a,b,r,s,k,t,0,0)),h=h.concat(["L",a+r*m(t)+v,b+s*l(t)+u]),h=h.concat(w(a,b,r,s,t,k,v,u)),h=h.concat(["Z"]),k=["M",a+p*o,b+j*q],k=k.concat(w(a,b,p,j,c,e,0,0)),k=k.concat(["L",a+p*m(e)+v,b+j*l(e)+u]),k=k.concat(w(a,b,p,j,e,c,v,u)),k=k.concat(["Z"]),o=["M",a+r*o,b+s*q,"L",a+r*o+v,b+s*q+u,"L",a+p*o+v,b+j*q+ +u,"L",a+p*o,b+j*q,"Z"],a=["M",a+r*d,b+s*y,"L",a+r*d+v,b+s*y+u,"L",a+p*d+v,b+j*y+u,"L",a+p*d,b+j*y,"Z"],b=l((c+e)/2),c=l(c),e=l(e);return{top:i,zTop:g,out:h,zOut:Math.max(b,c,e)*g,inn:k,zInn:Math.max(b,c,e)*g,side1:o,zSide1:c*g*0.99,side2:a,zSide2:e*g*0.99}};d.Chart.prototype.is3d=function(){return this.options.chart.options3d&&this.options.chart.options3d.enabled};d.wrap(d.Chart.prototype,"isInsidePlot",function(d){return this.is3d()?!0:d.apply(this,[].slice.call(arguments,1))});d.getOptions().chart.options3d= +{enabled:!1,alpha:0,beta:0,depth:100,viewDistance:25,frame:{bottom:{size:1,color:"rgba(255,255,255,0)"},side:{size:1,color:"rgba(255,255,255,0)"},back:{size:1,color:"rgba(255,255,255,0)"}}};d.wrap(d.Chart.prototype,"init",function(f){var a=[].slice.call(arguments,1),b;if(a[0].chart.options3d&&a[0].chart.options3d.enabled)b=a[0].plotOptions||{},b=b.pie||{},b.borderColor=d.pick(b.borderColor,void 0);f.apply(this,a)});d.wrap(d.Chart.prototype,"setChartSize",function(d){d.apply(this,[].slice.call(arguments, +1));if(this.is3d()){var a=this.inverted,b=this.clipBox,c=this.margin;b[a?"y":"x"]=-(c[3]||0);b[a?"x":"y"]=-(c[0]||0);b[a?"height":"width"]=this.chartWidth+(c[3]||0)+(c[1]||0);b[a?"width":"height"]=this.chartHeight+(c[0]||0)+(c[2]||0)}});d.wrap(d.Chart.prototype,"redraw",function(d){if(this.is3d())this.isDirtyBox=!0;d.apply(this,[].slice.call(arguments,1))});d.Chart.prototype.retrieveStacks=function(f,a){var b={},c=1;if(f||!a)return this.series;d.each(this.series,function(a){b[a.options.stack||0]? +b[a.options.stack||0].series.push(a):(b[a.options.stack||0]={series:[a],position:c},c++)});b.totalStacks=c+1;return b};d.wrap(d.Axis.prototype,"init",function(f){var a=arguments;if(a[1].is3d())a[2].tickWidth=d.pick(a[2].tickWidth,0),a[2].gridLineWidth=d.pick(a[2].gridLineWidth,1);f.apply(this,[].slice.call(arguments,1))});d.wrap(d.Axis.prototype,"render",function(d){d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.renderer,c=a.options.chart.options3d,e=c.alpha,g= +c.beta*(a.yAxis[0].opposite?-1:1),j=c.frame,i=j.bottom,h=j.back,j=j.side,k=c.depth,o=this.height,q=this.width,l=this.left,m=this.top,c={x:a.plotLeft+a.plotWidth/2,y:a.plotTop+a.plotHeight/2,z:k,vd:c.viewDistance};if(this.horiz)this.axisLine&&this.axisLine.hide(),g={x:l,y:m+(a.yAxis[0].reversed?-i.size:o),z:0,width:q,height:i.size,depth:k,alpha:e,beta:g,origin:c},this.bottomFrame?this.bottomFrame.animate(g):this.bottomFrame=b.cuboid(g).attr({fill:i.color,zIndex:a.yAxis[0].reversed&&e>0?4:-1}).css({stroke:i.color}).add(); +else{var n={x:l,y:m,z:k+1,width:q,height:o+i.size,depth:h.size,alpha:e,beta:g,origin:c};this.backFrame?this.backFrame.animate(n):this.backFrame=b.cuboid(n).attr({fill:h.color,zIndex:-3}).css({stroke:h.color}).add();this.axisLine&&this.axisLine.hide();a={x:(a.yAxis[0].opposite?q:0)+l-j.size,y:m,z:0,width:j.size,height:o+i.size,depth:k+h.size,alpha:e,beta:g,origin:c};this.sideFrame?this.sideFrame.animate(a):this.sideFrame=b.cuboid(a).attr({fill:j.color,zIndex:-2}).css({stroke:j.color}).add()}}});d.wrap(d.Axis.prototype, +"getPlotLinePath",function(d){var a=d.apply(this,[].slice.call(arguments,1));if(!this.chart.is3d())return a;if(a===null)return a;var b=this.chart,c=b.options.chart.options3d,e=c.depth;c.origin={x:b.plotLeft+b.plotWidth/2,y:b.plotTop+b.plotHeight/2,z:e,vd:c.viewDistance};var a=[{x:a[1],y:a[2],z:this.horiz||this.opposite?e:0},{x:a[1],y:a[2],z:e},{x:a[4],y:a[5],z:e},{x:a[4],y:a[5],z:this.horiz||this.opposite?0:e}],e=b.options.inverted?c.beta:c.alpha,g=b.options.inverted?c.alpha:c.beta;g*=b.yAxis[0].opposite? +-1:1;a=x(a,e,g,c.origin);return a=this.chart.renderer.toLinePath(a,!1)});d.wrap(d.Axis.prototype,"getPlotBandPath",function(d){if(this.chart.is3d()){var a=arguments,b=a[1],a=this.getPlotLinePath(a[2]);(b=this.getPlotLinePath(b))&&a?b.push(a[7],a[8],a[4],a[5],a[1],a[2]):b=null;return b}else return d.apply(this,[].slice.call(arguments,1))});d.wrap(d.Tick.prototype,"getMarkPath",function(d){var a=d.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;var b=this.axis.chart,c=b.options.chart.options3d, +e={x:b.plotLeft+b.plotWidth/2,y:b.plotTop+b.plotHeight/2,z:c.depth,vd:c.viewDistance},a=[{x:a[1],y:a[2],z:0},{x:a[4],y:a[5],z:0}],g=b.inverted?c.beta:c.alpha,c=b.inverted?c.alpha:c.beta;c*=b.yAxis[0].opposite?-1:1;a=x(a,g,c,e);return a=["M",a[0].x,a[0].y,"L",a[1].x,a[1].y]});d.wrap(d.Tick.prototype,"getLabelPosition",function(d){var a=d.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;var b=this.axis.chart,c=b.options.chart.options3d,e={x:b.plotLeft+b.plotWidth/2,y:b.plotTop+ +b.plotHeight/2,z:c.depth,vd:c.viewDistance},g=b.inverted?c.beta:c.alpha,c=b.inverted?c.alpha:c.beta;c*=b.yAxis[0].opposite?-1:1;return a=x([{x:a.x,y:a.y,z:0}],g,c,e)[0]});d.wrap(d.Axis.prototype,"drawCrosshair",function(d){var a=arguments;this.chart.is3d()&&a[2]&&(a[2]={plotX:a[2].plotXold||a[2].plotX,plotY:a[2].plotYold||a[2].plotY});d.apply(this,[].slice.call(a,1))});d.wrap(d.seriesTypes.column.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a= +this.chart,b=this.options,c=a.options.chart.options3d,e=b.depth||25,g={x:a.plotWidth/2,y:a.plotHeight/2,z:c.depth,vd:c.viewDistance},j=c.alpha,i=c.beta*(a.yAxis[0].opposite?-1:1),h=(b.stacking?b.stack||0:this._i)*(e+(b.groupZPadding||1));b.grouping!==!1&&(h=0);h+=b.groupZPadding||1;d.each(this.data,function(a){if(a.y!==null){var b=a.shapeArgs,c=a.tooltipPos;a.shapeType="cuboid";b.alpha=j;b.beta=i;b.z=h;b.origin=g;b.depth=e;c=x([{x:c[0],y:c[1],z:h}],j,i,g)[0];a.tooltipPos=[c.x,c.y]}})}});d.wrap(d.seriesTypes.column.prototype, +"animate",function(f){if(this.chart.is3d()){var a=arguments[1],b=this.yAxis,c=this,e=this.yAxis.reversed;if(d.svg)a?d.each(c.data,function(a){if(a.y!==null&&(a.height=a.shapeArgs.height,a.shapey=a.shapeArgs.y,a.shapeArgs.height=1,!e))a.shapeArgs.y=a.stackY?a.plotY+b.translate(a.stackY):a.plotY+(a.negative?-a.height:a.height)}):(d.each(c.data,function(a){if(a.y!==null)a.shapeArgs.height=a.height,a.shapeArgs.y=a.shapey,a.graphic&&a.graphic.animate(a.shapeArgs,c.options.animation)}),this.drawDataLabels(), +c.animate=null)}else f.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.column.prototype,"init",function(d){d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.options,b=a.grouping,c=a.stacking,e=0;if((b===void 0||b)&&c){b=this.chart.retrieveStacks(b,c);c=a.stack||0;for(e=0;e<b[c].series.length;e++)if(b[c].series[e]===this)break;e=b.totalStacks*10-10*(b.totalStacks-b[c].position)-e}a.zIndex=e}});d.wrap(d.Series.prototype,"alignDataLabel",function(d){if(this.chart.is3d()&& +(this.type==="column"||this.type==="columnrange")){var a=this.chart,b=a.options.chart.options3d,c=arguments[4],e={x:c.x,y:c.y,z:0},e=x([e],b.alpha,b.beta*(a.yAxis[0].opposite?-1:1),{x:a.plotWidth/2,y:a.plotHeight/2,z:b.depth,vd:b.viewDistance})[0];c.x=e.x;c.y=e.y}d.apply(this,[].slice.call(arguments,1))});d.seriesTypes.columnrange&&d.wrap(d.seriesTypes.columnrange.prototype,"drawPoints",D);d.wrap(d.seriesTypes.column.prototype,"drawPoints",D);var C=d.getOptions();C.plotOptions.cylinder=d.merge(C.plotOptions.column); +C=d.extendClass(d.seriesTypes.column,{type:"cylinder"});d.seriesTypes.cylinder=C;d.wrap(d.seriesTypes.cylinder.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.options,c=b.plotOptions.cylinder,b=b.chart.options3d,e=c.depth||0,g={x:a.inverted?a.plotHeight/2:a.plotWidth/2,y:a.inverted?a.plotWidth/2:a.plotHeight/2,z:b.depth,vd:b.viewDistance},j=b.alpha,i=c.stacking?(this.options.stack||0)*e:this._i*e;i+=e/2;c.grouping!==!1&&(i=0);d.each(this.data, +function(a){var b=a.shapeArgs;a.shapeType="arc3d";b.x+=e/2;b.z=i;b.start=0;b.end=2*n;b.r=e*0.95;b.innerR=0;b.depth=b.height*(1/l((90-j)*t))-i;b.alpha=90-j;b.beta=0;b.origin=g})}});d.wrap(d.seriesTypes.pie.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this,b=a.chart,c=a.options,e=c.depth||0,g=b.options.chart.options3d,j={x:b.plotWidth/2,y:b.plotHeight/2,z:g.depth},i=g.alpha,h=g.beta,k=c.stacking?(c.stack||0)*e:a._i*e;k+=e/2;c.grouping!==!1&& +(k=0);d.each(a.data,function(b){b.shapeType="arc3d";var c=b.shapeArgs;if(b.y)c.z=k,c.depth=e*0.75,c.origin=j,c.alpha=i,c.beta=h,c=(c.end+c.start)/2,b.slicedTranslation={translateX:z(m(c)*a.options.slicedOffset*m(i*t)),translateY:z(l(c)*a.options.slicedOffset*m(i*t))}})}});d.wrap(d.seriesTypes.pie.prototype.pointClass.prototype,"haloPath",function(d){var a=arguments;return this.series.chart.is3d()?[]:d.call(this,a[1])});d.wrap(d.seriesTypes.pie.prototype,"drawPoints",function(f){if(this.chart.is3d()){var a= +this.options,b=this.options.states;this.borderWidth=a.borderWidth=a.edgeWidth||1;this.borderColor=a.edgeColor=d.pick(a.edgeColor,a.borderColor,void 0);b.hover.borderColor=d.pick(b.hover.edgeColor,this.borderColor);b.hover.borderWidth=d.pick(b.hover.edgeWidth,this.borderWidth);b.select.borderColor=d.pick(b.select.edgeColor,this.borderColor);b.select.borderWidth=d.pick(b.select.edgeWidth,this.borderWidth);d.each(this.data,function(a){var c=a.pointAttr;c[""].stroke=a.series.borderColor||a.color;c[""]["stroke-width"]= +a.series.borderWidth;c.hover.stroke=b.hover.borderColor;c.hover["stroke-width"]=b.hover.borderWidth;c.select.stroke=b.select.borderColor;c.select["stroke-width"]=b.select.borderWidth})}f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var c=this.group;d.each(this.points,function(a){a.graphic.out.add(c);a.graphic.inn.add(c);a.graphic.side1.add(c);a.graphic.side2.add(c)})}});d.wrap(d.seriesTypes.pie.prototype,"drawDataLabels",function(f){this.chart.is3d()&&d.each(this.data,function(a){var b= +a.shapeArgs,c=b.r,d=b.depth,f=b.alpha*t,b=(b.start+b.end)/2,a=a.labelPos;a[1]+=-c*(1-m(f))*l(b)+(l(b)>0?l(f)*d:0);a[3]+=-c*(1-m(f))*l(b)+(l(b)>0?l(f)*d:0);a[5]+=-c*(1-m(f))*l(b)+(l(b)>0?l(f)*d:0)});f.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.pie.prototype,"addPoint",function(d){d.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&this.update()});d.wrap(d.seriesTypes.pie.prototype,"animate",function(f){if(this.chart.is3d()){var a=arguments[1],b=this.options.animation,c=this.center, +e=this.group,g=this.markerGroup;if(d.svg)if(b===!0&&(b={}),a){if(e.oldtranslateX=e.translateX,e.oldtranslateY=e.translateY,a={translateX:c[0],translateY:c[1],scaleX:0.001,scaleY:0.001},e.attr(a),g)g.attrSetters=e.attrSetters,g.attr(a)}else a={translateX:e.oldtranslateX,translateY:e.oldtranslateY,scaleX:1,scaleY:1},e.animate(a,b),g&&g.animate(a,b),this.animate=null}else f.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.scatter.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments, +1));if(this.chart.is3d()){var a=this.chart,b=this.chart.options.chart.options3d,c=b.alpha,e=b.beta,g={x:a.inverted?a.plotHeight/2:a.plotWidth/2,y:a.inverted?a.plotWidth/2:a.plotHeight/2,z:b.depth,vd:b.viewDistance},b=b.depth,j=a.options.zAxis||{min:0,max:b},i=b/(j.max-j.min);d.each(this.data,function(a){var b={x:a.plotX,y:a.plotY,z:(a.z-j.min)*i},b=x([b],c,e,g)[0];a.plotXold=a.plotX;a.plotYold=a.plotY;a.plotX=b.x;a.plotY=b.y;a.plotZ=b.z})}});d.wrap(d.seriesTypes.scatter.prototype,"init",function(d){var a= +d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d())this.pointArrayMap=["x","y","z"],this.tooltipOptions.pointFormat=this.userOptions.tooltip?this.userOptions.tooltip.pointFormat||"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>":"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>";return a});if(d.VMLRenderer)d.setOptions({animate:!1}),d.VMLRenderer.prototype.cuboid=d.SVGRenderer.prototype.cuboid,d.VMLRenderer.prototype.cuboidPath=d.SVGRenderer.prototype.cuboidPath, +d.VMLRenderer.prototype.toLinePath=d.SVGRenderer.prototype.toLinePath,d.VMLRenderer.prototype.createElement3D=d.SVGRenderer.prototype.createElement3D,d.VMLRenderer.prototype.arc3d=function(f){f=d.SVGRenderer.prototype.arc3d.call(this,f);f.css({zIndex:f.zIndex});return f},d.VMLRenderer.prototype.arc3dPath=d.SVGRenderer.prototype.arc3dPath,d.Chart.prototype.renderSeries=function(){for(var d,a=this.series.length;a--;)d=this.series[a],d.translate(),d.setTooltipPoints&&d.setTooltipPoints(),d.render()}, +d.wrap(d.Axis.prototype,"render",function(d){d.apply(this,[].slice.call(arguments,1));this.sideFrame&&(this.sideFrame.css({zIndex:0}),this.sideFrame.front.attr({fill:this.sideFrame.color}));this.bottomFrame&&(this.bottomFrame.css({zIndex:1}),this.bottomFrame.front.attr({fill:this.bottomFrame.color}));this.backFrame&&(this.backFrame.css({zIndex:0}),this.backFrame.front.attr({fill:this.backFrame.color}))})})(Highcharts); diff --git a/html/includes/js/highcharts-3d.src.js b/html/includes/js/highcharts-3d.src.js new file mode 100644 index 0000000..7cee3e5 --- /dev/null +++ b/html/includes/js/highcharts-3d.src.js @@ -0,0 +1,1383 @@ +// ==ClosureCompiler== +// @compilation_level SIMPLE_OPTIMIZATIONS + +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * + * (c) 2009-2013 Torstein Hønsi + * + * License: www.highcharts.com/license + */ + +// JSLint options: +/*global Highcharts, HighchartsAdapter, document, window, navigator, setInterval, clearInterval, clearTimeout, setTimeout, location, jQuery, $, console */ + +(function (Highcharts) { + /** + Shorthands for often used function +*/ +/** + * Mathematical Functionility + */ +var PI = Math.PI, + deg2rad = (PI / 180), // degrees to radians + sin = Math.sin, + cos = Math.cos, + + round = Math.round; + +function perspective(points, angle2, angle1, origin) { + angle1 *= deg2rad; + angle2 *= deg2rad; + + var result = [], + xe, + ye, + ze; + + angle1 *= -1; + + xe = origin.x; + ye = origin.y; + ze = (origin.z === 0 ? 0.0001 : origin.z) * (origin.vd || 25); + + // some kind of minimum? + ze = Math.max(500, ze); + + var s1 = sin(angle1), + c1 = cos(angle1), + s2 = sin(angle2), + c2 = cos(angle2); + + var x, y, z, p; + + Highcharts.each(points, function (point) { + x = point.x - xe; + y = point.y - ye; + z = point.z || 0; + + p = { + x: c1 * x - s1 * z, + y: -s1 * s2 * x - c1 * s2 * z + c2 * y, + z: s1 * c2 * x + c1 * c2 * z + s2 * y + }; + + p.x = p.x * ((ze - p.z) / ze) + xe; + p.y = p.y * ((ze - p.z) / ze) + ye; + + result.push({x: round(p.x), y: round(p.y), z: round(p.z)}); + }); + return result; +} +/*** + EXTENSION TO THE SVG-RENDERER TO ENABLE 3D SHAPES + ***/ +////// HELPER METHODS ////// +var dFactor = (4 * (Math.sqrt(2) - 1) / 3) / (PI / 2); + +function defined(obj) { + return obj !== undefined && obj !== null; +} + + +function curveTo(cx, cy, rx, ry, start, end, dx, dy) { + var result = []; + if ((end > start) && (end - start > PI / 2 + 0.0001)) { + result = result.concat(curveTo(cx, cy, rx, ry, start, start + (PI / 2), dx, dy)); + result = result.concat(curveTo(cx, cy, rx, ry, start + (PI / 2), end, dx, dy)); + return result; + } else if ((end < start) && (start - end > PI / 2 + 0.0001)) { + result = result.concat(curveTo(cx, cy, rx, ry, start, start - (PI / 2), dx, dy)); + result = result.concat(curveTo(cx, cy, rx, ry, start - (PI / 2), end, dx, dy)); + return result; + } else { + var arcAngle = end - start; + return [ + 'C', + cx + (rx * cos(start)) - ((rx * dFactor * arcAngle) * sin(start)) + dx, + cy + (ry * sin(start)) + ((ry * dFactor * arcAngle) * cos(start)) + dy, + cx + (rx * cos(end)) + ((rx * dFactor * arcAngle) * sin(end)) + dx, + cy + (ry * sin(end)) - ((ry * dFactor * arcAngle) * cos(end)) + dy, + + cx + (rx * cos(end)) + dx, + cy + (ry * sin(end)) + dy + ]; + } +} + +Highcharts.SVGRenderer.prototype.toLinePath = function (points, closed) { + var result = []; + + // Put "L x y" for each point + Highcharts.each(points, function (point) { + result.push('L', point.x, point.y); + }); + + // Set the first element to M + result[0] = 'M'; + + // If it is a closed line, add Z + if (closed) { + result.push('Z'); + } + + return result; +}; + +////// CUBOIDS ////// +Highcharts.SVGRenderer.prototype.cuboid = function (shapeArgs) { + + var result = this.g(), + paths = this.cuboidPath(shapeArgs); + + result.front = this.path(paths[0]).attr({zIndex: paths[3], 'stroke-linejoin': 'round'}).add(result); + result.top = this.path(paths[1]).attr({zIndex: paths[4], 'stroke-linejoin': 'round'}).add(result); + result.side = this.path(paths[2]).attr({zIndex: paths[5], 'stroke-linejoin': 'round'}).add(result); + + result.fillSetter = function (color) { + var c0 = color, + c1 = Highcharts.Color(color).brighten(0.1).get(), + c2 = Highcharts.Color(color).brighten(-0.1).get(); + + this.front.attr({fill: c0}); + this.top.attr({fill: c1}); + this.side.attr({fill: c2}); + + this.color = color; + return this; + }; + + result.opacitySetter = function (opacity) { + this.front.attr({opacity: opacity}); + this.top.attr({opacity: opacity}); + this.side.attr({opacity: opacity}); + return this; + }; + + result.attr = function (args) { + if (args.shapeArgs || defined(args.x)) { + var shapeArgs = args.shapeArgs || args; + var paths = this.renderer.cuboidPath(shapeArgs); + this.front.attr({d: paths[0], zIndex: paths[3]}); + this.top.attr({d: paths[1], zIndex: paths[4]}); + this.side.attr({d: paths[2], zIndex: paths[5]}); + } else { + Highcharts.SVGElement.prototype.attr.call(this, args); + } + + return this; + }; + + result.animate = function (args, duration, complete) { + if (defined(args.x) && defined(args.y)) { + var paths = this.renderer.cuboidPath(args); + this.front.attr({zIndex: paths[3]}).animate({d: paths[0]}, duration, complete); + this.top.attr({zIndex: paths[4]}).animate({d: paths[1]}, duration, complete); + this.side.attr({zIndex: paths[5]}).animate({d: paths[2]}, duration, complete); + } else if (args.opacity) { + this.front.animate(args, duration, complete); + this.top.animate(args, duration, complete); + this.side.animate(args, duration, complete); + } else { + Highcharts.SVGElement.prototype.animate.call(this, args, duration, complete); + } + return this; + }; + + result.destroy = function () { + this.front.destroy(); + this.top.destroy(); + this.side.destroy(); + + return null; + }; + + // Apply the Z index to the cuboid group + result.attr({ zIndex: -paths[3] }); + + return result; +}; + + +Highcharts.SVGRenderer.prototype.cuboidPath = function (shapeArgs) { + var x = shapeArgs.x, + y = shapeArgs.y, + z = shapeArgs.z, + h = shapeArgs.height, + w = shapeArgs.width, + d = shapeArgs.depth, + alpha = shapeArgs.alpha, + beta = shapeArgs.beta, + origin = shapeArgs.origin; + + var pArr = [ + {x: x, y: y, z: z}, + {x: x + w, y: y, z: z}, + {x: x + w, y: y + h, z: z}, + {x: x, y: y + h, z: z}, + {x: x, y: y + h, z: z + d}, + {x: x + w, y: y + h, z: z + d}, + {x: x + w, y: y, z: z + d}, + {x: x, y: y, z: z + d} + ]; + + pArr = perspective(pArr, alpha, beta, origin); + + var path1, // FRONT + path2, // TOP OR BOTTOM + path3; // LEFT OR RIGHT + + // front + path1 = [ + 'M', pArr[0].x, pArr[0].y, + 'L', pArr[1].x, pArr[1].y, + 'L', pArr[2].x, pArr[2].y, + 'L', pArr[3].x, pArr[3].y, + 'Z' + ]; + var z1 = (pArr[0].z + pArr[1].z + pArr[2].z + pArr[3].z) / 4; + + // top or bottom + var top = [ + 'M', pArr[0].x, pArr[0].y, + 'L', pArr[7].x, pArr[7].y, + 'L', pArr[6].x, pArr[6].y, + 'L', pArr[1].x, pArr[1].y, + 'Z' + ]; + var bottom = [ + 'M', pArr[3].x, pArr[3].y, + 'L', pArr[2].x, pArr[2].y, + 'L', pArr[5].x, pArr[5].y, + 'L', pArr[4].x, pArr[4].y, + 'Z' + ]; + if (pArr[7].y < pArr[1].y) { + path2 = top; + } else if (pArr[4].y > pArr[2].y) { + path2 = bottom; + } else { + path2 = []; + } + var z2 = (beta > 0 ? (pArr[0].z + pArr[7].z + pArr[6].z + pArr[1].z) / 4 : (pArr[3].z + pArr[2].z + pArr[5].z + pArr[4].z) / 4); + + // side + var right = [ + 'M', pArr[1].x, pArr[1].y, + 'L', pArr[2].x, pArr[2].y, + 'L', pArr[5].x, pArr[5].y, + 'L', pArr[6].x, pArr[6].y, + 'Z' + ]; + var left = [ + 'M', pArr[0].x, pArr[0].y, + 'L', pArr[7].x, pArr[7].y, + 'L', pArr[4].x, pArr[4].y, + 'L', pArr[3].x, pArr[3].y, + 'Z' + ]; + if (pArr[6].x > pArr[1].x) { + path3 = right; + } else if (pArr[7].x < pArr[0].x) { + path3 = left; + } else { + path3 = []; + } + var z3 = (alpha > 0 ? (pArr[1].z + pArr[2].z + pArr[5].z + pArr[6].z) / 4 : (pArr[0].z + pArr[7].z + pArr[4].z + pArr[3].z) / 4); + + return [path1, path2, path3, z1, z2, z3]; +}; + +////// SECTORS ////// +Highcharts.SVGRenderer.prototype.arc3d = function (shapeArgs) { + + shapeArgs.alpha *= deg2rad; + shapeArgs.beta *= deg2rad; + var result = this.g(), + paths = this.arc3dPath(shapeArgs), + renderer = result.renderer; + + var zIndex = paths.zTop * 100; + + result.shapeArgs = shapeArgs; // Store for later use + + result.top = renderer.path(paths.top).attr({zIndex: paths.zTop}).add(result); + result.side1 = renderer.path(paths.side2).attr({zIndex: paths.zSide2}); + result.side2 = renderer.path(paths.side1).attr({zIndex: paths.zSide1}); + result.inn = renderer.path(paths.inn).attr({zIndex: paths.zInn}); + result.out = renderer.path(paths.out).attr({zIndex: paths.zOut}); + + result.fillSetter = function (color) { + this.color = color; + + var c0 = color, + c2 = Highcharts.Color(color).brighten(-0.1).get(); + + this.side1.attr({fill: c2}); + this.side2.attr({fill: c2}); + this.inn.attr({fill: c2}); + this.out.attr({fill: c2}); + this.top.attr({fill: c0}); + return this; + }; + + result.translateXSetter = function (value) { + this.out.attr({translateX: value}); + this.inn.attr({translateX: value}); + this.side1.attr({translateX: value}); + this.side2.attr({translateX: value}); + this.top.attr({translateX: value}); + }; + + result.translateYSetter = function (value) { + this.out.attr({translateY: value}); + this.inn.attr({translateY: value}); + this.side1.attr({translateY: value}); + this.side2.attr({translateY: value}); + this.top.attr({translateY: value}); + }; + + result.animate = function (args, duration, complete) { + if (defined(args.end) || defined(args.start)) { + this._shapeArgs = this.shapeArgs; + + Highcharts.SVGElement.prototype.animate.call(this, { + _args: args + }, { + duration: duration, + step: function () { + var args = arguments, + fx = args[1], + result = fx.elem, + start = result._shapeArgs, + end = fx.end, + pos = fx.pos, + sA = Highcharts.merge(start, { + x: start.x + ((end.x - start.x) * pos), + y: start.y + ((end.y - start.y) * pos), + r: start.r + ((end.r - start.r) * pos), + innerR: start.innerR + ((end.innerR - start.innerR) * pos), + start: start.start + ((end.start - start.start) * pos), + end: start.end + ((end.end - start.end) * pos) + }); + + var paths = result.renderer.arc3dPath(sA); + + result.shapeArgs = sA; + + result.top.attr({d: paths.top, zIndex: paths.zTop}); + result.inn.attr({d: paths.inn, zIndex: paths.zInn}); + result.out.attr({d: paths.out, zIndex: paths.zOut}); + result.side1.attr({d: paths.side1, zIndex: paths.zSide1}); + result.side2.attr({d: paths.side2, zIndex: paths.zSide2}); + + } + }, complete); + } else { + Highcharts.SVGElement.prototype.animate.call(this, args, duration, complete); + } + return this; + }; + + result.destroy = function () { + this.top.destroy(); + this.out.destroy(); + this.inn.destroy(); + this.side1.destroy(); + this.side2.destroy(); + + Highcharts.SVGElement.prototype.destroy.call(this); + }; + result.hide = function () { + this.top.hide(); + this.out.hide(); + this.inn.hide(); + this.side1.hide(); + this.side2.hide(); + }; + result.show = function () { + this.top.show(); + this.out.show(); + this.inn.show(); + this.side1.show(); + this.side2.show(); + }; + + result.zIndex = zIndex; + result.attr({zIndex: zIndex}); + return result; +}; + + +Highcharts.SVGRenderer.prototype.arc3dPath = function (shapeArgs) { + var cx = shapeArgs.x, + cy = shapeArgs.y, + start = shapeArgs.start, + end = shapeArgs.end - 0.00001, + r = shapeArgs.r, + ir = shapeArgs.innerR, + d = shapeArgs.depth, + alpha = shapeArgs.alpha, + beta = shapeArgs.beta; + + // Some Variables + var cs = cos(start), + ss = sin(start), + ce = cos(end), + se = sin(end), + rx = r * cos(beta), + ry = r * cos(alpha), + irx = ir * cos(beta), + iry = ir * cos(alpha), + dx = d * sin(beta), + dy = d * sin(alpha); + + // TOP + var top = ['M', cx + (rx * cs), cy + (ry * ss)]; + top = top.concat(curveTo(cx, cy, rx, ry, start, end, 0, 0)); + top = top.concat([ + 'L', cx + (irx * ce), cy + (iry * se) + ]); + top = top.concat(curveTo(cx, cy, irx, iry, end, start, 0, 0)); + top = top.concat(['Z']); + + // OUTSIDE + var b = (beta > 0 ? PI / 2 : 0), + a = (alpha > 0 ? 0 : PI / 2); + + var start2 = start > -b ? start : (end > -b ? -b : start), + end2 = end < PI - a ? end : (start < PI - a ? PI - a : end); + + var out = ['M', cx + (rx * cos(start2)), cy + (ry * sin(start2))]; + out = out.concat(curveTo(cx, cy, rx, ry, start2, end2, 0, 0)); + out = out.concat([ + 'L', cx + (rx * cos(end2)) + dx, cy + (ry * sin(end2)) + dy + ]); + out = out.concat(curveTo(cx, cy, rx, ry, end2, start2, dx, dy)); + out = out.concat(['Z']); + + // INSIDE + var inn = ['M', cx + (irx * cs), cy + (iry * ss)]; + inn = inn.concat(curveTo(cx, cy, irx, iry, start, end, 0, 0)); + inn = inn.concat([ + 'L', cx + (irx * cos(end)) + dx, cy + (iry * sin(end)) + dy + ]); + inn = inn.concat(curveTo(cx, cy, irx, iry, end, start, dx, dy)); + inn = inn.concat(['Z']); + + // SIDES + var side1 = [ + 'M', cx + (rx * cs), cy + (ry * ss), + 'L', cx + (rx * cs) + dx, cy + (ry * ss) + dy, + 'L', cx + (irx * cs) + dx, cy + (iry * ss) + dy, + 'L', cx + (irx * cs), cy + (iry * ss), + 'Z' + ]; + var side2 = [ + 'M', cx + (rx * ce), cy + (ry * se), + 'L', cx + (rx * ce) + dx, cy + (ry * se) + dy, + 'L', cx + (irx * ce) + dx, cy + (iry * se) + dy, + 'L', cx + (irx * ce), cy + (iry * se), + 'Z' + ]; + + var a1 = sin((start + end) / 2), + a2 = sin(start), + a3 = sin(end); + + return { + top: top, + zTop: r, + out: out, + zOut: Math.max(a1, a2, a3) * r, + inn: inn, + zInn: Math.max(a1, a2, a3) * r, + side1: side1, + zSide1: a2 * (r * 0.99), + side2: side2, + zSide2: a3 * (r * 0.99) + }; +}; +/*** + EXTENSION FOR 3D CHARTS +***/ +// Shorthand to check the is3d flag +Highcharts.Chart.prototype.is3d = function () { + return this.options.chart.options3d && this.options.chart.options3d.enabled; +}; + +Highcharts.wrap(Highcharts.Chart.prototype, 'isInsidePlot', function (proceed) { + if (this.is3d()) { + return true; + } else { + return proceed.apply(this, [].slice.call(arguments, 1)); + } +}); + +var defaultChartOptions = Highcharts.getOptions(); +defaultChartOptions.chart.options3d = { + enabled: false, + alpha: 0, + beta: 0, + depth: 100, + viewDistance: 25, + frame: { + bottom: { size: 1, color: 'rgba(255,255,255,0)' }, + side: { size: 1, color: 'rgba(255,255,255,0)' }, + back: { size: 1, color: 'rgba(255,255,255,0)' } + } +}; + +Highcharts.wrap(Highcharts.Chart.prototype, 'init', function (proceed) { + var args = [].slice.call(arguments, 1), + plotOptions, + pieOptions; + + if (args[0].chart.options3d && args[0].chart.options3d.enabled) { + plotOptions = args[0].plotOptions || {}; + pieOptions = plotOptions.pie || {}; + + pieOptions.borderColor = Highcharts.pick(pieOptions.borderColor, undefined); + } + proceed.apply(this, args); +}); + +Highcharts.wrap(Highcharts.Chart.prototype, 'setChartSize', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + + if (this.is3d()) { + var inverted = this.inverted, + clipBox = this.clipBox, + margin = this.margin, + x = inverted ? 'y' : 'x', + y = inverted ? 'x' : 'y', + w = inverted ? 'height' : 'width', + h = inverted ? 'width' : 'height'; + + clipBox[x] = -(margin[3] || 0); + clipBox[y] = -(margin[0] || 0); + clipBox[w] = this.chartWidth + (margin[3] || 0) + (margin[1] || 0); + clipBox[h] = this.chartHeight + (margin[0] || 0) + (margin[2] || 0); + } +}); + +Highcharts.wrap(Highcharts.Chart.prototype, 'redraw', function (proceed) { + if (this.is3d()) { + // Set to force a redraw of all elements + this.isDirtyBox = true; + } + proceed.apply(this, [].slice.call(arguments, 1)); +}); + +Highcharts.Chart.prototype.retrieveStacks = function (grouping, stacking) { + + var stacks = {}, + i = 1; + + if (grouping || !stacking) { return this.series; } + + Highcharts.each(this.series, function (S) { + if (!stacks[S.options.stack || 0]) { + stacks[S.options.stack || 0] = { series: [S], position: i}; + i++; + } else { + stacks[S.options.stack || 0].series.push(S); + } + }); + stacks.totalStacks = i + 1; + return stacks; +}; + +/*** + EXTENSION TO THE AXIS +***/ +Highcharts.wrap(Highcharts.Axis.prototype, 'init', function (proceed) { + var args = arguments; + if (args[1].is3d()) { + args[2].tickWidth = Highcharts.pick(args[2].tickWidth, 0); + args[2].gridLineWidth = Highcharts.pick(args[2].gridLineWidth, 1); + } + + proceed.apply(this, [].slice.call(arguments, 1)); +}); +Highcharts.wrap(Highcharts.Axis.prototype, 'render', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + + // Do not do this if the chart is not 3D + if (!this.chart.is3d()) { + return; + } + + var chart = this.chart, + renderer = chart.renderer, + options3d = chart.options.chart.options3d, + alpha = options3d.alpha, + beta = options3d.beta * (chart.yAxis[0].opposite ? -1 : 1), + frame = options3d.frame, + fbottom = frame.bottom, + fback = frame.back, + fside = frame.side, + depth = options3d.depth, + height = this.height, + width = this.width, + left = this.left, + top = this.top; + + var origin = { + x: chart.plotLeft + (chart.plotWidth / 2), + y: chart.plotTop + (chart.plotHeight / 2), + z: depth, + vd: options3d.viewDistance + }; + if (this.horiz) { + /// BOTTOM + if (this.axisLine) { + this.axisLine.hide(); + } + var bottomShape = { + x: left, + y: top + (chart.yAxis[0].reversed ? -fbottom.size : height), + z: 0, + width: width, + height: fbottom.size, + depth: depth, + alpha: alpha, + beta: beta, + origin: origin + }; + if (!this.bottomFrame) { + this.bottomFrame = renderer.cuboid(bottomShape).attr({fill: fbottom.color, zIndex: (chart.yAxis[0].reversed && alpha > 0 ? 4 : -1)}).css({stroke: fbottom.color}).add(); + } else { + this.bottomFrame.animate(bottomShape); + } + } else { + // BACK + var backShape = { + x: left, + y: top, + z: depth + 1, + width: width, + height: height + fbottom.size, + depth: fback.size, + alpha: alpha, + beta: beta, + origin: origin + }; + if (!this.backFrame) { + this.backFrame = renderer.cuboid(backShape).attr({fill: fback.color, zIndex: -3}).css({stroke: fback.color}).add(); + } else { + this.backFrame.animate(backShape); + } + // SIDE + if (this.axisLine) { + this.axisLine.hide(); + } + var sideShape = { + x: (chart.yAxis[0].opposite ? width : 0) + left - fside.size, + y: top, + z: 0, + width: fside.size, + height: height + fbottom.size, + depth: depth + fback.size, + alpha: alpha, + beta: beta, + origin: origin + }; + if (!this.sideFrame) { + this.sideFrame = renderer.cuboid(sideShape).attr({fill: fside.color, zIndex: -2}).css({stroke: fside.color}).add(); + } else { + this.sideFrame.animate(sideShape); + } + } +}); + +Highcharts.wrap(Highcharts.Axis.prototype, 'getPlotLinePath', function (proceed) { + var path = proceed.apply(this, [].slice.call(arguments, 1)); + + // Do not do this if the chart is not 3D + if (!this.chart.is3d()) { + return path; + } + + if (path === null) { return path; } + + var chart = this.chart, + options3d = chart.options.chart.options3d; + + var d = options3d.depth; + + options3d.origin = { + x: chart.plotLeft + (chart.plotWidth / 2), + y: chart.plotTop + (chart.plotHeight / 2), + z: d, + vd: options3d.viewDistance + }; + + var pArr = [ + { x: path[1], y: path[2], z : (this.horiz || this.opposite ? d : 0)}, + { x: path[1], y: path[2], z : d }, + { x: path[4], y: path[5], z : d }, + { x: path[4], y: path[5], z : (this.horiz || this.opposite ? 0 : d)} + ]; + + var alpha = chart.options.inverted ? options3d.beta : options3d.alpha, + beta = chart.options.inverted ? options3d.alpha : options3d.beta; + + beta *= (chart.yAxis[0].opposite ? -1 : 1); + + pArr = perspective(pArr, alpha, beta, options3d.origin); + path = this.chart.renderer.toLinePath(pArr, false); + + return path; +}); + +Highcharts.wrap(Highcharts.Axis.prototype, 'getPlotBandPath', function (proceed) { + // Do not do this if the chart is not 3D + if (!this.chart.is3d()) { + return proceed.apply(this, [].slice.call(arguments, 1)); + } else { + var args = arguments, + from = args[1], + to = args[2]; + + var toPath = this.getPlotLinePath(to), + path = this.getPlotLinePath(from); + + if (path && toPath) { + path.push( + toPath[7], // These two do not exist in the regular getPlotLine + toPath[8], // ---- # 3005 + toPath[4], + toPath[5], + toPath[1], + toPath[2] + ); + } else { // outside the axis area + path = null; + } + + return path; + } +}); + +/*** + EXTENSION TO THE TICKS +***/ + +Highcharts.wrap(Highcharts.Tick.prototype, 'getMarkPath', function (proceed) { + var path = proceed.apply(this, [].slice.call(arguments, 1)); + + // Do not do this if the chart is not 3D + if (!this.axis.chart.is3d()) { + return path; + } + + var chart = this.axis.chart, + options3d = chart.options.chart.options3d; + + var origin = { + x: chart.plotLeft + (chart.plotWidth / 2), + y: chart.plotTop + (chart.plotHeight / 2), + z: options3d.depth, + vd: options3d.viewDistance + }; + + var pArr = [ + {x: path[1], y: path[2], z: 0}, + {x: path[4], y: path[5], z: 0} + ]; + + var alpha = chart.inverted ? options3d.beta : options3d.alpha, + beta = chart.inverted ? options3d.alpha : options3d.beta; + + beta *= (chart.yAxis[0].opposite ? -1 : 1); + + pArr = perspective(pArr, alpha, beta, origin); + path = [ + 'M', pArr[0].x, pArr[0].y, + 'L', pArr[1].x, pArr[1].y + ]; + return path; +}); + +Highcharts.wrap(Highcharts.Tick.prototype, 'getLabelPosition', function (proceed) { + var pos = proceed.apply(this, [].slice.call(arguments, 1)); + + // Do not do this if the chart is not 3D + if (!this.axis.chart.is3d()) { + return pos; + } + + var chart = this.axis.chart, + options3d = chart.options.chart.options3d; + + var origin = { + x: chart.plotLeft + (chart.plotWidth / 2), + y: chart.plotTop + (chart.plotHeight / 2), + z: options3d.depth, + vd: options3d.viewDistance + }; + + var alpha = chart.inverted ? options3d.beta : options3d.alpha, + beta = chart.inverted ? options3d.alpha : options3d.beta; + + beta *= (chart.yAxis[0].opposite ? -1 : 1); + + pos = perspective([{x: pos.x, y: pos.y, z: 0}], alpha, beta, origin)[0]; + return pos; +}); + +Highcharts.wrap(Highcharts.Axis.prototype, 'drawCrosshair', function (proceed) { + var args = arguments; + if (this.chart.is3d()) { + if (args[2]) { + args[2] = { + plotX: args[2].plotXold || args[2].plotX, + plotY: args[2].plotYold || args[2].plotY + }; + } + } + proceed.apply(this, [].slice.call(args, 1)); +});/*** + EXTENSION FOR 3D COLUMNS +***/ +Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'translate', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + + // Do not do this if the chart is not 3D + if (!this.chart.is3d()) { + return; + } + + var series = this, + chart = series.chart, + options = chart.options, + seriesOptions = series.options, + options3d = options.chart.options3d, + + depth = seriesOptions.depth || 25, + origin = { + x: chart.plotWidth / 2, + y: chart.plotHeight / 2, + z: options3d.depth, + vd: options3d.viewDistance + }, + alpha = options3d.alpha, + beta = options3d.beta * (chart.yAxis[0].opposite ? -1 : 1); + + var stack = seriesOptions.stacking ? (seriesOptions.stack || 0) : series._i; + var z = stack * (depth + (seriesOptions.groupZPadding || 1)); + + if (seriesOptions.grouping !== false) { z = 0; } + + z += (seriesOptions.groupZPadding || 1); + + Highcharts.each(series.data, function (point) { + if (point.y !== null) { + var shapeArgs = point.shapeArgs, + tooltipPos = point.tooltipPos; + + point.shapeType = 'cuboid'; + shapeArgs.alpha = alpha; + shapeArgs.beta = beta; + shapeArgs.z = z; + shapeArgs.origin = origin; + shapeArgs.depth = depth; + + // Translate the tooltip position in 3d space + tooltipPos = perspective([{ x: tooltipPos[0], y: tooltipPos[1], z: z }], alpha, beta, origin)[0]; + point.tooltipPos = [tooltipPos.x, tooltipPos.y]; + } + }); +}); + +Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'animate', function (proceed) { + if (!this.chart.is3d()) { + proceed.apply(this, [].slice.call(arguments, 1)); + } else { + var args = arguments, + init = args[1], + yAxis = this.yAxis, + series = this, + reversed = this.yAxis.reversed; + + if (Highcharts.svg) { // VML is too slow anyway + if (init) { + Highcharts.each(series.data, function (point) { + if (point.y !== null) { + point.height = point.shapeArgs.height; + point.shapey = point.shapeArgs.y; //#2968 + point.shapeArgs.height = 1; + if (!reversed) { + if (point.stackY) { + point.shapeArgs.y = point.plotY + yAxis.translate(point.stackY); + } else { + point.shapeArgs.y = point.plotY + (point.negative ? -point.height : point.height); + } + } + } + }); + + } else { // run the animation + Highcharts.each(series.data, function (point) { + if (point.y !== null) { + point.shapeArgs.height = point.height; + point.shapeArgs.y = point.shapey; //#2968 + // null value do not have a graphic + if (point.graphic) { + point.graphic.animate(point.shapeArgs, series.options.animation); + } + } + }); + + // redraw datalabels to the correct position + this.drawDataLabels(); + + // delete this function to allow it only once + series.animate = null; + } + } + } +}); + +Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'init', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + + if (this.chart.is3d()) { + var seriesOptions = this.options, + grouping = seriesOptions.grouping, + stacking = seriesOptions.stacking, + z = 0; + + if (!(grouping !== undefined && !grouping) && stacking) { + var stacks = this.chart.retrieveStacks(grouping, stacking), + stack = seriesOptions.stack || 0, + i; // position within the stack + for (i = 0; i < stacks[stack].series.length; i++) { + if (stacks[stack].series[i] === this) { + break; + } + } + z = (stacks.totalStacks * 10) - (10 * (stacks.totalStacks - stacks[stack].position)) - i; + } + + seriesOptions.zIndex = z; + } +}); +function draw3DPoints(proceed) { + // Do not do this if the chart is not 3D + if (this.chart.is3d()) { + var grouping = this.chart.options.plotOptions.column.grouping; + if (grouping !== undefined && !grouping && this.group.zIndex !== undefined) { + this.group.attr({zIndex : (this.group.zIndex * 10)}); + } + + var options = this.options, + states = this.options.states; + + this.borderWidth = options.borderWidth = options.edgeWidth || 1; + + Highcharts.each(this.data, function (point) { + if (point.y !== null) { + var pointAttr = point.pointAttr; + + // Set the border color to the fill color to provide a smooth edge + this.borderColor = Highcharts.pick(options.edgeColor, pointAttr[''].fill); + + pointAttr[''].stroke = this.borderColor; + pointAttr.hover.stroke = Highcharts.pick(states.hover.edgeColor, this.borderColor); + pointAttr.select.stroke = Highcharts.pick(states.select.edgeColor, this.borderColor); + } + }); + } + + proceed.apply(this, [].slice.call(arguments, 1)); +} + +Highcharts.wrap(Highcharts.Series.prototype, 'alignDataLabel', function (proceed) { + + // Only do this for 3D columns and columnranges + if (this.chart.is3d() && (this.type === 'column' || this.type === 'columnrange')) { + var series = this, + chart = series.chart, + options = chart.options, + options3d = options.chart.options3d, + origin = { + x: chart.plotWidth / 2, + y: chart.plotHeight / 2, + z: options3d.depth, + vd: options3d.viewDistance + }, + alpha = options3d.alpha, + beta = options3d.beta * (chart.yAxis[0].opposite ? -1 : 1); + + var args = arguments, + alignTo = args[4]; + + var pos = ({x: alignTo.x, y: alignTo.y, z: 0}); + pos = perspective([pos], alpha, beta, origin)[0]; + alignTo.x = pos.x; + alignTo.y = pos.y; + } + + proceed.apply(this, [].slice.call(arguments, 1)); +}); + +if (Highcharts.seriesTypes.columnrange) { + Highcharts.wrap(Highcharts.seriesTypes.columnrange.prototype, 'drawPoints', draw3DPoints); +} + +Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'drawPoints', draw3DPoints); + +/*** + EXTENSION FOR 3D CYLINDRICAL COLUMNS + Not supported +***/ +var defaultOptions = Highcharts.getOptions(); +defaultOptions.plotOptions.cylinder = Highcharts.merge(defaultOptions.plotOptions.column); +var CylinderSeries = Highcharts.extendClass(Highcharts.seriesTypes.column, { + type: 'cylinder' +}); +Highcharts.seriesTypes.cylinder = CylinderSeries; + +Highcharts.wrap(Highcharts.seriesTypes.cylinder.prototype, 'translate', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + + // Do not do this if the chart is not 3D + if (!this.chart.is3d()) { + return; + } + + var series = this, + chart = series.chart, + options = chart.options, + cylOptions = options.plotOptions.cylinder, + options3d = options.chart.options3d, + depth = cylOptions.depth || 0, + origin = { + x: chart.inverted ? chart.plotHeight / 2 : chart.plotWidth / 2, + y: chart.inverted ? chart.plotWidth / 2 : chart.plotHeight / 2, + z: options3d.depth, + vd: options3d.viewDistance + }, + alpha = options3d.alpha; + + var z = cylOptions.stacking ? (this.options.stack || 0) * depth : series._i * depth; + z += depth / 2; + + if (cylOptions.grouping !== false) { z = 0; } + + Highcharts.each(series.data, function (point) { + var shapeArgs = point.shapeArgs; + point.shapeType = 'arc3d'; + shapeArgs.x += depth / 2; + shapeArgs.z = z; + shapeArgs.start = 0; + shapeArgs.end = 2 * PI; + shapeArgs.r = depth * 0.95; + shapeArgs.innerR = 0; + shapeArgs.depth = shapeArgs.height * (1 / sin((90 - alpha) * deg2rad)) - z; + shapeArgs.alpha = 90 - alpha; + shapeArgs.beta = 0; + shapeArgs.origin = origin; + }); +}); +/*** + EXTENSION FOR 3D PIES +***/ + +Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'translate', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + + // Do not do this if the chart is not 3D + if (!this.chart.is3d()) { + return; + } + + var series = this, + chart = series.chart, + options = chart.options, + seriesOptions = series.options, + depth = seriesOptions.depth || 0, + options3d = options.chart.options3d, + origin = { + x: chart.plotWidth / 2, + y: chart.plotHeight / 2, + z: options3d.depth + }, + alpha = options3d.alpha, + beta = options3d.beta; + + var z = seriesOptions.stacking ? (seriesOptions.stack || 0) * depth : series._i * depth; + z += depth / 2; + + if (seriesOptions.grouping !== false) { z = 0; } + + Highcharts.each(series.data, function (point) { + point.shapeType = 'arc3d'; + var shapeArgs = point.shapeArgs; + + if (point.y) { // will be false if null or 0 #3006 + shapeArgs.z = z; + shapeArgs.depth = depth * 0.75; + shapeArgs.origin = origin; + shapeArgs.alpha = alpha; + shapeArgs.beta = beta; + + var angle = (shapeArgs.end + shapeArgs.start) / 2; + + point.slicedTranslation = { + translateX : round(cos(angle) * series.options.slicedOffset * cos(alpha * deg2rad)), + translateY : round(sin(angle) * series.options.slicedOffset * cos(alpha * deg2rad)) + }; + } else { + shapeArgs = null; + } + }); +}); + +Highcharts.wrap(Highcharts.seriesTypes.pie.prototype.pointClass.prototype, 'haloPath', function (proceed) { + var args = arguments; + return this.series.chart.is3d() ? [] : proceed.call(this, args[1]); +}); + +Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'drawPoints', function (proceed) { + // Do not do this if the chart is not 3D + if (this.chart.is3d()) { + var options = this.options, + states = this.options.states; + + // Set the border color to the fill color to provide a smooth edge + this.borderWidth = options.borderWidth = options.edgeWidth || 1; + this.borderColor = options.edgeColor = Highcharts.pick(options.edgeColor, options.borderColor, undefined); + + states.hover.borderColor = Highcharts.pick(states.hover.edgeColor, this.borderColor); + states.hover.borderWidth = Highcharts.pick(states.hover.edgeWidth, this.borderWidth); + states.select.borderColor = Highcharts.pick(states.select.edgeColor, this.borderColor); + states.select.borderWidth = Highcharts.pick(states.select.edgeWidth, this.borderWidth); + + Highcharts.each(this.data, function (point) { + var pointAttr = point.pointAttr; + pointAttr[''].stroke = point.series.borderColor || point.color; + pointAttr['']['stroke-width'] = point.series.borderWidth; + pointAttr.hover.stroke = states.hover.borderColor; + pointAttr.hover['stroke-width'] = states.hover.borderWidth; + pointAttr.select.stroke = states.select.borderColor; + pointAttr.select['stroke-width'] = states.select.borderWidth; + }); + } + + proceed.apply(this, [].slice.call(arguments, 1)); + + if (this.chart.is3d()) { + var seriesGroup = this.group; + Highcharts.each(this.points, function (point) { + point.graphic.out.add(seriesGroup); + point.graphic.inn.add(seriesGroup); + point.graphic.side1.add(seriesGroup); + point.graphic.side2.add(seriesGroup); + }); + } +}); + +Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'drawDataLabels', function (proceed) { + if (this.chart.is3d()) { + var series = this; + Highcharts.each(series.data, function (point) { + var shapeArgs = point.shapeArgs, + r = shapeArgs.r, + d = shapeArgs.depth, + a1 = shapeArgs.alpha * deg2rad, + a2 = (shapeArgs.start + shapeArgs.end) / 2, + labelPos = point.labelPos; + + labelPos[1] += (-r * (1 - cos(a1)) * sin(a2)) + (sin(a2) > 0 ? sin(a1) * d : 0); + labelPos[3] += (-r * (1 - cos(a1)) * sin(a2)) + (sin(a2) > 0 ? sin(a1) * d : 0); + labelPos[5] += (-r * (1 - cos(a1)) * sin(a2)) + (sin(a2) > 0 ? sin(a1) * d : 0); + }); + } + + proceed.apply(this, [].slice.call(arguments, 1)); +}); + +Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'addPoint', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + if (this.chart.is3d()) { + // destroy (and rebuild) everything!!! + this.update(); + } +}); + +Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'animate', function (proceed) { + if (!this.chart.is3d()) { + proceed.apply(this, [].slice.call(arguments, 1)); + } else { + var args = arguments, + init = args[1], + animation = this.options.animation, + attribs, + center = this.center, + group = this.group, + markerGroup = this.markerGroup; + + if (Highcharts.svg) { // VML is too slow anyway + + if (animation === true) { + animation = {}; + } + // Initialize the animation + if (init) { + + // Scale down the group and place it in the center + group.oldtranslateX = group.translateX; + group.oldtranslateY = group.translateY; + attribs = { + translateX: center[0], + translateY: center[1], + scaleX: 0.001, // #1499 + scaleY: 0.001 + }; + + group.attr(attribs); + if (markerGroup) { + markerGroup.attrSetters = group.attrSetters; + markerGroup.attr(attribs); + } + + // Run the animation + } else { + attribs = { + translateX: group.oldtranslateX, + translateY: group.oldtranslateY, + scaleX: 1, + scaleY: 1 + }; + group.animate(attribs, animation); + + if (markerGroup) { + markerGroup.animate(attribs, animation); + } + + // Delete this function to allow it only once + this.animate = null; + } + + } + } +});/*** + EXTENSION FOR 3D SCATTER CHART +***/ +Highcharts.wrap(Highcharts.seriesTypes.scatter.prototype, 'translate', function (proceed) { +//function translate3d(proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + + if (!this.chart.is3d()) { + return; + } + + var series = this, + chart = series.chart, + options3d = series.chart.options.chart.options3d, + alpha = options3d.alpha, + beta = options3d.beta, + origin = { + x: chart.inverted ? chart.plotHeight / 2 : chart.plotWidth / 2, + y: chart.inverted ? chart.plotWidth / 2 : chart.plotHeight / 2, + z: options3d.depth, + vd: options3d.viewDistance + }, + depth = options3d.depth, + zAxis = chart.options.zAxis || { min : 0, max: depth }; + + var rangeModifier = depth / (zAxis.max - zAxis.min); + + Highcharts.each(series.data, function (point) { + var pCo = { + x: point.plotX, + y: point.plotY, + z: (point.z - zAxis.min) * rangeModifier + }; + + pCo = perspective([pCo], alpha, beta, origin)[0]; + + point.plotXold = point.plotX; + point.plotYold = point.plotY; + + point.plotX = pCo.x; + point.plotY = pCo.y; + point.plotZ = pCo.z; + }); +}); + +Highcharts.wrap(Highcharts.seriesTypes.scatter.prototype, 'init', function (proceed) { + var result = proceed.apply(this, [].slice.call(arguments, 1)); + + if (this.chart.is3d()) { + // Add a third coordinate + this.pointArrayMap = ['x', 'y', 'z']; + + // Set a new default tooltip formatter + var default3dScatterTooltip = 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>'; + if (this.userOptions.tooltip) { + this.tooltipOptions.pointFormat = this.userOptions.tooltip.pointFormat || default3dScatterTooltip; + } else { + this.tooltipOptions.pointFormat = default3dScatterTooltip; + } + } + return result; +});/** + * Extension to the VML Renderer + */ +if (Highcharts.VMLRenderer) { + +Highcharts.setOptions({animate: false}); + +Highcharts.VMLRenderer.prototype.cuboid = Highcharts.SVGRenderer.prototype.cuboid; +Highcharts.VMLRenderer.prototype.cuboidPath = Highcharts.SVGRenderer.prototype.cuboidPath; + +Highcharts.VMLRenderer.prototype.toLinePath = Highcharts.SVGRenderer.prototype.toLinePath; + +Highcharts.VMLRenderer.prototype.createElement3D = Highcharts.SVGRenderer.prototype.createElement3D; + +Highcharts.VMLRenderer.prototype.arc3d = function (shapeArgs) { + var result = Highcharts.SVGRenderer.prototype.arc3d.call(this, shapeArgs); + result.css({zIndex: result.zIndex}); + return result; +}; + +Highcharts.VMLRenderer.prototype.arc3dPath = Highcharts.SVGRenderer.prototype.arc3dPath; + +// Draw the series in the reverse order +Highcharts.Chart.prototype.renderSeries = function () { + var serie, + i = this.series.length; + while (i--) { + serie = this.series[i]; + serie.translate(); + if (serie.setTooltipPoints) { + serie.setTooltipPoints(); + } + serie.render(); + } +}; + +Highcharts.wrap(Highcharts.Axis.prototype, 'render', function (proceed) { + proceed.apply(this, [].slice.call(arguments, 1)); + // VML doesn't support a negative z-index + if (this.sideFrame) { + this.sideFrame.css({zIndex: 0}); + this.sideFrame.front.attr({fill: this.sideFrame.color}); + } + if (this.bottomFrame) { + this.bottomFrame.css({zIndex: 1}); + this.bottomFrame.front.attr({fill: this.bottomFrame.color}); + } + if (this.backFrame) { + this.backFrame.css({zIndex: 0}); + this.backFrame.front.attr({fill: this.backFrame.color}); + } +}); + +} + +}(Highcharts)); diff --git a/html/includes/js/highcharts-all.js b/html/includes/js/highcharts-all.js new file mode 100644 index 0000000..beeca1f --- /dev/null +++ b/html/includes/js/highcharts-all.js @@ -0,0 +1,471 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + + Standalone Highcharts Framework + + License: MIT License +*/ +var HighchartsAdapter=function(){function p(c){function b(b,a,d){b.removeEventListener(a,d,!1)}function d(b,a,d){d=b.HCProxiedMethods[d.toString()];b.detachEvent("on"+a,d)}function a(a,c){var f=a.HCEvents,i,g,k,j;if(a.removeEventListener)i=b;else if(a.attachEvent)i=d;else return;c?(g={},g[c]=!0):g=f;for(j in g)if(f[j])for(k=f[j].length;k--;)i(a,j,f[j][k])}c.HCExtended||Highcharts.extend(c,{HCExtended:!0,HCEvents:{},bind:function(b,a){var d=this,c=this.HCEvents,g;if(d.addEventListener)d.addEventListener(b, +a,!1);else if(d.attachEvent){g=function(b){b.target=b.srcElement||window;a.call(d,b)};if(!d.HCProxiedMethods)d.HCProxiedMethods={};d.HCProxiedMethods[a.toString()]=g;d.attachEvent("on"+b,g)}c[b]===s&&(c[b]=[]);c[b].push(a)},unbind:function(c,h){var f,i;c?(f=this.HCEvents[c]||[],h?(i=HighchartsAdapter.inArray(h,f),i>-1&&(f.splice(i,1),this.HCEvents[c]=f),this.removeEventListener?b(this,c,h):this.attachEvent&&d(this,c,h)):(a(this,c),this.HCEvents[c]=[])):(a(this),this.HCEvents={})},trigger:function(b, +a){var d=this.HCEvents[b]||[],c=d.length,g,k,j;k=function(){a.defaultPrevented=!0};for(g=0;g<c;g++){j=d[g];if(a.stopped)break;a.preventDefault=k;a.target=this;if(!a.type)a.type=b;j.call(this,a)===!1&&a.preventDefault()}}});return c}var s,l=document,q=[],m=[],r,n={},o;Math.easeInOutSine=function(c,b,d,a){return-d/2*(Math.cos(Math.PI*c/a)-1)+b};return{init:function(c){if(!l.defaultView)this._getStyle=function(b,d){var a;return b.style[d]?b.style[d]:(d==="opacity"&&(d="filter"),a=b.currentStyle[d.replace(/\-(\w)/g, +function(b,a){return a.toUpperCase()})],d==="filter"&&(a=a.replace(/alpha\(opacity=([0-9]+)\)/,function(b,a){return a/100})),a===""?1:a)},this.adapterRun=function(b,d){var a={width:"clientWidth",height:"clientHeight"}[d];if(a)return b.style.zoom=1,b[a]-2*parseInt(HighchartsAdapter._getStyle(b,"padding"),10)};if(!Array.prototype.forEach)this.each=function(b,d){for(var a=0,c=b.length;a<c;a++)if(d.call(b[a],b[a],a,b)===!1)return a};if(!Array.prototype.indexOf)this.inArray=function(b,d){var a,c=0;if(d)for(a= +d.length;c<a;c++)if(d[c]===b)return c;return-1};if(!Array.prototype.filter)this.grep=function(b,d){for(var a=[],c=0,h=b.length;c<h;c++)d(b[c],c)&&a.push(b[c]);return a};o=function(b,c,a){this.options=c;this.elem=b;this.prop=a};o.prototype={update:function(){var b;b=this.paths;var d=this.elem,a=d.element;if(n[this.prop])n[this.prop](this);else b&&a?d.attr("d",c.step(b[0],b[1],this.now,this.toD)):d.attr?a&&d.attr(this.prop,this.now):(b={},b[this.prop]=this.now+this.unit,Highcharts.css(d,b));this.options.step&& +this.options.step.call(this.elem,this.now,this)},custom:function(b,c,a){var e=this,h=function(a){return e.step(a)},f;this.startTime=+new Date;this.start=b;this.end=c;this.unit=a;this.now=this.start;this.pos=this.state=0;h.elem=this.elem;h()&&m.push(h)===1&&(r=setInterval(function(){for(f=0;f<m.length;f++)m[f]()||m.splice(f--,1);m.length||clearInterval(r)},13))},step:function(b){var c=+new Date,a;a=this.options;var e=this.elem,h;if(e.stopAnimation||e.attr&&!e.element)a=!1;else if(b||c>=a.duration+ +this.startTime){this.now=this.end;this.pos=this.state=1;this.update();b=this.options.curAnim[this.prop]=!0;for(h in a.curAnim)a.curAnim[h]!==!0&&(b=!1);b&&a.complete&&a.complete.call(e);a=!1}else e=c-this.startTime,this.state=e/a.duration,this.pos=a.easing(e,0,1,a.duration),this.now=this.start+(this.end-this.start)*this.pos,this.update(),a=!0;return a}};this.animate=function(b,d,a){var e,h="",f,i,g;b.stopAnimation=!1;if(typeof a!=="object"||a===null)e=arguments,a={duration:e[2],easing:e[3],complete:e[4]}; +if(typeof a.duration!=="number")a.duration=400;a.easing=Math[a.easing]||Math.easeInOutSine;a.curAnim=Highcharts.extend({},d);for(g in d)i=new o(b,a,g),f=null,g==="d"?(i.paths=c.init(b,b.d,d.d),i.toD=d.d,e=0,f=1):b.attr?e=b.attr(g):(e=parseFloat(HighchartsAdapter._getStyle(b,g))||0,g!=="opacity"&&(h="px")),f||(f=d[g]),i.custom(e,f,h)}},_getStyle:function(c,b){return window.getComputedStyle(c,void 0).getPropertyValue(b)},addAnimSetter:function(c,b){n[c]=b},getScript:function(c,b){var d=l.getElementsByTagName("head")[0], +a=l.createElement("script");a.type="text/javascript";a.src=c;a.onload=b;d.appendChild(a)},inArray:function(c,b){return b.indexOf?b.indexOf(c):q.indexOf.call(b,c)},adapterRun:function(c,b){return parseInt(HighchartsAdapter._getStyle(c,b),10)},grep:function(c,b){return q.filter.call(c,b)},map:function(c,b){for(var d=[],a=0,e=c.length;a<e;a++)d[a]=b.call(c[a],c[a],a,c);return d},offset:function(c){var b=document.documentElement,c=c.getBoundingClientRect();return{top:c.top+(window.pageYOffset||b.scrollTop)- +(b.clientTop||0),left:c.left+(window.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}},addEvent:function(c,b,d){p(c).bind(b,d)},removeEvent:function(c,b,d){p(c).unbind(b,d)},fireEvent:function(c,b,d,a){var e;l.createEvent&&(c.dispatchEvent||c.fireEvent)?(e=l.createEvent("Events"),e.initEvent(b,!0,!0),e.target=c,Highcharts.extend(e,d),c.dispatchEvent?c.dispatchEvent(e):c.fireEvent(b,e)):c.HCExtended===!0&&(d=d||{},c.trigger(b,d));d&&d.defaultPrevented&&(a=null);a&&a(d)},washMouseEvent:function(c){return c}, +stop:function(c){c.stopAnimation=!0},each:function(c,b){return Array.prototype.forEach.call(c,b)}}}(); +/* + Highcharts JS v4.0.4 (2014-09-02) + + (c) 2009-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(){function r(a,b){var c;a||(a={});for(c in b)a[c]=b[c];return a}function w(){var a,b=arguments,c,d={},e=function(a,b){var c,d;typeof a!=="object"&&(a={});for(d in b)b.hasOwnProperty(d)&&(c=b[d],a[d]=c&&typeof c==="object"&&Object.prototype.toString.call(c)!=="[object Array]"&&d!=="renderTo"&&typeof c.nodeType!=="number"?e(a[d]||{},c):b[d]);return a};b[0]===!0&&(d=b[1],b=Array.prototype.slice.call(b,2));c=b.length;for(a=0;a<c;a++)d=e(d,b[a]);return d}function y(a,b){return parseInt(a,b|| +10)}function Ga(a){return typeof a==="string"}function da(a){return a&&typeof a==="object"}function Ha(a){return Object.prototype.toString.call(a)==="[object Array]"}function ja(a){return typeof a==="number"}function za(a){return V.log(a)/V.LN10}function ka(a){return V.pow(10,a)}function la(a,b){for(var c=a.length;c--;)if(a[c]===b){a.splice(c,1);break}}function s(a){return a!==u&&a!==null}function F(a,b,c){var d,e;if(Ga(b))s(c)?a.setAttribute(b,c):a&&a.getAttribute&&(e=a.getAttribute(b));else if(s(b)&& +da(b))for(d in b)a.setAttribute(d,b[d]);return e}function ra(a){return Ha(a)?a:[a]}function p(){var a=arguments,b,c,d=a.length;for(b=0;b<d;b++)if(c=a[b],c!==u&&c!==null)return c}function B(a,b){if(Aa&&!ba&&b&&b.opacity!==u)b.filter="alpha(opacity="+b.opacity*100+")";r(a.style,b)}function $(a,b,c,d,e){a=x.createElement(a);b&&r(a,b);e&&B(a,{padding:0,border:P,margin:0});c&&B(a,c);d&&d.appendChild(a);return a}function ma(a,b){var c=function(){return u};c.prototype=new a;r(c.prototype,b);return c}function Ba(a, +b,c,d){var e=K.numberFormat,f=E.lang,g=+a||0,h=b===-1?(g.toString().split(".")[1]||"").length:isNaN(b=Q(b))?2:b,i=c===void 0?f.decimalPoint:c,f=d===void 0?f.thousandsSep:d,j=g<0?"-":"",k=String(y(g=Q(g).toFixed(h))),l=k.length>3?k.length%3:0;return e!==Ba?e(a,b,c,d):j+(l?k.substr(0,l)+f:"")+k.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+f)+(h?i+Q(g-k).toFixed(h).slice(2):"")}function Ia(a,b){return Array((b||2)+1-String(a).length).join(0)+a}function Na(a,b,c){var d=a[b];a[b]=function(){var a=Array.prototype.slice.call(arguments); +a.unshift(d);return c.apply(this,a)}}function Ja(a,b){for(var c="{",d=!1,e,f,g,h,i,j=[];(c=a.indexOf(c))!==-1;){e=a.slice(0,c);if(d){f=e.split(":");g=f.shift().split(".");i=g.length;e=b;for(h=0;h<i;h++)e=e[g[h]];if(f.length)f=f.join(":"),g=/\.([0-9])/,h=E.lang,i=void 0,/f$/.test(f)?(i=(i=f.match(g))?i[1]:-1,e!==null&&(e=Ba(e,i,h.decimalPoint,f.indexOf(",")>-1?h.thousandsSep:""))):e=cb(f,e)}j.push(e);a=a.slice(c+1);c=(d=!d)?"}":"{"}j.push(a);return j.join("")}function mb(a){return V.pow(10,U(V.log(a)/ +V.LN10))}function nb(a,b,c,d){var e,c=p(c,1);e=a/c;b||(b=[1,2,2.5,5,10],d===!1&&(c===1?b=[1,2,5,10]:c<=0.1&&(b=[1/c])));for(d=0;d<b.length;d++)if(a=b[d],e<=(b[d]+(b[d+1]||b[d]))/2)break;a*=c;return a}function ob(a,b){var c=a.length,d,e;for(e=0;e<c;e++)a[e].ss_i=e;a.sort(function(a,c){d=b(a,c);return d===0?a.ss_i-c.ss_i:d});for(e=0;e<c;e++)delete a[e].ss_i}function Oa(a){for(var b=a.length,c=a[0];b--;)a[b]<c&&(c=a[b]);return c}function Ca(a){for(var b=a.length,c=a[0];b--;)a[b]>c&&(c=a[b]);return c} +function Pa(a,b){for(var c in a)a[c]&&a[c]!==b&&a[c].destroy&&a[c].destroy(),delete a[c]}function Qa(a){db||(db=$(Ka));a&&db.appendChild(a);db.innerHTML=""}function ea(a){return parseFloat(a.toPrecision(14))}function Ra(a,b){va=p(a,b.animation)}function Bb(){var a=E.global.useUTC,b=a?"getUTC":"get",c=a?"setUTC":"set";Da=E.global.Date||window.Date;Sa=(a&&E.global.timezoneOffset||0)*6E4;eb=a?Da.UTC:function(a,b,c,g,h,i){return(new Da(a,b,p(c,1),p(g,0),p(h,0),p(i,0))).getTime()};pb=b+"Minutes";qb=b+ +"Hours";rb=b+"Day";Xa=b+"Date";fb=b+"Month";gb=b+"FullYear";Cb=c+"Minutes";Db=c+"Hours";sb=c+"Date";Eb=c+"Month";Fb=c+"FullYear"}function S(){}function Ta(a,b,c,d){this.axis=a;this.pos=b;this.type=c||"";this.isNew=!0;!c&&!d&&this.addLabel()}function na(){this.init.apply(this,arguments)}function Ya(){this.init.apply(this,arguments)}function Gb(a,b,c,d,e){var f=a.chart.inverted;this.axis=a;this.isNegative=c;this.options=b;this.x=d;this.total=null;this.points={};this.stack=e;this.alignOptions={align:b.align|| +(f?c?"left":"right":"center"),verticalAlign:b.verticalAlign||(f?"middle":c?"bottom":"top"),y:p(b.y,f?4:c?14:-6),x:p(b.x,f?c?-6:6:0)};this.textAlign=b.textAlign||(f?c?"right":"left":"center")}var u,x=document,G=window,V=Math,v=V.round,U=V.floor,La=V.ceil,t=V.max,L=V.min,Q=V.abs,aa=V.cos,fa=V.sin,oa=V.PI,Ea=oa*2/360,wa=navigator.userAgent,Hb=G.opera,Aa=/msie/i.test(wa)&&!Hb,hb=x.documentMode===8,tb=/AppleWebKit/.test(wa),Ua=/Firefox/.test(wa),Ib=/(Mobile|Android|Windows Phone)/.test(wa),xa="http://www.w3.org/2000/svg", +ba=!!x.createElementNS&&!!x.createElementNS(xa,"svg").createSVGRect,Ob=Ua&&parseInt(wa.split("Firefox/")[1],10)<4,ga=!ba&&!Aa&&!!x.createElement("canvas").getContext,Za,$a,Jb={},ub=0,db,E,cb,va,vb,A,ha,sa=function(){return u},W=[],ab=0,Ka="div",P="none",Pb=/^[0-9]+$/,Qb="stroke-width",Da,eb,Sa,pb,qb,rb,Xa,fb,gb,Cb,Db,sb,Eb,Fb,H={},K;G.Highcharts?ha(16,!0):K=G.Highcharts={};cb=function(a,b,c){if(!s(b)||isNaN(b))return"Invalid date";var a=p(a,"%Y-%m-%d %H:%M:%S"),d=new Da(b-Sa),e,f=d[qb](),g=d[rb](), +h=d[Xa](),i=d[fb](),j=d[gb](),k=E.lang,l=k.weekdays,d=r({a:l[g].substr(0,3),A:l[g],d:Ia(h),e:h,b:k.shortMonths[i],B:k.months[i],m:Ia(i+1),y:j.toString().substr(2,2),Y:j,H:Ia(f),I:Ia(f%12||12),l:f%12||12,M:Ia(d[pb]()),p:f<12?"AM":"PM",P:f<12?"am":"pm",S:Ia(d.getSeconds()),L:Ia(v(b%1E3),3)},K.dateFormats);for(e in d)for(;a.indexOf("%"+e)!==-1;)a=a.replace("%"+e,typeof d[e]==="function"?d[e](b):d[e]);return c?a.substr(0,1).toUpperCase()+a.substr(1):a};ha=function(a,b){var c="Highcharts error #"+a+": www.highcharts.com/errors/"+ +a;if(b)throw c;G.console&&console.log(c)};A={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5,month:26784E5,year:31556952E3};vb={init:function(a,b,c){var b=b||"",d=a.shift,e=b.indexOf("C")>-1,f=e?7:3,g,b=b.split(" "),c=[].concat(c),h,i,j=function(a){for(g=a.length;g--;)a[g]==="M"&&a.splice(g+1,0,a[g+1],a[g+2],a[g+1],a[g+2])};e&&(j(b),j(c));a.isArea&&(h=b.splice(b.length-6,6),i=c.splice(c.length-6,6));if(d<=c.length/f&&b.length===c.length)for(;d--;)c=[].concat(c).splice(0,f).concat(c); +a.shift=0;if(b.length)for(a=c.length;b.length<a;)d=[].concat(b).splice(b.length-f,f),e&&(d[f-6]=d[f-2],d[f-5]=d[f-1]),b=b.concat(d);h&&(b=b.concat(h),c=c.concat(i));return[b,c]},step:function(a,b,c,d){var e=[],f=a.length;if(c===1)e=d;else if(f===b.length&&c<1)for(;f--;)d=parseFloat(a[f]),e[f]=isNaN(d)?a[f]:c*parseFloat(b[f]-d)+d;else e=b;return e}};(function(a){G.HighchartsAdapter=G.HighchartsAdapter||a&&{init:function(b){var c=a.fx;a.extend(a.easing,{easeOutQuad:function(a,b,c,g,h){return-g*(b/= +h)*(b-2)+c}});a.each(["cur","_default","width","height","opacity"],function(b,e){var f=c.step,g;e==="cur"?f=c.prototype:e==="_default"&&a.Tween&&(f=a.Tween.propHooks[e],e="set");(g=f[e])&&(f[e]=function(a){var c,a=b?a:this;if(a.prop!=="align")return c=a.elem,c.attr?c.attr(a.prop,e==="cur"?u:a.now):g.apply(this,arguments)})});Na(a.cssHooks.opacity,"get",function(a,b,c){return b.attr?b.opacity||0:a.call(this,b,c)});this.addAnimSetter("d",function(a){var c=a.elem,f;if(!a.started)f=b.init(c,c.d,c.toD), +a.start=f[0],a.end=f[1],a.started=!0;c.attr("d",b.step(a.start,a.end,a.pos,c.toD))});this.each=Array.prototype.forEach?function(a,b){return Array.prototype.forEach.call(a,b)}:function(a,b){var c,g=a.length;for(c=0;c<g;c++)if(b.call(a[c],a[c],c,a)===!1)return c};a.fn.highcharts=function(){var a="Chart",b=arguments,c,g;if(this[0]){Ga(b[0])&&(a=b[0],b=Array.prototype.slice.call(b,1));c=b[0];if(c!==u)c.chart=c.chart||{},c.chart.renderTo=this[0],new K[a](c,b[1]),g=this;c===u&&(g=W[F(this[0],"data-highcharts-chart")])}return g}}, +addAnimSetter:function(b,c){a.Tween?a.Tween.propHooks[b]={set:c}:a.fx.step[b]=c},getScript:a.getScript,inArray:a.inArray,adapterRun:function(b,c){return a(b)[c]()},grep:a.grep,map:function(a,c){for(var d=[],e=0,f=a.length;e<f;e++)d[e]=c.call(a[e],a[e],e,a);return d},offset:function(b){return a(b).offset()},addEvent:function(b,c,d){a(b).bind(c,d)},removeEvent:function(b,c,d){var e=x.removeEventListener?"removeEventListener":"detachEvent";x[e]&&b&&!b[e]&&(b[e]=function(){});a(b).unbind(c,d)},fireEvent:function(b, +c,d,e){var f=a.Event(c),g="detached"+c,h;!Aa&&d&&(delete d.layerX,delete d.layerY,delete d.returnValue);r(f,d);b[c]&&(b[g]=b[c],b[c]=null);a.each(["preventDefault","stopPropagation"],function(a,b){var c=f[b];f[b]=function(){try{c.call(f)}catch(a){b==="preventDefault"&&(h=!0)}}});a(b).trigger(f);b[g]&&(b[c]=b[g],b[g]=null);e&&!f.isDefaultPrevented()&&!h&&e(f)},washMouseEvent:function(a){var c=a.originalEvent||a;if(c.pageX===u)c.pageX=a.pageX,c.pageY=a.pageY;return c},animate:function(b,c,d){var e= +a(b);if(!b.style)b.style={};if(c.d)b.toD=c.d,c.d=1;e.stop();c.opacity!==u&&b.attr&&(c.opacity+="px");b.hasAnim=1;e.animate(c,d)},stop:function(b){b.hasAnim&&a(b).stop()}}})(G.jQuery);var T=G.HighchartsAdapter,M=T||{};T&&T.init.call(T,vb);var ib=M.adapterRun,Rb=M.getScript,Ma=M.inArray,q=M.each,wb=M.grep,Sb=M.offset,Va=M.map,N=M.addEvent,X=M.removeEvent,I=M.fireEvent,Tb=M.washMouseEvent,jb=M.animate,bb=M.stop,M={enabled:!0,x:0,y:15,style:{color:"#606060",cursor:"default",fontSize:"11px"}};E={colors:"#7cb5ec,#434348,#90ed7d,#f7a35c,#8085e9,#f15c80,#e4d354,#8085e8,#8d4653,#91e8e1".split(","), +symbols:["circle","diamond","square","triangle","triangle-down"],lang:{loading:"Loading...",months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),shortMonths:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),decimalPoint:".",numericSymbols:"k,M,G,T,P,E".split(","),resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:","},global:{useUTC:!0, +canvasToolsURL:"http://code.highcharts.com/4.0.4/modules/canvas-tools.js",VMLRadialGradientURL:"http://code.highcharts.com/4.0.4/gfx/vml-radial-gradient.png"},chart:{borderColor:"#4572A7",borderRadius:0,defaultSeriesType:"line",ignoreHiddenSeries:!0,spacing:[10,10,15,10],backgroundColor:"#FFFFFF",plotBorderColor:"#C0C0C0",resetZoomButton:{theme:{zIndex:20},position:{align:"right",x:-10,y:10}}},title:{text:"Chart title",align:"center",margin:15,style:{color:"#333333",fontSize:"18px"}},subtitle:{text:"", +align:"center",style:{color:"#555555"}},plotOptions:{line:{allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},lineWidth:2,marker:{lineWidth:0,radius:4,lineColor:"#FFFFFF",states:{hover:{enabled:!0,lineWidthPlus:1,radiusPlus:2},select:{fillColor:"#FFFFFF",lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:w(M,{align:"center",enabled:!1,formatter:function(){return this.y===null?"":Ba(this.y,-1)},verticalAlign:"bottom",y:0}),cropThreshold:300,pointRange:0,states:{hover:{lineWidthPlus:1, +marker:{},halo:{size:10,opacity:0.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3}},labels:{style:{position:"absolute",color:"#3E576F"}},legend:{enabled:!0,align:"center",layout:"horizontal",labelFormatter:function(){return this.name},borderColor:"#909090",borderRadius:0,navigation:{activeColor:"#274b6d",inactiveColor:"#CCC"},shadow:!1,itemStyle:{color:"#333333",fontSize:"12px",fontWeight:"bold"},itemHoverStyle:{color:"#000"},itemHiddenStyle:{color:"#CCC"},itemCheckboxStyle:{position:"absolute", +width:"13px",height:"13px"},symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"white",opacity:0.5,textAlign:"center"}},tooltip:{enabled:!0,animation:ba,backgroundColor:"rgba(249, 249, 249, .85)",borderWidth:1,borderRadius:3,dateTimeLabelFormats:{millisecond:"%A, %b %e, %H:%M:%S.%L",second:"%A, %b %e, %H:%M:%S",minute:"%A, %b %e, %H:%M",hour:"%A, %b %e, %H:%M", +day:"%A, %b %e, %Y",week:"Week from %A, %b %e, %Y",month:"%B %Y",year:"%Y"},headerFormat:'<span style="font-size: 10px">{point.key}</span><br/>',pointFormat:'<span style="color:{series.color}">●</span> {series.name}: <b>{point.y}</b><br/>',shadow:!0,snap:Ib?25:10,style:{color:"#333333",cursor:"default",fontSize:"12px",padding:"8px",whiteSpace:"nowrap"}},credits:{enabled:!0,text:"Highcharts.com",href:"http://www.highcharts.com",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer", +color:"#909090",fontSize:"9px"}}};var ca=E.plotOptions,T=ca.line;Bb();var Ub=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,Vb=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,Wb=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,ya=function(a){var b=[],c,d;(function(a){a&&a.stops?d=Va(a.stops,function(a){return ya(a[1])}):(c=Ub.exec(a))?b=[y(c[1]),y(c[2]),y(c[3]),parseFloat(c[4],10)]:(c=Vb.exec(a))?b=[y(c[1],16),y(c[2],16),y(c[3], +16),1]:(c=Wb.exec(a))&&(b=[y(c[1]),y(c[2]),y(c[3]),1])})(a);return{get:function(c){var f;d?(f=w(a),f.stops=[].concat(f.stops),q(d,function(a,b){f.stops[b]=[f.stops[b][0],a.get(c)]})):f=b&&!isNaN(b[0])?c==="rgb"?"rgb("+b[0]+","+b[1]+","+b[2]+")":c==="a"?b[3]:"rgba("+b.join(",")+")":a;return f},brighten:function(a){if(d)q(d,function(b){b.brighten(a)});else if(ja(a)&&a!==0){var c;for(c=0;c<3;c++)b[c]+=y(a*255),b[c]<0&&(b[c]=0),b[c]>255&&(b[c]=255)}return this},rgba:b,setOpacity:function(a){b[3]=a;return this}}}; +S.prototype={opacity:1,textProps:"fontSize,fontWeight,fontFamily,color,lineHeight,width,textDecoration,textShadow,HcTextStroke".split(","),init:function(a,b){this.element=b==="span"?$(b):x.createElementNS(xa,b);this.renderer=a},animate:function(a,b,c){b=p(b,va,!0);bb(this);if(b){b=w(b,{});if(c)b.complete=c;jb(this,a,b)}else this.attr(a),c&&c();return this},colorGradient:function(a,b,c){var d=this.renderer,e,f,g,h,i,j,k,l,n,m,o=[];a.linearGradient?f="linearGradient":a.radialGradient&&(f="radialGradient"); +if(f){g=a[f];h=d.gradients;j=a.stops;n=c.radialReference;Ha(g)&&(a[f]=g={x1:g[0],y1:g[1],x2:g[2],y2:g[3],gradientUnits:"userSpaceOnUse"});f==="radialGradient"&&n&&!s(g.gradientUnits)&&(g=w(g,{cx:n[0]-n[2]/2+g.cx*n[2],cy:n[1]-n[2]/2+g.cy*n[2],r:g.r*n[2],gradientUnits:"userSpaceOnUse"}));for(m in g)m!=="id"&&o.push(m,g[m]);for(m in j)o.push(j[m]);o=o.join(",");h[o]?a=h[o].attr("id"):(g.id=a="highcharts-"+ub++,h[o]=i=d.createElement(f).attr(g).add(d.defs),i.stops=[],q(j,function(a){a[1].indexOf("rgba")=== +0?(e=ya(a[1]),k=e.get("rgb"),l=e.get("a")):(k=a[1],l=1);a=d.createElement("stop").attr({offset:a[0],"stop-color":k,"stop-opacity":l}).add(i);i.stops.push(a)}));c.setAttribute(b,"url("+d.url+"#"+a+")")}},attr:function(a,b){var c,d,e=this.element,f,g=this,h;typeof a==="string"&&b!==u&&(c=a,a={},a[c]=b);if(typeof a==="string")g=(this[a+"Getter"]||this._defaultGetter).call(this,a,e);else{for(c in a){d=a[c];h=!1;this.symbolName&&/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)/.test(c)&&(f||(this.symbolAttr(a), +f=!0),h=!0);if(this.rotation&&(c==="x"||c==="y"))this.doTransform=!0;h||(this[c+"Setter"]||this._defaultSetter).call(this,d,c,e);this.shadows&&/^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(c)&&this.updateShadows(c,d)}if(this.doTransform)this.updateTransform(),this.doTransform=!1}return g},updateShadows:function(a,b){for(var c=this.shadows,d=c.length;d--;)c[d].setAttribute(a,a==="height"?t(b-(c[d].cutHeight||0),0):a==="d"?this.d:b)},addClass:function(a){var b=this.element,c=F(b,"class")|| +"";c.indexOf(a)===-1&&F(b,"class",c+" "+a);return this},symbolAttr:function(a){var b=this;q("x,y,r,start,end,width,height,innerR,anchorX,anchorY".split(","),function(c){b[c]=p(a[c],b[c])});b.attr({d:b.renderer.symbols[b.symbolName](b.x,b.y,b.width,b.height,b)})},clip:function(a){return this.attr("clip-path",a?"url("+this.renderer.url+"#"+a.id+")":P)},crisp:function(a){var b,c={},d,e=a.strokeWidth||this.strokeWidth||0;d=v(e)%2/2;a.x=U(a.x||this.x||0)+d;a.y=U(a.y||this.y||0)+d;a.width=U((a.width||this.width|| +0)-2*d);a.height=U((a.height||this.height||0)-2*d);a.strokeWidth=e;for(b in a)this[b]!==a[b]&&(this[b]=c[b]=a[b]);return c},css:function(a){var b=this.styles,c={},d=this.element,e,f,g="";e=!b;if(a&&a.color)a.fill=a.color;if(b)for(f in a)a[f]!==b[f]&&(c[f]=a[f],e=!0);if(e){e=this.textWidth=a&&a.width&&d.nodeName.toLowerCase()==="text"&&y(a.width);b&&(a=r(b,c));this.styles=a;e&&(ga||!ba&&this.renderer.forExport)&&delete a.width;if(Aa&&!ba)B(this.element,a);else{b=function(a,b){return"-"+b.toLowerCase()}; +for(f in a)g+=f.replace(/([A-Z])/g,b)+":"+a[f]+";";F(d,"style",g)}e&&this.added&&this.renderer.buildText(this)}return this},on:function(a,b){var c=this,d=c.element;$a&&a==="click"?(d.ontouchstart=function(a){c.touchEventFired=Da.now();a.preventDefault();b.call(d,a)},d.onclick=function(a){(wa.indexOf("Android")===-1||Da.now()-(c.touchEventFired||0)>1100)&&b.call(d,a)}):d["on"+a]=b;return this},setRadialReference:function(a){this.element.radialReference=a;return this},translate:function(a,b){return this.attr({translateX:a, +translateY:b})},invert:function(){this.inverted=!0;this.updateTransform();return this},updateTransform:function(){var a=this.translateX||0,b=this.translateY||0,c=this.scaleX,d=this.scaleY,e=this.inverted,f=this.rotation,g=this.element;e&&(a+=this.attr("width"),b+=this.attr("height"));a=["translate("+a+","+b+")"];e?a.push("rotate(90) scale(-1,1)"):f&&a.push("rotate("+f+" "+(g.getAttribute("x")||0)+" "+(g.getAttribute("y")||0)+")");(s(c)||s(d))&&a.push("scale("+p(c,1)+" "+p(d,1)+")");a.length&&g.setAttribute("transform", +a.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,b,c){var d,e,f,g,h={};e=this.renderer;f=e.alignedObjects;if(a){if(this.alignOptions=a,this.alignByTranslate=b,!c||Ga(c))this.alignTo=d=c||"renderer",la(f,this),f.push(this),c=null}else a=this.alignOptions,b=this.alignByTranslate,d=this.alignTo;c=p(c,e[d],e);d=a.align;e=a.verticalAlign;f=(c.x||0)+(a.x||0);g=(c.y||0)+(a.y||0);if(d==="right"||d==="center")f+=(c.width-(a.width||0))/{right:1,center:2}[d]; +h[b?"translateX":"x"]=v(f);if(e==="bottom"||e==="middle")g+=(c.height-(a.height||0))/({bottom:1,middle:2}[e]||1);h[b?"translateY":"y"]=v(g);this[this.placed?"animate":"attr"](h);this.placed=!0;this.alignAttr=h;return this},getBBox:function(){var a=this.bBox,b=this.renderer,c,d,e=this.rotation;c=this.element;var f=this.styles,g=e*Ea;d=this.textStr;var h;if(d===""||Pb.test(d))h="num."+d.toString().length+(f?"|"+f.fontSize+"|"+f.fontFamily:"");h&&(a=b.cache[h]);if(!a){if(c.namespaceURI===xa||b.forExport){try{a= +c.getBBox?r({},c.getBBox()):{width:c.offsetWidth,height:c.offsetHeight}}catch(i){}if(!a||a.width<0)a={width:0,height:0}}else a=this.htmlGetBBox();if(b.isSVG){c=a.width;d=a.height;if(Aa&&f&&f.fontSize==="11px"&&d.toPrecision(3)==="16.9")a.height=d=14;if(e)a.width=Q(d*fa(g))+Q(c*aa(g)),a.height=Q(d*aa(g))+Q(c*fa(g))}this.bBox=a;h&&(b.cache[h]=a)}return a},show:function(a){a&&this.element.namespaceURI===xa?this.element.removeAttribute("visibility"):this.attr({visibility:a?"inherit":"visible"});return this}, +hide:function(){return this.attr({visibility:"hidden"})},fadeOut:function(a){var b=this;b.animate({opacity:0},{duration:a||150,complete:function(){b.attr({y:-9999})}})},add:function(a){var b=this.renderer,c=a||b,d=c.element||b.box,e=this.element,f=this.zIndex,g,h;if(a)this.parentGroup=a;this.parentInverted=a&&a.inverted;this.textStr!==void 0&&b.buildText(this);if(f)c.handleZ=!0,f=y(f);if(c.handleZ){a=d.childNodes;for(g=0;g<a.length;g++)if(b=a[g],c=F(b,"zIndex"),b!==e&&(y(c)>f||!s(f)&&s(c))){d.insertBefore(e, +b);h=!0;break}}h||d.appendChild(e);this.added=!0;if(this.onAdd)this.onAdd();return this},safeRemoveChild:function(a){var b=a.parentNode;b&&b.removeChild(a)},destroy:function(){var a=this,b=a.element||{},c=a.shadows,d=a.renderer.isSVG&&b.nodeName==="SPAN"&&a.parentGroup,e,f;b.onclick=b.onmouseout=b.onmouseover=b.onmousemove=b.point=null;bb(a);if(a.clipPath)a.clipPath=a.clipPath.destroy();if(a.stops){for(f=0;f<a.stops.length;f++)a.stops[f]=a.stops[f].destroy();a.stops=null}a.safeRemoveChild(b);for(c&& +q(c,function(b){a.safeRemoveChild(b)});d&&d.div&&d.div.childNodes.length===0;)b=d.parentGroup,a.safeRemoveChild(d.div),delete d.div,d=b;a.alignTo&&la(a.renderer.alignedObjects,a);for(e in a)delete a[e];return null},shadow:function(a,b,c){var d=[],e,f,g=this.element,h,i,j,k;if(a){i=p(a.width,3);j=(a.opacity||0.15)/i;k=this.parentInverted?"(-1,-1)":"("+p(a.offsetX,1)+", "+p(a.offsetY,1)+")";for(e=1;e<=i;e++){f=g.cloneNode(0);h=i*2+1-2*e;F(f,{isShadow:"true",stroke:a.color||"black","stroke-opacity":j* +e,"stroke-width":h,transform:"translate"+k,fill:P});if(c)F(f,"height",t(F(f,"height")-h,0)),f.cutHeight=h;b?b.element.appendChild(f):g.parentNode.insertBefore(f,g);d.push(f)}this.shadows=d}return this},xGetter:function(a){this.element.nodeName==="circle"&&(a={x:"cx",y:"cy"}[a]||a);return this._defaultGetter(a)},_defaultGetter:function(a){a=p(this[a],this.element?this.element.getAttribute(a):null,0);/^[\-0-9\.]+$/.test(a)&&(a=parseFloat(a));return a},dSetter:function(a,b,c){a&&a.join&&(a=a.join(" ")); +/(NaN| {2}|^$)/.test(a)&&(a="M 0 0");c.setAttribute(b,a);this[b]=a},dashstyleSetter:function(a){var b;if(a=a&&a.toLowerCase()){a=a.replace("shortdashdotdot","3,1,1,1,1,1,").replace("shortdashdot","3,1,1,1").replace("shortdot","1,1,").replace("shortdash","3,1,").replace("longdash","8,3,").replace(/dot/g,"1,3,").replace("dash","4,3,").replace(/,$/,"").split(",");for(b=a.length;b--;)a[b]=y(a[b])*this["stroke-width"];a=a.join(",").replace("NaN","none");this.element.setAttribute("stroke-dasharray",a)}}, +alignSetter:function(a){this.element.setAttribute("text-anchor",{left:"start",center:"middle",right:"end"}[a])},opacitySetter:function(a,b,c){this[b]=a;c.setAttribute(b,a)},titleSetter:function(a){var b=this.element.getElementsByTagName("title")[0];b||(b=x.createElementNS(xa,"title"),this.element.appendChild(b));b.textContent=p(a,"").replace(/<[^>]*>/g,"")},textSetter:function(a){if(a!==this.textStr)delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this)},fillSetter:function(a,b, +c){typeof a==="string"?c.setAttribute(b,a):a&&this.colorGradient(a,b,c)},zIndexSetter:function(a,b,c){c.setAttribute(b,a);this[b]=a},_defaultSetter:function(a,b,c){c.setAttribute(b,a)}};S.prototype.yGetter=S.prototype.xGetter;S.prototype.translateXSetter=S.prototype.translateYSetter=S.prototype.rotationSetter=S.prototype.verticalAlignSetter=S.prototype.scaleXSetter=S.prototype.scaleYSetter=function(a,b){this[b]=a;this.doTransform=!0};S.prototype["stroke-widthSetter"]=S.prototype.strokeSetter=function(a, +b,c){this[b]=a;if(this.stroke&&this["stroke-width"])this.strokeWidth=this["stroke-width"],S.prototype.fillSetter.call(this,this.stroke,"stroke",c),c.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0;else if(b==="stroke-width"&&a===0&&this.hasStroke)c.removeAttribute("stroke"),this.hasStroke=!1};var ta=function(){this.init.apply(this,arguments)};ta.prototype={Element:S,init:function(a,b,c,d,e){var f=location,g,d=this.createElement("svg").attr({version:"1.1"}).css(this.getStyle(d)); +g=d.element;a.appendChild(g);a.innerHTML.indexOf("xmlns")===-1&&F(g,"xmlns",xa);this.isSVG=!0;this.box=g;this.boxWrapper=d;this.alignedObjects=[];this.url=(Ua||tb)&&x.getElementsByTagName("base").length?f.href.replace(/#.*?$/,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(x.createTextNode("Created with Highcharts 4.0.4"));this.defs=this.createElement("defs").add();this.forExport=e;this.gradients={};this.cache={};this.setSize(b,c,!1);var h; +if(Ua&&a.getBoundingClientRect)this.subPixelFix=b=function(){B(a,{left:0,top:0});h=a.getBoundingClientRect();B(a,{left:La(h.left)-h.left+"px",top:La(h.top)-h.top+"px"})},b(),N(G,"resize",b)},getStyle:function(a){return this.style=r({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();Pa(this.gradients|| +{});this.gradients=null;if(a)this.defs=a.destroy();this.subPixelFix&&X(G,"resize",this.subPixelFix);return this.alignedObjects=null},createElement:function(a){var b=new this.Element;b.init(this,a);return b},draw:function(){},buildText:function(a){for(var b=a.element,c=this,d=c.forExport,e=p(a.textStr,"").toString(),f=e.indexOf("<")!==-1,g=b.childNodes,h,i,j=F(b,"x"),k=a.styles,l=a.textWidth,n=k&&k.lineHeight,m=k&&k.HcTextStroke,o=g.length,Y=function(a){return n?y(n):c.fontMetrics(/(px|em)$/.test(a&& +a.style.fontSize)?a.style.fontSize:k&&k.fontSize||c.style.fontSize||12,a).h};o--;)b.removeChild(g[o]);!f&&!m&&e.indexOf(" ")===-1?b.appendChild(x.createTextNode(e)):(h=/<.*style="([^"]+)".*>/,i=/<.*href="(http[^"]+)".*>/,l&&!a.added&&this.box.appendChild(b),e=f?e.replace(/<(b|strong)>/g,'<span style="font-weight:bold">').replace(/<(i|em)>/g,'<span style="font-style:italic">').replace(/<a/g,"<span").replace(/<\/(b|strong|i|em|a)>/g,"</span>").split(/<br.*?>/g):[e],e[e.length-1]===""&&e.pop(),q(e,function(e, +f){var g,n=0,e=e.replace(/<span/g,"|||<span").replace(/<\/span>/g,"</span>|||");g=e.split("|||");q(g,function(e){if(e!==""||g.length===1){var m={},o=x.createElementNS(xa,"tspan"),p;h.test(e)&&(p=e.match(h)[1].replace(/(;| |^)color([ :])/,"$1fill$2"),F(o,"style",p));i.test(e)&&!d&&(F(o,"onclick",'location.href="'+e.match(i)[1]+'"'),B(o,{cursor:"pointer"}));e=(e.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"<").replace(/>/g,">");if(e!==" "){o.appendChild(x.createTextNode(e));if(n)m.dx=0;else if(f&& +j!==null)m.x=j;F(o,m);b.appendChild(o);!n&&f&&(!ba&&d&&B(o,{display:"block"}),F(o,"dy",Y(o)));if(l)for(var e=e.replace(/([^\^])-/g,"$1- ").split(" "),m=g.length>1||e.length>1&&k.whiteSpace!=="nowrap",q,D,s=k.HcHeight,t=[],u=Y(o),Lb=1;m&&(e.length||t.length);)delete a.bBox,q=a.getBBox(),D=q.width,!ba&&c.forExport&&(D=c.measureSpanWidth(o.firstChild.data,a.styles)),q=D>l,!q||e.length===1?(e=t,t=[],e.length&&(Lb++,s&&Lb*u>s?(e=["..."],a.attr("title",a.textStr)):(o=x.createElementNS(xa,"tspan"),F(o,{dy:u, +x:j}),p&&F(o,"style",p),b.appendChild(o))),D>l&&(l=D)):(o.removeChild(o.firstChild),t.unshift(e.pop())),e.length&&o.appendChild(x.createTextNode(e.join(" ").replace(/- /g,"-")));n++}}})}))},button:function(a,b,c,d,e,f,g,h,i){var j=this.label(a,b,c,i,null,null,null,null,"button"),k=0,l,n,m,o,p,q,a={x1:0,y1:0,x2:0,y2:1},e=w({"stroke-width":1,stroke:"#CCCCCC",fill:{linearGradient:a,stops:[[0,"#FEFEFE"],[1,"#F6F6F6"]]},r:2,padding:5,style:{color:"black"}},e);m=e.style;delete e.style;f=w(e,{stroke:"#68A", +fill:{linearGradient:a,stops:[[0,"#FFF"],[1,"#ACF"]]}},f);o=f.style;delete f.style;g=w(e,{stroke:"#68A",fill:{linearGradient:a,stops:[[0,"#9BD"],[1,"#CDF"]]}},g);p=g.style;delete g.style;h=w(e,{style:{color:"#CCC"}},h);q=h.style;delete h.style;N(j.element,Aa?"mouseover":"mouseenter",function(){k!==3&&j.attr(f).css(o)});N(j.element,Aa?"mouseout":"mouseleave",function(){k!==3&&(l=[e,f,g][k],n=[m,o,p][k],j.attr(l).css(n))});j.setState=function(a){(j.state=k=a)?a===2?j.attr(g).css(p):a===3&&j.attr(h).css(q): +j.attr(e).css(m)};return j.on("click",function(){k!==3&&d.call(j)}).attr(e).css(r({cursor:"default"},m))},crispLine:function(a,b){a[1]===a[4]&&(a[1]=a[4]=v(a[1])-b%2/2);a[2]===a[5]&&(a[2]=a[5]=v(a[2])+b%2/2);return a},path:function(a){var b={fill:P};Ha(a)?b.d=a:da(a)&&r(b,a);return this.createElement("path").attr(b)},circle:function(a,b,c){a=da(a)?a:{x:a,y:b,r:c};b=this.createElement("circle");b.xSetter=function(a){this.element.setAttribute("cx",a)};b.ySetter=function(a){this.element.setAttribute("cy", +a)};return b.attr(a)},arc:function(a,b,c,d,e,f){if(da(a))b=a.y,c=a.r,d=a.innerR,e=a.start,f=a.end,a=a.x;a=this.symbol("arc",a||0,b||0,c||0,c||0,{innerR:d||0,start:e||0,end:f||0});a.r=c;return a},rect:function(a,b,c,d,e,f){var e=da(a)?a.r:e,g=this.createElement("rect"),a=da(a)?a:a===u?{}:{x:a,y:b,width:t(c,0),height:t(d,0)};if(f!==u)a.strokeWidth=f,a=g.crisp(a);if(e)a.r=e;g.rSetter=function(a){F(this.element,{rx:a,ry:a})};return g.attr(a)},setSize:function(a,b,c){var d=this.alignedObjects,e=d.length; +this.width=a;this.height=b;for(this.boxWrapper[p(c,!0)?"animate":"attr"]({width:a,height:b});e--;)d[e].align()},g:function(a){var b=this.createElement("g");return s(a)?b.attr({"class":"highcharts-"+a}):b},image:function(a,b,c,d,e){var f={preserveAspectRatio:P};arguments.length>1&&r(f,{x:b,y:c,width:d,height:e});f=this.createElement("image").attr(f);f.element.setAttributeNS?f.element.setAttributeNS("http://www.w3.org/1999/xlink","href",a):f.element.setAttribute("hc-svg-href",a);return f},symbol:function(a, +b,c,d,e,f){var g,h=this.symbols[a],h=h&&h(v(b),v(c),d,e,f),i=/^url\((.*?)\)$/,j,k;if(h)g=this.path(h),r(g,{symbolName:a,x:b,y:c,width:d,height:e}),f&&r(g,f);else if(i.test(a))k=function(a,b){a.element&&(a.attr({width:b[0],height:b[1]}),a.alignByTranslate||a.translate(v((d-b[0])/2),v((e-b[1])/2)))},j=a.match(i)[1],a=Jb[j]||f&&f.width&&f.height&&[f.width,f.height],g=this.image(j).attr({x:b,y:c}),g.isImg=!0,a?k(g,a):(g.attr({width:0,height:0}),$("img",{onload:function(){k(g,Jb[j]=[this.width,this.height])}, +src:j}));return g},symbols:{circle:function(a,b,c,d){var e=0.166*c;return["M",a+c/2,b,"C",a+c+e,b,a+c+e,b+d,a+c/2,b+d,"C",a-e,b+d,a-e,b,a+c/2,b,"Z"]},square:function(a,b,c,d){return["M",a,b,"L",a+c,b,a+c,b+d,a,b+d,"Z"]},triangle:function(a,b,c,d){return["M",a+c/2,b,"L",a+c,b+d,a,b+d,"Z"]},"triangle-down":function(a,b,c,d){return["M",a,b,"L",a+c,b,a+c/2,b+d,"Z"]},diamond:function(a,b,c,d){return["M",a+c/2,b,"L",a+c,b+d/2,a+c/2,b+d,a,b+d/2,"Z"]},arc:function(a,b,c,d,e){var f=e.start,c=e.r||c||d,g=e.end- +0.001,d=e.innerR,h=e.open,i=aa(f),j=fa(f),k=aa(g),g=fa(g),e=e.end-f<oa?0:1;return["M",a+c*i,b+c*j,"A",c,c,0,e,1,a+c*k,b+c*g,h?"M":"L",a+d*k,b+d*g,"A",d,d,0,e,0,a+d*i,b+d*j,h?"":"Z"]},callout:function(a,b,c,d,e){var f=L(e&&e.r||0,c,d),g=f+6,h=e&&e.anchorX,i=e&&e.anchorY,e=v(e.strokeWidth||0)%2/2;a+=e;b+=e;e=["M",a+f,b,"L",a+c-f,b,"C",a+c,b,a+c,b,a+c,b+f,"L",a+c,b+d-f,"C",a+c,b+d,a+c,b+d,a+c-f,b+d,"L",a+f,b+d,"C",a,b+d,a,b+d,a,b+d-f,"L",a,b+f,"C",a,b,a,b,a+f,b];h&&h>c&&i>b+g&&i<b+d-g?e.splice(13,3, +"L",a+c,i-6,a+c+6,i,a+c,i+6,a+c,b+d-f):h&&h<0&&i>b+g&&i<b+d-g?e.splice(33,3,"L",a,i+6,a-6,i,a,i-6,a,b+f):i&&i>d&&h>a+g&&h<a+c-g?e.splice(23,3,"L",h+6,b+d,h,b+d+6,h-6,b+d,a+f,b+d):i&&i<0&&h>a+g&&h<a+c-g&&e.splice(3,3,"L",h-6,b,h,b-6,h+6,b,c-f,b);return e}},clipRect:function(a,b,c,d){var e="highcharts-"+ub++,f=this.createElement("clipPath").attr({id:e}).add(this.defs),a=this.rect(a,b,c,d,0).add(f);a.id=e;a.clipPath=f;return a},text:function(a,b,c,d){var e=ga||!ba&&this.forExport,f={};if(d&&!this.forExport)return this.html(a, +b,c);f.x=Math.round(b||0);if(c)f.y=Math.round(c);if(a||a===0)f.text=a;a=this.createElement("text").attr(f);e&&a.css({position:"absolute"});if(!d)a.xSetter=function(a,b,c){var d=c.getElementsByTagName("tspan"),e,f=c.getAttribute(b),n;for(n=0;n<d.length;n++)e=d[n],e.getAttribute(b)===f&&e.setAttribute(b,a);c.setAttribute(b,a)};return a},fontMetrics:function(a,b){a=a||this.style.fontSize;if(b&&G.getComputedStyle)b=b.element||b,a=G.getComputedStyle(b,"").fontSize;var a=/px/.test(a)?y(a):/em/.test(a)? +parseFloat(a)*12:12,c=a<24?a+4:v(a*1.2),d=v(c*0.8);return{h:c,b:d,f:a}},label:function(a,b,c,d,e,f,g,h,i){function j(){var a,b;a=o.element.style;D=(t===void 0||xb===void 0||m.styles.textAlign)&&o.textStr&&o.getBBox();m.width=(t||D.width||0)+2*C+kb;m.height=(xb||D.height||0)+2*C;R=C+n.fontMetrics(a&&a.fontSize,o).b;if(y){if(!p)a=v(-J*C),b=h?-R:0,m.box=p=d?n.symbol(d,a,b,m.width,m.height,z):n.rect(a,b,m.width,m.height,0,z[Qb]),p.attr("fill",P).add(m);p.isImg||p.attr(r({width:v(m.width),height:v(m.height)}, +z));z=null}}function k(){var a=m.styles,a=a&&a.textAlign,b=kb+C*(1-J),c;c=h?0:R;if(s(t)&&D&&(a==="center"||a==="right"))b+={center:0.5,right:1}[a]*(t-D.width);if(b!==o.x||c!==o.y)o.attr("x",b),c!==u&&o.attr("y",c);o.x=b;o.y=c}function l(a,b){p?p.attr(a,b):z[a]=b}var n=this,m=n.g(i),o=n.text("",0,0,g).attr({zIndex:1}),p,D,J=0,C=3,kb=0,t,xb,yb,x,Kb=0,z={},R,y;m.onAdd=function(){o.add(m);m.attr({text:a||a===0?a:"",x:b,y:c});p&&s(e)&&m.attr({anchorX:e,anchorY:f})};m.widthSetter=function(a){t=a};m.heightSetter= +function(a){xb=a};m.paddingSetter=function(a){s(a)&&a!==C&&(C=a,k())};m.paddingLeftSetter=function(a){s(a)&&a!==kb&&(kb=a,k())};m.alignSetter=function(a){J={left:0,center:0.5,right:1}[a]};m.textSetter=function(a){a!==u&&o.textSetter(a);j();k()};m["stroke-widthSetter"]=function(a,b){a&&(y=!0);Kb=a%2/2;l(b,a)};m.strokeSetter=m.fillSetter=m.rSetter=function(a,b){b==="fill"&&a&&(y=!0);l(b,a)};m.anchorXSetter=function(a,b){e=a;l(b,a+Kb-yb)};m.anchorYSetter=function(a,b){f=a;l(b,a-x)};m.xSetter=function(a){m.x= +a;J&&(a-=J*((t||D.width)+C));yb=v(a);m.attr("translateX",yb)};m.ySetter=function(a){x=m.y=v(a);m.attr("translateY",x)};var A=m.css;return r(m,{css:function(a){if(a){var b={},a=w(a);q(m.textProps,function(c){a[c]!==u&&(b[c]=a[c],delete a[c])});o.css(b)}return A.call(m,a)},getBBox:function(){return{width:D.width+2*C,height:D.height+2*C,x:D.x-C,y:D.y-C}},shadow:function(a){p&&p.shadow(a);return m},destroy:function(){X(m.element,"mouseenter");X(m.element,"mouseleave");o&&(o=o.destroy());p&&(p=p.destroy()); +S.prototype.destroy.call(m);m=n=j=k=l=null}})}};Za=ta;r(S.prototype,{htmlCss:function(a){var b=this.element;if(b=a&&b.tagName==="SPAN"&&a.width)delete a.width,this.textWidth=b,this.updateTransform();this.styles=r(this.styles,a);B(this.element,a);return this},htmlGetBBox:function(){var a=this.element,b=this.bBox;if(!b){if(a.nodeName==="text")a.style.position="absolute";b=this.bBox={x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}}return b},htmlUpdateTransform:function(){if(this.added){var a= +this.renderer,b=this.element,c=this.translateX||0,d=this.translateY||0,e=this.x||0,f=this.y||0,g=this.textAlign||"left",h={left:0,center:0.5,right:1}[g],i=this.shadows;B(b,{marginLeft:c,marginTop:d});i&&q(i,function(a){B(a,{marginLeft:c+1,marginTop:d+1})});this.inverted&&q(b.childNodes,function(c){a.invertChild(c,b)});if(b.tagName==="SPAN"){var j=this.rotation,k,l=y(this.textWidth),n=[j,g,b.innerHTML,this.textWidth].join(",");if(n!==this.cTT){k=a.fontMetrics(b.style.fontSize).b;s(j)&&this.setSpanRotation(j, +h,k);i=p(this.elemWidth,b.offsetWidth);if(i>l&&/[ \-]/.test(b.textContent||b.innerText))B(b,{width:l+"px",display:"block",whiteSpace:"normal"}),i=l;this.getSpanCorrection(i,k,h,j,g)}B(b,{left:e+(this.xCorr||0)+"px",top:f+(this.yCorr||0)+"px"});if(tb)k=b.offsetHeight;this.cTT=n}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,c){var d={},e=Aa?"-ms-transform":tb?"-webkit-transform":Ua?"MozTransform":Hb?"-o-transform":"";d[e]=d.transform="rotate("+a+"deg)";d[e+(Ua?"Origin":"-origin")]=d.transformOrigin= +b*100+"% "+c+"px";B(this.element,d)},getSpanCorrection:function(a,b,c){this.xCorr=-a*c;this.yCorr=-b}});r(ta.prototype,{html:function(a,b,c){var d=this.createElement("span"),e=d.element,f=d.renderer;d.textSetter=function(a){a!==e.innerHTML&&delete this.bBox;e.innerHTML=this.textStr=a};d.xSetter=d.ySetter=d.alignSetter=d.rotationSetter=function(a,b){b==="align"&&(b="textAlign");d[b]=a;d.htmlUpdateTransform()};d.attr({text:a,x:v(b),y:v(c)}).css({position:"absolute",whiteSpace:"nowrap",fontFamily:this.style.fontFamily, +fontSize:this.style.fontSize});d.css=d.htmlCss;if(f.isSVG)d.add=function(a){var b,c=f.box.parentNode,j=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)j.push(a),a=a.parentGroup;q(j.reverse(),function(a){var d;b=a.div=a.div||$(Ka,{className:F(a.element,"class")},{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px"},b||c);d=b.style;r(a,{translateXSetter:function(b,c){d.left=b+"px";a[c]=b;a.doTransform=!0},translateYSetter:function(b,c){d.top=b+"px";a[c]=b;a.doTransform=!0},visibilitySetter:function(a, +b){d[b]=a}})})}}else b=c;b.appendChild(e);d.added=!0;d.alignOnAdd&&d.htmlUpdateTransform();return d};return d}});var Z;if(!ba&&!ga){Z={init:function(a,b){var c=["<",b,' filled="f" stroked="f"'],d=["position: ","absolute",";"],e=b===Ka;(b==="shape"||e)&&d.push("left:0;top:0;width:1px;height:1px;");d.push("visibility: ",e?"hidden":"visible");c.push(' style="',d.join(""),'"/>');if(b)c=e||b==="span"||b==="img"?c.join(""):a.prepVML(c),this.element=$(c);this.renderer=a},add:function(a){var b=this.renderer, +c=this.element,d=b.box,d=a?a.element||a:d;a&&a.inverted&&b.invertChild(c,d);d.appendChild(c);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform();if(this.onAdd)this.onAdd();return this},updateTransform:S.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=aa(a*Ea),c=fa(a*Ea);B(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11=",b,", M12=",-c,", M21=",c,", M22=",b,", sizingMethod='auto expand')"].join(""):P})},getSpanCorrection:function(a, +b,c,d,e){var f=d?aa(d*Ea):1,g=d?fa(d*Ea):0,h=p(this.elemHeight,this.element.offsetHeight),i;this.xCorr=f<0&&-a;this.yCorr=g<0&&-h;i=f*g<0;this.xCorr+=g*b*(i?1-c:c);this.yCorr-=f*b*(d?i?c:1-c:1);e&&e!=="left"&&(this.xCorr-=a*c*(f<0?-1:1),d&&(this.yCorr-=h*c*(g<0?-1:1)),B(this.element,{textAlign:e}))},pathToVML:function(a){for(var b=a.length,c=[];b--;)if(ja(a[b]))c[b]=v(a[b]*10)-5;else if(a[b]==="Z")c[b]="x";else if(c[b]=a[b],a.isArc&&(a[b]==="wa"||a[b]==="at"))c[b+5]===c[b+7]&&(c[b+7]+=a[b+7]>a[b+ +5]?1:-1),c[b+6]===c[b+8]&&(c[b+8]+=a[b+8]>a[b+6]?1:-1);return c.join(" ")||"x"},clip:function(a){var b=this,c;a?(c=a.members,la(c,b),c.push(b),b.destroyClip=function(){la(c,b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:hb?"inherit":"rect(auto)"});return b.css(a)},css:S.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&Qa(a)},destroy:function(){this.destroyClip&&this.destroyClip();return S.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a= +G.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,b){var c,a=a.split(/[ ,]/);c=a.length;if(c===9||c===11)a[c-4]=a[c-2]=y(a[c-2])-10*b;return a.join(" ")},shadow:function(a,b,c){var d=[],e,f=this.element,g=this.renderer,h,i=f.style,j,k=f.path,l,n,m,o;k&&typeof k.value!=="string"&&(k="x");n=k;if(a){m=p(a.width,3);o=(a.opacity||0.15)/m;for(e=1;e<=3;e++){l=m*2+1-2*e;c&&(n=this.cutOffPath(k.value,l+0.5));j=['<shape isShadow="true" strokeweight="',l,'" filled="false" path="',n,'" coordsize="10 10" style="', +f.style.cssText,'" />'];h=$(g.prepVML(j),null,{left:y(i.left)+p(a.offsetX,1),top:y(i.top)+p(a.offsetY,1)});if(c)h.cutOff=l+1;j=['<stroke color="',a.color||"black",'" opacity="',o*e,'"/>'];$(g.prepVML(j),null,null,h);b?b.element.appendChild(h):f.parentNode.insertBefore(h,f);d.push(h)}this.shadows=d}return this},updateShadows:sa,setAttr:function(a,b){hb?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){this.element.className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]|| +$(this.renderer.prepVML(["<stroke/>"]),null,null,c))[b]=a||"solid";this[b]=a},dSetter:function(a,b,c){var d=this.shadows,a=a||[];this.d=a.join&&a.join(" ");c.path=a=this.pathToVML(a);if(d)for(c=d.length;c--;)d[c].path=d[c].cutOff?this.cutOffPath(a,d[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var d=c.nodeName;if(d==="SPAN")c.style.color=a;else if(d!=="IMG")c.filled=a!==P,this.setAttr("fillcolor",this.renderer.color(a,c,b,this))},opacitySetter:sa,rotationSetter:function(a,b,c){c=c.style; +this[b]=c[b]=a;c.left=-v(fa(a*Ea)+1)+"px";c.top=v(aa(a*Ea))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a;this[b]=a;ja(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){a==="inherit"&&(a="visible");this.shadows&&q(this.shadows,function(c){c.style[b]=a});c.nodeName==="DIV"&&(a=a==="hidden"?"-999em":0,hb||(c.style[b]=a?"visible":"hidden"), +b="top");c.style[b]=a},xSetter:function(a,b,c){this[b]=a;b==="x"?b="left":b==="y"&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}};K.VMLElement=Z=ma(S,Z);Z.prototype.ySetter=Z.prototype.widthSetter=Z.prototype.heightSetter=Z.prototype.xSetter;var ia={Element:Z,isIE8:wa.indexOf("MSIE 8.0")>-1,init:function(a,b,c,d){var e;this.alignedObjects=[];d=this.createElement(Ka).css(r(this.getStyle(d),{position:"relative"}));e=d.element; +a.appendChild(d.element);this.isVML=!0;this.box=e;this.boxWrapper=d;this.cache={};this.setSize(b,c,!1);if(!x.namespaces.hcv){x.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{x.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(f){x.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},isHidden:function(){return!this.box.offsetWidth}, +clipRect:function(a,b,c,d){var e=this.createElement(),f=da(a);return r(e,{members:[],left:(f?a.x:a)+1,top:(f?a.y:b)+1,width:(f?a.width:c)-1,height:(f?a.height:d)-1,getCSS:function(a){var b=a.element,c=b.nodeName,a=a.inverted,d=this.top-(c==="shape"?b.offsetTop:0),e=this.left,b=e+this.width,f=d+this.height,d={clip:"rect("+v(a?e:d)+"px,"+v(a?f:b)+"px,"+v(a?b:f)+"px,"+v(a?d:e)+"px)"};!a&&hb&&c==="DIV"&&r(d,{width:b+"px",height:f+"px"});return d},updateClipping:function(){q(e.members,function(a){a.element&& +a.css(e.getCSS(a))})}})},color:function(a,b,c,d){var e=this,f,g=/^rgba/,h,i,j=P;a&&a.linearGradient?i="gradient":a&&a.radialGradient&&(i="pattern");if(i){var k,l,n=a.linearGradient||a.radialGradient,m,o,p,D,J,C="",a=a.stops,t,s=[],u=function(){h=['<fill colors="'+s.join(",")+'" opacity="',p,'" o:opacity2="',o,'" type="',i,'" ',C,'focus="100%" method="any" />'];$(e.prepVML(h),null,null,b)};m=a[0];t=a[a.length-1];m[0]>0&&a.unshift([0,m[1]]);t[0]<1&&a.push([1,t[1]]);q(a,function(a,b){g.test(a[1])?(f= +ya(a[1]),k=f.get("rgb"),l=f.get("a")):(k=a[1],l=1);s.push(a[0]*100+"% "+k);b?(p=l,D=k):(o=l,J=k)});if(c==="fill")if(i==="gradient")c=n.x1||n[0]||0,a=n.y1||n[1]||0,m=n.x2||n[2]||0,n=n.y2||n[3]||0,C='angle="'+(90-V.atan((n-a)/(m-c))*180/oa)+'"',u();else{var j=n.r,r=j*2,v=j*2,x=n.cx,z=n.cy,R=b.radialReference,w,j=function(){R&&(w=d.getBBox(),x+=(R[0]-w.x)/w.width-0.5,z+=(R[1]-w.y)/w.height-0.5,r*=R[2]/w.width,v*=R[2]/w.height);C='src="'+E.global.VMLRadialGradientURL+'" size="'+r+","+v+'" origin="0.5,0.5" position="'+ +x+","+z+'" color2="'+J+'" ';u()};d.added?j():d.onAdd=j;j=D}else j=k}else if(g.test(a)&&b.tagName!=="IMG")f=ya(a),h=["<",c,' opacity="',f.get("a"),'"/>'],$(this.prepVML(h),null,null,b),j=f.get("rgb");else{j=b.getElementsByTagName(c);if(j.length)j[0].opacity=1,j[0].type="solid";j=a}return j},prepVML:function(a){var b=this.isIE8,a=a.join("");b?(a=a.replace("/>",' xmlns="urn:schemas-microsoft-com:vml" />'),a=a.indexOf('style="')===-1?a.replace("/>",' style="display:inline-block;behavior:url(#default#VML);" />'): +a.replace('style="','style="display:inline-block;behavior:url(#default#VML);')):a=a.replace("<","<hcv:");return a},text:ta.prototype.html,path:function(a){var b={coordsize:"10 10"};Ha(a)?b.d=a:da(a)&&r(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,c){var d=this.symbol("circle");if(da(a))c=a.r,b=a.y,a=a.x;d.isCircle=!0;d.r=c;return d.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement(Ka).attr(b)},image:function(a, +b,c,d,e){var f=this.createElement("img").attr({src:a});arguments.length>1&&f.attr({x:b,y:c,width:d,height:e});return f},createElement:function(a){return a==="rect"?this.symbol(a):ta.prototype.createElement.call(this,a)},invertChild:function(a,b){var c=this,d=b.style,e=a.tagName==="IMG"&&a.style;B(a,{flip:"x",left:y(d.width)-(e?y(e.top):1),top:y(d.height)-(e?y(e.left):1),rotation:-90});q(a.childNodes,function(b){c.invertChild(b,a)})},symbols:{arc:function(a,b,c,d,e){var f=e.start,g=e.end,h=e.r||c|| +d,c=e.innerR,d=aa(f),i=fa(f),j=aa(g),k=fa(g);if(g-f===0)return["x"];f=["wa",a-h,b-h,a+h,b+h,a+h*d,b+h*i,a+h*j,b+h*k];e.open&&!c&&f.push("e","M",a,b);f.push("at",a-c,b-c,a+c,b+c,a+c*j,b+c*k,a+c*d,b+c*i,"x","e");f.isArc=!0;return f},circle:function(a,b,c,d,e){e&&(c=d=2*e.r);e&&e.isCircle&&(a-=c/2,b-=d/2);return["wa",a,b,a+c,b+d,a+c,b+d/2,a+c,b+d/2,"e"]},rect:function(a,b,c,d,e){return ta.prototype.symbols[!s(e)||!e.r?"square":"callout"].call(0,a,b,c,d,e)}}};K.VMLRenderer=Z=function(){this.init.apply(this, +arguments)};Z.prototype=w(ta.prototype,ia);Za=Z}ta.prototype.measureSpanWidth=function(a,b){var c=x.createElement("span"),d;d=x.createTextNode(a);c.appendChild(d);B(c,b);this.box.appendChild(c);d=c.offsetWidth;Qa(c);return d};var Mb;if(ga)K.CanVGRenderer=Z=function(){xa="http://www.w3.org/1999/xhtml"},Z.prototype.symbols={},Mb=function(){function a(){var a=b.length,d;for(d=0;d<a;d++)b[d]();b=[]}var b=[];return{push:function(c,d){b.length===0&&Rb(d,a);b.push(c)}}}(),Za=Z;Ta.prototype={addLabel:function(){var a= +this.axis,b=a.options,c=a.chart,d=a.horiz,e=a.categories,f=a.names,g=this.pos,h=b.labels,i=h.rotation,j=a.tickPositions,d=d&&e&&!h.step&&!h.staggerLines&&!h.rotation&&c.plotWidth/j.length||!d&&(c.margin[3]||c.chartWidth*0.33),k=g===j[0],l=g===j[j.length-1],n,f=e?p(e[g],f[g],g):g,e=this.label,m=j.info;a.isDatetimeAxis&&m&&(n=b.dateTimeLabelFormats[m.higherRanks[g]||m.unitName]);this.isFirst=k;this.isLast=l;b=a.labelFormatter.call({axis:a,chart:c,isFirst:k,isLast:l,dateTimeLabelFormat:n,value:a.isLog? +ea(ka(f)):f});g=d&&{width:t(1,v(d-2*(h.padding||10)))+"px"};if(s(e))e&&e.attr({text:b}).css(g);else{n={align:a.labelAlign};if(ja(i))n.rotation=i;if(d&&h.ellipsis)g.HcHeight=a.len/j.length;this.label=e=s(b)&&h.enabled?c.renderer.text(b,0,0,h.useHTML).attr(n).css(r(g,h.style)).add(a.labelGroup):null;a.tickBaseline=c.renderer.fontMetrics(h.style.fontSize,e).b;i&&a.side===2&&(a.tickBaseline*=aa(i*Ea))}this.yOffset=e?p(h.y,a.tickBaseline+(a.side===2?8:-(e.getBBox().height/2))):0},getLabelSize:function(){var a= +this.label,b=this.axis;return a?a.getBBox()[b.horiz?"height":"width"]:0},getLabelSides:function(){var a=this.label.getBBox(),b=this.axis,c=b.horiz,d=b.options.labels,a=c?a.width:a.height,b=c?d.x-a*{left:0,center:0.5,right:1}[b.labelAlign]:0;return[b,c?a+b:a]},handleOverflow:function(a,b){var c=!0,d=this.axis,e=this.isFirst,f=this.isLast,g=d.horiz?b.x:b.y,h=d.reversed,i=d.tickPositions,j=this.getLabelSides(),k=j[0],j=j[1],l,n,m,o=this.label.line;l=o||0;n=d.labelEdge;m=d.justifyLabels&&(e||f);n[l]=== +u||g+k>n[l]?n[l]=g+j:m||(c=!1);if(m){l=(n=d.justifyToPlot)?d.pos:0;n=n?l+d.len:d.chart.chartWidth;do a+=e?1:-1,m=d.ticks[i[a]];while(i[a]&&(!m||!m.label||m.label.line!==o));d=m&&m.label.xy&&m.label.xy.x+m.getLabelSides()[e?0:1];e&&!h||f&&h?g+k<l&&(g=l-k,m&&g+j>d&&(c=!1)):g+j>n&&(g=n-j,m&&g+k<d&&(c=!1));b.x=g}return c},getPosition:function(a,b,c,d){var e=this.axis,f=e.chart,g=d&&f.oldChartHeight||f.chartHeight;return{x:a?e.translate(b+c,null,null,d)+e.transB:e.left+e.offset+(e.opposite?(d&&f.oldChartWidth|| +f.chartWidth)-e.right-e.left:0),y:a?g-e.bottom+e.offset-(e.opposite?e.height:0):g-e.translate(b+c,null,null,d)-e.transB}},getLabelPosition:function(a,b,c,d,e,f,g,h){var i=this.axis,j=i.transA,k=i.reversed,l=i.staggerLines,a=a+e.x-(f&&d?f*j*(k?-1:1):0),b=b+this.yOffset-(f&&!d?f*j*(k?1:-1):0);if(l)c.line=g/(h||1)%l,b+=c.line*(i.labelOffset/l);return{x:a,y:b}},getMarkPath:function(a,b,c,d,e,f){return f.crispLine(["M",a,b,"L",a+(e?0:-c),b+(e?c:0)],d)},render:function(a,b,c){var d=this.axis,e=d.options, +f=d.chart.renderer,g=d.horiz,h=this.type,i=this.label,j=this.pos,k=e.labels,l=this.gridLine,n=h?h+"Grid":"grid",m=h?h+"Tick":"tick",o=e[n+"LineWidth"],q=e[n+"LineColor"],D=e[n+"LineDashStyle"],J=e[m+"Length"],n=e[m+"Width"]||0,C=e[m+"Color"],t=e[m+"Position"],m=this.mark,s=k.step,r=!0,v=d.tickmarkOffset,w=this.getPosition(g,j,v,b),x=w.x,w=w.y,z=g&&x===d.pos+d.len||!g&&w===d.pos?-1:1,c=p(c,1);this.isActive=!0;if(o){j=d.getPlotLinePath(j+v,o*z,b,!0);if(l===u){l={stroke:q,"stroke-width":o};if(D)l.dashstyle= +D;if(!h)l.zIndex=1;if(b)l.opacity=0;this.gridLine=l=o?f.path(j).attr(l).add(d.gridGroup):null}if(!b&&l&&j)l[this.isNew?"attr":"animate"]({d:j,opacity:c})}if(n&&J)t==="inside"&&(J=-J),d.opposite&&(J=-J),h=this.getMarkPath(x,w,J,n*z,g,f),m?m.animate({d:h,opacity:c}):this.mark=f.path(h).attr({stroke:C,"stroke-width":n,opacity:c}).add(d.axisGroup);if(i&&!isNaN(x))i.xy=w=this.getLabelPosition(x,w,i,g,k,v,a,s),this.isFirst&&!this.isLast&&!p(e.showFirstLabel,1)||this.isLast&&!this.isFirst&&!p(e.showLastLabel, +1)?r=!1:!d.isRadial&&!k.step&&!k.rotation&&!b&&c!==0&&(r=this.handleOverflow(a,w)),s&&a%s&&(r=!1),r&&!isNaN(w.y)?(w.opacity=c,i[this.isNew?"attr":"animate"](w),this.isNew=!1):i.attr("y",-9999)},destroy:function(){Pa(this,this.axis)}};K.PlotLineOrBand=function(a,b){this.axis=a;if(b)this.options=b,this.id=b.id};K.PlotLineOrBand.prototype={render:function(){var a=this,b=a.axis,c=b.horiz,d=(b.pointRange||0)/2,e=a.options,f=e.label,g=a.label,h=e.width,i=e.to,j=e.from,k=s(j)&&s(i),l=e.value,n=e.dashStyle, +m=a.svgElem,o=[],p,q=e.color,J=e.zIndex,C=e.events,r={},u=b.chart.renderer;b.isLog&&(j=za(j),i=za(i),l=za(l));if(h){if(o=b.getPlotLinePath(l,h),r={stroke:q,"stroke-width":h},n)r.dashstyle=n}else if(k){j=t(j,b.min-d);i=L(i,b.max+d);o=b.getPlotBandPath(j,i,e);if(q)r.fill=q;if(e.borderWidth)r.stroke=e.borderColor,r["stroke-width"]=e.borderWidth}else return;if(s(J))r.zIndex=J;if(m)if(o)m.animate({d:o},null,m.onGetPath);else{if(m.hide(),m.onGetPath=function(){m.show()},g)a.label=g=g.destroy()}else if(o&& +o.length&&(a.svgElem=m=u.path(o).attr(r).add(),C))for(p in d=function(b){m.on(b,function(c){C[b].apply(a,[c])})},C)d(p);if(f&&s(f.text)&&o&&o.length&&b.width>0&&b.height>0){f=w({align:c&&k&&"center",x:c?!k&&4:10,verticalAlign:!c&&k&&"middle",y:c?k?16:10:k?6:-4,rotation:c&&!k&&90},f);if(!g){r={align:f.textAlign||f.align,rotation:f.rotation};if(s(J))r.zIndex=J;a.label=g=u.text(f.text,0,0,f.useHTML).attr(r).css(f.style).add()}b=[o[1],o[4],k?o[6]:o[1]];k=[o[2],o[5],k?o[7]:o[2]];o=Oa(b);c=Oa(k);g.align(f, +!1,{x:o,y:c,width:Ca(b)-o,height:Ca(k)-c});g.show()}else g&&g.hide();return a},destroy:function(){la(this.axis.plotLinesAndBands,this);delete this.axis;Pa(this)}};na.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,gridLineColor:"#C0C0C0",labels:M,lineColor:"#C0D0E0",lineWidth:1,minPadding:0.01,maxPadding:0.01,minorGridLineColor:"#E0E0E0",minorGridLineWidth:1,minorTickColor:"#A0A0A0", +minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickColor:"#C0D0E0",tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",tickWidth:1,title:{align:"middle",style:{color:"#707070"}},type:"linear"},defaultYAxisOptions:{endOnTick:!0,gridLineWidth:1,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8,y:3},lineWidth:0,maxPadding:0.05,minPadding:0.05,startOnTick:!0,tickWidth:0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return Ba(this.total, +-1)},style:M.style}},defaultLeftAxisOptions:{labels:{x:-15,y:null},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15,y:null},title:{rotation:90}},defaultBottomAxisOptions:{labels:{x:0,y:null},title:{rotation:0}},defaultTopAxisOptions:{labels:{x:0,y:-15},title:{rotation:0}},init:function(a,b){var c=b.isX;this.horiz=a.inverted?!c:c;this.coll=(this.isXAxis=c)?"xAxis":"yAxis";this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var d= +this.options,e=d.type;this.labelFormatter=d.labels.formatter||this.defaultLabelFormatter;this.userOptions=b;this.minPixelPadding=0;this.chart=a;this.reversed=d.reversed;this.zoomEnabled=d.zoomEnabled!==!1;this.categories=d.categories||e==="category";this.names=[];this.isLog=e==="logarithmic";this.isDatetimeAxis=e==="datetime";this.isLinked=s(d.linkedTo);this.tickmarkOffset=this.categories&&d.tickmarkPlacement==="between"&&p(d.tickInterval,1)===1?0.5:0;this.ticks={};this.labelEdge=[];this.minorTicks= +{};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=d.minRange||d.maxZoom;this.range=d.range;this.offset=d.offset||0;this.stacks={};this.oldStacks={};this.min=this.max=null;this.crosshair=p(d.crosshair,ra(a.options.tooltip.crosshairs)[c?0:1],!1);var f,d=this.options.events;Ma(this,a.axes)===-1&&(c&&!this.isColorAxis?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];if(a.inverted&&c&&this.reversed=== +u)this.reversed=!0;this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(f in d)N(this,f,d[f]);if(this.isLog)this.val2lin=za,this.lin2val=ka},setOptions:function(a){this.options=w(this.defaultOptions,this.isXAxis?{}:this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],w(E[this.coll],a))},defaultLabelFormatter:function(){var a=this.axis,b=this.value,c=a.categories,d=this.dateTimeLabelFormat, +e=E.lang.numericSymbols,f=e&&e.length,g,h=a.options.labels.format,a=a.isLog?b:a.tickInterval;if(h)g=Ja(h,this);else if(c)g=b;else if(d)g=cb(d,b);else if(f&&a>=1E3)for(;f--&&g===u;)c=Math.pow(1E3,f+1),a>=c&&e[f]!==null&&(g=Ba(b/c,-1)+e[f]);g===u&&(g=Q(b)>=1E4?Ba(b,0):Ba(b,-1,u,""));return g},getSeriesExtremes:function(){var a=this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.ignoreMinPadding=a.ignoreMaxPadding=null;a.buildStacks&&a.buildStacks();q(a.series,function(c){if(c.visible||!b.options.chart.ignoreHiddenSeries){var d; +d=c.options.threshold;var e;a.hasVisibleSeries=!0;a.isLog&&d<=0&&(d=null);if(a.isXAxis){if(d=c.xData,d.length)a.dataMin=L(p(a.dataMin,d[0]),Oa(d)),a.dataMax=t(p(a.dataMax,d[0]),Ca(d))}else{c.getExtremes();e=c.dataMax;c=c.dataMin;if(s(c)&&s(e))a.dataMin=L(p(a.dataMin,c),c),a.dataMax=t(p(a.dataMax,e),e);if(s(d))if(a.dataMin>=d)a.dataMin=d,a.ignoreMinPadding=!0;else if(a.dataMax<d)a.dataMax=d,a.ignoreMaxPadding=!0}}})},translate:function(a,b,c,d,e,f){var g=1,h=0,i=d?this.oldTransA:this.transA,d=d?this.oldMin: +this.min,j=this.minPixelPadding,e=(this.options.ordinal||this.isLog&&e)&&this.lin2val;if(!i)i=this.transA;if(c)g*=-1,h=this.len;this.reversed&&(g*=-1,h-=g*(this.sector||this.len));b?(a=a*g+h,a-=j,a=a/i+d,e&&(a=this.lin2val(a))):(e&&(a=this.val2lin(a)),f==="between"&&(f=0.5),a=g*(a-d)*i+h+g*j+(ja(f)?i*f*this.pointRange:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null, +!0)},getPlotLinePath:function(a,b,c,d,e){var f=this.chart,g=this.left,h=this.top,i,j,k=c&&f.oldChartHeight||f.chartHeight,l=c&&f.oldChartWidth||f.chartWidth,n;i=this.transB;e=p(e,this.translate(a,null,null,c));a=c=v(e+i);i=j=v(k-e-i);if(isNaN(e))n=!0;else if(this.horiz){if(i=h,j=k-this.bottom,a<g||a>g+this.width)n=!0}else if(a=g,c=l-this.right,i<h||i>h+this.height)n=!0;return n&&!d?null:f.renderer.crispLine(["M",a,i,"L",c,j],b||1)},getLinearTickPositions:function(a,b,c){var d,e=ea(U(b/a)*a),f=ea(La(c/ +a)*a),g=[];if(b===c&&ja(b))return[b];for(b=e;b<=f;){g.push(b);b=ea(b+a);if(b===d)break;d=b}return g},getMinorTickPositions:function(){var a=this.options,b=this.tickPositions,c=this.minorTickInterval,d=[],e;if(this.isLog){e=b.length;for(a=1;a<e;a++)d=d.concat(this.getLogTickPositions(c,b[a-1],b[a],!0))}else if(this.isDatetimeAxis&&a.minorTickInterval==="auto")d=d.concat(this.getTimeTicks(this.normalizeTimeTickInterval(c),this.min,this.max,a.startOfWeek)),d[0]<this.min&&d.shift();else for(b=this.min+ +(b[0]-this.min)%c;b<=this.max;b+=c)d.push(b);return d},adjustForMinRange:function(){var a=this.options,b=this.min,c=this.max,d,e=this.dataMax-this.dataMin>=this.minRange,f,g,h,i,j;if(this.isXAxis&&this.minRange===u&&!this.isLog)s(a.min)||s(a.max)?this.minRange=null:(q(this.series,function(a){i=a.xData;for(g=j=a.xIncrement?1:i.length-1;g>0;g--)if(h=i[g]-i[g-1],f===u||h<f)f=h}),this.minRange=L(f*5,this.dataMax-this.dataMin));if(c-b<this.minRange){var k=this.minRange;d=(k-c+b)/2;d=[b-d,p(a.min,b-d)]; +if(e)d[2]=this.dataMin;b=Ca(d);c=[b+k,p(a.max,b+k)];if(e)c[2]=this.dataMax;c=Oa(c);c-b<k&&(d[0]=c-k,d[1]=p(a.min,c-k),b=Ca(d))}this.min=b;this.max=c},setAxisTranslation:function(a){var b=this,c=b.max-b.min,d=b.axisPointRange||0,e,f=0,g=0,h=b.linkedParent,i=!!b.categories,j=b.transA;if(b.isXAxis||i||d)h?(f=h.minPointOffset,g=h.pointRangePadding):q(b.series,function(a){var h=i?1:b.isXAxis?a.pointRange:b.axisPointRange||0,j=a.options.pointPlacement,m=a.closestPointRange;h>c&&(h=0);d=t(d,h);f=t(f,Ga(j)? +0:h/2);g=t(g,j==="on"?0:h);!a.noSharedTooltip&&s(m)&&(e=s(e)?L(e,m):m)}),h=b.ordinalSlope&&e?b.ordinalSlope/e:1,b.minPointOffset=f*=h,b.pointRangePadding=g*=h,b.pointRange=L(d,c),b.closestPointRange=e;if(a)b.oldTransA=j;b.translationSlope=b.transA=j=b.len/(c+g||1);b.transB=b.horiz?b.left:b.bottom;b.minPixelPadding=j*f},setTickPositions:function(a){var b=this,c=b.chart,d=b.options,e=d.startOnTick,f=d.endOnTick,g=b.isLog,h=b.isDatetimeAxis,i=b.isXAxis,j=b.isLinked,k=b.options.tickPositioner,l=d.maxPadding, +n=d.minPadding,m=d.tickInterval,o=d.minTickInterval,Y=d.tickPixelInterval,D,J=b.categories;j?(b.linkedParent=c[b.coll][d.linkedTo],c=b.linkedParent.getExtremes(),b.min=p(c.min,c.dataMin),b.max=p(c.max,c.dataMax),d.type!==b.linkedParent.options.type&&ha(11,1)):(b.min=p(b.userMin,d.min,b.dataMin),b.max=p(b.userMax,d.max,b.dataMax));if(g)!a&&L(b.min,p(b.dataMin,b.min))<=0&&ha(10,1),b.min=ea(za(b.min)),b.max=ea(za(b.max));if(b.range&&s(b.max))b.userMin=b.min=t(b.min,b.max-b.range),b.userMax=b.max,b.range= +null;b.beforePadding&&b.beforePadding();b.adjustForMinRange();if(!J&&!b.axisPointRange&&!b.usePercentage&&!j&&s(b.min)&&s(b.max)&&(c=b.max-b.min)){if(!s(d.min)&&!s(b.userMin)&&n&&(b.dataMin<0||!b.ignoreMinPadding))b.min-=c*n;if(!s(d.max)&&!s(b.userMax)&&l&&(b.dataMax>0||!b.ignoreMaxPadding))b.max+=c*l}if(ja(d.floor))b.min=t(b.min,d.floor);if(ja(d.ceiling))b.max=L(b.max,d.ceiling);b.min===b.max||b.min===void 0||b.max===void 0?b.tickInterval=1:j&&!m&&Y===b.linkedParent.options.tickPixelInterval?b.tickInterval= +b.linkedParent.tickInterval:(b.tickInterval=p(m,J?1:(b.max-b.min)*Y/t(b.len,Y)),!s(m)&&b.len<Y&&!this.isRadial&&!this.isLog&&!J&&e&&f&&(D=!0,b.tickInterval/=4));i&&!a&&q(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)});b.setAxisTranslation(!0);b.beforeSetTickPositions&&b.beforeSetTickPositions();if(b.postProcessTickInterval)b.tickInterval=b.postProcessTickInterval(b.tickInterval);if(b.pointRange)b.tickInterval=t(b.pointRange,b.tickInterval);if(!m&&b.tickInterval<o)b.tickInterval= +o;if(!h&&!g&&!m)b.tickInterval=nb(b.tickInterval,null,mb(b.tickInterval),p(d.allowDecimals,!(b.tickInterval>1&&b.tickInterval<5&&b.max>1E3&&b.max<9999)));b.minorTickInterval=d.minorTickInterval==="auto"&&b.tickInterval?b.tickInterval/5:d.minorTickInterval;b.tickPositions=a=d.tickPositions?[].concat(d.tickPositions):k&&k.apply(b,[b.min,b.max]);if(!a)!b.ordinalPositions&&(b.max-b.min)/b.tickInterval>t(2*b.len,200)&&ha(19,!0),a=h?b.getTimeTicks(b.normalizeTimeTickInterval(b.tickInterval,d.units),b.min, +b.max,d.startOfWeek,b.ordinalPositions,b.closestPointRange,!0):g?b.getLogTickPositions(b.tickInterval,b.min,b.max):b.getLinearTickPositions(b.tickInterval,b.min,b.max),D&&a.splice(1,a.length-2),b.tickPositions=a;if(!j)d=a[0],g=a[a.length-1],h=b.minPointOffset||0,e?b.min=d:b.min-h>d&&a.shift(),f?b.max=g:b.max+h<g&&a.pop(),a.length===0&&s(d)&&a.push((g+d)/2),a.length===1&&(e=Q(b.max)>1E13?1:0.001,b.min-=e,b.max+=e)},setMaxTicks:function(){var a=this.chart,b=a.maxTicks||{},c=this.tickPositions,d=this._maxTicksKey= +[this.coll,this.pos,this.len].join("-");if(!this.isLinked&&!this.isDatetimeAxis&&c&&c.length>(b[d]||0)&&this.options.alignTicks!==!1)b[d]=c.length;a.maxTicks=b},adjustTickAmount:function(){var a=this._maxTicksKey,b=this.tickPositions,c=this.chart.maxTicks;if(c&&c[a]&&!this.isDatetimeAxis&&!this.categories&&!this.isLinked&&this.options.alignTicks!==!1&&this.min!==u){var d=this.tickAmount,e=b.length;this.tickAmount=a=c[a];if(e<a){for(;b.length<a;)b.push(ea(b[b.length-1]+this.tickInterval));this.transA*= +(e-1)/(a-1);this.max=b[b.length-1]}if(s(d)&&a!==d)this.isDirty=!0}},setScale:function(){var a=this.stacks,b,c,d,e;this.oldMin=this.min;this.oldMax=this.max;this.oldAxisLength=this.len;this.setAxisSize();e=this.len!==this.oldAxisLength;q(this.series,function(a){if(a.isDirtyData||a.isDirty||a.xAxis.isDirty)d=!0});if(e||d||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax){if(!this.isXAxis)for(b in a)for(c in a[b])a[b][c].total=null,a[b][c].cum=0;this.forceRedraw= +!1;this.getSeriesExtremes();this.setTickPositions();this.oldUserMin=this.userMin;this.oldUserMax=this.userMax;if(!this.isDirty)this.isDirty=e||this.min!==this.oldMin||this.max!==this.oldMax}else if(!this.isXAxis){if(this.oldStacks)a=this.stacks=this.oldStacks;for(b in a)for(c in a[b])a[b][c].cum=a[b][c].total}this.setMaxTicks()},setExtremes:function(a,b,c,d,e){var f=this,g=f.chart,c=p(c,!0),e=r(e,{min:a,max:b});I(f,"setExtremes",e,function(){f.userMin=a;f.userMax=b;f.eventArgs=e;f.isDirtyExtremes= +!0;c&&g.redraw(d)})},zoom:function(a,b){var c=this.dataMin,d=this.dataMax,e=this.options;this.allowZoomOutside||(s(c)&&a<=L(c,p(e.min,c))&&(a=u),s(d)&&b>=t(d,p(e.max,d))&&(b=u));this.displayBtn=a!==u||b!==u;this.setExtremes(a,b,!1,u,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsetLeft||0,d=this.horiz,e=p(b.width,a.plotWidth-c+(b.offsetRight||0)),f=p(b.height,a.plotHeight),g=p(b.top,a.plotTop),b=p(b.left,a.plotLeft+c),c=/%$/;c.test(f)&&(f=parseInt(f,10)/ +100*a.plotHeight);c.test(g)&&(g=parseInt(g,10)/100*a.plotHeight+a.plotTop);this.left=b;this.top=g;this.width=e;this.height=f;this.bottom=a.chartHeight-f-g;this.right=a.chartWidth-e-b;this.len=t(d?e:f,0);this.pos=d?b:g},getExtremes:function(){var a=this.isLog;return{min:a?ea(ka(this.min)):this.min,max:a?ea(ka(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,c=b?ka(this.min):this.min,b=b?ka(this.max): +this.max;c>a||a===null?a=c:b<a&&(a=b);return this.translate(a,0,1,0,1)},autoLabelAlign:function(a){a=(p(a,0)-this.side*90+720)%360;return a>15&&a<165?"right":a>195&&a<345?"left":"center"},getOffset:function(){var a=this,b=a.chart,c=b.renderer,d=a.options,e=a.tickPositions,f=a.ticks,g=a.horiz,h=a.side,i=b.inverted?[1,0,3,2][h]:h,j,k,l=0,n,m=0,o=d.title,Y=d.labels,D=0,J=b.axisOffset,b=b.clipOffset,C=[-1,1,1,-1][h],r,v=1,w=p(Y.maxStaggerLines,5),x,y,A,z,R;a.hasData=j=a.hasVisibleSeries||s(a.min)&&s(a.max)&& +!!e;a.showAxis=k=j||p(d.showEmpty,!0);a.staggerLines=a.horiz&&Y.staggerLines;if(!a.axisGroup)a.gridGroup=c.g("grid").attr({zIndex:d.gridZIndex||1}).add(),a.axisGroup=c.g("axis").attr({zIndex:d.zIndex||2}).add(),a.labelGroup=c.g("axis-labels").attr({zIndex:Y.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels").add();if(j||a.isLinked){a.labelAlign=p(Y.align||a.autoLabelAlign(Y.rotation));q(e,function(b){f[b]?f[b].addLabel():f[b]=new Ta(a,b)});if(a.horiz&&!a.staggerLines&&w&&!Y.rotation){for(j= +a.reversed?[].concat(e).reverse():e;v<w;){x=[];y=!1;for(r=0;r<j.length;r++)A=j[r],z=(z=f[A].label&&f[A].label.getBBox())?z.width:0,R=r%v,z&&(A=a.translate(A),x[R]!==u&&A<x[R]&&(y=!0),x[R]=A+z);if(y)v++;else break}if(v>1)a.staggerLines=v}q(e,function(b){if(h===0||h===2||{1:"left",3:"right"}[h]===a.labelAlign)D=t(f[b].getLabelSize(),D)});if(a.staggerLines)D*=a.staggerLines,a.labelOffset=D}else for(r in f)f[r].destroy(),delete f[r];if(o&&o.text&&o.enabled!==!1){if(!a.axisTitle)a.axisTitle=c.text(o.text, +0,0,o.useHTML).attr({zIndex:7,rotation:o.rotation||0,align:o.textAlign||{low:"left",middle:"center",high:"right"}[o.align]}).addClass("highcharts-"+this.coll.toLowerCase()+"-title").css(o.style).add(a.axisGroup),a.axisTitle.isNew=!0;if(k)l=a.axisTitle.getBBox()[g?"height":"width"],n=o.offset,m=s(n)?0:p(o.margin,g?5:10);a.axisTitle[k?"show":"hide"]()}a.offset=C*p(d.offset,J[h]);c=h===2?a.tickBaseline:0;g=D+m+(D&&C*(g?p(Y.y,a.tickBaseline+8):Y.x)-c);a.axisTitleMargin=p(n,g);J[h]=t(J[h],a.axisTitleMargin+ +l+C*a.offset,g);b[i]=t(b[i],U(d.lineWidth/2)*2)},getLinePath:function(a){var b=this.chart,c=this.opposite,d=this.offset,e=this.horiz,f=this.left+(c?this.width:0)+d,d=b.chartHeight-this.bottom-(c?this.height:0)+d;c&&(a*=-1);return b.renderer.crispLine(["M",e?this.left:f,e?d:this.top,"L",e?b.chartWidth-this.right:f,e?d:b.chartHeight-this.bottom],a)},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,d=this.len,e=this.options.title,f=a?b:c,g=this.opposite,h=this.offset,i=y(e.style.fontSize|| +12),d={low:f+(a?0:d),middle:f+d/2,high:f+(a?d:0)}[e.align],b=(a?c+this.height:b)+(a?1:-1)*(g?-1:1)*this.axisTitleMargin+(this.side===2?i:0);return{x:a?d:b+(g?this.width:0)+h+(e.x||0),y:a?b-(g?this.height:0)+h:d+(e.y||0)}},render:function(){var a=this,b=a.horiz,c=a.reversed,d=a.chart,e=d.renderer,f=a.options,g=a.isLog,h=a.isLinked,i=a.tickPositions,j,k=a.axisTitle,l=a.ticks,n=a.minorTicks,m=a.alternateBands,o=f.stackLabels,p=f.alternateGridColor,D=a.tickmarkOffset,J=f.lineWidth,C=d.hasRendered&&s(a.oldMin)&& +!isNaN(a.oldMin),r=a.hasData,t=a.showAxis,v,w=f.labels.overflow,x=a.justifyLabels=b&&w!==!1,A;a.labelEdge.length=0;a.justifyToPlot=w==="justify";q([l,n,m],function(a){for(var b in a)a[b].isActive=!1});if(r||h)if(a.minorTickInterval&&!a.categories&&q(a.getMinorTickPositions(),function(b){n[b]||(n[b]=new Ta(a,b,"minor"));C&&n[b].isNew&&n[b].render(null,!0);n[b].render(null,!1,1)}),i.length&&(j=i.slice(),(b&&c||!b&&!c)&&j.reverse(),x&&(j=j.slice(1).concat([j[0]])),q(j,function(b,c){x&&(c=c===j.length- +1?0:c+1);if(!h||b>=a.min&&b<=a.max)l[b]||(l[b]=new Ta(a,b)),C&&l[b].isNew&&l[b].render(c,!0,0.1),l[b].render(c)}),D&&a.min===0&&(l[-1]||(l[-1]=new Ta(a,-1,null,!0)),l[-1].render(-1))),p&&q(i,function(b,c){if(c%2===0&&b<a.max)m[b]||(m[b]=new K.PlotLineOrBand(a)),v=b+D,A=i[c+1]!==u?i[c+1]+D:a.max,m[b].options={from:g?ka(v):v,to:g?ka(A):A,color:p},m[b].render(),m[b].isActive=!0}),!a._addedPlotLB)q((f.plotLines||[]).concat(f.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0;q([l,n, +m],function(a){var b,c,e=[],f=va?va.duration||500:0,g=function(){for(c=e.length;c--;)a[e[c]]&&!a[e[c]].isActive&&(a[e[c]].destroy(),delete a[e[c]])};for(b in a)if(!a[b].isActive)a[b].render(b,!1,0),a[b].isActive=!1,e.push(b);a===m||!d.hasRendered||!f?g():f&&setTimeout(g,f)});if(J)b=a.getLinePath(J),a.axisLine?a.axisLine.animate({d:b}):a.axisLine=e.path(b).attr({stroke:f.lineColor,"stroke-width":J,zIndex:7}).add(a.axisGroup),a.axisLine[t?"show":"hide"]();if(k&&t)k[k.isNew?"attr":"animate"](a.getTitlePosition()), +k.isNew=!1;o&&o.enabled&&a.renderStackTotals();a.isDirty=!1},redraw:function(){this.render();q(this.plotLinesAndBands,function(a){a.render()});q(this.series,function(a){a.isDirty=!0})},destroy:function(a){var b=this,c=b.stacks,d,e=b.plotLinesAndBands;a||X(b);for(d in c)Pa(c[d]),c[d]=null;q([b.ticks,b.minorTicks,b.alternateBands],function(a){Pa(a)});for(a=e.length;a--;)e[a].destroy();q("stackTotalGroup,axisLine,axisTitle,axisGroup,cross,gridGroup,labelGroup".split(","),function(a){b[a]&&(b[a]=b[a].destroy())}); +this.cross&&this.cross.destroy()},drawCrosshair:function(a,b){if(this.crosshair)if((s(b)||!p(this.crosshair.snap,!0))===!1)this.hideCrosshair();else{var c,d=this.crosshair,e=d.animation;p(d.snap,!0)?s(b)&&(c=this.chart.inverted!=this.horiz?b.plotX:this.len-b.plotY):c=this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos;c=this.isRadial?this.getPlotLinePath(this.isXAxis?b.x:p(b.stackY,b.y)):this.getPlotLinePath(null,null,null,null,c);if(c===null)this.hideCrosshair();else if(this.cross)this.cross.attr({visibility:"visible"})[e? +"animate":"attr"]({d:c},e);else{e={"stroke-width":d.width||1,stroke:d.color||"#C0C0C0",zIndex:d.zIndex||2};if(d.dashStyle)e.dashstyle=d.dashStyle;this.cross=this.chart.renderer.path(c).attr(e).add()}}},hideCrosshair:function(){this.cross&&this.cross.hide()}};r(na.prototype,{getPlotBandPath:function(a,b){var c=this.getPlotLinePath(b),d=this.getPlotLinePath(a);d&&c?d.push(c[4],c[5],c[1],c[2]):d=null;return d},addPlotBand:function(a){return this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){return this.addPlotBandOrLine(a, +"plotLines")},addPlotBandOrLine:function(a,b){var c=(new K.PlotLineOrBand(this,a)).render(),d=this.userOptions;c&&(b&&(d[b]=d[b]||[],d[b].push(a)),this.plotLinesAndBands.push(c));return c},removePlotBandOrLine:function(a){for(var b=this.plotLinesAndBands,c=this.options,d=this.userOptions,e=b.length;e--;)b[e].id===a&&b[e].destroy();q([c.plotLines||[],d.plotLines||[],c.plotBands||[],d.plotBands||[]],function(b){for(e=b.length;e--;)b[e].id===a&&la(b,b[e])})}});na.prototype.getTimeTicks=function(a,b, +c,d){var e=[],f={},g=E.global.useUTC,h,i=new Da(b-Sa),j=a.unitRange,k=a.count;if(s(b)){j>=A.second&&(i.setMilliseconds(0),i.setSeconds(j>=A.minute?0:k*U(i.getSeconds()/k)));if(j>=A.minute)i[Cb](j>=A.hour?0:k*U(i[pb]()/k));if(j>=A.hour)i[Db](j>=A.day?0:k*U(i[qb]()/k));if(j>=A.day)i[sb](j>=A.month?1:k*U(i[Xa]()/k));j>=A.month&&(i[Eb](j>=A.year?0:k*U(i[fb]()/k)),h=i[gb]());j>=A.year&&(h-=h%k,i[Fb](h));if(j===A.week)i[sb](i[Xa]()-i[rb]()+p(d,1));b=1;Sa&&(i=new Da(i.getTime()+Sa));h=i[gb]();for(var d= +i.getTime(),l=i[fb](),n=i[Xa](),m=(A.day+(g?Sa:i.getTimezoneOffset()*6E4))%A.day;d<c;)e.push(d),j===A.year?d=eb(h+b*k,0):j===A.month?d=eb(h,l+b*k):!g&&(j===A.day||j===A.week)?d=eb(h,l,n+b*k*(j===A.day?1:7)):d+=j*k,b++;e.push(d);q(wb(e,function(a){return j<=A.hour&&a%A.day===m}),function(a){f[a]="day"})}e.info=r(a,{higherRanks:f,totalRange:j*k});return e};na.prototype.normalizeTimeTickInterval=function(a,b){var c=b||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute", +[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],d=c[c.length-1],e=A[d[0]],f=d[1],g;for(g=0;g<c.length;g++)if(d=c[g],e=A[d[0]],f=d[1],c[g+1]&&a<=(e*f[f.length-1]+A[c[g+1][0]])/2)break;e===A.year&&a<5*e&&(f=[1,2,5]);c=nb(a/e,f,d[0]==="year"?t(mb(a/e),1):1);return{unitRange:e,count:c,unitName:d[0]}};na.prototype.getLogTickPositions=function(a,b,c,d){var e=this.options,f=this.len,g=[];if(!d)this._minorAutoInterval=null;if(a>=0.5)a=v(a),g=this.getLinearTickPositions(a, +b,c);else if(a>=0.08)for(var f=U(b),h,i,j,k,l,e=a>0.3?[1,2,4]:a>0.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];f<c+1&&!l;f++){i=e.length;for(h=0;h<i&&!l;h++)j=za(ka(f)*e[h]),j>b&&(!d||k<=c)&&k!==u&&g.push(k),k>c&&(l=!0),k=j}else if(b=ka(b),c=ka(c),a=e[d?"minorTickInterval":"tickInterval"],a=p(a==="auto"?null:a,this._minorAutoInterval,(c-b)*(e.tickPixelInterval/(d?5:1))/((d?f/this.tickPositions.length:f)||1)),a=nb(a,null,mb(a)),g=Va(this.getLinearTickPositions(a,b,c),za),!d)this._minorAutoInterval=a/5;if(!d)this.tickInterval= +a;return g};var Nb=K.Tooltip=function(){this.init.apply(this,arguments)};Nb.prototype={init:function(a,b){var c=b.borderWidth,d=b.style,e=y(d.padding);this.chart=a;this.options=b;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.label=a.renderer.label("",0,0,b.shape||"callout",null,null,b.useHTML,null,"tooltip").attr({padding:e,fill:b.backgroundColor,"stroke-width":c,r:b.borderRadius,zIndex:8}).css(d).css({padding:0}).add().attr({y:-9999});ga||this.label.shadow(b.shadow);this.shared=b.shared}, +destroy:function(){if(this.label)this.label=this.label.destroy();clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},move:function(a,b,c,d){var e=this,f=e.now,g=e.options.animation!==!1&&!e.isHidden&&(Q(a-f.x)>1||Q(b-f.y)>1),h=e.followPointer||e.len>1;r(f,{x:g?(2*f.x+a)/3:a,y:g?(f.y+b)/2:b,anchorX:h?u:g?(2*f.anchorX+c)/3:c,anchorY:h?u:g?(f.anchorY+d)/2:d});e.label.attr(f);if(g)clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){e&&e.move(a,b,c,d)},32)},hide:function(a){var b= +this,c;clearTimeout(this.hideTimer);if(!this.isHidden)c=this.chart.hoverPoints,this.hideTimer=setTimeout(function(){b.label.fadeOut();b.isHidden=!0},p(a,this.options.hideDelay,500)),c&&q(c,function(a){a.setState()}),this.chart.hoverPoints=null},getAnchor:function(a,b){var c,d=this.chart,e=d.inverted,f=d.plotTop,g=0,h=0,i,a=ra(a);c=a[0].tooltipPos;this.followPointer&&b&&(b.chartX===u&&(b=d.pointer.normalize(b)),c=[b.chartX-d.plotLeft,b.chartY-f]);c||(q(a,function(a){i=a.series.yAxis;g+=a.plotX;h+= +(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!e&&i?i.top-f:0)}),g/=a.length,h/=a.length,c=[e?d.plotWidth-h:g,this.shared&&!e&&a.length>1&&b?b.chartY-f:e?d.plotHeight-g:h]);return Va(c,v)},getPosition:function(a,b,c){var d=this.chart,e=this.distance,f={},g,h=["y",d.chartHeight,b,c.plotY+d.plotTop],i=["x",d.chartWidth,a,c.plotX+d.plotLeft],j=c.ttBelow||d.inverted&&!c.negative||!d.inverted&&c.negative,k=function(a,b,c,d){var g=c<d-e,b=d+e+c<b,c=d-e-c;d+=e;if(j&&b)f[a]=d;else if(!j&&g)f[a]=c;else if(g)f[a]= +c;else if(b)f[a]=d;else return!1},l=function(a,b,c,d){if(d<e||d>b-e)return!1;else f[a]=d<c/2?1:d>b-c/2?b-c-2:d-c/2},n=function(a){var b=h;h=i;i=b;g=a},m=function(){k.apply(0,h)!==!1?l.apply(0,i)===!1&&!g&&(n(!0),m()):g?f.x=f.y=0:(n(!0),m())};(d.inverted||this.len>1)&&n();m();return f},defaultFormatter:function(a){var b=this.points||ra(this),c=b[0].series,d;d=[a.tooltipHeaderFormatter(b[0])];q(b,function(a){c=a.series;d.push(c.tooltipFormatter&&c.tooltipFormatter(a)||a.point.tooltipFormatter(c.tooltipOptions.pointFormat))}); +d.push(a.options.footerFormat||"");return d.join("")},refresh:function(a,b){var c=this.chart,d=this.label,e=this.options,f,g,h={},i,j=[];i=e.formatter||this.defaultFormatter;var h=c.hoverPoints,k,l=this.shared;clearTimeout(this.hideTimer);this.followPointer=ra(a)[0].series.tooltipOptions.followPointer;g=this.getAnchor(a,b);f=g[0];g=g[1];l&&(!a.series||!a.series.noSharedTooltip)?(c.hoverPoints=a,h&&q(h,function(a){a.setState()}),q(a,function(a){a.setState("hover");j.push(a.getLabelConfig())}),h={x:a[0].category, +y:a[0].y},h.points=j,this.len=j.length,a=a[0]):h=a.getLabelConfig();i=i.call(h,this);h=a.series;this.distance=p(h.tooltipOptions.distance,16);i===!1?this.hide():(this.isHidden&&(bb(d),d.attr("opacity",1).show()),d.attr({text:i}),k=e.borderColor||a.color||h.color||"#606060",d.attr({stroke:k}),this.updatePosition({plotX:f,plotY:g,negative:a.negative,ttBelow:a.ttBelow}),this.isHidden=!1);I(c,"tooltipRefresh",{text:i,x:f+c.plotLeft,y:g+c.plotTop,borderColor:k})},updatePosition:function(a){var b=this.chart, +c=this.label,c=(this.options.positioner||this.getPosition).call(this,c.width,c.height,a);this.move(v(c.x),v(c.y),a.plotX+b.plotLeft,a.plotY+b.plotTop)},tooltipHeaderFormatter:function(a){var b=a.series,c=b.tooltipOptions,d=c.dateTimeLabelFormats,e=c.xDateFormat,f=b.xAxis,g=f&&f.options.type==="datetime"&&ja(a.key),c=c.headerFormat,f=f&&f.closestPointRange,h;if(g&&!e){if(f)for(h in A){if(A[h]>=f||A[h]<=A.day&&a.key%A[h]>0){e=d[h];break}}else e=d.day;e=e||d.year}g&&e&&(c=c.replace("{point.key}","{point.key:"+ +e+"}"));return Ja(c,{point:a,series:b})}};var pa;$a=x.documentElement.ontouchstart!==u;var Wa=K.Pointer=function(a,b){this.init(a,b)};Wa.prototype={init:function(a,b){var c=b.chart,d=c.events,e=ga?"":c.zoomType,c=a.inverted,f;this.options=b;this.chart=a;this.zoomX=f=/x/.test(e);this.zoomY=e=/y/.test(e);this.zoomHor=f&&!c||e&&c;this.zoomVert=e&&!c||f&&c;this.hasZoom=f||e;this.runChartClick=d&&!!d.click;this.pinchDown=[];this.lastValidTouch={};if(K.Tooltip&&b.tooltip.enabled)a.tooltip=new Nb(a,b.tooltip), +this.followTouchMove=b.tooltip.followTouchMove;this.setDOMEvents()},normalize:function(a,b){var c,d,a=a||window.event,a=Tb(a);if(!a.target)a.target=a.srcElement;d=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;if(!b)this.chartPosition=b=Sb(this.chart.container);d.pageX===u?(c=t(a.x,a.clientX-b.left),d=a.y):(c=d.pageX-b.left,d=d.pageY-b.top);return r(a,{chartX:v(c),chartY:v(d)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};q(this.chart.axes,function(c){b[c.isXAxis?"xAxis": +"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},getIndex:function(a){var b=this.chart;return b.inverted?b.plotHeight+b.plotTop-a.chartY:a.chartX-b.plotLeft},runPointActions:function(a){var b=this.chart,c=b.series,d=b.tooltip,e,f,g=b.hoverPoint,h=b.hoverSeries,i,j,k=b.chartWidth,l=this.getIndex(a);if(d&&this.options.tooltip.shared&&(!h||!h.noSharedTooltip)){f=[];i=c.length;for(j=0;j<i;j++)if(c[j].visible&&c[j].options.enableMouseTracking!==!1&&!c[j].noSharedTooltip&& +c[j].singularTooltips!==!0&&c[j].tooltipPoints.length&&(e=c[j].tooltipPoints[l])&&e.series)e._dist=Q(l-e.clientX),k=L(k,e._dist),f.push(e);for(i=f.length;i--;)f[i]._dist>k&&f.splice(i,1);if(f.length&&f[0].clientX!==this.hoverX)d.refresh(f,a),this.hoverX=f[0].clientX}c=h&&h.tooltipOptions.followPointer;if(h&&h.tracker&&!c){if((e=h.tooltipPoints[l])&&e!==g)e.onMouseOver(a)}else d&&c&&!d.isHidden&&(h=d.getAnchor([{}],a),d.updatePosition({plotX:h[0],plotY:h[1]}));if(d&&!this._onDocumentMouseMove)this._onDocumentMouseMove= +function(a){if(W[pa])W[pa].pointer.onDocumentMouseMove(a)},N(x,"mousemove",this._onDocumentMouseMove);q(b.axes,function(b){b.drawCrosshair(a,p(e,g))})},reset:function(a,b){var c=this.chart,d=c.hoverSeries,e=c.hoverPoint,f=c.tooltip,g=f&&f.shared?c.hoverPoints:e;(a=a&&f&&g)&&ra(g)[0].plotX===u&&(a=!1);if(a)f.refresh(g),e&&e.setState(e.state,!0);else{if(e)e.onMouseOut();if(d)d.onMouseOut();f&&f.hide(b);if(this._onDocumentMouseMove)X(x,"mousemove",this._onDocumentMouseMove),this._onDocumentMouseMove= +null;q(c.axes,function(a){a.hideCrosshair()});this.hoverX=null}},scaleGroups:function(a,b){var c=this.chart,d;q(c.series,function(e){d=a||e.getPlotBox();e.xAxis&&e.xAxis.zoomEnabled&&(e.group.attr(d),e.markerGroup&&(e.markerGroup.attr(d),e.markerGroup.clip(b?c.clipRect:null)),e.dataLabelsGroup&&e.dataLabelsGroup.attr(d))});c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY}, +drag:function(a){var b=this.chart,c=b.options.chart,d=a.chartX,e=a.chartY,f=this.zoomHor,g=this.zoomVert,h=b.plotLeft,i=b.plotTop,j=b.plotWidth,k=b.plotHeight,l,n=this.mouseDownX,m=this.mouseDownY,o=c.panKey&&a[c.panKey+"Key"];d<h?d=h:d>h+j&&(d=h+j);e<i?e=i:e>i+k&&(e=i+k);this.hasDragged=Math.sqrt(Math.pow(n-d,2)+Math.pow(m-e,2));if(this.hasDragged>10){l=b.isInsidePlot(n-h,m-i);if(b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&l&&!o&&!this.selectionMarker)this.selectionMarker=b.renderer.rect(h,i, +f?1:j,g?1:k,0).attr({fill:c.selectionMarkerFill||"rgba(69,114,167,0.25)",zIndex:7}).add();this.selectionMarker&&f&&(d-=n,this.selectionMarker.attr({width:Q(d),x:(d>0?0:d)+n}));this.selectionMarker&&g&&(d=e-m,this.selectionMarker.attr({height:Q(d),y:(d>0?0:d)+m}));l&&!this.selectionMarker&&c.panning&&b.pan(a,c.panning)}},drop:function(a){var b=this.chart,c=this.hasPinched;if(this.selectionMarker){var d={xAxis:[],yAxis:[],originalEvent:a.originalEvent||a},e=this.selectionMarker,f=e.attr?e.attr("x"): +e.x,g=e.attr?e.attr("y"):e.y,h=e.attr?e.attr("width"):e.width,i=e.attr?e.attr("height"):e.height,j;if(this.hasDragged||c)q(b.axes,function(b){if(b.zoomEnabled){var c=b.horiz,e=a.type==="touchend"?b.minPixelPadding:0,m=b.toValue((c?f:g)+e),c=b.toValue((c?f+h:g+i)-e);!isNaN(m)&&!isNaN(c)&&(d[b.coll].push({axis:b,min:L(m,c),max:t(m,c)}),j=!0)}}),j&&I(b,"selection",d,function(a){b.zoom(r(a,c?{animation:!1}:null))});this.selectionMarker=this.selectionMarker.destroy();c&&this.scaleGroups()}if(b)B(b.container, +{cursor:b._cursor}),b.cancelClick=this.hasDragged>10,b.mouseIsDown=this.hasDragged=this.hasPinched=!1,this.pinchDown=[]},onContainerMouseDown:function(a){a=this.normalize(a);a.preventDefault&&a.preventDefault();this.dragStart(a)},onDocumentMouseUp:function(a){W[pa]&&W[pa].pointer.drop(a)},onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition,d=b.hoverSeries,a=this.normalize(a,c);c&&d&&!this.inClass(a.target,"highcharts-tracker")&&!b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)&& +this.reset()},onContainerMouseLeave:function(){var a=W[pa];if(a)a.pointer.reset(),a.pointer.chartPosition=null},onContainerMouseMove:function(a){var b=this.chart;pa=b.index;a=this.normalize(a);a.returnValue=!1;b.mouseIsDown==="mousedown"&&this.drag(a);(this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop))&&!b.openMenu&&this.runPointActions(a)},inClass:function(a,b){for(var c;a;){if(c=F(a,"class"))if(c.indexOf(b)!==-1)return!0;else if(c.indexOf("highcharts-container")!== +-1)return!1;a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries,c=(a=a.relatedTarget||a.toElement)&&a.point&&a.point.series;if(b&&!b.options.stickyTracking&&!this.inClass(a,"highcharts-tooltip")&&c!==b)b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,d=b.plotLeft,e=b.plotTop,a=this.normalize(a);a.cancelBubble=!0;b.cancelClick||(c&&this.inClass(a.target,"highcharts-tracker")?(I(c.series,"click",r(a,{point:c})),b.hoverPoint&&c.firePointEvent("click", +a)):(r(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-d,a.chartY-e)&&I(b,"click",a)))},setDOMEvents:function(){var a=this,b=a.chart.container;b.onmousedown=function(b){a.onContainerMouseDown(b)};b.onmousemove=function(b){a.onContainerMouseMove(b)};b.onclick=function(b){a.onContainerClick(b)};N(b,"mouseleave",a.onContainerMouseLeave);ab===1&&N(x,"mouseup",a.onDocumentMouseUp);if($a)b.ontouchstart=function(b){a.onContainerTouchStart(b)},b.ontouchmove=function(b){a.onContainerTouchMove(b)},ab===1&& +N(x,"touchend",a.onDocumentTouchEnd)},destroy:function(){var a;X(this.chart.container,"mouseleave",this.onContainerMouseLeave);ab||(X(x,"mouseup",this.onDocumentMouseUp),X(x,"touchend",this.onDocumentTouchEnd));clearInterval(this.tooltipTimeout);for(a in this)this[a]=null}};r(K.Pointer.prototype,{pinchTranslate:function(a,b,c,d,e,f){(this.zoomHor||this.pinchHor)&&this.pinchTranslateDirection(!0,a,b,c,d,e,f);(this.zoomVert||this.pinchVert)&&this.pinchTranslateDirection(!1,a,b,c,d,e,f)},pinchTranslateDirection:function(a, +b,c,d,e,f,g,h){var i=this.chart,j=a?"x":"y",k=a?"X":"Y",l="chart"+k,n=a?"width":"height",m=i["plot"+(a?"Left":"Top")],o,p,q=h||1,r=i.inverted,C=i.bounds[a?"h":"v"],t=b.length===1,s=b[0][l],v=c[0][l],u=!t&&b[1][l],w=!t&&c[1][l],x,c=function(){!t&&Q(s-u)>20&&(q=h||Q(v-w)/Q(s-u));p=(m-v)/q+s;o=i["plot"+(a?"Width":"Height")]/q};c();b=p;b<C.min?(b=C.min,x=!0):b+o>C.max&&(b=C.max-o,x=!0);x?(v-=0.8*(v-g[j][0]),t||(w-=0.8*(w-g[j][1])),c()):g[j]=[v,w];r||(f[j]=p-m,f[n]=o);f=r?1/q:q;e[n]=o;e[j]=b;d[r?a?"scaleY": +"scaleX":"scale"+k]=q;d["translate"+k]=f*m+(v-f*s)},pinch:function(a){var b=this,c=b.chart,d=b.pinchDown,e=b.followTouchMove,f=a.touches,g=f.length,h=b.lastValidTouch,i=b.hasZoom,j=b.selectionMarker,k={},l=g===1&&(b.inClass(a.target,"highcharts-tracker")&&c.runTrackerClick||b.runChartClick),n={};(i||e)&&!l&&a.preventDefault();Va(f,function(a){return b.normalize(a)});if(a.type==="touchstart")q(f,function(a,b){d[b]={chartX:a.chartX,chartY:a.chartY}}),h.x=[d[0].chartX,d[1]&&d[1].chartX],h.y=[d[0].chartY, +d[1]&&d[1].chartY],q(c.axes,function(a){if(a.zoomEnabled){var b=c.bounds[a.horiz?"h":"v"],d=a.minPixelPadding,e=a.toPixels(p(a.options.min,a.dataMin)),f=a.toPixels(p(a.options.max,a.dataMax)),g=L(e,f),e=t(e,f);b.min=L(a.pos,g-d);b.max=t(a.pos+a.len,e+d)}}),b.res=!0;else if(d.length){if(!j)b.selectionMarker=j=r({destroy:sa},c.plotBox);b.pinchTranslate(d,f,k,j,n,h);b.hasPinched=i;b.scaleGroups(k,n);if(!i&&e&&g===1)this.runPointActions(b.normalize(a));else if(b.res)b.res=!1,this.reset(!1,0)}},onContainerTouchStart:function(a){var b= +this.chart;pa=b.index;a.touches.length===1?(a=this.normalize(a),b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)?(this.runPointActions(a),this.pinch(a)):this.reset()):a.touches.length===2&&this.pinch(a)},onContainerTouchMove:function(a){(a.touches.length===1||a.touches.length===2)&&this.pinch(a)},onDocumentTouchEnd:function(a){W[pa]&&W[pa].pointer.drop(a)}});if(G.PointerEvent||G.MSPointerEvent){var ua={},zb=!!G.PointerEvent,Xb=function(){var a,b=[];b.item=function(a){return this[a]};for(a in ua)ua.hasOwnProperty(a)&& +b.push({pageX:ua[a].pageX,pageY:ua[a].pageY,target:ua[a].target});return b},Ab=function(a,b,c,d){a=a.originalEvent||a;if((a.pointerType==="touch"||a.pointerType===a.MSPOINTER_TYPE_TOUCH)&&W[pa])d(a),d=W[pa].pointer,d[b]({type:c,target:a.currentTarget,preventDefault:sa,touches:Xb()})};r(Wa.prototype,{onContainerPointerDown:function(a){Ab(a,"onContainerTouchStart","touchstart",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){Ab(a, +"onContainerTouchMove","touchmove",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY};if(!ua[a.pointerId].target)ua[a.pointerId].target=a.currentTarget})},onDocumentPointerUp:function(a){Ab(a,"onContainerTouchEnd","touchend",function(a){delete ua[a.pointerId]})},batchMSEvents:function(a){a(this.chart.container,zb?"pointerdown":"MSPointerDown",this.onContainerPointerDown);a(this.chart.container,zb?"pointermove":"MSPointerMove",this.onContainerPointerMove);a(x,zb?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}}); +Na(Wa.prototype,"init",function(a,b,c){a.call(this,b,c);(this.hasZoom||this.followTouchMove)&&B(b.container,{"-ms-touch-action":P,"touch-action":P})});Na(Wa.prototype,"setDOMEvents",function(a){a.apply(this);(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(N)});Na(Wa.prototype,"destroy",function(a){this.batchMSEvents(X);a.call(this)})}var lb=K.Legend=function(a,b){this.init(a,b)};lb.prototype={init:function(a,b){var c=this,d=b.itemStyle,e=p(b.padding,8),f=b.itemMarginTop||0;this.options=b; +if(b.enabled)c.itemStyle=d,c.itemHiddenStyle=w(d,b.itemHiddenStyle),c.itemMarginTop=f,c.padding=e,c.initialItemX=e,c.initialItemY=e-5,c.maxItemWidth=0,c.chart=a,c.itemHeight=0,c.lastLineHeight=0,c.symbolWidth=p(b.symbolWidth,16),c.pages=[],c.render(),N(c.chart,"endResize",function(){c.positionCheckboxes()})},colorizeItem:function(a,b){var c=this.options,d=a.legendItem,e=a.legendLine,f=a.legendSymbol,g=this.itemHiddenStyle.color,c=b?c.itemStyle.color:g,h=b?a.legendColor||a.color||"#CCC":g,g=a.options&& +a.options.marker,i={fill:h},j;d&&d.css({fill:c,color:c});e&&e.attr({stroke:h});if(f){if(g&&f.isMarker)for(j in i.stroke=h,g=a.convertAttribs(g),g)d=g[j],d!==u&&(i[j]=d);f.attr(i)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,d=a._legendItemPos,e=d[0],d=d[1],f=a.checkbox;a.legendGroup&&a.legendGroup.translate(b?e:this.legendWidth-e-2*c-4,d);if(f)f.x=e,f.y=d},destroyItem:function(a){var b=a.checkbox;q(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&& +(a[b]=a[b].destroy())});b&&Qa(a.checkbox)},destroy:function(){var a=this.group,b=this.box;if(b)this.box=b.destroy();if(a)this.group=a.destroy()},positionCheckboxes:function(a){var b=this.group.alignAttr,c,d=this.clipHeight||this.legendHeight;if(b)c=b.translateY,q(this.allItems,function(e){var f=e.checkbox,g;f&&(g=c+f.y+(a||0)+3,B(f,{left:b.translateX+e.checkboxOffset+f.x-20+"px",top:g+"px",display:g>c-6&&g<c+d-6?"":P}))})},renderTitle:function(){var a=this.padding,b=this.options.title,c=0;if(b.text){if(!this.title)this.title= +this.chart.renderer.label(b.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(b.style).add(this.group);a=this.title.getBBox();c=a.height;this.offsetWidth=a.width;this.contentGroup.attr({translateY:c})}this.titleHeight=c},renderItem:function(a){var b=this.chart,c=b.renderer,d=this.options,e=d.layout==="horizontal",f=this.symbolWidth,g=d.symbolPadding,h=this.itemStyle,i=this.itemHiddenStyle,j=this.padding,k=e?p(d.itemDistance,20):0,l=!d.rtl,n=d.width,m=d.itemMarginBottom||0, +o=this.itemMarginTop,q=this.initialItemX,r=a.legendItem,s=a.series&&a.series.drawLegendSymbol?a.series:a,C=s.options,C=this.createCheckboxForItem&&C&&C.showCheckbox,u=d.useHTML;if(!r){a.legendGroup=c.g("legend-item").attr({zIndex:1}).add(this.scrollGroup);a.legendItem=r=c.text(d.labelFormat?Ja(d.labelFormat,a):d.labelFormatter.call(a),l?f+g:-g,this.baseline||0,u).css(w(a.visible?h:i)).attr({align:l?"left":"right",zIndex:2}).add(a.legendGroup);if(!this.baseline)this.baseline=c.fontMetrics(h.fontSize, +r).f+3+o,r.attr("y",this.baseline);s.drawLegendSymbol(this,a);this.setItemEvents&&this.setItemEvents(a,r,u,h,i);this.colorizeItem(a,a.visible);C&&this.createCheckboxForItem(a)}c=r.getBBox();f=a.checkboxOffset=d.itemWidth||a.legendItemWidth||f+g+c.width+k+(C?20:0);this.itemHeight=g=v(a.legendItemHeight||c.height);if(e&&this.itemX-q+f>(n||b.chartWidth-2*j-q-d.x))this.itemX=q,this.itemY+=o+this.lastLineHeight+m,this.lastLineHeight=0;this.maxItemWidth=t(this.maxItemWidth,f);this.lastItemY=o+this.itemY+ +m;this.lastLineHeight=t(g,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];e?this.itemX+=f:(this.itemY+=o+g+m,this.lastLineHeight=g);this.offsetWidth=n||t((e?this.itemX-q-k:f)+j,this.offsetWidth)},getAllItems:function(){var a=[];q(this.chart.series,function(b){var c=b.options;if(p(c.showInLegend,!s(c.linkedTo)?u:!1,!0))a=a.concat(b.legendItems||(c.legendType==="point"?b.data:b))});return a},render:function(){var a=this,b=a.chart,c=b.renderer,d=a.group,e,f,g,h,i=a.box,j=a.options,k=a.padding, +l=j.borderWidth,n=j.backgroundColor;a.itemX=a.initialItemX;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;if(!d)a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup);a.renderTitle();e=a.getAllItems();ob(e,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});j.reversed&&e.reverse();a.allItems=e;a.display=f=!!e.length;q(e,function(b){a.renderItem(b)});g=j.width||a.offsetWidth; +h=a.lastItemY+a.lastLineHeight+a.titleHeight;h=a.handleOverflow(h);if(l||n){g+=k;h+=k;if(i){if(g>0&&h>0)i[i.isNew?"attr":"animate"](i.crisp({width:g,height:h})),i.isNew=!1}else a.box=i=c.rect(0,0,g,h,j.borderRadius,l||0).attr({stroke:j.borderColor,"stroke-width":l||0,fill:n||P}).add(d).shadow(j.shadow),i.isNew=!0;i[f?"show":"hide"]()}a.legendWidth=g;a.legendHeight=h;q(e,function(b){a.positionItem(b)});f&&d.align(r({width:g,height:h},j),!0,"spacingBox");b.isResizing||this.positionCheckboxes()},handleOverflow:function(a){var b= +this,c=this.chart,d=c.renderer,e=this.options,f=e.y,f=c.spacingBox.height+(e.verticalAlign==="top"?-f:f)-this.padding,g=e.maxHeight,h,i=this.clipRect,j=e.navigation,k=p(j.animation,!0),l=j.arrowSize||12,n=this.nav,m=this.pages,o,r=this.allItems;e.layout==="horizontal"&&(f/=2);g&&(f=L(f,g));m.length=0;if(a>f&&!e.useHTML){this.clipHeight=h=t(f-20-this.titleHeight-this.padding,0);this.currentPage=p(this.currentPage,1);this.fullHeight=a;q(r,function(a,b){var c=a._legendItemPos[1],d=v(a.legendItem.getBBox().height), +e=m.length;if(!e||c-m[e-1]>h&&(o||c)!==m[e-1])m.push(o||c),e++;b===r.length-1&&c+d-m[e-1]>h&&m.push(c);c!==o&&(o=c)});if(!i)i=b.clipRect=d.clipRect(0,this.padding,9999,0),b.contentGroup.clip(i);i.attr({height:h});if(!n)this.nav=n=d.g().attr({zIndex:1}).add(this.group),this.up=d.symbol("triangle",0,0,l,l).on("click",function(){b.scroll(-1,k)}).add(n),this.pager=d.text("",15,10).css(j.style).add(n),this.down=d.symbol("triangle-down",0,0,l,l).on("click",function(){b.scroll(1,k)}).add(n);b.scroll(0); +a=f}else if(n)i.attr({height:c.chartHeight}),n.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0;return a},scroll:function(a,b){var c=this.pages,d=c.length,e=this.currentPage+a,f=this.clipHeight,g=this.options.navigation,h=g.activeColor,g=g.inactiveColor,i=this.pager,j=this.padding;e>d&&(e=d);if(e>0)b!==u&&Ra(b,this.chart),this.nav.attr({translateX:j,translateY:f+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({fill:e===1?g:h}).css({cursor:e===1?"default":"pointer"}), +i.attr({text:e+"/"+d}),this.down.attr({x:18+this.pager.getBBox().width,fill:e===d?g:h}).css({cursor:e===d?"default":"pointer"}),c=-c[e-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=e,this.positionCheckboxes(c)}};M=K.LegendSymbolMixin={drawRectangle:function(a,b){var c=a.options.symbolHeight||12;b.legendSymbol=this.chart.renderer.rect(0,a.baseline-5-c/2,a.symbolWidth,c,a.options.symbolRadius||0).attr({zIndex:3}).add(b.legendGroup)},drawLineMarker:function(a){var b= +this.options,c=b.marker,d;d=a.symbolWidth;var e=this.chart.renderer,f=this.legendGroup,a=a.baseline-v(e.fontMetrics(a.options.itemStyle.fontSize,this.legendItem).b*0.3),g;if(b.lineWidth){g={"stroke-width":b.lineWidth};if(b.dashStyle)g.dashstyle=b.dashStyle;this.legendLine=e.path(["M",0,a,"L",d,a]).attr(g).add(f)}if(c&&c.enabled!==!1)b=c.radius,this.legendSymbol=d=e.symbol(this.symbol,d/2-b,a-b,2*b,2*b).add(f),d.isMarker=!0}};(/Trident\/7\.0/.test(wa)||Ua)&&Na(lb.prototype,"positionItem",function(a, +b){var c=this,d=function(){b._legendItemPos&&a.call(c,b)};d();setTimeout(d)});Ya.prototype={init:function(a,b){var c,d=a.series;a.series=null;c=w(E,a);c.series=a.series=d;this.userOptions=a;d=c.chart;this.margin=this.splashArray("margin",d);this.spacing=this.splashArray("spacing",d);var e=d.events;this.bounds={h:{},v:{}};this.callback=b;this.isResizing=0;this.options=c;this.axes=[];this.series=[];this.hasCartesianSeries=d.showAxes;var f=this,g;f.index=W.length;W.push(f);ab++;d.reflow!==!1&&N(f,"load", +function(){f.initReflow()});if(e)for(g in e)N(f,g,e[g]);f.xAxis=[];f.yAxis=[];f.animation=ga?!1:p(d.animation,!0);f.pointCount=f.colorCounter=f.symbolCounter=0;f.firstRender()},initSeries:function(a){var b=this.options.chart;(b=H[a.type||b.type||b.defaultSeriesType])||ha(17,!0);b=new b;b.init(this,a);return b},isInsidePlot:function(a,b,c){var d=c?b:a,a=c?a:b;return d>=0&&d<=this.plotWidth&&a>=0&&a<=this.plotHeight},adjustTickAmounts:function(){this.options.chart.alignTicks!==!1&&q(this.axes,function(a){a.adjustTickAmount()}); +this.maxTicks=null},redraw:function(a){var b=this.axes,c=this.series,d=this.pointer,e=this.legend,f=this.isDirtyLegend,g,h,i=this.hasCartesianSeries,j=this.isDirtyBox,k=c.length,l=k,n=this.renderer,m=n.isHidden(),o=[];Ra(a,this);m&&this.cloneRenderTo();for(this.layOutTitles();l--;)if(a=c[l],a.options.stacking&&(g=!0,a.isDirty)){h=!0;break}if(h)for(l=k;l--;)if(a=c[l],a.options.stacking)a.isDirty=!0;q(c,function(a){a.isDirty&&a.options.legendType==="point"&&(f=!0)});if(f&&e.options.enabled)e.render(), +this.isDirtyLegend=!1;g&&this.getStacks();if(i){if(!this.isResizing)this.maxTicks=null,q(b,function(a){a.setScale()});this.adjustTickAmounts()}this.getMargins();i&&(q(b,function(a){a.isDirty&&(j=!0)}),q(b,function(a){if(a.isDirtyExtremes)a.isDirtyExtremes=!1,o.push(function(){I(a,"afterSetExtremes",r(a.eventArgs,a.getExtremes()));delete a.eventArgs});(j||g)&&a.redraw()}));j&&this.drawChartBox();q(c,function(a){a.isDirty&&a.visible&&(!a.isCartesian||a.xAxis)&&a.redraw()});d&&d.reset(!0);n.draw();I(this, +"redraw");m&&this.cloneRenderTo(!0);q(o,function(a){a.call()})},get:function(a){var b=this.axes,c=this.series,d,e;for(d=0;d<b.length;d++)if(b[d].options.id===a)return b[d];for(d=0;d<c.length;d++)if(c[d].options.id===a)return c[d];for(d=0;d<c.length;d++){e=c[d].points||[];for(b=0;b<e.length;b++)if(e[b].id===a)return e[b]}return null},getAxes:function(){var a=this,b=this.options,c=b.xAxis=ra(b.xAxis||{}),b=b.yAxis=ra(b.yAxis||{});q(c,function(a,b){a.index=b;a.isX=!0});q(b,function(a,b){a.index=b}); +c=c.concat(b);q(c,function(b){new na(a,b)});a.adjustTickAmounts()},getSelectedPoints:function(){var a=[];q(this.series,function(b){a=a.concat(wb(b.points||[],function(a){return a.selected}))});return a},getSelectedSeries:function(){return wb(this.series,function(a){return a.selected})},getStacks:function(){var a=this;q(a.yAxis,function(a){if(a.stacks&&a.hasVisibleSeries)a.oldStacks=a.stacks});q(a.series,function(b){if(b.options.stacking&&(b.visible===!0||a.options.chart.ignoreHiddenSeries===!1))b.stackKey= +b.type+p(b.options.stack,"")})},setTitle:function(a,b,c){var g;var d=this,e=d.options,f;f=e.title=w(e.title,a);g=e.subtitle=w(e.subtitle,b),e=g;q([["title",a,f],["subtitle",b,e]],function(a){var b=a[0],c=d[b],e=a[1],a=a[2];c&&e&&(d[b]=c=c.destroy());a&&a.text&&!c&&(d[b]=d.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+b,zIndex:a.zIndex||4}).css(a.style).add())});d.layOutTitles(c)},layOutTitles:function(a){var b=0,c=this.title,d=this.subtitle,e=this.options,f=e.title, +e=e.subtitle,g=this.renderer,h=this.spacingBox.width-44;if(c&&(c.css({width:(f.width||h)+"px"}).align(r({y:g.fontMetrics(f.style.fontSize,c).b-3},f),!1,"spacingBox"),!f.floating&&!f.verticalAlign))b=c.getBBox().height;d&&(d.css({width:(e.width||h)+"px"}).align(r({y:b+(f.margin-13)+g.fontMetrics(f.style.fontSize,d).b},e),!1,"spacingBox"),!e.floating&&!e.verticalAlign&&(b=La(b+d.getBBox().height)));c=this.titleOffset!==b;this.titleOffset=b;if(!this.isDirtyBox&&c)this.isDirtyBox=c,this.hasRendered&& +p(a,!0)&&this.isDirtyBox&&this.redraw()},getChartSize:function(){var a=this.options.chart,b=a.width,a=a.height,c=this.renderToClone||this.renderTo;if(!s(b))this.containerWidth=ib(c,"width");if(!s(a))this.containerHeight=ib(c,"height");this.chartWidth=t(0,b||this.containerWidth||600);this.chartHeight=t(0,p(a,this.containerHeight>19?this.containerHeight:400))},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;a?b&&(this.renderTo.appendChild(c),Qa(b),delete this.renderToClone):(c&& +c.parentNode===this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),B(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),x.body.appendChild(b),c&&b.appendChild(c))},getContainer:function(){var a,b=this.options.chart,c,d,e;this.renderTo=a=b.renderTo;e="highcharts-"+ub++;if(Ga(a))this.renderTo=a=x.getElementById(a);a||ha(13,!0);c=y(F(a,"data-highcharts-chart"));!isNaN(c)&&W[c]&&W[c].hasRendered&& +W[c].destroy();F(a,"data-highcharts-chart",this.index);a.innerHTML="";!b.skipClone&&!a.offsetWidth&&this.cloneRenderTo();this.getChartSize();c=this.chartWidth;d=this.chartHeight;this.container=a=$(Ka,{className:"highcharts-container"+(b.className?" "+b.className:""),id:e},r({position:"relative",overflow:"hidden",width:c+"px",height:d+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},b.style),this.renderToClone||a);this._cursor=a.style.cursor;this.renderer= +b.forExport?new ta(a,c,d,b.style,!0):new Za(a,c,d,b.style);ga&&this.renderer.create(this,a,c,d)},getMargins:function(){var a=this.spacing,b,c=this.legend,d=this.margin,e=this.options.legend,f=p(e.margin,20),g=e.x,h=e.y,i=e.align,j=e.verticalAlign,k=this.titleOffset;this.resetMargins();b=this.axisOffset;if(k&&!s(d[0]))this.plotTop=t(this.plotTop,k+this.options.title.margin+a[0]);if(c.display&&!e.floating)if(i==="right"){if(!s(d[1]))this.marginRight=t(this.marginRight,c.legendWidth-g+f+a[1])}else if(i=== +"left"){if(!s(d[3]))this.plotLeft=t(this.plotLeft,c.legendWidth+g+f+a[3])}else if(j==="top"){if(!s(d[0]))this.plotTop=t(this.plotTop,c.legendHeight+h+f+a[0])}else if(j==="bottom"&&!s(d[2]))this.marginBottom=t(this.marginBottom,c.legendHeight-h+f+a[2]);this.extraBottomMargin&&(this.marginBottom+=this.extraBottomMargin);this.extraTopMargin&&(this.plotTop+=this.extraTopMargin);this.hasCartesianSeries&&q(this.axes,function(a){a.getOffset()});s(d[3])||(this.plotLeft+=b[3]);s(d[0])||(this.plotTop+=b[0]); +s(d[2])||(this.marginBottom+=b[2]);s(d[1])||(this.marginRight+=b[1]);this.setChartSize()},reflow:function(a){var b=this,c=b.options.chart,d=b.renderTo,e=c.width||ib(d,"width"),f=c.height||ib(d,"height"),c=a?a.target:G,d=function(){if(b.container)b.setSize(e,f,!1),b.hasUserSize=null};if(!b.hasUserSize&&e&&f&&(c===G||c===x)){if(e!==b.containerWidth||f!==b.containerHeight)clearTimeout(b.reflowTimeout),a?b.reflowTimeout=setTimeout(d,100):d();b.containerWidth=e;b.containerHeight=f}},initReflow:function(){var a= +this,b=function(b){a.reflow(b)};N(G,"resize",b);N(a,"destroy",function(){X(G,"resize",b)})},setSize:function(a,b,c){var d=this,e,f,g;d.isResizing+=1;g=function(){d&&I(d,"endResize",null,function(){d.isResizing-=1})};Ra(c,d);d.oldChartHeight=d.chartHeight;d.oldChartWidth=d.chartWidth;if(s(a))d.chartWidth=e=t(0,v(a)),d.hasUserSize=!!e;if(s(b))d.chartHeight=f=t(0,v(b));(va?jb:B)(d.container,{width:e+"px",height:f+"px"},va);d.setChartSize(!0);d.renderer.setSize(e,f,c);d.maxTicks=null;q(d.axes,function(a){a.isDirty= +!0;a.setScale()});q(d.series,function(a){a.isDirty=!0});d.isDirtyLegend=!0;d.isDirtyBox=!0;d.layOutTitles();d.getMargins();d.redraw(c);d.oldChartHeight=null;I(d,"resize");va===!1?g():setTimeout(g,va&&va.duration||500)},setChartSize:function(a){var b=this.inverted,c=this.renderer,d=this.chartWidth,e=this.chartHeight,f=this.options.chart,g=this.spacing,h=this.clipOffset,i,j,k,l;this.plotLeft=i=v(this.plotLeft);this.plotTop=j=v(this.plotTop);this.plotWidth=k=t(0,v(d-i-this.marginRight));this.plotHeight= +l=t(0,v(e-j-this.marginBottom));this.plotSizeX=b?l:k;this.plotSizeY=b?k:l;this.plotBorderWidth=f.plotBorderWidth||0;this.spacingBox=c.spacingBox={x:g[3],y:g[0],width:d-g[3]-g[1],height:e-g[0]-g[2]};this.plotBox=c.plotBox={x:i,y:j,width:k,height:l};d=2*U(this.plotBorderWidth/2);b=La(t(d,h[3])/2);c=La(t(d,h[0])/2);this.clipBox={x:b,y:c,width:U(this.plotSizeX-t(d,h[1])/2-b),height:t(0,U(this.plotSizeY-t(d,h[2])/2-c))};a||q(this.axes,function(a){a.setAxisSize();a.setAxisTranslation()})},resetMargins:function(){var a= +this.spacing,b=this.margin;this.plotTop=p(b[0],a[0]);this.marginRight=p(b[1],a[1]);this.marginBottom=p(b[2],a[2]);this.plotLeft=p(b[3],a[3]);this.axisOffset=[0,0,0,0];this.clipOffset=[0,0,0,0]},drawChartBox:function(){var a=this.options.chart,b=this.renderer,c=this.chartWidth,d=this.chartHeight,e=this.chartBackground,f=this.plotBackground,g=this.plotBorder,h=this.plotBGImage,i=a.borderWidth||0,j=a.backgroundColor,k=a.plotBackgroundColor,l=a.plotBackgroundImage,n=a.plotBorderWidth||0,m,o=this.plotLeft, +p=this.plotTop,q=this.plotWidth,r=this.plotHeight,t=this.plotBox,s=this.clipRect,v=this.clipBox;m=i+(a.shadow?8:0);if(i||j)if(e)e.animate(e.crisp({width:c-m,height:d-m}));else{e={fill:j||P};if(i)e.stroke=a.borderColor,e["stroke-width"]=i;this.chartBackground=b.rect(m/2,m/2,c-m,d-m,a.borderRadius,i).attr(e).addClass("highcharts-background").add().shadow(a.shadow)}if(k)f?f.animate(t):this.plotBackground=b.rect(o,p,q,r,0).attr({fill:k}).add().shadow(a.plotShadow);if(l)h?h.animate(t):this.plotBGImage= +b.image(l,o,p,q,r).add();s?s.animate({width:v.width,height:v.height}):this.clipRect=b.clipRect(v);if(n)g?g.animate(g.crisp({x:o,y:p,width:q,height:r,strokeWidth:-n})):this.plotBorder=b.rect(o,p,q,r,0,-n).attr({stroke:a.plotBorderColor,"stroke-width":n,fill:P,zIndex:1}).add();this.isDirtyBox=!1},propFromSeries:function(){var a=this,b=a.options.chart,c,d=a.options.series,e,f;q(["inverted","angular","polar"],function(g){c=H[b.type||b.defaultSeriesType];f=a[g]||b[g]||c&&c.prototype[g];for(e=d&&d.length;!f&& +e--;)(c=H[d[e].type])&&c.prototype[g]&&(f=!0);a[g]=f})},linkSeries:function(){var a=this,b=a.series;q(b,function(a){a.linkedSeries.length=0});q(b,function(b){var d=b.options.linkedTo;if(Ga(d)&&(d=d===":previous"?a.series[b.index-1]:a.get(d)))d.linkedSeries.push(b),b.linkedParent=d})},renderSeries:function(){q(this.series,function(a){a.translate();a.setTooltipPoints&&a.setTooltipPoints();a.render()})},renderLabels:function(){var a=this,b=a.options.labels;b.items&&q(b.items,function(c){var d=r(b.style, +c.style),e=y(d.left)+a.plotLeft,f=y(d.top)+a.plotTop+12;delete d.left;delete d.top;a.renderer.text(c.html,e,f).attr({zIndex:2}).css(d).add()})},render:function(){var a=this.axes,b=this.renderer,c=this.options;this.setTitle();this.legend=new lb(this,c.legend);this.getStacks();q(a,function(a){a.setScale()});this.getMargins();this.maxTicks=null;q(a,function(a){a.setTickPositions(!0);a.setMaxTicks()});this.adjustTickAmounts();this.getMargins();this.drawChartBox();this.hasCartesianSeries&&q(a,function(a){a.render()}); +if(!this.seriesGroup)this.seriesGroup=b.g("series-group").attr({zIndex:3}).add();this.renderSeries();this.renderLabels();this.showCredits(c.credits);this.hasRendered=!0},showCredits:function(a){if(a.enabled&&!this.credits)this.credits=this.renderer.text(a.text,0,0).on("click",function(){if(a.href)location.href=a.href}).attr({align:a.position.align,zIndex:8}).css(a.style).add().align(a.position)},destroy:function(){var a=this,b=a.axes,c=a.series,d=a.container,e,f=d&&d.parentNode;I(a,"destroy");W[a.index]= +u;ab--;a.renderTo.removeAttribute("data-highcharts-chart");X(a);for(e=b.length;e--;)b[e]=b[e].destroy();for(e=c.length;e--;)c[e]=c[e].destroy();q("title,subtitle,chartBackground,plotBackground,plotBGImage,plotBorder,seriesGroup,clipRect,credits,pointer,scroller,rangeSelector,legend,resetZoomButton,tooltip,renderer".split(","),function(b){var c=a[b];c&&c.destroy&&(a[b]=c.destroy())});if(d)d.innerHTML="",X(d),f&&Qa(d);for(e in a)delete a[e]},isReadyToRender:function(){var a=this;return!ba&&G==G.top&& +x.readyState!=="complete"||ga&&!G.canvg?(ga?Mb.push(function(){a.firstRender()},a.options.global.canvasToolsURL):x.attachEvent("onreadystatechange",function(){x.detachEvent("onreadystatechange",a.firstRender);x.readyState==="complete"&&a.firstRender()}),!1):!0},firstRender:function(){var a=this,b=a.options,c=a.callback;if(a.isReadyToRender()){a.getContainer();I(a,"init");a.resetMargins();a.setChartSize();a.propFromSeries();a.getAxes();q(b.series||[],function(b){a.initSeries(b)});a.linkSeries();I(a, +"beforeRender");if(K.Pointer)a.pointer=new Wa(a,b);a.render();a.renderer.draw();c&&c.apply(a,[a]);q(a.callbacks,function(b){b.apply(a,[a])});a.cloneRenderTo(!0);I(a,"load")}},splashArray:function(a,b){var c=b[a],c=da(c)?c:[c,c,c,c];return[p(b[a+"Top"],c[0]),p(b[a+"Right"],c[1]),p(b[a+"Bottom"],c[2]),p(b[a+"Left"],c[3])]}};Ya.prototype.callbacks=[];Z=K.CenteredSeriesMixin={getCenter:function(){var a=this.options,b=this.chart,c=2*(a.slicedOffset||0),d,e=b.plotWidth-2*c,f=b.plotHeight-2*c,b=a.center, +a=[p(b[0],"50%"),p(b[1],"50%"),a.size||"100%",a.innerSize||0],g=L(e,f),h;return Va(a,function(a,b){h=/%$/.test(a);d=b<2||b===2&&h;return(h?[e,f,g,g][b]*y(a)/100:a)+(d?c:0)})}};var Fa=function(){};Fa.prototype={init:function(a,b,c){this.series=a;this.applyOptions(b,c);this.pointAttr={};if(a.options.colorByPoint&&(b=a.options.colors||a.chart.options.colors,this.color=this.color||b[a.colorCounter++],a.colorCounter===b.length))a.colorCounter=0;a.chart.pointCount++;return this},applyOptions:function(a, +b){var c=this.series,d=c.options.pointValKey||c.pointValKey,a=Fa.prototype.optionsToObject.call(this,a);r(this,a);this.options=this.options?r(this.options,a):a;if(d)this.y=this[d];if(this.x===u&&c)this.x=b===u?c.autoIncrement():b;return this},optionsToObject:function(a){var b={},c=this.series,d=c.pointArrayMap||["y"],e=d.length,f=0,g=0;if(typeof a==="number"||a===null)b[d[0]]=a;else if(Ha(a)){if(a.length>e){c=typeof a[0];if(c==="string")b.name=a[0];else if(c==="number")b.x=a[0];f++}for(;g<e;)b[d[g++]]= +a[f++]}else if(typeof a==="object"){b=a;if(a.dataLabels)c._hasPointLabels=!0;if(a.marker)c._hasPointMarkers=!0}return b},destroy:function(){var a=this.series.chart,b=a.hoverPoints,c;a.pointCount--;if(b&&(this.setState(),la(b,this),!b.length))a.hoverPoints=null;if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)X(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(c in this)this[c]=null},destroyElements:function(){for(var a="graphic,dataLabel,dataLabelUpper,group,connector,shadowGroup".split(","), +b,c=6;c--;)b=a[c],this[b]&&(this[b]=this[b].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var b=this.series,c=b.tooltipOptions,d=p(c.valueDecimals,""),e=c.valuePrefix||"",f=c.valueSuffix||"";q(b.pointArrayMap||["y"],function(b){b="{point."+b;if(e||f)a=a.replace(b+"}",e+b+"}"+f);a=a.replace(b+"}",b+":,."+d+"f}")});return Ja(a, +{point:this,series:this.series})},firePointEvent:function(a,b,c){var d=this,e=this.series.options;(e.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();a==="click"&&e.allowPointSelect&&(c=function(a){d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});I(this,a,b,c)}};var O=function(){};O.prototype={isCartesian:!0,type:"line",pointClass:Fa,sorted:!0,requireSorting:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor",r:"radius"},axisTypes:["xAxis", +"yAxis"],colorCounter:0,parallelArrays:["x","y"],init:function(a,b){var c=this,d,e,f=a.series,g=function(a,b){return p(a.options.index,a._i)-p(b.options.index,b._i)};c.chart=a;c.options=b=c.setOptions(b);c.linkedSeries=[];c.bindAxes();r(c,{name:b.name,state:"",pointAttr:{},visible:b.visible!==!1,selected:b.selected===!0});if(ga)b.animation=!1;e=b.events;for(d in e)N(c,d,e[d]);if(e&&e.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;c.getColor();c.getSymbol(); +q(c.parallelArrays,function(a){c[a+"Data"]=[]});c.setData(b.data,!1);if(c.isCartesian)a.hasCartesianSeries=!0;f.push(c);c._i=f.length-1;ob(f,g);this.yAxis&&ob(this.yAxis.series,g);q(f,function(a,b){a.index=b;a.name=a.name||"Series "+(b+1)})},bindAxes:function(){var a=this,b=a.options,c=a.chart,d;q(a.axisTypes||[],function(e){q(c[e],function(c){d=c.options;if(b[e]===d.index||b[e]!==u&&b[e]===d.id||b[e]===u&&d.index===0)c.series.push(a),a[e]=c,c.isDirty=!0});!a[e]&&a.optionalAxis!==e&&ha(18,!0)})}, +updateParallelArrays:function(a,b){var c=a.series,d=arguments;q(c.parallelArrays,typeof b==="number"?function(d){var f=d==="y"&&c.toYData?c.toYData(a):a[d];c[d+"Data"][b]=f}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(d,2))})},autoIncrement:function(){var a=this.options,b=this.xIncrement,b=p(b,a.pointStart,0);this.pointInterval=p(this.pointInterval,a.pointInterval,1);this.xIncrement=b+this.pointInterval;return b},getSegments:function(){var a=-1,b=[],c,d=this.points, +e=d.length;if(e)if(this.options.connectNulls){for(c=e;c--;)d[c].y===null&&d.splice(c,1);d.length&&(b=[d])}else q(d,function(c,g){c.y===null?(g>a+1&&b.push(d.slice(a+1,g)),a=g):g===e-1&&b.push(d.slice(a+1,g+1))});this.segments=b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},d=b.plotOptions||{},e=c[this.type];this.userOptions=a;c=w(e,c.series,a);this.tooltipOptions=w(E.tooltip,E.plotOptions[this.type].tooltip,b.tooltip,d.series&&d.series.tooltip,d[this.type]&& +d[this.type].tooltip,a.tooltip);e.marker===null&&delete c.marker;return c},getCyclic:function(a,b,c){var d=this.userOptions,e="_"+a+"Index",f=a+"Counter";b||(s(d[e])?b=d[e]:(d[e]=b=this.chart[f]%c.length,this.chart[f]+=1),b=c[b]);this[a]=b},getColor:function(){this.options.colorByPoint||this.getCyclic("color",this.options.color||ca[this.type].color,this.chart.options.colors)},getSymbol:function(){var a=this.options.marker;this.getCyclic("symbol",a.symbol,this.chart.options.symbols);if(/^url/.test(this.symbol))a.radius= +0},drawLegendSymbol:M.drawLineMarker,setData:function(a,b,c,d){var e=this,f=e.points,g=f&&f.length||0,h,i=e.options,j=e.chart,k=null,l=e.xAxis,n=l&&!!l.categories,m=e.tooltipPoints,o=i.turboThreshold,r=this.xData,t=this.yData,s=(h=e.pointArrayMap)&&h.length,a=a||[];h=a.length;b=p(b,!0);if(d!==!1&&h&&g===h&&!e.cropped&&!e.hasGroupedData)q(a,function(a,b){f[b].update(a,!1,null,!1)});else{e.xIncrement=null;e.pointRange=n?1:i.pointRange;e.colorCounter=0;q(this.parallelArrays,function(a){e[a+"Data"].length= +0});if(o&&h>o){for(c=0;k===null&&c<h;)k=a[c],c++;if(ja(k)){n=p(i.pointStart,0);i=p(i.pointInterval,1);for(c=0;c<h;c++)r[c]=n,t[c]=a[c],n+=i;e.xIncrement=n}else if(Ha(k))if(s)for(c=0;c<h;c++)i=a[c],r[c]=i[0],t[c]=i.slice(1,s+1);else for(c=0;c<h;c++)i=a[c],r[c]=i[0],t[c]=i[1];else ha(12)}else for(c=0;c<h;c++)if(a[c]!==u&&(i={series:e},e.pointClass.prototype.applyOptions.apply(i,[a[c]]),e.updateParallelArrays(i,c),n&&i.name))l.names[i.x]=i.name;Ga(t[0])&&ha(14,!0);e.data=[];e.options.data=a;for(c=g;c--;)f[c]&& +f[c].destroy&&f[c].destroy();if(m)m.length=0;if(l)l.minRange=l.userMinRange;e.isDirty=e.isDirtyData=j.isDirtyBox=!0;c=!1}b&&j.redraw(c)},processData:function(a){var b=this.xData,c=this.yData,d=b.length,e;e=0;var f,g,h=this.xAxis,i,j=this.options;i=j.cropThreshold;var k=0,l=this.isCartesian,n,m;if(l&&!this.isDirty&&!h.isDirty&&!this.yAxis.isDirty&&!a)return!1;if(h)n=h.getExtremes(),m=n.min,n=n.max;if(l&&this.sorted&&(!i||d>i||this.forceCrop))if(b[d-1]<m||b[0]>n)b=[],c=[];else if(b[0]<m||b[d-1]>n)e= +this.cropData(this.xData,this.yData,m,n),b=e.xData,c=e.yData,e=e.start,f=!0,k=b.length;for(i=b.length-1;i>=0;i--)d=b[i]-b[i-1],!f&&b[i]>m&&b[i]<n&&k++,d>0&&(g===u||d<g)?g=d:d<0&&this.requireSorting&&ha(15);this.cropped=f;this.cropStart=e;this.processedXData=b;this.processedYData=c;this.activePointCount=k;if(j.pointRange===null)this.pointRange=g||1;this.closestPointRange=g},cropData:function(a,b,c,d){var e=a.length,f=0,g=e,h=p(this.cropShoulder,1),i;for(i=0;i<e;i++)if(a[i]>=c){f=t(0,i-h);break}for(;i< +e;i++)if(a[i]>d){g=i+h;break}return{xData:a.slice(f,g),yData:b.slice(f,g),start:f,end:g}},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,e=this.processedYData,f=this.pointClass,g=d.length,h=this.cropStart||0,i,j=this.hasGroupedData,k,l=[],n;if(!b&&!j)b=[],b.length=a.length,b=this.data=b;for(n=0;n<g;n++)i=h+n,j?l[n]=(new f).init(this,[d[n]].concat(ra(e[n]))):(b[i]?k=b[i]:a[i]!==u&&(b[i]=k=(new f).init(this,a[i],d[n])),l[n]=k),l[n].index=i;if(b&&(g!==(c=b.length)|| +j))for(n=0;n<c;n++)if(n===h&&!j&&(n+=g),b[n])b[n].destroyElements(),b[n].plotX=u;this.data=b;this.points=l},getExtremes:function(a){var b=this.yAxis,c=this.processedXData,d,e=[],f=0;d=this.xAxis.getExtremes();var g=d.min,h=d.max,i,j,k,l,a=a||this.stackedYData||this.processedYData;d=a.length;for(l=0;l<d;l++)if(j=c[l],k=a[l],i=k!==null&&k!==u&&(!b.isLog||k.length||k>0),j=this.getExtremesFromAll||this.cropped||(c[l+1]||j)>=g&&(c[l-1]||j)<=h,i&&j)if(i=k.length)for(;i--;)k[i]!==null&&(e[f++]=k[i]);else e[f++]= +k;this.dataMin=p(void 0,Oa(e));this.dataMax=p(void 0,Ca(e))},translate:function(){this.processedXData||this.processData();this.generatePoints();for(var a=this.options,b=a.stacking,c=this.xAxis,d=c.categories,e=this.yAxis,f=this.points,g=f.length,h=!!this.modifyValue,i=a.pointPlacement,j=i==="between"||ja(i),k=a.threshold,a=0;a<g;a++){var l=f[a],n=l.x,m=l.y,o=l.low,q=b&&e.stacks[(this.negStacks&&m<k?"-":"")+this.stackKey];if(e.isLog&&m<=0)l.y=m=null,ha(10);l.plotX=c.translate(n,0,0,0,1,i,this.type=== +"flags");if(b&&this.visible&&q&&q[n])q=q[n],m=q.points[this.index+","+a],o=m[0],m=m[1],o===0&&(o=p(k,e.min)),e.isLog&&o<=0&&(o=null),l.total=l.stackTotal=q.total,l.percentage=q.total&&l.y/q.total*100,l.stackY=m,q.setOffset(this.pointXOffset||0,this.barW||0);l.yBottom=s(o)?e.translate(o,0,1,0,1):null;h&&(m=this.modifyValue(m,l));l.plotY=typeof m==="number"&&m!==Infinity?e.translate(m,0,1,0,1):u;l.clientX=j?c.translate(n,0,0,0,1):l.plotX;l.negative=l.y<(k||0);l.category=d&&d[l.x]!==u?d[l.x]:l.x}this.getSegments()}, +animate:function(a){var b=this.chart,c=b.renderer,d;d=this.options.animation;var e=this.clipBox||b.clipBox,f=b.inverted,g;if(d&&!da(d))d=ca[this.type].animation;g=["_sharedClip",d.duration,d.easing,e.height].join(",");a?(a=b[g],d=b[g+"m"],a||(b[g]=a=c.clipRect(r(e,{width:0})),b[g+"m"]=d=c.clipRect(-99,f?-b.plotLeft:-b.plotTop,99,f?b.chartWidth:b.chartHeight)),this.group.clip(a),this.markerGroup.clip(d),this.sharedClipKey=g):((a=b[g])&&a.animate({width:b.plotSizeX},d),b[g+"m"]&&b[g+"m"].animate({width:b.plotSizeX+ +99},d),this.animate=null)},afterAnimate:function(){var a=this.chart,b=this.sharedClipKey,c=this.group,d=this.clipBox;if(c&&this.options.clip!==!1){if(!b||!d)c.clip(d?a.renderer.clipRect(d):a.clipRect);this.markerGroup.clip()}I(this,"afterAnimate");setTimeout(function(){b&&a[b]&&(d||(a[b]=a[b].destroy()),a[b+"m"]&&(a[b+"m"]=a[b+"m"].destroy()))},100)},drawPoints:function(){var a,b=this.points,c=this.chart,d,e,f,g,h,i,j,k,l=this.options.marker,n=this.pointAttr[""],m,o,q,t=this.markerGroup,s=p(l.enabled, +!this.requireSorting||this.activePointCount<0.5*this.xAxis.len/l.radius);if(l.enabled!==!1||this._hasPointMarkers)for(f=b.length;f--;)if(g=b[f],d=U(g.plotX),e=g.plotY,k=g.graphic,m=g.marker||{},o=!!g.marker,a=s&&m.enabled===u||m.enabled,q=c.isInsidePlot(v(d),e,c.inverted),a&&e!==u&&!isNaN(e)&&g.y!==null)if(a=g.pointAttr[g.selected?"select":""]||n,h=a.r,i=p(m.symbol,this.symbol),j=i.indexOf("url")===0,k)k[q?"show":"hide"](!0).animate(r({x:d-h,y:e-h},k.symbolName?{width:2*h,height:2*h}:{}));else{if(q&& +(h>0||j))g.graphic=c.renderer.symbol(i,d-h,e-h,2*h,2*h,o?m:l).attr(a).add(t)}else if(k)g.graphic=k.destroy()},convertAttribs:function(a,b,c,d){var e=this.pointAttrToOptions,f,g,h={},a=a||{},b=b||{},c=c||{},d=d||{};for(f in e)g=e[f],h[f]=p(a[g],b[f],c[f],d[f]);return h},getAttribs:function(){var a=this,b=a.options,c=ca[a.type].marker?b.marker:b,d=c.states,e=d.hover,f,g=a.color;f={stroke:g,fill:g};var h=a.points||[],i,j=[],k,l=a.pointAttrToOptions;k=a.hasPointSpecificOptions;var n=b.negativeColor,m= +c.lineColor,o=c.fillColor;i=b.turboThreshold;var p;b.marker?(e.radius=e.radius||c.radius+e.radiusPlus,e.lineWidth=e.lineWidth||c.lineWidth+e.lineWidthPlus):e.color=e.color||ya(e.color||g).brighten(e.brightness).get();j[""]=a.convertAttribs(c,f);q(["hover","select"],function(b){j[b]=a.convertAttribs(d[b],j[""])});a.pointAttr=j;g=h.length;if(!i||g<i||k)for(;g--;){i=h[g];if((c=i.options&&i.options.marker||i.options)&&c.enabled===!1)c.radius=0;if(i.negative&&n)i.color=i.fillColor=n;k=b.colorByPoint|| +i.color;if(i.options)for(p in l)s(c[l[p]])&&(k=!0);if(k){c=c||{};k=[];d=c.states||{};f=d.hover=d.hover||{};if(!b.marker)f.color=f.color||!i.options.color&&e.color||ya(i.color).brighten(f.brightness||e.brightness).get();f={color:i.color};if(!o)f.fillColor=i.color;if(!m)f.lineColor=i.color;k[""]=a.convertAttribs(r(f,c),j[""]);k.hover=a.convertAttribs(d.hover,j.hover,k[""]);k.select=a.convertAttribs(d.select,j.select,k[""])}else k=j;i.pointAttr=k}},destroy:function(){var a=this,b=a.chart,c=/AppleWebKit\/533/.test(wa), +d,e,f=a.data||[],g,h,i;I(a,"destroy");X(a);q(a.axisTypes||[],function(b){if(i=a[b])la(i.series,a),i.isDirty=i.forceRedraw=!0});a.legendItem&&a.chart.legend.destroyItem(a);for(e=f.length;e--;)(g=f[e])&&g.destroy&&g.destroy();a.points=null;clearTimeout(a.animationTimeout);q("area,graph,dataLabelsGroup,group,markerGroup,tracker,graphNeg,areaNeg,posClip,negClip".split(","),function(b){a[b]&&(d=c&&b==="group"?"hide":"destroy",a[b][d]())});if(b.hoverSeries===a)b.hoverSeries=null;la(b.series,a);for(h in a)delete a[h]}, +getSegmentPath:function(a){var b=this,c=[],d=b.options.step;q(a,function(e,f){var g=e.plotX,h=e.plotY,i;b.getPointSpline?c.push.apply(c,b.getPointSpline(a,e,f)):(c.push(f?"L":"M"),d&&f&&(i=a[f-1],d==="right"?c.push(i.plotX,h):d==="center"?c.push((i.plotX+g)/2,i.plotY,(i.plotX+g)/2,h):c.push(g,i.plotY)),c.push(e.plotX,e.plotY))});return c},getGraphPath:function(){var a=this,b=[],c,d=[];q(a.segments,function(e){c=a.getSegmentPath(e);e.length>1?b=b.concat(c):d.push(e[0])});a.singlePoints=d;return a.graphPath= +b},drawGraph:function(){var a=this,b=this.options,c=[["graph",b.lineColor||this.color]],d=b.lineWidth,e=b.dashStyle,f=b.linecap!=="square",g=this.getGraphPath(),h=b.negativeColor;h&&c.push(["graphNeg",h]);q(c,function(c,h){var k=c[0],l=a[k];if(l)bb(l),l.animate({d:g});else if(d&&g.length)l={stroke:c[1],"stroke-width":d,fill:P,zIndex:1},e?l.dashstyle=e:f&&(l["stroke-linecap"]=l["stroke-linejoin"]="round"),a[k]=a.chart.renderer.path(g).attr(l).add(a.group).shadow(!h&&b.shadow)})},clipNeg:function(){var a= +this.options,b=this.chart,c=b.renderer,d=a.negativeColor||a.negativeFillColor,e,f=this.graph,g=this.area,h=this.posClip,i=this.negClip;e=b.chartWidth;var j=b.chartHeight,k=t(e,j),l=this.yAxis;if(d&&(f||g)){d=v(l.toPixels(a.threshold||0,!0));d<0&&(k-=d);a={x:0,y:0,width:k,height:d};k={x:0,y:d,width:k,height:k};if(b.inverted)a.height=k.y=b.plotWidth-d,c.isVML&&(a={x:b.plotWidth-d-b.plotLeft,y:0,width:e,height:j},k={x:d+b.plotLeft-e,y:0,width:b.plotLeft+d,height:e});l.reversed?(b=k,e=a):(b=a,e=k);h? +(h.animate(b),i.animate(e)):(this.posClip=h=c.clipRect(b),this.negClip=i=c.clipRect(e),f&&this.graphNeg&&(f.clip(h),this.graphNeg.clip(i)),g&&(g.clip(h),this.areaNeg.clip(i)))}},invertGroups:function(){function a(){var a={width:b.yAxis.len,height:b.xAxis.len};q(["group","markerGroup"],function(c){b[c]&&b[c].attr(a).invert()})}var b=this,c=b.chart;if(b.xAxis)N(c,"resize",a),N(b,"destroy",function(){X(c,"resize",a)}),a(),b.invertGroups=a},plotGroup:function(a,b,c,d,e){var f=this[a],g=!f;g&&(this[a]= +f=this.chart.renderer.g(b).attr({visibility:c,zIndex:d||0.1}).add(e));f[g?"attr":"animate"](this.getPlotBox());return f},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;if(a.inverted)b=c,c=this.xAxis;return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,d=a.options,e=(c=d.animation)&&!!a.animate&&b.renderer.isSVG&&p(c.duration,500)||0,f=a.visible?"visible":"hidden",g=d.zIndex,h=a.hasRendered,i=b.seriesGroup; +c=a.plotGroup("group","series",f,g,i);a.markerGroup=a.plotGroup("markerGroup","markers",f,g,i);e&&a.animate(!0);a.getAttribs();c.inverted=a.isCartesian?b.inverted:!1;a.drawGraph&&(a.drawGraph(),a.clipNeg());q(a.points,function(a){a.redraw&&a.redraw()});a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&a.options.enableMouseTracking!==!1&&a.drawTracker();b.inverted&&a.invertGroups();d.clip!==!1&&!a.sharedClipKey&&!h&&c.clip(b.clipRect);e&&a.animate();if(!h)e?a.animationTimeout= +setTimeout(function(){a.afterAnimate()},e):a.afterAnimate();a.isDirty=a.isDirtyData=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:p(d&&d.left,a.plotLeft),translateY:p(e&&e.top,a.plotTop)}));this.translate();this.setTooltipPoints&&this.setTooltipPoints(!0);this.render();b&&I(this,"updatedData")}};Gb.prototype={destroy:function(){Pa(this,this.axis)}, +render:function(a){var b=this.options,c=b.format,c=c?Ja(c,this):b.formatter.call(this);this.label?this.label.attr({text:c,visibility:"hidden"}):this.label=this.axis.chart.renderer.text(c,null,null,b.useHTML).css(b.style).attr({align:this.textAlign,rotation:b.rotation,visibility:"hidden"}).add(a)},setOffset:function(a,b){var c=this.axis,d=c.chart,e=d.inverted,f=this.isNegative,g=c.translate(c.usePercentage?100:this.total,0,0,0,1),c=c.translate(0),c=Q(g-c),h=d.xAxis[0].translate(this.x)+a,i=d.plotHeight, +f={x:e?f?g:g-c:h,y:e?i-h-b:f?i-g-c:i-g,width:e?c:b,height:e?b:c};if(e=this.label)e.align(this.alignOptions,null,f),f=e.alignAttr,e[this.options.crop===!1||d.isInsidePlot(f.x,f.y)?"show":"hide"](!0)}};na.prototype.buildStacks=function(){var a=this.series,b=p(this.options.reversedStacks,!0),c=a.length;if(!this.isXAxis){for(this.usePercentage=!1;c--;)a[b?c:a.length-c-1].setStackedPoints();if(this.usePercentage)for(c=0;c<a.length;c++)a[c].setPercentStacks()}};na.prototype.renderStackTotals=function(){var a= +this.chart,b=a.renderer,c=this.stacks,d,e,f=this.stackTotalGroup;if(!f)this.stackTotalGroup=f=b.g("stack-labels").attr({visibility:"visible",zIndex:6}).add();f.translate(a.plotLeft,a.plotTop);for(d in c)for(e in a=c[d],a)a[e].render(f)};O.prototype.setStackedPoints=function(){if(this.options.stacking&&!(this.visible!==!0&&this.chart.options.chart.ignoreHiddenSeries!==!1)){var a=this.processedXData,b=this.processedYData,c=[],d=b.length,e=this.options,f=e.threshold,g=e.stack,e=e.stacking,h=this.stackKey, +i="-"+h,j=this.negStacks,k=this.yAxis,l=k.stacks,n=k.oldStacks,m,o,p,q,r,s;for(q=0;q<d;q++){r=a[q];s=b[q];p=this.index+","+q;o=(m=j&&s<f)?i:h;l[o]||(l[o]={});if(!l[o][r])n[o]&&n[o][r]?(l[o][r]=n[o][r],l[o][r].total=null):l[o][r]=new Gb(k,k.options.stackLabels,m,r,g);o=l[o][r];o.points[p]=[o.cum||0];e==="percent"?(m=m?h:i,j&&l[m]&&l[m][r]?(m=l[m][r],o.total=m.total=t(m.total,o.total)+Q(s)||0):o.total=ea(o.total+(Q(s)||0))):o.total=ea(o.total+(s||0));o.cum=(o.cum||0)+(s||0);o.points[p].push(o.cum); +c[q]=o.cum}if(e==="percent")k.usePercentage=!0;this.stackedYData=c;k.oldStacks={}}};O.prototype.setPercentStacks=function(){var a=this,b=a.stackKey,c=a.yAxis.stacks,d=a.processedXData;q([b,"-"+b],function(b){var e;for(var f=d.length,g,h;f--;)if(g=d[f],e=(h=c[b]&&c[b][g])&&h.points[a.index+","+f],g=e)h=h.total?100/h.total:0,g[0]=ea(g[0]*h),g[1]=ea(g[1]*h),a.stackedYData[f]=g[1]})};r(Ya.prototype,{addSeries:function(a,b,c){var d,e=this;a&&(b=p(b,!0),I(e,"addSeries",{options:a},function(){d=e.initSeries(a); +e.isDirtyLegend=!0;e.linkSeries();b&&e.redraw(c)}));return d},addAxis:function(a,b,c,d){var e=b?"xAxis":"yAxis",f=this.options;new na(this,w(a,{index:this[e].length,isX:b}));f[e]=ra(f[e]||{});f[e].push(a);p(c,!0)&&this.redraw(d)},showLoading:function(a){var b=this,c=b.options,d=b.loadingDiv,e=c.loading,f=function(){d&&B(d,{left:b.plotLeft+"px",top:b.plotTop+"px",width:b.plotWidth+"px",height:b.plotHeight+"px"})};if(!d)b.loadingDiv=d=$(Ka,{className:"highcharts-loading"},r(e.style,{zIndex:10,display:P}), +b.container),b.loadingSpan=$("span",null,e.labelStyle,d),N(b,"redraw",f);b.loadingSpan.innerHTML=a||c.lang.loading;if(!b.loadingShown)B(d,{opacity:0,display:""}),jb(d,{opacity:e.style.opacity},{duration:e.showDuration||0}),b.loadingShown=!0;f()},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&jb(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){B(b,{display:P})}});this.loadingShown=!1}});r(Fa.prototype,{update:function(a,b,c,d){function e(){f.applyOptions(a);if(da(a)&& +!Ha(a))f.redraw=function(){if(h)a&&a.marker&&a.marker.symbol?f.graphic=h.destroy():h.attr(f.pointAttr[f.state||""]);if(a&&a.dataLabels&&f.dataLabel)f.dataLabel=f.dataLabel.destroy();f.redraw=null};i=f.index;g.updateParallelArrays(f,i);k.data[i]=f.options;g.isDirty=g.isDirtyData=!0;if(!g.fixedBox&&g.hasCartesianSeries)j.isDirtyBox=!0;k.legendType==="point"&&j.legend.destroyItem(f);b&&j.redraw(c)}var f=this,g=f.series,h=f.graphic,i,j=g.chart,k=g.options,b=p(b,!0);d===!1?e():f.firePointEvent("update", +{options:a},e)},remove:function(a,b){var c=this,d=c.series,e=d.points,f=d.chart,g,h=d.data;Ra(b,f);a=p(a,!0);c.firePointEvent("remove",null,function(){g=Ma(c,h);h.length===e.length&&e.splice(g,1);h.splice(g,1);d.options.data.splice(g,1);d.updateParallelArrays(c,"splice",g,1);c.destroy();d.isDirty=!0;d.isDirtyData=!0;a&&f.redraw()})}});r(O.prototype,{addPoint:function(a,b,c,d){var e=this.options,f=this.data,g=this.graph,h=this.area,i=this.chart,j=this.xAxis&&this.xAxis.names,k=g&&g.shift||0,l=e.data, +n,m=this.xData;Ra(d,i);c&&q([g,h,this.graphNeg,this.areaNeg],function(a){if(a)a.shift=k+1});if(h)h.isArea=!0;b=p(b,!0);d={series:this};this.pointClass.prototype.applyOptions.apply(d,[a]);g=d.x;h=m.length;if(this.requireSorting&&g<m[h-1])for(n=!0;h&&m[h-1]>g;)h--;this.updateParallelArrays(d,"splice",h,0,0);this.updateParallelArrays(d,h);if(j&&d.name)j[g]=d.name;l.splice(h,0,a);n&&(this.data.splice(h,0,null),this.processData());e.legendType==="point"&&this.generatePoints();c&&(f[0]&&f[0].remove?f[0].remove(!1): +(f.shift(),this.updateParallelArrays(d,"shift"),l.shift()));this.isDirtyData=this.isDirty=!0;b&&(this.getAttribs(),i.redraw())},remove:function(a,b){var c=this,d=c.chart,a=p(a,!0);if(!c.isRemoving)c.isRemoving=!0,I(c,"remove",null,function(){c.destroy();d.isDirtyLegend=d.isDirtyBox=!0;d.linkSeries();a&&d.redraw(b)});c.isRemoving=!1},update:function(a,b){var c=this,d=this.chart,e=this.userOptions,f=this.type,g=H[f].prototype,h=["group","markerGroup","dataLabelsGroup"],i;q(h,function(a){h[a]=c[a];delete c[a]}); +a=w(e,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1);for(i in g)g.hasOwnProperty(i)&&(this[i]=u);r(this,H[a.type||f].prototype);q(h,function(a){c[a]=h[a]});this.init(d,a);d.linkSeries();p(b,!0)&&d.redraw(!1)}});r(na.prototype,{update:function(a,b){var c=this.chart,a=c.options[this.coll][this.options.index]=w(this.userOptions,a);this.destroy(!0);this._addedPlotLB=u;this.init(c,r(a,{events:u}));c.isDirtyBox=!0;p(b,!0)&&c.redraw()},remove:function(a){for(var b= +this.chart,c=this.coll,d=this.series,e=d.length;e--;)d[e]&&d[e].remove(!1);la(b.axes,this);la(b[c],this);b.options[c].splice(this.options.index,1);q(b[c],function(a,b){a.options.index=b});this.destroy();b.isDirtyBox=!0;p(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}});ia=ma(O);H.line=ia;ca.area=w(T,{threshold:0});var qa=ma(O,{type:"area",getSegments:function(){var a=this,b=[],c=[],d=[],e=this.xAxis,f=this.yAxis,g=f.stacks[this.stackKey], +h={},i,j,k=this.points,l=this.options.connectNulls,n,m;if(this.options.stacking&&!this.cropped){for(n=0;n<k.length;n++)h[k[n].x]=k[n];for(m in g)g[m].total!==null&&d.push(+m);d.sort(function(a,b){return a-b});q(d,function(b){var d=0,k;if(!l||h[b]&&h[b].y!==null)if(h[b])c.push(h[b]);else{for(n=a.index;n<=f.series.length;n++)if(k=g[b].points[n+","+b]){d=k[1];break}i=e.translate(b);j=f.toPixels(d,!0);c.push({y:null,plotX:i,clientX:i,plotY:j,yBottom:j,onMouseOver:sa})}});c.length&&b.push(c)}else O.prototype.getSegments.call(this), +b=this.segments;this.segments=b},getSegmentPath:function(a){var b=O.prototype.getSegmentPath.call(this,a),c=[].concat(b),d,e=this.options;d=b.length;var f=this.yAxis.getThreshold(e.threshold),g;d===3&&c.push("L",b[1],b[2]);if(e.stacking&&!this.closedStacks)for(d=a.length-1;d>=0;d--)g=p(a[d].yBottom,f),d<a.length-1&&e.step&&c.push(a[d+1].plotX,g),c.push(a[d].plotX,g);else this.closeSegment(c,a,f);this.areaPath=this.areaPath.concat(c);return b},closeSegment:function(a,b,c){a.push("L",b[b.length-1].plotX, +c,"L",b[0].plotX,c)},drawGraph:function(){this.areaPath=[];O.prototype.drawGraph.apply(this);var a=this,b=this.areaPath,c=this.options,d=c.negativeColor,e=c.negativeFillColor,f=[["area",this.color,c.fillColor]];(d||e)&&f.push(["areaNeg",d,e]);q(f,function(d){var e=d[0],f=a[e];f?f.animate({d:b}):a[e]=a.chart.renderer.path(b).attr({fill:p(d[2],ya(d[1]).setOpacity(p(c.fillOpacity,0.75)).get()),zIndex:0}).add(a.group)})},drawLegendSymbol:M.drawRectangle});H.area=qa;ca.spline=w(T);ia=ma(O,{type:"spline", +getPointSpline:function(a,b,c){var d=b.plotX,e=b.plotY,f=a[c-1],g=a[c+1],h,i,j,k;if(f&&g){a=f.plotY;j=g.plotX;var g=g.plotY,l;h=(1.5*d+f.plotX)/2.5;i=(1.5*e+a)/2.5;j=(1.5*d+j)/2.5;k=(1.5*e+g)/2.5;l=(k-i)*(j-d)/(j-h)+e-k;i+=l;k+=l;i>a&&i>e?(i=t(a,e),k=2*e-i):i<a&&i<e&&(i=L(a,e),k=2*e-i);k>g&&k>e?(k=t(g,e),i=2*e-k):k<g&&k<e&&(k=L(g,e),i=2*e-k);b.rightContX=j;b.rightContY=k}c?(b=["C",f.rightContX||f.plotX,f.rightContY||f.plotY,h||d,i||e,d,e],f.rightContX=f.rightContY=null):b=["M",d,e];return b}});H.spline= +ia;ca.areaspline=w(ca.area);qa=qa.prototype;ia=ma(ia,{type:"areaspline",closedStacks:!0,getSegmentPath:qa.getSegmentPath,closeSegment:qa.closeSegment,drawGraph:qa.drawGraph,drawLegendSymbol:M.drawRectangle});H.areaspline=ia;ca.column=w(T,{borderColor:"#FFFFFF",borderRadius:0,groupPadding:0.2,marker:null,pointPadding:0.1,minPointLength:0,cropThreshold:50,pointRange:null,states:{hover:{brightness:0.1,shadow:!1,halo:!1},select:{color:"#C0C0C0",borderColor:"#000000",shadow:!1}},dataLabels:{align:null, +verticalAlign:null,y:null},stickyTracking:!1,tooltip:{distance:6},threshold:0});ia=ma(O,{type:"column",pointAttrToOptions:{stroke:"borderColor",fill:"color",r:"borderRadius"},cropShoulder:0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){O.prototype.init.apply(this,arguments);var a=this,b=a.chart;b.hasRendered&&q(b.series,function(b){if(b.type===a.type)b.isDirty=!0})},getColumnMetrics:function(){var a=this,b=a.options,c=a.xAxis,d=a.yAxis,e=c.reversed,f,g={},h,i=0;b.grouping=== +!1?i=1:q(a.chart.series,function(b){var c=b.options,e=b.yAxis;if(b.type===a.type&&b.visible&&d.len===e.len&&d.pos===e.pos)c.stacking?(f=b.stackKey,g[f]===u&&(g[f]=i++),h=g[f]):c.grouping!==!1&&(h=i++),b.columnIndex=h});var c=L(Q(c.transA)*(c.ordinalSlope||b.pointRange||c.closestPointRange||c.tickInterval||1),c.len),j=c*b.groupPadding,k=(c-2*j)/i,l=b.pointWidth,b=s(l)?(k-l)/2:k*b.pointPadding,l=p(l,k-2*b);return a.columnMetrics={width:l,offset:b+(j+((e?i-(a.columnIndex||0):a.columnIndex)||0)*k-c/2)* +(e?-1:1)}},translate:function(){var a=this,b=a.chart,c=a.options,d=a.borderWidth=p(c.borderWidth,a.activePointCount>0.5*a.xAxis.len?0:1),e=a.yAxis,f=a.translatedThreshold=e.getThreshold(c.threshold),g=p(c.minPointLength,5),h=a.getColumnMetrics(),i=h.width,j=a.barW=t(i,1+2*d),k=a.pointXOffset=h.offset,l=-(d%2?0.5:0),n=d%2?0.5:1;b.renderer.isVML&&b.inverted&&(n+=1);c.pointPadding&&(j=La(j));O.prototype.translate.apply(a);q(a.points,function(c){var d=p(c.yBottom,f),h=L(t(-999-d,c.plotY),e.len+999+d), +q=c.plotX+k,r=j,s=L(h,d),u;u=t(h,d)-s;Q(u)<g&&g&&(u=g,s=v(Q(s-f)>g?d-g:f-(e.translate(c.y,0,1,0,1)<=f?g:0)));c.barX=q;c.pointWidth=i;c.tooltipPos=b.inverted?[e.len-h,a.xAxis.len-q-r/2]:[q+r/2,h+e.pos-b.plotTop];r=v(q+r)+l;q=v(q)+l;r-=q;d=Q(s)<0.5;u=v(s+u)+n;s=v(s)+n;u-=s;d&&(s-=1,u+=1);c.shapeType="rect";c.shapeArgs={x:q,y:s,width:r,height:u}})},getSymbol:sa,drawLegendSymbol:M.drawRectangle,drawGraph:sa,drawPoints:function(){var a=this,b=this.chart,c=a.options,d=b.renderer,e=c.animationLimit||250, +f,g;q(a.points,function(h){var i=h.plotY,j=h.graphic;if(i!==u&&!isNaN(i)&&h.y!==null)f=h.shapeArgs,i=s(a.borderWidth)?{"stroke-width":a.borderWidth}:{},g=h.pointAttr[h.selected?"select":""]||a.pointAttr[""],j?(bb(j),j.attr(i)[b.pointCount<e?"animate":"attr"](w(f))):h.graphic=d[h.shapeType](f).attr(g).attr(i).add(a.group).shadow(c.shadow,null,c.stacking&&!c.borderRadius);else if(j)h.graphic=j.destroy()})},animate:function(a){var b=this.yAxis,c=this.options,d=this.chart.inverted,e={};if(ba)a?(e.scaleY= +0.001,a=L(b.pos+b.len,t(b.pos,b.toPixels(c.threshold))),d?e.translateX=a-b.len:e.translateY=a,this.group.attr(e)):(e.scaleY=1,e[d?"translateX":"translateY"]=b.pos,this.group.animate(e,this.options.animation),this.animate=null)},remove:function(){var a=this,b=a.chart;b.hasRendered&&q(b.series,function(b){if(b.type===a.type)b.isDirty=!0});O.prototype.remove.apply(a,arguments)}});H.column=ia;ca.bar=w(ca.column);qa=ma(ia,{type:"bar",inverted:!0});H.bar=qa;ca.scatter=w(T,{lineWidth:0,tooltip:{headerFormat:'<span style="color:{series.color}">●</span> <span style="font-size: 10px;"> {series.name}</span><br/>', +pointFormat:"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>"},stickyTracking:!1});qa=ma(O,{type:"scatter",sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["markerGroup","dataLabelsGroup"],takeOrdinalPosition:!1,singularTooltips:!0,drawGraph:function(){this.options.lineWidth&&O.prototype.drawGraph.call(this)}});H.scatter=qa;ca.pie=w(T,{borderColor:"#FFFFFF",borderWidth:1,center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return this.point.name}}, +ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,states:{hover:{brightness:0.1,shadow:!1}},stickyTracking:!1,tooltip:{followPointer:!0}});T={type:"pie",isCartesian:!1,pointClass:ma(Fa,{init:function(){Fa.prototype.init.apply(this,arguments);var a=this,b;if(a.y<0)a.y=null;r(a,{visible:a.visible!==!1,name:p(a.name,"Slice")});b=function(b){a.slice(b.type==="select")};N(a,"select",b);N(a,"unselect",b);return a},setVisible:function(a){var b=this,c=b.series, +d=c.chart;b.visible=b.options.visible=a=a===u?!b.visible:a;c.options.data[Ma(b,c.data)]=b.options;q(["graphic","dataLabel","connector","shadowGroup"],function(c){if(b[c])b[c][a?"show":"hide"](!0)});b.legendItem&&d.legend.colorizeItem(b,a);if(!c.isDirty&&c.options.ignoreHiddenPoint)c.isDirty=!0,d.redraw()},slice:function(a,b,c){var d=this.series;Ra(c,d.chart);p(b,!0);this.sliced=this.options.sliced=a=s(a)?a:!this.sliced;d.options.data[Ma(this,d.data)]=this.options;a=a?this.slicedTranslation:{translateX:0, +translateY:0};this.graphic.animate(a);this.shadowGroup&&this.shadowGroup.animate(a)},haloPath:function(a){var b=this.shapeArgs,c=this.series.chart;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.plotLeft+b.x,c.plotTop+b.y,b.r+a,b.r+a,{innerR:this.shapeArgs.r,start:b.start,end:b.end})}}),requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},singularTooltips:!0, +getColor:sa,animate:function(a){var b=this,c=b.points,d=b.startAngleRad;if(!a)q(c,function(a){var c=a.graphic,a=a.shapeArgs;c&&(c.attr({r:b.center[3]/2,start:d,end:d}),c.animate({r:a.r,start:a.start,end:a.end},b.options.animation))}),b.animate=null},setData:function(a,b,c,d){O.prototype.setData.call(this,a,!1,c,d);this.processData();this.generatePoints();p(b,!0)&&this.chart.redraw(c)},generatePoints:function(){var a,b=0,c,d,e,f=this.options.ignoreHiddenPoint;O.prototype.generatePoints.call(this); +c=this.points;d=c.length;for(a=0;a<d;a++)e=c[a],b+=f&&!e.visible?0:e.y;this.total=b;for(a=0;a<d;a++)e=c[a],e.percentage=b>0?e.y/b*100:0,e.total=b},translate:function(a){this.generatePoints();var b=0,c=this.options,d=c.slicedOffset,e=d+c.borderWidth,f,g,h,i=c.startAngle||0,j=this.startAngleRad=oa/180*(i-90),i=(this.endAngleRad=oa/180*(p(c.endAngle,i+360)-90))-j,k=this.points,l=c.dataLabels.distance,c=c.ignoreHiddenPoint,n,m=k.length,o;if(!a)this.center=a=this.getCenter();this.getX=function(b,c){h= +V.asin(L((b-a[1])/(a[2]/2+l),1));return a[0]+(c?-1:1)*aa(h)*(a[2]/2+l)};for(n=0;n<m;n++){o=k[n];f=j+b*i;if(!c||o.visible)b+=o.percentage/100;g=j+b*i;o.shapeType="arc";o.shapeArgs={x:a[0],y:a[1],r:a[2]/2,innerR:a[3]/2,start:v(f*1E3)/1E3,end:v(g*1E3)/1E3};h=(g+f)/2;h>1.5*oa?h-=2*oa:h<-oa/2&&(h+=2*oa);o.slicedTranslation={translateX:v(aa(h)*d),translateY:v(fa(h)*d)};f=aa(h)*a[2]/2;g=fa(h)*a[2]/2;o.tooltipPos=[a[0]+f*0.7,a[1]+g*0.7];o.half=h<-oa/2||h>oa/2?1:0;o.angle=h;e=L(e,l/2);o.labelPos=[a[0]+f+aa(h)* +l,a[1]+g+fa(h)*l,a[0]+f+aa(h)*e,a[1]+g+fa(h)*e,a[0]+f,a[1]+g,l<0?"center":o.half?"right":"left",h]}},drawGraph:null,drawPoints:function(){var a=this,b=a.chart.renderer,c,d,e=a.options.shadow,f,g;if(e&&!a.shadowGroup)a.shadowGroup=b.g("shadow").add(a.group);q(a.points,function(h){d=h.graphic;g=h.shapeArgs;f=h.shadowGroup;if(e&&!f)f=h.shadowGroup=b.g("shadow").add(a.shadowGroup);c=h.sliced?h.slicedTranslation:{translateX:0,translateY:0};f&&f.attr(c);d?d.animate(r(g,c)):h.graphic=d=b[h.shapeType](g).setRadialReference(a.center).attr(h.pointAttr[h.selected? +"select":""]).attr({"stroke-linejoin":"round"}).attr(c).add(a.group).shadow(e,f);h.visible!==void 0&&h.setVisible(h.visible)})},sortByAngle:function(a,b){a.sort(function(a,d){return a.angle!==void 0&&(d.angle-a.angle)*b})},drawLegendSymbol:M.drawRectangle,getCenter:Z.getCenter,getSymbol:sa};T=ma(O,T);H.pie=T;O.prototype.drawDataLabels=function(){var a=this,b=a.options,c=b.cursor,d=b.dataLabels,e=a.points,f,g,h=a.hasRendered||0,i,j;if(d.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(d), +j=a.plotGroup("dataLabelsGroup","data-labels",d.defer?"hidden":"visible",d.zIndex||6),p(d.defer,!0)&&(j.attr({opacity:+h}),h||N(a,"afterAnimate",function(){a.visible&&j.show();j[b.animation?"animate":"attr"]({opacity:1},{duration:200})})),g=d,q(e,function(b){var e,h=b.dataLabel,m,o,q=b.connector,t=!0;f=b.options&&b.options.dataLabels;e=p(f&&f.enabled,g.enabled);if(h&&!e)b.dataLabel=h.destroy();else if(e){d=w(g,f);e=d.rotation;m=b.getLabelConfig();i=d.format?Ja(d.format,m):d.formatter.call(m,d);d.style.color= +p(d.color,d.style.color,a.color,"black");if(h)if(s(i))h.attr({text:i}),t=!1;else{if(b.dataLabel=h=h.destroy(),q)b.connector=q.destroy()}else if(s(i)){h={fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":d.borderWidth,r:d.borderRadius||0,rotation:e,padding:d.padding,zIndex:1};for(o in h)h[o]===u&&delete h[o];h=b.dataLabel=a.chart.renderer[e?"text":"label"](i,0,-999,null,null,null,d.useHTML).attr(h).css(r(d.style,c&&{cursor:c})).add(j).shadow(d.shadow)}h&&a.alignDataLabel(b,h,d,null,t)}})}; +O.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=p(a.plotX,-999),i=p(a.plotY,-999),j=b.getBBox();if(a=this.visible&&(a.series.forceDL||f.isInsidePlot(h,v(i),g)||d&&f.isInsidePlot(h,g?d.x+1:d.y+d.height-1,g)))d=r({x:g?f.plotWidth-i:h,y:v(g?f.plotHeight-h:i),width:0,height:0},d),r(c,{width:j.width,height:j.height}),c.rotation?b[e?"attr":"animate"]({x:d.x+c.x+d.width/2,y:d.y+c.y+d.height/2}).attr({align:c.align}):(b.align(c,null,d),g=b.alignAttr,p(c.overflow,"justify")=== +"justify"?this.justifyDataLabel(b,c,g,j,d,e):p(c.crop,!0)&&(a=f.isInsidePlot(g.x,g.y)&&f.isInsidePlot(g.x+j.width,g.y+j.height)));if(!a)b.attr({y:-999}),b.placed=!1};O.prototype.justifyDataLabel=function(a,b,c,d,e,f){var g=this.chart,h=b.align,i=b.verticalAlign,j,k;j=c.x;if(j<0)h==="right"?b.align="left":b.x=-j,k=!0;j=c.x+d.width;if(j>g.plotWidth)h==="left"?b.align="right":b.x=g.plotWidth-j,k=!0;j=c.y;if(j<0)i==="bottom"?b.verticalAlign="top":b.y=-j,k=!0;j=c.y+d.height;if(j>g.plotHeight)i==="top"? +b.verticalAlign="bottom":b.y=g.plotHeight-j,k=!0;if(k)a.placed=!f,a.align(b,null,e)};if(H.pie)H.pie.prototype.drawDataLabels=function(){var a=this,b=a.data,c,d=a.chart,e=a.options.dataLabels,f=p(e.connectorPadding,10),g=p(e.connectorWidth,1),h=d.plotWidth,i=d.plotHeight,j,k,l=p(e.softConnector,!0),n=e.distance,m=a.center,o=m[2]/2,r=m[1],s=n>0,u,w,x,A=[[],[]],y,B,I,H,z,R=[0,0,0,0],N=function(a,b){return b.y-a.y};if(a.visible&&(e.enabled||a._hasPointLabels)){O.prototype.drawDataLabels.apply(a);q(b, +function(a){a.dataLabel&&a.visible&&A[a.half].push(a)});for(H=2;H--;){var G=[],M=[],F=A[H],K=F.length,E;if(K){a.sortByAngle(F,H-0.5);for(z=b=0;!b&&F[z];)b=F[z]&&F[z].dataLabel&&(F[z].dataLabel.getBBox().height||21),z++;if(n>0){w=L(r+o+n,d.plotHeight);for(z=t(0,r-o-n);z<=w;z+=b)G.push(z);w=G.length;if(K>w){c=[].concat(F);c.sort(N);for(z=K;z--;)c[z].rank=z;for(z=K;z--;)F[z].rank>=w&&F.splice(z,1);K=F.length}for(z=0;z<K;z++){c=F[z];x=c.labelPos;c=9999;var S,P;for(P=0;P<w;P++)S=Q(G[P]-x[1]),S<c&&(c=S, +E=P);if(E<z&&G[z]!==null)E=z;else for(w<K-z+E&&G[z]!==null&&(E=w-K+z);G[E]===null;)E++;M.push({i:E,y:G[E]});G[E]=null}M.sort(N)}for(z=0;z<K;z++){c=F[z];x=c.labelPos;u=c.dataLabel;I=c.visible===!1?"hidden":"visible";c=x[1];if(n>0){if(w=M.pop(),E=w.i,B=w.y,c>B&&G[E+1]!==null||c<B&&G[E-1]!==null)B=L(t(0,c),d.plotHeight)}else B=c;y=e.justify?m[0]+(H?-1:1)*(o+n):a.getX(B===r-o-n||B===r+o+n?c:B,H);u._attr={visibility:I,align:x[6]};u._pos={x:y+e.x+({left:f,right:-f}[x[6]]||0),y:B+e.y-10};u.connX=y;u.connY= +B;if(this.options.size===null)w=u.width,y-w<f?R[3]=t(v(w-y+f),R[3]):y+w>h-f&&(R[1]=t(v(y+w-h+f),R[1])),B-b/2<0?R[0]=t(v(-B+b/2),R[0]):B+b/2>i&&(R[2]=t(v(B+b/2-i),R[2]))}}}if(Ca(R)===0||this.verifyDataLabelOverflow(R))this.placeDataLabels(),s&&g&&q(this.points,function(b){j=b.connector;x=b.labelPos;if((u=b.dataLabel)&&u._pos)I=u._attr.visibility,y=u.connX,B=u.connY,k=l?["M",y+(x[6]==="left"?5:-5),B,"C",y,B,2*x[2]-x[4],2*x[3]-x[5],x[2],x[3],"L",x[4],x[5]]:["M",y+(x[6]==="left"?5:-5),B,"L",x[2],x[3], +"L",x[4],x[5]],j?(j.animate({d:k}),j.attr("visibility",I)):b.connector=j=a.chart.renderer.path(k).attr({"stroke-width":g,stroke:e.connectorColor||b.color||"#606060",visibility:I}).add(a.dataLabelsGroup);else if(j)b.connector=j.destroy()})}},H.pie.prototype.placeDataLabels=function(){q(this.points,function(a){var a=a.dataLabel,b;if(a)(b=a._pos)?(a.attr(a._attr),a[a.moved?"animate":"attr"](b),a.moved=!0):a&&a.attr({y:-999})})},H.pie.prototype.alignDataLabel=sa,H.pie.prototype.verifyDataLabelOverflow= +function(a){var b=this.center,c=this.options,d=c.center,e=c=c.minSize||80,f;d[0]!==null?e=t(b[2]-t(a[1],a[3]),c):(e=t(b[2]-a[1]-a[3],c),b[0]+=(a[3]-a[1])/2);d[1]!==null?e=t(L(e,b[2]-t(a[0],a[2])),c):(e=t(L(e,b[2]-a[0]-a[2]),c),b[1]+=(a[0]-a[2])/2);e<b[2]?(b[2]=e,this.translate(b),q(this.points,function(a){if(a.dataLabel)a.dataLabel._pos=null}),this.drawDataLabels&&this.drawDataLabels()):f=!0;return f};if(H.column)H.column.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted, +h=a.dlBox||a.shapeArgs,i=a.below||a.plotY>p(this.translatedThreshold,f.plotSizeY),j=p(c.inside,!!this.options.stacking);if(h&&(d=w(h),g&&(d={x:f.plotWidth-d.y-d.height,y:f.plotHeight-d.x-d.width,width:d.height,height:d.width}),!j))g?(d.x+=i?0:d.width,d.width=0):(d.y+=i?d.height:0,d.height=0);c.align=p(c.align,!g||j?"center":i?"right":"left");c.verticalAlign=p(c.verticalAlign,g||j?"middle":i?"top":"bottom");O.prototype.alignDataLabel.call(this,a,b,c,d,e)};T=K.TrackerMixin={drawTrackerPoint:function(){var a= +this,b=a.chart,c=b.pointer,d=a.options.cursor,e=d&&{cursor:d},f=function(c){var d=c.target,e;if(b.hoverSeries!==a)a.onMouseOver();for(;d&&!e;)e=d.point,d=d.parentNode;if(e!==u&&e!==b.hoverPoint)e.onMouseOver(c)};q(a.points,function(a){if(a.graphic)a.graphic.element.point=a;if(a.dataLabel)a.dataLabel.element.point=a});if(!a._hasTracking)q(a.trackerGroups,function(b){if(a[b]&&(a[b].addClass("highcharts-tracker").on("mouseover",f).on("mouseout",function(a){c.onTrackerMouseOut(a)}).css(e),$a))a[b].on("touchstart", +f)}),a._hasTracking=!0},drawTrackerGraph:function(){var a=this,b=a.options,c=b.trackByArea,d=[].concat(c?a.areaPath:a.graphPath),e=d.length,f=a.chart,g=f.pointer,h=f.renderer,i=f.options.tooltip.snap,j=a.tracker,k=b.cursor,l=k&&{cursor:k},k=a.singlePoints,n,m=function(){if(f.hoverSeries!==a)a.onMouseOver()},o="rgba(192,192,192,"+(ba?1.0E-4:0.002)+")";if(e&&!c)for(n=e+1;n--;)d[n]==="M"&&d.splice(n+1,0,d[n+1]-i,d[n+2],"L"),(n&&d[n]==="M"||n===e)&&d.splice(n,0,"L",d[n-2]+i,d[n-1]);for(n=0;n<k.length;n++)e= +k[n],d.push("M",e.plotX-i,e.plotY,"L",e.plotX+i,e.plotY);j?j.attr({d:d}):(a.tracker=h.path(d).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:o,fill:c?o:P,"stroke-width":b.lineWidth+(c?0:2*i),zIndex:2}).add(a.group),q([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",m).on("mouseout",function(a){g.onTrackerMouseOut(a)}).css(l);if($a)a.on("touchstart",m)}))}};if(H.column)ia.prototype.drawTracker=T.drawTrackerPoint;if(H.pie)H.pie.prototype.drawTracker= +T.drawTrackerPoint;if(H.scatter)qa.prototype.drawTracker=T.drawTrackerPoint;r(lb.prototype,{setItemEvents:function(a,b,c,d,e){var f=this;(c?b:a.legendGroup).on("mouseover",function(){a.setState("hover");b.css(f.options.itemHoverStyle)}).on("mouseout",function(){b.css(a.visible?d:e);a.setState()}).on("click",function(b){var c=function(){a.setVisible()},b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):I(a,"legendItemClick",b,c)})},createCheckboxForItem:function(a){a.checkbox= +$("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},this.options.itemCheckboxStyle,this.chart.container);N(a.checkbox,"click",function(b){I(a,"checkboxClick",{checked:b.target.checked},function(){a.select()})})}});E.legend.itemStyle.cursor="pointer";r(Ya.prototype,{showResetZoom:function(){var a=this,b=E.lang,c=a.options.chart.resetZoomButton,d=c.theme,e=d.states,f=c.relativeTo==="chart"?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()}, +d,e&&e.hover).attr({align:c.position.align,title:b.resetZoomTitle}).add().align(c.position,!1,f)},zoomOut:function(){var a=this;I(a,"selection",{resetSelection:!0},function(){a.zoom()})},zoom:function(a){var b,c=this.pointer,d=!1,e;!a||a.resetSelection?q(this.axes,function(a){b=a.zoom()}):q(a.xAxis.concat(a.yAxis),function(a){var e=a.axis,h=e.isXAxis;if(c[h?"zoomX":"zoomY"]||c[h?"pinchX":"pinchY"])b=e.zoom(a.min,a.max),e.displayBtn&&(d=!0)});e=this.resetZoomButton;if(d&&!e)this.showResetZoom();else if(!d&& +da(e))this.resetZoomButton=e.destroy();b&&this.redraw(p(this.options.chart.animation,a&&a.animation,this.pointCount<100))},pan:function(a,b){var c=this,d=c.hoverPoints,e;d&&q(d,function(a){a.setState()});q(b==="xy"?[1,0]:[1],function(b){var d=a[b?"chartX":"chartY"],h=c[b?"xAxis":"yAxis"][0],i=c[b?"mouseDownX":"mouseDownY"],j=(h.pointRange||0)/2,k=h.getExtremes(),l=h.toValue(i-d,!0)+j,i=h.toValue(i+c[b?"plotWidth":"plotHeight"]-d,!0)-j;h.series.length&&l>L(k.dataMin,k.min)&&i<t(k.dataMax,k.max)&&(h.setExtremes(l, +i,!1,!1,{trigger:"pan"}),e=!0);c[b?"mouseDownX":"mouseDownY"]=d});e&&c.redraw(!1);B(c.container,{cursor:"move"})}});r(Fa.prototype,{select:function(a,b){var c=this,d=c.series,e=d.chart,a=p(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=c.options.selected=a;d.options.data[Ma(c,d.data)]=c.options;c.setState(a&&"select");b||q(e.getSelectedPoints(),function(a){if(a.selected&&a!==c)a.selected=a.options.selected=!1,d.options.data[Ma(a,d.data)]=a.options,a.setState(""), +a.firePointEvent("unselect")})})},onMouseOver:function(a){var b=this.series,c=b.chart,d=c.tooltip,e=c.hoverPoint;if(e&&e!==this)e.onMouseOut();this.firePointEvent("mouseOver");d&&(!d.shared||b.noSharedTooltip)&&d.refresh(this,a);this.setState("hover");c.hoverPoint=this},onMouseOut:function(){var a=this.series.chart,b=a.hoverPoints;this.firePointEvent("mouseOut");if(!b||Ma(this,b)===-1)this.setState(),a.hoverPoint=null},importEvents:function(){if(!this.hasImportedEvents){var a=w(this.series.options.point, +this.options).events,b;this.events=a;for(b in a)N(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,b){var c=this.plotX,d=this.plotY,e=this.series,f=e.options.states,g=ca[e.type].marker&&e.options.marker,h=g&&!g.enabled,i=g&&g.states[a],j=i&&i.enabled===!1,k=e.stateMarkerGraphic,l=this.marker||{},n=e.chart,m=e.halo,o,a=a||"";o=this.pointAttr[a]||e.pointAttr[a];if(!(a===this.state&&!b||this.selected&&a!=="select"||f[a]&&f[a].enabled===!1||a&&(j||h&&i.enabled===!1)||a&&l.states&&l.states[a]&& +l.states[a].enabled===!1)){if(this.graphic)g=g&&this.graphic.symbolName&&o.r,this.graphic.attr(w(o,g?{x:c-g,y:d-g,width:2*g,height:2*g}:{})),k&&k.hide();else{if(a&&i)if(g=i.radius,l=l.symbol||e.symbol,k&&k.currentSymbol!==l&&(k=k.destroy()),k)k[b?"animate":"attr"]({x:c-g,y:d-g});else if(l)e.stateMarkerGraphic=k=n.renderer.symbol(l,c-g,d-g,2*g,2*g).attr(o).add(e.markerGroup),k.currentSymbol=l;if(k)k[a&&n.isInsidePlot(c,d,n.inverted)?"show":"hide"]()}if((c=f[a]&&f[a].halo)&&c.size){if(!m)e.halo=m=n.renderer.path().add(e.seriesGroup); +m.attr(r({fill:ya(this.color||e.color).setOpacity(c.opacity).get()},c.attributes))[b?"animate":"attr"]({d:this.haloPath(c.size)})}else m&&m.attr({d:[]});this.state=a}},haloPath:function(a){var b=this.series,c=b.chart,d=b.getPlotBox(),e=c.inverted;return c.renderer.symbols.circle(d.translateX+(e?b.yAxis.len-this.plotY:this.plotX)-a,d.translateY+(e?b.xAxis.len-this.plotX:this.plotY)-a,a*2,a*2)}});r(O.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&& +I(this,"mouseOver");this.setState("hover");a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;if(d)d.onMouseOut();this&&a.events.mouseOut&&I(this,"mouseOut");c&&!a.stickyTracking&&(!c.shared||this.noSharedTooltip)&&c.hide();this.setState();b.hoverSeries=null},setState:function(a){var b=this.options,c=this.graph,d=this.graphNeg,e=b.states,b=b.lineWidth,a=a||"";if(this.state!==a)this.state=a,e[a]&&e[a].enabled===!1||(a&&(b=e[a].lineWidth||b+(e[a].lineWidthPlus|| +0)),c&&!c.dashstyle&&(a={"stroke-width":b},c.attr(a),d&&d.attr(a)))},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,f,g=d.options.chart.ignoreHiddenSeries,h=c.visible;f=(c.visible=a=c.userOptions.visible=a===u?!h:a)?"show":"hide";q(["group","dataLabelsGroup","markerGroup","tracker"],function(a){if(c[a])c[a][f]()});if(d.hoverSeries===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&q(d.series,function(a){if(a.options.stacking&&a.visible)a.isDirty=!0});q(c.linkedSeries, +function(b){b.setVisible(a,!1)});if(g)d.isDirtyBox=!0;b!==!1&&d.redraw();I(c,f)},setTooltipPoints:function(a){var b=[],c,d,e=this.xAxis,f=e&&e.getExtremes(),g=e?e.tooltipLen||e.len:this.chart.plotSizeX,h,i,j=[];if(!(this.options.enableMouseTracking===!1||this.singularTooltips)){if(a)this.tooltipPoints=null;q(this.segments||this.points,function(a){b=b.concat(a)});e&&e.reversed&&(b=b.reverse());this.orderTooltipPoints&&this.orderTooltipPoints(b);a=b.length;for(i=0;i<a;i++)if(e=b[i],c=e.x,c>=f.min&& +c<=f.max){h=b[i+1];c=d===u?0:d+1;for(d=b[i+1]?L(t(0,U((e.clientX+(h?h.wrappedClientX||h.clientX:g))/2)),g):g;c>=0&&c<=d;)j[c++]=e}this.tooltipPoints=j}},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=a===u?!this.selected:a;if(this.checkbox)this.checkbox.checked=a;I(this,a?"select":"unselect")},drawTracker:T.drawTrackerGraph});r(K,{Axis:na,Chart:Ya,Color:ya,Point:Fa,Tick:Ta,Renderer:Za,Series:O,SVGElement:S,SVGRenderer:ta,arrayMin:Oa,arrayMax:Ca, +charts:W,dateFormat:cb,format:Ja,pathAnim:vb,getOptions:function(){return E},hasBidiBug:Ob,isTouchDevice:Ib,numberFormat:Ba,seriesTypes:H,setOptions:function(a){E=w(!0,E,a);Bb();return E},addEvent:N,removeEvent:X,createElement:$,discardElement:Qa,css:B,each:q,extend:r,map:Va,merge:w,pick:p,splat:ra,extendClass:ma,pInt:y,wrap:Na,svg:ba,canvas:ga,vml:!ba&&!ga,product:"Highcharts",version:"4.0.4"})})(); +/* + Highcharts JS v4.0.4 (2014-09-02) + + (c) 2009-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(l,C){function K(a,b,c){this.init.call(this,a,b,c)}var P=l.arrayMin,Q=l.arrayMax,s=l.each,F=l.extend,q=l.merge,R=l.map,o=l.pick,x=l.pInt,p=l.getOptions().plotOptions,g=l.seriesTypes,v=l.extendClass,L=l.splat,r=l.wrap,M=l.Axis,y=l.Tick,H=l.Point,S=l.Pointer,T=l.CenteredSeriesMixin,z=l.TrackerMixin,t=l.Series,w=Math,D=w.round,A=w.floor,N=w.max,U=l.Color,u=function(){};F(K.prototype,{init:function(a,b,c){var d=this,e=d.defaultOptions;d.chart=b;if(b.angular)e.background={};d.options=a=q(e,a); +(a=a.background)&&s([].concat(L(a)).reverse(),function(a){var b=a.backgroundColor,a=q(d.defaultBackgroundOptions,a);if(b)a.backgroundColor=b;a.color=a.backgroundColor;c.options.plotBands.unshift(a)})},defaultOptions:{center:["50%","50%"],size:"85%",startAngle:0},defaultBackgroundOptions:{shape:"circle",borderWidth:1,borderColor:"silver",backgroundColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,"#FFF"],[1,"#DDD"]]},from:-Number.MAX_VALUE,innerRadius:0,to:Number.MAX_VALUE,outerRadius:"105%"}}); +var G=M.prototype,y=y.prototype,V={getOffset:u,redraw:function(){this.isDirty=!1},render:function(){this.isDirty=!1},setScale:u,setCategories:u,setTitle:u},O={isRadial:!0,defaultRadialGaugeOptions:{labels:{align:"center",x:0,y:null},minorGridLineWidth:0,minorTickInterval:"auto",minorTickLength:10,minorTickPosition:"inside",minorTickWidth:1,tickLength:10,tickPosition:"inside",tickWidth:2,title:{rotation:0},zIndex:2},defaultRadialXOptions:{gridLineWidth:1,labels:{align:null,distance:15,x:0,y:null}, +maxPadding:0,minPadding:0,showLastLabel:!1,tickLength:0},defaultRadialYOptions:{gridLineInterpolation:"circle",labels:{align:"right",x:-3,y:-2},showLastLabel:!1,title:{x:4,text:null,rotation:90}},setOptions:function(a){a=this.options=q(this.defaultOptions,this.defaultRadialOptions,a);if(!a.plotBands)a.plotBands=[]},getOffset:function(){G.getOffset.call(this);this.chart.axisOffset[this.side]=0;this.center=this.pane.center=T.getCenter.call(this.pane)},getLinePath:function(a,b){var c=this.center,b=o(b, +c[2]/2-this.offset);return this.chart.renderer.symbols.arc(this.left+c[0],this.top+c[1],b,b,{start:this.startAngleRad,end:this.endAngleRad,open:!0,innerR:0})},setAxisTranslation:function(){G.setAxisTranslation.call(this);if(this.center)this.transA=this.isCircular?(this.endAngleRad-this.startAngleRad)/(this.max-this.min||1):this.center[2]/2/(this.max-this.min||1),this.minPixelPadding=this.isXAxis?this.transA*this.minPointOffset:0},beforeSetTickPositions:function(){this.autoConnect&&(this.max+=this.categories&& +1||this.pointRange||this.closestPointRange||0)},setAxisSize:function(){G.setAxisSize.call(this);if(this.isRadial){this.center=this.pane.center=l.CenteredSeriesMixin.getCenter.call(this.pane);if(this.isCircular)this.sector=this.endAngleRad-this.startAngleRad;this.len=this.width=this.height=this.center[2]*o(this.sector,1)/2}},getPosition:function(a,b){return this.postTranslate(this.isCircular?this.translate(a):0,o(this.isCircular?b:this.translate(a),this.center[2]/2)-this.offset)},postTranslate:function(a, +b){var c=this.chart,d=this.center,a=this.startAngleRad+a;return{x:c.plotLeft+d[0]+Math.cos(a)*b,y:c.plotTop+d[1]+Math.sin(a)*b}},getPlotBandPath:function(a,b,c){var d=this.center,e=this.startAngleRad,f=d[2]/2,h=[o(c.outerRadius,"100%"),c.innerRadius,o(c.thickness,10)],j=/%$/,k,m=this.isCircular;this.options.gridLineInterpolation==="polygon"?d=this.getPlotLinePath(a).concat(this.getPlotLinePath(b,!0)):(m||(h[0]=this.translate(a),h[1]=this.translate(b)),h=R(h,function(a){j.test(a)&&(a=x(a,10)*f/100); +return a}),c.shape==="circle"||!m?(a=-Math.PI/2,b=Math.PI*1.5,k=!0):(a=e+this.translate(a),b=e+this.translate(b)),d=this.chart.renderer.symbols.arc(this.left+d[0],this.top+d[1],h[0],h[0],{start:a,end:b,innerR:o(h[1],h[0]-h[2]),open:k}));return d},getPlotLinePath:function(a,b){var c=this,d=c.center,e=c.chart,f=c.getPosition(a),h,j,k;c.isCircular?k=["M",d[0]+e.plotLeft,d[1]+e.plotTop,"L",f.x,f.y]:c.options.gridLineInterpolation==="circle"?(a=c.translate(a))&&(k=c.getLinePath(0,a)):(s(e.xAxis,function(a){a.pane=== +c.pane&&(h=a)}),k=[],a=c.translate(a),d=h.tickPositions,h.autoConnect&&(d=d.concat([d[0]])),b&&(d=[].concat(d).reverse()),s(d,function(f,c){j=h.getPosition(f,a);k.push(c?"L":"M",j.x,j.y)}));return k},getTitlePosition:function(){var a=this.center,b=this.chart,c=this.options.title;return{x:b.plotLeft+a[0]+(c.x||0),y:b.plotTop+a[1]-{high:0.5,middle:0.25,low:0}[c.align]*a[2]+(c.y||0)}}};r(G,"init",function(a,b,c){var i;var d=b.angular,e=b.polar,f=c.isX,h=d&&f,j,k;k=b.options;var m=c.pane||0;if(d){if(F(this, +h?V:O),j=!f)this.defaultRadialOptions=this.defaultRadialGaugeOptions}else if(e)F(this,O),this.defaultRadialOptions=(j=f)?this.defaultRadialXOptions:q(this.defaultYAxisOptions,this.defaultRadialYOptions);a.call(this,b,c);if(!h&&(d||e)){a=this.options;if(!b.panes)b.panes=[];this.pane=(i=b.panes[m]=b.panes[m]||new K(L(k.pane)[m],b,this),m=i);m=m.options;b.inverted=!1;k.chart.zoomType=null;this.startAngleRad=b=(m.startAngle-90)*Math.PI/180;this.endAngleRad=k=(o(m.endAngle,m.startAngle+360)-90)*Math.PI/ +180;this.offset=a.offset||0;if((this.isCircular=j)&&c.max===C&&k-b===2*Math.PI)this.autoConnect=!0}});r(y,"getPosition",function(a,b,c,d,e){var f=this.axis;return f.getPosition?f.getPosition(c):a.call(this,b,c,d,e)});r(y,"getLabelPosition",function(a,b,c,d,e,f,h,j,k){var m=this.axis,i=f.y,n=f.align,g=(m.translate(this.pos)+m.startAngleRad+Math.PI/2)/Math.PI*180%360;m.isRadial?(a=m.getPosition(this.pos,m.center[2]/2+o(f.distance,-25)),f.rotation==="auto"?d.attr({rotation:g}):i===null&&(i=m.chart.renderer.fontMetrics(d.styles.fontSize).b- +d.getBBox().height/2),n===null&&(n=m.isCircular?g>20&&g<160?"left":g>200&&g<340?"right":"center":"center",d.attr({align:n})),a.x+=f.x,a.y+=i):a=a.call(this,b,c,d,e,f,h,j,k);return a});r(y,"getMarkPath",function(a,b,c,d,e,f,h){var j=this.axis;j.isRadial?(a=j.getPosition(this.pos,j.center[2]/2+d),b=["M",b,c,"L",a.x,a.y]):b=a.call(this,b,c,d,e,f,h);return b});p.arearange=q(p.area,{lineWidth:1,marker:null,threshold:null,tooltip:{pointFormat:'<span style="color:{series.color}">●</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'}, +trackByArea:!0,dataLabels:{align:null,verticalAlign:null,xLow:0,xHigh:0,yLow:0,yHigh:0},states:{hover:{halo:!1}}});g.arearange=v(g.area,{type:"arearange",pointArrayMap:["low","high"],toYData:function(a){return[a.low,a.high]},pointValKey:"low",getSegments:function(){var a=this;s(a.points,function(b){if(!a.options.connectNulls&&(b.low===null||b.high===null))b.y=null;else if(b.low===null&&b.high!==null)b.y=b.high});t.prototype.getSegments.call(this)},translate:function(){var a=this.yAxis;g.area.prototype.translate.apply(this); +s(this.points,function(b){var c=b.low,d=b.high,e=b.plotY;d===null&&c===null?b.y=null:c===null?(b.plotLow=b.plotY=null,b.plotHigh=a.translate(d,0,1,0,1)):d===null?(b.plotLow=e,b.plotHigh=null):(b.plotLow=e,b.plotHigh=a.translate(d,0,1,0,1))})},getSegmentPath:function(a){var b,c=[],d=a.length,e=t.prototype.getSegmentPath,f,h;h=this.options;var j=h.step;for(b=HighchartsAdapter.grep(a,function(a){return a.plotLow!==null});d--;)f=a[d],f.plotHigh!==null&&c.push({plotX:f.plotX,plotY:f.plotHigh});a=e.call(this, +b);if(j)j===!0&&(j="left"),h.step={left:"right",center:"center",right:"left"}[j];c=e.call(this,c);h.step=j;h=[].concat(a,c);c[0]="L";this.areaPath=this.areaPath.concat(a,c);return h},drawDataLabels:function(){var a=this.data,b=a.length,c,d=[],e=t.prototype,f=this.options.dataLabels,h=f.align,j,k=this.chart.inverted;if(f.enabled||this._hasPointLabels){for(c=b;c--;)if(j=a[c],j.y=j.high,j._plotY=j.plotY,j.plotY=j.plotHigh,d[c]=j.dataLabel,j.dataLabel=j.dataLabelUpper,j.below=!1,k){if(!h)f.align="left"; +f.x=f.xHigh}else f.y=f.yHigh;e.drawDataLabels&&e.drawDataLabels.apply(this,arguments);for(c=b;c--;)if(j=a[c],j.dataLabelUpper=j.dataLabel,j.dataLabel=d[c],j.y=j.low,j.plotY=j._plotY,j.below=!0,k){if(!h)f.align="right";f.x=f.xLow}else f.y=f.yLow;e.drawDataLabels&&e.drawDataLabels.apply(this,arguments)}f.align=h},alignDataLabel:function(){g.column.prototype.alignDataLabel.apply(this,arguments)},getSymbol:u,drawPoints:u});p.areasplinerange=q(p.arearange);g.areasplinerange=v(g.arearange,{type:"areasplinerange", +getPointSpline:g.spline.prototype.getPointSpline});(function(){var a=g.column.prototype;p.columnrange=q(p.column,p.arearange,{lineWidth:1,pointRange:null});g.columnrange=v(g.arearange,{type:"columnrange",translate:function(){var b=this,c=b.yAxis,d;a.translate.apply(b);s(b.points,function(a){var f=a.shapeArgs,h=b.options.minPointLength,j;a.tooltipPos=null;a.plotHigh=d=c.translate(a.high,0,1,0,1);a.plotLow=a.plotY;j=d;a=a.plotY-d;a<h&&(h-=a,a+=h,j-=h/2);f.height=a;f.y=j})},trackerGroups:["group","dataLabelsGroup"], +drawGraph:u,pointAttrToOptions:a.pointAttrToOptions,drawPoints:a.drawPoints,drawTracker:a.drawTracker,animate:a.animate,getColumnMetrics:a.getColumnMetrics})})();p.gauge=q(p.line,{dataLabels:{enabled:!0,defer:!1,y:15,borderWidth:1,borderColor:"silver",borderRadius:3,crop:!1,style:{fontWeight:"bold"},verticalAlign:"top",zIndex:2},dial:{},pivot:{},tooltip:{headerFormat:""},showInLegend:!1});z={type:"gauge",pointClass:v(H,{setState:function(a){this.state=a}}),angular:!0,drawGraph:u,fixedBox:!0,forceDL:!0, +trackerGroups:["group","dataLabelsGroup"],translate:function(){var a=this.yAxis,b=this.options,c=a.center;this.generatePoints();s(this.points,function(d){var e=q(b.dial,d.dial),f=x(o(e.radius,80))*c[2]/200,h=x(o(e.baseLength,70))*f/100,j=x(o(e.rearLength,10))*f/100,k=e.baseWidth||3,m=e.topWidth||1,i=b.overshoot,n=a.startAngleRad+a.translate(d.y,null,null,null,!0);i&&typeof i==="number"?(i=i/180*Math.PI,n=Math.max(a.startAngleRad-i,Math.min(a.endAngleRad+i,n))):b.wrap===!1&&(n=Math.max(a.startAngleRad, +Math.min(a.endAngleRad,n)));n=n*180/Math.PI;d.shapeType="path";d.shapeArgs={d:e.path||["M",-j,-k/2,"L",h,-k/2,f,-m/2,f,m/2,h,k/2,-j,k/2,"z"],translateX:c[0],translateY:c[1],rotation:n};d.plotX=c[0];d.plotY=c[1]})},drawPoints:function(){var a=this,b=a.yAxis.center,c=a.pivot,d=a.options,e=d.pivot,f=a.chart.renderer;s(a.points,function(c){var b=c.graphic,k=c.shapeArgs,e=k.d,i=q(d.dial,c.dial);b?(b.animate(k),k.d=e):c.graphic=f[c.shapeType](k).attr({stroke:i.borderColor||"none","stroke-width":i.borderWidth|| +0,fill:i.backgroundColor||"black",rotation:k.rotation}).add(a.group)});c?c.animate({translateX:b[0],translateY:b[1]}):a.pivot=f.circle(0,0,o(e.radius,5)).attr({"stroke-width":e.borderWidth||0,stroke:e.borderColor||"silver",fill:e.backgroundColor||"black"}).translate(b[0],b[1]).add(a.group)},animate:function(a){var b=this;if(!a)s(b.points,function(a){var d=a.graphic;d&&(d.attr({rotation:b.yAxis.startAngleRad*180/Math.PI}),d.animate({rotation:a.shapeArgs.rotation},b.options.animation))}),b.animate= +null},render:function(){this.group=this.plotGroup("group","series",this.visible?"visible":"hidden",this.options.zIndex,this.chart.seriesGroup);t.prototype.render.call(this);this.group.clip(this.chart.clipRect)},setData:function(a,b){t.prototype.setData.call(this,a,!1);this.processData();this.generatePoints();o(b,!0)&&this.chart.redraw()},drawTracker:z&&z.drawTrackerPoint};g.gauge=v(g.line,z);p.boxplot=q(p.column,{fillColor:"#FFFFFF",lineWidth:1,medianWidth:2,states:{hover:{brightness:-0.3}},threshold:null, +tooltip:{pointFormat:'<span style="color:{series.color}">●</span> <b> {series.name}</b><br/>Maximum: {point.high}<br/>Upper quartile: {point.q3}<br/>Median: {point.median}<br/>Lower quartile: {point.q1}<br/>Minimum: {point.low}<br/>'},whiskerLength:"50%",whiskerWidth:2});g.boxplot=v(g.column,{type:"boxplot",pointArrayMap:["low","q1","median","q3","high"],toYData:function(a){return[a.low,a.q1,a.median,a.q3,a.high]},pointValKey:"high",pointAttrToOptions:{fill:"fillColor",stroke:"color","stroke-width":"lineWidth"}, +drawDataLabels:u,translate:function(){var a=this.yAxis,b=this.pointArrayMap;g.column.prototype.translate.apply(this);s(this.points,function(c){s(b,function(b){c[b]!==null&&(c[b+"Plot"]=a.translate(c[b],0,1,0,1))})})},drawPoints:function(){var a=this,b=a.points,c=a.options,d=a.chart.renderer,e,f,h,j,k,m,i,n,g,l,p,I,r,q,J,u,v,t,w,x,z,y,E=a.doQuartiles!==!1,B=parseInt(a.options.whiskerLength,10)/100;s(b,function(b){g=b.graphic;z=b.shapeArgs;p={};q={};u={};y=b.color||a.color;if(b.plotY!==C)if(e=b.pointAttr[b.selected? +"selected":""],v=z.width,t=A(z.x),w=t+v,x=D(v/2),f=A(E?b.q1Plot:b.lowPlot),h=A(E?b.q3Plot:b.lowPlot),j=A(b.highPlot),k=A(b.lowPlot),p.stroke=b.stemColor||c.stemColor||y,p["stroke-width"]=o(b.stemWidth,c.stemWidth,c.lineWidth),p.dashstyle=b.stemDashStyle||c.stemDashStyle,q.stroke=b.whiskerColor||c.whiskerColor||y,q["stroke-width"]=o(b.whiskerWidth,c.whiskerWidth,c.lineWidth),u.stroke=b.medianColor||c.medianColor||y,u["stroke-width"]=o(b.medianWidth,c.medianWidth,c.lineWidth),u["stroke-linecap"]="round", +i=p["stroke-width"]%2/2,n=t+x+i,l=["M",n,h,"L",n,j,"M",n,f,"L",n,k],E&&(i=e["stroke-width"]%2/2,n=A(n)+i,f=A(f)+i,h=A(h)+i,t+=i,w+=i,I=["M",t,h,"L",t,f,"L",w,f,"L",w,h,"L",t,h,"z"]),B&&(i=q["stroke-width"]%2/2,j+=i,k+=i,r=["M",n-x*B,j,"L",n+x*B,j,"M",n-x*B,k,"L",n+x*B,k]),i=u["stroke-width"]%2/2,m=D(b.medianPlot)+i,J=["M",t,m,"L",w,m],g)b.stem.animate({d:l}),B&&b.whiskers.animate({d:r}),E&&b.box.animate({d:I}),b.medianShape.animate({d:J});else{b.graphic=g=d.g().add(a.group);b.stem=d.path(l).attr(p).add(g); +if(B)b.whiskers=d.path(r).attr(q).add(g);if(E)b.box=d.path(I).attr(e).add(g);b.medianShape=d.path(J).attr(u).add(g)}})}});p.errorbar=q(p.boxplot,{color:"#000000",grouping:!1,linkedTo:":previous",tooltip:{pointFormat:'<span style="color:{series.color}">●</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'},whiskerWidth:null});g.errorbar=v(g.boxplot,{type:"errorbar",pointArrayMap:["low","high"],toYData:function(a){return[a.low,a.high]},pointValKey:"high",doQuartiles:!1,drawDataLabels:g.arearange? +g.arearange.prototype.drawDataLabels:u,getColumnMetrics:function(){return this.linkedParent&&this.linkedParent.columnMetrics||g.column.prototype.getColumnMetrics.call(this)}});p.waterfall=q(p.column,{lineWidth:1,lineColor:"#333",dashStyle:"dot",borderColor:"#333",states:{hover:{lineWidthPlus:0}}});g.waterfall=v(g.column,{type:"waterfall",upColorProp:"fill",pointArrayMap:["low","y"],pointValKey:"y",init:function(a,b){b.stacking=!0;g.column.prototype.init.call(this,a,b)},translate:function(){var a= +this.yAxis,b,c,d,e,f,h,j,k,m,i;b=this.options.threshold;g.column.prototype.translate.apply(this);k=m=b;d=this.points;for(c=0,b=d.length;c<b;c++){e=d[c];f=e.shapeArgs;h=this.getStack(c);i=h.points[this.index+","+c];if(isNaN(e.y))e.y=this.yData[c];j=N(k,k+e.y)+i[0];f.y=a.translate(j,0,1);e.isSum?(f.y=a.translate(i[1],0,1),f.height=a.translate(i[0],0,1)-f.y):e.isIntermediateSum?(f.y=a.translate(i[1],0,1),f.height=a.translate(m,0,1)-f.y,m=i[1]):k+=h.total;f.height<0&&(f.y+=f.height,f.height*=-1);e.plotY= +f.y=D(f.y)-this.borderWidth%2/2;f.height=N(D(f.height),0.001);e.yBottom=f.y+f.height;f=e.plotY+(e.negative?f.height:0);this.chart.inverted?e.tooltipPos[0]=a.len-f:e.tooltipPos[1]=f}},processData:function(a){var b=this.yData,c=this.points,d,e=b.length,f,h,j,k,m,i;h=f=j=k=this.options.threshold||0;for(i=0;i<e;i++)m=b[i],d=c&&c[i]?c[i]:{},m==="sum"||d.isSum?b[i]=h:m==="intermediateSum"||d.isIntermediateSum?b[i]=f:(h+=m,f+=m),j=Math.min(h,j),k=Math.max(h,k);t.prototype.processData.call(this,a);this.dataMin= +j;this.dataMax=k},toYData:function(a){if(a.isSum)return a.x===0?null:"sum";else if(a.isIntermediateSum)return a.x===0?null:"intermediateSum";return a.y},getAttribs:function(){g.column.prototype.getAttribs.apply(this,arguments);var a=this.options,b=a.states,c=a.upColor||this.color,a=l.Color(c).brighten(0.1).get(),d=q(this.pointAttr),e=this.upColorProp;d[""][e]=c;d.hover[e]=b.hover.upColor||a;d.select[e]=b.select.upColor||c;s(this.points,function(a){if(a.y>0&&!a.color)a.pointAttr=d,a.color=c})},getGraphPath:function(){var a= +this.data,b=a.length,c=D(this.options.lineWidth+this.borderWidth)%2/2,d=[],e,f,h;for(h=1;h<b;h++)f=a[h].shapeArgs,e=a[h-1].shapeArgs,f=["M",e.x+e.width,e.y+c,"L",f.x,e.y+c],a[h-1].y<0&&(f[2]+=e.height,f[5]+=e.height),d=d.concat(f);return d},getExtremes:u,getStack:function(a){var b=this.yAxis.stacks,c=this.stackKey;this.processedYData[a]<this.options.threshold&&(c="-"+c);return b[c][a]},drawGraph:t.prototype.drawGraph});p.bubble=q(p.scatter,{dataLabels:{formatter:function(){return this.point.z},inside:!0, +style:{color:"white",textShadow:"0px 0px 3px black"},verticalAlign:"middle"},marker:{lineColor:null,lineWidth:1},minSize:8,maxSize:"20%",states:{hover:{halo:{size:5}}},tooltip:{pointFormat:"({point.x}, {point.y}), Size: {point.z}"},turboThreshold:0,zThreshold:0});z=v(H,{haloPath:function(){return H.prototype.haloPath.call(this,this.shapeArgs.r+this.series.options.states.hover.halo.size)}});g.bubble=v(g.scatter,{type:"bubble",pointClass:z,pointArrayMap:["y","z"],parallelArrays:["x","y","z"],trackerGroups:["group", +"dataLabelsGroup"],bubblePadding:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor"},applyOpacity:function(a){var b=this.options.marker,c=o(b.fillOpacity,0.5),a=a||b.fillColor||this.color;c!==1&&(a=U(a).setOpacity(c).get("rgba"));return a},convertAttribs:function(){var a=t.prototype.convertAttribs.apply(this,arguments);a.fill=this.applyOpacity(a.fill);return a},getRadii:function(a,b,c,d){var e,f,h,j=this.zData,k=[],m=this.options.sizeBy!=="width";for(f=0,e=j.length;f< +e;f++)h=b-a,h=h>0?(j[f]-a)/(b-a):0.5,m&&h>=0&&(h=Math.sqrt(h)),k.push(w.ceil(c+h*(d-c))/2);this.radii=k},animate:function(a){var b=this.options.animation;if(!a)s(this.points,function(a){var d=a.graphic,a=a.shapeArgs;d&&a&&(d.attr("r",1),d.animate({r:a.r},b))}),this.animate=null},translate:function(){var a,b=this.data,c,d,e=this.radii;g.scatter.prototype.translate.call(this);for(a=b.length;a--;)c=b[a],d=e?e[a]:0,c.negative=c.z<(this.options.zThreshold||0),d>=this.minPxSize/2?(c.shapeType="circle", +c.shapeArgs={x:c.plotX,y:c.plotY,r:d},c.dlBox={x:c.plotX-d,y:c.plotY-d,width:2*d,height:2*d}):c.shapeArgs=c.plotY=c.dlBox=C},drawLegendSymbol:function(a,b){var c=x(a.itemStyle.fontSize)/2;b.legendSymbol=this.chart.renderer.circle(c,a.baseline-c,c).attr({zIndex:3}).add(b.legendGroup);b.legendSymbol.isMarker=!0},drawPoints:g.column.prototype.drawPoints,alignDataLabel:g.column.prototype.alignDataLabel});M.prototype.beforePadding=function(){var a=this,b=this.len,c=this.chart,d=0,e=b,f=this.isXAxis,h= +f?"xData":"yData",j=this.min,k={},m=w.min(c.plotWidth,c.plotHeight),i=Number.MAX_VALUE,n=-Number.MAX_VALUE,g=this.max-j,l=b/g,p=[];this.tickPositions&&(s(this.series,function(b){var h=b.options;if(b.bubblePadding&&(b.visible||!c.options.chart.ignoreHiddenSeries))if(a.allowZoomOutside=!0,p.push(b),f)s(["minSize","maxSize"],function(a){var b=h[a],f=/%$/.test(b),b=x(b);k[a]=f?m*b/100:b}),b.minPxSize=k.minSize,b=b.zData,b.length&&(i=o(h.zMin,w.min(i,w.max(P(b),h.displayNegative===!1?h.zThreshold:-Number.MAX_VALUE))), +n=o(h.zMax,w.max(n,Q(b))))}),s(p,function(a){var b=a[h],c=b.length,m;f&&a.getRadii(i,n,k.minSize,k.maxSize);if(g>0)for(;c--;)typeof b[c]==="number"&&(m=a.radii[c],d=Math.min((b[c]-j)*l-m,d),e=Math.max((b[c]-j)*l+m,e))}),p.length&&g>0&&o(this.options.min,this.userMin)===C&&o(this.options.max,this.userMax)===C&&(e-=b,l*=(b+d-e)/b,this.min+=d/l,this.max+=e/l))};(function(){function a(a,b,c){a.call(this,b,c);if(this.chart.polar)this.closeSegment=function(a){var b=this.xAxis.center;a.push("L",b[0],b[1])}, +this.closedStacks=!0}function b(a,b){var c=this.chart,d=this.options.animation,e=this.group,i=this.markerGroup,n=this.xAxis.center,g=c.plotLeft,l=c.plotTop;if(c.polar){if(c.renderer.isSVG)d===!0&&(d={}),b?(c={translateX:n[0]+g,translateY:n[1]+l,scaleX:0.001,scaleY:0.001},e.attr(c),i&&i.attr(c)):(c={translateX:g,translateY:l,scaleX:1,scaleY:1},e.animate(c,d),i&&i.animate(c,d),this.animate=null)}else a.call(this,b)}var c=t.prototype,d=S.prototype,e;c.toXY=function(a){var b,c=this.chart,d=a.plotX;b= +a.plotY;a.rectPlotX=d;a.rectPlotY=b;d=(d/Math.PI*180+this.xAxis.pane.options.startAngle)%360;d<0&&(d+=360);a.clientX=d;b=this.xAxis.postTranslate(a.plotX,this.yAxis.len-b);a.plotX=a.polarPlotX=b.x-c.plotLeft;a.plotY=a.polarPlotY=b.y-c.plotTop};c.orderTooltipPoints=function(a){if(this.chart.polar&&(a.sort(function(a,b){return a.clientX-b.clientX}),a[0]))a[0].wrappedClientX=a[0].clientX+360,a.push(a[0])};g.area&&r(g.area.prototype,"init",a);g.areaspline&&r(g.areaspline.prototype,"init",a);g.spline&& +r(g.spline.prototype,"getPointSpline",function(a,b,c,d){var e,i,n,g,l,p,o;if(this.chart.polar){e=c.plotX;i=c.plotY;a=b[d-1];n=b[d+1];this.connectEnds&&(a||(a=b[b.length-2]),n||(n=b[1]));if(a&&n)g=a.plotX,l=a.plotY,b=n.plotX,p=n.plotY,g=(1.5*e+g)/2.5,l=(1.5*i+l)/2.5,n=(1.5*e+b)/2.5,o=(1.5*i+p)/2.5,b=Math.sqrt(Math.pow(g-e,2)+Math.pow(l-i,2)),p=Math.sqrt(Math.pow(n-e,2)+Math.pow(o-i,2)),g=Math.atan2(l-i,g-e),l=Math.atan2(o-i,n-e),o=Math.PI/2+(g+l)/2,Math.abs(g-o)>Math.PI/2&&(o-=Math.PI),g=e+Math.cos(o)* +b,l=i+Math.sin(o)*b,n=e+Math.cos(Math.PI+o)*p,o=i+Math.sin(Math.PI+o)*p,c.rightContX=n,c.rightContY=o;d?(c=["C",a.rightContX||a.plotX,a.rightContY||a.plotY,g||e,l||i,e,i],a.rightContX=a.rightContY=null):c=["M",e,i]}else c=a.call(this,b,c,d);return c});r(c,"translate",function(a){a.call(this);if(this.chart.polar&&!this.preventPostTranslate)for(var a=this.points,b=a.length;b--;)this.toXY(a[b])});r(c,"getSegmentPath",function(a,b){var c=this.points;if(this.chart.polar&&this.options.connectEnds!==!1&& +b[b.length-1]===c[c.length-1]&&c[0].y!==null)this.connectEnds=!0,b=[].concat(b,[c[0]]);return a.call(this,b)});r(c,"animate",b);r(c,"setTooltipPoints",function(a,b){this.chart.polar&&F(this.xAxis,{tooltipLen:360});return a.call(this,b)});if(g.column)e=g.column.prototype,r(e,"animate",b),r(e,"translate",function(a){var b=this.xAxis,c=this.yAxis.len,d=b.center,e=b.startAngleRad,i=this.chart.renderer,g,l;this.preventPostTranslate=!0;a.call(this);if(b.isRadial){b=this.points;for(l=b.length;l--;)g=b[l], +a=g.barX+e,g.shapeType="path",g.shapeArgs={d:i.symbols.arc(d[0],d[1],c-g.plotY,null,{start:a,end:a+g.pointWidth,innerR:c-o(g.yBottom,c)})},this.toXY(g),g.tooltipPos=[g.plotX,g.plotY],g.ttBelow=g.plotY>d[1]}}),r(e,"alignDataLabel",function(a,b,d,e,g,i){if(this.chart.polar){a=b.rectPlotX/Math.PI*180;if(e.align===null)e.align=a>20&&a<160?"left":a>200&&a<340?"right":"center";if(e.verticalAlign===null)e.verticalAlign=a<45||a>315?"bottom":a>135&&a<225?"top":"middle";c.alignDataLabel.call(this,b,d,e,g,i)}else a.call(this, +b,d,e,g,i)});r(d,"getIndex",function(a,b){var c,d=this.chart,e;d.polar?(e=d.xAxis[0].center,c=b.chartX-e[0]-d.plotLeft,d=b.chartY-e[1]-d.plotTop,c=180-Math.round(Math.atan2(c,d)/Math.PI*180)):c=a.call(this,b);return c});r(d,"getCoordinates",function(a,b){var c=this.chart,d={xAxis:[],yAxis:[]};c.polar?s(c.axes,function(a){var e=a.isXAxis,f=a.center,g=b.chartX-f[0]-c.plotLeft,f=b.chartY-f[1]-c.plotTop;d[e?"xAxis":"yAxis"].push({axis:a,value:a.translate(e?Math.PI-Math.atan2(g,f):Math.sqrt(Math.pow(g, +2)+Math.pow(f,2)),!0)})}):d=a.call(this,b);return d})})()})(Highcharts); +/* + Highcharts JS v4.0.4 (2014-09-02) + + (c) 2009-2013 Torstein Hønsi + + License: www.highcharts.com/license +*/ +(function(d){function x(f,a,b,c){var e,g,j;b*=t;a*=t;var i=[],h,k,o;b*=-1;h=c.x;k=c.y;o=(c.z===0?1.0E-4:c.z)*(c.vd||25);o=Math.max(500,o);var q=l(b),n=m(b),r=l(a),s=m(a),p,v,u;d.each(f,function(a){p=a.x-h;v=a.y-k;u=a.z||0;e=n*p-q*u;g=-q*r*p-n*r*u+s*v;j=q*s*p+n*s*u+r*v;e=e*((o-j)/o)+h;g=g*((o-j)/o)+k;i.push({x:z(e),y:z(g),z:z(j)})});return i}function A(f){return f!==void 0&&f!==null}function w(f,a,b,c,e,g,d,i){var h=[];return g>e&&g-e>n/2+1.0E-4?(h=h.concat(w(f,a,b,c,e,e+n/2,d,i)),h=h.concat(w(f,a, +b,c,e+n/2,g,d,i))):g<e&&e-g>n/2+1.0E-4?(h=h.concat(w(f,a,b,c,e,e-n/2,d,i)),h=h.concat(w(f,a,b,c,e-n/2,g,d,i))):(h=g-e,["C",f+b*m(e)-b*B*h*l(e)+d,a+c*l(e)+c*B*h*m(e)+i,f+b*m(g)+b*B*h*l(g)+d,a+c*l(g)-c*B*h*m(g)+i,f+b*m(g)+d,a+c*l(g)+i])}function D(f){if(this.chart.is3d()){var a=this.chart.options.plotOptions.column.grouping;a!==void 0&&!a&&this.group.zIndex!==void 0&&this.group.attr({zIndex:this.group.zIndex*10});var b=this.options,c=this.options.states;this.borderWidth=b.borderWidth=b.edgeWidth||1; +d.each(this.data,function(a){if(a.y!==null)a=a.pointAttr,this.borderColor=d.pick(b.edgeColor,a[""].fill),a[""].stroke=this.borderColor,a.hover.stroke=d.pick(c.hover.edgeColor,this.borderColor),a.select.stroke=d.pick(c.select.edgeColor,this.borderColor)})}f.apply(this,[].slice.call(arguments,1))}var n=Math.PI,t=n/180,l=Math.sin,m=Math.cos,z=Math.round,B=4*(Math.sqrt(2)-1)/3/(n/2);d.SVGRenderer.prototype.toLinePath=function(f,a){var b=[];d.each(f,function(a){b.push("L",a.x,a.y)});b[0]="M";a&&b.push("Z"); +return b};d.SVGRenderer.prototype.cuboid=function(f){var a=this.g(),f=this.cuboidPath(f);a.front=this.path(f[0]).attr({zIndex:f[3],"stroke-linejoin":"round"}).add(a);a.top=this.path(f[1]).attr({zIndex:f[4],"stroke-linejoin":"round"}).add(a);a.side=this.path(f[2]).attr({zIndex:f[5],"stroke-linejoin":"round"}).add(a);a.fillSetter=function(a){var c=d.Color(a).brighten(0.1).get(),e=d.Color(a).brighten(-0.1).get();this.front.attr({fill:a});this.top.attr({fill:c});this.side.attr({fill:e});this.color=a; +return this};a.opacitySetter=function(a){this.front.attr({opacity:a});this.top.attr({opacity:a});this.side.attr({opacity:a});return this};a.attr=function(a){a.shapeArgs||A(a.x)?(a=this.renderer.cuboidPath(a.shapeArgs||a),this.front.attr({d:a[0],zIndex:a[3]}),this.top.attr({d:a[1],zIndex:a[4]}),this.side.attr({d:a[2],zIndex:a[5]})):d.SVGElement.prototype.attr.call(this,a);return this};a.animate=function(a,c,e){A(a.x)&&A(a.y)?(a=this.renderer.cuboidPath(a),this.front.attr({zIndex:a[3]}).animate({d:a[0]}, +c,e),this.top.attr({zIndex:a[4]}).animate({d:a[1]},c,e),this.side.attr({zIndex:a[5]}).animate({d:a[2]},c,e)):a.opacity?(this.front.animate(a,c,e),this.top.animate(a,c,e),this.side.animate(a,c,e)):d.SVGElement.prototype.animate.call(this,a,c,e);return this};a.destroy=function(){this.front.destroy();this.top.destroy();this.side.destroy();return null};a.attr({zIndex:-f[3]});return a};d.SVGRenderer.prototype.cuboidPath=function(d){var a=d.x,b=d.y,c=d.z,e=d.height,g=d.width,j=d.depth,i=d.alpha,h=d.beta, +a=[{x:a,y:b,z:c},{x:a+g,y:b,z:c},{x:a+g,y:b+e,z:c},{x:a,y:b+e,z:c},{x:a,y:b+e,z:c+j},{x:a+g,y:b+e,z:c+j},{x:a+g,y:b,z:c+j},{x:a,y:b,z:c+j}],a=x(a,i,h,d.origin),d=["M",a[0].x,a[0].y,"L",a[7].x,a[7].y,"L",a[6].x,a[6].y,"L",a[1].x,a[1].y,"Z"],b=["M",a[3].x,a[3].y,"L",a[2].x,a[2].y,"L",a[5].x,a[5].y,"L",a[4].x,a[4].y,"Z"],c=["M",a[1].x,a[1].y,"L",a[2].x,a[2].y,"L",a[5].x,a[5].y,"L",a[6].x,a[6].y,"Z"],e=["M",a[0].x,a[0].y,"L",a[7].x,a[7].y,"L",a[4].x,a[4].y,"L",a[3].x,a[3].y,"Z"];return[["M",a[0].x,a[0].y, +"L",a[1].x,a[1].y,"L",a[2].x,a[2].y,"L",a[3].x,a[3].y,"Z"],a[7].y<a[1].y?d:a[4].y>a[2].y?b:[],a[6].x>a[1].x?c:a[7].x<a[0].x?e:[],(a[0].z+a[1].z+a[2].z+a[3].z)/4,h>0?(a[0].z+a[7].z+a[6].z+a[1].z)/4:(a[3].z+a[2].z+a[5].z+a[4].z)/4,i>0?(a[1].z+a[2].z+a[5].z+a[6].z)/4:(a[0].z+a[7].z+a[4].z+a[3].z)/4]};d.SVGRenderer.prototype.arc3d=function(f){f.alpha*=t;f.beta*=t;var a=this.g(),b=this.arc3dPath(f),c=a.renderer,e=b.zTop*100;a.shapeArgs=f;a.top=c.path(b.top).attr({zIndex:b.zTop}).add(a);a.side1=c.path(b.side2).attr({zIndex:b.zSide2}); +a.side2=c.path(b.side1).attr({zIndex:b.zSide1});a.inn=c.path(b.inn).attr({zIndex:b.zInn});a.out=c.path(b.out).attr({zIndex:b.zOut});a.fillSetter=function(a){this.color=a;var b=d.Color(a).brighten(-0.1).get();this.side1.attr({fill:b});this.side2.attr({fill:b});this.inn.attr({fill:b});this.out.attr({fill:b});this.top.attr({fill:a});return this};a.translateXSetter=function(a){this.out.attr({translateX:a});this.inn.attr({translateX:a});this.side1.attr({translateX:a});this.side2.attr({translateX:a});this.top.attr({translateX:a})}; +a.translateYSetter=function(a){this.out.attr({translateY:a});this.inn.attr({translateY:a});this.side1.attr({translateY:a});this.side2.attr({translateY:a});this.top.attr({translateY:a})};a.animate=function(a,b,c){A(a.end)||A(a.start)?(this._shapeArgs=this.shapeArgs,d.SVGElement.prototype.animate.call(this,{_args:a},{duration:b,step:function(){var a=arguments[1],b=a.elem,c=b._shapeArgs,e=a.end,a=a.pos,c=d.merge(c,{x:c.x+(e.x-c.x)*a,y:c.y+(e.y-c.y)*a,r:c.r+(e.r-c.r)*a,innerR:c.innerR+(e.innerR-c.innerR)* +a,start:c.start+(e.start-c.start)*a,end:c.end+(e.end-c.end)*a}),e=b.renderer.arc3dPath(c);b.shapeArgs=c;b.top.attr({d:e.top,zIndex:e.zTop});b.inn.attr({d:e.inn,zIndex:e.zInn});b.out.attr({d:e.out,zIndex:e.zOut});b.side1.attr({d:e.side1,zIndex:e.zSide1});b.side2.attr({d:e.side2,zIndex:e.zSide2})}},c)):d.SVGElement.prototype.animate.call(this,a,b,c);return this};a.destroy=function(){this.top.destroy();this.out.destroy();this.inn.destroy();this.side1.destroy();this.side2.destroy();d.SVGElement.prototype.destroy.call(this)}; +a.hide=function(){this.top.hide();this.out.hide();this.inn.hide();this.side1.hide();this.side2.hide()};a.show=function(){this.top.show();this.out.show();this.inn.show();this.side1.show();this.side2.show()};a.zIndex=e;a.attr({zIndex:e});return a};d.SVGRenderer.prototype.arc3dPath=function(d){var a=d.x,b=d.y,c=d.start,e=d.end-1.0E-5,g=d.r,j=d.innerR,i=d.depth,h=d.alpha,k=d.beta,o=m(c),q=l(c),d=m(e),y=l(e),r=g*m(k),s=g*m(h),p=j*m(k);j*=m(h);var v=i*l(k),u=i*l(h),i=["M",a+r*o,b+s*q],i=i.concat(w(a,b, +r,s,c,e,0,0)),i=i.concat(["L",a+p*d,b+j*y]),i=i.concat(w(a,b,p,j,e,c,0,0)),i=i.concat(["Z"]),k=k>0?n/2:0,h=h>0?0:n/2,k=c>-k?c:e>-k?-k:c,t=e<n-h?e:c<n-h?n-h:e,h=["M",a+r*m(k),b+s*l(k)],h=h.concat(w(a,b,r,s,k,t,0,0)),h=h.concat(["L",a+r*m(t)+v,b+s*l(t)+u]),h=h.concat(w(a,b,r,s,t,k,v,u)),h=h.concat(["Z"]),k=["M",a+p*o,b+j*q],k=k.concat(w(a,b,p,j,c,e,0,0)),k=k.concat(["L",a+p*m(e)+v,b+j*l(e)+u]),k=k.concat(w(a,b,p,j,e,c,v,u)),k=k.concat(["Z"]),o=["M",a+r*o,b+s*q,"L",a+r*o+v,b+s*q+u,"L",a+p*o+v,b+j*q+ +u,"L",a+p*o,b+j*q,"Z"],a=["M",a+r*d,b+s*y,"L",a+r*d+v,b+s*y+u,"L",a+p*d+v,b+j*y+u,"L",a+p*d,b+j*y,"Z"],b=l((c+e)/2),c=l(c),e=l(e);return{top:i,zTop:g,out:h,zOut:Math.max(b,c,e)*g,inn:k,zInn:Math.max(b,c,e)*g,side1:o,zSide1:c*g*0.99,side2:a,zSide2:e*g*0.99}};d.Chart.prototype.is3d=function(){return this.options.chart.options3d&&this.options.chart.options3d.enabled};d.wrap(d.Chart.prototype,"isInsidePlot",function(d){return this.is3d()?!0:d.apply(this,[].slice.call(arguments,1))});d.getOptions().chart.options3d= +{enabled:!1,alpha:0,beta:0,depth:100,viewDistance:25,frame:{bottom:{size:1,color:"rgba(255,255,255,0)"},side:{size:1,color:"rgba(255,255,255,0)"},back:{size:1,color:"rgba(255,255,255,0)"}}};d.wrap(d.Chart.prototype,"init",function(f){var a=[].slice.call(arguments,1),b;if(a[0].chart.options3d&&a[0].chart.options3d.enabled)b=a[0].plotOptions||{},b=b.pie||{},b.borderColor=d.pick(b.borderColor,void 0);f.apply(this,a)});d.wrap(d.Chart.prototype,"setChartSize",function(d){d.apply(this,[].slice.call(arguments, +1));if(this.is3d()){var a=this.inverted,b=this.clipBox,c=this.margin;b[a?"y":"x"]=-(c[3]||0);b[a?"x":"y"]=-(c[0]||0);b[a?"height":"width"]=this.chartWidth+(c[3]||0)+(c[1]||0);b[a?"width":"height"]=this.chartHeight+(c[0]||0)+(c[2]||0)}});d.wrap(d.Chart.prototype,"redraw",function(d){if(this.is3d())this.isDirtyBox=!0;d.apply(this,[].slice.call(arguments,1))});d.Chart.prototype.retrieveStacks=function(f,a){var b={},c=1;if(f||!a)return this.series;d.each(this.series,function(a){b[a.options.stack||0]? +b[a.options.stack||0].series.push(a):(b[a.options.stack||0]={series:[a],position:c},c++)});b.totalStacks=c+1;return b};d.wrap(d.Axis.prototype,"init",function(f){var a=arguments;if(a[1].is3d())a[2].tickWidth=d.pick(a[2].tickWidth,0),a[2].gridLineWidth=d.pick(a[2].gridLineWidth,1);f.apply(this,[].slice.call(arguments,1))});d.wrap(d.Axis.prototype,"render",function(d){d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.renderer,c=a.options.chart.options3d,e=c.alpha,g= +c.beta*(a.yAxis[0].opposite?-1:1),j=c.frame,i=j.bottom,h=j.back,j=j.side,k=c.depth,o=this.height,q=this.width,l=this.left,m=this.top,c={x:a.plotLeft+a.plotWidth/2,y:a.plotTop+a.plotHeight/2,z:k,vd:c.viewDistance};if(this.horiz)this.axisLine&&this.axisLine.hide(),g={x:l,y:m+(a.yAxis[0].reversed?-i.size:o),z:0,width:q,height:i.size,depth:k,alpha:e,beta:g,origin:c},this.bottomFrame?this.bottomFrame.animate(g):this.bottomFrame=b.cuboid(g).attr({fill:i.color,zIndex:a.yAxis[0].reversed&&e>0?4:-1}).css({stroke:i.color}).add(); +else{var n={x:l,y:m,z:k+1,width:q,height:o+i.size,depth:h.size,alpha:e,beta:g,origin:c};this.backFrame?this.backFrame.animate(n):this.backFrame=b.cuboid(n).attr({fill:h.color,zIndex:-3}).css({stroke:h.color}).add();this.axisLine&&this.axisLine.hide();a={x:(a.yAxis[0].opposite?q:0)+l-j.size,y:m,z:0,width:j.size,height:o+i.size,depth:k+h.size,alpha:e,beta:g,origin:c};this.sideFrame?this.sideFrame.animate(a):this.sideFrame=b.cuboid(a).attr({fill:j.color,zIndex:-2}).css({stroke:j.color}).add()}}});d.wrap(d.Axis.prototype, +"getPlotLinePath",function(d){var a=d.apply(this,[].slice.call(arguments,1));if(!this.chart.is3d())return a;if(a===null)return a;var b=this.chart,c=b.options.chart.options3d,e=c.depth;c.origin={x:b.plotLeft+b.plotWidth/2,y:b.plotTop+b.plotHeight/2,z:e,vd:c.viewDistance};var a=[{x:a[1],y:a[2],z:this.horiz||this.opposite?e:0},{x:a[1],y:a[2],z:e},{x:a[4],y:a[5],z:e},{x:a[4],y:a[5],z:this.horiz||this.opposite?0:e}],e=b.options.inverted?c.beta:c.alpha,g=b.options.inverted?c.alpha:c.beta;g*=b.yAxis[0].opposite? +-1:1;a=x(a,e,g,c.origin);return a=this.chart.renderer.toLinePath(a,!1)});d.wrap(d.Axis.prototype,"getPlotBandPath",function(d){if(this.chart.is3d()){var a=arguments,b=a[1],a=this.getPlotLinePath(a[2]);(b=this.getPlotLinePath(b))&&a?b.push(a[7],a[8],a[4],a[5],a[1],a[2]):b=null;return b}else return d.apply(this,[].slice.call(arguments,1))});d.wrap(d.Tick.prototype,"getMarkPath",function(d){var a=d.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;var b=this.axis.chart,c=b.options.chart.options3d, +e={x:b.plotLeft+b.plotWidth/2,y:b.plotTop+b.plotHeight/2,z:c.depth,vd:c.viewDistance},a=[{x:a[1],y:a[2],z:0},{x:a[4],y:a[5],z:0}],g=b.inverted?c.beta:c.alpha,c=b.inverted?c.alpha:c.beta;c*=b.yAxis[0].opposite?-1:1;a=x(a,g,c,e);return a=["M",a[0].x,a[0].y,"L",a[1].x,a[1].y]});d.wrap(d.Tick.prototype,"getLabelPosition",function(d){var a=d.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;var b=this.axis.chart,c=b.options.chart.options3d,e={x:b.plotLeft+b.plotWidth/2,y:b.plotTop+ +b.plotHeight/2,z:c.depth,vd:c.viewDistance},g=b.inverted?c.beta:c.alpha,c=b.inverted?c.alpha:c.beta;c*=b.yAxis[0].opposite?-1:1;return a=x([{x:a.x,y:a.y,z:0}],g,c,e)[0]});d.wrap(d.Axis.prototype,"drawCrosshair",function(d){var a=arguments;this.chart.is3d()&&a[2]&&(a[2]={plotX:a[2].plotXold||a[2].plotX,plotY:a[2].plotYold||a[2].plotY});d.apply(this,[].slice.call(a,1))});d.wrap(d.seriesTypes.column.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a= +this.chart,b=this.options,c=a.options.chart.options3d,e=b.depth||25,g={x:a.plotWidth/2,y:a.plotHeight/2,z:c.depth,vd:c.viewDistance},j=c.alpha,i=c.beta*(a.yAxis[0].opposite?-1:1),h=(b.stacking?b.stack||0:this._i)*(e+(b.groupZPadding||1));b.grouping!==!1&&(h=0);h+=b.groupZPadding||1;d.each(this.data,function(a){if(a.y!==null){var b=a.shapeArgs,c=a.tooltipPos;a.shapeType="cuboid";b.alpha=j;b.beta=i;b.z=h;b.origin=g;b.depth=e;c=x([{x:c[0],y:c[1],z:h}],j,i,g)[0];a.tooltipPos=[c.x,c.y]}})}});d.wrap(d.seriesTypes.column.prototype, +"animate",function(f){if(this.chart.is3d()){var a=arguments[1],b=this.yAxis,c=this,e=this.yAxis.reversed;if(d.svg)a?d.each(c.data,function(a){if(a.y!==null&&(a.height=a.shapeArgs.height,a.shapey=a.shapeArgs.y,a.shapeArgs.height=1,!e))a.shapeArgs.y=a.stackY?a.plotY+b.translate(a.stackY):a.plotY+(a.negative?-a.height:a.height)}):(d.each(c.data,function(a){if(a.y!==null)a.shapeArgs.height=a.height,a.shapeArgs.y=a.shapey,a.graphic&&a.graphic.animate(a.shapeArgs,c.options.animation)}),this.drawDataLabels(), +c.animate=null)}else f.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.column.prototype,"init",function(d){d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.options,b=a.grouping,c=a.stacking,e=0;if((b===void 0||b)&&c){b=this.chart.retrieveStacks(b,c);c=a.stack||0;for(e=0;e<b[c].series.length;e++)if(b[c].series[e]===this)break;e=b.totalStacks*10-10*(b.totalStacks-b[c].position)-e}a.zIndex=e}});d.wrap(d.Series.prototype,"alignDataLabel",function(d){if(this.chart.is3d()&& +(this.type==="column"||this.type==="columnrange")){var a=this.chart,b=a.options.chart.options3d,c=arguments[4],e={x:c.x,y:c.y,z:0},e=x([e],b.alpha,b.beta*(a.yAxis[0].opposite?-1:1),{x:a.plotWidth/2,y:a.plotHeight/2,z:b.depth,vd:b.viewDistance})[0];c.x=e.x;c.y=e.y}d.apply(this,[].slice.call(arguments,1))});d.seriesTypes.columnrange&&d.wrap(d.seriesTypes.columnrange.prototype,"drawPoints",D);d.wrap(d.seriesTypes.column.prototype,"drawPoints",D);var C=d.getOptions();C.plotOptions.cylinder=d.merge(C.plotOptions.column); +C=d.extendClass(d.seriesTypes.column,{type:"cylinder"});d.seriesTypes.cylinder=C;d.wrap(d.seriesTypes.cylinder.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.options,c=b.plotOptions.cylinder,b=b.chart.options3d,e=c.depth||0,g={x:a.inverted?a.plotHeight/2:a.plotWidth/2,y:a.inverted?a.plotWidth/2:a.plotHeight/2,z:b.depth,vd:b.viewDistance},j=b.alpha,i=c.stacking?(this.options.stack||0)*e:this._i*e;i+=e/2;c.grouping!==!1&&(i=0);d.each(this.data, +function(a){var b=a.shapeArgs;a.shapeType="arc3d";b.x+=e/2;b.z=i;b.start=0;b.end=2*n;b.r=e*0.95;b.innerR=0;b.depth=b.height*(1/l((90-j)*t))-i;b.alpha=90-j;b.beta=0;b.origin=g})}});d.wrap(d.seriesTypes.pie.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this,b=a.chart,c=a.options,e=c.depth||0,g=b.options.chart.options3d,j={x:b.plotWidth/2,y:b.plotHeight/2,z:g.depth},i=g.alpha,h=g.beta,k=c.stacking?(c.stack||0)*e:a._i*e;k+=e/2;c.grouping!==!1&& +(k=0);d.each(a.data,function(b){b.shapeType="arc3d";var c=b.shapeArgs;if(b.y)c.z=k,c.depth=e*0.75,c.origin=j,c.alpha=i,c.beta=h,c=(c.end+c.start)/2,b.slicedTranslation={translateX:z(m(c)*a.options.slicedOffset*m(i*t)),translateY:z(l(c)*a.options.slicedOffset*m(i*t))}})}});d.wrap(d.seriesTypes.pie.prototype.pointClass.prototype,"haloPath",function(d){var a=arguments;return this.series.chart.is3d()?[]:d.call(this,a[1])});d.wrap(d.seriesTypes.pie.prototype,"drawPoints",function(f){if(this.chart.is3d()){var a= +this.options,b=this.options.states;this.borderWidth=a.borderWidth=a.edgeWidth||1;this.borderColor=a.edgeColor=d.pick(a.edgeColor,a.borderColor,void 0);b.hover.borderColor=d.pick(b.hover.edgeColor,this.borderColor);b.hover.borderWidth=d.pick(b.hover.edgeWidth,this.borderWidth);b.select.borderColor=d.pick(b.select.edgeColor,this.borderColor);b.select.borderWidth=d.pick(b.select.edgeWidth,this.borderWidth);d.each(this.data,function(a){var c=a.pointAttr;c[""].stroke=a.series.borderColor||a.color;c[""]["stroke-width"]= +a.series.borderWidth;c.hover.stroke=b.hover.borderColor;c.hover["stroke-width"]=b.hover.borderWidth;c.select.stroke=b.select.borderColor;c.select["stroke-width"]=b.select.borderWidth})}f.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var c=this.group;d.each(this.points,function(a){a.graphic.out.add(c);a.graphic.inn.add(c);a.graphic.side1.add(c);a.graphic.side2.add(c)})}});d.wrap(d.seriesTypes.pie.prototype,"drawDataLabels",function(f){this.chart.is3d()&&d.each(this.data,function(a){var b= +a.shapeArgs,c=b.r,d=b.depth,f=b.alpha*t,b=(b.start+b.end)/2,a=a.labelPos;a[1]+=-c*(1-m(f))*l(b)+(l(b)>0?l(f)*d:0);a[3]+=-c*(1-m(f))*l(b)+(l(b)>0?l(f)*d:0);a[5]+=-c*(1-m(f))*l(b)+(l(b)>0?l(f)*d:0)});f.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.pie.prototype,"addPoint",function(d){d.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&this.update()});d.wrap(d.seriesTypes.pie.prototype,"animate",function(f){if(this.chart.is3d()){var a=arguments[1],b=this.options.animation,c=this.center, +e=this.group,g=this.markerGroup;if(d.svg)if(b===!0&&(b={}),a){if(e.oldtranslateX=e.translateX,e.oldtranslateY=e.translateY,a={translateX:c[0],translateY:c[1],scaleX:0.001,scaleY:0.001},e.attr(a),g)g.attrSetters=e.attrSetters,g.attr(a)}else a={translateX:e.oldtranslateX,translateY:e.oldtranslateY,scaleX:1,scaleY:1},e.animate(a,b),g&&g.animate(a,b),this.animate=null}else f.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.scatter.prototype,"translate",function(f){f.apply(this,[].slice.call(arguments, +1));if(this.chart.is3d()){var a=this.chart,b=this.chart.options.chart.options3d,c=b.alpha,e=b.beta,g={x:a.inverted?a.plotHeight/2:a.plotWidth/2,y:a.inverted?a.plotWidth/2:a.plotHeight/2,z:b.depth,vd:b.viewDistance},b=b.depth,j=a.options.zAxis||{min:0,max:b},i=b/(j.max-j.min);d.each(this.data,function(a){var b={x:a.plotX,y:a.plotY,z:(a.z-j.min)*i},b=x([b],c,e,g)[0];a.plotXold=a.plotX;a.plotYold=a.plotY;a.plotX=b.x;a.plotY=b.y;a.plotZ=b.z})}});d.wrap(d.seriesTypes.scatter.prototype,"init",function(d){var a= +d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d())this.pointArrayMap=["x","y","z"],this.tooltipOptions.pointFormat=this.userOptions.tooltip?this.userOptions.tooltip.pointFormat||"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>":"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>";return a});if(d.VMLRenderer)d.setOptions({animate:!1}),d.VMLRenderer.prototype.cuboid=d.SVGRenderer.prototype.cuboid,d.VMLRenderer.prototype.cuboidPath=d.SVGRenderer.prototype.cuboidPath, +d.VMLRenderer.prototype.toLinePath=d.SVGRenderer.prototype.toLinePath,d.VMLRenderer.prototype.createElement3D=d.SVGRenderer.prototype.createElement3D,d.VMLRenderer.prototype.arc3d=function(f){f=d.SVGRenderer.prototype.arc3d.call(this,f);f.css({zIndex:f.zIndex});return f},d.VMLRenderer.prototype.arc3dPath=d.SVGRenderer.prototype.arc3dPath,d.Chart.prototype.renderSeries=function(){for(var d,a=this.series.length;a--;)d=this.series[a],d.translate(),d.setTooltipPoints&&d.setTooltipPoints(),d.render()}, +d.wrap(d.Axis.prototype,"render",function(d){d.apply(this,[].slice.call(arguments,1));this.sideFrame&&(this.sideFrame.css({zIndex:0}),this.sideFrame.front.attr({fill:this.sideFrame.color}));this.bottomFrame&&(this.bottomFrame.css({zIndex:1}),this.bottomFrame.front.attr({fill:this.bottomFrame.color}));this.backFrame&&(this.backFrame.css({zIndex:0}),this.backFrame.front.attr({fill:this.backFrame.color}))})})(Highcharts); +/* + Highcharts JS v4.0.4 (2014-09-02) + Exporting module + + (c) 2010-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(f){var A=f.Chart,t=f.addEvent,B=f.removeEvent,l=f.createElement,o=f.discardElement,v=f.css,k=f.merge,r=f.each,p=f.extend,D=Math.max,j=document,C=window,E=f.isTouchDevice,F=f.Renderer.prototype.symbols,s=f.getOptions(),y;p(s.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"});s.navigation={menuStyle:{border:"1px solid #A0A0A0", +background:"#FFFFFF",padding:"5px 0"},menuItemStyle:{padding:"0 10px",background:"none",color:"#303030",fontSize:E?"14px":"11px"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{symbolFill:"#E0E0E0",symbolSize:14,symbolStroke:"#666",symbolStrokeWidth:3,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,theme:{fill:"white",stroke:"none"},verticalAlign:"top",width:24}};s.exporting={type:"image/png",url:"http://export.highcharts.com/",buttons:{contextButton:{menuClassName:"highcharts-contextmenu", +symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}};f.post=function(b,a,d){var c,b=l("form",k({method:"post", +action:b,enctype:"multipart/form-data"},d),{display:"none"},j.body);for(c in a)l("input",{type:"hidden",name:c,value:a[c]},null,b);b.submit();o(b)};p(A.prototype,{getSVG:function(b){var a=this,d,c,z,h,g=k(a.options,b);if(!j.createElementNS)j.createElementNS=function(a,b){return j.createElement(b)};b=l("div",null,{position:"absolute",top:"-9999em",width:a.chartWidth+"px",height:a.chartHeight+"px"},j.body);c=a.renderTo.style.width;h=a.renderTo.style.height;c=g.exporting.sourceWidth||g.chart.width|| +/px$/.test(c)&&parseInt(c,10)||600;h=g.exporting.sourceHeight||g.chart.height||/px$/.test(h)&&parseInt(h,10)||400;p(g.chart,{animation:!1,renderTo:b,forExport:!0,width:c,height:h});g.exporting.enabled=!1;g.series=[];r(a.series,function(a){z=k(a.options,{animation:!1,enableMouseTracking:!1,showCheckbox:!1,visible:a.visible});z.isInternal||g.series.push(z)});d=new f.Chart(g,a.callback);r(["xAxis","yAxis"],function(b){r(a[b],function(a,c){var g=d[b][c],f=a.getExtremes(),h=f.userMin,f=f.userMax;g&&(h!== +void 0||f!==void 0)&&g.setExtremes(h,f,!0,!1)})});c=d.container.innerHTML;g=null;d.destroy();o(b);c=c.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g," xlink:href=").replace(/\n/," ").replace(/<\/svg>.*?$/,"</svg>").replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g,'$1="rgb($2)" $1-opacity="$3"').replace(/ /g, +" ").replace(/­/g,"").replace(/<IMG /g,"<image ").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g,'width="$1"').replace(/hc-svg-href="([^"]+)">/g,'xlink:href="$1"/>').replace(/id=([^" >]+)/g,'id="$1"').replace(/class=([^" >]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:(path|rect)/g,"$1").replace(/style="([^"]+)"/g,function(a){return a.toLowerCase()});return c=c.replace(/(url\(#highcharts-[0-9]+)"/g,"$1").replace(/"/g,"'")},exportChart:function(b,a){var b= +b||{},d=this.options.exporting,d=this.getSVG(k({chart:{borderRadius:0}},d.chartOptions,a,{exporting:{sourceWidth:b.sourceWidth||d.sourceWidth,sourceHeight:b.sourceHeight||d.sourceHeight}})),b=k(this.options.exporting,b);f.post(b.url,{filename:b.filename||"chart",type:b.type,width:b.width||0,scale:b.scale||2,svg:d},b.formAttributes)},print:function(){var b=this,a=b.container,d=[],c=a.parentNode,f=j.body,h=f.childNodes;if(!b.isPrinting)b.isPrinting=!0,r(h,function(a,b){if(a.nodeType===1)d[b]=a.style.display, +a.style.display="none"}),f.appendChild(a),C.focus(),C.print(),setTimeout(function(){c.appendChild(a);r(h,function(a,b){if(a.nodeType===1)a.style.display=d[b]});b.isPrinting=!1},1E3)},contextMenu:function(b,a,d,c,f,h,g){var e=this,k=e.options.navigation,q=k.menuItemStyle,m=e.chartWidth,n=e.chartHeight,j="cache-"+b,i=e[j],u=D(f,h),w,x,o,s=function(a){e.pointer.inClass(a.target,b)||x()};if(!i)e[j]=i=l("div",{className:b},{position:"absolute",zIndex:1E3,padding:u+"px"},e.container),w=l("div",null,p({MozBoxShadow:"3px 3px 10px #888", +WebkitBoxShadow:"3px 3px 10px #888",boxShadow:"3px 3px 10px #888"},k.menuStyle),i),x=function(){v(i,{display:"none"});g&&g.setState(0);e.openMenu=!1},t(i,"mouseleave",function(){o=setTimeout(x,500)}),t(i,"mouseenter",function(){clearTimeout(o)}),t(document,"mouseup",s),t(e,"destroy",function(){B(document,"mouseup",s)}),r(a,function(a){if(a){var b=a.separator?l("hr",null,null,w):l("div",{onmouseover:function(){v(this,k.menuItemHoverStyle)},onmouseout:function(){v(this,q)},onclick:function(){x();a.onclick.apply(e, +arguments)},innerHTML:a.text||e.options.lang[a.textKey]},p({cursor:"pointer"},q),w);e.exportDivElements.push(b)}}),e.exportDivElements.push(w,i),e.exportMenuWidth=i.offsetWidth,e.exportMenuHeight=i.offsetHeight;a={display:"block"};d+e.exportMenuWidth>m?a.right=m-d-f-u+"px":a.left=d-u+"px";c+h+e.exportMenuHeight>n&&g.alignOptions.verticalAlign!=="top"?a.bottom=n-c-u+"px":a.top=c+h-u+"px";v(i,a);e.openMenu=!0},addButton:function(b){var a=this,d=a.renderer,c=k(a.options.navigation.buttonOptions,b),j= +c.onclick,h=c.menuItems,g,e,l={stroke:c.symbolStroke,fill:c.symbolFill},q=c.symbolSize||12;if(!a.btnCount)a.btnCount=0;if(!a.exportDivElements)a.exportDivElements=[],a.exportSVGElements=[];if(c.enabled!==!1){var m=c.theme,n=m.states,o=n&&n.hover,n=n&&n.select,i;delete m.states;j?i=function(){j.apply(a,arguments)}:h&&(i=function(){a.contextMenu(e.menuClassName,h,e.translateX,e.translateY,e.width,e.height,e);e.setState(2)});c.text&&c.symbol?m.paddingLeft=f.pick(m.paddingLeft,25):c.text||p(m,{width:c.width, +height:c.height,padding:0});e=d.button(c.text,0,0,i,m,o,n).attr({title:a.options.lang[c._titleKey],"stroke-linecap":"round"});e.menuClassName=b.menuClassName||"highcharts-menu-"+a.btnCount++;c.symbol&&(g=d.symbol(c.symbol,c.symbolX-q/2,c.symbolY-q/2,q,q).attr(p(l,{"stroke-width":c.symbolStrokeWidth||1,zIndex:1})).add(e));e.add().align(p(c,{width:e.width,x:f.pick(c.x,y)}),!0,"spacingBox");y+=(e.width+c.buttonSpacing)*(c.align==="right"?-1:1);a.exportSVGElements.push(e,g)}},destroyExport:function(b){var b= +b.target,a,d;for(a=0;a<b.exportSVGElements.length;a++)if(d=b.exportSVGElements[a])d.onclick=d.ontouchstart=null,b.exportSVGElements[a]=d.destroy();for(a=0;a<b.exportDivElements.length;a++)d=b.exportDivElements[a],B(d,"mouseleave"),b.exportDivElements[a]=d.onmouseout=d.onmouseover=d.ontouchstart=d.onclick=null,o(d)}});F.menu=function(b,a,d,c){return["M",b,a+2.5,"L",b+d,a+2.5,"M",b,a+c/2+0.5,"L",b+d,a+c/2+0.5,"M",b,a+c-1.5,"L",b+d,a+c-1.5]};A.prototype.callbacks.push(function(b){var a,d=b.options.exporting, +c=d.buttons;y=0;if(d.enabled!==!1){for(a in c)b.addButton(c[a]);t(b,"destroy",b.destroyExport)}})})(Highcharts); +/* + Data plugin for Highcharts + + (c) 2012-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(g){var j=g.each,q=HighchartsAdapter.inArray,s=g.splat,l,n=function(a,b){this.init(a,b)};g.extend(n.prototype,{init:function(a,b){this.options=a;this.chartOptions=b;this.columns=a.columns||this.rowsToColumns(a.rows)||[];this.rawColumns=[];this.columns.length?this.dataFound():(this.parseCSV(),this.parseTable(),this.parseGoogleSpreadsheet())},getColumnDistribution:function(){var a=this.chartOptions,b=this.options,c=[],f=function(a){return(g.seriesTypes[a||"line"].prototype.pointArrayMap||[0]).length}, +e=a&&a.chart&&a.chart.type,d=[],i=[],p,h;j(a&&a.series||[],function(a){d.push(f(a.type||e))});j(b&&b.seriesMapping||[],function(a){c.push(a.x||0)});c.length===0&&c.push(0);j(b&&b.seriesMapping||[],function(b){var c=new l,m,j=d[p]||f(e),o=g.seriesTypes[((a&&a.series||[])[p]||{}).type||e||"line"].prototype.pointArrayMap||["y"];c.addColumnReader(b.x,"x");for(m in b)b.hasOwnProperty(m)&&m!=="x"&&c.addColumnReader(b[m],m);for(h=0;h<j;h++)c.hasReader(o[h])||c.addColumnReader(void 0,o[h]);i.push(c);p++}); +b=g.seriesTypes[e||"line"].prototype.pointArrayMap;b===void 0&&(b=["y"]);this.valueCount={global:f(e),xColumns:c,individual:d,seriesBuilders:i,globalPointArrayMap:b}},dataFound:function(){if(this.options.switchRowsAndColumns)this.columns=this.rowsToColumns(this.columns);this.getColumnDistribution();this.parseTypes();this.findHeaderRow();this.parsed()!==!1&&this.complete()},parseCSV:function(){var a=this,b=this.options,c=b.csv,f=this.columns,e=b.startRow||0,d=b.endRow||Number.MAX_VALUE,i=b.startColumn|| +0,p=b.endColumn||Number.MAX_VALUE,h,g,r=0;c&&(g=c.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split(b.lineDelimiter||"\n"),h=b.itemDelimiter||(c.indexOf("\t")!==-1?"\t":","),j(g,function(b,c){var g=a.trim(b),t=g.indexOf("#")===0;c>=e&&c<=d&&!t&&g!==""&&(g=b.split(h),j(g,function(a,b){b>=i&&b<=p&&(f[b-i]||(f[b-i]=[]),f[b-i][r]=a)}),r+=1)}),this.dataFound())},parseTable:function(){var a=this.options,b=a.table,c=this.columns,f=a.startRow||0,e=a.endRow||Number.MAX_VALUE,d=a.startColumn||0,i=a.endColumn|| +Number.MAX_VALUE;b&&(typeof b==="string"&&(b=document.getElementById(b)),j(b.getElementsByTagName("tr"),function(a,b){b>=f&&b<=e&&j(a.children,function(a,e){if((a.tagName==="TD"||a.tagName==="TH")&&e>=d&&e<=i)c[e-d]||(c[e-d]=[]),c[e-d][b-f]=a.innerHTML})}),this.dataFound())},parseGoogleSpreadsheet:function(){var a=this,b=this.options,c=b.googleSpreadsheetKey,f=this.columns,e=b.startRow||0,d=b.endRow||Number.MAX_VALUE,i=b.startColumn||0,g=b.endColumn||Number.MAX_VALUE,h,j;c&&jQuery.ajax({dataType:"json", +url:"https://spreadsheets.google.com/feeds/cells/"+c+"/"+(b.googleSpreadsheetWorksheet||"od6")+"/public/values?alt=json-in-script&callback=?",error:b.error,success:function(b){var b=b.feed.entry,c,l=b.length,o=0,n=0,k;for(k=0;k<l;k++)c=b[k],o=Math.max(o,c.gs$cell.col),n=Math.max(n,c.gs$cell.row);for(k=0;k<o;k++)if(k>=i&&k<=g)f[k-i]=[],f[k-i].length=Math.min(n,d-e);for(k=0;k<l;k++)if(c=b[k],h=c.gs$cell.row-1,j=c.gs$cell.col-1,j>=i&&j<=g&&h>=e&&h<=d)f[j-i][h-e]=c.content.$t;a.dataFound()}})},findHeaderRow:function(){var a= +0;j(this.columns,function(b){b.isNumeric&&typeof b[0]!=="string"&&(a=null)});this.headerRow=a},trim:function(a){return typeof a==="string"?a.replace(/^\s+|\s+$/g,""):a},parseTypes:function(){for(var a=this.columns,b=this.rawColumns,c=a.length,f,e,d,i,g,h,j=[],l,m=this.chartOptions;c--;){f=a[c].length;b[c]=[];for(l=(g=q(c,this.valueCount.xColumns)!==-1)&&m&&m.xAxis&&s(m.xAxis)[0].type==="category";f--;)if(e=j[f]||a[c][f],d=parseFloat(e),i=b[c][f]=this.trim(e),l)a[c][f]=i;else if(i==d)a[c][f]=d,d>31536E6? +a[c].isDatetime=!0:a[c].isNumeric=!0;else if(d=this.parseDate(e),g&&typeof d==="number"&&!isNaN(d)){if(j[f]=e,a[c][f]=d,a[c].isDatetime=!0,a[c][f+1]!==void 0){e=d>a[c][f+1];if(e!==h&&h!==void 0)this.alternativeFormat?(this.dateFormat=this.alternativeFormat,f=a[c].length,this.alternativeFormat=this.dateFormats[this.dateFormat].alternative):a[c].unsorted=!0;h=e}}else if(a[c][f]=i===""?null:i,f!==0&&(a[c].isDatetime||a[c].isNumeric))a[c].mixed=!0;g&&a[c].mixed&&(a[c]=b[c])}if(a[0].isDatetime&&h){b=typeof a[0][0]!== +"number";for(c=0;c<a.length;c++)a[c].reverse(),b&&a[c].unshift(a[c].pop())}},dateFormats:{"YYYY-mm-dd":{regex:/^([0-9]{4})[\-\/\.]([0-9]{2})[\-\/\.]([0-9]{2})$/,parser:function(a){return Date.UTC(+a[1],a[2]-1,+a[3])}},"dd/mm/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(a){return Date.UTC(+a[3],a[2]-1,+a[1])},alternative:"mm/dd/YYYY"},"mm/dd/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(a){return Date.UTC(+a[3],a[1]-1,+a[2])}}, +"dd/mm/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,parser:function(a){return Date.UTC(+a[3]+2E3,a[2]-1,+a[1])},alternative:"mm/dd/YY"},"mm/dd/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,parser:function(a){console.log(a);return Date.UTC(+a[3]+2E3,a[1]-1,+a[2])}}},parseDate:function(a){var b=this.options.parseDate,c,f,e=this.options.dateFormat||this.dateFormat,d;b&&(c=b(a));if(typeof a==="string"){if(e)b=this.dateFormats[e],(d=a.match(b.regex))&&(c=b.parser(d)); +else for(f in this.dateFormats)if(b=this.dateFormats[f],d=a.match(b.regex)){this.dateFormat=f;this.alternativeFormat=b.alternative;c=b.parser(d);break}d||(d=Date.parse(a),typeof d==="object"&&d!==null&&d.getTime?c=d.getTime()-d.getTimezoneOffset()*6E4:typeof d==="number"&&!isNaN(d)&&(c=d-(new Date(d)).getTimezoneOffset()*6E4))}return c},rowsToColumns:function(a){var b,c,f,e,d;if(a){d=[];c=a.length;for(b=0;b<c;b++){e=a[b].length;for(f=0;f<e;f++)d[f]||(d[f]=[]),d[f][b]=a[b][f]}}return d},parsed:function(){if(this.options.parsed)return this.options.parsed.call(this, +this.columns)},getFreeIndexes:function(a,b){var c,f,e=[],d=[],i;for(f=0;f<a;f+=1)e.push(!0);for(c=0;c<b.length;c+=1){i=b[c].getReferencedColumnIndexes();for(f=0;f<i.length;f+=1)e[i[f]]=!1}for(f=0;f<e.length;f+=1)e[f]&&d.push(f);return d},complete:function(){var a=this.columns,b,c=this.options,f,e,d,i,g=[],h;if(c.complete||c.afterComplete){for(d=0;d<a.length;d++)if(this.headerRow===0)a[d].name=a[d].shift();f=[];e=this.getFreeIndexes(a.length,this.valueCount.seriesBuilders);for(d=0;d<this.valueCount.seriesBuilders.length;d++)h= +this.valueCount.seriesBuilders[d],h.populateColumns(e)&&g.push(h);for(;e.length>0;){h=new l;h.addColumnReader(0,"x");d=q(0,e);d!==-1&&e.splice(d,1);for(d=0;d<this.valueCount.global;d++)h.addColumnReader(void 0,this.valueCount.globalPointArrayMap[d]);h.populateColumns(e)&&g.push(h)}g.length>0&&g[0].readers.length>0&&(h=a[g[0].readers[0].columnIndex],h!==void 0&&(h.isDatetime?b="datetime":h.isNumeric||(b="category")));if(b==="category")for(d=0;d<g.length;d++){h=g[d];for(e=0;e<h.readers.length;e++)if(h.readers[e].configName=== +"x")h.readers[e].configName="name"}for(d=0;d<g.length;d++){h=g[d];e=[];for(i=0;i<a[0].length;i++)e[i]=h.read(a,i);f[d]={data:e};if(h.name)f[d].name=h.name}a={xAxis:{type:b},series:f};c.complete&&c.complete(a);c.afterComplete&&c.afterComplete(a)}}});g.Data=n;g.data=function(a,b){return new n(a,b)};g.wrap(g.Chart.prototype,"init",function(a,b,c){var f=this;b&&b.data?g.data(g.extend(b.data,{afterComplete:function(e){var d,i;if(b.hasOwnProperty("series"))if(typeof b.series==="object")for(d=Math.max(b.series.length, +e.series.length);d--;)i=b.series[d]||{},b.series[d]=g.merge(i,e.series[d]);else delete b.series;b=g.merge(e,b);a.call(f,b,c)}}),b):a.call(f,b,c)});l=function(){this.readers=[];this.pointIsArray=!0};l.prototype.populateColumns=function(a){var b=!0;j(this.readers,function(b){if(b.columnIndex===void 0)b.columnIndex=a.shift()});j(this.readers,function(a){a.columnIndex===void 0&&(b=!1)});return b};l.prototype.read=function(a,b){var c=this.pointIsArray,f=c?[]:{},e;j(this.readers,function(d){var e=a[d.columnIndex][b]; +c?f.push(e):f[d.configName]=e});if(this.name===void 0&&this.readers.length>=2&&(e=this.getReferencedColumnIndexes(),e.length>=2))e.shift(),e.sort(),this.name=a[e.shift()].name;return f};l.prototype.addColumnReader=function(a,b){this.readers.push({columnIndex:a,configName:b});if(!(b==="x"||b==="y"||b===void 0))this.pointIsArray=!1};l.prototype.getReferencedColumnIndexes=function(){var a,b=[],c;for(a=0;a<this.readers.length;a+=1)c=this.readers[a],c.columnIndex!==void 0&&b.push(c.columnIndex);return b}; +l.prototype.hasReader=function(a){var b,c;for(b=0;b<this.readers.length;b+=1)if(c=this.readers[b],c.configName===a)return!0}})(Highcharts); diff --git a/html/includes/js/highcharts-functions.js b/html/includes/js/highcharts-functions.js new file mode 100644 index 0000000..4fe381a --- /dev/null +++ b/html/includes/js/highcharts-functions.js @@ -0,0 +1 @@ +round_up = function(x,factor){ return x - (x%factor) + (x%factor>0 && factor);}
\ No newline at end of file diff --git a/html/includes/js/highcharts-more.js b/html/includes/js/highcharts-more.js new file mode 100644 index 0000000..f7c8da5 --- /dev/null +++ b/html/includes/js/highcharts-more.js @@ -0,0 +1,53 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + + (c) 2009-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(l,C){function K(a,b,c){this.init.call(this,a,b,c)}var P=l.arrayMin,Q=l.arrayMax,s=l.each,F=l.extend,q=l.merge,R=l.map,o=l.pick,x=l.pInt,p=l.getOptions().plotOptions,g=l.seriesTypes,v=l.extendClass,L=l.splat,r=l.wrap,M=l.Axis,y=l.Tick,H=l.Point,S=l.Pointer,T=l.CenteredSeriesMixin,z=l.TrackerMixin,t=l.Series,w=Math,D=w.round,A=w.floor,N=w.max,U=l.Color,u=function(){};F(K.prototype,{init:function(a,b,c){var d=this,e=d.defaultOptions;d.chart=b;if(b.angular)e.background={};d.options=a=q(e,a); +(a=a.background)&&s([].concat(L(a)).reverse(),function(a){var b=a.backgroundColor,a=q(d.defaultBackgroundOptions,a);if(b)a.backgroundColor=b;a.color=a.backgroundColor;c.options.plotBands.unshift(a)})},defaultOptions:{center:["50%","50%"],size:"85%",startAngle:0},defaultBackgroundOptions:{shape:"circle",borderWidth:1,borderColor:"silver",backgroundColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,"#FFF"],[1,"#DDD"]]},from:-Number.MAX_VALUE,innerRadius:0,to:Number.MAX_VALUE,outerRadius:"105%"}}); +var G=M.prototype,y=y.prototype,V={getOffset:u,redraw:function(){this.isDirty=!1},render:function(){this.isDirty=!1},setScale:u,setCategories:u,setTitle:u},O={isRadial:!0,defaultRadialGaugeOptions:{labels:{align:"center",x:0,y:null},minorGridLineWidth:0,minorTickInterval:"auto",minorTickLength:10,minorTickPosition:"inside",minorTickWidth:1,tickLength:10,tickPosition:"inside",tickWidth:2,title:{rotation:0},zIndex:2},defaultRadialXOptions:{gridLineWidth:1,labels:{align:null,distance:15,x:0,y:null}, +maxPadding:0,minPadding:0,showLastLabel:!1,tickLength:0},defaultRadialYOptions:{gridLineInterpolation:"circle",labels:{align:"right",x:-3,y:-2},showLastLabel:!1,title:{x:4,text:null,rotation:90}},setOptions:function(a){a=this.options=q(this.defaultOptions,this.defaultRadialOptions,a);if(!a.plotBands)a.plotBands=[]},getOffset:function(){G.getOffset.call(this);this.chart.axisOffset[this.side]=0;this.center=this.pane.center=T.getCenter.call(this.pane)},getLinePath:function(a,b){var c=this.center,b=o(b, +c[2]/2-this.offset);return this.chart.renderer.symbols.arc(this.left+c[0],this.top+c[1],b,b,{start:this.startAngleRad,end:this.endAngleRad,open:!0,innerR:0})},setAxisTranslation:function(){G.setAxisTranslation.call(this);if(this.center)this.transA=this.isCircular?(this.endAngleRad-this.startAngleRad)/(this.max-this.min||1):this.center[2]/2/(this.max-this.min||1),this.minPixelPadding=this.isXAxis?this.transA*this.minPointOffset:0},beforeSetTickPositions:function(){this.autoConnect&&(this.max+=this.categories&& +1||this.pointRange||this.closestPointRange||0)},setAxisSize:function(){G.setAxisSize.call(this);if(this.isRadial){this.center=this.pane.center=l.CenteredSeriesMixin.getCenter.call(this.pane);if(this.isCircular)this.sector=this.endAngleRad-this.startAngleRad;this.len=this.width=this.height=this.center[2]*o(this.sector,1)/2}},getPosition:function(a,b){return this.postTranslate(this.isCircular?this.translate(a):0,o(this.isCircular?b:this.translate(a),this.center[2]/2)-this.offset)},postTranslate:function(a, +b){var c=this.chart,d=this.center,a=this.startAngleRad+a;return{x:c.plotLeft+d[0]+Math.cos(a)*b,y:c.plotTop+d[1]+Math.sin(a)*b}},getPlotBandPath:function(a,b,c){var d=this.center,e=this.startAngleRad,f=d[2]/2,h=[o(c.outerRadius,"100%"),c.innerRadius,o(c.thickness,10)],j=/%$/,k,m=this.isCircular;this.options.gridLineInterpolation==="polygon"?d=this.getPlotLinePath(a).concat(this.getPlotLinePath(b,!0)):(m||(h[0]=this.translate(a),h[1]=this.translate(b)),h=R(h,function(a){j.test(a)&&(a=x(a,10)*f/100); +return a}),c.shape==="circle"||!m?(a=-Math.PI/2,b=Math.PI*1.5,k=!0):(a=e+this.translate(a),b=e+this.translate(b)),d=this.chart.renderer.symbols.arc(this.left+d[0],this.top+d[1],h[0],h[0],{start:a,end:b,innerR:o(h[1],h[0]-h[2]),open:k}));return d},getPlotLinePath:function(a,b){var c=this,d=c.center,e=c.chart,f=c.getPosition(a),h,j,k;c.isCircular?k=["M",d[0]+e.plotLeft,d[1]+e.plotTop,"L",f.x,f.y]:c.options.gridLineInterpolation==="circle"?(a=c.translate(a))&&(k=c.getLinePath(0,a)):(s(e.xAxis,function(a){a.pane=== +c.pane&&(h=a)}),k=[],a=c.translate(a),d=h.tickPositions,h.autoConnect&&(d=d.concat([d[0]])),b&&(d=[].concat(d).reverse()),s(d,function(f,c){j=h.getPosition(f,a);k.push(c?"L":"M",j.x,j.y)}));return k},getTitlePosition:function(){var a=this.center,b=this.chart,c=this.options.title;return{x:b.plotLeft+a[0]+(c.x||0),y:b.plotTop+a[1]-{high:0.5,middle:0.25,low:0}[c.align]*a[2]+(c.y||0)}}};r(G,"init",function(a,b,c){var i;var d=b.angular,e=b.polar,f=c.isX,h=d&&f,j,k;k=b.options;var m=c.pane||0;if(d){if(F(this, +h?V:O),j=!f)this.defaultRadialOptions=this.defaultRadialGaugeOptions}else if(e)F(this,O),this.defaultRadialOptions=(j=f)?this.defaultRadialXOptions:q(this.defaultYAxisOptions,this.defaultRadialYOptions);a.call(this,b,c);if(!h&&(d||e)){a=this.options;if(!b.panes)b.panes=[];this.pane=(i=b.panes[m]=b.panes[m]||new K(L(k.pane)[m],b,this),m=i);m=m.options;b.inverted=!1;k.chart.zoomType=null;this.startAngleRad=b=(m.startAngle-90)*Math.PI/180;this.endAngleRad=k=(o(m.endAngle,m.startAngle+360)-90)*Math.PI/ +180;this.offset=a.offset||0;if((this.isCircular=j)&&c.max===C&&k-b===2*Math.PI)this.autoConnect=!0}});r(y,"getPosition",function(a,b,c,d,e){var f=this.axis;return f.getPosition?f.getPosition(c):a.call(this,b,c,d,e)});r(y,"getLabelPosition",function(a,b,c,d,e,f,h,j,k){var m=this.axis,i=f.y,n=f.align,g=(m.translate(this.pos)+m.startAngleRad+Math.PI/2)/Math.PI*180%360;m.isRadial?(a=m.getPosition(this.pos,m.center[2]/2+o(f.distance,-25)),f.rotation==="auto"?d.attr({rotation:g}):i===null&&(i=m.chart.renderer.fontMetrics(d.styles.fontSize).b- +d.getBBox().height/2),n===null&&(n=m.isCircular?g>20&&g<160?"left":g>200&&g<340?"right":"center":"center",d.attr({align:n})),a.x+=f.x,a.y+=i):a=a.call(this,b,c,d,e,f,h,j,k);return a});r(y,"getMarkPath",function(a,b,c,d,e,f,h){var j=this.axis;j.isRadial?(a=j.getPosition(this.pos,j.center[2]/2+d),b=["M",b,c,"L",a.x,a.y]):b=a.call(this,b,c,d,e,f,h);return b});p.arearange=q(p.area,{lineWidth:1,marker:null,threshold:null,tooltip:{pointFormat:'<span style="color:{series.color}">●</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'}, +trackByArea:!0,dataLabels:{align:null,verticalAlign:null,xLow:0,xHigh:0,yLow:0,yHigh:0},states:{hover:{halo:!1}}});g.arearange=v(g.area,{type:"arearange",pointArrayMap:["low","high"],toYData:function(a){return[a.low,a.high]},pointValKey:"low",getSegments:function(){var a=this;s(a.points,function(b){if(!a.options.connectNulls&&(b.low===null||b.high===null))b.y=null;else if(b.low===null&&b.high!==null)b.y=b.high});t.prototype.getSegments.call(this)},translate:function(){var a=this.yAxis;g.area.prototype.translate.apply(this); +s(this.points,function(b){var c=b.low,d=b.high,e=b.plotY;d===null&&c===null?b.y=null:c===null?(b.plotLow=b.plotY=null,b.plotHigh=a.translate(d,0,1,0,1)):d===null?(b.plotLow=e,b.plotHigh=null):(b.plotLow=e,b.plotHigh=a.translate(d,0,1,0,1))})},getSegmentPath:function(a){var b,c=[],d=a.length,e=t.prototype.getSegmentPath,f,h;h=this.options;var j=h.step;for(b=HighchartsAdapter.grep(a,function(a){return a.plotLow!==null});d--;)f=a[d],f.plotHigh!==null&&c.push({plotX:f.plotX,plotY:f.plotHigh});a=e.call(this, +b);if(j)j===!0&&(j="left"),h.step={left:"right",center:"center",right:"left"}[j];c=e.call(this,c);h.step=j;h=[].concat(a,c);c[0]="L";this.areaPath=this.areaPath.concat(a,c);return h},drawDataLabels:function(){var a=this.data,b=a.length,c,d=[],e=t.prototype,f=this.options.dataLabels,h=f.align,j,k=this.chart.inverted;if(f.enabled||this._hasPointLabels){for(c=b;c--;)if(j=a[c],j.y=j.high,j._plotY=j.plotY,j.plotY=j.plotHigh,d[c]=j.dataLabel,j.dataLabel=j.dataLabelUpper,j.below=!1,k){if(!h)f.align="left"; +f.x=f.xHigh}else f.y=f.yHigh;e.drawDataLabels&&e.drawDataLabels.apply(this,arguments);for(c=b;c--;)if(j=a[c],j.dataLabelUpper=j.dataLabel,j.dataLabel=d[c],j.y=j.low,j.plotY=j._plotY,j.below=!0,k){if(!h)f.align="right";f.x=f.xLow}else f.y=f.yLow;e.drawDataLabels&&e.drawDataLabels.apply(this,arguments)}f.align=h},alignDataLabel:function(){g.column.prototype.alignDataLabel.apply(this,arguments)},getSymbol:u,drawPoints:u});p.areasplinerange=q(p.arearange);g.areasplinerange=v(g.arearange,{type:"areasplinerange", +getPointSpline:g.spline.prototype.getPointSpline});(function(){var a=g.column.prototype;p.columnrange=q(p.column,p.arearange,{lineWidth:1,pointRange:null});g.columnrange=v(g.arearange,{type:"columnrange",translate:function(){var b=this,c=b.yAxis,d;a.translate.apply(b);s(b.points,function(a){var f=a.shapeArgs,h=b.options.minPointLength,j;a.tooltipPos=null;a.plotHigh=d=c.translate(a.high,0,1,0,1);a.plotLow=a.plotY;j=d;a=a.plotY-d;a<h&&(h-=a,a+=h,j-=h/2);f.height=a;f.y=j})},trackerGroups:["group","dataLabelsGroup"], +drawGraph:u,pointAttrToOptions:a.pointAttrToOptions,drawPoints:a.drawPoints,drawTracker:a.drawTracker,animate:a.animate,getColumnMetrics:a.getColumnMetrics})})();p.gauge=q(p.line,{dataLabels:{enabled:!0,defer:!1,y:15,borderWidth:1,borderColor:"silver",borderRadius:3,crop:!1,style:{fontWeight:"bold"},verticalAlign:"top",zIndex:2},dial:{},pivot:{},tooltip:{headerFormat:""},showInLegend:!1});z={type:"gauge",pointClass:v(H,{setState:function(a){this.state=a}}),angular:!0,drawGraph:u,fixedBox:!0,forceDL:!0, +trackerGroups:["group","dataLabelsGroup"],translate:function(){var a=this.yAxis,b=this.options,c=a.center;this.generatePoints();s(this.points,function(d){var e=q(b.dial,d.dial),f=x(o(e.radius,80))*c[2]/200,h=x(o(e.baseLength,70))*f/100,j=x(o(e.rearLength,10))*f/100,k=e.baseWidth||3,m=e.topWidth||1,i=b.overshoot,n=a.startAngleRad+a.translate(d.y,null,null,null,!0);i&&typeof i==="number"?(i=i/180*Math.PI,n=Math.max(a.startAngleRad-i,Math.min(a.endAngleRad+i,n))):b.wrap===!1&&(n=Math.max(a.startAngleRad, +Math.min(a.endAngleRad,n)));n=n*180/Math.PI;d.shapeType="path";d.shapeArgs={d:e.path||["M",-j,-k/2,"L",h,-k/2,f,-m/2,f,m/2,h,k/2,-j,k/2,"z"],translateX:c[0],translateY:c[1],rotation:n};d.plotX=c[0];d.plotY=c[1]})},drawPoints:function(){var a=this,b=a.yAxis.center,c=a.pivot,d=a.options,e=d.pivot,f=a.chart.renderer;s(a.points,function(c){var b=c.graphic,k=c.shapeArgs,e=k.d,i=q(d.dial,c.dial);b?(b.animate(k),k.d=e):c.graphic=f[c.shapeType](k).attr({stroke:i.borderColor||"none","stroke-width":i.borderWidth|| +0,fill:i.backgroundColor||"black",rotation:k.rotation}).add(a.group)});c?c.animate({translateX:b[0],translateY:b[1]}):a.pivot=f.circle(0,0,o(e.radius,5)).attr({"stroke-width":e.borderWidth||0,stroke:e.borderColor||"silver",fill:e.backgroundColor||"black"}).translate(b[0],b[1]).add(a.group)},animate:function(a){var b=this;if(!a)s(b.points,function(a){var d=a.graphic;d&&(d.attr({rotation:b.yAxis.startAngleRad*180/Math.PI}),d.animate({rotation:a.shapeArgs.rotation},b.options.animation))}),b.animate= +null},render:function(){this.group=this.plotGroup("group","series",this.visible?"visible":"hidden",this.options.zIndex,this.chart.seriesGroup);t.prototype.render.call(this);this.group.clip(this.chart.clipRect)},setData:function(a,b){t.prototype.setData.call(this,a,!1);this.processData();this.generatePoints();o(b,!0)&&this.chart.redraw()},drawTracker:z&&z.drawTrackerPoint};g.gauge=v(g.line,z);p.boxplot=q(p.column,{fillColor:"#FFFFFF",lineWidth:1,medianWidth:2,states:{hover:{brightness:-0.3}},threshold:null, +tooltip:{pointFormat:'<span style="color:{series.color}">●</span> <b> {series.name}</b><br/>Maximum: {point.high}<br/>Upper quartile: {point.q3}<br/>Median: {point.median}<br/>Lower quartile: {point.q1}<br/>Minimum: {point.low}<br/>'},whiskerLength:"50%",whiskerWidth:2});g.boxplot=v(g.column,{type:"boxplot",pointArrayMap:["low","q1","median","q3","high"],toYData:function(a){return[a.low,a.q1,a.median,a.q3,a.high]},pointValKey:"high",pointAttrToOptions:{fill:"fillColor",stroke:"color","stroke-width":"lineWidth"}, +drawDataLabels:u,translate:function(){var a=this.yAxis,b=this.pointArrayMap;g.column.prototype.translate.apply(this);s(this.points,function(c){s(b,function(b){c[b]!==null&&(c[b+"Plot"]=a.translate(c[b],0,1,0,1))})})},drawPoints:function(){var a=this,b=a.points,c=a.options,d=a.chart.renderer,e,f,h,j,k,m,i,n,g,l,p,I,r,q,J,u,v,t,w,x,z,y,E=a.doQuartiles!==!1,B=parseInt(a.options.whiskerLength,10)/100;s(b,function(b){g=b.graphic;z=b.shapeArgs;p={};q={};u={};y=b.color||a.color;if(b.plotY!==C)if(e=b.pointAttr[b.selected? +"selected":""],v=z.width,t=A(z.x),w=t+v,x=D(v/2),f=A(E?b.q1Plot:b.lowPlot),h=A(E?b.q3Plot:b.lowPlot),j=A(b.highPlot),k=A(b.lowPlot),p.stroke=b.stemColor||c.stemColor||y,p["stroke-width"]=o(b.stemWidth,c.stemWidth,c.lineWidth),p.dashstyle=b.stemDashStyle||c.stemDashStyle,q.stroke=b.whiskerColor||c.whiskerColor||y,q["stroke-width"]=o(b.whiskerWidth,c.whiskerWidth,c.lineWidth),u.stroke=b.medianColor||c.medianColor||y,u["stroke-width"]=o(b.medianWidth,c.medianWidth,c.lineWidth),u["stroke-linecap"]="round", +i=p["stroke-width"]%2/2,n=t+x+i,l=["M",n,h,"L",n,j,"M",n,f,"L",n,k],E&&(i=e["stroke-width"]%2/2,n=A(n)+i,f=A(f)+i,h=A(h)+i,t+=i,w+=i,I=["M",t,h,"L",t,f,"L",w,f,"L",w,h,"L",t,h,"z"]),B&&(i=q["stroke-width"]%2/2,j+=i,k+=i,r=["M",n-x*B,j,"L",n+x*B,j,"M",n-x*B,k,"L",n+x*B,k]),i=u["stroke-width"]%2/2,m=D(b.medianPlot)+i,J=["M",t,m,"L",w,m],g)b.stem.animate({d:l}),B&&b.whiskers.animate({d:r}),E&&b.box.animate({d:I}),b.medianShape.animate({d:J});else{b.graphic=g=d.g().add(a.group);b.stem=d.path(l).attr(p).add(g); +if(B)b.whiskers=d.path(r).attr(q).add(g);if(E)b.box=d.path(I).attr(e).add(g);b.medianShape=d.path(J).attr(u).add(g)}})}});p.errorbar=q(p.boxplot,{color:"#000000",grouping:!1,linkedTo:":previous",tooltip:{pointFormat:'<span style="color:{series.color}">●</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'},whiskerWidth:null});g.errorbar=v(g.boxplot,{type:"errorbar",pointArrayMap:["low","high"],toYData:function(a){return[a.low,a.high]},pointValKey:"high",doQuartiles:!1,drawDataLabels:g.arearange? +g.arearange.prototype.drawDataLabels:u,getColumnMetrics:function(){return this.linkedParent&&this.linkedParent.columnMetrics||g.column.prototype.getColumnMetrics.call(this)}});p.waterfall=q(p.column,{lineWidth:1,lineColor:"#333",dashStyle:"dot",borderColor:"#333",states:{hover:{lineWidthPlus:0}}});g.waterfall=v(g.column,{type:"waterfall",upColorProp:"fill",pointArrayMap:["low","y"],pointValKey:"y",init:function(a,b){b.stacking=!0;g.column.prototype.init.call(this,a,b)},translate:function(){var a= +this.yAxis,b,c,d,e,f,h,j,k,m,i;b=this.options.threshold;g.column.prototype.translate.apply(this);k=m=b;d=this.points;for(c=0,b=d.length;c<b;c++){e=d[c];f=e.shapeArgs;h=this.getStack(c);i=h.points[this.index+","+c];if(isNaN(e.y))e.y=this.yData[c];j=N(k,k+e.y)+i[0];f.y=a.translate(j,0,1);e.isSum?(f.y=a.translate(i[1],0,1),f.height=a.translate(i[0],0,1)-f.y):e.isIntermediateSum?(f.y=a.translate(i[1],0,1),f.height=a.translate(m,0,1)-f.y,m=i[1]):k+=h.total;f.height<0&&(f.y+=f.height,f.height*=-1);e.plotY= +f.y=D(f.y)-this.borderWidth%2/2;f.height=N(D(f.height),0.001);e.yBottom=f.y+f.height;f=e.plotY+(e.negative?f.height:0);this.chart.inverted?e.tooltipPos[0]=a.len-f:e.tooltipPos[1]=f}},processData:function(a){var b=this.yData,c=this.points,d,e=b.length,f,h,j,k,m,i;h=f=j=k=this.options.threshold||0;for(i=0;i<e;i++)m=b[i],d=c&&c[i]?c[i]:{},m==="sum"||d.isSum?b[i]=h:m==="intermediateSum"||d.isIntermediateSum?b[i]=f:(h+=m,f+=m),j=Math.min(h,j),k=Math.max(h,k);t.prototype.processData.call(this,a);this.dataMin= +j;this.dataMax=k},toYData:function(a){if(a.isSum)return a.x===0?null:"sum";else if(a.isIntermediateSum)return a.x===0?null:"intermediateSum";return a.y},getAttribs:function(){g.column.prototype.getAttribs.apply(this,arguments);var a=this.options,b=a.states,c=a.upColor||this.color,a=l.Color(c).brighten(0.1).get(),d=q(this.pointAttr),e=this.upColorProp;d[""][e]=c;d.hover[e]=b.hover.upColor||a;d.select[e]=b.select.upColor||c;s(this.points,function(a){if(a.y>0&&!a.color)a.pointAttr=d,a.color=c})},getGraphPath:function(){var a= +this.data,b=a.length,c=D(this.options.lineWidth+this.borderWidth)%2/2,d=[],e,f,h;for(h=1;h<b;h++)f=a[h].shapeArgs,e=a[h-1].shapeArgs,f=["M",e.x+e.width,e.y+c,"L",f.x,e.y+c],a[h-1].y<0&&(f[2]+=e.height,f[5]+=e.height),d=d.concat(f);return d},getExtremes:u,getStack:function(a){var b=this.yAxis.stacks,c=this.stackKey;this.processedYData[a]<this.options.threshold&&(c="-"+c);return b[c][a]},drawGraph:t.prototype.drawGraph});p.bubble=q(p.scatter,{dataLabels:{formatter:function(){return this.point.z},inside:!0, +style:{color:"white",textShadow:"0px 0px 3px black"},verticalAlign:"middle"},marker:{lineColor:null,lineWidth:1},minSize:8,maxSize:"20%",states:{hover:{halo:{size:5}}},tooltip:{pointFormat:"({point.x}, {point.y}), Size: {point.z}"},turboThreshold:0,zThreshold:0});z=v(H,{haloPath:function(){return H.prototype.haloPath.call(this,this.shapeArgs.r+this.series.options.states.hover.halo.size)}});g.bubble=v(g.scatter,{type:"bubble",pointClass:z,pointArrayMap:["y","z"],parallelArrays:["x","y","z"],trackerGroups:["group", +"dataLabelsGroup"],bubblePadding:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor"},applyOpacity:function(a){var b=this.options.marker,c=o(b.fillOpacity,0.5),a=a||b.fillColor||this.color;c!==1&&(a=U(a).setOpacity(c).get("rgba"));return a},convertAttribs:function(){var a=t.prototype.convertAttribs.apply(this,arguments);a.fill=this.applyOpacity(a.fill);return a},getRadii:function(a,b,c,d){var e,f,h,j=this.zData,k=[],m=this.options.sizeBy!=="width";for(f=0,e=j.length;f< +e;f++)h=b-a,h=h>0?(j[f]-a)/(b-a):0.5,m&&h>=0&&(h=Math.sqrt(h)),k.push(w.ceil(c+h*(d-c))/2);this.radii=k},animate:function(a){var b=this.options.animation;if(!a)s(this.points,function(a){var d=a.graphic,a=a.shapeArgs;d&&a&&(d.attr("r",1),d.animate({r:a.r},b))}),this.animate=null},translate:function(){var a,b=this.data,c,d,e=this.radii;g.scatter.prototype.translate.call(this);for(a=b.length;a--;)c=b[a],d=e?e[a]:0,c.negative=c.z<(this.options.zThreshold||0),d>=this.minPxSize/2?(c.shapeType="circle", +c.shapeArgs={x:c.plotX,y:c.plotY,r:d},c.dlBox={x:c.plotX-d,y:c.plotY-d,width:2*d,height:2*d}):c.shapeArgs=c.plotY=c.dlBox=C},drawLegendSymbol:function(a,b){var c=x(a.itemStyle.fontSize)/2;b.legendSymbol=this.chart.renderer.circle(c,a.baseline-c,c).attr({zIndex:3}).add(b.legendGroup);b.legendSymbol.isMarker=!0},drawPoints:g.column.prototype.drawPoints,alignDataLabel:g.column.prototype.alignDataLabel});M.prototype.beforePadding=function(){var a=this,b=this.len,c=this.chart,d=0,e=b,f=this.isXAxis,h= +f?"xData":"yData",j=this.min,k={},m=w.min(c.plotWidth,c.plotHeight),i=Number.MAX_VALUE,n=-Number.MAX_VALUE,g=this.max-j,l=b/g,p=[];this.tickPositions&&(s(this.series,function(b){var h=b.options;if(b.bubblePadding&&(b.visible||!c.options.chart.ignoreHiddenSeries))if(a.allowZoomOutside=!0,p.push(b),f)s(["minSize","maxSize"],function(a){var b=h[a],f=/%$/.test(b),b=x(b);k[a]=f?m*b/100:b}),b.minPxSize=k.minSize,b=b.zData,b.length&&(i=o(h.zMin,w.min(i,w.max(P(b),h.displayNegative===!1?h.zThreshold:-Number.MAX_VALUE))), +n=o(h.zMax,w.max(n,Q(b))))}),s(p,function(a){var b=a[h],c=b.length,m;f&&a.getRadii(i,n,k.minSize,k.maxSize);if(g>0)for(;c--;)typeof b[c]==="number"&&(m=a.radii[c],d=Math.min((b[c]-j)*l-m,d),e=Math.max((b[c]-j)*l+m,e))}),p.length&&g>0&&o(this.options.min,this.userMin)===C&&o(this.options.max,this.userMax)===C&&(e-=b,l*=(b+d-e)/b,this.min+=d/l,this.max+=e/l))};(function(){function a(a,b,c){a.call(this,b,c);if(this.chart.polar)this.closeSegment=function(a){var b=this.xAxis.center;a.push("L",b[0],b[1])}, +this.closedStacks=!0}function b(a,b){var c=this.chart,d=this.options.animation,e=this.group,i=this.markerGroup,n=this.xAxis.center,g=c.plotLeft,l=c.plotTop;if(c.polar){if(c.renderer.isSVG)d===!0&&(d={}),b?(c={translateX:n[0]+g,translateY:n[1]+l,scaleX:0.001,scaleY:0.001},e.attr(c),i&&i.attr(c)):(c={translateX:g,translateY:l,scaleX:1,scaleY:1},e.animate(c,d),i&&i.animate(c,d),this.animate=null)}else a.call(this,b)}var c=t.prototype,d=S.prototype,e;c.toXY=function(a){var b,c=this.chart,d=a.plotX;b= +a.plotY;a.rectPlotX=d;a.rectPlotY=b;d=(d/Math.PI*180+this.xAxis.pane.options.startAngle)%360;d<0&&(d+=360);a.clientX=d;b=this.xAxis.postTranslate(a.plotX,this.yAxis.len-b);a.plotX=a.polarPlotX=b.x-c.plotLeft;a.plotY=a.polarPlotY=b.y-c.plotTop};c.orderTooltipPoints=function(a){if(this.chart.polar&&(a.sort(function(a,b){return a.clientX-b.clientX}),a[0]))a[0].wrappedClientX=a[0].clientX+360,a.push(a[0])};g.area&&r(g.area.prototype,"init",a);g.areaspline&&r(g.areaspline.prototype,"init",a);g.spline&& +r(g.spline.prototype,"getPointSpline",function(a,b,c,d){var e,i,n,g,l,p,o;if(this.chart.polar){e=c.plotX;i=c.plotY;a=b[d-1];n=b[d+1];this.connectEnds&&(a||(a=b[b.length-2]),n||(n=b[1]));if(a&&n)g=a.plotX,l=a.plotY,b=n.plotX,p=n.plotY,g=(1.5*e+g)/2.5,l=(1.5*i+l)/2.5,n=(1.5*e+b)/2.5,o=(1.5*i+p)/2.5,b=Math.sqrt(Math.pow(g-e,2)+Math.pow(l-i,2)),p=Math.sqrt(Math.pow(n-e,2)+Math.pow(o-i,2)),g=Math.atan2(l-i,g-e),l=Math.atan2(o-i,n-e),o=Math.PI/2+(g+l)/2,Math.abs(g-o)>Math.PI/2&&(o-=Math.PI),g=e+Math.cos(o)* +b,l=i+Math.sin(o)*b,n=e+Math.cos(Math.PI+o)*p,o=i+Math.sin(Math.PI+o)*p,c.rightContX=n,c.rightContY=o;d?(c=["C",a.rightContX||a.plotX,a.rightContY||a.plotY,g||e,l||i,e,i],a.rightContX=a.rightContY=null):c=["M",e,i]}else c=a.call(this,b,c,d);return c});r(c,"translate",function(a){a.call(this);if(this.chart.polar&&!this.preventPostTranslate)for(var a=this.points,b=a.length;b--;)this.toXY(a[b])});r(c,"getSegmentPath",function(a,b){var c=this.points;if(this.chart.polar&&this.options.connectEnds!==!1&& +b[b.length-1]===c[c.length-1]&&c[0].y!==null)this.connectEnds=!0,b=[].concat(b,[c[0]]);return a.call(this,b)});r(c,"animate",b);r(c,"setTooltipPoints",function(a,b){this.chart.polar&&F(this.xAxis,{tooltipLen:360});return a.call(this,b)});if(g.column)e=g.column.prototype,r(e,"animate",b),r(e,"translate",function(a){var b=this.xAxis,c=this.yAxis.len,d=b.center,e=b.startAngleRad,i=this.chart.renderer,g,l;this.preventPostTranslate=!0;a.call(this);if(b.isRadial){b=this.points;for(l=b.length;l--;)g=b[l], +a=g.barX+e,g.shapeType="path",g.shapeArgs={d:i.symbols.arc(d[0],d[1],c-g.plotY,null,{start:a,end:a+g.pointWidth,innerR:c-o(g.yBottom,c)})},this.toXY(g),g.tooltipPos=[g.plotX,g.plotY],g.ttBelow=g.plotY>d[1]}}),r(e,"alignDataLabel",function(a,b,d,e,g,i){if(this.chart.polar){a=b.rectPlotX/Math.PI*180;if(e.align===null)e.align=a>20&&a<160?"left":a>200&&a<340?"right":"center";if(e.verticalAlign===null)e.verticalAlign=a<45||a>315?"bottom":a>135&&a<225?"top":"middle";c.alignDataLabel.call(this,b,d,e,g,i)}else a.call(this, +b,d,e,g,i)});r(d,"getIndex",function(a,b){var c,d=this.chart,e;d.polar?(e=d.xAxis[0].center,c=b.chartX-e[0]-d.plotLeft,d=b.chartY-e[1]-d.plotTop,c=180-Math.round(Math.atan2(c,d)/Math.PI*180)):c=a.call(this,b);return c});r(d,"getCoordinates",function(a,b){var c=this.chart,d={xAxis:[],yAxis:[]};c.polar?s(c.axes,function(a){var e=a.isXAxis,f=a.center,g=b.chartX-f[0]-c.plotLeft,f=b.chartY-f[1]-c.plotTop;d[e?"xAxis":"yAxis"].push({axis:a,value:a.translate(e?Math.PI-Math.atan2(g,f):Math.sqrt(Math.pow(g, +2)+Math.pow(f,2)),!0)})}):d=a.call(this,b);return d})})()})(Highcharts); diff --git a/html/includes/js/highcharts-more.src.js b/html/includes/js/highcharts-more.src.js new file mode 100644 index 0000000..df65b08 --- /dev/null +++ b/html/includes/js/highcharts-more.src.js @@ -0,0 +1,2575 @@ +// ==ClosureCompiler== +// @compilation_level SIMPLE_OPTIMIZATIONS + +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * + * (c) 2009-2014 Torstein Honsi + * + * License: www.highcharts.com/license + */ + +// JSLint options: +/*global Highcharts, HighchartsAdapter, document, window, navigator, setInterval, clearInterval, clearTimeout, setTimeout, location, jQuery, $, console */ + +(function (Highcharts, UNDEFINED) { +var arrayMin = Highcharts.arrayMin, + arrayMax = Highcharts.arrayMax, + each = Highcharts.each, + extend = Highcharts.extend, + merge = Highcharts.merge, + map = Highcharts.map, + pick = Highcharts.pick, + pInt = Highcharts.pInt, + defaultPlotOptions = Highcharts.getOptions().plotOptions, + seriesTypes = Highcharts.seriesTypes, + extendClass = Highcharts.extendClass, + splat = Highcharts.splat, + wrap = Highcharts.wrap, + Axis = Highcharts.Axis, + Tick = Highcharts.Tick, + Point = Highcharts.Point, + Pointer = Highcharts.Pointer, + CenteredSeriesMixin = Highcharts.CenteredSeriesMixin, + TrackerMixin = Highcharts.TrackerMixin, + Series = Highcharts.Series, + math = Math, + mathRound = math.round, + mathFloor = math.floor, + mathMax = math.max, + Color = Highcharts.Color, + noop = function () {};/** + * The Pane object allows options that are common to a set of X and Y axes. + * + * In the future, this can be extended to basic Highcharts and Highstock. + */ +function Pane(options, chart, firstAxis) { + this.init.call(this, options, chart, firstAxis); +} + +// Extend the Pane prototype +extend(Pane.prototype, { + + /** + * Initiate the Pane object + */ + init: function (options, chart, firstAxis) { + var pane = this, + backgroundOption, + defaultOptions = pane.defaultOptions; + + pane.chart = chart; + + // Set options + if (chart.angular) { // gauges + defaultOptions.background = {}; // gets extended by this.defaultBackgroundOptions + } + pane.options = options = merge(defaultOptions, options); + + backgroundOption = options.background; + + // To avoid having weighty logic to place, update and remove the backgrounds, + // push them to the first axis' plot bands and borrow the existing logic there. + if (backgroundOption) { + each([].concat(splat(backgroundOption)).reverse(), function (config) { + var backgroundColor = config.backgroundColor; // if defined, replace the old one (specific for gradients) + config = merge(pane.defaultBackgroundOptions, config); + if (backgroundColor) { + config.backgroundColor = backgroundColor; + } + config.color = config.backgroundColor; // due to naming in plotBands + firstAxis.options.plotBands.unshift(config); + }); + } + }, + + /** + * The default options object + */ + defaultOptions: { + // background: {conditional}, + center: ['50%', '50%'], + size: '85%', + startAngle: 0 + //endAngle: startAngle + 360 + }, + + /** + * The default background options + */ + defaultBackgroundOptions: { + shape: 'circle', + borderWidth: 1, + borderColor: 'silver', + backgroundColor: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0, '#FFF'], + [1, '#DDD'] + ] + }, + from: -Number.MAX_VALUE, // corrected to axis min + innerRadius: 0, + to: Number.MAX_VALUE, // corrected to axis max + outerRadius: '105%' + } + +}); +var axisProto = Axis.prototype, + tickProto = Tick.prototype; + +/** + * Augmented methods for the x axis in order to hide it completely, used for the X axis in gauges + */ +var hiddenAxisMixin = { + getOffset: noop, + redraw: function () { + this.isDirty = false; // prevent setting Y axis dirty + }, + render: function () { + this.isDirty = false; // prevent setting Y axis dirty + }, + setScale: noop, + setCategories: noop, + setTitle: noop +}; + +/** + * Augmented methods for the value axis + */ +/*jslint unparam: true*/ +var radialAxisMixin = { + isRadial: true, + + /** + * The default options extend defaultYAxisOptions + */ + defaultRadialGaugeOptions: { + labels: { + align: 'center', + x: 0, + y: null // auto + }, + minorGridLineWidth: 0, + minorTickInterval: 'auto', + minorTickLength: 10, + minorTickPosition: 'inside', + minorTickWidth: 1, + tickLength: 10, + tickPosition: 'inside', + tickWidth: 2, + title: { + rotation: 0 + }, + zIndex: 2 // behind dials, points in the series group + }, + + // Circular axis around the perimeter of a polar chart + defaultRadialXOptions: { + gridLineWidth: 1, // spokes + labels: { + align: null, // auto + distance: 15, + x: 0, + y: null // auto + }, + maxPadding: 0, + minPadding: 0, + showLastLabel: false, + tickLength: 0 + }, + + // Radial axis, like a spoke in a polar chart + defaultRadialYOptions: { + gridLineInterpolation: 'circle', + labels: { + align: 'right', + x: -3, + y: -2 + }, + showLastLabel: false, + title: { + x: 4, + text: null, + rotation: 90 + } + }, + + /** + * Merge and set options + */ + setOptions: function (userOptions) { + + var options = this.options = merge( + this.defaultOptions, + this.defaultRadialOptions, + userOptions + ); + + // Make sure the plotBands array is instanciated for each Axis (#2649) + if (!options.plotBands) { + options.plotBands = []; + } + + }, + + /** + * Wrap the getOffset method to return zero offset for title or labels in a radial + * axis + */ + getOffset: function () { + // Call the Axis prototype method (the method we're in now is on the instance) + axisProto.getOffset.call(this); + + // Title or label offsets are not counted + this.chart.axisOffset[this.side] = 0; + + // Set the center array + this.center = this.pane.center = CenteredSeriesMixin.getCenter.call(this.pane); + }, + + + /** + * Get the path for the axis line. This method is also referenced in the getPlotLinePath + * method. + */ + getLinePath: function (lineWidth, radius) { + var center = this.center; + radius = pick(radius, center[2] / 2 - this.offset); + + return this.chart.renderer.symbols.arc( + this.left + center[0], + this.top + center[1], + radius, + radius, + { + start: this.startAngleRad, + end: this.endAngleRad, + open: true, + innerR: 0 + } + ); + }, + + /** + * Override setAxisTranslation by setting the translation to the difference + * in rotation. This allows the translate method to return angle for + * any given value. + */ + setAxisTranslation: function () { + + // Call uber method + axisProto.setAxisTranslation.call(this); + + // Set transA and minPixelPadding + if (this.center) { // it's not defined the first time + if (this.isCircular) { + + this.transA = (this.endAngleRad - this.startAngleRad) / + ((this.max - this.min) || 1); + + + } else { + this.transA = (this.center[2] / 2) / ((this.max - this.min) || 1); + } + + if (this.isXAxis) { + this.minPixelPadding = this.transA * this.minPointOffset; + } else { + // This is a workaround for regression #2593, but categories still don't position correctly. + // TODO: Implement true handling of Y axis categories on gauges. + this.minPixelPadding = 0; + } + } + }, + + /** + * In case of auto connect, add one closestPointRange to the max value right before + * tickPositions are computed, so that ticks will extend passed the real max. + */ + beforeSetTickPositions: function () { + if (this.autoConnect) { + this.max += (this.categories && 1) || this.pointRange || this.closestPointRange || 0; // #1197, #2260 + } + }, + + /** + * Override the setAxisSize method to use the arc's circumference as length. This + * allows tickPixelInterval to apply to pixel lengths along the perimeter + */ + setAxisSize: function () { + + axisProto.setAxisSize.call(this); + + if (this.isRadial) { + + // Set the center array + this.center = this.pane.center = Highcharts.CenteredSeriesMixin.getCenter.call(this.pane); + + // The sector is used in Axis.translate to compute the translation of reversed axis points (#2570) + if (this.isCircular) { + this.sector = this.endAngleRad - this.startAngleRad; + } + + // Axis len is used to lay out the ticks + this.len = this.width = this.height = this.center[2] * pick(this.sector, 1) / 2; + + + } + }, + + /** + * Returns the x, y coordinate of a point given by a value and a pixel distance + * from center + */ + getPosition: function (value, length) { + return this.postTranslate( + this.isCircular ? this.translate(value) : 0, // #2848 + pick(this.isCircular ? length : this.translate(value), this.center[2] / 2) - this.offset + ); + }, + + /** + * Translate from intermediate plotX (angle), plotY (axis.len - radius) to final chart coordinates. + */ + postTranslate: function (angle, radius) { + + var chart = this.chart, + center = this.center; + + angle = this.startAngleRad + angle; + + return { + x: chart.plotLeft + center[0] + Math.cos(angle) * radius, + y: chart.plotTop + center[1] + Math.sin(angle) * radius + }; + + }, + + /** + * Find the path for plot bands along the radial axis + */ + getPlotBandPath: function (from, to, options) { + var center = this.center, + startAngleRad = this.startAngleRad, + fullRadius = center[2] / 2, + radii = [ + pick(options.outerRadius, '100%'), + options.innerRadius, + pick(options.thickness, 10) + ], + percentRegex = /%$/, + start, + end, + open, + isCircular = this.isCircular, // X axis in a polar chart + ret; + + // Polygonal plot bands + if (this.options.gridLineInterpolation === 'polygon') { + ret = this.getPlotLinePath(from).concat(this.getPlotLinePath(to, true)); + + // Circular grid bands + } else { + + // Plot bands on Y axis (radial axis) - inner and outer radius depend on to and from + if (!isCircular) { + radii[0] = this.translate(from); + radii[1] = this.translate(to); + } + + // Convert percentages to pixel values + radii = map(radii, function (radius) { + if (percentRegex.test(radius)) { + radius = (pInt(radius, 10) * fullRadius) / 100; + } + return radius; + }); + + // Handle full circle + if (options.shape === 'circle' || !isCircular) { + start = -Math.PI / 2; + end = Math.PI * 1.5; + open = true; + } else { + start = startAngleRad + this.translate(from); + end = startAngleRad + this.translate(to); + } + + + ret = this.chart.renderer.symbols.arc( + this.left + center[0], + this.top + center[1], + radii[0], + radii[0], + { + start: start, + end: end, + innerR: pick(radii[1], radii[0] - radii[2]), + open: open + } + ); + } + + return ret; + }, + + /** + * Find the path for plot lines perpendicular to the radial axis. + */ + getPlotLinePath: function (value, reverse) { + var axis = this, + center = axis.center, + chart = axis.chart, + end = axis.getPosition(value), + xAxis, + xy, + tickPositions, + ret; + + // Spokes + if (axis.isCircular) { + ret = ['M', center[0] + chart.plotLeft, center[1] + chart.plotTop, 'L', end.x, end.y]; + + // Concentric circles + } else if (axis.options.gridLineInterpolation === 'circle') { + value = axis.translate(value); + if (value) { // a value of 0 is in the center + ret = axis.getLinePath(0, value); + } + // Concentric polygons + } else { + // Find the X axis in the same pane + each(chart.xAxis, function (a) { + if (a.pane === axis.pane) { + xAxis = a; + } + }); + ret = []; + value = axis.translate(value); + tickPositions = xAxis.tickPositions; + if (xAxis.autoConnect) { + tickPositions = tickPositions.concat([tickPositions[0]]); + } + // Reverse the positions for concatenation of polygonal plot bands + if (reverse) { + tickPositions = [].concat(tickPositions).reverse(); + } + + each(tickPositions, function (pos, i) { + xy = xAxis.getPosition(pos, value); + ret.push(i ? 'L' : 'M', xy.x, xy.y); + }); + + } + return ret; + }, + + /** + * Find the position for the axis title, by default inside the gauge + */ + getTitlePosition: function () { + var center = this.center, + chart = this.chart, + titleOptions = this.options.title; + + return { + x: chart.plotLeft + center[0] + (titleOptions.x || 0), + y: chart.plotTop + center[1] - ({ high: 0.5, middle: 0.25, low: 0 }[titleOptions.align] * + center[2]) + (titleOptions.y || 0) + }; + } + +}; +/*jslint unparam: false*/ + +/** + * Override axisProto.init to mix in special axis instance functions and function overrides + */ +wrap(axisProto, 'init', function (proceed, chart, userOptions) { + var axis = this, + angular = chart.angular, + polar = chart.polar, + isX = userOptions.isX, + isHidden = angular && isX, + isCircular, + startAngleRad, + endAngleRad, + options, + chartOptions = chart.options, + paneIndex = userOptions.pane || 0, + pane, + paneOptions; + + // Before prototype.init + if (angular) { + extend(this, isHidden ? hiddenAxisMixin : radialAxisMixin); + isCircular = !isX; + if (isCircular) { + this.defaultRadialOptions = this.defaultRadialGaugeOptions; + } + + } else if (polar) { + //extend(this, userOptions.isX ? radialAxisMixin : radialAxisMixin); + extend(this, radialAxisMixin); + isCircular = isX; + this.defaultRadialOptions = isX ? this.defaultRadialXOptions : merge(this.defaultYAxisOptions, this.defaultRadialYOptions); + + } + + // Run prototype.init + proceed.call(this, chart, userOptions); + + if (!isHidden && (angular || polar)) { + options = this.options; + + // Create the pane and set the pane options. + if (!chart.panes) { + chart.panes = []; + } + this.pane = pane = chart.panes[paneIndex] = chart.panes[paneIndex] || new Pane( + splat(chartOptions.pane)[paneIndex], + chart, + axis + ); + paneOptions = pane.options; + + + // Disable certain features on angular and polar axes + chart.inverted = false; + chartOptions.chart.zoomType = null; + + // Start and end angle options are + // given in degrees relative to top, while internal computations are + // in radians relative to right (like SVG). + this.startAngleRad = startAngleRad = (paneOptions.startAngle - 90) * Math.PI / 180; + this.endAngleRad = endAngleRad = (pick(paneOptions.endAngle, paneOptions.startAngle + 360) - 90) * Math.PI / 180; + this.offset = options.offset || 0; + + this.isCircular = isCircular; + + // Automatically connect grid lines? + if (isCircular && userOptions.max === UNDEFINED && endAngleRad - startAngleRad === 2 * Math.PI) { + this.autoConnect = true; + } + } + +}); + +/** + * Add special cases within the Tick class' methods for radial axes. + */ +wrap(tickProto, 'getPosition', function (proceed, horiz, pos, tickmarkOffset, old) { + var axis = this.axis; + + return axis.getPosition ? + axis.getPosition(pos) : + proceed.call(this, horiz, pos, tickmarkOffset, old); +}); + +/** + * Wrap the getLabelPosition function to find the center position of the label + * based on the distance option + */ +wrap(tickProto, 'getLabelPosition', function (proceed, x, y, label, horiz, labelOptions, tickmarkOffset, index, step) { + var axis = this.axis, + optionsY = labelOptions.y, + ret, + align = labelOptions.align, + angle = ((axis.translate(this.pos) + axis.startAngleRad + Math.PI / 2) / Math.PI * 180) % 360; + + if (axis.isRadial) { + ret = axis.getPosition(this.pos, (axis.center[2] / 2) + pick(labelOptions.distance, -25)); + + // Automatically rotated + if (labelOptions.rotation === 'auto') { + label.attr({ + rotation: angle + }); + + // Vertically centered + } else if (optionsY === null) { + optionsY = axis.chart.renderer.fontMetrics(label.styles.fontSize).b - label.getBBox().height / 2; + } + + // Automatic alignment + if (align === null) { + if (axis.isCircular) { + if (angle > 20 && angle < 160) { + align = 'left'; // right hemisphere + } else if (angle > 200 && angle < 340) { + align = 'right'; // left hemisphere + } else { + align = 'center'; // top or bottom + } + } else { + align = 'center'; + } + label.attr({ + align: align + }); + } + + ret.x += labelOptions.x; + ret.y += optionsY; + + } else { + ret = proceed.call(this, x, y, label, horiz, labelOptions, tickmarkOffset, index, step); + } + return ret; +}); + +/** + * Wrap the getMarkPath function to return the path of the radial marker + */ +wrap(tickProto, 'getMarkPath', function (proceed, x, y, tickLength, tickWidth, horiz, renderer) { + var axis = this.axis, + endPoint, + ret; + + if (axis.isRadial) { + endPoint = axis.getPosition(this.pos, axis.center[2] / 2 + tickLength); + ret = [ + 'M', + x, + y, + 'L', + endPoint.x, + endPoint.y + ]; + } else { + ret = proceed.call(this, x, y, tickLength, tickWidth, horiz, renderer); + } + return ret; +});/* + * The AreaRangeSeries class + * + */ + +/** + * Extend the default options with map options + */ +defaultPlotOptions.arearange = merge(defaultPlotOptions.area, { + lineWidth: 1, + marker: null, + threshold: null, + tooltip: { + pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>' + }, + trackByArea: true, + dataLabels: { + align: null, + verticalAlign: null, + xLow: 0, + xHigh: 0, + yLow: 0, + yHigh: 0 + }, + states: { + hover: { + halo: false + } + } +}); + +/** + * Add the series type + */ +seriesTypes.arearange = extendClass(seriesTypes.area, { + type: 'arearange', + pointArrayMap: ['low', 'high'], + toYData: function (point) { + return [point.low, point.high]; + }, + pointValKey: 'low', + + /** + * Extend getSegments to force null points if the higher value is null. #1703. + */ + getSegments: function () { + var series = this; + + each(series.points, function (point) { + if (!series.options.connectNulls && (point.low === null || point.high === null)) { + point.y = null; + } else if (point.low === null && point.high !== null) { + point.y = point.high; + } + }); + Series.prototype.getSegments.call(this); + }, + + /** + * Translate data points from raw values x and y to plotX and plotY + */ + translate: function () { + var series = this, + yAxis = series.yAxis; + + seriesTypes.area.prototype.translate.apply(series); + + // Set plotLow and plotHigh + each(series.points, function (point) { + + var low = point.low, + high = point.high, + plotY = point.plotY; + + if (high === null && low === null) { + point.y = null; + } else if (low === null) { + point.plotLow = point.plotY = null; + point.plotHigh = yAxis.translate(high, 0, 1, 0, 1); + } else if (high === null) { + point.plotLow = plotY; + point.plotHigh = null; + } else { + point.plotLow = plotY; + point.plotHigh = yAxis.translate(high, 0, 1, 0, 1); + } + }); + }, + + /** + * Extend the line series' getSegmentPath method by applying the segment + * path to both lower and higher values of the range + */ + getSegmentPath: function (segment) { + + var lowSegment, + highSegment = [], + i = segment.length, + baseGetSegmentPath = Series.prototype.getSegmentPath, + point, + linePath, + lowerPath, + options = this.options, + step = options.step, + higherPath; + + // Remove nulls from low segment + lowSegment = HighchartsAdapter.grep(segment, function (point) { + return point.plotLow !== null; + }); + + // Make a segment with plotX and plotY for the top values + while (i--) { + point = segment[i]; + if (point.plotHigh !== null) { + highSegment.push({ + plotX: point.plotX, + plotY: point.plotHigh + }); + } + } + + // Get the paths + lowerPath = baseGetSegmentPath.call(this, lowSegment); + if (step) { + if (step === true) { + step = 'left'; + } + options.step = { left: 'right', center: 'center', right: 'left' }[step]; // swap for reading in getSegmentPath + } + higherPath = baseGetSegmentPath.call(this, highSegment); + options.step = step; + + // Create a line on both top and bottom of the range + linePath = [].concat(lowerPath, higherPath); + + // For the area path, we need to change the 'move' statement into 'lineTo' or 'curveTo' + higherPath[0] = 'L'; // this probably doesn't work for spline + this.areaPath = this.areaPath.concat(lowerPath, higherPath); + + return linePath; + }, + + /** + * Extend the basic drawDataLabels method by running it for both lower and higher + * values. + */ + drawDataLabels: function () { + + var data = this.data, + length = data.length, + i, + originalDataLabels = [], + seriesProto = Series.prototype, + dataLabelOptions = this.options.dataLabels, + align = dataLabelOptions.align, + point, + inverted = this.chart.inverted; + + if (dataLabelOptions.enabled || this._hasPointLabels) { + + // Step 1: set preliminary values for plotY and dataLabel and draw the upper labels + i = length; + while (i--) { + point = data[i]; + + // Set preliminary values + point.y = point.high; + point._plotY = point.plotY; + point.plotY = point.plotHigh; + + // Store original data labels and set preliminary label objects to be picked up + // in the uber method + originalDataLabels[i] = point.dataLabel; + point.dataLabel = point.dataLabelUpper; + + // Set the default offset + point.below = false; + if (inverted) { + if (!align) { + dataLabelOptions.align = 'left'; + } + dataLabelOptions.x = dataLabelOptions.xHigh; + } else { + dataLabelOptions.y = dataLabelOptions.yHigh; + } + } + + if (seriesProto.drawDataLabels) { + seriesProto.drawDataLabels.apply(this, arguments); // #1209 + } + + // Step 2: reorganize and handle data labels for the lower values + i = length; + while (i--) { + point = data[i]; + + // Move the generated labels from step 1, and reassign the original data labels + point.dataLabelUpper = point.dataLabel; + point.dataLabel = originalDataLabels[i]; + + // Reset values + point.y = point.low; + point.plotY = point._plotY; + + // Set the default offset + point.below = true; + if (inverted) { + if (!align) { + dataLabelOptions.align = 'right'; + } + dataLabelOptions.x = dataLabelOptions.xLow; + } else { + dataLabelOptions.y = dataLabelOptions.yLow; + } + } + if (seriesProto.drawDataLabels) { + seriesProto.drawDataLabels.apply(this, arguments); + } + } + + dataLabelOptions.align = align; + + }, + + alignDataLabel: function () { + seriesTypes.column.prototype.alignDataLabel.apply(this, arguments); + }, + + getSymbol: noop, + + drawPoints: noop +});/** + * The AreaSplineRangeSeries class + */ + +defaultPlotOptions.areasplinerange = merge(defaultPlotOptions.arearange); + +/** + * AreaSplineRangeSeries object + */ +seriesTypes.areasplinerange = extendClass(seriesTypes.arearange, { + type: 'areasplinerange', + getPointSpline: seriesTypes.spline.prototype.getPointSpline +}); + +(function () { + + var colProto = seriesTypes.column.prototype; + + /** + * The ColumnRangeSeries class + */ + defaultPlotOptions.columnrange = merge(defaultPlotOptions.column, defaultPlotOptions.arearange, { + lineWidth: 1, + pointRange: null + }); + + /** + * ColumnRangeSeries object + */ + seriesTypes.columnrange = extendClass(seriesTypes.arearange, { + type: 'columnrange', + /** + * Translate data points from raw values x and y to plotX and plotY + */ + translate: function () { + var series = this, + yAxis = series.yAxis, + plotHigh; + + colProto.translate.apply(series); + + // Set plotLow and plotHigh + each(series.points, function (point) { + var shapeArgs = point.shapeArgs, + minPointLength = series.options.minPointLength, + heightDifference, + height, + y; + + point.tooltipPos = null; // don't inherit from column + point.plotHigh = plotHigh = yAxis.translate(point.high, 0, 1, 0, 1); + point.plotLow = point.plotY; + + // adjust shape + y = plotHigh; + height = point.plotY - plotHigh; + + if (height < minPointLength) { + heightDifference = (minPointLength - height); + height += heightDifference; + y -= heightDifference / 2; + } + shapeArgs.height = height; + shapeArgs.y = y; + }); + }, + trackerGroups: ['group', 'dataLabelsGroup'], + drawGraph: noop, + pointAttrToOptions: colProto.pointAttrToOptions, + drawPoints: colProto.drawPoints, + drawTracker: colProto.drawTracker, + animate: colProto.animate, + getColumnMetrics: colProto.getColumnMetrics + }); +}()); + +/* + * The GaugeSeries class + */ + + + +/** + * Extend the default options + */ +defaultPlotOptions.gauge = merge(defaultPlotOptions.line, { + dataLabels: { + enabled: true, + defer: false, + y: 15, + borderWidth: 1, + borderColor: 'silver', + borderRadius: 3, + crop: false, + style: { + fontWeight: 'bold' + }, + verticalAlign: 'top', + zIndex: 2 + }, + dial: { + // radius: '80%', + // backgroundColor: 'black', + // borderColor: 'silver', + // borderWidth: 0, + // baseWidth: 3, + // topWidth: 1, + // baseLength: '70%' // of radius + // rearLength: '10%' + }, + pivot: { + //radius: 5, + //borderWidth: 0 + //borderColor: 'silver', + //backgroundColor: 'black' + }, + tooltip: { + headerFormat: '' + }, + showInLegend: false +}); + +/** + * Extend the point object + */ +var GaugePoint = extendClass(Point, { + /** + * Don't do any hover colors or anything + */ + setState: function (state) { + this.state = state; + } +}); + + +/** + * Add the series type + */ +var GaugeSeries = { + type: 'gauge', + pointClass: GaugePoint, + + // chart.angular will be set to true when a gauge series is present, and this will + // be used on the axes + angular: true, + drawGraph: noop, + fixedBox: true, + forceDL: true, + trackerGroups: ['group', 'dataLabelsGroup'], + + /** + * Calculate paths etc + */ + translate: function () { + + var series = this, + yAxis = series.yAxis, + options = series.options, + center = yAxis.center; + + series.generatePoints(); + + each(series.points, function (point) { + + var dialOptions = merge(options.dial, point.dial), + radius = (pInt(pick(dialOptions.radius, 80)) * center[2]) / 200, + baseLength = (pInt(pick(dialOptions.baseLength, 70)) * radius) / 100, + rearLength = (pInt(pick(dialOptions.rearLength, 10)) * radius) / 100, + baseWidth = dialOptions.baseWidth || 3, + topWidth = dialOptions.topWidth || 1, + overshoot = options.overshoot, + rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true); + + // Handle the wrap and overshoot options + if (overshoot && typeof overshoot === 'number') { + overshoot = overshoot / 180 * Math.PI; + rotation = Math.max(yAxis.startAngleRad - overshoot, Math.min(yAxis.endAngleRad + overshoot, rotation)); + + } else if (options.wrap === false) { + rotation = Math.max(yAxis.startAngleRad, Math.min(yAxis.endAngleRad, rotation)); + } + + rotation = rotation * 180 / Math.PI; + + point.shapeType = 'path'; + point.shapeArgs = { + d: dialOptions.path || [ + 'M', + -rearLength, -baseWidth / 2, + 'L', + baseLength, -baseWidth / 2, + radius, -topWidth / 2, + radius, topWidth / 2, + baseLength, baseWidth / 2, + -rearLength, baseWidth / 2, + 'z' + ], + translateX: center[0], + translateY: center[1], + rotation: rotation + }; + + // Positions for data label + point.plotX = center[0]; + point.plotY = center[1]; + }); + }, + + /** + * Draw the points where each point is one needle + */ + drawPoints: function () { + + var series = this, + center = series.yAxis.center, + pivot = series.pivot, + options = series.options, + pivotOptions = options.pivot, + renderer = series.chart.renderer; + + each(series.points, function (point) { + + var graphic = point.graphic, + shapeArgs = point.shapeArgs, + d = shapeArgs.d, + dialOptions = merge(options.dial, point.dial); // #1233 + + if (graphic) { + graphic.animate(shapeArgs); + shapeArgs.d = d; // animate alters it + } else { + point.graphic = renderer[point.shapeType](shapeArgs) + .attr({ + stroke: dialOptions.borderColor || 'none', + 'stroke-width': dialOptions.borderWidth || 0, + fill: dialOptions.backgroundColor || 'black', + rotation: shapeArgs.rotation // required by VML when animation is false + }) + .add(series.group); + } + }); + + // Add or move the pivot + if (pivot) { + pivot.animate({ // #1235 + translateX: center[0], + translateY: center[1] + }); + } else { + series.pivot = renderer.circle(0, 0, pick(pivotOptions.radius, 5)) + .attr({ + 'stroke-width': pivotOptions.borderWidth || 0, + stroke: pivotOptions.borderColor || 'silver', + fill: pivotOptions.backgroundColor || 'black' + }) + .translate(center[0], center[1]) + .add(series.group); + } + }, + + /** + * Animate the arrow up from startAngle + */ + animate: function (init) { + var series = this; + + if (!init) { + each(series.points, function (point) { + var graphic = point.graphic; + + if (graphic) { + // start value + graphic.attr({ + rotation: series.yAxis.startAngleRad * 180 / Math.PI + }); + + // animate + graphic.animate({ + rotation: point.shapeArgs.rotation + }, series.options.animation); + } + }); + + // delete this function to allow it only once + series.animate = null; + } + }, + + render: function () { + this.group = this.plotGroup( + 'group', + 'series', + this.visible ? 'visible' : 'hidden', + this.options.zIndex, + this.chart.seriesGroup + ); + Series.prototype.render.call(this); + this.group.clip(this.chart.clipRect); + }, + + /** + * Extend the basic setData method by running processData and generatePoints immediately, + * in order to access the points from the legend. + */ + setData: function (data, redraw) { + Series.prototype.setData.call(this, data, false); + this.processData(); + this.generatePoints(); + if (pick(redraw, true)) { + this.chart.redraw(); + } + }, + + /** + * If the tracking module is loaded, add the point tracker + */ + drawTracker: TrackerMixin && TrackerMixin.drawTrackerPoint +}; +seriesTypes.gauge = extendClass(seriesTypes.line, GaugeSeries); + +/* **************************************************************************** + * Start Box plot series code * + *****************************************************************************/ + +// Set default options +defaultPlotOptions.boxplot = merge(defaultPlotOptions.column, { + fillColor: '#FFFFFF', + lineWidth: 1, + //medianColor: null, + medianWidth: 2, + states: { + hover: { + brightness: -0.3 + } + }, + //stemColor: null, + //stemDashStyle: 'solid' + //stemWidth: null, + threshold: null, + tooltip: { + pointFormat: '<span style="color:{series.color}">\u25CF</span> <b> {series.name}</b><br/>' + + 'Maximum: {point.high}<br/>' + + 'Upper quartile: {point.q3}<br/>' + + 'Median: {point.median}<br/>' + + 'Lower quartile: {point.q1}<br/>' + + 'Minimum: {point.low}<br/>' + + }, + //whiskerColor: null, + whiskerLength: '50%', + whiskerWidth: 2 +}); + +// Create the series object +seriesTypes.boxplot = extendClass(seriesTypes.column, { + type: 'boxplot', + pointArrayMap: ['low', 'q1', 'median', 'q3', 'high'], // array point configs are mapped to this + toYData: function (point) { // return a plain array for speedy calculation + return [point.low, point.q1, point.median, point.q3, point.high]; + }, + pointValKey: 'high', // defines the top of the tracker + + /** + * One-to-one mapping from options to SVG attributes + */ + pointAttrToOptions: { // mapping between SVG attributes and the corresponding options + fill: 'fillColor', + stroke: 'color', + 'stroke-width': 'lineWidth' + }, + + /** + * Disable data labels for box plot + */ + drawDataLabels: noop, + + /** + * Translate data points from raw values x and y to plotX and plotY + */ + translate: function () { + var series = this, + yAxis = series.yAxis, + pointArrayMap = series.pointArrayMap; + + seriesTypes.column.prototype.translate.apply(series); + + // do the translation on each point dimension + each(series.points, function (point) { + each(pointArrayMap, function (key) { + if (point[key] !== null) { + point[key + 'Plot'] = yAxis.translate(point[key], 0, 1, 0, 1); + } + }); + }); + }, + + /** + * Draw the data points + */ + drawPoints: function () { + var series = this, //state = series.state, + points = series.points, + options = series.options, + chart = series.chart, + renderer = chart.renderer, + pointAttr, + q1Plot, + q3Plot, + highPlot, + lowPlot, + medianPlot, + crispCorr, + crispX, + graphic, + stemPath, + stemAttr, + boxPath, + whiskersPath, + whiskersAttr, + medianPath, + medianAttr, + width, + left, + right, + halfWidth, + shapeArgs, + color, + doQuartiles = series.doQuartiles !== false, // error bar inherits this series type but doesn't do quartiles + whiskerLength = parseInt(series.options.whiskerLength, 10) / 100; + + + each(points, function (point) { + + graphic = point.graphic; + shapeArgs = point.shapeArgs; // the box + stemAttr = {}; + whiskersAttr = {}; + medianAttr = {}; + color = point.color || series.color; + + if (point.plotY !== UNDEFINED) { + + pointAttr = point.pointAttr[point.selected ? 'selected' : '']; + + // crisp vector coordinates + width = shapeArgs.width; + left = mathFloor(shapeArgs.x); + right = left + width; + halfWidth = mathRound(width / 2); + //crispX = mathRound(left + halfWidth) + crispCorr; + q1Plot = mathFloor(doQuartiles ? point.q1Plot : point.lowPlot);// + crispCorr; + q3Plot = mathFloor(doQuartiles ? point.q3Plot : point.lowPlot);// + crispCorr; + highPlot = mathFloor(point.highPlot);// + crispCorr; + lowPlot = mathFloor(point.lowPlot);// + crispCorr; + + // Stem attributes + stemAttr.stroke = point.stemColor || options.stemColor || color; + stemAttr['stroke-width'] = pick(point.stemWidth, options.stemWidth, options.lineWidth); + stemAttr.dashstyle = point.stemDashStyle || options.stemDashStyle; + + // Whiskers attributes + whiskersAttr.stroke = point.whiskerColor || options.whiskerColor || color; + whiskersAttr['stroke-width'] = pick(point.whiskerWidth, options.whiskerWidth, options.lineWidth); + + // Median attributes + medianAttr.stroke = point.medianColor || options.medianColor || color; + medianAttr['stroke-width'] = pick(point.medianWidth, options.medianWidth, options.lineWidth); + medianAttr['stroke-linecap'] = 'round'; // #1638 + + + // The stem + crispCorr = (stemAttr['stroke-width'] % 2) / 2; + crispX = left + halfWidth + crispCorr; + stemPath = [ + // stem up + 'M', + crispX, q3Plot, + 'L', + crispX, highPlot, + + // stem down + 'M', + crispX, q1Plot, + 'L', + crispX, lowPlot + ]; + + // The box + if (doQuartiles) { + crispCorr = (pointAttr['stroke-width'] % 2) / 2; + crispX = mathFloor(crispX) + crispCorr; + q1Plot = mathFloor(q1Plot) + crispCorr; + q3Plot = mathFloor(q3Plot) + crispCorr; + left += crispCorr; + right += crispCorr; + boxPath = [ + 'M', + left, q3Plot, + 'L', + left, q1Plot, + 'L', + right, q1Plot, + 'L', + right, q3Plot, + 'L', + left, q3Plot, + 'z' + ]; + } + + // The whiskers + if (whiskerLength) { + crispCorr = (whiskersAttr['stroke-width'] % 2) / 2; + highPlot = highPlot + crispCorr; + lowPlot = lowPlot + crispCorr; + whiskersPath = [ + // High whisker + 'M', + crispX - halfWidth * whiskerLength, + highPlot, + 'L', + crispX + halfWidth * whiskerLength, + highPlot, + + // Low whisker + 'M', + crispX - halfWidth * whiskerLength, + lowPlot, + 'L', + crispX + halfWidth * whiskerLength, + lowPlot + ]; + } + + // The median + crispCorr = (medianAttr['stroke-width'] % 2) / 2; + medianPlot = mathRound(point.medianPlot) + crispCorr; + medianPath = [ + 'M', + left, + medianPlot, + 'L', + right, + medianPlot + ]; + + // Create or update the graphics + if (graphic) { // update + + point.stem.animate({ d: stemPath }); + if (whiskerLength) { + point.whiskers.animate({ d: whiskersPath }); + } + if (doQuartiles) { + point.box.animate({ d: boxPath }); + } + point.medianShape.animate({ d: medianPath }); + + } else { // create new + point.graphic = graphic = renderer.g() + .add(series.group); + + point.stem = renderer.path(stemPath) + .attr(stemAttr) + .add(graphic); + + if (whiskerLength) { + point.whiskers = renderer.path(whiskersPath) + .attr(whiskersAttr) + .add(graphic); + } + if (doQuartiles) { + point.box = renderer.path(boxPath) + .attr(pointAttr) + .add(graphic); + } + point.medianShape = renderer.path(medianPath) + .attr(medianAttr) + .add(graphic); + } + } + }); + + } + + +}); + +/* **************************************************************************** + * End Box plot series code * + *****************************************************************************/ +/* **************************************************************************** + * Start error bar series code * + *****************************************************************************/ + +// 1 - set default options +defaultPlotOptions.errorbar = merge(defaultPlotOptions.boxplot, { + color: '#000000', + grouping: false, + linkedTo: ':previous', + tooltip: { + pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>' + }, + whiskerWidth: null +}); + +// 2 - Create the series object +seriesTypes.errorbar = extendClass(seriesTypes.boxplot, { + type: 'errorbar', + pointArrayMap: ['low', 'high'], // array point configs are mapped to this + toYData: function (point) { // return a plain array for speedy calculation + return [point.low, point.high]; + }, + pointValKey: 'high', // defines the top of the tracker + doQuartiles: false, + drawDataLabels: seriesTypes.arearange ? seriesTypes.arearange.prototype.drawDataLabels : noop, + + /** + * Get the width and X offset, either on top of the linked series column + * or standalone + */ + getColumnMetrics: function () { + return (this.linkedParent && this.linkedParent.columnMetrics) || + seriesTypes.column.prototype.getColumnMetrics.call(this); + } +}); + +/* **************************************************************************** + * End error bar series code * + *****************************************************************************/ +/* **************************************************************************** + * Start Waterfall series code * + *****************************************************************************/ + +// 1 - set default options +defaultPlotOptions.waterfall = merge(defaultPlotOptions.column, { + lineWidth: 1, + lineColor: '#333', + dashStyle: 'dot', + borderColor: '#333', + states: { + hover: { + lineWidthPlus: 0 // #3126 + } + } +}); + + +// 2 - Create the series object +seriesTypes.waterfall = extendClass(seriesTypes.column, { + type: 'waterfall', + + upColorProp: 'fill', + + pointArrayMap: ['low', 'y'], + + pointValKey: 'y', + + /** + * Init waterfall series, force stacking + */ + init: function (chart, options) { + // force stacking + options.stacking = true; + + seriesTypes.column.prototype.init.call(this, chart, options); + }, + + + /** + * Translate data points from raw values + */ + translate: function () { + var series = this, + options = series.options, + yAxis = series.yAxis, + len, + i, + points, + point, + shapeArgs, + stack, + y, + previousY, + previousIntermediate, + stackPoint, + threshold = options.threshold, + tooltipY; + + // run column series translate + seriesTypes.column.prototype.translate.apply(this); + + previousY = previousIntermediate = threshold; + points = series.points; + + for (i = 0, len = points.length; i < len; i++) { + // cache current point object + point = points[i]; + shapeArgs = point.shapeArgs; + + // get current stack + stack = series.getStack(i); + stackPoint = stack.points[series.index + ',' + i]; + + // override point value for sums + if (isNaN(point.y)) { + point.y = series.yData[i]; + } + + // up points + y = mathMax(previousY, previousY + point.y) + stackPoint[0]; + shapeArgs.y = yAxis.translate(y, 0, 1); + + + // sum points + if (point.isSum) { + shapeArgs.y = yAxis.translate(stackPoint[1], 0, 1); + shapeArgs.height = yAxis.translate(stackPoint[0], 0, 1) - shapeArgs.y; + + } else if (point.isIntermediateSum) { + shapeArgs.y = yAxis.translate(stackPoint[1], 0, 1); + shapeArgs.height = yAxis.translate(previousIntermediate, 0, 1) - shapeArgs.y; + previousIntermediate = stackPoint[1]; + + // if it's not the sum point, update previous stack end position + } else { + previousY += stack.total; + } + + // negative points + if (shapeArgs.height < 0) { + shapeArgs.y += shapeArgs.height; + shapeArgs.height *= -1; + } + + point.plotY = shapeArgs.y = mathRound(shapeArgs.y) - (series.borderWidth % 2) / 2; + shapeArgs.height = mathMax(mathRound(shapeArgs.height), 0.001); // #3151 + point.yBottom = shapeArgs.y + shapeArgs.height; + + // Correct tooltip placement (#3014) + tooltipY = point.plotY + (point.negative ? shapeArgs.height : 0); + if (series.chart.inverted) { + point.tooltipPos[0] = yAxis.len - tooltipY; + } else { + point.tooltipPos[1] = tooltipY; + } + + } + }, + + /** + * Call default processData then override yData to reflect waterfall's extremes on yAxis + */ + processData: function (force) { + var series = this, + options = series.options, + yData = series.yData, + points = series.points, + point, + dataLength = yData.length, + threshold = options.threshold || 0, + subSum, + sum, + dataMin, + dataMax, + y, + i; + + sum = subSum = dataMin = dataMax = threshold; + + for (i = 0; i < dataLength; i++) { + y = yData[i]; + point = points && points[i] ? points[i] : {}; + + if (y === "sum" || point.isSum) { + yData[i] = sum; + } else if (y === "intermediateSum" || point.isIntermediateSum) { + yData[i] = subSum; + } else { + sum += y; + subSum += y; + } + dataMin = Math.min(sum, dataMin); + dataMax = Math.max(sum, dataMax); + } + + Series.prototype.processData.call(this, force); + + // Record extremes + series.dataMin = dataMin; + series.dataMax = dataMax; + }, + + /** + * Return y value or string if point is sum + */ + toYData: function (pt) { + if (pt.isSum) { + return (pt.x === 0 ? null : "sum"); //#3245 Error when first element is Sum or Intermediate Sum + } else if (pt.isIntermediateSum) { + return (pt.x === 0 ? null : "intermediateSum"); //#3245 + } + return pt.y; + }, + + /** + * Postprocess mapping between options and SVG attributes + */ + getAttribs: function () { + seriesTypes.column.prototype.getAttribs.apply(this, arguments); + + var series = this, + options = series.options, + stateOptions = options.states, + upColor = options.upColor || series.color, + hoverColor = Highcharts.Color(upColor).brighten(0.1).get(), + seriesDownPointAttr = merge(series.pointAttr), + upColorProp = series.upColorProp; + + seriesDownPointAttr[''][upColorProp] = upColor; + seriesDownPointAttr.hover[upColorProp] = stateOptions.hover.upColor || hoverColor; + seriesDownPointAttr.select[upColorProp] = stateOptions.select.upColor || upColor; + + each(series.points, function (point) { + if (point.y > 0 && !point.color) { + point.pointAttr = seriesDownPointAttr; + point.color = upColor; + } + }); + }, + + /** + * Draw columns' connector lines + */ + getGraphPath: function () { + + var data = this.data, + length = data.length, + lineWidth = this.options.lineWidth + this.borderWidth, + normalizer = mathRound(lineWidth) % 2 / 2, + path = [], + M = 'M', + L = 'L', + prevArgs, + pointArgs, + i, + d; + + for (i = 1; i < length; i++) { + pointArgs = data[i].shapeArgs; + prevArgs = data[i - 1].shapeArgs; + + d = [ + M, + prevArgs.x + prevArgs.width, prevArgs.y + normalizer, + L, + pointArgs.x, prevArgs.y + normalizer + ]; + + if (data[i - 1].y < 0) { + d[2] += prevArgs.height; + d[5] += prevArgs.height; + } + + path = path.concat(d); + } + + return path; + }, + + /** + * Extremes are recorded in processData + */ + getExtremes: noop, + + /** + * Return stack for given index + */ + getStack: function (i) { + var axis = this.yAxis, + stacks = axis.stacks, + key = this.stackKey; + + if (this.processedYData[i] < this.options.threshold) { + key = '-' + key; + } + + return stacks[key][i]; + }, + + drawGraph: Series.prototype.drawGraph +}); + +/* **************************************************************************** + * End Waterfall series code * + *****************************************************************************/ +/* **************************************************************************** + * Start Bubble series code * + *****************************************************************************/ + +// 1 - set default options +defaultPlotOptions.bubble = merge(defaultPlotOptions.scatter, { + dataLabels: { + formatter: function () { // #2945 + return this.point.z; + }, + inside: true, + style: { + color: 'white', + textShadow: '0px 0px 3px black' + }, + verticalAlign: 'middle' + }, + // displayNegative: true, + marker: { + // fillOpacity: 0.5, + lineColor: null, // inherit from series.color + lineWidth: 1 + }, + minSize: 8, + maxSize: '20%', + // negativeColor: null, + // sizeBy: 'area' + states: { + hover: { + halo: { + size: 5 + } + } + }, + tooltip: { + pointFormat: '({point.x}, {point.y}), Size: {point.z}' + }, + turboThreshold: 0, + zThreshold: 0 +}); + +var BubblePoint = extendClass(Point, { + haloPath: function () { + return Point.prototype.haloPath.call(this, this.shapeArgs.r + this.series.options.states.hover.halo.size); + } +}); + +// 2 - Create the series object +seriesTypes.bubble = extendClass(seriesTypes.scatter, { + type: 'bubble', + pointClass: BubblePoint, + pointArrayMap: ['y', 'z'], + parallelArrays: ['x', 'y', 'z'], + trackerGroups: ['group', 'dataLabelsGroup'], + bubblePadding: true, + + /** + * Mapping between SVG attributes and the corresponding options + */ + pointAttrToOptions: { + stroke: 'lineColor', + 'stroke-width': 'lineWidth', + fill: 'fillColor' + }, + + /** + * Apply the fillOpacity to all fill positions + */ + applyOpacity: function (fill) { + var markerOptions = this.options.marker, + fillOpacity = pick(markerOptions.fillOpacity, 0.5); + + // When called from Legend.colorizeItem, the fill isn't predefined + fill = fill || markerOptions.fillColor || this.color; + + if (fillOpacity !== 1) { + fill = Color(fill).setOpacity(fillOpacity).get('rgba'); + } + return fill; + }, + + /** + * Extend the convertAttribs method by applying opacity to the fill + */ + convertAttribs: function () { + var obj = Series.prototype.convertAttribs.apply(this, arguments); + + obj.fill = this.applyOpacity(obj.fill); + + return obj; + }, + + /** + * Get the radius for each point based on the minSize, maxSize and each point's Z value. This + * must be done prior to Series.translate because the axis needs to add padding in + * accordance with the point sizes. + */ + getRadii: function (zMin, zMax, minSize, maxSize) { + var len, + i, + pos, + zData = this.zData, + radii = [], + sizeByArea = this.options.sizeBy !== 'width', + zRange; + + // Set the shape type and arguments to be picked up in drawPoints + for (i = 0, len = zData.length; i < len; i++) { + zRange = zMax - zMin; + pos = zRange > 0 ? // relative size, a number between 0 and 1 + (zData[i] - zMin) / (zMax - zMin) : + 0.5; + if (sizeByArea && pos >= 0) { + pos = Math.sqrt(pos); + } + radii.push(math.ceil(minSize + pos * (maxSize - minSize)) / 2); + } + this.radii = radii; + }, + + /** + * Perform animation on the bubbles + */ + animate: function (init) { + var animation = this.options.animation; + + if (!init) { // run the animation + each(this.points, function (point) { + var graphic = point.graphic, + shapeArgs = point.shapeArgs; + + if (graphic && shapeArgs) { + // start values + graphic.attr('r', 1); + + // animate + graphic.animate({ + r: shapeArgs.r + }, animation); + } + }); + + // delete this function to allow it only once + this.animate = null; + } + }, + + /** + * Extend the base translate method to handle bubble size + */ + translate: function () { + + var i, + data = this.data, + point, + radius, + radii = this.radii; + + // Run the parent method + seriesTypes.scatter.prototype.translate.call(this); + + // Set the shape type and arguments to be picked up in drawPoints + i = data.length; + + while (i--) { + point = data[i]; + radius = radii ? radii[i] : 0; // #1737 + + // Flag for negativeColor to be applied in Series.js + point.negative = point.z < (this.options.zThreshold || 0); + + if (radius >= this.minPxSize / 2) { + // Shape arguments + point.shapeType = 'circle'; + point.shapeArgs = { + x: point.plotX, + y: point.plotY, + r: radius + }; + + // Alignment box for the data label + point.dlBox = { + x: point.plotX - radius, + y: point.plotY - radius, + width: 2 * radius, + height: 2 * radius + }; + } else { // below zThreshold + point.shapeArgs = point.plotY = point.dlBox = UNDEFINED; // #1691 + } + } + }, + + /** + * Get the series' symbol in the legend + * + * @param {Object} legend The legend object + * @param {Object} item The series (this) or point + */ + drawLegendSymbol: function (legend, item) { + var radius = pInt(legend.itemStyle.fontSize) / 2; + + item.legendSymbol = this.chart.renderer.circle( + radius, + legend.baseline - radius, + radius + ).attr({ + zIndex: 3 + }).add(item.legendGroup); + item.legendSymbol.isMarker = true; + + }, + + drawPoints: seriesTypes.column.prototype.drawPoints, + alignDataLabel: seriesTypes.column.prototype.alignDataLabel +}); + +/** + * Add logic to pad each axis with the amount of pixels + * necessary to avoid the bubbles to overflow. + */ +Axis.prototype.beforePadding = function () { + var axis = this, + axisLength = this.len, + chart = this.chart, + pxMin = 0, + pxMax = axisLength, + isXAxis = this.isXAxis, + dataKey = isXAxis ? 'xData' : 'yData', + min = this.min, + extremes = {}, + smallestSize = math.min(chart.plotWidth, chart.plotHeight), + zMin = Number.MAX_VALUE, + zMax = -Number.MAX_VALUE, + range = this.max - min, + transA = axisLength / range, + activeSeries = []; + + // Handle padding on the second pass, or on redraw + if (this.tickPositions) { + each(this.series, function (series) { + + var seriesOptions = series.options, + zData; + + if (series.bubblePadding && (series.visible || !chart.options.chart.ignoreHiddenSeries)) { + + // Correction for #1673 + axis.allowZoomOutside = true; + + // Cache it + activeSeries.push(series); + + if (isXAxis) { // because X axis is evaluated first + + // For each series, translate the size extremes to pixel values + each(['minSize', 'maxSize'], function (prop) { + var length = seriesOptions[prop], + isPercent = /%$/.test(length); + + length = pInt(length); + extremes[prop] = isPercent ? + smallestSize * length / 100 : + length; + + }); + series.minPxSize = extremes.minSize; + + // Find the min and max Z + zData = series.zData; + if (zData.length) { // #1735 + zMin = pick(seriesOptions.zMin, math.min( + zMin, + math.max( + arrayMin(zData), + seriesOptions.displayNegative === false ? seriesOptions.zThreshold : -Number.MAX_VALUE + ) + )); + zMax = pick(seriesOptions.zMax, math.max(zMax, arrayMax(zData))); + } + } + } + }); + + each(activeSeries, function (series) { + + var data = series[dataKey], + i = data.length, + radius; + + if (isXAxis) { + series.getRadii(zMin, zMax, extremes.minSize, extremes.maxSize); + } + + if (range > 0) { + while (i--) { + if (typeof data[i] === 'number') { + radius = series.radii[i]; + pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin); + pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax); + } + } + } + }); + + if (activeSeries.length && range > 0 && pick(this.options.min, this.userMin) === UNDEFINED && pick(this.options.max, this.userMax) === UNDEFINED) { + pxMax -= axisLength; + transA *= (axisLength + pxMin - pxMax) / axisLength; + this.min += pxMin / transA; + this.max += pxMax / transA; + } + } +}; + +/* **************************************************************************** + * End Bubble series code * + *****************************************************************************/ + +(function () { + + /** + * Extensions for polar charts. Additionally, much of the geometry required for polar charts is + * gathered in RadialAxes.js. + * + */ + + var seriesProto = Series.prototype, + pointerProto = Pointer.prototype, + colProto; + + /** + * Translate a point's plotX and plotY from the internal angle and radius measures to + * true plotX, plotY coordinates + */ + seriesProto.toXY = function (point) { + var xy, + chart = this.chart, + plotX = point.plotX, + plotY = point.plotY, + clientX; + + // Save rectangular plotX, plotY for later computation + point.rectPlotX = plotX; + point.rectPlotY = plotY; + + // Record the angle in degrees for use in tooltip + clientX = ((plotX / Math.PI * 180) + this.xAxis.pane.options.startAngle) % 360; + if (clientX < 0) { // #2665 + clientX += 360; + } + point.clientX = clientX; + + + // Find the polar plotX and plotY + xy = this.xAxis.postTranslate(point.plotX, this.yAxis.len - plotY); + point.plotX = point.polarPlotX = xy.x - chart.plotLeft; + point.plotY = point.polarPlotY = xy.y - chart.plotTop; + }; + + /** + * Order the tooltip points to get the mouse capture ranges correct. #1915. + */ + seriesProto.orderTooltipPoints = function (points) { + if (this.chart.polar) { + points.sort(function (a, b) { + return a.clientX - b.clientX; + }); + + // Wrap mouse tracking around to capture movement on the segment to the left + // of the north point (#1469, #2093). + if (points[0]) { + points[0].wrappedClientX = points[0].clientX + 360; + points.push(points[0]); + } + } + }; + + + /** + * Add some special init logic to areas and areasplines + */ + function initArea(proceed, chart, options) { + proceed.call(this, chart, options); + if (this.chart.polar) { + + /** + * Overridden method to close a segment path. While in a cartesian plane the area + * goes down to the threshold, in the polar chart it goes to the center. + */ + this.closeSegment = function (path) { + var center = this.xAxis.center; + path.push( + 'L', + center[0], + center[1] + ); + }; + + // Instead of complicated logic to draw an area around the inner area in a stack, + // just draw it behind + this.closedStacks = true; + } + } + + if (seriesTypes.area) { + wrap(seriesTypes.area.prototype, 'init', initArea); + } + if (seriesTypes.areaspline) { + wrap(seriesTypes.areaspline.prototype, 'init', initArea); + } + + if (seriesTypes.spline) { + /** + * Overridden method for calculating a spline from one point to the next + */ + wrap(seriesTypes.spline.prototype, 'getPointSpline', function (proceed, segment, point, i) { + + var ret, + smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc; + denom = smoothing + 1, + plotX, + plotY, + lastPoint, + nextPoint, + lastX, + lastY, + nextX, + nextY, + leftContX, + leftContY, + rightContX, + rightContY, + distanceLeftControlPoint, + distanceRightControlPoint, + leftContAngle, + rightContAngle, + jointAngle; + + + if (this.chart.polar) { + + plotX = point.plotX; + plotY = point.plotY; + lastPoint = segment[i - 1]; + nextPoint = segment[i + 1]; + + // Connect ends + if (this.connectEnds) { + if (!lastPoint) { + lastPoint = segment[segment.length - 2]; // not the last but the second last, because the segment is already connected + } + if (!nextPoint) { + nextPoint = segment[1]; + } + } + + // find control points + if (lastPoint && nextPoint) { + + lastX = lastPoint.plotX; + lastY = lastPoint.plotY; + nextX = nextPoint.plotX; + nextY = nextPoint.plotY; + leftContX = (smoothing * plotX + lastX) / denom; + leftContY = (smoothing * plotY + lastY) / denom; + rightContX = (smoothing * plotX + nextX) / denom; + rightContY = (smoothing * plotY + nextY) / denom; + distanceLeftControlPoint = Math.sqrt(Math.pow(leftContX - plotX, 2) + Math.pow(leftContY - plotY, 2)); + distanceRightControlPoint = Math.sqrt(Math.pow(rightContX - plotX, 2) + Math.pow(rightContY - plotY, 2)); + leftContAngle = Math.atan2(leftContY - plotY, leftContX - plotX); + rightContAngle = Math.atan2(rightContY - plotY, rightContX - plotX); + jointAngle = (Math.PI / 2) + ((leftContAngle + rightContAngle) / 2); + + + // Ensure the right direction, jointAngle should be in the same quadrant as leftContAngle + if (Math.abs(leftContAngle - jointAngle) > Math.PI / 2) { + jointAngle -= Math.PI; + } + + // Find the corrected control points for a spline straight through the point + leftContX = plotX + Math.cos(jointAngle) * distanceLeftControlPoint; + leftContY = plotY + Math.sin(jointAngle) * distanceLeftControlPoint; + rightContX = plotX + Math.cos(Math.PI + jointAngle) * distanceRightControlPoint; + rightContY = plotY + Math.sin(Math.PI + jointAngle) * distanceRightControlPoint; + + // Record for drawing in next point + point.rightContX = rightContX; + point.rightContY = rightContY; + + } + + + // moveTo or lineTo + if (!i) { + ret = ['M', plotX, plotY]; + } else { // curve from last point to this + ret = [ + 'C', + lastPoint.rightContX || lastPoint.plotX, + lastPoint.rightContY || lastPoint.plotY, + leftContX || plotX, + leftContY || plotY, + plotX, + plotY + ]; + lastPoint.rightContX = lastPoint.rightContY = null; // reset for updating series later + } + + + } else { + ret = proceed.call(this, segment, point, i); + } + return ret; + }); + } + + /** + * Extend translate. The plotX and plotY values are computed as if the polar chart were a + * cartesian plane, where plotX denotes the angle in radians and (yAxis.len - plotY) is the pixel distance from + * center. + */ + wrap(seriesProto, 'translate', function (proceed) { + + // Run uber method + proceed.call(this); + + // Postprocess plot coordinates + if (this.chart.polar && !this.preventPostTranslate) { + var points = this.points, + i = points.length; + while (i--) { + // Translate plotX, plotY from angle and radius to true plot coordinates + this.toXY(points[i]); + } + } + }); + + /** + * Extend getSegmentPath to allow connecting ends across 0 to provide a closed circle in + * line-like series. + */ + wrap(seriesProto, 'getSegmentPath', function (proceed, segment) { + + var points = this.points; + + // Connect the path + if (this.chart.polar && this.options.connectEnds !== false && + segment[segment.length - 1] === points[points.length - 1] && points[0].y !== null) { + this.connectEnds = true; // re-used in splines + segment = [].concat(segment, [points[0]]); + } + + // Run uber method + return proceed.call(this, segment); + + }); + + + function polarAnimate(proceed, init) { + var chart = this.chart, + animation = this.options.animation, + group = this.group, + markerGroup = this.markerGroup, + center = this.xAxis.center, + plotLeft = chart.plotLeft, + plotTop = chart.plotTop, + attribs; + + // Specific animation for polar charts + if (chart.polar) { + + // Enable animation on polar charts only in SVG. In VML, the scaling is different, plus animation + // would be so slow it would't matter. + if (chart.renderer.isSVG) { + + if (animation === true) { + animation = {}; + } + + // Initialize the animation + if (init) { + + // Scale down the group and place it in the center + attribs = { + translateX: center[0] + plotLeft, + translateY: center[1] + plotTop, + scaleX: 0.001, // #1499 + scaleY: 0.001 + }; + + group.attr(attribs); + if (markerGroup) { + //markerGroup.attrSetters = group.attrSetters; + markerGroup.attr(attribs); + } + + // Run the animation + } else { + attribs = { + translateX: plotLeft, + translateY: plotTop, + scaleX: 1, + scaleY: 1 + }; + group.animate(attribs, animation); + if (markerGroup) { + markerGroup.animate(attribs, animation); + } + + // Delete this function to allow it only once + this.animate = null; + } + } + + // For non-polar charts, revert to the basic animation + } else { + proceed.call(this, init); + } + } + + // Define the animate method for regular series + wrap(seriesProto, 'animate', polarAnimate); + + /** + * Throw in a couple of properties to let setTooltipPoints know we're indexing the points + * in degrees (0-360), not plot pixel width. + */ + wrap(seriesProto, 'setTooltipPoints', function (proceed, renew) { + + if (this.chart.polar) { + extend(this.xAxis, { + tooltipLen: 360 // degrees are the resolution unit of the tooltipPoints array + }); + } + // Run uber method + return proceed.call(this, renew); + }); + + + if (seriesTypes.column) { + + colProto = seriesTypes.column.prototype; + /** + * Define the animate method for columnseries + */ + wrap(colProto, 'animate', polarAnimate); + + + /** + * Extend the column prototype's translate method + */ + wrap(colProto, 'translate', function (proceed) { + + var xAxis = this.xAxis, + len = this.yAxis.len, + center = xAxis.center, + startAngleRad = xAxis.startAngleRad, + renderer = this.chart.renderer, + start, + points, + point, + i; + + this.preventPostTranslate = true; + + // Run uber method + proceed.call(this); + + // Postprocess plot coordinates + if (xAxis.isRadial) { + points = this.points; + i = points.length; + while (i--) { + point = points[i]; + start = point.barX + startAngleRad; + point.shapeType = 'path'; + point.shapeArgs = { + d: renderer.symbols.arc( + center[0], + center[1], + len - point.plotY, + null, + { + start: start, + end: start + point.pointWidth, + innerR: len - pick(point.yBottom, len) + } + ) + }; + // Provide correct plotX, plotY for tooltip + this.toXY(point); + point.tooltipPos = [point.plotX, point.plotY]; + point.ttBelow = point.plotY > center[1]; + } + } + }); + + + /** + * Align column data labels outside the columns. #1199. + */ + wrap(colProto, 'alignDataLabel', function (proceed, point, dataLabel, options, alignTo, isNew) { + + if (this.chart.polar) { + var angle = point.rectPlotX / Math.PI * 180, + align, + verticalAlign; + + // Align nicely outside the perimeter of the columns + if (options.align === null) { + if (angle > 20 && angle < 160) { + align = 'left'; // right hemisphere + } else if (angle > 200 && angle < 340) { + align = 'right'; // left hemisphere + } else { + align = 'center'; // top or bottom + } + options.align = align; + } + if (options.verticalAlign === null) { + if (angle < 45 || angle > 315) { + verticalAlign = 'bottom'; // top part + } else if (angle > 135 && angle < 225) { + verticalAlign = 'top'; // bottom part + } else { + verticalAlign = 'middle'; // left or right + } + options.verticalAlign = verticalAlign; + } + + seriesProto.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew); + } else { + proceed.call(this, point, dataLabel, options, alignTo, isNew); + } + + }); + } + + + /** + * Extend the mouse tracker to return the tooltip position index in terms of + * degrees rather than pixels + */ + wrap(pointerProto, 'getIndex', function (proceed, e) { + var ret, + chart = this.chart, + center, + x, + y; + + if (chart.polar) { + center = chart.xAxis[0].center; + x = e.chartX - center[0] - chart.plotLeft; + y = e.chartY - center[1] - chart.plotTop; + + ret = 180 - Math.round(Math.atan2(x, y) / Math.PI * 180); + + } else { + + // Run uber method + ret = proceed.call(this, e); + } + return ret; + }); + + /** + * Extend getCoordinates to prepare for polar axis values + */ + wrap(pointerProto, 'getCoordinates', function (proceed, e) { + var chart = this.chart, + ret = { + xAxis: [], + yAxis: [] + }; + + if (chart.polar) { + + each(chart.axes, function (axis) { + var isXAxis = axis.isXAxis, + center = axis.center, + x = e.chartX - center[0] - chart.plotLeft, + y = e.chartY - center[1] - chart.plotTop; + + ret[isXAxis ? 'xAxis' : 'yAxis'].push({ + axis: axis, + value: axis.translate( + isXAxis ? + Math.PI - Math.atan2(x, y) : // angle + Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)), // distance from center + true + ) + }); + }); + + } else { + ret = proceed.call(this, e); + } + + return ret; + }); + +}()); + +}(Highcharts)); diff --git a/html/includes/js/highcharts.js b/html/includes/js/highcharts.js new file mode 100644 index 0000000..1133176 --- /dev/null +++ b/html/includes/js/highcharts.js @@ -0,0 +1,308 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + + (c) 2009-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(){function r(a,b){var c;a||(a={});for(c in b)a[c]=b[c];return a}function w(){var a,b=arguments,c,d={},e=function(a,b){var c,d;typeof a!=="object"&&(a={});for(d in b)b.hasOwnProperty(d)&&(c=b[d],a[d]=c&&typeof c==="object"&&Object.prototype.toString.call(c)!=="[object Array]"&&d!=="renderTo"&&typeof c.nodeType!=="number"?e(a[d]||{},c):b[d]);return a};b[0]===!0&&(d=b[1],b=Array.prototype.slice.call(b,2));c=b.length;for(a=0;a<c;a++)d=e(d,b[a]);return d}function y(a,b){return parseInt(a,b|| +10)}function Ga(a){return typeof a==="string"}function da(a){return a&&typeof a==="object"}function Ha(a){return Object.prototype.toString.call(a)==="[object Array]"}function ja(a){return typeof a==="number"}function za(a){return V.log(a)/V.LN10}function ka(a){return V.pow(10,a)}function la(a,b){for(var c=a.length;c--;)if(a[c]===b){a.splice(c,1);break}}function s(a){return a!==u&&a!==null}function F(a,b,c){var d,e;if(Ga(b))s(c)?a.setAttribute(b,c):a&&a.getAttribute&&(e=a.getAttribute(b));else if(s(b)&& +da(b))for(d in b)a.setAttribute(d,b[d]);return e}function ra(a){return Ha(a)?a:[a]}function p(){var a=arguments,b,c,d=a.length;for(b=0;b<d;b++)if(c=a[b],c!==u&&c!==null)return c}function B(a,b){if(Aa&&!ba&&b&&b.opacity!==u)b.filter="alpha(opacity="+b.opacity*100+")";r(a.style,b)}function $(a,b,c,d,e){a=x.createElement(a);b&&r(a,b);e&&B(a,{padding:0,border:P,margin:0});c&&B(a,c);d&&d.appendChild(a);return a}function ma(a,b){var c=function(){return u};c.prototype=new a;r(c.prototype,b);return c}function Ba(a, +b,c,d){var e=K.numberFormat,f=E.lang,g=+a||0,h=b===-1?(g.toString().split(".")[1]||"").length:isNaN(b=Q(b))?2:b,i=c===void 0?f.decimalPoint:c,f=d===void 0?f.thousandsSep:d,j=g<0?"-":"",k=String(y(g=Q(g).toFixed(h))),l=k.length>3?k.length%3:0;return e!==Ba?e(a,b,c,d):j+(l?k.substr(0,l)+f:"")+k.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+f)+(h?i+Q(g-k).toFixed(h).slice(2):"")}function Ia(a,b){return Array((b||2)+1-String(a).length).join(0)+a}function Na(a,b,c){var d=a[b];a[b]=function(){var a=Array.prototype.slice.call(arguments); +a.unshift(d);return c.apply(this,a)}}function Ja(a,b){for(var c="{",d=!1,e,f,g,h,i,j=[];(c=a.indexOf(c))!==-1;){e=a.slice(0,c);if(d){f=e.split(":");g=f.shift().split(".");i=g.length;e=b;for(h=0;h<i;h++)e=e[g[h]];if(f.length)f=f.join(":"),g=/\.([0-9])/,h=E.lang,i=void 0,/f$/.test(f)?(i=(i=f.match(g))?i[1]:-1,e!==null&&(e=Ba(e,i,h.decimalPoint,f.indexOf(",")>-1?h.thousandsSep:""))):e=cb(f,e)}j.push(e);a=a.slice(c+1);c=(d=!d)?"}":"{"}j.push(a);return j.join("")}function mb(a){return V.pow(10,U(V.log(a)/ +V.LN10))}function nb(a,b,c,d){var e,c=p(c,1);e=a/c;b||(b=[1,2,2.5,5,10],d===!1&&(c===1?b=[1,2,5,10]:c<=0.1&&(b=[1/c])));for(d=0;d<b.length;d++)if(a=b[d],e<=(b[d]+(b[d+1]||b[d]))/2)break;a*=c;return a}function ob(a,b){var c=a.length,d,e;for(e=0;e<c;e++)a[e].ss_i=e;a.sort(function(a,c){d=b(a,c);return d===0?a.ss_i-c.ss_i:d});for(e=0;e<c;e++)delete a[e].ss_i}function Oa(a){for(var b=a.length,c=a[0];b--;)a[b]<c&&(c=a[b]);return c}function Ca(a){for(var b=a.length,c=a[0];b--;)a[b]>c&&(c=a[b]);return c} +function Pa(a,b){for(var c in a)a[c]&&a[c]!==b&&a[c].destroy&&a[c].destroy(),delete a[c]}function Qa(a){db||(db=$(Ka));a&&db.appendChild(a);db.innerHTML=""}function ea(a){return parseFloat(a.toPrecision(14))}function Ra(a,b){va=p(a,b.animation)}function Bb(){var a=E.global.useUTC,b=a?"getUTC":"get",c=a?"setUTC":"set";Da=E.global.Date||window.Date;Sa=(a&&E.global.timezoneOffset||0)*6E4;eb=a?Da.UTC:function(a,b,c,g,h,i){return(new Da(a,b,p(c,1),p(g,0),p(h,0),p(i,0))).getTime()};pb=b+"Minutes";qb=b+ +"Hours";rb=b+"Day";Xa=b+"Date";fb=b+"Month";gb=b+"FullYear";Cb=c+"Minutes";Db=c+"Hours";sb=c+"Date";Eb=c+"Month";Fb=c+"FullYear"}function S(){}function Ta(a,b,c,d){this.axis=a;this.pos=b;this.type=c||"";this.isNew=!0;!c&&!d&&this.addLabel()}function na(){this.init.apply(this,arguments)}function Ya(){this.init.apply(this,arguments)}function Gb(a,b,c,d,e){var f=a.chart.inverted;this.axis=a;this.isNegative=c;this.options=b;this.x=d;this.total=null;this.points={};this.stack=e;this.alignOptions={align:b.align|| +(f?c?"left":"right":"center"),verticalAlign:b.verticalAlign||(f?"middle":c?"bottom":"top"),y:p(b.y,f?4:c?14:-6),x:p(b.x,f?c?-6:6:0)};this.textAlign=b.textAlign||(f?c?"right":"left":"center")}var u,x=document,G=window,V=Math,v=V.round,U=V.floor,La=V.ceil,t=V.max,L=V.min,Q=V.abs,aa=V.cos,fa=V.sin,oa=V.PI,Ea=oa*2/360,wa=navigator.userAgent,Hb=G.opera,Aa=/msie/i.test(wa)&&!Hb,hb=x.documentMode===8,tb=/AppleWebKit/.test(wa),Ua=/Firefox/.test(wa),Ib=/(Mobile|Android|Windows Phone)/.test(wa),xa="http://www.w3.org/2000/svg", +ba=!!x.createElementNS&&!!x.createElementNS(xa,"svg").createSVGRect,Ob=Ua&&parseInt(wa.split("Firefox/")[1],10)<4,ga=!ba&&!Aa&&!!x.createElement("canvas").getContext,Za,$a,Jb={},ub=0,db,E,cb,va,vb,A,ha,sa=function(){return u},W=[],ab=0,Ka="div",P="none",Pb=/^[0-9]+$/,Qb="stroke-width",Da,eb,Sa,pb,qb,rb,Xa,fb,gb,Cb,Db,sb,Eb,Fb,H={},K;G.Highcharts?ha(16,!0):K=G.Highcharts={};cb=function(a,b,c){if(!s(b)||isNaN(b))return"Invalid date";var a=p(a,"%Y-%m-%d %H:%M:%S"),d=new Da(b-Sa),e,f=d[qb](),g=d[rb](), +h=d[Xa](),i=d[fb](),j=d[gb](),k=E.lang,l=k.weekdays,d=r({a:l[g].substr(0,3),A:l[g],d:Ia(h),e:h,b:k.shortMonths[i],B:k.months[i],m:Ia(i+1),y:j.toString().substr(2,2),Y:j,H:Ia(f),I:Ia(f%12||12),l:f%12||12,M:Ia(d[pb]()),p:f<12?"AM":"PM",P:f<12?"am":"pm",S:Ia(d.getSeconds()),L:Ia(v(b%1E3),3)},K.dateFormats);for(e in d)for(;a.indexOf("%"+e)!==-1;)a=a.replace("%"+e,typeof d[e]==="function"?d[e](b):d[e]);return c?a.substr(0,1).toUpperCase()+a.substr(1):a};ha=function(a,b){var c="Highcharts error #"+a+": www.highcharts.com/errors/"+ +a;if(b)throw c;G.console&&console.log(c)};A={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5,month:26784E5,year:31556952E3};vb={init:function(a,b,c){var b=b||"",d=a.shift,e=b.indexOf("C")>-1,f=e?7:3,g,b=b.split(" "),c=[].concat(c),h,i,j=function(a){for(g=a.length;g--;)a[g]==="M"&&a.splice(g+1,0,a[g+1],a[g+2],a[g+1],a[g+2])};e&&(j(b),j(c));a.isArea&&(h=b.splice(b.length-6,6),i=c.splice(c.length-6,6));if(d<=c.length/f&&b.length===c.length)for(;d--;)c=[].concat(c).splice(0,f).concat(c); +a.shift=0;if(b.length)for(a=c.length;b.length<a;)d=[].concat(b).splice(b.length-f,f),e&&(d[f-6]=d[f-2],d[f-5]=d[f-1]),b=b.concat(d);h&&(b=b.concat(h),c=c.concat(i));return[b,c]},step:function(a,b,c,d){var e=[],f=a.length;if(c===1)e=d;else if(f===b.length&&c<1)for(;f--;)d=parseFloat(a[f]),e[f]=isNaN(d)?a[f]:c*parseFloat(b[f]-d)+d;else e=b;return e}};(function(a){G.HighchartsAdapter=G.HighchartsAdapter||a&&{init:function(b){var c=a.fx;a.extend(a.easing,{easeOutQuad:function(a,b,c,g,h){return-g*(b/= +h)*(b-2)+c}});a.each(["cur","_default","width","height","opacity"],function(b,e){var f=c.step,g;e==="cur"?f=c.prototype:e==="_default"&&a.Tween&&(f=a.Tween.propHooks[e],e="set");(g=f[e])&&(f[e]=function(a){var c,a=b?a:this;if(a.prop!=="align")return c=a.elem,c.attr?c.attr(a.prop,e==="cur"?u:a.now):g.apply(this,arguments)})});Na(a.cssHooks.opacity,"get",function(a,b,c){return b.attr?b.opacity||0:a.call(this,b,c)});this.addAnimSetter("d",function(a){var c=a.elem,f;if(!a.started)f=b.init(c,c.d,c.toD), +a.start=f[0],a.end=f[1],a.started=!0;c.attr("d",b.step(a.start,a.end,a.pos,c.toD))});this.each=Array.prototype.forEach?function(a,b){return Array.prototype.forEach.call(a,b)}:function(a,b){var c,g=a.length;for(c=0;c<g;c++)if(b.call(a[c],a[c],c,a)===!1)return c};a.fn.highcharts=function(){var a="Chart",b=arguments,c,g;if(this[0]){Ga(b[0])&&(a=b[0],b=Array.prototype.slice.call(b,1));c=b[0];if(c!==u)c.chart=c.chart||{},c.chart.renderTo=this[0],new K[a](c,b[1]),g=this;c===u&&(g=W[F(this[0],"data-highcharts-chart")])}return g}}, +addAnimSetter:function(b,c){a.Tween?a.Tween.propHooks[b]={set:c}:a.fx.step[b]=c},getScript:a.getScript,inArray:a.inArray,adapterRun:function(b,c){return a(b)[c]()},grep:a.grep,map:function(a,c){for(var d=[],e=0,f=a.length;e<f;e++)d[e]=c.call(a[e],a[e],e,a);return d},offset:function(b){return a(b).offset()},addEvent:function(b,c,d){a(b).bind(c,d)},removeEvent:function(b,c,d){var e=x.removeEventListener?"removeEventListener":"detachEvent";x[e]&&b&&!b[e]&&(b[e]=function(){});a(b).unbind(c,d)},fireEvent:function(b, +c,d,e){var f=a.Event(c),g="detached"+c,h;!Aa&&d&&(delete d.layerX,delete d.layerY,delete d.returnValue);r(f,d);b[c]&&(b[g]=b[c],b[c]=null);a.each(["preventDefault","stopPropagation"],function(a,b){var c=f[b];f[b]=function(){try{c.call(f)}catch(a){b==="preventDefault"&&(h=!0)}}});a(b).trigger(f);b[g]&&(b[c]=b[g],b[g]=null);e&&!f.isDefaultPrevented()&&!h&&e(f)},washMouseEvent:function(a){var c=a.originalEvent||a;if(c.pageX===u)c.pageX=a.pageX,c.pageY=a.pageY;return c},animate:function(b,c,d){var e= +a(b);if(!b.style)b.style={};if(c.d)b.toD=c.d,c.d=1;e.stop();c.opacity!==u&&b.attr&&(c.opacity+="px");b.hasAnim=1;e.animate(c,d)},stop:function(b){b.hasAnim&&a(b).stop()}}})(G.jQuery);var T=G.HighchartsAdapter,M=T||{};T&&T.init.call(T,vb);var ib=M.adapterRun,Rb=M.getScript,Ma=M.inArray,q=M.each,wb=M.grep,Sb=M.offset,Va=M.map,N=M.addEvent,X=M.removeEvent,I=M.fireEvent,Tb=M.washMouseEvent,jb=M.animate,bb=M.stop,M={enabled:!0,x:0,y:15,style:{color:"#606060",cursor:"default",fontSize:"11px"}};E={colors:"#7cb5ec,#434348,#90ed7d,#f7a35c,#8085e9,#f15c80,#e4d354,#8085e8,#8d4653,#91e8e1".split(","), +symbols:["circle","diamond","square","triangle","triangle-down"],lang:{loading:"Loading...",months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),shortMonths:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),decimalPoint:".",numericSymbols:"k,M,G,T,P,E".split(","),resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:","},global:{useUTC:!0, +canvasToolsURL:"http://code.highcharts.com/4.0.4/modules/canvas-tools.js",VMLRadialGradientURL:"http://code.highcharts.com/4.0.4/gfx/vml-radial-gradient.png"},chart:{borderColor:"#4572A7",borderRadius:0,defaultSeriesType:"line",ignoreHiddenSeries:!0,spacing:[10,10,15,10],backgroundColor:"#FFFFFF",plotBorderColor:"#C0C0C0",resetZoomButton:{theme:{zIndex:20},position:{align:"right",x:-10,y:10}}},title:{text:"Chart title",align:"center",margin:15,style:{color:"#333333",fontSize:"18px"}},subtitle:{text:"", +align:"center",style:{color:"#555555"}},plotOptions:{line:{allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},lineWidth:2,marker:{lineWidth:0,radius:4,lineColor:"#FFFFFF",states:{hover:{enabled:!0,lineWidthPlus:1,radiusPlus:2},select:{fillColor:"#FFFFFF",lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:w(M,{align:"center",enabled:!1,formatter:function(){return this.y===null?"":Ba(this.y,-1)},verticalAlign:"bottom",y:0}),cropThreshold:300,pointRange:0,states:{hover:{lineWidthPlus:1, +marker:{},halo:{size:10,opacity:0.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3}},labels:{style:{position:"absolute",color:"#3E576F"}},legend:{enabled:!0,align:"center",layout:"horizontal",labelFormatter:function(){return this.name},borderColor:"#909090",borderRadius:0,navigation:{activeColor:"#274b6d",inactiveColor:"#CCC"},shadow:!1,itemStyle:{color:"#333333",fontSize:"12px",fontWeight:"bold"},itemHoverStyle:{color:"#000"},itemHiddenStyle:{color:"#CCC"},itemCheckboxStyle:{position:"absolute", +width:"13px",height:"13px"},symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"white",opacity:0.5,textAlign:"center"}},tooltip:{enabled:!0,animation:ba,backgroundColor:"rgba(249, 249, 249, .85)",borderWidth:1,borderRadius:3,dateTimeLabelFormats:{millisecond:"%A, %b %e, %H:%M:%S.%L",second:"%A, %b %e, %H:%M:%S",minute:"%A, %b %e, %H:%M",hour:"%A, %b %e, %H:%M", +day:"%A, %b %e, %Y",week:"Week from %A, %b %e, %Y",month:"%B %Y",year:"%Y"},headerFormat:'<span style="font-size: 10px">{point.key}</span><br/>',pointFormat:'<span style="color:{series.color}">●</span> {series.name}: <b>{point.y}</b><br/>',shadow:!0,snap:Ib?25:10,style:{color:"#333333",cursor:"default",fontSize:"12px",padding:"8px",whiteSpace:"nowrap"}},credits:{enabled:!0,text:"Highcharts.com",href:"http://www.highcharts.com",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer", +color:"#909090",fontSize:"9px"}}};var ca=E.plotOptions,T=ca.line;Bb();var Ub=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,Vb=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,Wb=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,ya=function(a){var b=[],c,d;(function(a){a&&a.stops?d=Va(a.stops,function(a){return ya(a[1])}):(c=Ub.exec(a))?b=[y(c[1]),y(c[2]),y(c[3]),parseFloat(c[4],10)]:(c=Vb.exec(a))?b=[y(c[1],16),y(c[2],16),y(c[3], +16),1]:(c=Wb.exec(a))&&(b=[y(c[1]),y(c[2]),y(c[3]),1])})(a);return{get:function(c){var f;d?(f=w(a),f.stops=[].concat(f.stops),q(d,function(a,b){f.stops[b]=[f.stops[b][0],a.get(c)]})):f=b&&!isNaN(b[0])?c==="rgb"?"rgb("+b[0]+","+b[1]+","+b[2]+")":c==="a"?b[3]:"rgba("+b.join(",")+")":a;return f},brighten:function(a){if(d)q(d,function(b){b.brighten(a)});else if(ja(a)&&a!==0){var c;for(c=0;c<3;c++)b[c]+=y(a*255),b[c]<0&&(b[c]=0),b[c]>255&&(b[c]=255)}return this},rgba:b,setOpacity:function(a){b[3]=a;return this}}}; +S.prototype={opacity:1,textProps:"fontSize,fontWeight,fontFamily,color,lineHeight,width,textDecoration,textShadow,HcTextStroke".split(","),init:function(a,b){this.element=b==="span"?$(b):x.createElementNS(xa,b);this.renderer=a},animate:function(a,b,c){b=p(b,va,!0);bb(this);if(b){b=w(b,{});if(c)b.complete=c;jb(this,a,b)}else this.attr(a),c&&c();return this},colorGradient:function(a,b,c){var d=this.renderer,e,f,g,h,i,j,k,l,n,m,o=[];a.linearGradient?f="linearGradient":a.radialGradient&&(f="radialGradient"); +if(f){g=a[f];h=d.gradients;j=a.stops;n=c.radialReference;Ha(g)&&(a[f]=g={x1:g[0],y1:g[1],x2:g[2],y2:g[3],gradientUnits:"userSpaceOnUse"});f==="radialGradient"&&n&&!s(g.gradientUnits)&&(g=w(g,{cx:n[0]-n[2]/2+g.cx*n[2],cy:n[1]-n[2]/2+g.cy*n[2],r:g.r*n[2],gradientUnits:"userSpaceOnUse"}));for(m in g)m!=="id"&&o.push(m,g[m]);for(m in j)o.push(j[m]);o=o.join(",");h[o]?a=h[o].attr("id"):(g.id=a="highcharts-"+ub++,h[o]=i=d.createElement(f).attr(g).add(d.defs),i.stops=[],q(j,function(a){a[1].indexOf("rgba")=== +0?(e=ya(a[1]),k=e.get("rgb"),l=e.get("a")):(k=a[1],l=1);a=d.createElement("stop").attr({offset:a[0],"stop-color":k,"stop-opacity":l}).add(i);i.stops.push(a)}));c.setAttribute(b,"url("+d.url+"#"+a+")")}},attr:function(a,b){var c,d,e=this.element,f,g=this,h;typeof a==="string"&&b!==u&&(c=a,a={},a[c]=b);if(typeof a==="string")g=(this[a+"Getter"]||this._defaultGetter).call(this,a,e);else{for(c in a){d=a[c];h=!1;this.symbolName&&/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)/.test(c)&&(f||(this.symbolAttr(a), +f=!0),h=!0);if(this.rotation&&(c==="x"||c==="y"))this.doTransform=!0;h||(this[c+"Setter"]||this._defaultSetter).call(this,d,c,e);this.shadows&&/^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(c)&&this.updateShadows(c,d)}if(this.doTransform)this.updateTransform(),this.doTransform=!1}return g},updateShadows:function(a,b){for(var c=this.shadows,d=c.length;d--;)c[d].setAttribute(a,a==="height"?t(b-(c[d].cutHeight||0),0):a==="d"?this.d:b)},addClass:function(a){var b=this.element,c=F(b,"class")|| +"";c.indexOf(a)===-1&&F(b,"class",c+" "+a);return this},symbolAttr:function(a){var b=this;q("x,y,r,start,end,width,height,innerR,anchorX,anchorY".split(","),function(c){b[c]=p(a[c],b[c])});b.attr({d:b.renderer.symbols[b.symbolName](b.x,b.y,b.width,b.height,b)})},clip:function(a){return this.attr("clip-path",a?"url("+this.renderer.url+"#"+a.id+")":P)},crisp:function(a){var b,c={},d,e=a.strokeWidth||this.strokeWidth||0;d=v(e)%2/2;a.x=U(a.x||this.x||0)+d;a.y=U(a.y||this.y||0)+d;a.width=U((a.width||this.width|| +0)-2*d);a.height=U((a.height||this.height||0)-2*d);a.strokeWidth=e;for(b in a)this[b]!==a[b]&&(this[b]=c[b]=a[b]);return c},css:function(a){var b=this.styles,c={},d=this.element,e,f,g="";e=!b;if(a&&a.color)a.fill=a.color;if(b)for(f in a)a[f]!==b[f]&&(c[f]=a[f],e=!0);if(e){e=this.textWidth=a&&a.width&&d.nodeName.toLowerCase()==="text"&&y(a.width);b&&(a=r(b,c));this.styles=a;e&&(ga||!ba&&this.renderer.forExport)&&delete a.width;if(Aa&&!ba)B(this.element,a);else{b=function(a,b){return"-"+b.toLowerCase()}; +for(f in a)g+=f.replace(/([A-Z])/g,b)+":"+a[f]+";";F(d,"style",g)}e&&this.added&&this.renderer.buildText(this)}return this},on:function(a,b){var c=this,d=c.element;$a&&a==="click"?(d.ontouchstart=function(a){c.touchEventFired=Da.now();a.preventDefault();b.call(d,a)},d.onclick=function(a){(wa.indexOf("Android")===-1||Da.now()-(c.touchEventFired||0)>1100)&&b.call(d,a)}):d["on"+a]=b;return this},setRadialReference:function(a){this.element.radialReference=a;return this},translate:function(a,b){return this.attr({translateX:a, +translateY:b})},invert:function(){this.inverted=!0;this.updateTransform();return this},updateTransform:function(){var a=this.translateX||0,b=this.translateY||0,c=this.scaleX,d=this.scaleY,e=this.inverted,f=this.rotation,g=this.element;e&&(a+=this.attr("width"),b+=this.attr("height"));a=["translate("+a+","+b+")"];e?a.push("rotate(90) scale(-1,1)"):f&&a.push("rotate("+f+" "+(g.getAttribute("x")||0)+" "+(g.getAttribute("y")||0)+")");(s(c)||s(d))&&a.push("scale("+p(c,1)+" "+p(d,1)+")");a.length&&g.setAttribute("transform", +a.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,b,c){var d,e,f,g,h={};e=this.renderer;f=e.alignedObjects;if(a){if(this.alignOptions=a,this.alignByTranslate=b,!c||Ga(c))this.alignTo=d=c||"renderer",la(f,this),f.push(this),c=null}else a=this.alignOptions,b=this.alignByTranslate,d=this.alignTo;c=p(c,e[d],e);d=a.align;e=a.verticalAlign;f=(c.x||0)+(a.x||0);g=(c.y||0)+(a.y||0);if(d==="right"||d==="center")f+=(c.width-(a.width||0))/{right:1,center:2}[d]; +h[b?"translateX":"x"]=v(f);if(e==="bottom"||e==="middle")g+=(c.height-(a.height||0))/({bottom:1,middle:2}[e]||1);h[b?"translateY":"y"]=v(g);this[this.placed?"animate":"attr"](h);this.placed=!0;this.alignAttr=h;return this},getBBox:function(){var a=this.bBox,b=this.renderer,c,d,e=this.rotation;c=this.element;var f=this.styles,g=e*Ea;d=this.textStr;var h;if(d===""||Pb.test(d))h="num."+d.toString().length+(f?"|"+f.fontSize+"|"+f.fontFamily:"");h&&(a=b.cache[h]);if(!a){if(c.namespaceURI===xa||b.forExport){try{a= +c.getBBox?r({},c.getBBox()):{width:c.offsetWidth,height:c.offsetHeight}}catch(i){}if(!a||a.width<0)a={width:0,height:0}}else a=this.htmlGetBBox();if(b.isSVG){c=a.width;d=a.height;if(Aa&&f&&f.fontSize==="11px"&&d.toPrecision(3)==="16.9")a.height=d=14;if(e)a.width=Q(d*fa(g))+Q(c*aa(g)),a.height=Q(d*aa(g))+Q(c*fa(g))}this.bBox=a;h&&(b.cache[h]=a)}return a},show:function(a){a&&this.element.namespaceURI===xa?this.element.removeAttribute("visibility"):this.attr({visibility:a?"inherit":"visible"});return this}, +hide:function(){return this.attr({visibility:"hidden"})},fadeOut:function(a){var b=this;b.animate({opacity:0},{duration:a||150,complete:function(){b.attr({y:-9999})}})},add:function(a){var b=this.renderer,c=a||b,d=c.element||b.box,e=this.element,f=this.zIndex,g,h;if(a)this.parentGroup=a;this.parentInverted=a&&a.inverted;this.textStr!==void 0&&b.buildText(this);if(f)c.handleZ=!0,f=y(f);if(c.handleZ){a=d.childNodes;for(g=0;g<a.length;g++)if(b=a[g],c=F(b,"zIndex"),b!==e&&(y(c)>f||!s(f)&&s(c))){d.insertBefore(e, +b);h=!0;break}}h||d.appendChild(e);this.added=!0;if(this.onAdd)this.onAdd();return this},safeRemoveChild:function(a){var b=a.parentNode;b&&b.removeChild(a)},destroy:function(){var a=this,b=a.element||{},c=a.shadows,d=a.renderer.isSVG&&b.nodeName==="SPAN"&&a.parentGroup,e,f;b.onclick=b.onmouseout=b.onmouseover=b.onmousemove=b.point=null;bb(a);if(a.clipPath)a.clipPath=a.clipPath.destroy();if(a.stops){for(f=0;f<a.stops.length;f++)a.stops[f]=a.stops[f].destroy();a.stops=null}a.safeRemoveChild(b);for(c&& +q(c,function(b){a.safeRemoveChild(b)});d&&d.div&&d.div.childNodes.length===0;)b=d.parentGroup,a.safeRemoveChild(d.div),delete d.div,d=b;a.alignTo&&la(a.renderer.alignedObjects,a);for(e in a)delete a[e];return null},shadow:function(a,b,c){var d=[],e,f,g=this.element,h,i,j,k;if(a){i=p(a.width,3);j=(a.opacity||0.15)/i;k=this.parentInverted?"(-1,-1)":"("+p(a.offsetX,1)+", "+p(a.offsetY,1)+")";for(e=1;e<=i;e++){f=g.cloneNode(0);h=i*2+1-2*e;F(f,{isShadow:"true",stroke:a.color||"black","stroke-opacity":j* +e,"stroke-width":h,transform:"translate"+k,fill:P});if(c)F(f,"height",t(F(f,"height")-h,0)),f.cutHeight=h;b?b.element.appendChild(f):g.parentNode.insertBefore(f,g);d.push(f)}this.shadows=d}return this},xGetter:function(a){this.element.nodeName==="circle"&&(a={x:"cx",y:"cy"}[a]||a);return this._defaultGetter(a)},_defaultGetter:function(a){a=p(this[a],this.element?this.element.getAttribute(a):null,0);/^[\-0-9\.]+$/.test(a)&&(a=parseFloat(a));return a},dSetter:function(a,b,c){a&&a.join&&(a=a.join(" ")); +/(NaN| {2}|^$)/.test(a)&&(a="M 0 0");c.setAttribute(b,a);this[b]=a},dashstyleSetter:function(a){var b;if(a=a&&a.toLowerCase()){a=a.replace("shortdashdotdot","3,1,1,1,1,1,").replace("shortdashdot","3,1,1,1").replace("shortdot","1,1,").replace("shortdash","3,1,").replace("longdash","8,3,").replace(/dot/g,"1,3,").replace("dash","4,3,").replace(/,$/,"").split(",");for(b=a.length;b--;)a[b]=y(a[b])*this["stroke-width"];a=a.join(",").replace("NaN","none");this.element.setAttribute("stroke-dasharray",a)}}, +alignSetter:function(a){this.element.setAttribute("text-anchor",{left:"start",center:"middle",right:"end"}[a])},opacitySetter:function(a,b,c){this[b]=a;c.setAttribute(b,a)},titleSetter:function(a){var b=this.element.getElementsByTagName("title")[0];b||(b=x.createElementNS(xa,"title"),this.element.appendChild(b));b.textContent=p(a,"").replace(/<[^>]*>/g,"")},textSetter:function(a){if(a!==this.textStr)delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this)},fillSetter:function(a,b, +c){typeof a==="string"?c.setAttribute(b,a):a&&this.colorGradient(a,b,c)},zIndexSetter:function(a,b,c){c.setAttribute(b,a);this[b]=a},_defaultSetter:function(a,b,c){c.setAttribute(b,a)}};S.prototype.yGetter=S.prototype.xGetter;S.prototype.translateXSetter=S.prototype.translateYSetter=S.prototype.rotationSetter=S.prototype.verticalAlignSetter=S.prototype.scaleXSetter=S.prototype.scaleYSetter=function(a,b){this[b]=a;this.doTransform=!0};S.prototype["stroke-widthSetter"]=S.prototype.strokeSetter=function(a, +b,c){this[b]=a;if(this.stroke&&this["stroke-width"])this.strokeWidth=this["stroke-width"],S.prototype.fillSetter.call(this,this.stroke,"stroke",c),c.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0;else if(b==="stroke-width"&&a===0&&this.hasStroke)c.removeAttribute("stroke"),this.hasStroke=!1};var ta=function(){this.init.apply(this,arguments)};ta.prototype={Element:S,init:function(a,b,c,d,e){var f=location,g,d=this.createElement("svg").attr({version:"1.1"}).css(this.getStyle(d)); +g=d.element;a.appendChild(g);a.innerHTML.indexOf("xmlns")===-1&&F(g,"xmlns",xa);this.isSVG=!0;this.box=g;this.boxWrapper=d;this.alignedObjects=[];this.url=(Ua||tb)&&x.getElementsByTagName("base").length?f.href.replace(/#.*?$/,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(x.createTextNode("Created with Highcharts 4.0.4"));this.defs=this.createElement("defs").add();this.forExport=e;this.gradients={};this.cache={};this.setSize(b,c,!1);var h; +if(Ua&&a.getBoundingClientRect)this.subPixelFix=b=function(){B(a,{left:0,top:0});h=a.getBoundingClientRect();B(a,{left:La(h.left)-h.left+"px",top:La(h.top)-h.top+"px"})},b(),N(G,"resize",b)},getStyle:function(a){return this.style=r({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();Pa(this.gradients|| +{});this.gradients=null;if(a)this.defs=a.destroy();this.subPixelFix&&X(G,"resize",this.subPixelFix);return this.alignedObjects=null},createElement:function(a){var b=new this.Element;b.init(this,a);return b},draw:function(){},buildText:function(a){for(var b=a.element,c=this,d=c.forExport,e=p(a.textStr,"").toString(),f=e.indexOf("<")!==-1,g=b.childNodes,h,i,j=F(b,"x"),k=a.styles,l=a.textWidth,n=k&&k.lineHeight,m=k&&k.HcTextStroke,o=g.length,Y=function(a){return n?y(n):c.fontMetrics(/(px|em)$/.test(a&& +a.style.fontSize)?a.style.fontSize:k&&k.fontSize||c.style.fontSize||12,a).h};o--;)b.removeChild(g[o]);!f&&!m&&e.indexOf(" ")===-1?b.appendChild(x.createTextNode(e)):(h=/<.*style="([^"]+)".*>/,i=/<.*href="(http[^"]+)".*>/,l&&!a.added&&this.box.appendChild(b),e=f?e.replace(/<(b|strong)>/g,'<span style="font-weight:bold">').replace(/<(i|em)>/g,'<span style="font-style:italic">').replace(/<a/g,"<span").replace(/<\/(b|strong|i|em|a)>/g,"</span>").split(/<br.*?>/g):[e],e[e.length-1]===""&&e.pop(),q(e,function(e, +f){var g,n=0,e=e.replace(/<span/g,"|||<span").replace(/<\/span>/g,"</span>|||");g=e.split("|||");q(g,function(e){if(e!==""||g.length===1){var m={},o=x.createElementNS(xa,"tspan"),p;h.test(e)&&(p=e.match(h)[1].replace(/(;| |^)color([ :])/,"$1fill$2"),F(o,"style",p));i.test(e)&&!d&&(F(o,"onclick",'location.href="'+e.match(i)[1]+'"'),B(o,{cursor:"pointer"}));e=(e.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"<").replace(/>/g,">");if(e!==" "){o.appendChild(x.createTextNode(e));if(n)m.dx=0;else if(f&& +j!==null)m.x=j;F(o,m);b.appendChild(o);!n&&f&&(!ba&&d&&B(o,{display:"block"}),F(o,"dy",Y(o)));if(l)for(var e=e.replace(/([^\^])-/g,"$1- ").split(" "),m=g.length>1||e.length>1&&k.whiteSpace!=="nowrap",q,D,s=k.HcHeight,t=[],u=Y(o),Lb=1;m&&(e.length||t.length);)delete a.bBox,q=a.getBBox(),D=q.width,!ba&&c.forExport&&(D=c.measureSpanWidth(o.firstChild.data,a.styles)),q=D>l,!q||e.length===1?(e=t,t=[],e.length&&(Lb++,s&&Lb*u>s?(e=["..."],a.attr("title",a.textStr)):(o=x.createElementNS(xa,"tspan"),F(o,{dy:u, +x:j}),p&&F(o,"style",p),b.appendChild(o))),D>l&&(l=D)):(o.removeChild(o.firstChild),t.unshift(e.pop())),e.length&&o.appendChild(x.createTextNode(e.join(" ").replace(/- /g,"-")));n++}}})}))},button:function(a,b,c,d,e,f,g,h,i){var j=this.label(a,b,c,i,null,null,null,null,"button"),k=0,l,n,m,o,p,q,a={x1:0,y1:0,x2:0,y2:1},e=w({"stroke-width":1,stroke:"#CCCCCC",fill:{linearGradient:a,stops:[[0,"#FEFEFE"],[1,"#F6F6F6"]]},r:2,padding:5,style:{color:"black"}},e);m=e.style;delete e.style;f=w(e,{stroke:"#68A", +fill:{linearGradient:a,stops:[[0,"#FFF"],[1,"#ACF"]]}},f);o=f.style;delete f.style;g=w(e,{stroke:"#68A",fill:{linearGradient:a,stops:[[0,"#9BD"],[1,"#CDF"]]}},g);p=g.style;delete g.style;h=w(e,{style:{color:"#CCC"}},h);q=h.style;delete h.style;N(j.element,Aa?"mouseover":"mouseenter",function(){k!==3&&j.attr(f).css(o)});N(j.element,Aa?"mouseout":"mouseleave",function(){k!==3&&(l=[e,f,g][k],n=[m,o,p][k],j.attr(l).css(n))});j.setState=function(a){(j.state=k=a)?a===2?j.attr(g).css(p):a===3&&j.attr(h).css(q): +j.attr(e).css(m)};return j.on("click",function(){k!==3&&d.call(j)}).attr(e).css(r({cursor:"default"},m))},crispLine:function(a,b){a[1]===a[4]&&(a[1]=a[4]=v(a[1])-b%2/2);a[2]===a[5]&&(a[2]=a[5]=v(a[2])+b%2/2);return a},path:function(a){var b={fill:P};Ha(a)?b.d=a:da(a)&&r(b,a);return this.createElement("path").attr(b)},circle:function(a,b,c){a=da(a)?a:{x:a,y:b,r:c};b=this.createElement("circle");b.xSetter=function(a){this.element.setAttribute("cx",a)};b.ySetter=function(a){this.element.setAttribute("cy", +a)};return b.attr(a)},arc:function(a,b,c,d,e,f){if(da(a))b=a.y,c=a.r,d=a.innerR,e=a.start,f=a.end,a=a.x;a=this.symbol("arc",a||0,b||0,c||0,c||0,{innerR:d||0,start:e||0,end:f||0});a.r=c;return a},rect:function(a,b,c,d,e,f){var e=da(a)?a.r:e,g=this.createElement("rect"),a=da(a)?a:a===u?{}:{x:a,y:b,width:t(c,0),height:t(d,0)};if(f!==u)a.strokeWidth=f,a=g.crisp(a);if(e)a.r=e;g.rSetter=function(a){F(this.element,{rx:a,ry:a})};return g.attr(a)},setSize:function(a,b,c){var d=this.alignedObjects,e=d.length; +this.width=a;this.height=b;for(this.boxWrapper[p(c,!0)?"animate":"attr"]({width:a,height:b});e--;)d[e].align()},g:function(a){var b=this.createElement("g");return s(a)?b.attr({"class":"highcharts-"+a}):b},image:function(a,b,c,d,e){var f={preserveAspectRatio:P};arguments.length>1&&r(f,{x:b,y:c,width:d,height:e});f=this.createElement("image").attr(f);f.element.setAttributeNS?f.element.setAttributeNS("http://www.w3.org/1999/xlink","href",a):f.element.setAttribute("hc-svg-href",a);return f},symbol:function(a, +b,c,d,e,f){var g,h=this.symbols[a],h=h&&h(v(b),v(c),d,e,f),i=/^url\((.*?)\)$/,j,k;if(h)g=this.path(h),r(g,{symbolName:a,x:b,y:c,width:d,height:e}),f&&r(g,f);else if(i.test(a))k=function(a,b){a.element&&(a.attr({width:b[0],height:b[1]}),a.alignByTranslate||a.translate(v((d-b[0])/2),v((e-b[1])/2)))},j=a.match(i)[1],a=Jb[j]||f&&f.width&&f.height&&[f.width,f.height],g=this.image(j).attr({x:b,y:c}),g.isImg=!0,a?k(g,a):(g.attr({width:0,height:0}),$("img",{onload:function(){k(g,Jb[j]=[this.width,this.height])}, +src:j}));return g},symbols:{circle:function(a,b,c,d){var e=0.166*c;return["M",a+c/2,b,"C",a+c+e,b,a+c+e,b+d,a+c/2,b+d,"C",a-e,b+d,a-e,b,a+c/2,b,"Z"]},square:function(a,b,c,d){return["M",a,b,"L",a+c,b,a+c,b+d,a,b+d,"Z"]},triangle:function(a,b,c,d){return["M",a+c/2,b,"L",a+c,b+d,a,b+d,"Z"]},"triangle-down":function(a,b,c,d){return["M",a,b,"L",a+c,b,a+c/2,b+d,"Z"]},diamond:function(a,b,c,d){return["M",a+c/2,b,"L",a+c,b+d/2,a+c/2,b+d,a,b+d/2,"Z"]},arc:function(a,b,c,d,e){var f=e.start,c=e.r||c||d,g=e.end- +0.001,d=e.innerR,h=e.open,i=aa(f),j=fa(f),k=aa(g),g=fa(g),e=e.end-f<oa?0:1;return["M",a+c*i,b+c*j,"A",c,c,0,e,1,a+c*k,b+c*g,h?"M":"L",a+d*k,b+d*g,"A",d,d,0,e,0,a+d*i,b+d*j,h?"":"Z"]},callout:function(a,b,c,d,e){var f=L(e&&e.r||0,c,d),g=f+6,h=e&&e.anchorX,i=e&&e.anchorY,e=v(e.strokeWidth||0)%2/2;a+=e;b+=e;e=["M",a+f,b,"L",a+c-f,b,"C",a+c,b,a+c,b,a+c,b+f,"L",a+c,b+d-f,"C",a+c,b+d,a+c,b+d,a+c-f,b+d,"L",a+f,b+d,"C",a,b+d,a,b+d,a,b+d-f,"L",a,b+f,"C",a,b,a,b,a+f,b];h&&h>c&&i>b+g&&i<b+d-g?e.splice(13,3, +"L",a+c,i-6,a+c+6,i,a+c,i+6,a+c,b+d-f):h&&h<0&&i>b+g&&i<b+d-g?e.splice(33,3,"L",a,i+6,a-6,i,a,i-6,a,b+f):i&&i>d&&h>a+g&&h<a+c-g?e.splice(23,3,"L",h+6,b+d,h,b+d+6,h-6,b+d,a+f,b+d):i&&i<0&&h>a+g&&h<a+c-g&&e.splice(3,3,"L",h-6,b,h,b-6,h+6,b,c-f,b);return e}},clipRect:function(a,b,c,d){var e="highcharts-"+ub++,f=this.createElement("clipPath").attr({id:e}).add(this.defs),a=this.rect(a,b,c,d,0).add(f);a.id=e;a.clipPath=f;return a},text:function(a,b,c,d){var e=ga||!ba&&this.forExport,f={};if(d&&!this.forExport)return this.html(a, +b,c);f.x=Math.round(b||0);if(c)f.y=Math.round(c);if(a||a===0)f.text=a;a=this.createElement("text").attr(f);e&&a.css({position:"absolute"});if(!d)a.xSetter=function(a,b,c){var d=c.getElementsByTagName("tspan"),e,f=c.getAttribute(b),n;for(n=0;n<d.length;n++)e=d[n],e.getAttribute(b)===f&&e.setAttribute(b,a);c.setAttribute(b,a)};return a},fontMetrics:function(a,b){a=a||this.style.fontSize;if(b&&G.getComputedStyle)b=b.element||b,a=G.getComputedStyle(b,"").fontSize;var a=/px/.test(a)?y(a):/em/.test(a)? +parseFloat(a)*12:12,c=a<24?a+4:v(a*1.2),d=v(c*0.8);return{h:c,b:d,f:a}},label:function(a,b,c,d,e,f,g,h,i){function j(){var a,b;a=o.element.style;D=(t===void 0||xb===void 0||m.styles.textAlign)&&o.textStr&&o.getBBox();m.width=(t||D.width||0)+2*C+kb;m.height=(xb||D.height||0)+2*C;R=C+n.fontMetrics(a&&a.fontSize,o).b;if(y){if(!p)a=v(-J*C),b=h?-R:0,m.box=p=d?n.symbol(d,a,b,m.width,m.height,z):n.rect(a,b,m.width,m.height,0,z[Qb]),p.attr("fill",P).add(m);p.isImg||p.attr(r({width:v(m.width),height:v(m.height)}, +z));z=null}}function k(){var a=m.styles,a=a&&a.textAlign,b=kb+C*(1-J),c;c=h?0:R;if(s(t)&&D&&(a==="center"||a==="right"))b+={center:0.5,right:1}[a]*(t-D.width);if(b!==o.x||c!==o.y)o.attr("x",b),c!==u&&o.attr("y",c);o.x=b;o.y=c}function l(a,b){p?p.attr(a,b):z[a]=b}var n=this,m=n.g(i),o=n.text("",0,0,g).attr({zIndex:1}),p,D,J=0,C=3,kb=0,t,xb,yb,x,Kb=0,z={},R,y;m.onAdd=function(){o.add(m);m.attr({text:a||a===0?a:"",x:b,y:c});p&&s(e)&&m.attr({anchorX:e,anchorY:f})};m.widthSetter=function(a){t=a};m.heightSetter= +function(a){xb=a};m.paddingSetter=function(a){s(a)&&a!==C&&(C=a,k())};m.paddingLeftSetter=function(a){s(a)&&a!==kb&&(kb=a,k())};m.alignSetter=function(a){J={left:0,center:0.5,right:1}[a]};m.textSetter=function(a){a!==u&&o.textSetter(a);j();k()};m["stroke-widthSetter"]=function(a,b){a&&(y=!0);Kb=a%2/2;l(b,a)};m.strokeSetter=m.fillSetter=m.rSetter=function(a,b){b==="fill"&&a&&(y=!0);l(b,a)};m.anchorXSetter=function(a,b){e=a;l(b,a+Kb-yb)};m.anchorYSetter=function(a,b){f=a;l(b,a-x)};m.xSetter=function(a){m.x= +a;J&&(a-=J*((t||D.width)+C));yb=v(a);m.attr("translateX",yb)};m.ySetter=function(a){x=m.y=v(a);m.attr("translateY",x)};var A=m.css;return r(m,{css:function(a){if(a){var b={},a=w(a);q(m.textProps,function(c){a[c]!==u&&(b[c]=a[c],delete a[c])});o.css(b)}return A.call(m,a)},getBBox:function(){return{width:D.width+2*C,height:D.height+2*C,x:D.x-C,y:D.y-C}},shadow:function(a){p&&p.shadow(a);return m},destroy:function(){X(m.element,"mouseenter");X(m.element,"mouseleave");o&&(o=o.destroy());p&&(p=p.destroy()); +S.prototype.destroy.call(m);m=n=j=k=l=null}})}};Za=ta;r(S.prototype,{htmlCss:function(a){var b=this.element;if(b=a&&b.tagName==="SPAN"&&a.width)delete a.width,this.textWidth=b,this.updateTransform();this.styles=r(this.styles,a);B(this.element,a);return this},htmlGetBBox:function(){var a=this.element,b=this.bBox;if(!b){if(a.nodeName==="text")a.style.position="absolute";b=this.bBox={x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}}return b},htmlUpdateTransform:function(){if(this.added){var a= +this.renderer,b=this.element,c=this.translateX||0,d=this.translateY||0,e=this.x||0,f=this.y||0,g=this.textAlign||"left",h={left:0,center:0.5,right:1}[g],i=this.shadows;B(b,{marginLeft:c,marginTop:d});i&&q(i,function(a){B(a,{marginLeft:c+1,marginTop:d+1})});this.inverted&&q(b.childNodes,function(c){a.invertChild(c,b)});if(b.tagName==="SPAN"){var j=this.rotation,k,l=y(this.textWidth),n=[j,g,b.innerHTML,this.textWidth].join(",");if(n!==this.cTT){k=a.fontMetrics(b.style.fontSize).b;s(j)&&this.setSpanRotation(j, +h,k);i=p(this.elemWidth,b.offsetWidth);if(i>l&&/[ \-]/.test(b.textContent||b.innerText))B(b,{width:l+"px",display:"block",whiteSpace:"normal"}),i=l;this.getSpanCorrection(i,k,h,j,g)}B(b,{left:e+(this.xCorr||0)+"px",top:f+(this.yCorr||0)+"px"});if(tb)k=b.offsetHeight;this.cTT=n}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,c){var d={},e=Aa?"-ms-transform":tb?"-webkit-transform":Ua?"MozTransform":Hb?"-o-transform":"";d[e]=d.transform="rotate("+a+"deg)";d[e+(Ua?"Origin":"-origin")]=d.transformOrigin= +b*100+"% "+c+"px";B(this.element,d)},getSpanCorrection:function(a,b,c){this.xCorr=-a*c;this.yCorr=-b}});r(ta.prototype,{html:function(a,b,c){var d=this.createElement("span"),e=d.element,f=d.renderer;d.textSetter=function(a){a!==e.innerHTML&&delete this.bBox;e.innerHTML=this.textStr=a};d.xSetter=d.ySetter=d.alignSetter=d.rotationSetter=function(a,b){b==="align"&&(b="textAlign");d[b]=a;d.htmlUpdateTransform()};d.attr({text:a,x:v(b),y:v(c)}).css({position:"absolute",whiteSpace:"nowrap",fontFamily:this.style.fontFamily, +fontSize:this.style.fontSize});d.css=d.htmlCss;if(f.isSVG)d.add=function(a){var b,c=f.box.parentNode,j=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)j.push(a),a=a.parentGroup;q(j.reverse(),function(a){var d;b=a.div=a.div||$(Ka,{className:F(a.element,"class")},{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px"},b||c);d=b.style;r(a,{translateXSetter:function(b,c){d.left=b+"px";a[c]=b;a.doTransform=!0},translateYSetter:function(b,c){d.top=b+"px";a[c]=b;a.doTransform=!0},visibilitySetter:function(a, +b){d[b]=a}})})}}else b=c;b.appendChild(e);d.added=!0;d.alignOnAdd&&d.htmlUpdateTransform();return d};return d}});var Z;if(!ba&&!ga){Z={init:function(a,b){var c=["<",b,' filled="f" stroked="f"'],d=["position: ","absolute",";"],e=b===Ka;(b==="shape"||e)&&d.push("left:0;top:0;width:1px;height:1px;");d.push("visibility: ",e?"hidden":"visible");c.push(' style="',d.join(""),'"/>');if(b)c=e||b==="span"||b==="img"?c.join(""):a.prepVML(c),this.element=$(c);this.renderer=a},add:function(a){var b=this.renderer, +c=this.element,d=b.box,d=a?a.element||a:d;a&&a.inverted&&b.invertChild(c,d);d.appendChild(c);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform();if(this.onAdd)this.onAdd();return this},updateTransform:S.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=aa(a*Ea),c=fa(a*Ea);B(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11=",b,", M12=",-c,", M21=",c,", M22=",b,", sizingMethod='auto expand')"].join(""):P})},getSpanCorrection:function(a, +b,c,d,e){var f=d?aa(d*Ea):1,g=d?fa(d*Ea):0,h=p(this.elemHeight,this.element.offsetHeight),i;this.xCorr=f<0&&-a;this.yCorr=g<0&&-h;i=f*g<0;this.xCorr+=g*b*(i?1-c:c);this.yCorr-=f*b*(d?i?c:1-c:1);e&&e!=="left"&&(this.xCorr-=a*c*(f<0?-1:1),d&&(this.yCorr-=h*c*(g<0?-1:1)),B(this.element,{textAlign:e}))},pathToVML:function(a){for(var b=a.length,c=[];b--;)if(ja(a[b]))c[b]=v(a[b]*10)-5;else if(a[b]==="Z")c[b]="x";else if(c[b]=a[b],a.isArc&&(a[b]==="wa"||a[b]==="at"))c[b+5]===c[b+7]&&(c[b+7]+=a[b+7]>a[b+ +5]?1:-1),c[b+6]===c[b+8]&&(c[b+8]+=a[b+8]>a[b+6]?1:-1);return c.join(" ")||"x"},clip:function(a){var b=this,c;a?(c=a.members,la(c,b),c.push(b),b.destroyClip=function(){la(c,b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:hb?"inherit":"rect(auto)"});return b.css(a)},css:S.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&Qa(a)},destroy:function(){this.destroyClip&&this.destroyClip();return S.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a= +G.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,b){var c,a=a.split(/[ ,]/);c=a.length;if(c===9||c===11)a[c-4]=a[c-2]=y(a[c-2])-10*b;return a.join(" ")},shadow:function(a,b,c){var d=[],e,f=this.element,g=this.renderer,h,i=f.style,j,k=f.path,l,n,m,o;k&&typeof k.value!=="string"&&(k="x");n=k;if(a){m=p(a.width,3);o=(a.opacity||0.15)/m;for(e=1;e<=3;e++){l=m*2+1-2*e;c&&(n=this.cutOffPath(k.value,l+0.5));j=['<shape isShadow="true" strokeweight="',l,'" filled="false" path="',n,'" coordsize="10 10" style="', +f.style.cssText,'" />'];h=$(g.prepVML(j),null,{left:y(i.left)+p(a.offsetX,1),top:y(i.top)+p(a.offsetY,1)});if(c)h.cutOff=l+1;j=['<stroke color="',a.color||"black",'" opacity="',o*e,'"/>'];$(g.prepVML(j),null,null,h);b?b.element.appendChild(h):f.parentNode.insertBefore(h,f);d.push(h)}this.shadows=d}return this},updateShadows:sa,setAttr:function(a,b){hb?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){this.element.className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]|| +$(this.renderer.prepVML(["<stroke/>"]),null,null,c))[b]=a||"solid";this[b]=a},dSetter:function(a,b,c){var d=this.shadows,a=a||[];this.d=a.join&&a.join(" ");c.path=a=this.pathToVML(a);if(d)for(c=d.length;c--;)d[c].path=d[c].cutOff?this.cutOffPath(a,d[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var d=c.nodeName;if(d==="SPAN")c.style.color=a;else if(d!=="IMG")c.filled=a!==P,this.setAttr("fillcolor",this.renderer.color(a,c,b,this))},opacitySetter:sa,rotationSetter:function(a,b,c){c=c.style; +this[b]=c[b]=a;c.left=-v(fa(a*Ea)+1)+"px";c.top=v(aa(a*Ea))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a;this[b]=a;ja(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){a==="inherit"&&(a="visible");this.shadows&&q(this.shadows,function(c){c.style[b]=a});c.nodeName==="DIV"&&(a=a==="hidden"?"-999em":0,hb||(c.style[b]=a?"visible":"hidden"), +b="top");c.style[b]=a},xSetter:function(a,b,c){this[b]=a;b==="x"?b="left":b==="y"&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}};K.VMLElement=Z=ma(S,Z);Z.prototype.ySetter=Z.prototype.widthSetter=Z.prototype.heightSetter=Z.prototype.xSetter;var ia={Element:Z,isIE8:wa.indexOf("MSIE 8.0")>-1,init:function(a,b,c,d){var e;this.alignedObjects=[];d=this.createElement(Ka).css(r(this.getStyle(d),{position:"relative"}));e=d.element; +a.appendChild(d.element);this.isVML=!0;this.box=e;this.boxWrapper=d;this.cache={};this.setSize(b,c,!1);if(!x.namespaces.hcv){x.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{x.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(f){x.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},isHidden:function(){return!this.box.offsetWidth}, +clipRect:function(a,b,c,d){var e=this.createElement(),f=da(a);return r(e,{members:[],left:(f?a.x:a)+1,top:(f?a.y:b)+1,width:(f?a.width:c)-1,height:(f?a.height:d)-1,getCSS:function(a){var b=a.element,c=b.nodeName,a=a.inverted,d=this.top-(c==="shape"?b.offsetTop:0),e=this.left,b=e+this.width,f=d+this.height,d={clip:"rect("+v(a?e:d)+"px,"+v(a?f:b)+"px,"+v(a?b:f)+"px,"+v(a?d:e)+"px)"};!a&&hb&&c==="DIV"&&r(d,{width:b+"px",height:f+"px"});return d},updateClipping:function(){q(e.members,function(a){a.element&& +a.css(e.getCSS(a))})}})},color:function(a,b,c,d){var e=this,f,g=/^rgba/,h,i,j=P;a&&a.linearGradient?i="gradient":a&&a.radialGradient&&(i="pattern");if(i){var k,l,n=a.linearGradient||a.radialGradient,m,o,p,D,J,C="",a=a.stops,t,s=[],u=function(){h=['<fill colors="'+s.join(",")+'" opacity="',p,'" o:opacity2="',o,'" type="',i,'" ',C,'focus="100%" method="any" />'];$(e.prepVML(h),null,null,b)};m=a[0];t=a[a.length-1];m[0]>0&&a.unshift([0,m[1]]);t[0]<1&&a.push([1,t[1]]);q(a,function(a,b){g.test(a[1])?(f= +ya(a[1]),k=f.get("rgb"),l=f.get("a")):(k=a[1],l=1);s.push(a[0]*100+"% "+k);b?(p=l,D=k):(o=l,J=k)});if(c==="fill")if(i==="gradient")c=n.x1||n[0]||0,a=n.y1||n[1]||0,m=n.x2||n[2]||0,n=n.y2||n[3]||0,C='angle="'+(90-V.atan((n-a)/(m-c))*180/oa)+'"',u();else{var j=n.r,r=j*2,v=j*2,x=n.cx,z=n.cy,R=b.radialReference,w,j=function(){R&&(w=d.getBBox(),x+=(R[0]-w.x)/w.width-0.5,z+=(R[1]-w.y)/w.height-0.5,r*=R[2]/w.width,v*=R[2]/w.height);C='src="'+E.global.VMLRadialGradientURL+'" size="'+r+","+v+'" origin="0.5,0.5" position="'+ +x+","+z+'" color2="'+J+'" ';u()};d.added?j():d.onAdd=j;j=D}else j=k}else if(g.test(a)&&b.tagName!=="IMG")f=ya(a),h=["<",c,' opacity="',f.get("a"),'"/>'],$(this.prepVML(h),null,null,b),j=f.get("rgb");else{j=b.getElementsByTagName(c);if(j.length)j[0].opacity=1,j[0].type="solid";j=a}return j},prepVML:function(a){var b=this.isIE8,a=a.join("");b?(a=a.replace("/>",' xmlns="urn:schemas-microsoft-com:vml" />'),a=a.indexOf('style="')===-1?a.replace("/>",' style="display:inline-block;behavior:url(#default#VML);" />'): +a.replace('style="','style="display:inline-block;behavior:url(#default#VML);')):a=a.replace("<","<hcv:");return a},text:ta.prototype.html,path:function(a){var b={coordsize:"10 10"};Ha(a)?b.d=a:da(a)&&r(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,c){var d=this.symbol("circle");if(da(a))c=a.r,b=a.y,a=a.x;d.isCircle=!0;d.r=c;return d.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement(Ka).attr(b)},image:function(a, +b,c,d,e){var f=this.createElement("img").attr({src:a});arguments.length>1&&f.attr({x:b,y:c,width:d,height:e});return f},createElement:function(a){return a==="rect"?this.symbol(a):ta.prototype.createElement.call(this,a)},invertChild:function(a,b){var c=this,d=b.style,e=a.tagName==="IMG"&&a.style;B(a,{flip:"x",left:y(d.width)-(e?y(e.top):1),top:y(d.height)-(e?y(e.left):1),rotation:-90});q(a.childNodes,function(b){c.invertChild(b,a)})},symbols:{arc:function(a,b,c,d,e){var f=e.start,g=e.end,h=e.r||c|| +d,c=e.innerR,d=aa(f),i=fa(f),j=aa(g),k=fa(g);if(g-f===0)return["x"];f=["wa",a-h,b-h,a+h,b+h,a+h*d,b+h*i,a+h*j,b+h*k];e.open&&!c&&f.push("e","M",a,b);f.push("at",a-c,b-c,a+c,b+c,a+c*j,b+c*k,a+c*d,b+c*i,"x","e");f.isArc=!0;return f},circle:function(a,b,c,d,e){e&&(c=d=2*e.r);e&&e.isCircle&&(a-=c/2,b-=d/2);return["wa",a,b,a+c,b+d,a+c,b+d/2,a+c,b+d/2,"e"]},rect:function(a,b,c,d,e){return ta.prototype.symbols[!s(e)||!e.r?"square":"callout"].call(0,a,b,c,d,e)}}};K.VMLRenderer=Z=function(){this.init.apply(this, +arguments)};Z.prototype=w(ta.prototype,ia);Za=Z}ta.prototype.measureSpanWidth=function(a,b){var c=x.createElement("span"),d;d=x.createTextNode(a);c.appendChild(d);B(c,b);this.box.appendChild(c);d=c.offsetWidth;Qa(c);return d};var Mb;if(ga)K.CanVGRenderer=Z=function(){xa="http://www.w3.org/1999/xhtml"},Z.prototype.symbols={},Mb=function(){function a(){var a=b.length,d;for(d=0;d<a;d++)b[d]();b=[]}var b=[];return{push:function(c,d){b.length===0&&Rb(d,a);b.push(c)}}}(),Za=Z;Ta.prototype={addLabel:function(){var a= +this.axis,b=a.options,c=a.chart,d=a.horiz,e=a.categories,f=a.names,g=this.pos,h=b.labels,i=h.rotation,j=a.tickPositions,d=d&&e&&!h.step&&!h.staggerLines&&!h.rotation&&c.plotWidth/j.length||!d&&(c.margin[3]||c.chartWidth*0.33),k=g===j[0],l=g===j[j.length-1],n,f=e?p(e[g],f[g],g):g,e=this.label,m=j.info;a.isDatetimeAxis&&m&&(n=b.dateTimeLabelFormats[m.higherRanks[g]||m.unitName]);this.isFirst=k;this.isLast=l;b=a.labelFormatter.call({axis:a,chart:c,isFirst:k,isLast:l,dateTimeLabelFormat:n,value:a.isLog? +ea(ka(f)):f});g=d&&{width:t(1,v(d-2*(h.padding||10)))+"px"};if(s(e))e&&e.attr({text:b}).css(g);else{n={align:a.labelAlign};if(ja(i))n.rotation=i;if(d&&h.ellipsis)g.HcHeight=a.len/j.length;this.label=e=s(b)&&h.enabled?c.renderer.text(b,0,0,h.useHTML).attr(n).css(r(g,h.style)).add(a.labelGroup):null;a.tickBaseline=c.renderer.fontMetrics(h.style.fontSize,e).b;i&&a.side===2&&(a.tickBaseline*=aa(i*Ea))}this.yOffset=e?p(h.y,a.tickBaseline+(a.side===2?8:-(e.getBBox().height/2))):0},getLabelSize:function(){var a= +this.label,b=this.axis;return a?a.getBBox()[b.horiz?"height":"width"]:0},getLabelSides:function(){var a=this.label.getBBox(),b=this.axis,c=b.horiz,d=b.options.labels,a=c?a.width:a.height,b=c?d.x-a*{left:0,center:0.5,right:1}[b.labelAlign]:0;return[b,c?a+b:a]},handleOverflow:function(a,b){var c=!0,d=this.axis,e=this.isFirst,f=this.isLast,g=d.horiz?b.x:b.y,h=d.reversed,i=d.tickPositions,j=this.getLabelSides(),k=j[0],j=j[1],l,n,m,o=this.label.line;l=o||0;n=d.labelEdge;m=d.justifyLabels&&(e||f);n[l]=== +u||g+k>n[l]?n[l]=g+j:m||(c=!1);if(m){l=(n=d.justifyToPlot)?d.pos:0;n=n?l+d.len:d.chart.chartWidth;do a+=e?1:-1,m=d.ticks[i[a]];while(i[a]&&(!m||!m.label||m.label.line!==o));d=m&&m.label.xy&&m.label.xy.x+m.getLabelSides()[e?0:1];e&&!h||f&&h?g+k<l&&(g=l-k,m&&g+j>d&&(c=!1)):g+j>n&&(g=n-j,m&&g+k<d&&(c=!1));b.x=g}return c},getPosition:function(a,b,c,d){var e=this.axis,f=e.chart,g=d&&f.oldChartHeight||f.chartHeight;return{x:a?e.translate(b+c,null,null,d)+e.transB:e.left+e.offset+(e.opposite?(d&&f.oldChartWidth|| +f.chartWidth)-e.right-e.left:0),y:a?g-e.bottom+e.offset-(e.opposite?e.height:0):g-e.translate(b+c,null,null,d)-e.transB}},getLabelPosition:function(a,b,c,d,e,f,g,h){var i=this.axis,j=i.transA,k=i.reversed,l=i.staggerLines,a=a+e.x-(f&&d?f*j*(k?-1:1):0),b=b+this.yOffset-(f&&!d?f*j*(k?1:-1):0);if(l)c.line=g/(h||1)%l,b+=c.line*(i.labelOffset/l);return{x:a,y:b}},getMarkPath:function(a,b,c,d,e,f){return f.crispLine(["M",a,b,"L",a+(e?0:-c),b+(e?c:0)],d)},render:function(a,b,c){var d=this.axis,e=d.options, +f=d.chart.renderer,g=d.horiz,h=this.type,i=this.label,j=this.pos,k=e.labels,l=this.gridLine,n=h?h+"Grid":"grid",m=h?h+"Tick":"tick",o=e[n+"LineWidth"],q=e[n+"LineColor"],D=e[n+"LineDashStyle"],J=e[m+"Length"],n=e[m+"Width"]||0,C=e[m+"Color"],t=e[m+"Position"],m=this.mark,s=k.step,r=!0,v=d.tickmarkOffset,w=this.getPosition(g,j,v,b),x=w.x,w=w.y,z=g&&x===d.pos+d.len||!g&&w===d.pos?-1:1,c=p(c,1);this.isActive=!0;if(o){j=d.getPlotLinePath(j+v,o*z,b,!0);if(l===u){l={stroke:q,"stroke-width":o};if(D)l.dashstyle= +D;if(!h)l.zIndex=1;if(b)l.opacity=0;this.gridLine=l=o?f.path(j).attr(l).add(d.gridGroup):null}if(!b&&l&&j)l[this.isNew?"attr":"animate"]({d:j,opacity:c})}if(n&&J)t==="inside"&&(J=-J),d.opposite&&(J=-J),h=this.getMarkPath(x,w,J,n*z,g,f),m?m.animate({d:h,opacity:c}):this.mark=f.path(h).attr({stroke:C,"stroke-width":n,opacity:c}).add(d.axisGroup);if(i&&!isNaN(x))i.xy=w=this.getLabelPosition(x,w,i,g,k,v,a,s),this.isFirst&&!this.isLast&&!p(e.showFirstLabel,1)||this.isLast&&!this.isFirst&&!p(e.showLastLabel, +1)?r=!1:!d.isRadial&&!k.step&&!k.rotation&&!b&&c!==0&&(r=this.handleOverflow(a,w)),s&&a%s&&(r=!1),r&&!isNaN(w.y)?(w.opacity=c,i[this.isNew?"attr":"animate"](w),this.isNew=!1):i.attr("y",-9999)},destroy:function(){Pa(this,this.axis)}};K.PlotLineOrBand=function(a,b){this.axis=a;if(b)this.options=b,this.id=b.id};K.PlotLineOrBand.prototype={render:function(){var a=this,b=a.axis,c=b.horiz,d=(b.pointRange||0)/2,e=a.options,f=e.label,g=a.label,h=e.width,i=e.to,j=e.from,k=s(j)&&s(i),l=e.value,n=e.dashStyle, +m=a.svgElem,o=[],p,q=e.color,J=e.zIndex,C=e.events,r={},u=b.chart.renderer;b.isLog&&(j=za(j),i=za(i),l=za(l));if(h){if(o=b.getPlotLinePath(l,h),r={stroke:q,"stroke-width":h},n)r.dashstyle=n}else if(k){j=t(j,b.min-d);i=L(i,b.max+d);o=b.getPlotBandPath(j,i,e);if(q)r.fill=q;if(e.borderWidth)r.stroke=e.borderColor,r["stroke-width"]=e.borderWidth}else return;if(s(J))r.zIndex=J;if(m)if(o)m.animate({d:o},null,m.onGetPath);else{if(m.hide(),m.onGetPath=function(){m.show()},g)a.label=g=g.destroy()}else if(o&& +o.length&&(a.svgElem=m=u.path(o).attr(r).add(),C))for(p in d=function(b){m.on(b,function(c){C[b].apply(a,[c])})},C)d(p);if(f&&s(f.text)&&o&&o.length&&b.width>0&&b.height>0){f=w({align:c&&k&&"center",x:c?!k&&4:10,verticalAlign:!c&&k&&"middle",y:c?k?16:10:k?6:-4,rotation:c&&!k&&90},f);if(!g){r={align:f.textAlign||f.align,rotation:f.rotation};if(s(J))r.zIndex=J;a.label=g=u.text(f.text,0,0,f.useHTML).attr(r).css(f.style).add()}b=[o[1],o[4],k?o[6]:o[1]];k=[o[2],o[5],k?o[7]:o[2]];o=Oa(b);c=Oa(k);g.align(f, +!1,{x:o,y:c,width:Ca(b)-o,height:Ca(k)-c});g.show()}else g&&g.hide();return a},destroy:function(){la(this.axis.plotLinesAndBands,this);delete this.axis;Pa(this)}};na.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,gridLineColor:"#C0C0C0",labels:M,lineColor:"#C0D0E0",lineWidth:1,minPadding:0.01,maxPadding:0.01,minorGridLineColor:"#E0E0E0",minorGridLineWidth:1,minorTickColor:"#A0A0A0", +minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickColor:"#C0D0E0",tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",tickWidth:1,title:{align:"middle",style:{color:"#707070"}},type:"linear"},defaultYAxisOptions:{endOnTick:!0,gridLineWidth:1,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8,y:3},lineWidth:0,maxPadding:0.05,minPadding:0.05,startOnTick:!0,tickWidth:0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return Ba(this.total, +-1)},style:M.style}},defaultLeftAxisOptions:{labels:{x:-15,y:null},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15,y:null},title:{rotation:90}},defaultBottomAxisOptions:{labels:{x:0,y:null},title:{rotation:0}},defaultTopAxisOptions:{labels:{x:0,y:-15},title:{rotation:0}},init:function(a,b){var c=b.isX;this.horiz=a.inverted?!c:c;this.coll=(this.isXAxis=c)?"xAxis":"yAxis";this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var d= +this.options,e=d.type;this.labelFormatter=d.labels.formatter||this.defaultLabelFormatter;this.userOptions=b;this.minPixelPadding=0;this.chart=a;this.reversed=d.reversed;this.zoomEnabled=d.zoomEnabled!==!1;this.categories=d.categories||e==="category";this.names=[];this.isLog=e==="logarithmic";this.isDatetimeAxis=e==="datetime";this.isLinked=s(d.linkedTo);this.tickmarkOffset=this.categories&&d.tickmarkPlacement==="between"&&p(d.tickInterval,1)===1?0.5:0;this.ticks={};this.labelEdge=[];this.minorTicks= +{};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=d.minRange||d.maxZoom;this.range=d.range;this.offset=d.offset||0;this.stacks={};this.oldStacks={};this.min=this.max=null;this.crosshair=p(d.crosshair,ra(a.options.tooltip.crosshairs)[c?0:1],!1);var f,d=this.options.events;Ma(this,a.axes)===-1&&(c&&!this.isColorAxis?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];if(a.inverted&&c&&this.reversed=== +u)this.reversed=!0;this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(f in d)N(this,f,d[f]);if(this.isLog)this.val2lin=za,this.lin2val=ka},setOptions:function(a){this.options=w(this.defaultOptions,this.isXAxis?{}:this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],w(E[this.coll],a))},defaultLabelFormatter:function(){var a=this.axis,b=this.value,c=a.categories,d=this.dateTimeLabelFormat, +e=E.lang.numericSymbols,f=e&&e.length,g,h=a.options.labels.format,a=a.isLog?b:a.tickInterval;if(h)g=Ja(h,this);else if(c)g=b;else if(d)g=cb(d,b);else if(f&&a>=1E3)for(;f--&&g===u;)c=Math.pow(1E3,f+1),a>=c&&e[f]!==null&&(g=Ba(b/c,-1)+e[f]);g===u&&(g=Q(b)>=1E4?Ba(b,0):Ba(b,-1,u,""));return g},getSeriesExtremes:function(){var a=this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.ignoreMinPadding=a.ignoreMaxPadding=null;a.buildStacks&&a.buildStacks();q(a.series,function(c){if(c.visible||!b.options.chart.ignoreHiddenSeries){var d; +d=c.options.threshold;var e;a.hasVisibleSeries=!0;a.isLog&&d<=0&&(d=null);if(a.isXAxis){if(d=c.xData,d.length)a.dataMin=L(p(a.dataMin,d[0]),Oa(d)),a.dataMax=t(p(a.dataMax,d[0]),Ca(d))}else{c.getExtremes();e=c.dataMax;c=c.dataMin;if(s(c)&&s(e))a.dataMin=L(p(a.dataMin,c),c),a.dataMax=t(p(a.dataMax,e),e);if(s(d))if(a.dataMin>=d)a.dataMin=d,a.ignoreMinPadding=!0;else if(a.dataMax<d)a.dataMax=d,a.ignoreMaxPadding=!0}}})},translate:function(a,b,c,d,e,f){var g=1,h=0,i=d?this.oldTransA:this.transA,d=d?this.oldMin: +this.min,j=this.minPixelPadding,e=(this.options.ordinal||this.isLog&&e)&&this.lin2val;if(!i)i=this.transA;if(c)g*=-1,h=this.len;this.reversed&&(g*=-1,h-=g*(this.sector||this.len));b?(a=a*g+h,a-=j,a=a/i+d,e&&(a=this.lin2val(a))):(e&&(a=this.val2lin(a)),f==="between"&&(f=0.5),a=g*(a-d)*i+h+g*j+(ja(f)?i*f*this.pointRange:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null, +!0)},getPlotLinePath:function(a,b,c,d,e){var f=this.chart,g=this.left,h=this.top,i,j,k=c&&f.oldChartHeight||f.chartHeight,l=c&&f.oldChartWidth||f.chartWidth,n;i=this.transB;e=p(e,this.translate(a,null,null,c));a=c=v(e+i);i=j=v(k-e-i);if(isNaN(e))n=!0;else if(this.horiz){if(i=h,j=k-this.bottom,a<g||a>g+this.width)n=!0}else if(a=g,c=l-this.right,i<h||i>h+this.height)n=!0;return n&&!d?null:f.renderer.crispLine(["M",a,i,"L",c,j],b||1)},getLinearTickPositions:function(a,b,c){var d,e=ea(U(b/a)*a),f=ea(La(c/ +a)*a),g=[];if(b===c&&ja(b))return[b];for(b=e;b<=f;){g.push(b);b=ea(b+a);if(b===d)break;d=b}return g},getMinorTickPositions:function(){var a=this.options,b=this.tickPositions,c=this.minorTickInterval,d=[],e;if(this.isLog){e=b.length;for(a=1;a<e;a++)d=d.concat(this.getLogTickPositions(c,b[a-1],b[a],!0))}else if(this.isDatetimeAxis&&a.minorTickInterval==="auto")d=d.concat(this.getTimeTicks(this.normalizeTimeTickInterval(c),this.min,this.max,a.startOfWeek)),d[0]<this.min&&d.shift();else for(b=this.min+ +(b[0]-this.min)%c;b<=this.max;b+=c)d.push(b);return d},adjustForMinRange:function(){var a=this.options,b=this.min,c=this.max,d,e=this.dataMax-this.dataMin>=this.minRange,f,g,h,i,j;if(this.isXAxis&&this.minRange===u&&!this.isLog)s(a.min)||s(a.max)?this.minRange=null:(q(this.series,function(a){i=a.xData;for(g=j=a.xIncrement?1:i.length-1;g>0;g--)if(h=i[g]-i[g-1],f===u||h<f)f=h}),this.minRange=L(f*5,this.dataMax-this.dataMin));if(c-b<this.minRange){var k=this.minRange;d=(k-c+b)/2;d=[b-d,p(a.min,b-d)]; +if(e)d[2]=this.dataMin;b=Ca(d);c=[b+k,p(a.max,b+k)];if(e)c[2]=this.dataMax;c=Oa(c);c-b<k&&(d[0]=c-k,d[1]=p(a.min,c-k),b=Ca(d))}this.min=b;this.max=c},setAxisTranslation:function(a){var b=this,c=b.max-b.min,d=b.axisPointRange||0,e,f=0,g=0,h=b.linkedParent,i=!!b.categories,j=b.transA;if(b.isXAxis||i||d)h?(f=h.minPointOffset,g=h.pointRangePadding):q(b.series,function(a){var h=i?1:b.isXAxis?a.pointRange:b.axisPointRange||0,j=a.options.pointPlacement,m=a.closestPointRange;h>c&&(h=0);d=t(d,h);f=t(f,Ga(j)? +0:h/2);g=t(g,j==="on"?0:h);!a.noSharedTooltip&&s(m)&&(e=s(e)?L(e,m):m)}),h=b.ordinalSlope&&e?b.ordinalSlope/e:1,b.minPointOffset=f*=h,b.pointRangePadding=g*=h,b.pointRange=L(d,c),b.closestPointRange=e;if(a)b.oldTransA=j;b.translationSlope=b.transA=j=b.len/(c+g||1);b.transB=b.horiz?b.left:b.bottom;b.minPixelPadding=j*f},setTickPositions:function(a){var b=this,c=b.chart,d=b.options,e=d.startOnTick,f=d.endOnTick,g=b.isLog,h=b.isDatetimeAxis,i=b.isXAxis,j=b.isLinked,k=b.options.tickPositioner,l=d.maxPadding, +n=d.minPadding,m=d.tickInterval,o=d.minTickInterval,Y=d.tickPixelInterval,D,J=b.categories;j?(b.linkedParent=c[b.coll][d.linkedTo],c=b.linkedParent.getExtremes(),b.min=p(c.min,c.dataMin),b.max=p(c.max,c.dataMax),d.type!==b.linkedParent.options.type&&ha(11,1)):(b.min=p(b.userMin,d.min,b.dataMin),b.max=p(b.userMax,d.max,b.dataMax));if(g)!a&&L(b.min,p(b.dataMin,b.min))<=0&&ha(10,1),b.min=ea(za(b.min)),b.max=ea(za(b.max));if(b.range&&s(b.max))b.userMin=b.min=t(b.min,b.max-b.range),b.userMax=b.max,b.range= +null;b.beforePadding&&b.beforePadding();b.adjustForMinRange();if(!J&&!b.axisPointRange&&!b.usePercentage&&!j&&s(b.min)&&s(b.max)&&(c=b.max-b.min)){if(!s(d.min)&&!s(b.userMin)&&n&&(b.dataMin<0||!b.ignoreMinPadding))b.min-=c*n;if(!s(d.max)&&!s(b.userMax)&&l&&(b.dataMax>0||!b.ignoreMaxPadding))b.max+=c*l}if(ja(d.floor))b.min=t(b.min,d.floor);if(ja(d.ceiling))b.max=L(b.max,d.ceiling);b.min===b.max||b.min===void 0||b.max===void 0?b.tickInterval=1:j&&!m&&Y===b.linkedParent.options.tickPixelInterval?b.tickInterval= +b.linkedParent.tickInterval:(b.tickInterval=p(m,J?1:(b.max-b.min)*Y/t(b.len,Y)),!s(m)&&b.len<Y&&!this.isRadial&&!this.isLog&&!J&&e&&f&&(D=!0,b.tickInterval/=4));i&&!a&&q(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)});b.setAxisTranslation(!0);b.beforeSetTickPositions&&b.beforeSetTickPositions();if(b.postProcessTickInterval)b.tickInterval=b.postProcessTickInterval(b.tickInterval);if(b.pointRange)b.tickInterval=t(b.pointRange,b.tickInterval);if(!m&&b.tickInterval<o)b.tickInterval= +o;if(!h&&!g&&!m)b.tickInterval=nb(b.tickInterval,null,mb(b.tickInterval),p(d.allowDecimals,!(b.tickInterval>1&&b.tickInterval<5&&b.max>1E3&&b.max<9999)));b.minorTickInterval=d.minorTickInterval==="auto"&&b.tickInterval?b.tickInterval/5:d.minorTickInterval;b.tickPositions=a=d.tickPositions?[].concat(d.tickPositions):k&&k.apply(b,[b.min,b.max]);if(!a)!b.ordinalPositions&&(b.max-b.min)/b.tickInterval>t(2*b.len,200)&&ha(19,!0),a=h?b.getTimeTicks(b.normalizeTimeTickInterval(b.tickInterval,d.units),b.min, +b.max,d.startOfWeek,b.ordinalPositions,b.closestPointRange,!0):g?b.getLogTickPositions(b.tickInterval,b.min,b.max):b.getLinearTickPositions(b.tickInterval,b.min,b.max),D&&a.splice(1,a.length-2),b.tickPositions=a;if(!j)d=a[0],g=a[a.length-1],h=b.minPointOffset||0,e?b.min=d:b.min-h>d&&a.shift(),f?b.max=g:b.max+h<g&&a.pop(),a.length===0&&s(d)&&a.push((g+d)/2),a.length===1&&(e=Q(b.max)>1E13?1:0.001,b.min-=e,b.max+=e)},setMaxTicks:function(){var a=this.chart,b=a.maxTicks||{},c=this.tickPositions,d=this._maxTicksKey= +[this.coll,this.pos,this.len].join("-");if(!this.isLinked&&!this.isDatetimeAxis&&c&&c.length>(b[d]||0)&&this.options.alignTicks!==!1)b[d]=c.length;a.maxTicks=b},adjustTickAmount:function(){var a=this._maxTicksKey,b=this.tickPositions,c=this.chart.maxTicks;if(c&&c[a]&&!this.isDatetimeAxis&&!this.categories&&!this.isLinked&&this.options.alignTicks!==!1&&this.min!==u){var d=this.tickAmount,e=b.length;this.tickAmount=a=c[a];if(e<a){for(;b.length<a;)b.push(ea(b[b.length-1]+this.tickInterval));this.transA*= +(e-1)/(a-1);this.max=b[b.length-1]}if(s(d)&&a!==d)this.isDirty=!0}},setScale:function(){var a=this.stacks,b,c,d,e;this.oldMin=this.min;this.oldMax=this.max;this.oldAxisLength=this.len;this.setAxisSize();e=this.len!==this.oldAxisLength;q(this.series,function(a){if(a.isDirtyData||a.isDirty||a.xAxis.isDirty)d=!0});if(e||d||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax){if(!this.isXAxis)for(b in a)for(c in a[b])a[b][c].total=null,a[b][c].cum=0;this.forceRedraw= +!1;this.getSeriesExtremes();this.setTickPositions();this.oldUserMin=this.userMin;this.oldUserMax=this.userMax;if(!this.isDirty)this.isDirty=e||this.min!==this.oldMin||this.max!==this.oldMax}else if(!this.isXAxis){if(this.oldStacks)a=this.stacks=this.oldStacks;for(b in a)for(c in a[b])a[b][c].cum=a[b][c].total}this.setMaxTicks()},setExtremes:function(a,b,c,d,e){var f=this,g=f.chart,c=p(c,!0),e=r(e,{min:a,max:b});I(f,"setExtremes",e,function(){f.userMin=a;f.userMax=b;f.eventArgs=e;f.isDirtyExtremes= +!0;c&&g.redraw(d)})},zoom:function(a,b){var c=this.dataMin,d=this.dataMax,e=this.options;this.allowZoomOutside||(s(c)&&a<=L(c,p(e.min,c))&&(a=u),s(d)&&b>=t(d,p(e.max,d))&&(b=u));this.displayBtn=a!==u||b!==u;this.setExtremes(a,b,!1,u,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsetLeft||0,d=this.horiz,e=p(b.width,a.plotWidth-c+(b.offsetRight||0)),f=p(b.height,a.plotHeight),g=p(b.top,a.plotTop),b=p(b.left,a.plotLeft+c),c=/%$/;c.test(f)&&(f=parseInt(f,10)/ +100*a.plotHeight);c.test(g)&&(g=parseInt(g,10)/100*a.plotHeight+a.plotTop);this.left=b;this.top=g;this.width=e;this.height=f;this.bottom=a.chartHeight-f-g;this.right=a.chartWidth-e-b;this.len=t(d?e:f,0);this.pos=d?b:g},getExtremes:function(){var a=this.isLog;return{min:a?ea(ka(this.min)):this.min,max:a?ea(ka(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,c=b?ka(this.min):this.min,b=b?ka(this.max): +this.max;c>a||a===null?a=c:b<a&&(a=b);return this.translate(a,0,1,0,1)},autoLabelAlign:function(a){a=(p(a,0)-this.side*90+720)%360;return a>15&&a<165?"right":a>195&&a<345?"left":"center"},getOffset:function(){var a=this,b=a.chart,c=b.renderer,d=a.options,e=a.tickPositions,f=a.ticks,g=a.horiz,h=a.side,i=b.inverted?[1,0,3,2][h]:h,j,k,l=0,n,m=0,o=d.title,Y=d.labels,D=0,J=b.axisOffset,b=b.clipOffset,C=[-1,1,1,-1][h],r,v=1,w=p(Y.maxStaggerLines,5),x,y,A,z,R;a.hasData=j=a.hasVisibleSeries||s(a.min)&&s(a.max)&& +!!e;a.showAxis=k=j||p(d.showEmpty,!0);a.staggerLines=a.horiz&&Y.staggerLines;if(!a.axisGroup)a.gridGroup=c.g("grid").attr({zIndex:d.gridZIndex||1}).add(),a.axisGroup=c.g("axis").attr({zIndex:d.zIndex||2}).add(),a.labelGroup=c.g("axis-labels").attr({zIndex:Y.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels").add();if(j||a.isLinked){a.labelAlign=p(Y.align||a.autoLabelAlign(Y.rotation));q(e,function(b){f[b]?f[b].addLabel():f[b]=new Ta(a,b)});if(a.horiz&&!a.staggerLines&&w&&!Y.rotation){for(j= +a.reversed?[].concat(e).reverse():e;v<w;){x=[];y=!1;for(r=0;r<j.length;r++)A=j[r],z=(z=f[A].label&&f[A].label.getBBox())?z.width:0,R=r%v,z&&(A=a.translate(A),x[R]!==u&&A<x[R]&&(y=!0),x[R]=A+z);if(y)v++;else break}if(v>1)a.staggerLines=v}q(e,function(b){if(h===0||h===2||{1:"left",3:"right"}[h]===a.labelAlign)D=t(f[b].getLabelSize(),D)});if(a.staggerLines)D*=a.staggerLines,a.labelOffset=D}else for(r in f)f[r].destroy(),delete f[r];if(o&&o.text&&o.enabled!==!1){if(!a.axisTitle)a.axisTitle=c.text(o.text, +0,0,o.useHTML).attr({zIndex:7,rotation:o.rotation||0,align:o.textAlign||{low:"left",middle:"center",high:"right"}[o.align]}).addClass("highcharts-"+this.coll.toLowerCase()+"-title").css(o.style).add(a.axisGroup),a.axisTitle.isNew=!0;if(k)l=a.axisTitle.getBBox()[g?"height":"width"],n=o.offset,m=s(n)?0:p(o.margin,g?5:10);a.axisTitle[k?"show":"hide"]()}a.offset=C*p(d.offset,J[h]);c=h===2?a.tickBaseline:0;g=D+m+(D&&C*(g?p(Y.y,a.tickBaseline+8):Y.x)-c);a.axisTitleMargin=p(n,g);J[h]=t(J[h],a.axisTitleMargin+ +l+C*a.offset,g);b[i]=t(b[i],U(d.lineWidth/2)*2)},getLinePath:function(a){var b=this.chart,c=this.opposite,d=this.offset,e=this.horiz,f=this.left+(c?this.width:0)+d,d=b.chartHeight-this.bottom-(c?this.height:0)+d;c&&(a*=-1);return b.renderer.crispLine(["M",e?this.left:f,e?d:this.top,"L",e?b.chartWidth-this.right:f,e?d:b.chartHeight-this.bottom],a)},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,d=this.len,e=this.options.title,f=a?b:c,g=this.opposite,h=this.offset,i=y(e.style.fontSize|| +12),d={low:f+(a?0:d),middle:f+d/2,high:f+(a?d:0)}[e.align],b=(a?c+this.height:b)+(a?1:-1)*(g?-1:1)*this.axisTitleMargin+(this.side===2?i:0);return{x:a?d:b+(g?this.width:0)+h+(e.x||0),y:a?b-(g?this.height:0)+h:d+(e.y||0)}},render:function(){var a=this,b=a.horiz,c=a.reversed,d=a.chart,e=d.renderer,f=a.options,g=a.isLog,h=a.isLinked,i=a.tickPositions,j,k=a.axisTitle,l=a.ticks,n=a.minorTicks,m=a.alternateBands,o=f.stackLabels,p=f.alternateGridColor,D=a.tickmarkOffset,J=f.lineWidth,C=d.hasRendered&&s(a.oldMin)&& +!isNaN(a.oldMin),r=a.hasData,t=a.showAxis,v,w=f.labels.overflow,x=a.justifyLabels=b&&w!==!1,A;a.labelEdge.length=0;a.justifyToPlot=w==="justify";q([l,n,m],function(a){for(var b in a)a[b].isActive=!1});if(r||h)if(a.minorTickInterval&&!a.categories&&q(a.getMinorTickPositions(),function(b){n[b]||(n[b]=new Ta(a,b,"minor"));C&&n[b].isNew&&n[b].render(null,!0);n[b].render(null,!1,1)}),i.length&&(j=i.slice(),(b&&c||!b&&!c)&&j.reverse(),x&&(j=j.slice(1).concat([j[0]])),q(j,function(b,c){x&&(c=c===j.length- +1?0:c+1);if(!h||b>=a.min&&b<=a.max)l[b]||(l[b]=new Ta(a,b)),C&&l[b].isNew&&l[b].render(c,!0,0.1),l[b].render(c)}),D&&a.min===0&&(l[-1]||(l[-1]=new Ta(a,-1,null,!0)),l[-1].render(-1))),p&&q(i,function(b,c){if(c%2===0&&b<a.max)m[b]||(m[b]=new K.PlotLineOrBand(a)),v=b+D,A=i[c+1]!==u?i[c+1]+D:a.max,m[b].options={from:g?ka(v):v,to:g?ka(A):A,color:p},m[b].render(),m[b].isActive=!0}),!a._addedPlotLB)q((f.plotLines||[]).concat(f.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0;q([l,n, +m],function(a){var b,c,e=[],f=va?va.duration||500:0,g=function(){for(c=e.length;c--;)a[e[c]]&&!a[e[c]].isActive&&(a[e[c]].destroy(),delete a[e[c]])};for(b in a)if(!a[b].isActive)a[b].render(b,!1,0),a[b].isActive=!1,e.push(b);a===m||!d.hasRendered||!f?g():f&&setTimeout(g,f)});if(J)b=a.getLinePath(J),a.axisLine?a.axisLine.animate({d:b}):a.axisLine=e.path(b).attr({stroke:f.lineColor,"stroke-width":J,zIndex:7}).add(a.axisGroup),a.axisLine[t?"show":"hide"]();if(k&&t)k[k.isNew?"attr":"animate"](a.getTitlePosition()), +k.isNew=!1;o&&o.enabled&&a.renderStackTotals();a.isDirty=!1},redraw:function(){this.render();q(this.plotLinesAndBands,function(a){a.render()});q(this.series,function(a){a.isDirty=!0})},destroy:function(a){var b=this,c=b.stacks,d,e=b.plotLinesAndBands;a||X(b);for(d in c)Pa(c[d]),c[d]=null;q([b.ticks,b.minorTicks,b.alternateBands],function(a){Pa(a)});for(a=e.length;a--;)e[a].destroy();q("stackTotalGroup,axisLine,axisTitle,axisGroup,cross,gridGroup,labelGroup".split(","),function(a){b[a]&&(b[a]=b[a].destroy())}); +this.cross&&this.cross.destroy()},drawCrosshair:function(a,b){if(this.crosshair)if((s(b)||!p(this.crosshair.snap,!0))===!1)this.hideCrosshair();else{var c,d=this.crosshair,e=d.animation;p(d.snap,!0)?s(b)&&(c=this.chart.inverted!=this.horiz?b.plotX:this.len-b.plotY):c=this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos;c=this.isRadial?this.getPlotLinePath(this.isXAxis?b.x:p(b.stackY,b.y)):this.getPlotLinePath(null,null,null,null,c);if(c===null)this.hideCrosshair();else if(this.cross)this.cross.attr({visibility:"visible"})[e? +"animate":"attr"]({d:c},e);else{e={"stroke-width":d.width||1,stroke:d.color||"#C0C0C0",zIndex:d.zIndex||2};if(d.dashStyle)e.dashstyle=d.dashStyle;this.cross=this.chart.renderer.path(c).attr(e).add()}}},hideCrosshair:function(){this.cross&&this.cross.hide()}};r(na.prototype,{getPlotBandPath:function(a,b){var c=this.getPlotLinePath(b),d=this.getPlotLinePath(a);d&&c?d.push(c[4],c[5],c[1],c[2]):d=null;return d},addPlotBand:function(a){return this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){return this.addPlotBandOrLine(a, +"plotLines")},addPlotBandOrLine:function(a,b){var c=(new K.PlotLineOrBand(this,a)).render(),d=this.userOptions;c&&(b&&(d[b]=d[b]||[],d[b].push(a)),this.plotLinesAndBands.push(c));return c},removePlotBandOrLine:function(a){for(var b=this.plotLinesAndBands,c=this.options,d=this.userOptions,e=b.length;e--;)b[e].id===a&&b[e].destroy();q([c.plotLines||[],d.plotLines||[],c.plotBands||[],d.plotBands||[]],function(b){for(e=b.length;e--;)b[e].id===a&&la(b,b[e])})}});na.prototype.getTimeTicks=function(a,b, +c,d){var e=[],f={},g=E.global.useUTC,h,i=new Da(b-Sa),j=a.unitRange,k=a.count;if(s(b)){j>=A.second&&(i.setMilliseconds(0),i.setSeconds(j>=A.minute?0:k*U(i.getSeconds()/k)));if(j>=A.minute)i[Cb](j>=A.hour?0:k*U(i[pb]()/k));if(j>=A.hour)i[Db](j>=A.day?0:k*U(i[qb]()/k));if(j>=A.day)i[sb](j>=A.month?1:k*U(i[Xa]()/k));j>=A.month&&(i[Eb](j>=A.year?0:k*U(i[fb]()/k)),h=i[gb]());j>=A.year&&(h-=h%k,i[Fb](h));if(j===A.week)i[sb](i[Xa]()-i[rb]()+p(d,1));b=1;Sa&&(i=new Da(i.getTime()+Sa));h=i[gb]();for(var d= +i.getTime(),l=i[fb](),n=i[Xa](),m=(A.day+(g?Sa:i.getTimezoneOffset()*6E4))%A.day;d<c;)e.push(d),j===A.year?d=eb(h+b*k,0):j===A.month?d=eb(h,l+b*k):!g&&(j===A.day||j===A.week)?d=eb(h,l,n+b*k*(j===A.day?1:7)):d+=j*k,b++;e.push(d);q(wb(e,function(a){return j<=A.hour&&a%A.day===m}),function(a){f[a]="day"})}e.info=r(a,{higherRanks:f,totalRange:j*k});return e};na.prototype.normalizeTimeTickInterval=function(a,b){var c=b||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute", +[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],d=c[c.length-1],e=A[d[0]],f=d[1],g;for(g=0;g<c.length;g++)if(d=c[g],e=A[d[0]],f=d[1],c[g+1]&&a<=(e*f[f.length-1]+A[c[g+1][0]])/2)break;e===A.year&&a<5*e&&(f=[1,2,5]);c=nb(a/e,f,d[0]==="year"?t(mb(a/e),1):1);return{unitRange:e,count:c,unitName:d[0]}};na.prototype.getLogTickPositions=function(a,b,c,d){var e=this.options,f=this.len,g=[];if(!d)this._minorAutoInterval=null;if(a>=0.5)a=v(a),g=this.getLinearTickPositions(a, +b,c);else if(a>=0.08)for(var f=U(b),h,i,j,k,l,e=a>0.3?[1,2,4]:a>0.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];f<c+1&&!l;f++){i=e.length;for(h=0;h<i&&!l;h++)j=za(ka(f)*e[h]),j>b&&(!d||k<=c)&&k!==u&&g.push(k),k>c&&(l=!0),k=j}else if(b=ka(b),c=ka(c),a=e[d?"minorTickInterval":"tickInterval"],a=p(a==="auto"?null:a,this._minorAutoInterval,(c-b)*(e.tickPixelInterval/(d?5:1))/((d?f/this.tickPositions.length:f)||1)),a=nb(a,null,mb(a)),g=Va(this.getLinearTickPositions(a,b,c),za),!d)this._minorAutoInterval=a/5;if(!d)this.tickInterval= +a;return g};var Nb=K.Tooltip=function(){this.init.apply(this,arguments)};Nb.prototype={init:function(a,b){var c=b.borderWidth,d=b.style,e=y(d.padding);this.chart=a;this.options=b;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.label=a.renderer.label("",0,0,b.shape||"callout",null,null,b.useHTML,null,"tooltip").attr({padding:e,fill:b.backgroundColor,"stroke-width":c,r:b.borderRadius,zIndex:8}).css(d).css({padding:0}).add().attr({y:-9999});ga||this.label.shadow(b.shadow);this.shared=b.shared}, +destroy:function(){if(this.label)this.label=this.label.destroy();clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},move:function(a,b,c,d){var e=this,f=e.now,g=e.options.animation!==!1&&!e.isHidden&&(Q(a-f.x)>1||Q(b-f.y)>1),h=e.followPointer||e.len>1;r(f,{x:g?(2*f.x+a)/3:a,y:g?(f.y+b)/2:b,anchorX:h?u:g?(2*f.anchorX+c)/3:c,anchorY:h?u:g?(f.anchorY+d)/2:d});e.label.attr(f);if(g)clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){e&&e.move(a,b,c,d)},32)},hide:function(a){var b= +this,c;clearTimeout(this.hideTimer);if(!this.isHidden)c=this.chart.hoverPoints,this.hideTimer=setTimeout(function(){b.label.fadeOut();b.isHidden=!0},p(a,this.options.hideDelay,500)),c&&q(c,function(a){a.setState()}),this.chart.hoverPoints=null},getAnchor:function(a,b){var c,d=this.chart,e=d.inverted,f=d.plotTop,g=0,h=0,i,a=ra(a);c=a[0].tooltipPos;this.followPointer&&b&&(b.chartX===u&&(b=d.pointer.normalize(b)),c=[b.chartX-d.plotLeft,b.chartY-f]);c||(q(a,function(a){i=a.series.yAxis;g+=a.plotX;h+= +(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!e&&i?i.top-f:0)}),g/=a.length,h/=a.length,c=[e?d.plotWidth-h:g,this.shared&&!e&&a.length>1&&b?b.chartY-f:e?d.plotHeight-g:h]);return Va(c,v)},getPosition:function(a,b,c){var d=this.chart,e=this.distance,f={},g,h=["y",d.chartHeight,b,c.plotY+d.plotTop],i=["x",d.chartWidth,a,c.plotX+d.plotLeft],j=c.ttBelow||d.inverted&&!c.negative||!d.inverted&&c.negative,k=function(a,b,c,d){var g=c<d-e,b=d+e+c<b,c=d-e-c;d+=e;if(j&&b)f[a]=d;else if(!j&&g)f[a]=c;else if(g)f[a]= +c;else if(b)f[a]=d;else return!1},l=function(a,b,c,d){if(d<e||d>b-e)return!1;else f[a]=d<c/2?1:d>b-c/2?b-c-2:d-c/2},n=function(a){var b=h;h=i;i=b;g=a},m=function(){k.apply(0,h)!==!1?l.apply(0,i)===!1&&!g&&(n(!0),m()):g?f.x=f.y=0:(n(!0),m())};(d.inverted||this.len>1)&&n();m();return f},defaultFormatter:function(a){var b=this.points||ra(this),c=b[0].series,d;d=[a.tooltipHeaderFormatter(b[0])];q(b,function(a){c=a.series;d.push(c.tooltipFormatter&&c.tooltipFormatter(a)||a.point.tooltipFormatter(c.tooltipOptions.pointFormat))}); +d.push(a.options.footerFormat||"");return d.join("")},refresh:function(a,b){var c=this.chart,d=this.label,e=this.options,f,g,h={},i,j=[];i=e.formatter||this.defaultFormatter;var h=c.hoverPoints,k,l=this.shared;clearTimeout(this.hideTimer);this.followPointer=ra(a)[0].series.tooltipOptions.followPointer;g=this.getAnchor(a,b);f=g[0];g=g[1];l&&(!a.series||!a.series.noSharedTooltip)?(c.hoverPoints=a,h&&q(h,function(a){a.setState()}),q(a,function(a){a.setState("hover");j.push(a.getLabelConfig())}),h={x:a[0].category, +y:a[0].y},h.points=j,this.len=j.length,a=a[0]):h=a.getLabelConfig();i=i.call(h,this);h=a.series;this.distance=p(h.tooltipOptions.distance,16);i===!1?this.hide():(this.isHidden&&(bb(d),d.attr("opacity",1).show()),d.attr({text:i}),k=e.borderColor||a.color||h.color||"#606060",d.attr({stroke:k}),this.updatePosition({plotX:f,plotY:g,negative:a.negative,ttBelow:a.ttBelow}),this.isHidden=!1);I(c,"tooltipRefresh",{text:i,x:f+c.plotLeft,y:g+c.plotTop,borderColor:k})},updatePosition:function(a){var b=this.chart, +c=this.label,c=(this.options.positioner||this.getPosition).call(this,c.width,c.height,a);this.move(v(c.x),v(c.y),a.plotX+b.plotLeft,a.plotY+b.plotTop)},tooltipHeaderFormatter:function(a){var b=a.series,c=b.tooltipOptions,d=c.dateTimeLabelFormats,e=c.xDateFormat,f=b.xAxis,g=f&&f.options.type==="datetime"&&ja(a.key),c=c.headerFormat,f=f&&f.closestPointRange,h;if(g&&!e){if(f)for(h in A){if(A[h]>=f||A[h]<=A.day&&a.key%A[h]>0){e=d[h];break}}else e=d.day;e=e||d.year}g&&e&&(c=c.replace("{point.key}","{point.key:"+ +e+"}"));return Ja(c,{point:a,series:b})}};var pa;$a=x.documentElement.ontouchstart!==u;var Wa=K.Pointer=function(a,b){this.init(a,b)};Wa.prototype={init:function(a,b){var c=b.chart,d=c.events,e=ga?"":c.zoomType,c=a.inverted,f;this.options=b;this.chart=a;this.zoomX=f=/x/.test(e);this.zoomY=e=/y/.test(e);this.zoomHor=f&&!c||e&&c;this.zoomVert=e&&!c||f&&c;this.hasZoom=f||e;this.runChartClick=d&&!!d.click;this.pinchDown=[];this.lastValidTouch={};if(K.Tooltip&&b.tooltip.enabled)a.tooltip=new Nb(a,b.tooltip), +this.followTouchMove=b.tooltip.followTouchMove;this.setDOMEvents()},normalize:function(a,b){var c,d,a=a||window.event,a=Tb(a);if(!a.target)a.target=a.srcElement;d=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;if(!b)this.chartPosition=b=Sb(this.chart.container);d.pageX===u?(c=t(a.x,a.clientX-b.left),d=a.y):(c=d.pageX-b.left,d=d.pageY-b.top);return r(a,{chartX:v(c),chartY:v(d)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};q(this.chart.axes,function(c){b[c.isXAxis?"xAxis": +"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},getIndex:function(a){var b=this.chart;return b.inverted?b.plotHeight+b.plotTop-a.chartY:a.chartX-b.plotLeft},runPointActions:function(a){var b=this.chart,c=b.series,d=b.tooltip,e,f,g=b.hoverPoint,h=b.hoverSeries,i,j,k=b.chartWidth,l=this.getIndex(a);if(d&&this.options.tooltip.shared&&(!h||!h.noSharedTooltip)){f=[];i=c.length;for(j=0;j<i;j++)if(c[j].visible&&c[j].options.enableMouseTracking!==!1&&!c[j].noSharedTooltip&& +c[j].singularTooltips!==!0&&c[j].tooltipPoints.length&&(e=c[j].tooltipPoints[l])&&e.series)e._dist=Q(l-e.clientX),k=L(k,e._dist),f.push(e);for(i=f.length;i--;)f[i]._dist>k&&f.splice(i,1);if(f.length&&f[0].clientX!==this.hoverX)d.refresh(f,a),this.hoverX=f[0].clientX}c=h&&h.tooltipOptions.followPointer;if(h&&h.tracker&&!c){if((e=h.tooltipPoints[l])&&e!==g)e.onMouseOver(a)}else d&&c&&!d.isHidden&&(h=d.getAnchor([{}],a),d.updatePosition({plotX:h[0],plotY:h[1]}));if(d&&!this._onDocumentMouseMove)this._onDocumentMouseMove= +function(a){if(W[pa])W[pa].pointer.onDocumentMouseMove(a)},N(x,"mousemove",this._onDocumentMouseMove);q(b.axes,function(b){b.drawCrosshair(a,p(e,g))})},reset:function(a,b){var c=this.chart,d=c.hoverSeries,e=c.hoverPoint,f=c.tooltip,g=f&&f.shared?c.hoverPoints:e;(a=a&&f&&g)&&ra(g)[0].plotX===u&&(a=!1);if(a)f.refresh(g),e&&e.setState(e.state,!0);else{if(e)e.onMouseOut();if(d)d.onMouseOut();f&&f.hide(b);if(this._onDocumentMouseMove)X(x,"mousemove",this._onDocumentMouseMove),this._onDocumentMouseMove= +null;q(c.axes,function(a){a.hideCrosshair()});this.hoverX=null}},scaleGroups:function(a,b){var c=this.chart,d;q(c.series,function(e){d=a||e.getPlotBox();e.xAxis&&e.xAxis.zoomEnabled&&(e.group.attr(d),e.markerGroup&&(e.markerGroup.attr(d),e.markerGroup.clip(b?c.clipRect:null)),e.dataLabelsGroup&&e.dataLabelsGroup.attr(d))});c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY}, +drag:function(a){var b=this.chart,c=b.options.chart,d=a.chartX,e=a.chartY,f=this.zoomHor,g=this.zoomVert,h=b.plotLeft,i=b.plotTop,j=b.plotWidth,k=b.plotHeight,l,n=this.mouseDownX,m=this.mouseDownY,o=c.panKey&&a[c.panKey+"Key"];d<h?d=h:d>h+j&&(d=h+j);e<i?e=i:e>i+k&&(e=i+k);this.hasDragged=Math.sqrt(Math.pow(n-d,2)+Math.pow(m-e,2));if(this.hasDragged>10){l=b.isInsidePlot(n-h,m-i);if(b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&l&&!o&&!this.selectionMarker)this.selectionMarker=b.renderer.rect(h,i, +f?1:j,g?1:k,0).attr({fill:c.selectionMarkerFill||"rgba(69,114,167,0.25)",zIndex:7}).add();this.selectionMarker&&f&&(d-=n,this.selectionMarker.attr({width:Q(d),x:(d>0?0:d)+n}));this.selectionMarker&&g&&(d=e-m,this.selectionMarker.attr({height:Q(d),y:(d>0?0:d)+m}));l&&!this.selectionMarker&&c.panning&&b.pan(a,c.panning)}},drop:function(a){var b=this.chart,c=this.hasPinched;if(this.selectionMarker){var d={xAxis:[],yAxis:[],originalEvent:a.originalEvent||a},e=this.selectionMarker,f=e.attr?e.attr("x"): +e.x,g=e.attr?e.attr("y"):e.y,h=e.attr?e.attr("width"):e.width,i=e.attr?e.attr("height"):e.height,j;if(this.hasDragged||c)q(b.axes,function(b){if(b.zoomEnabled){var c=b.horiz,e=a.type==="touchend"?b.minPixelPadding:0,m=b.toValue((c?f:g)+e),c=b.toValue((c?f+h:g+i)-e);!isNaN(m)&&!isNaN(c)&&(d[b.coll].push({axis:b,min:L(m,c),max:t(m,c)}),j=!0)}}),j&&I(b,"selection",d,function(a){b.zoom(r(a,c?{animation:!1}:null))});this.selectionMarker=this.selectionMarker.destroy();c&&this.scaleGroups()}if(b)B(b.container, +{cursor:b._cursor}),b.cancelClick=this.hasDragged>10,b.mouseIsDown=this.hasDragged=this.hasPinched=!1,this.pinchDown=[]},onContainerMouseDown:function(a){a=this.normalize(a);a.preventDefault&&a.preventDefault();this.dragStart(a)},onDocumentMouseUp:function(a){W[pa]&&W[pa].pointer.drop(a)},onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition,d=b.hoverSeries,a=this.normalize(a,c);c&&d&&!this.inClass(a.target,"highcharts-tracker")&&!b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)&& +this.reset()},onContainerMouseLeave:function(){var a=W[pa];if(a)a.pointer.reset(),a.pointer.chartPosition=null},onContainerMouseMove:function(a){var b=this.chart;pa=b.index;a=this.normalize(a);a.returnValue=!1;b.mouseIsDown==="mousedown"&&this.drag(a);(this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop))&&!b.openMenu&&this.runPointActions(a)},inClass:function(a,b){for(var c;a;){if(c=F(a,"class"))if(c.indexOf(b)!==-1)return!0;else if(c.indexOf("highcharts-container")!== +-1)return!1;a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries,c=(a=a.relatedTarget||a.toElement)&&a.point&&a.point.series;if(b&&!b.options.stickyTracking&&!this.inClass(a,"highcharts-tooltip")&&c!==b)b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,d=b.plotLeft,e=b.plotTop,a=this.normalize(a);a.cancelBubble=!0;b.cancelClick||(c&&this.inClass(a.target,"highcharts-tracker")?(I(c.series,"click",r(a,{point:c})),b.hoverPoint&&c.firePointEvent("click", +a)):(r(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-d,a.chartY-e)&&I(b,"click",a)))},setDOMEvents:function(){var a=this,b=a.chart.container;b.onmousedown=function(b){a.onContainerMouseDown(b)};b.onmousemove=function(b){a.onContainerMouseMove(b)};b.onclick=function(b){a.onContainerClick(b)};N(b,"mouseleave",a.onContainerMouseLeave);ab===1&&N(x,"mouseup",a.onDocumentMouseUp);if($a)b.ontouchstart=function(b){a.onContainerTouchStart(b)},b.ontouchmove=function(b){a.onContainerTouchMove(b)},ab===1&& +N(x,"touchend",a.onDocumentTouchEnd)},destroy:function(){var a;X(this.chart.container,"mouseleave",this.onContainerMouseLeave);ab||(X(x,"mouseup",this.onDocumentMouseUp),X(x,"touchend",this.onDocumentTouchEnd));clearInterval(this.tooltipTimeout);for(a in this)this[a]=null}};r(K.Pointer.prototype,{pinchTranslate:function(a,b,c,d,e,f){(this.zoomHor||this.pinchHor)&&this.pinchTranslateDirection(!0,a,b,c,d,e,f);(this.zoomVert||this.pinchVert)&&this.pinchTranslateDirection(!1,a,b,c,d,e,f)},pinchTranslateDirection:function(a, +b,c,d,e,f,g,h){var i=this.chart,j=a?"x":"y",k=a?"X":"Y",l="chart"+k,n=a?"width":"height",m=i["plot"+(a?"Left":"Top")],o,p,q=h||1,r=i.inverted,C=i.bounds[a?"h":"v"],t=b.length===1,s=b[0][l],v=c[0][l],u=!t&&b[1][l],w=!t&&c[1][l],x,c=function(){!t&&Q(s-u)>20&&(q=h||Q(v-w)/Q(s-u));p=(m-v)/q+s;o=i["plot"+(a?"Width":"Height")]/q};c();b=p;b<C.min?(b=C.min,x=!0):b+o>C.max&&(b=C.max-o,x=!0);x?(v-=0.8*(v-g[j][0]),t||(w-=0.8*(w-g[j][1])),c()):g[j]=[v,w];r||(f[j]=p-m,f[n]=o);f=r?1/q:q;e[n]=o;e[j]=b;d[r?a?"scaleY": +"scaleX":"scale"+k]=q;d["translate"+k]=f*m+(v-f*s)},pinch:function(a){var b=this,c=b.chart,d=b.pinchDown,e=b.followTouchMove,f=a.touches,g=f.length,h=b.lastValidTouch,i=b.hasZoom,j=b.selectionMarker,k={},l=g===1&&(b.inClass(a.target,"highcharts-tracker")&&c.runTrackerClick||b.runChartClick),n={};(i||e)&&!l&&a.preventDefault();Va(f,function(a){return b.normalize(a)});if(a.type==="touchstart")q(f,function(a,b){d[b]={chartX:a.chartX,chartY:a.chartY}}),h.x=[d[0].chartX,d[1]&&d[1].chartX],h.y=[d[0].chartY, +d[1]&&d[1].chartY],q(c.axes,function(a){if(a.zoomEnabled){var b=c.bounds[a.horiz?"h":"v"],d=a.minPixelPadding,e=a.toPixels(p(a.options.min,a.dataMin)),f=a.toPixels(p(a.options.max,a.dataMax)),g=L(e,f),e=t(e,f);b.min=L(a.pos,g-d);b.max=t(a.pos+a.len,e+d)}}),b.res=!0;else if(d.length){if(!j)b.selectionMarker=j=r({destroy:sa},c.plotBox);b.pinchTranslate(d,f,k,j,n,h);b.hasPinched=i;b.scaleGroups(k,n);if(!i&&e&&g===1)this.runPointActions(b.normalize(a));else if(b.res)b.res=!1,this.reset(!1,0)}},onContainerTouchStart:function(a){var b= +this.chart;pa=b.index;a.touches.length===1?(a=this.normalize(a),b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)?(this.runPointActions(a),this.pinch(a)):this.reset()):a.touches.length===2&&this.pinch(a)},onContainerTouchMove:function(a){(a.touches.length===1||a.touches.length===2)&&this.pinch(a)},onDocumentTouchEnd:function(a){W[pa]&&W[pa].pointer.drop(a)}});if(G.PointerEvent||G.MSPointerEvent){var ua={},zb=!!G.PointerEvent,Xb=function(){var a,b=[];b.item=function(a){return this[a]};for(a in ua)ua.hasOwnProperty(a)&& +b.push({pageX:ua[a].pageX,pageY:ua[a].pageY,target:ua[a].target});return b},Ab=function(a,b,c,d){a=a.originalEvent||a;if((a.pointerType==="touch"||a.pointerType===a.MSPOINTER_TYPE_TOUCH)&&W[pa])d(a),d=W[pa].pointer,d[b]({type:c,target:a.currentTarget,preventDefault:sa,touches:Xb()})};r(Wa.prototype,{onContainerPointerDown:function(a){Ab(a,"onContainerTouchStart","touchstart",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){Ab(a, +"onContainerTouchMove","touchmove",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY};if(!ua[a.pointerId].target)ua[a.pointerId].target=a.currentTarget})},onDocumentPointerUp:function(a){Ab(a,"onContainerTouchEnd","touchend",function(a){delete ua[a.pointerId]})},batchMSEvents:function(a){a(this.chart.container,zb?"pointerdown":"MSPointerDown",this.onContainerPointerDown);a(this.chart.container,zb?"pointermove":"MSPointerMove",this.onContainerPointerMove);a(x,zb?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}}); +Na(Wa.prototype,"init",function(a,b,c){a.call(this,b,c);(this.hasZoom||this.followTouchMove)&&B(b.container,{"-ms-touch-action":P,"touch-action":P})});Na(Wa.prototype,"setDOMEvents",function(a){a.apply(this);(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(N)});Na(Wa.prototype,"destroy",function(a){this.batchMSEvents(X);a.call(this)})}var lb=K.Legend=function(a,b){this.init(a,b)};lb.prototype={init:function(a,b){var c=this,d=b.itemStyle,e=p(b.padding,8),f=b.itemMarginTop||0;this.options=b; +if(b.enabled)c.itemStyle=d,c.itemHiddenStyle=w(d,b.itemHiddenStyle),c.itemMarginTop=f,c.padding=e,c.initialItemX=e,c.initialItemY=e-5,c.maxItemWidth=0,c.chart=a,c.itemHeight=0,c.lastLineHeight=0,c.symbolWidth=p(b.symbolWidth,16),c.pages=[],c.render(),N(c.chart,"endResize",function(){c.positionCheckboxes()})},colorizeItem:function(a,b){var c=this.options,d=a.legendItem,e=a.legendLine,f=a.legendSymbol,g=this.itemHiddenStyle.color,c=b?c.itemStyle.color:g,h=b?a.legendColor||a.color||"#CCC":g,g=a.options&& +a.options.marker,i={fill:h},j;d&&d.css({fill:c,color:c});e&&e.attr({stroke:h});if(f){if(g&&f.isMarker)for(j in i.stroke=h,g=a.convertAttribs(g),g)d=g[j],d!==u&&(i[j]=d);f.attr(i)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,d=a._legendItemPos,e=d[0],d=d[1],f=a.checkbox;a.legendGroup&&a.legendGroup.translate(b?e:this.legendWidth-e-2*c-4,d);if(f)f.x=e,f.y=d},destroyItem:function(a){var b=a.checkbox;q(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&& +(a[b]=a[b].destroy())});b&&Qa(a.checkbox)},destroy:function(){var a=this.group,b=this.box;if(b)this.box=b.destroy();if(a)this.group=a.destroy()},positionCheckboxes:function(a){var b=this.group.alignAttr,c,d=this.clipHeight||this.legendHeight;if(b)c=b.translateY,q(this.allItems,function(e){var f=e.checkbox,g;f&&(g=c+f.y+(a||0)+3,B(f,{left:b.translateX+e.checkboxOffset+f.x-20+"px",top:g+"px",display:g>c-6&&g<c+d-6?"":P}))})},renderTitle:function(){var a=this.padding,b=this.options.title,c=0;if(b.text){if(!this.title)this.title= +this.chart.renderer.label(b.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(b.style).add(this.group);a=this.title.getBBox();c=a.height;this.offsetWidth=a.width;this.contentGroup.attr({translateY:c})}this.titleHeight=c},renderItem:function(a){var b=this.chart,c=b.renderer,d=this.options,e=d.layout==="horizontal",f=this.symbolWidth,g=d.symbolPadding,h=this.itemStyle,i=this.itemHiddenStyle,j=this.padding,k=e?p(d.itemDistance,20):0,l=!d.rtl,n=d.width,m=d.itemMarginBottom||0, +o=this.itemMarginTop,q=this.initialItemX,r=a.legendItem,s=a.series&&a.series.drawLegendSymbol?a.series:a,C=s.options,C=this.createCheckboxForItem&&C&&C.showCheckbox,u=d.useHTML;if(!r){a.legendGroup=c.g("legend-item").attr({zIndex:1}).add(this.scrollGroup);a.legendItem=r=c.text(d.labelFormat?Ja(d.labelFormat,a):d.labelFormatter.call(a),l?f+g:-g,this.baseline||0,u).css(w(a.visible?h:i)).attr({align:l?"left":"right",zIndex:2}).add(a.legendGroup);if(!this.baseline)this.baseline=c.fontMetrics(h.fontSize, +r).f+3+o,r.attr("y",this.baseline);s.drawLegendSymbol(this,a);this.setItemEvents&&this.setItemEvents(a,r,u,h,i);this.colorizeItem(a,a.visible);C&&this.createCheckboxForItem(a)}c=r.getBBox();f=a.checkboxOffset=d.itemWidth||a.legendItemWidth||f+g+c.width+k+(C?20:0);this.itemHeight=g=v(a.legendItemHeight||c.height);if(e&&this.itemX-q+f>(n||b.chartWidth-2*j-q-d.x))this.itemX=q,this.itemY+=o+this.lastLineHeight+m,this.lastLineHeight=0;this.maxItemWidth=t(this.maxItemWidth,f);this.lastItemY=o+this.itemY+ +m;this.lastLineHeight=t(g,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];e?this.itemX+=f:(this.itemY+=o+g+m,this.lastLineHeight=g);this.offsetWidth=n||t((e?this.itemX-q-k:f)+j,this.offsetWidth)},getAllItems:function(){var a=[];q(this.chart.series,function(b){var c=b.options;if(p(c.showInLegend,!s(c.linkedTo)?u:!1,!0))a=a.concat(b.legendItems||(c.legendType==="point"?b.data:b))});return a},render:function(){var a=this,b=a.chart,c=b.renderer,d=a.group,e,f,g,h,i=a.box,j=a.options,k=a.padding, +l=j.borderWidth,n=j.backgroundColor;a.itemX=a.initialItemX;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;if(!d)a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup);a.renderTitle();e=a.getAllItems();ob(e,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});j.reversed&&e.reverse();a.allItems=e;a.display=f=!!e.length;q(e,function(b){a.renderItem(b)});g=j.width||a.offsetWidth; +h=a.lastItemY+a.lastLineHeight+a.titleHeight;h=a.handleOverflow(h);if(l||n){g+=k;h+=k;if(i){if(g>0&&h>0)i[i.isNew?"attr":"animate"](i.crisp({width:g,height:h})),i.isNew=!1}else a.box=i=c.rect(0,0,g,h,j.borderRadius,l||0).attr({stroke:j.borderColor,"stroke-width":l||0,fill:n||P}).add(d).shadow(j.shadow),i.isNew=!0;i[f?"show":"hide"]()}a.legendWidth=g;a.legendHeight=h;q(e,function(b){a.positionItem(b)});f&&d.align(r({width:g,height:h},j),!0,"spacingBox");b.isResizing||this.positionCheckboxes()},handleOverflow:function(a){var b= +this,c=this.chart,d=c.renderer,e=this.options,f=e.y,f=c.spacingBox.height+(e.verticalAlign==="top"?-f:f)-this.padding,g=e.maxHeight,h,i=this.clipRect,j=e.navigation,k=p(j.animation,!0),l=j.arrowSize||12,n=this.nav,m=this.pages,o,r=this.allItems;e.layout==="horizontal"&&(f/=2);g&&(f=L(f,g));m.length=0;if(a>f&&!e.useHTML){this.clipHeight=h=t(f-20-this.titleHeight-this.padding,0);this.currentPage=p(this.currentPage,1);this.fullHeight=a;q(r,function(a,b){var c=a._legendItemPos[1],d=v(a.legendItem.getBBox().height), +e=m.length;if(!e||c-m[e-1]>h&&(o||c)!==m[e-1])m.push(o||c),e++;b===r.length-1&&c+d-m[e-1]>h&&m.push(c);c!==o&&(o=c)});if(!i)i=b.clipRect=d.clipRect(0,this.padding,9999,0),b.contentGroup.clip(i);i.attr({height:h});if(!n)this.nav=n=d.g().attr({zIndex:1}).add(this.group),this.up=d.symbol("triangle",0,0,l,l).on("click",function(){b.scroll(-1,k)}).add(n),this.pager=d.text("",15,10).css(j.style).add(n),this.down=d.symbol("triangle-down",0,0,l,l).on("click",function(){b.scroll(1,k)}).add(n);b.scroll(0); +a=f}else if(n)i.attr({height:c.chartHeight}),n.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0;return a},scroll:function(a,b){var c=this.pages,d=c.length,e=this.currentPage+a,f=this.clipHeight,g=this.options.navigation,h=g.activeColor,g=g.inactiveColor,i=this.pager,j=this.padding;e>d&&(e=d);if(e>0)b!==u&&Ra(b,this.chart),this.nav.attr({translateX:j,translateY:f+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({fill:e===1?g:h}).css({cursor:e===1?"default":"pointer"}), +i.attr({text:e+"/"+d}),this.down.attr({x:18+this.pager.getBBox().width,fill:e===d?g:h}).css({cursor:e===d?"default":"pointer"}),c=-c[e-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=e,this.positionCheckboxes(c)}};M=K.LegendSymbolMixin={drawRectangle:function(a,b){var c=a.options.symbolHeight||12;b.legendSymbol=this.chart.renderer.rect(0,a.baseline-5-c/2,a.symbolWidth,c,a.options.symbolRadius||0).attr({zIndex:3}).add(b.legendGroup)},drawLineMarker:function(a){var b= +this.options,c=b.marker,d;d=a.symbolWidth;var e=this.chart.renderer,f=this.legendGroup,a=a.baseline-v(e.fontMetrics(a.options.itemStyle.fontSize,this.legendItem).b*0.3),g;if(b.lineWidth){g={"stroke-width":b.lineWidth};if(b.dashStyle)g.dashstyle=b.dashStyle;this.legendLine=e.path(["M",0,a,"L",d,a]).attr(g).add(f)}if(c&&c.enabled!==!1)b=c.radius,this.legendSymbol=d=e.symbol(this.symbol,d/2-b,a-b,2*b,2*b).add(f),d.isMarker=!0}};(/Trident\/7\.0/.test(wa)||Ua)&&Na(lb.prototype,"positionItem",function(a, +b){var c=this,d=function(){b._legendItemPos&&a.call(c,b)};d();setTimeout(d)});Ya.prototype={init:function(a,b){var c,d=a.series;a.series=null;c=w(E,a);c.series=a.series=d;this.userOptions=a;d=c.chart;this.margin=this.splashArray("margin",d);this.spacing=this.splashArray("spacing",d);var e=d.events;this.bounds={h:{},v:{}};this.callback=b;this.isResizing=0;this.options=c;this.axes=[];this.series=[];this.hasCartesianSeries=d.showAxes;var f=this,g;f.index=W.length;W.push(f);ab++;d.reflow!==!1&&N(f,"load", +function(){f.initReflow()});if(e)for(g in e)N(f,g,e[g]);f.xAxis=[];f.yAxis=[];f.animation=ga?!1:p(d.animation,!0);f.pointCount=f.colorCounter=f.symbolCounter=0;f.firstRender()},initSeries:function(a){var b=this.options.chart;(b=H[a.type||b.type||b.defaultSeriesType])||ha(17,!0);b=new b;b.init(this,a);return b},isInsidePlot:function(a,b,c){var d=c?b:a,a=c?a:b;return d>=0&&d<=this.plotWidth&&a>=0&&a<=this.plotHeight},adjustTickAmounts:function(){this.options.chart.alignTicks!==!1&&q(this.axes,function(a){a.adjustTickAmount()}); +this.maxTicks=null},redraw:function(a){var b=this.axes,c=this.series,d=this.pointer,e=this.legend,f=this.isDirtyLegend,g,h,i=this.hasCartesianSeries,j=this.isDirtyBox,k=c.length,l=k,n=this.renderer,m=n.isHidden(),o=[];Ra(a,this);m&&this.cloneRenderTo();for(this.layOutTitles();l--;)if(a=c[l],a.options.stacking&&(g=!0,a.isDirty)){h=!0;break}if(h)for(l=k;l--;)if(a=c[l],a.options.stacking)a.isDirty=!0;q(c,function(a){a.isDirty&&a.options.legendType==="point"&&(f=!0)});if(f&&e.options.enabled)e.render(), +this.isDirtyLegend=!1;g&&this.getStacks();if(i){if(!this.isResizing)this.maxTicks=null,q(b,function(a){a.setScale()});this.adjustTickAmounts()}this.getMargins();i&&(q(b,function(a){a.isDirty&&(j=!0)}),q(b,function(a){if(a.isDirtyExtremes)a.isDirtyExtremes=!1,o.push(function(){I(a,"afterSetExtremes",r(a.eventArgs,a.getExtremes()));delete a.eventArgs});(j||g)&&a.redraw()}));j&&this.drawChartBox();q(c,function(a){a.isDirty&&a.visible&&(!a.isCartesian||a.xAxis)&&a.redraw()});d&&d.reset(!0);n.draw();I(this, +"redraw");m&&this.cloneRenderTo(!0);q(o,function(a){a.call()})},get:function(a){var b=this.axes,c=this.series,d,e;for(d=0;d<b.length;d++)if(b[d].options.id===a)return b[d];for(d=0;d<c.length;d++)if(c[d].options.id===a)return c[d];for(d=0;d<c.length;d++){e=c[d].points||[];for(b=0;b<e.length;b++)if(e[b].id===a)return e[b]}return null},getAxes:function(){var a=this,b=this.options,c=b.xAxis=ra(b.xAxis||{}),b=b.yAxis=ra(b.yAxis||{});q(c,function(a,b){a.index=b;a.isX=!0});q(b,function(a,b){a.index=b}); +c=c.concat(b);q(c,function(b){new na(a,b)});a.adjustTickAmounts()},getSelectedPoints:function(){var a=[];q(this.series,function(b){a=a.concat(wb(b.points||[],function(a){return a.selected}))});return a},getSelectedSeries:function(){return wb(this.series,function(a){return a.selected})},getStacks:function(){var a=this;q(a.yAxis,function(a){if(a.stacks&&a.hasVisibleSeries)a.oldStacks=a.stacks});q(a.series,function(b){if(b.options.stacking&&(b.visible===!0||a.options.chart.ignoreHiddenSeries===!1))b.stackKey= +b.type+p(b.options.stack,"")})},setTitle:function(a,b,c){var g;var d=this,e=d.options,f;f=e.title=w(e.title,a);g=e.subtitle=w(e.subtitle,b),e=g;q([["title",a,f],["subtitle",b,e]],function(a){var b=a[0],c=d[b],e=a[1],a=a[2];c&&e&&(d[b]=c=c.destroy());a&&a.text&&!c&&(d[b]=d.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+b,zIndex:a.zIndex||4}).css(a.style).add())});d.layOutTitles(c)},layOutTitles:function(a){var b=0,c=this.title,d=this.subtitle,e=this.options,f=e.title, +e=e.subtitle,g=this.renderer,h=this.spacingBox.width-44;if(c&&(c.css({width:(f.width||h)+"px"}).align(r({y:g.fontMetrics(f.style.fontSize,c).b-3},f),!1,"spacingBox"),!f.floating&&!f.verticalAlign))b=c.getBBox().height;d&&(d.css({width:(e.width||h)+"px"}).align(r({y:b+(f.margin-13)+g.fontMetrics(f.style.fontSize,d).b},e),!1,"spacingBox"),!e.floating&&!e.verticalAlign&&(b=La(b+d.getBBox().height)));c=this.titleOffset!==b;this.titleOffset=b;if(!this.isDirtyBox&&c)this.isDirtyBox=c,this.hasRendered&& +p(a,!0)&&this.isDirtyBox&&this.redraw()},getChartSize:function(){var a=this.options.chart,b=a.width,a=a.height,c=this.renderToClone||this.renderTo;if(!s(b))this.containerWidth=ib(c,"width");if(!s(a))this.containerHeight=ib(c,"height");this.chartWidth=t(0,b||this.containerWidth||600);this.chartHeight=t(0,p(a,this.containerHeight>19?this.containerHeight:400))},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;a?b&&(this.renderTo.appendChild(c),Qa(b),delete this.renderToClone):(c&& +c.parentNode===this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),B(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),x.body.appendChild(b),c&&b.appendChild(c))},getContainer:function(){var a,b=this.options.chart,c,d,e;this.renderTo=a=b.renderTo;e="highcharts-"+ub++;if(Ga(a))this.renderTo=a=x.getElementById(a);a||ha(13,!0);c=y(F(a,"data-highcharts-chart"));!isNaN(c)&&W[c]&&W[c].hasRendered&& +W[c].destroy();F(a,"data-highcharts-chart",this.index);a.innerHTML="";!b.skipClone&&!a.offsetWidth&&this.cloneRenderTo();this.getChartSize();c=this.chartWidth;d=this.chartHeight;this.container=a=$(Ka,{className:"highcharts-container"+(b.className?" "+b.className:""),id:e},r({position:"relative",overflow:"hidden",width:c+"px",height:d+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},b.style),this.renderToClone||a);this._cursor=a.style.cursor;this.renderer= +b.forExport?new ta(a,c,d,b.style,!0):new Za(a,c,d,b.style);ga&&this.renderer.create(this,a,c,d)},getMargins:function(){var a=this.spacing,b,c=this.legend,d=this.margin,e=this.options.legend,f=p(e.margin,20),g=e.x,h=e.y,i=e.align,j=e.verticalAlign,k=this.titleOffset;this.resetMargins();b=this.axisOffset;if(k&&!s(d[0]))this.plotTop=t(this.plotTop,k+this.options.title.margin+a[0]);if(c.display&&!e.floating)if(i==="right"){if(!s(d[1]))this.marginRight=t(this.marginRight,c.legendWidth-g+f+a[1])}else if(i=== +"left"){if(!s(d[3]))this.plotLeft=t(this.plotLeft,c.legendWidth+g+f+a[3])}else if(j==="top"){if(!s(d[0]))this.plotTop=t(this.plotTop,c.legendHeight+h+f+a[0])}else if(j==="bottom"&&!s(d[2]))this.marginBottom=t(this.marginBottom,c.legendHeight-h+f+a[2]);this.extraBottomMargin&&(this.marginBottom+=this.extraBottomMargin);this.extraTopMargin&&(this.plotTop+=this.extraTopMargin);this.hasCartesianSeries&&q(this.axes,function(a){a.getOffset()});s(d[3])||(this.plotLeft+=b[3]);s(d[0])||(this.plotTop+=b[0]); +s(d[2])||(this.marginBottom+=b[2]);s(d[1])||(this.marginRight+=b[1]);this.setChartSize()},reflow:function(a){var b=this,c=b.options.chart,d=b.renderTo,e=c.width||ib(d,"width"),f=c.height||ib(d,"height"),c=a?a.target:G,d=function(){if(b.container)b.setSize(e,f,!1),b.hasUserSize=null};if(!b.hasUserSize&&e&&f&&(c===G||c===x)){if(e!==b.containerWidth||f!==b.containerHeight)clearTimeout(b.reflowTimeout),a?b.reflowTimeout=setTimeout(d,100):d();b.containerWidth=e;b.containerHeight=f}},initReflow:function(){var a= +this,b=function(b){a.reflow(b)};N(G,"resize",b);N(a,"destroy",function(){X(G,"resize",b)})},setSize:function(a,b,c){var d=this,e,f,g;d.isResizing+=1;g=function(){d&&I(d,"endResize",null,function(){d.isResizing-=1})};Ra(c,d);d.oldChartHeight=d.chartHeight;d.oldChartWidth=d.chartWidth;if(s(a))d.chartWidth=e=t(0,v(a)),d.hasUserSize=!!e;if(s(b))d.chartHeight=f=t(0,v(b));(va?jb:B)(d.container,{width:e+"px",height:f+"px"},va);d.setChartSize(!0);d.renderer.setSize(e,f,c);d.maxTicks=null;q(d.axes,function(a){a.isDirty= +!0;a.setScale()});q(d.series,function(a){a.isDirty=!0});d.isDirtyLegend=!0;d.isDirtyBox=!0;d.layOutTitles();d.getMargins();d.redraw(c);d.oldChartHeight=null;I(d,"resize");va===!1?g():setTimeout(g,va&&va.duration||500)},setChartSize:function(a){var b=this.inverted,c=this.renderer,d=this.chartWidth,e=this.chartHeight,f=this.options.chart,g=this.spacing,h=this.clipOffset,i,j,k,l;this.plotLeft=i=v(this.plotLeft);this.plotTop=j=v(this.plotTop);this.plotWidth=k=t(0,v(d-i-this.marginRight));this.plotHeight= +l=t(0,v(e-j-this.marginBottom));this.plotSizeX=b?l:k;this.plotSizeY=b?k:l;this.plotBorderWidth=f.plotBorderWidth||0;this.spacingBox=c.spacingBox={x:g[3],y:g[0],width:d-g[3]-g[1],height:e-g[0]-g[2]};this.plotBox=c.plotBox={x:i,y:j,width:k,height:l};d=2*U(this.plotBorderWidth/2);b=La(t(d,h[3])/2);c=La(t(d,h[0])/2);this.clipBox={x:b,y:c,width:U(this.plotSizeX-t(d,h[1])/2-b),height:t(0,U(this.plotSizeY-t(d,h[2])/2-c))};a||q(this.axes,function(a){a.setAxisSize();a.setAxisTranslation()})},resetMargins:function(){var a= +this.spacing,b=this.margin;this.plotTop=p(b[0],a[0]);this.marginRight=p(b[1],a[1]);this.marginBottom=p(b[2],a[2]);this.plotLeft=p(b[3],a[3]);this.axisOffset=[0,0,0,0];this.clipOffset=[0,0,0,0]},drawChartBox:function(){var a=this.options.chart,b=this.renderer,c=this.chartWidth,d=this.chartHeight,e=this.chartBackground,f=this.plotBackground,g=this.plotBorder,h=this.plotBGImage,i=a.borderWidth||0,j=a.backgroundColor,k=a.plotBackgroundColor,l=a.plotBackgroundImage,n=a.plotBorderWidth||0,m,o=this.plotLeft, +p=this.plotTop,q=this.plotWidth,r=this.plotHeight,t=this.plotBox,s=this.clipRect,v=this.clipBox;m=i+(a.shadow?8:0);if(i||j)if(e)e.animate(e.crisp({width:c-m,height:d-m}));else{e={fill:j||P};if(i)e.stroke=a.borderColor,e["stroke-width"]=i;this.chartBackground=b.rect(m/2,m/2,c-m,d-m,a.borderRadius,i).attr(e).addClass("highcharts-background").add().shadow(a.shadow)}if(k)f?f.animate(t):this.plotBackground=b.rect(o,p,q,r,0).attr({fill:k}).add().shadow(a.plotShadow);if(l)h?h.animate(t):this.plotBGImage= +b.image(l,o,p,q,r).add();s?s.animate({width:v.width,height:v.height}):this.clipRect=b.clipRect(v);if(n)g?g.animate(g.crisp({x:o,y:p,width:q,height:r,strokeWidth:-n})):this.plotBorder=b.rect(o,p,q,r,0,-n).attr({stroke:a.plotBorderColor,"stroke-width":n,fill:P,zIndex:1}).add();this.isDirtyBox=!1},propFromSeries:function(){var a=this,b=a.options.chart,c,d=a.options.series,e,f;q(["inverted","angular","polar"],function(g){c=H[b.type||b.defaultSeriesType];f=a[g]||b[g]||c&&c.prototype[g];for(e=d&&d.length;!f&& +e--;)(c=H[d[e].type])&&c.prototype[g]&&(f=!0);a[g]=f})},linkSeries:function(){var a=this,b=a.series;q(b,function(a){a.linkedSeries.length=0});q(b,function(b){var d=b.options.linkedTo;if(Ga(d)&&(d=d===":previous"?a.series[b.index-1]:a.get(d)))d.linkedSeries.push(b),b.linkedParent=d})},renderSeries:function(){q(this.series,function(a){a.translate();a.setTooltipPoints&&a.setTooltipPoints();a.render()})},renderLabels:function(){var a=this,b=a.options.labels;b.items&&q(b.items,function(c){var d=r(b.style, +c.style),e=y(d.left)+a.plotLeft,f=y(d.top)+a.plotTop+12;delete d.left;delete d.top;a.renderer.text(c.html,e,f).attr({zIndex:2}).css(d).add()})},render:function(){var a=this.axes,b=this.renderer,c=this.options;this.setTitle();this.legend=new lb(this,c.legend);this.getStacks();q(a,function(a){a.setScale()});this.getMargins();this.maxTicks=null;q(a,function(a){a.setTickPositions(!0);a.setMaxTicks()});this.adjustTickAmounts();this.getMargins();this.drawChartBox();this.hasCartesianSeries&&q(a,function(a){a.render()}); +if(!this.seriesGroup)this.seriesGroup=b.g("series-group").attr({zIndex:3}).add();this.renderSeries();this.renderLabels();this.showCredits(c.credits);this.hasRendered=!0},showCredits:function(a){if(a.enabled&&!this.credits)this.credits=this.renderer.text(a.text,0,0).on("click",function(){if(a.href)location.href=a.href}).attr({align:a.position.align,zIndex:8}).css(a.style).add().align(a.position)},destroy:function(){var a=this,b=a.axes,c=a.series,d=a.container,e,f=d&&d.parentNode;I(a,"destroy");W[a.index]= +u;ab--;a.renderTo.removeAttribute("data-highcharts-chart");X(a);for(e=b.length;e--;)b[e]=b[e].destroy();for(e=c.length;e--;)c[e]=c[e].destroy();q("title,subtitle,chartBackground,plotBackground,plotBGImage,plotBorder,seriesGroup,clipRect,credits,pointer,scroller,rangeSelector,legend,resetZoomButton,tooltip,renderer".split(","),function(b){var c=a[b];c&&c.destroy&&(a[b]=c.destroy())});if(d)d.innerHTML="",X(d),f&&Qa(d);for(e in a)delete a[e]},isReadyToRender:function(){var a=this;return!ba&&G==G.top&& +x.readyState!=="complete"||ga&&!G.canvg?(ga?Mb.push(function(){a.firstRender()},a.options.global.canvasToolsURL):x.attachEvent("onreadystatechange",function(){x.detachEvent("onreadystatechange",a.firstRender);x.readyState==="complete"&&a.firstRender()}),!1):!0},firstRender:function(){var a=this,b=a.options,c=a.callback;if(a.isReadyToRender()){a.getContainer();I(a,"init");a.resetMargins();a.setChartSize();a.propFromSeries();a.getAxes();q(b.series||[],function(b){a.initSeries(b)});a.linkSeries();I(a, +"beforeRender");if(K.Pointer)a.pointer=new Wa(a,b);a.render();a.renderer.draw();c&&c.apply(a,[a]);q(a.callbacks,function(b){b.apply(a,[a])});a.cloneRenderTo(!0);I(a,"load")}},splashArray:function(a,b){var c=b[a],c=da(c)?c:[c,c,c,c];return[p(b[a+"Top"],c[0]),p(b[a+"Right"],c[1]),p(b[a+"Bottom"],c[2]),p(b[a+"Left"],c[3])]}};Ya.prototype.callbacks=[];Z=K.CenteredSeriesMixin={getCenter:function(){var a=this.options,b=this.chart,c=2*(a.slicedOffset||0),d,e=b.plotWidth-2*c,f=b.plotHeight-2*c,b=a.center, +a=[p(b[0],"50%"),p(b[1],"50%"),a.size||"100%",a.innerSize||0],g=L(e,f),h;return Va(a,function(a,b){h=/%$/.test(a);d=b<2||b===2&&h;return(h?[e,f,g,g][b]*y(a)/100:a)+(d?c:0)})}};var Fa=function(){};Fa.prototype={init:function(a,b,c){this.series=a;this.applyOptions(b,c);this.pointAttr={};if(a.options.colorByPoint&&(b=a.options.colors||a.chart.options.colors,this.color=this.color||b[a.colorCounter++],a.colorCounter===b.length))a.colorCounter=0;a.chart.pointCount++;return this},applyOptions:function(a, +b){var c=this.series,d=c.options.pointValKey||c.pointValKey,a=Fa.prototype.optionsToObject.call(this,a);r(this,a);this.options=this.options?r(this.options,a):a;if(d)this.y=this[d];if(this.x===u&&c)this.x=b===u?c.autoIncrement():b;return this},optionsToObject:function(a){var b={},c=this.series,d=c.pointArrayMap||["y"],e=d.length,f=0,g=0;if(typeof a==="number"||a===null)b[d[0]]=a;else if(Ha(a)){if(a.length>e){c=typeof a[0];if(c==="string")b.name=a[0];else if(c==="number")b.x=a[0];f++}for(;g<e;)b[d[g++]]= +a[f++]}else if(typeof a==="object"){b=a;if(a.dataLabels)c._hasPointLabels=!0;if(a.marker)c._hasPointMarkers=!0}return b},destroy:function(){var a=this.series.chart,b=a.hoverPoints,c;a.pointCount--;if(b&&(this.setState(),la(b,this),!b.length))a.hoverPoints=null;if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)X(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(c in this)this[c]=null},destroyElements:function(){for(var a="graphic,dataLabel,dataLabelUpper,group,connector,shadowGroup".split(","), +b,c=6;c--;)b=a[c],this[b]&&(this[b]=this[b].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var b=this.series,c=b.tooltipOptions,d=p(c.valueDecimals,""),e=c.valuePrefix||"",f=c.valueSuffix||"";q(b.pointArrayMap||["y"],function(b){b="{point."+b;if(e||f)a=a.replace(b+"}",e+b+"}"+f);a=a.replace(b+"}",b+":,."+d+"f}")});return Ja(a, +{point:this,series:this.series})},firePointEvent:function(a,b,c){var d=this,e=this.series.options;(e.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();a==="click"&&e.allowPointSelect&&(c=function(a){d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});I(this,a,b,c)}};var O=function(){};O.prototype={isCartesian:!0,type:"line",pointClass:Fa,sorted:!0,requireSorting:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor",r:"radius"},axisTypes:["xAxis", +"yAxis"],colorCounter:0,parallelArrays:["x","y"],init:function(a,b){var c=this,d,e,f=a.series,g=function(a,b){return p(a.options.index,a._i)-p(b.options.index,b._i)};c.chart=a;c.options=b=c.setOptions(b);c.linkedSeries=[];c.bindAxes();r(c,{name:b.name,state:"",pointAttr:{},visible:b.visible!==!1,selected:b.selected===!0});if(ga)b.animation=!1;e=b.events;for(d in e)N(c,d,e[d]);if(e&&e.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;c.getColor();c.getSymbol(); +q(c.parallelArrays,function(a){c[a+"Data"]=[]});c.setData(b.data,!1);if(c.isCartesian)a.hasCartesianSeries=!0;f.push(c);c._i=f.length-1;ob(f,g);this.yAxis&&ob(this.yAxis.series,g);q(f,function(a,b){a.index=b;a.name=a.name||"Series "+(b+1)})},bindAxes:function(){var a=this,b=a.options,c=a.chart,d;q(a.axisTypes||[],function(e){q(c[e],function(c){d=c.options;if(b[e]===d.index||b[e]!==u&&b[e]===d.id||b[e]===u&&d.index===0)c.series.push(a),a[e]=c,c.isDirty=!0});!a[e]&&a.optionalAxis!==e&&ha(18,!0)})}, +updateParallelArrays:function(a,b){var c=a.series,d=arguments;q(c.parallelArrays,typeof b==="number"?function(d){var f=d==="y"&&c.toYData?c.toYData(a):a[d];c[d+"Data"][b]=f}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(d,2))})},autoIncrement:function(){var a=this.options,b=this.xIncrement,b=p(b,a.pointStart,0);this.pointInterval=p(this.pointInterval,a.pointInterval,1);this.xIncrement=b+this.pointInterval;return b},getSegments:function(){var a=-1,b=[],c,d=this.points, +e=d.length;if(e)if(this.options.connectNulls){for(c=e;c--;)d[c].y===null&&d.splice(c,1);d.length&&(b=[d])}else q(d,function(c,g){c.y===null?(g>a+1&&b.push(d.slice(a+1,g)),a=g):g===e-1&&b.push(d.slice(a+1,g+1))});this.segments=b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},d=b.plotOptions||{},e=c[this.type];this.userOptions=a;c=w(e,c.series,a);this.tooltipOptions=w(E.tooltip,E.plotOptions[this.type].tooltip,b.tooltip,d.series&&d.series.tooltip,d[this.type]&& +d[this.type].tooltip,a.tooltip);e.marker===null&&delete c.marker;return c},getCyclic:function(a,b,c){var d=this.userOptions,e="_"+a+"Index",f=a+"Counter";b||(s(d[e])?b=d[e]:(d[e]=b=this.chart[f]%c.length,this.chart[f]+=1),b=c[b]);this[a]=b},getColor:function(){this.options.colorByPoint||this.getCyclic("color",this.options.color||ca[this.type].color,this.chart.options.colors)},getSymbol:function(){var a=this.options.marker;this.getCyclic("symbol",a.symbol,this.chart.options.symbols);if(/^url/.test(this.symbol))a.radius= +0},drawLegendSymbol:M.drawLineMarker,setData:function(a,b,c,d){var e=this,f=e.points,g=f&&f.length||0,h,i=e.options,j=e.chart,k=null,l=e.xAxis,n=l&&!!l.categories,m=e.tooltipPoints,o=i.turboThreshold,r=this.xData,t=this.yData,s=(h=e.pointArrayMap)&&h.length,a=a||[];h=a.length;b=p(b,!0);if(d!==!1&&h&&g===h&&!e.cropped&&!e.hasGroupedData)q(a,function(a,b){f[b].update(a,!1,null,!1)});else{e.xIncrement=null;e.pointRange=n?1:i.pointRange;e.colorCounter=0;q(this.parallelArrays,function(a){e[a+"Data"].length= +0});if(o&&h>o){for(c=0;k===null&&c<h;)k=a[c],c++;if(ja(k)){n=p(i.pointStart,0);i=p(i.pointInterval,1);for(c=0;c<h;c++)r[c]=n,t[c]=a[c],n+=i;e.xIncrement=n}else if(Ha(k))if(s)for(c=0;c<h;c++)i=a[c],r[c]=i[0],t[c]=i.slice(1,s+1);else for(c=0;c<h;c++)i=a[c],r[c]=i[0],t[c]=i[1];else ha(12)}else for(c=0;c<h;c++)if(a[c]!==u&&(i={series:e},e.pointClass.prototype.applyOptions.apply(i,[a[c]]),e.updateParallelArrays(i,c),n&&i.name))l.names[i.x]=i.name;Ga(t[0])&&ha(14,!0);e.data=[];e.options.data=a;for(c=g;c--;)f[c]&& +f[c].destroy&&f[c].destroy();if(m)m.length=0;if(l)l.minRange=l.userMinRange;e.isDirty=e.isDirtyData=j.isDirtyBox=!0;c=!1}b&&j.redraw(c)},processData:function(a){var b=this.xData,c=this.yData,d=b.length,e;e=0;var f,g,h=this.xAxis,i,j=this.options;i=j.cropThreshold;var k=0,l=this.isCartesian,n,m;if(l&&!this.isDirty&&!h.isDirty&&!this.yAxis.isDirty&&!a)return!1;if(h)n=h.getExtremes(),m=n.min,n=n.max;if(l&&this.sorted&&(!i||d>i||this.forceCrop))if(b[d-1]<m||b[0]>n)b=[],c=[];else if(b[0]<m||b[d-1]>n)e= +this.cropData(this.xData,this.yData,m,n),b=e.xData,c=e.yData,e=e.start,f=!0,k=b.length;for(i=b.length-1;i>=0;i--)d=b[i]-b[i-1],!f&&b[i]>m&&b[i]<n&&k++,d>0&&(g===u||d<g)?g=d:d<0&&this.requireSorting&&ha(15);this.cropped=f;this.cropStart=e;this.processedXData=b;this.processedYData=c;this.activePointCount=k;if(j.pointRange===null)this.pointRange=g||1;this.closestPointRange=g},cropData:function(a,b,c,d){var e=a.length,f=0,g=e,h=p(this.cropShoulder,1),i;for(i=0;i<e;i++)if(a[i]>=c){f=t(0,i-h);break}for(;i< +e;i++)if(a[i]>d){g=i+h;break}return{xData:a.slice(f,g),yData:b.slice(f,g),start:f,end:g}},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,e=this.processedYData,f=this.pointClass,g=d.length,h=this.cropStart||0,i,j=this.hasGroupedData,k,l=[],n;if(!b&&!j)b=[],b.length=a.length,b=this.data=b;for(n=0;n<g;n++)i=h+n,j?l[n]=(new f).init(this,[d[n]].concat(ra(e[n]))):(b[i]?k=b[i]:a[i]!==u&&(b[i]=k=(new f).init(this,a[i],d[n])),l[n]=k),l[n].index=i;if(b&&(g!==(c=b.length)|| +j))for(n=0;n<c;n++)if(n===h&&!j&&(n+=g),b[n])b[n].destroyElements(),b[n].plotX=u;this.data=b;this.points=l},getExtremes:function(a){var b=this.yAxis,c=this.processedXData,d,e=[],f=0;d=this.xAxis.getExtremes();var g=d.min,h=d.max,i,j,k,l,a=a||this.stackedYData||this.processedYData;d=a.length;for(l=0;l<d;l++)if(j=c[l],k=a[l],i=k!==null&&k!==u&&(!b.isLog||k.length||k>0),j=this.getExtremesFromAll||this.cropped||(c[l+1]||j)>=g&&(c[l-1]||j)<=h,i&&j)if(i=k.length)for(;i--;)k[i]!==null&&(e[f++]=k[i]);else e[f++]= +k;this.dataMin=p(void 0,Oa(e));this.dataMax=p(void 0,Ca(e))},translate:function(){this.processedXData||this.processData();this.generatePoints();for(var a=this.options,b=a.stacking,c=this.xAxis,d=c.categories,e=this.yAxis,f=this.points,g=f.length,h=!!this.modifyValue,i=a.pointPlacement,j=i==="between"||ja(i),k=a.threshold,a=0;a<g;a++){var l=f[a],n=l.x,m=l.y,o=l.low,q=b&&e.stacks[(this.negStacks&&m<k?"-":"")+this.stackKey];if(e.isLog&&m<=0)l.y=m=null,ha(10);l.plotX=c.translate(n,0,0,0,1,i,this.type=== +"flags");if(b&&this.visible&&q&&q[n])q=q[n],m=q.points[this.index+","+a],o=m[0],m=m[1],o===0&&(o=p(k,e.min)),e.isLog&&o<=0&&(o=null),l.total=l.stackTotal=q.total,l.percentage=q.total&&l.y/q.total*100,l.stackY=m,q.setOffset(this.pointXOffset||0,this.barW||0);l.yBottom=s(o)?e.translate(o,0,1,0,1):null;h&&(m=this.modifyValue(m,l));l.plotY=typeof m==="number"&&m!==Infinity?e.translate(m,0,1,0,1):u;l.clientX=j?c.translate(n,0,0,0,1):l.plotX;l.negative=l.y<(k||0);l.category=d&&d[l.x]!==u?d[l.x]:l.x}this.getSegments()}, +animate:function(a){var b=this.chart,c=b.renderer,d;d=this.options.animation;var e=this.clipBox||b.clipBox,f=b.inverted,g;if(d&&!da(d))d=ca[this.type].animation;g=["_sharedClip",d.duration,d.easing,e.height].join(",");a?(a=b[g],d=b[g+"m"],a||(b[g]=a=c.clipRect(r(e,{width:0})),b[g+"m"]=d=c.clipRect(-99,f?-b.plotLeft:-b.plotTop,99,f?b.chartWidth:b.chartHeight)),this.group.clip(a),this.markerGroup.clip(d),this.sharedClipKey=g):((a=b[g])&&a.animate({width:b.plotSizeX},d),b[g+"m"]&&b[g+"m"].animate({width:b.plotSizeX+ +99},d),this.animate=null)},afterAnimate:function(){var a=this.chart,b=this.sharedClipKey,c=this.group,d=this.clipBox;if(c&&this.options.clip!==!1){if(!b||!d)c.clip(d?a.renderer.clipRect(d):a.clipRect);this.markerGroup.clip()}I(this,"afterAnimate");setTimeout(function(){b&&a[b]&&(d||(a[b]=a[b].destroy()),a[b+"m"]&&(a[b+"m"]=a[b+"m"].destroy()))},100)},drawPoints:function(){var a,b=this.points,c=this.chart,d,e,f,g,h,i,j,k,l=this.options.marker,n=this.pointAttr[""],m,o,q,t=this.markerGroup,s=p(l.enabled, +!this.requireSorting||this.activePointCount<0.5*this.xAxis.len/l.radius);if(l.enabled!==!1||this._hasPointMarkers)for(f=b.length;f--;)if(g=b[f],d=U(g.plotX),e=g.plotY,k=g.graphic,m=g.marker||{},o=!!g.marker,a=s&&m.enabled===u||m.enabled,q=c.isInsidePlot(v(d),e,c.inverted),a&&e!==u&&!isNaN(e)&&g.y!==null)if(a=g.pointAttr[g.selected?"select":""]||n,h=a.r,i=p(m.symbol,this.symbol),j=i.indexOf("url")===0,k)k[q?"show":"hide"](!0).animate(r({x:d-h,y:e-h},k.symbolName?{width:2*h,height:2*h}:{}));else{if(q&& +(h>0||j))g.graphic=c.renderer.symbol(i,d-h,e-h,2*h,2*h,o?m:l).attr(a).add(t)}else if(k)g.graphic=k.destroy()},convertAttribs:function(a,b,c,d){var e=this.pointAttrToOptions,f,g,h={},a=a||{},b=b||{},c=c||{},d=d||{};for(f in e)g=e[f],h[f]=p(a[g],b[f],c[f],d[f]);return h},getAttribs:function(){var a=this,b=a.options,c=ca[a.type].marker?b.marker:b,d=c.states,e=d.hover,f,g=a.color;f={stroke:g,fill:g};var h=a.points||[],i,j=[],k,l=a.pointAttrToOptions;k=a.hasPointSpecificOptions;var n=b.negativeColor,m= +c.lineColor,o=c.fillColor;i=b.turboThreshold;var p;b.marker?(e.radius=e.radius||c.radius+e.radiusPlus,e.lineWidth=e.lineWidth||c.lineWidth+e.lineWidthPlus):e.color=e.color||ya(e.color||g).brighten(e.brightness).get();j[""]=a.convertAttribs(c,f);q(["hover","select"],function(b){j[b]=a.convertAttribs(d[b],j[""])});a.pointAttr=j;g=h.length;if(!i||g<i||k)for(;g--;){i=h[g];if((c=i.options&&i.options.marker||i.options)&&c.enabled===!1)c.radius=0;if(i.negative&&n)i.color=i.fillColor=n;k=b.colorByPoint|| +i.color;if(i.options)for(p in l)s(c[l[p]])&&(k=!0);if(k){c=c||{};k=[];d=c.states||{};f=d.hover=d.hover||{};if(!b.marker)f.color=f.color||!i.options.color&&e.color||ya(i.color).brighten(f.brightness||e.brightness).get();f={color:i.color};if(!o)f.fillColor=i.color;if(!m)f.lineColor=i.color;k[""]=a.convertAttribs(r(f,c),j[""]);k.hover=a.convertAttribs(d.hover,j.hover,k[""]);k.select=a.convertAttribs(d.select,j.select,k[""])}else k=j;i.pointAttr=k}},destroy:function(){var a=this,b=a.chart,c=/AppleWebKit\/533/.test(wa), +d,e,f=a.data||[],g,h,i;I(a,"destroy");X(a);q(a.axisTypes||[],function(b){if(i=a[b])la(i.series,a),i.isDirty=i.forceRedraw=!0});a.legendItem&&a.chart.legend.destroyItem(a);for(e=f.length;e--;)(g=f[e])&&g.destroy&&g.destroy();a.points=null;clearTimeout(a.animationTimeout);q("area,graph,dataLabelsGroup,group,markerGroup,tracker,graphNeg,areaNeg,posClip,negClip".split(","),function(b){a[b]&&(d=c&&b==="group"?"hide":"destroy",a[b][d]())});if(b.hoverSeries===a)b.hoverSeries=null;la(b.series,a);for(h in a)delete a[h]}, +getSegmentPath:function(a){var b=this,c=[],d=b.options.step;q(a,function(e,f){var g=e.plotX,h=e.plotY,i;b.getPointSpline?c.push.apply(c,b.getPointSpline(a,e,f)):(c.push(f?"L":"M"),d&&f&&(i=a[f-1],d==="right"?c.push(i.plotX,h):d==="center"?c.push((i.plotX+g)/2,i.plotY,(i.plotX+g)/2,h):c.push(g,i.plotY)),c.push(e.plotX,e.plotY))});return c},getGraphPath:function(){var a=this,b=[],c,d=[];q(a.segments,function(e){c=a.getSegmentPath(e);e.length>1?b=b.concat(c):d.push(e[0])});a.singlePoints=d;return a.graphPath= +b},drawGraph:function(){var a=this,b=this.options,c=[["graph",b.lineColor||this.color]],d=b.lineWidth,e=b.dashStyle,f=b.linecap!=="square",g=this.getGraphPath(),h=b.negativeColor;h&&c.push(["graphNeg",h]);q(c,function(c,h){var k=c[0],l=a[k];if(l)bb(l),l.animate({d:g});else if(d&&g.length)l={stroke:c[1],"stroke-width":d,fill:P,zIndex:1},e?l.dashstyle=e:f&&(l["stroke-linecap"]=l["stroke-linejoin"]="round"),a[k]=a.chart.renderer.path(g).attr(l).add(a.group).shadow(!h&&b.shadow)})},clipNeg:function(){var a= +this.options,b=this.chart,c=b.renderer,d=a.negativeColor||a.negativeFillColor,e,f=this.graph,g=this.area,h=this.posClip,i=this.negClip;e=b.chartWidth;var j=b.chartHeight,k=t(e,j),l=this.yAxis;if(d&&(f||g)){d=v(l.toPixels(a.threshold||0,!0));d<0&&(k-=d);a={x:0,y:0,width:k,height:d};k={x:0,y:d,width:k,height:k};if(b.inverted)a.height=k.y=b.plotWidth-d,c.isVML&&(a={x:b.plotWidth-d-b.plotLeft,y:0,width:e,height:j},k={x:d+b.plotLeft-e,y:0,width:b.plotLeft+d,height:e});l.reversed?(b=k,e=a):(b=a,e=k);h? +(h.animate(b),i.animate(e)):(this.posClip=h=c.clipRect(b),this.negClip=i=c.clipRect(e),f&&this.graphNeg&&(f.clip(h),this.graphNeg.clip(i)),g&&(g.clip(h),this.areaNeg.clip(i)))}},invertGroups:function(){function a(){var a={width:b.yAxis.len,height:b.xAxis.len};q(["group","markerGroup"],function(c){b[c]&&b[c].attr(a).invert()})}var b=this,c=b.chart;if(b.xAxis)N(c,"resize",a),N(b,"destroy",function(){X(c,"resize",a)}),a(),b.invertGroups=a},plotGroup:function(a,b,c,d,e){var f=this[a],g=!f;g&&(this[a]= +f=this.chart.renderer.g(b).attr({visibility:c,zIndex:d||0.1}).add(e));f[g?"attr":"animate"](this.getPlotBox());return f},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;if(a.inverted)b=c,c=this.xAxis;return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,d=a.options,e=(c=d.animation)&&!!a.animate&&b.renderer.isSVG&&p(c.duration,500)||0,f=a.visible?"visible":"hidden",g=d.zIndex,h=a.hasRendered,i=b.seriesGroup; +c=a.plotGroup("group","series",f,g,i);a.markerGroup=a.plotGroup("markerGroup","markers",f,g,i);e&&a.animate(!0);a.getAttribs();c.inverted=a.isCartesian?b.inverted:!1;a.drawGraph&&(a.drawGraph(),a.clipNeg());q(a.points,function(a){a.redraw&&a.redraw()});a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&a.options.enableMouseTracking!==!1&&a.drawTracker();b.inverted&&a.invertGroups();d.clip!==!1&&!a.sharedClipKey&&!h&&c.clip(b.clipRect);e&&a.animate();if(!h)e?a.animationTimeout= +setTimeout(function(){a.afterAnimate()},e):a.afterAnimate();a.isDirty=a.isDirtyData=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:p(d&&d.left,a.plotLeft),translateY:p(e&&e.top,a.plotTop)}));this.translate();this.setTooltipPoints&&this.setTooltipPoints(!0);this.render();b&&I(this,"updatedData")}};Gb.prototype={destroy:function(){Pa(this,this.axis)}, +render:function(a){var b=this.options,c=b.format,c=c?Ja(c,this):b.formatter.call(this);this.label?this.label.attr({text:c,visibility:"hidden"}):this.label=this.axis.chart.renderer.text(c,null,null,b.useHTML).css(b.style).attr({align:this.textAlign,rotation:b.rotation,visibility:"hidden"}).add(a)},setOffset:function(a,b){var c=this.axis,d=c.chart,e=d.inverted,f=this.isNegative,g=c.translate(c.usePercentage?100:this.total,0,0,0,1),c=c.translate(0),c=Q(g-c),h=d.xAxis[0].translate(this.x)+a,i=d.plotHeight, +f={x:e?f?g:g-c:h,y:e?i-h-b:f?i-g-c:i-g,width:e?c:b,height:e?b:c};if(e=this.label)e.align(this.alignOptions,null,f),f=e.alignAttr,e[this.options.crop===!1||d.isInsidePlot(f.x,f.y)?"show":"hide"](!0)}};na.prototype.buildStacks=function(){var a=this.series,b=p(this.options.reversedStacks,!0),c=a.length;if(!this.isXAxis){for(this.usePercentage=!1;c--;)a[b?c:a.length-c-1].setStackedPoints();if(this.usePercentage)for(c=0;c<a.length;c++)a[c].setPercentStacks()}};na.prototype.renderStackTotals=function(){var a= +this.chart,b=a.renderer,c=this.stacks,d,e,f=this.stackTotalGroup;if(!f)this.stackTotalGroup=f=b.g("stack-labels").attr({visibility:"visible",zIndex:6}).add();f.translate(a.plotLeft,a.plotTop);for(d in c)for(e in a=c[d],a)a[e].render(f)};O.prototype.setStackedPoints=function(){if(this.options.stacking&&!(this.visible!==!0&&this.chart.options.chart.ignoreHiddenSeries!==!1)){var a=this.processedXData,b=this.processedYData,c=[],d=b.length,e=this.options,f=e.threshold,g=e.stack,e=e.stacking,h=this.stackKey, +i="-"+h,j=this.negStacks,k=this.yAxis,l=k.stacks,n=k.oldStacks,m,o,p,q,r,s;for(q=0;q<d;q++){r=a[q];s=b[q];p=this.index+","+q;o=(m=j&&s<f)?i:h;l[o]||(l[o]={});if(!l[o][r])n[o]&&n[o][r]?(l[o][r]=n[o][r],l[o][r].total=null):l[o][r]=new Gb(k,k.options.stackLabels,m,r,g);o=l[o][r];o.points[p]=[o.cum||0];e==="percent"?(m=m?h:i,j&&l[m]&&l[m][r]?(m=l[m][r],o.total=m.total=t(m.total,o.total)+Q(s)||0):o.total=ea(o.total+(Q(s)||0))):o.total=ea(o.total+(s||0));o.cum=(o.cum||0)+(s||0);o.points[p].push(o.cum); +c[q]=o.cum}if(e==="percent")k.usePercentage=!0;this.stackedYData=c;k.oldStacks={}}};O.prototype.setPercentStacks=function(){var a=this,b=a.stackKey,c=a.yAxis.stacks,d=a.processedXData;q([b,"-"+b],function(b){var e;for(var f=d.length,g,h;f--;)if(g=d[f],e=(h=c[b]&&c[b][g])&&h.points[a.index+","+f],g=e)h=h.total?100/h.total:0,g[0]=ea(g[0]*h),g[1]=ea(g[1]*h),a.stackedYData[f]=g[1]})};r(Ya.prototype,{addSeries:function(a,b,c){var d,e=this;a&&(b=p(b,!0),I(e,"addSeries",{options:a},function(){d=e.initSeries(a); +e.isDirtyLegend=!0;e.linkSeries();b&&e.redraw(c)}));return d},addAxis:function(a,b,c,d){var e=b?"xAxis":"yAxis",f=this.options;new na(this,w(a,{index:this[e].length,isX:b}));f[e]=ra(f[e]||{});f[e].push(a);p(c,!0)&&this.redraw(d)},showLoading:function(a){var b=this,c=b.options,d=b.loadingDiv,e=c.loading,f=function(){d&&B(d,{left:b.plotLeft+"px",top:b.plotTop+"px",width:b.plotWidth+"px",height:b.plotHeight+"px"})};if(!d)b.loadingDiv=d=$(Ka,{className:"highcharts-loading"},r(e.style,{zIndex:10,display:P}), +b.container),b.loadingSpan=$("span",null,e.labelStyle,d),N(b,"redraw",f);b.loadingSpan.innerHTML=a||c.lang.loading;if(!b.loadingShown)B(d,{opacity:0,display:""}),jb(d,{opacity:e.style.opacity},{duration:e.showDuration||0}),b.loadingShown=!0;f()},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&jb(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){B(b,{display:P})}});this.loadingShown=!1}});r(Fa.prototype,{update:function(a,b,c,d){function e(){f.applyOptions(a);if(da(a)&& +!Ha(a))f.redraw=function(){if(h)a&&a.marker&&a.marker.symbol?f.graphic=h.destroy():h.attr(f.pointAttr[f.state||""]);if(a&&a.dataLabels&&f.dataLabel)f.dataLabel=f.dataLabel.destroy();f.redraw=null};i=f.index;g.updateParallelArrays(f,i);k.data[i]=f.options;g.isDirty=g.isDirtyData=!0;if(!g.fixedBox&&g.hasCartesianSeries)j.isDirtyBox=!0;k.legendType==="point"&&j.legend.destroyItem(f);b&&j.redraw(c)}var f=this,g=f.series,h=f.graphic,i,j=g.chart,k=g.options,b=p(b,!0);d===!1?e():f.firePointEvent("update", +{options:a},e)},remove:function(a,b){var c=this,d=c.series,e=d.points,f=d.chart,g,h=d.data;Ra(b,f);a=p(a,!0);c.firePointEvent("remove",null,function(){g=Ma(c,h);h.length===e.length&&e.splice(g,1);h.splice(g,1);d.options.data.splice(g,1);d.updateParallelArrays(c,"splice",g,1);c.destroy();d.isDirty=!0;d.isDirtyData=!0;a&&f.redraw()})}});r(O.prototype,{addPoint:function(a,b,c,d){var e=this.options,f=this.data,g=this.graph,h=this.area,i=this.chart,j=this.xAxis&&this.xAxis.names,k=g&&g.shift||0,l=e.data, +n,m=this.xData;Ra(d,i);c&&q([g,h,this.graphNeg,this.areaNeg],function(a){if(a)a.shift=k+1});if(h)h.isArea=!0;b=p(b,!0);d={series:this};this.pointClass.prototype.applyOptions.apply(d,[a]);g=d.x;h=m.length;if(this.requireSorting&&g<m[h-1])for(n=!0;h&&m[h-1]>g;)h--;this.updateParallelArrays(d,"splice",h,0,0);this.updateParallelArrays(d,h);if(j&&d.name)j[g]=d.name;l.splice(h,0,a);n&&(this.data.splice(h,0,null),this.processData());e.legendType==="point"&&this.generatePoints();c&&(f[0]&&f[0].remove?f[0].remove(!1): +(f.shift(),this.updateParallelArrays(d,"shift"),l.shift()));this.isDirtyData=this.isDirty=!0;b&&(this.getAttribs(),i.redraw())},remove:function(a,b){var c=this,d=c.chart,a=p(a,!0);if(!c.isRemoving)c.isRemoving=!0,I(c,"remove",null,function(){c.destroy();d.isDirtyLegend=d.isDirtyBox=!0;d.linkSeries();a&&d.redraw(b)});c.isRemoving=!1},update:function(a,b){var c=this,d=this.chart,e=this.userOptions,f=this.type,g=H[f].prototype,h=["group","markerGroup","dataLabelsGroup"],i;q(h,function(a){h[a]=c[a];delete c[a]}); +a=w(e,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1);for(i in g)g.hasOwnProperty(i)&&(this[i]=u);r(this,H[a.type||f].prototype);q(h,function(a){c[a]=h[a]});this.init(d,a);d.linkSeries();p(b,!0)&&d.redraw(!1)}});r(na.prototype,{update:function(a,b){var c=this.chart,a=c.options[this.coll][this.options.index]=w(this.userOptions,a);this.destroy(!0);this._addedPlotLB=u;this.init(c,r(a,{events:u}));c.isDirtyBox=!0;p(b,!0)&&c.redraw()},remove:function(a){for(var b= +this.chart,c=this.coll,d=this.series,e=d.length;e--;)d[e]&&d[e].remove(!1);la(b.axes,this);la(b[c],this);b.options[c].splice(this.options.index,1);q(b[c],function(a,b){a.options.index=b});this.destroy();b.isDirtyBox=!0;p(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}});ia=ma(O);H.line=ia;ca.area=w(T,{threshold:0});var qa=ma(O,{type:"area",getSegments:function(){var a=this,b=[],c=[],d=[],e=this.xAxis,f=this.yAxis,g=f.stacks[this.stackKey], +h={},i,j,k=this.points,l=this.options.connectNulls,n,m;if(this.options.stacking&&!this.cropped){for(n=0;n<k.length;n++)h[k[n].x]=k[n];for(m in g)g[m].total!==null&&d.push(+m);d.sort(function(a,b){return a-b});q(d,function(b){var d=0,k;if(!l||h[b]&&h[b].y!==null)if(h[b])c.push(h[b]);else{for(n=a.index;n<=f.series.length;n++)if(k=g[b].points[n+","+b]){d=k[1];break}i=e.translate(b);j=f.toPixels(d,!0);c.push({y:null,plotX:i,clientX:i,plotY:j,yBottom:j,onMouseOver:sa})}});c.length&&b.push(c)}else O.prototype.getSegments.call(this), +b=this.segments;this.segments=b},getSegmentPath:function(a){var b=O.prototype.getSegmentPath.call(this,a),c=[].concat(b),d,e=this.options;d=b.length;var f=this.yAxis.getThreshold(e.threshold),g;d===3&&c.push("L",b[1],b[2]);if(e.stacking&&!this.closedStacks)for(d=a.length-1;d>=0;d--)g=p(a[d].yBottom,f),d<a.length-1&&e.step&&c.push(a[d+1].plotX,g),c.push(a[d].plotX,g);else this.closeSegment(c,a,f);this.areaPath=this.areaPath.concat(c);return b},closeSegment:function(a,b,c){a.push("L",b[b.length-1].plotX, +c,"L",b[0].plotX,c)},drawGraph:function(){this.areaPath=[];O.prototype.drawGraph.apply(this);var a=this,b=this.areaPath,c=this.options,d=c.negativeColor,e=c.negativeFillColor,f=[["area",this.color,c.fillColor]];(d||e)&&f.push(["areaNeg",d,e]);q(f,function(d){var e=d[0],f=a[e];f?f.animate({d:b}):a[e]=a.chart.renderer.path(b).attr({fill:p(d[2],ya(d[1]).setOpacity(p(c.fillOpacity,0.75)).get()),zIndex:0}).add(a.group)})},drawLegendSymbol:M.drawRectangle});H.area=qa;ca.spline=w(T);ia=ma(O,{type:"spline", +getPointSpline:function(a,b,c){var d=b.plotX,e=b.plotY,f=a[c-1],g=a[c+1],h,i,j,k;if(f&&g){a=f.plotY;j=g.plotX;var g=g.plotY,l;h=(1.5*d+f.plotX)/2.5;i=(1.5*e+a)/2.5;j=(1.5*d+j)/2.5;k=(1.5*e+g)/2.5;l=(k-i)*(j-d)/(j-h)+e-k;i+=l;k+=l;i>a&&i>e?(i=t(a,e),k=2*e-i):i<a&&i<e&&(i=L(a,e),k=2*e-i);k>g&&k>e?(k=t(g,e),i=2*e-k):k<g&&k<e&&(k=L(g,e),i=2*e-k);b.rightContX=j;b.rightContY=k}c?(b=["C",f.rightContX||f.plotX,f.rightContY||f.plotY,h||d,i||e,d,e],f.rightContX=f.rightContY=null):b=["M",d,e];return b}});H.spline= +ia;ca.areaspline=w(ca.area);qa=qa.prototype;ia=ma(ia,{type:"areaspline",closedStacks:!0,getSegmentPath:qa.getSegmentPath,closeSegment:qa.closeSegment,drawGraph:qa.drawGraph,drawLegendSymbol:M.drawRectangle});H.areaspline=ia;ca.column=w(T,{borderColor:"#FFFFFF",borderRadius:0,groupPadding:0.2,marker:null,pointPadding:0.1,minPointLength:0,cropThreshold:50,pointRange:null,states:{hover:{brightness:0.1,shadow:!1,halo:!1},select:{color:"#C0C0C0",borderColor:"#000000",shadow:!1}},dataLabels:{align:null, +verticalAlign:null,y:null},stickyTracking:!1,tooltip:{distance:6},threshold:0});ia=ma(O,{type:"column",pointAttrToOptions:{stroke:"borderColor",fill:"color",r:"borderRadius"},cropShoulder:0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){O.prototype.init.apply(this,arguments);var a=this,b=a.chart;b.hasRendered&&q(b.series,function(b){if(b.type===a.type)b.isDirty=!0})},getColumnMetrics:function(){var a=this,b=a.options,c=a.xAxis,d=a.yAxis,e=c.reversed,f,g={},h,i=0;b.grouping=== +!1?i=1:q(a.chart.series,function(b){var c=b.options,e=b.yAxis;if(b.type===a.type&&b.visible&&d.len===e.len&&d.pos===e.pos)c.stacking?(f=b.stackKey,g[f]===u&&(g[f]=i++),h=g[f]):c.grouping!==!1&&(h=i++),b.columnIndex=h});var c=L(Q(c.transA)*(c.ordinalSlope||b.pointRange||c.closestPointRange||c.tickInterval||1),c.len),j=c*b.groupPadding,k=(c-2*j)/i,l=b.pointWidth,b=s(l)?(k-l)/2:k*b.pointPadding,l=p(l,k-2*b);return a.columnMetrics={width:l,offset:b+(j+((e?i-(a.columnIndex||0):a.columnIndex)||0)*k-c/2)* +(e?-1:1)}},translate:function(){var a=this,b=a.chart,c=a.options,d=a.borderWidth=p(c.borderWidth,a.activePointCount>0.5*a.xAxis.len?0:1),e=a.yAxis,f=a.translatedThreshold=e.getThreshold(c.threshold),g=p(c.minPointLength,5),h=a.getColumnMetrics(),i=h.width,j=a.barW=t(i,1+2*d),k=a.pointXOffset=h.offset,l=-(d%2?0.5:0),n=d%2?0.5:1;b.renderer.isVML&&b.inverted&&(n+=1);c.pointPadding&&(j=La(j));O.prototype.translate.apply(a);q(a.points,function(c){var d=p(c.yBottom,f),h=L(t(-999-d,c.plotY),e.len+999+d), +q=c.plotX+k,r=j,s=L(h,d),u;u=t(h,d)-s;Q(u)<g&&g&&(u=g,s=v(Q(s-f)>g?d-g:f-(e.translate(c.y,0,1,0,1)<=f?g:0)));c.barX=q;c.pointWidth=i;c.tooltipPos=b.inverted?[e.len-h,a.xAxis.len-q-r/2]:[q+r/2,h+e.pos-b.plotTop];r=v(q+r)+l;q=v(q)+l;r-=q;d=Q(s)<0.5;u=v(s+u)+n;s=v(s)+n;u-=s;d&&(s-=1,u+=1);c.shapeType="rect";c.shapeArgs={x:q,y:s,width:r,height:u}})},getSymbol:sa,drawLegendSymbol:M.drawRectangle,drawGraph:sa,drawPoints:function(){var a=this,b=this.chart,c=a.options,d=b.renderer,e=c.animationLimit||250, +f,g;q(a.points,function(h){var i=h.plotY,j=h.graphic;if(i!==u&&!isNaN(i)&&h.y!==null)f=h.shapeArgs,i=s(a.borderWidth)?{"stroke-width":a.borderWidth}:{},g=h.pointAttr[h.selected?"select":""]||a.pointAttr[""],j?(bb(j),j.attr(i)[b.pointCount<e?"animate":"attr"](w(f))):h.graphic=d[h.shapeType](f).attr(g).attr(i).add(a.group).shadow(c.shadow,null,c.stacking&&!c.borderRadius);else if(j)h.graphic=j.destroy()})},animate:function(a){var b=this.yAxis,c=this.options,d=this.chart.inverted,e={};if(ba)a?(e.scaleY= +0.001,a=L(b.pos+b.len,t(b.pos,b.toPixels(c.threshold))),d?e.translateX=a-b.len:e.translateY=a,this.group.attr(e)):(e.scaleY=1,e[d?"translateX":"translateY"]=b.pos,this.group.animate(e,this.options.animation),this.animate=null)},remove:function(){var a=this,b=a.chart;b.hasRendered&&q(b.series,function(b){if(b.type===a.type)b.isDirty=!0});O.prototype.remove.apply(a,arguments)}});H.column=ia;ca.bar=w(ca.column);qa=ma(ia,{type:"bar",inverted:!0});H.bar=qa;ca.scatter=w(T,{lineWidth:0,tooltip:{headerFormat:'<span style="color:{series.color}">●</span> <span style="font-size: 10px;"> {series.name}</span><br/>', +pointFormat:"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>"},stickyTracking:!1});qa=ma(O,{type:"scatter",sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["markerGroup","dataLabelsGroup"],takeOrdinalPosition:!1,singularTooltips:!0,drawGraph:function(){this.options.lineWidth&&O.prototype.drawGraph.call(this)}});H.scatter=qa;ca.pie=w(T,{borderColor:"#FFFFFF",borderWidth:1,center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return this.point.name}}, +ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,states:{hover:{brightness:0.1,shadow:!1}},stickyTracking:!1,tooltip:{followPointer:!0}});T={type:"pie",isCartesian:!1,pointClass:ma(Fa,{init:function(){Fa.prototype.init.apply(this,arguments);var a=this,b;if(a.y<0)a.y=null;r(a,{visible:a.visible!==!1,name:p(a.name,"Slice")});b=function(b){a.slice(b.type==="select")};N(a,"select",b);N(a,"unselect",b);return a},setVisible:function(a){var b=this,c=b.series, +d=c.chart;b.visible=b.options.visible=a=a===u?!b.visible:a;c.options.data[Ma(b,c.data)]=b.options;q(["graphic","dataLabel","connector","shadowGroup"],function(c){if(b[c])b[c][a?"show":"hide"](!0)});b.legendItem&&d.legend.colorizeItem(b,a);if(!c.isDirty&&c.options.ignoreHiddenPoint)c.isDirty=!0,d.redraw()},slice:function(a,b,c){var d=this.series;Ra(c,d.chart);p(b,!0);this.sliced=this.options.sliced=a=s(a)?a:!this.sliced;d.options.data[Ma(this,d.data)]=this.options;a=a?this.slicedTranslation:{translateX:0, +translateY:0};this.graphic.animate(a);this.shadowGroup&&this.shadowGroup.animate(a)},haloPath:function(a){var b=this.shapeArgs,c=this.series.chart;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.plotLeft+b.x,c.plotTop+b.y,b.r+a,b.r+a,{innerR:this.shapeArgs.r,start:b.start,end:b.end})}}),requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},singularTooltips:!0, +getColor:sa,animate:function(a){var b=this,c=b.points,d=b.startAngleRad;if(!a)q(c,function(a){var c=a.graphic,a=a.shapeArgs;c&&(c.attr({r:b.center[3]/2,start:d,end:d}),c.animate({r:a.r,start:a.start,end:a.end},b.options.animation))}),b.animate=null},setData:function(a,b,c,d){O.prototype.setData.call(this,a,!1,c,d);this.processData();this.generatePoints();p(b,!0)&&this.chart.redraw(c)},generatePoints:function(){var a,b=0,c,d,e,f=this.options.ignoreHiddenPoint;O.prototype.generatePoints.call(this); +c=this.points;d=c.length;for(a=0;a<d;a++)e=c[a],b+=f&&!e.visible?0:e.y;this.total=b;for(a=0;a<d;a++)e=c[a],e.percentage=b>0?e.y/b*100:0,e.total=b},translate:function(a){this.generatePoints();var b=0,c=this.options,d=c.slicedOffset,e=d+c.borderWidth,f,g,h,i=c.startAngle||0,j=this.startAngleRad=oa/180*(i-90),i=(this.endAngleRad=oa/180*(p(c.endAngle,i+360)-90))-j,k=this.points,l=c.dataLabels.distance,c=c.ignoreHiddenPoint,n,m=k.length,o;if(!a)this.center=a=this.getCenter();this.getX=function(b,c){h= +V.asin(L((b-a[1])/(a[2]/2+l),1));return a[0]+(c?-1:1)*aa(h)*(a[2]/2+l)};for(n=0;n<m;n++){o=k[n];f=j+b*i;if(!c||o.visible)b+=o.percentage/100;g=j+b*i;o.shapeType="arc";o.shapeArgs={x:a[0],y:a[1],r:a[2]/2,innerR:a[3]/2,start:v(f*1E3)/1E3,end:v(g*1E3)/1E3};h=(g+f)/2;h>1.5*oa?h-=2*oa:h<-oa/2&&(h+=2*oa);o.slicedTranslation={translateX:v(aa(h)*d),translateY:v(fa(h)*d)};f=aa(h)*a[2]/2;g=fa(h)*a[2]/2;o.tooltipPos=[a[0]+f*0.7,a[1]+g*0.7];o.half=h<-oa/2||h>oa/2?1:0;o.angle=h;e=L(e,l/2);o.labelPos=[a[0]+f+aa(h)* +l,a[1]+g+fa(h)*l,a[0]+f+aa(h)*e,a[1]+g+fa(h)*e,a[0]+f,a[1]+g,l<0?"center":o.half?"right":"left",h]}},drawGraph:null,drawPoints:function(){var a=this,b=a.chart.renderer,c,d,e=a.options.shadow,f,g;if(e&&!a.shadowGroup)a.shadowGroup=b.g("shadow").add(a.group);q(a.points,function(h){d=h.graphic;g=h.shapeArgs;f=h.shadowGroup;if(e&&!f)f=h.shadowGroup=b.g("shadow").add(a.shadowGroup);c=h.sliced?h.slicedTranslation:{translateX:0,translateY:0};f&&f.attr(c);d?d.animate(r(g,c)):h.graphic=d=b[h.shapeType](g).setRadialReference(a.center).attr(h.pointAttr[h.selected? +"select":""]).attr({"stroke-linejoin":"round"}).attr(c).add(a.group).shadow(e,f);h.visible!==void 0&&h.setVisible(h.visible)})},sortByAngle:function(a,b){a.sort(function(a,d){return a.angle!==void 0&&(d.angle-a.angle)*b})},drawLegendSymbol:M.drawRectangle,getCenter:Z.getCenter,getSymbol:sa};T=ma(O,T);H.pie=T;O.prototype.drawDataLabels=function(){var a=this,b=a.options,c=b.cursor,d=b.dataLabels,e=a.points,f,g,h=a.hasRendered||0,i,j;if(d.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(d), +j=a.plotGroup("dataLabelsGroup","data-labels",d.defer?"hidden":"visible",d.zIndex||6),p(d.defer,!0)&&(j.attr({opacity:+h}),h||N(a,"afterAnimate",function(){a.visible&&j.show();j[b.animation?"animate":"attr"]({opacity:1},{duration:200})})),g=d,q(e,function(b){var e,h=b.dataLabel,m,o,q=b.connector,t=!0;f=b.options&&b.options.dataLabels;e=p(f&&f.enabled,g.enabled);if(h&&!e)b.dataLabel=h.destroy();else if(e){d=w(g,f);e=d.rotation;m=b.getLabelConfig();i=d.format?Ja(d.format,m):d.formatter.call(m,d);d.style.color= +p(d.color,d.style.color,a.color,"black");if(h)if(s(i))h.attr({text:i}),t=!1;else{if(b.dataLabel=h=h.destroy(),q)b.connector=q.destroy()}else if(s(i)){h={fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":d.borderWidth,r:d.borderRadius||0,rotation:e,padding:d.padding,zIndex:1};for(o in h)h[o]===u&&delete h[o];h=b.dataLabel=a.chart.renderer[e?"text":"label"](i,0,-999,null,null,null,d.useHTML).attr(h).css(r(d.style,c&&{cursor:c})).add(j).shadow(d.shadow)}h&&a.alignDataLabel(b,h,d,null,t)}})}; +O.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=p(a.plotX,-999),i=p(a.plotY,-999),j=b.getBBox();if(a=this.visible&&(a.series.forceDL||f.isInsidePlot(h,v(i),g)||d&&f.isInsidePlot(h,g?d.x+1:d.y+d.height-1,g)))d=r({x:g?f.plotWidth-i:h,y:v(g?f.plotHeight-h:i),width:0,height:0},d),r(c,{width:j.width,height:j.height}),c.rotation?b[e?"attr":"animate"]({x:d.x+c.x+d.width/2,y:d.y+c.y+d.height/2}).attr({align:c.align}):(b.align(c,null,d),g=b.alignAttr,p(c.overflow,"justify")=== +"justify"?this.justifyDataLabel(b,c,g,j,d,e):p(c.crop,!0)&&(a=f.isInsidePlot(g.x,g.y)&&f.isInsidePlot(g.x+j.width,g.y+j.height)));if(!a)b.attr({y:-999}),b.placed=!1};O.prototype.justifyDataLabel=function(a,b,c,d,e,f){var g=this.chart,h=b.align,i=b.verticalAlign,j,k;j=c.x;if(j<0)h==="right"?b.align="left":b.x=-j,k=!0;j=c.x+d.width;if(j>g.plotWidth)h==="left"?b.align="right":b.x=g.plotWidth-j,k=!0;j=c.y;if(j<0)i==="bottom"?b.verticalAlign="top":b.y=-j,k=!0;j=c.y+d.height;if(j>g.plotHeight)i==="top"? +b.verticalAlign="bottom":b.y=g.plotHeight-j,k=!0;if(k)a.placed=!f,a.align(b,null,e)};if(H.pie)H.pie.prototype.drawDataLabels=function(){var a=this,b=a.data,c,d=a.chart,e=a.options.dataLabels,f=p(e.connectorPadding,10),g=p(e.connectorWidth,1),h=d.plotWidth,i=d.plotHeight,j,k,l=p(e.softConnector,!0),n=e.distance,m=a.center,o=m[2]/2,r=m[1],s=n>0,u,w,x,A=[[],[]],y,B,I,H,z,R=[0,0,0,0],N=function(a,b){return b.y-a.y};if(a.visible&&(e.enabled||a._hasPointLabels)){O.prototype.drawDataLabels.apply(a);q(b, +function(a){a.dataLabel&&a.visible&&A[a.half].push(a)});for(H=2;H--;){var G=[],M=[],F=A[H],K=F.length,E;if(K){a.sortByAngle(F,H-0.5);for(z=b=0;!b&&F[z];)b=F[z]&&F[z].dataLabel&&(F[z].dataLabel.getBBox().height||21),z++;if(n>0){w=L(r+o+n,d.plotHeight);for(z=t(0,r-o-n);z<=w;z+=b)G.push(z);w=G.length;if(K>w){c=[].concat(F);c.sort(N);for(z=K;z--;)c[z].rank=z;for(z=K;z--;)F[z].rank>=w&&F.splice(z,1);K=F.length}for(z=0;z<K;z++){c=F[z];x=c.labelPos;c=9999;var S,P;for(P=0;P<w;P++)S=Q(G[P]-x[1]),S<c&&(c=S, +E=P);if(E<z&&G[z]!==null)E=z;else for(w<K-z+E&&G[z]!==null&&(E=w-K+z);G[E]===null;)E++;M.push({i:E,y:G[E]});G[E]=null}M.sort(N)}for(z=0;z<K;z++){c=F[z];x=c.labelPos;u=c.dataLabel;I=c.visible===!1?"hidden":"visible";c=x[1];if(n>0){if(w=M.pop(),E=w.i,B=w.y,c>B&&G[E+1]!==null||c<B&&G[E-1]!==null)B=L(t(0,c),d.plotHeight)}else B=c;y=e.justify?m[0]+(H?-1:1)*(o+n):a.getX(B===r-o-n||B===r+o+n?c:B,H);u._attr={visibility:I,align:x[6]};u._pos={x:y+e.x+({left:f,right:-f}[x[6]]||0),y:B+e.y-10};u.connX=y;u.connY= +B;if(this.options.size===null)w=u.width,y-w<f?R[3]=t(v(w-y+f),R[3]):y+w>h-f&&(R[1]=t(v(y+w-h+f),R[1])),B-b/2<0?R[0]=t(v(-B+b/2),R[0]):B+b/2>i&&(R[2]=t(v(B+b/2-i),R[2]))}}}if(Ca(R)===0||this.verifyDataLabelOverflow(R))this.placeDataLabels(),s&&g&&q(this.points,function(b){j=b.connector;x=b.labelPos;if((u=b.dataLabel)&&u._pos)I=u._attr.visibility,y=u.connX,B=u.connY,k=l?["M",y+(x[6]==="left"?5:-5),B,"C",y,B,2*x[2]-x[4],2*x[3]-x[5],x[2],x[3],"L",x[4],x[5]]:["M",y+(x[6]==="left"?5:-5),B,"L",x[2],x[3], +"L",x[4],x[5]],j?(j.animate({d:k}),j.attr("visibility",I)):b.connector=j=a.chart.renderer.path(k).attr({"stroke-width":g,stroke:e.connectorColor||b.color||"#606060",visibility:I}).add(a.dataLabelsGroup);else if(j)b.connector=j.destroy()})}},H.pie.prototype.placeDataLabels=function(){q(this.points,function(a){var a=a.dataLabel,b;if(a)(b=a._pos)?(a.attr(a._attr),a[a.moved?"animate":"attr"](b),a.moved=!0):a&&a.attr({y:-999})})},H.pie.prototype.alignDataLabel=sa,H.pie.prototype.verifyDataLabelOverflow= +function(a){var b=this.center,c=this.options,d=c.center,e=c=c.minSize||80,f;d[0]!==null?e=t(b[2]-t(a[1],a[3]),c):(e=t(b[2]-a[1]-a[3],c),b[0]+=(a[3]-a[1])/2);d[1]!==null?e=t(L(e,b[2]-t(a[0],a[2])),c):(e=t(L(e,b[2]-a[0]-a[2]),c),b[1]+=(a[0]-a[2])/2);e<b[2]?(b[2]=e,this.translate(b),q(this.points,function(a){if(a.dataLabel)a.dataLabel._pos=null}),this.drawDataLabels&&this.drawDataLabels()):f=!0;return f};if(H.column)H.column.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted, +h=a.dlBox||a.shapeArgs,i=a.below||a.plotY>p(this.translatedThreshold,f.plotSizeY),j=p(c.inside,!!this.options.stacking);if(h&&(d=w(h),g&&(d={x:f.plotWidth-d.y-d.height,y:f.plotHeight-d.x-d.width,width:d.height,height:d.width}),!j))g?(d.x+=i?0:d.width,d.width=0):(d.y+=i?d.height:0,d.height=0);c.align=p(c.align,!g||j?"center":i?"right":"left");c.verticalAlign=p(c.verticalAlign,g||j?"middle":i?"top":"bottom");O.prototype.alignDataLabel.call(this,a,b,c,d,e)};T=K.TrackerMixin={drawTrackerPoint:function(){var a= +this,b=a.chart,c=b.pointer,d=a.options.cursor,e=d&&{cursor:d},f=function(c){var d=c.target,e;if(b.hoverSeries!==a)a.onMouseOver();for(;d&&!e;)e=d.point,d=d.parentNode;if(e!==u&&e!==b.hoverPoint)e.onMouseOver(c)};q(a.points,function(a){if(a.graphic)a.graphic.element.point=a;if(a.dataLabel)a.dataLabel.element.point=a});if(!a._hasTracking)q(a.trackerGroups,function(b){if(a[b]&&(a[b].addClass("highcharts-tracker").on("mouseover",f).on("mouseout",function(a){c.onTrackerMouseOut(a)}).css(e),$a))a[b].on("touchstart", +f)}),a._hasTracking=!0},drawTrackerGraph:function(){var a=this,b=a.options,c=b.trackByArea,d=[].concat(c?a.areaPath:a.graphPath),e=d.length,f=a.chart,g=f.pointer,h=f.renderer,i=f.options.tooltip.snap,j=a.tracker,k=b.cursor,l=k&&{cursor:k},k=a.singlePoints,n,m=function(){if(f.hoverSeries!==a)a.onMouseOver()},o="rgba(192,192,192,"+(ba?1.0E-4:0.002)+")";if(e&&!c)for(n=e+1;n--;)d[n]==="M"&&d.splice(n+1,0,d[n+1]-i,d[n+2],"L"),(n&&d[n]==="M"||n===e)&&d.splice(n,0,"L",d[n-2]+i,d[n-1]);for(n=0;n<k.length;n++)e= +k[n],d.push("M",e.plotX-i,e.plotY,"L",e.plotX+i,e.plotY);j?j.attr({d:d}):(a.tracker=h.path(d).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:o,fill:c?o:P,"stroke-width":b.lineWidth+(c?0:2*i),zIndex:2}).add(a.group),q([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",m).on("mouseout",function(a){g.onTrackerMouseOut(a)}).css(l);if($a)a.on("touchstart",m)}))}};if(H.column)ia.prototype.drawTracker=T.drawTrackerPoint;if(H.pie)H.pie.prototype.drawTracker= +T.drawTrackerPoint;if(H.scatter)qa.prototype.drawTracker=T.drawTrackerPoint;r(lb.prototype,{setItemEvents:function(a,b,c,d,e){var f=this;(c?b:a.legendGroup).on("mouseover",function(){a.setState("hover");b.css(f.options.itemHoverStyle)}).on("mouseout",function(){b.css(a.visible?d:e);a.setState()}).on("click",function(b){var c=function(){a.setVisible()},b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):I(a,"legendItemClick",b,c)})},createCheckboxForItem:function(a){a.checkbox= +$("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},this.options.itemCheckboxStyle,this.chart.container);N(a.checkbox,"click",function(b){I(a,"checkboxClick",{checked:b.target.checked},function(){a.select()})})}});E.legend.itemStyle.cursor="pointer";r(Ya.prototype,{showResetZoom:function(){var a=this,b=E.lang,c=a.options.chart.resetZoomButton,d=c.theme,e=d.states,f=c.relativeTo==="chart"?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()}, +d,e&&e.hover).attr({align:c.position.align,title:b.resetZoomTitle}).add().align(c.position,!1,f)},zoomOut:function(){var a=this;I(a,"selection",{resetSelection:!0},function(){a.zoom()})},zoom:function(a){var b,c=this.pointer,d=!1,e;!a||a.resetSelection?q(this.axes,function(a){b=a.zoom()}):q(a.xAxis.concat(a.yAxis),function(a){var e=a.axis,h=e.isXAxis;if(c[h?"zoomX":"zoomY"]||c[h?"pinchX":"pinchY"])b=e.zoom(a.min,a.max),e.displayBtn&&(d=!0)});e=this.resetZoomButton;if(d&&!e)this.showResetZoom();else if(!d&& +da(e))this.resetZoomButton=e.destroy();b&&this.redraw(p(this.options.chart.animation,a&&a.animation,this.pointCount<100))},pan:function(a,b){var c=this,d=c.hoverPoints,e;d&&q(d,function(a){a.setState()});q(b==="xy"?[1,0]:[1],function(b){var d=a[b?"chartX":"chartY"],h=c[b?"xAxis":"yAxis"][0],i=c[b?"mouseDownX":"mouseDownY"],j=(h.pointRange||0)/2,k=h.getExtremes(),l=h.toValue(i-d,!0)+j,i=h.toValue(i+c[b?"plotWidth":"plotHeight"]-d,!0)-j;h.series.length&&l>L(k.dataMin,k.min)&&i<t(k.dataMax,k.max)&&(h.setExtremes(l, +i,!1,!1,{trigger:"pan"}),e=!0);c[b?"mouseDownX":"mouseDownY"]=d});e&&c.redraw(!1);B(c.container,{cursor:"move"})}});r(Fa.prototype,{select:function(a,b){var c=this,d=c.series,e=d.chart,a=p(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=c.options.selected=a;d.options.data[Ma(c,d.data)]=c.options;c.setState(a&&"select");b||q(e.getSelectedPoints(),function(a){if(a.selected&&a!==c)a.selected=a.options.selected=!1,d.options.data[Ma(a,d.data)]=a.options,a.setState(""), +a.firePointEvent("unselect")})})},onMouseOver:function(a){var b=this.series,c=b.chart,d=c.tooltip,e=c.hoverPoint;if(e&&e!==this)e.onMouseOut();this.firePointEvent("mouseOver");d&&(!d.shared||b.noSharedTooltip)&&d.refresh(this,a);this.setState("hover");c.hoverPoint=this},onMouseOut:function(){var a=this.series.chart,b=a.hoverPoints;this.firePointEvent("mouseOut");if(!b||Ma(this,b)===-1)this.setState(),a.hoverPoint=null},importEvents:function(){if(!this.hasImportedEvents){var a=w(this.series.options.point, +this.options).events,b;this.events=a;for(b in a)N(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,b){var c=this.plotX,d=this.plotY,e=this.series,f=e.options.states,g=ca[e.type].marker&&e.options.marker,h=g&&!g.enabled,i=g&&g.states[a],j=i&&i.enabled===!1,k=e.stateMarkerGraphic,l=this.marker||{},n=e.chart,m=e.halo,o,a=a||"";o=this.pointAttr[a]||e.pointAttr[a];if(!(a===this.state&&!b||this.selected&&a!=="select"||f[a]&&f[a].enabled===!1||a&&(j||h&&i.enabled===!1)||a&&l.states&&l.states[a]&& +l.states[a].enabled===!1)){if(this.graphic)g=g&&this.graphic.symbolName&&o.r,this.graphic.attr(w(o,g?{x:c-g,y:d-g,width:2*g,height:2*g}:{})),k&&k.hide();else{if(a&&i)if(g=i.radius,l=l.symbol||e.symbol,k&&k.currentSymbol!==l&&(k=k.destroy()),k)k[b?"animate":"attr"]({x:c-g,y:d-g});else if(l)e.stateMarkerGraphic=k=n.renderer.symbol(l,c-g,d-g,2*g,2*g).attr(o).add(e.markerGroup),k.currentSymbol=l;if(k)k[a&&n.isInsidePlot(c,d,n.inverted)?"show":"hide"]()}if((c=f[a]&&f[a].halo)&&c.size){if(!m)e.halo=m=n.renderer.path().add(e.seriesGroup); +m.attr(r({fill:ya(this.color||e.color).setOpacity(c.opacity).get()},c.attributes))[b?"animate":"attr"]({d:this.haloPath(c.size)})}else m&&m.attr({d:[]});this.state=a}},haloPath:function(a){var b=this.series,c=b.chart,d=b.getPlotBox(),e=c.inverted;return c.renderer.symbols.circle(d.translateX+(e?b.yAxis.len-this.plotY:this.plotX)-a,d.translateY+(e?b.xAxis.len-this.plotX:this.plotY)-a,a*2,a*2)}});r(O.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&& +I(this,"mouseOver");this.setState("hover");a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;if(d)d.onMouseOut();this&&a.events.mouseOut&&I(this,"mouseOut");c&&!a.stickyTracking&&(!c.shared||this.noSharedTooltip)&&c.hide();this.setState();b.hoverSeries=null},setState:function(a){var b=this.options,c=this.graph,d=this.graphNeg,e=b.states,b=b.lineWidth,a=a||"";if(this.state!==a)this.state=a,e[a]&&e[a].enabled===!1||(a&&(b=e[a].lineWidth||b+(e[a].lineWidthPlus|| +0)),c&&!c.dashstyle&&(a={"stroke-width":b},c.attr(a),d&&d.attr(a)))},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,f,g=d.options.chart.ignoreHiddenSeries,h=c.visible;f=(c.visible=a=c.userOptions.visible=a===u?!h:a)?"show":"hide";q(["group","dataLabelsGroup","markerGroup","tracker"],function(a){if(c[a])c[a][f]()});if(d.hoverSeries===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&q(d.series,function(a){if(a.options.stacking&&a.visible)a.isDirty=!0});q(c.linkedSeries, +function(b){b.setVisible(a,!1)});if(g)d.isDirtyBox=!0;b!==!1&&d.redraw();I(c,f)},setTooltipPoints:function(a){var b=[],c,d,e=this.xAxis,f=e&&e.getExtremes(),g=e?e.tooltipLen||e.len:this.chart.plotSizeX,h,i,j=[];if(!(this.options.enableMouseTracking===!1||this.singularTooltips)){if(a)this.tooltipPoints=null;q(this.segments||this.points,function(a){b=b.concat(a)});e&&e.reversed&&(b=b.reverse());this.orderTooltipPoints&&this.orderTooltipPoints(b);a=b.length;for(i=0;i<a;i++)if(e=b[i],c=e.x,c>=f.min&& +c<=f.max){h=b[i+1];c=d===u?0:d+1;for(d=b[i+1]?L(t(0,U((e.clientX+(h?h.wrappedClientX||h.clientX:g))/2)),g):g;c>=0&&c<=d;)j[c++]=e}this.tooltipPoints=j}},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=a===u?!this.selected:a;if(this.checkbox)this.checkbox.checked=a;I(this,a?"select":"unselect")},drawTracker:T.drawTrackerGraph});r(K,{Axis:na,Chart:Ya,Color:ya,Point:Fa,Tick:Ta,Renderer:Za,Series:O,SVGElement:S,SVGRenderer:ta,arrayMin:Oa,arrayMax:Ca, +charts:W,dateFormat:cb,format:Ja,pathAnim:vb,getOptions:function(){return E},hasBidiBug:Ob,isTouchDevice:Ib,numberFormat:Ba,seriesTypes:H,setOptions:function(a){E=w(!0,E,a);Bb();return E},addEvent:N,removeEvent:X,createElement:$,discardElement:Qa,css:B,each:q,extend:r,map:Va,merge:w,pick:p,splat:ra,extendClass:ma,pInt:y,wrap:Na,svg:ba,canvas:ga,vml:!ba&&!ga,product:"Highcharts",version:"4.0.4"})})(); diff --git a/html/includes/js/highcharts.src.js b/html/includes/js/highcharts.src.js new file mode 100644 index 0000000..6b32688 --- /dev/null +++ b/html/includes/js/highcharts.src.js @@ -0,0 +1,17737 @@ +// ==ClosureCompiler== +// @compilation_level SIMPLE_OPTIMIZATIONS + +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * + * (c) 2009-2014 Torstein Honsi + * + * License: www.highcharts.com/license + */ + +// JSLint options: +/*global Highcharts, HighchartsAdapter, document, window, navigator, setInterval, clearInterval, clearTimeout, setTimeout, location, jQuery, $, console, each, grep */ +/*jslint ass: true, sloppy: true, forin: true, plusplus: true, nomen: true, vars: true, regexp: true, newcap: true, browser: true, continue: true, white: true */ +(function () { +// encapsulated variables +var UNDEFINED, + doc = document, + win = window, + math = Math, + mathRound = math.round, + mathFloor = math.floor, + mathCeil = math.ceil, + mathMax = math.max, + mathMin = math.min, + mathAbs = math.abs, + mathCos = math.cos, + mathSin = math.sin, + mathPI = math.PI, + deg2rad = mathPI * 2 / 360, + + + // some variables + userAgent = navigator.userAgent, + isOpera = win.opera, + isIE = /msie/i.test(userAgent) && !isOpera, + docMode8 = doc.documentMode === 8, + isWebKit = /AppleWebKit/.test(userAgent), + isFirefox = /Firefox/.test(userAgent), + isTouchDevice = /(Mobile|Android|Windows Phone)/.test(userAgent), + SVG_NS = 'http://www.w3.org/2000/svg', + hasSVG = !!doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect, + hasBidiBug = isFirefox && parseInt(userAgent.split('Firefox/')[1], 10) < 4, // issue #38 + useCanVG = !hasSVG && !isIE && !!doc.createElement('canvas').getContext, + Renderer, + hasTouch, + symbolSizes = {}, + idCounter = 0, + garbageBin, + defaultOptions, + dateFormat, // function + globalAnimation, + pathAnim, + timeUnits, + error, + noop = function () { return UNDEFINED; }, + charts = [], + chartCount = 0, + PRODUCT = 'Highcharts', + VERSION = '4.0.4', + + // some constants for frequently used strings + DIV = 'div', + ABSOLUTE = 'absolute', + RELATIVE = 'relative', + HIDDEN = 'hidden', + PREFIX = 'highcharts-', + VISIBLE = 'visible', + PX = 'px', + NONE = 'none', + M = 'M', + L = 'L', + numRegex = /^[0-9]+$/, + NORMAL_STATE = '', + HOVER_STATE = 'hover', + SELECT_STATE = 'select', + + // Object for extending Axis + AxisPlotLineOrBandExtension, + + // constants for attributes + STROKE_WIDTH = 'stroke-width', + + // time methods, changed based on whether or not UTC is used + Date, // Allow using a different Date class + makeTime, + timezoneOffset, + getMinutes, + getHours, + getDay, + getDate, + getMonth, + getFullYear, + setMinutes, + setHours, + setDate, + setMonth, + setFullYear, + + + // lookup over the types and the associated classes + seriesTypes = {}, + Highcharts; + +// The Highcharts namespace +if (win.Highcharts) { + error(16, true); +} else { + Highcharts = win.Highcharts = {}; +} +/** + * Extend an object with the members of another + * @param {Object} a The object to be extended + * @param {Object} b The object to add to the first one + */ +function extend(a, b) { + var n; + if (!a) { + a = {}; + } + for (n in b) { + a[n] = b[n]; + } + return a; +} + +/** + * Deep merge two or more objects and return a third object. If the first argument is + * true, the contents of the second object is copied into the first object. + * Previously this function redirected to jQuery.extend(true), but this had two limitations. + * First, it deep merged arrays, which lead to workarounds in Highcharts. Second, + * it copied properties from extended prototypes. + */ +function merge() { + var i, + args = arguments, + len, + ret = {}, + doCopy = function (copy, original) { + var value, key; + + // An object is replacing a primitive + if (typeof copy !== 'object') { + copy = {}; + } + + for (key in original) { + if (original.hasOwnProperty(key)) { + value = original[key]; + + // Copy the contents of objects, but not arrays or DOM nodes + if (value && typeof value === 'object' && Object.prototype.toString.call(value) !== '[object Array]' + && key !== 'renderTo' && typeof value.nodeType !== 'number') { + copy[key] = doCopy(copy[key] || {}, value); + + // Primitives and arrays are copied over directly + } else { + copy[key] = original[key]; + } + } + } + return copy; + }; + + // If first argument is true, copy into the existing object. Used in setOptions. + if (args[0] === true) { + ret = args[1]; + args = Array.prototype.slice.call(args, 2); + } + + // For each argument, extend the return + len = args.length; + for (i = 0; i < len; i++) { + ret = doCopy(ret, args[i]); + } + + return ret; +} + +/** + * Shortcut for parseInt + * @param {Object} s + * @param {Number} mag Magnitude + */ +function pInt(s, mag) { + return parseInt(s, mag || 10); +} + +/** + * Check for string + * @param {Object} s + */ +function isString(s) { + return typeof s === 'string'; +} + +/** + * Check for object + * @param {Object} obj + */ +function isObject(obj) { + return obj && typeof obj === 'object'; +} + +/** + * Check for array + * @param {Object} obj + */ +function isArray(obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; +} + +/** + * Check for number + * @param {Object} n + */ +function isNumber(n) { + return typeof n === 'number'; +} + +function log2lin(num) { + return math.log(num) / math.LN10; +} +function lin2log(num) { + return math.pow(10, num); +} + +/** + * Remove last occurence of an item from an array + * @param {Array} arr + * @param {Mixed} item + */ +function erase(arr, item) { + var i = arr.length; + while (i--) { + if (arr[i] === item) { + arr.splice(i, 1); + break; + } + } + //return arr; +} + +/** + * Returns true if the object is not null or undefined. Like MooTools' $.defined. + * @param {Object} obj + */ +function defined(obj) { + return obj !== UNDEFINED && obj !== null; +} + +/** + * Set or get an attribute or an object of attributes. Can't use jQuery attr because + * it attempts to set expando properties on the SVG element, which is not allowed. + * + * @param {Object} elem The DOM element to receive the attribute(s) + * @param {String|Object} prop The property or an abject of key-value pairs + * @param {String} value The value if a single property is set + */ +function attr(elem, prop, value) { + var key, + ret; + + // if the prop is a string + if (isString(prop)) { + // set the value + if (defined(value)) { + elem.setAttribute(prop, value); + + // get the value + } else if (elem && elem.getAttribute) { // elem not defined when printing pie demo... + ret = elem.getAttribute(prop); + } + + // else if prop is defined, it is a hash of key/value pairs + } else if (defined(prop) && isObject(prop)) { + for (key in prop) { + elem.setAttribute(key, prop[key]); + } + } + return ret; +} +/** + * Check if an element is an array, and if not, make it into an array. Like + * MooTools' $.splat. + */ +function splat(obj) { + return isArray(obj) ? obj : [obj]; +} + + +/** + * Return the first value that is defined. Like MooTools' $.pick. + */ +function pick() { + var args = arguments, + i, + arg, + length = args.length; + for (i = 0; i < length; i++) { + arg = args[i]; + if (arg !== UNDEFINED && arg !== null) { + return arg; + } + } +} + +/** + * Set CSS on a given element + * @param {Object} el + * @param {Object} styles Style object with camel case property names + */ +function css(el, styles) { + if (isIE && !hasSVG) { // #2686 + if (styles && styles.opacity !== UNDEFINED) { + styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')'; + } + } + extend(el.style, styles); +} + +/** + * Utility function to create element with attributes and styles + * @param {Object} tag + * @param {Object} attribs + * @param {Object} styles + * @param {Object} parent + * @param {Object} nopad + */ +function createElement(tag, attribs, styles, parent, nopad) { + var el = doc.createElement(tag); + if (attribs) { + extend(el, attribs); + } + if (nopad) { + css(el, {padding: 0, border: NONE, margin: 0}); + } + if (styles) { + css(el, styles); + } + if (parent) { + parent.appendChild(el); + } + return el; +} + +/** + * Extend a prototyped class by new members + * @param {Object} parent + * @param {Object} members + */ +function extendClass(parent, members) { + var object = function () { return UNDEFINED; }; + object.prototype = new parent(); + extend(object.prototype, members); + return object; +} + +/** + * Format a number and return a string based on input settings + * @param {Number} number The input number to format + * @param {Number} decimals The amount of decimals + * @param {String} decPoint The decimal point, defaults to the one given in the lang options + * @param {String} thousandsSep The thousands separator, defaults to the one given in the lang options + */ +function numberFormat(number, decimals, decPoint, thousandsSep) { + var externalFn = Highcharts.numberFormat, + lang = defaultOptions.lang, + // http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_number_format/ + n = +number || 0, + c = decimals === -1 ? + (n.toString().split('.')[1] || '').length : // preserve decimals + (isNaN(decimals = mathAbs(decimals)) ? 2 : decimals), + d = decPoint === undefined ? lang.decimalPoint : decPoint, + t = thousandsSep === undefined ? lang.thousandsSep : thousandsSep, + s = n < 0 ? "-" : "", + i = String(pInt(n = mathAbs(n).toFixed(c))), + j = i.length > 3 ? i.length % 3 : 0; + + return externalFn !== numberFormat ? + externalFn(number, decimals, decPoint, thousandsSep) : + (s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + + (c ? d + mathAbs(n - i).toFixed(c).slice(2) : "")); +} + +/** + * Pad a string to a given length by adding 0 to the beginning + * @param {Number} number + * @param {Number} length + */ +function pad(number, length) { + // Create an array of the remaining length +1 and join it with 0's + return new Array((length || 2) + 1 - String(number).length).join(0) + number; +} + +/** + * Wrap a method with extended functionality, preserving the original function + * @param {Object} obj The context object that the method belongs to + * @param {String} method The name of the method to extend + * @param {Function} func A wrapper function callback. This function is called with the same arguments + * as the original function, except that the original function is unshifted and passed as the first + * argument. + */ +function wrap(obj, method, func) { + var proceed = obj[method]; + obj[method] = function () { + var args = Array.prototype.slice.call(arguments); + args.unshift(proceed); + return func.apply(this, args); + }; +} + +/** + * Based on http://www.php.net/manual/en/function.strftime.php + * @param {String} format + * @param {Number} timestamp + * @param {Boolean} capitalize + */ +dateFormat = function (format, timestamp, capitalize) { + if (!defined(timestamp) || isNaN(timestamp)) { + return 'Invalid date'; + } + format = pick(format, '%Y-%m-%d %H:%M:%S'); + + var date = new Date(timestamp - timezoneOffset), + key, // used in for constuct below + // get the basic time values + hours = date[getHours](), + day = date[getDay](), + dayOfMonth = date[getDate](), + month = date[getMonth](), + fullYear = date[getFullYear](), + lang = defaultOptions.lang, + langWeekdays = lang.weekdays, + + // List all format keys. Custom formats can be added from the outside. + replacements = extend({ + + // Day + 'a': langWeekdays[day].substr(0, 3), // Short weekday, like 'Mon' + 'A': langWeekdays[day], // Long weekday, like 'Monday' + 'd': pad(dayOfMonth), // Two digit day of the month, 01 to 31 + 'e': dayOfMonth, // Day of the month, 1 through 31 + + // Week (none implemented) + //'W': weekNumber(), + + // Month + 'b': lang.shortMonths[month], // Short month, like 'Jan' + 'B': lang.months[month], // Long month, like 'January' + 'm': pad(month + 1), // Two digit month number, 01 through 12 + + // Year + 'y': fullYear.toString().substr(2, 2), // Two digits year, like 09 for 2009 + 'Y': fullYear, // Four digits year, like 2009 + + // Time + 'H': pad(hours), // Two digits hours in 24h format, 00 through 23 + 'I': pad((hours % 12) || 12), // Two digits hours in 12h format, 00 through 11 + 'l': (hours % 12) || 12, // Hours in 12h format, 1 through 12 + 'M': pad(date[getMinutes]()), // Two digits minutes, 00 through 59 + 'p': hours < 12 ? 'AM' : 'PM', // Upper case AM or PM + 'P': hours < 12 ? 'am' : 'pm', // Lower case AM or PM + 'S': pad(date.getSeconds()), // Two digits seconds, 00 through 59 + 'L': pad(mathRound(timestamp % 1000), 3) // Milliseconds (naming from Ruby) + }, Highcharts.dateFormats); + + + // do the replaces + for (key in replacements) { + while (format.indexOf('%' + key) !== -1) { // regex would do it in one line, but this is faster + format = format.replace('%' + key, typeof replacements[key] === 'function' ? replacements[key](timestamp) : replacements[key]); + } + } + + // Optionally capitalize the string and return + return capitalize ? format.substr(0, 1).toUpperCase() + format.substr(1) : format; +}; + +/** + * Format a single variable. Similar to sprintf, without the % prefix. + */ +function formatSingle(format, val) { + var floatRegex = /f$/, + decRegex = /\.([0-9])/, + lang = defaultOptions.lang, + decimals; + + if (floatRegex.test(format)) { // float + decimals = format.match(decRegex); + decimals = decimals ? decimals[1] : -1; + if (val !== null) { + val = numberFormat( + val, + decimals, + lang.decimalPoint, + format.indexOf(',') > -1 ? lang.thousandsSep : '' + ); + } + } else { + val = dateFormat(format, val); + } + return val; +} + +/** + * Format a string according to a subset of the rules of Python's String.format method. + */ +function format(str, ctx) { + var splitter = '{', + isInside = false, + segment, + valueAndFormat, + path, + i, + len, + ret = [], + val, + index; + + while ((index = str.indexOf(splitter)) !== -1) { + + segment = str.slice(0, index); + if (isInside) { // we're on the closing bracket looking back + + valueAndFormat = segment.split(':'); + path = valueAndFormat.shift().split('.'); // get first and leave format + len = path.length; + val = ctx; + + // Assign deeper paths + for (i = 0; i < len; i++) { + val = val[path[i]]; + } + + // Format the replacement + if (valueAndFormat.length) { + val = formatSingle(valueAndFormat.join(':'), val); + } + + // Push the result and advance the cursor + ret.push(val); + + } else { + ret.push(segment); + + } + str = str.slice(index + 1); // the rest + isInside = !isInside; // toggle + splitter = isInside ? '}' : '{'; // now look for next matching bracket + } + ret.push(str); + return ret.join(''); +} + +/** + * Get the magnitude of a number + */ +function getMagnitude(num) { + return math.pow(10, mathFloor(math.log(num) / math.LN10)); +} + +/** + * Take an interval and normalize it to multiples of 1, 2, 2.5 and 5 + * @param {Number} interval + * @param {Array} multiples + * @param {Number} magnitude + * @param {Object} options + */ +function normalizeTickInterval(interval, multiples, magnitude, allowDecimals) { + var normalized, i; + + // round to a tenfold of 1, 2, 2.5 or 5 + magnitude = pick(magnitude, 1); + normalized = interval / magnitude; + + // multiples for a linear scale + if (!multiples) { + multiples = [1, 2, 2.5, 5, 10]; + + // the allowDecimals option + if (allowDecimals === false) { + if (magnitude === 1) { + multiples = [1, 2, 5, 10]; + } else if (magnitude <= 0.1) { + multiples = [1 / magnitude]; + } + } + } + + // normalize the interval to the nearest multiple + for (i = 0; i < multiples.length; i++) { + interval = multiples[i]; + if (normalized <= (multiples[i] + (multiples[i + 1] || multiples[i])) / 2) { + break; + } + } + + // multiply back to the correct magnitude + interval *= magnitude; + + return interval; +} + + +/** + * Utility method that sorts an object array and keeping the order of equal items. + * ECMA script standard does not specify the behaviour when items are equal. + */ +function stableSort(arr, sortFunction) { + var length = arr.length, + sortValue, + i; + + // Add index to each item + for (i = 0; i < length; i++) { + arr[i].ss_i = i; // stable sort index + } + + arr.sort(function (a, b) { + sortValue = sortFunction(a, b); + return sortValue === 0 ? a.ss_i - b.ss_i : sortValue; + }); + + // Remove index from items + for (i = 0; i < length; i++) { + delete arr[i].ss_i; // stable sort index + } +} + +/** + * Non-recursive method to find the lowest member of an array. Math.min raises a maximum + * call stack size exceeded error in Chrome when trying to apply more than 150.000 points. This + * method is slightly slower, but safe. + */ +function arrayMin(data) { + var i = data.length, + min = data[0]; + + while (i--) { + if (data[i] < min) { + min = data[i]; + } + } + return min; +} + +/** + * Non-recursive method to find the lowest member of an array. Math.min raises a maximum + * call stack size exceeded error in Chrome when trying to apply more than 150.000 points. This + * method is slightly slower, but safe. + */ +function arrayMax(data) { + var i = data.length, + max = data[0]; + + while (i--) { + if (data[i] > max) { + max = data[i]; + } + } + return max; +} + +/** + * Utility method that destroys any SVGElement or VMLElement that are properties on the given object. + * It loops all properties and invokes destroy if there is a destroy method. The property is + * then delete'ed. + * @param {Object} The object to destroy properties on + * @param {Object} Exception, do not destroy this property, only delete it. + */ +function destroyObjectProperties(obj, except) { + var n; + for (n in obj) { + // If the object is non-null and destroy is defined + if (obj[n] && obj[n] !== except && obj[n].destroy) { + // Invoke the destroy + obj[n].destroy(); + } + + // Delete the property from the object. + delete obj[n]; + } +} + + +/** + * Discard an element by moving it to the bin and delete + * @param {Object} The HTML node to discard + */ +function discardElement(element) { + // create a garbage bin element, not part of the DOM + if (!garbageBin) { + garbageBin = createElement(DIV); + } + + // move the node and empty bin + if (element) { + garbageBin.appendChild(element); + } + garbageBin.innerHTML = ''; +} + +/** + * Provide error messages for debugging, with links to online explanation + */ +error = function (code, stop) { + var msg = 'Highcharts error #' + code + ': www.highcharts.com/errors/' + code; + if (stop) { + throw msg; + } + // else ... + if (win.console) { + console.log(msg); + } +}; + +/** + * Fix JS round off float errors + * @param {Number} num + */ +function correctFloat(num) { + return parseFloat( + num.toPrecision(14) + ); +} + +/** + * Set the global animation to either a given value, or fall back to the + * given chart's animation option + * @param {Object} animation + * @param {Object} chart + */ +function setAnimation(animation, chart) { + globalAnimation = pick(animation, chart.animation); +} + +/** + * The time unit lookup + */ +timeUnits = { + millisecond: 1, + second: 1000, + minute: 60000, + hour: 3600000, + day: 24 * 3600000, + week: 7 * 24 * 3600000, + month: 31 * 24 * 3600000, + year: 31556952000 +}; +/** + * Path interpolation algorithm used across adapters + */ +pathAnim = { + /** + * Prepare start and end values so that the path can be animated one to one + */ + init: function (elem, fromD, toD) { + fromD = fromD || ''; + var shift = elem.shift, + bezier = fromD.indexOf('C') > -1, + numParams = bezier ? 7 : 3, + endLength, + slice, + i, + start = fromD.split(' '), + end = [].concat(toD), // copy + startBaseLine, + endBaseLine, + sixify = function (arr) { // in splines make move points have six parameters like bezier curves + i = arr.length; + while (i--) { + if (arr[i] === M) { + arr.splice(i + 1, 0, arr[i + 1], arr[i + 2], arr[i + 1], arr[i + 2]); + } + } + }; + + if (bezier) { + sixify(start); + sixify(end); + } + + // pull out the base lines before padding + if (elem.isArea) { + startBaseLine = start.splice(start.length - 6, 6); + endBaseLine = end.splice(end.length - 6, 6); + } + + // if shifting points, prepend a dummy point to the end path + if (shift <= end.length / numParams && start.length === end.length) { + while (shift--) { + end = [].concat(end).splice(0, numParams).concat(end); + } + } + elem.shift = 0; // reset for following animations + + // copy and append last point until the length matches the end length + if (start.length) { + endLength = end.length; + while (start.length < endLength) { + + //bezier && sixify(start); + slice = [].concat(start).splice(start.length - numParams, numParams); + if (bezier) { // disable first control point + slice[numParams - 6] = slice[numParams - 2]; + slice[numParams - 5] = slice[numParams - 1]; + } + start = start.concat(slice); + } + } + + if (startBaseLine) { // append the base lines for areas + start = start.concat(startBaseLine); + end = end.concat(endBaseLine); + } + return [start, end]; + }, + + /** + * Interpolate each value of the path and return the array + */ + step: function (start, end, pos, complete) { + var ret = [], + i = start.length, + startVal; + + if (pos === 1) { // land on the final path without adjustment points appended in the ends + ret = complete; + + } else if (i === end.length && pos < 1) { + while (i--) { + startVal = parseFloat(start[i]); + ret[i] = + isNaN(startVal) ? // a letter instruction like M or L + start[i] : + pos * (parseFloat(end[i] - startVal)) + startVal; + + } + } else { // if animation is finished or length not matching, land on right value + ret = end; + } + return ret; + } +}; + +(function ($) { + /** + * The default HighchartsAdapter for jQuery + */ + win.HighchartsAdapter = win.HighchartsAdapter || ($ && { + + /** + * Initialize the adapter by applying some extensions to jQuery + */ + init: function (pathAnim) { + + // extend the animate function to allow SVG animations + var Fx = $.fx; + + /*jslint unparam: true*//* allow unused param x in this function */ + $.extend($.easing, { + easeOutQuad: function (x, t, b, c, d) { + return -c * (t /= d) * (t - 2) + b; + } + }); + /*jslint unparam: false*/ + + // extend some methods to check for elem.attr, which means it is a Highcharts SVG object + $.each(['cur', '_default', 'width', 'height', 'opacity'], function (i, fn) { + var obj = Fx.step, + base; + + // Handle different parent objects + if (fn === 'cur') { + obj = Fx.prototype; // 'cur', the getter, relates to Fx.prototype + + } else if (fn === '_default' && $.Tween) { // jQuery 1.8 model + obj = $.Tween.propHooks[fn]; + fn = 'set'; + } + + // Overwrite the method + base = obj[fn]; + if (base) { // step.width and step.height don't exist in jQuery < 1.7 + + // create the extended function replacement + obj[fn] = function (fx) { + + var elem; + + // Fx.prototype.cur does not use fx argument + fx = i ? fx : this; + + // Don't run animations on textual properties like align (#1821) + if (fx.prop === 'align') { + return; + } + + // shortcut + elem = fx.elem; + + // Fx.prototype.cur returns the current value. The other ones are setters + // and returning a value has no effect. + return elem.attr ? // is SVG element wrapper + elem.attr(fx.prop, fn === 'cur' ? UNDEFINED : fx.now) : // apply the SVG wrapper's method + base.apply(this, arguments); // use jQuery's built-in method + }; + } + }); + + // Extend the opacity getter, needed for fading opacity with IE9 and jQuery 1.10+ + wrap($.cssHooks.opacity, 'get', function (proceed, elem, computed) { + return elem.attr ? (elem.opacity || 0) : proceed.call(this, elem, computed); + }); + + // Define the setter function for d (path definitions) + this.addAnimSetter('d', function (fx) { + var elem = fx.elem, + ends; + + // Normally start and end should be set in state == 0, but sometimes, + // for reasons unknown, this doesn't happen. Perhaps state == 0 is skipped + // in these cases + if (!fx.started) { + ends = pathAnim.init(elem, elem.d, elem.toD); + fx.start = ends[0]; + fx.end = ends[1]; + fx.started = true; + } + + // Interpolate each value of the path + elem.attr('d', pathAnim.step(fx.start, fx.end, fx.pos, elem.toD)); + }); + + /** + * Utility for iterating over an array. Parameters are reversed compared to jQuery. + * @param {Array} arr + * @param {Function} fn + */ + this.each = Array.prototype.forEach ? + function (arr, fn) { // modern browsers + return Array.prototype.forEach.call(arr, fn); + + } : + function (arr, fn) { // legacy + var i, + len = arr.length; + for (i = 0; i < len; i++) { + if (fn.call(arr[i], arr[i], i, arr) === false) { + return i; + } + } + }; + + /** + * Register Highcharts as a plugin in the respective framework + */ + $.fn.highcharts = function () { + var constr = 'Chart', // default constructor + args = arguments, + options, + ret, + chart; + + if (this[0]) { + + if (isString(args[0])) { + constr = args[0]; + args = Array.prototype.slice.call(args, 1); + } + options = args[0]; + + // Create the chart + if (options !== UNDEFINED) { + /*jslint unused:false*/ + options.chart = options.chart || {}; + options.chart.renderTo = this[0]; + chart = new Highcharts[constr](options, args[1]); + ret = this; + /*jslint unused:true*/ + } + + // When called without parameters or with the return argument, get a predefined chart + if (options === UNDEFINED) { + ret = charts[attr(this[0], 'data-highcharts-chart')]; + } + } + + return ret; + }; + + }, + + /** + * Add an animation setter for a specific property + */ + addAnimSetter: function (prop, setter) { + // jQuery 1.8 style + if ($.Tween) { + $.Tween.propHooks[prop] = { + set: setter + }; + // pre 1.8 + } else { + $.fx.step[prop] = setter; + } + }, + + /** + * Downloads a script and executes a callback when done. + * @param {String} scriptLocation + * @param {Function} callback + */ + getScript: $.getScript, + + /** + * Return the index of an item in an array, or -1 if not found + */ + inArray: $.inArray, + + /** + * A direct link to jQuery methods. MooTools and Prototype adapters must be implemented for each case of method. + * @param {Object} elem The HTML element + * @param {String} method Which method to run on the wrapped element + */ + adapterRun: function (elem, method) { + return $(elem)[method](); + }, + + /** + * Filter an array + */ + grep: $.grep, + + /** + * Map an array + * @param {Array} arr + * @param {Function} fn + */ + map: function (arr, fn) { + //return jQuery.map(arr, fn); + var results = [], + i = 0, + len = arr.length; + for (; i < len; i++) { + results[i] = fn.call(arr[i], arr[i], i, arr); + } + return results; + + }, + + /** + * Get the position of an element relative to the top left of the page + */ + offset: function (el) { + return $(el).offset(); + }, + + /** + * Add an event listener + * @param {Object} el A HTML element or custom object + * @param {String} event The event type + * @param {Function} fn The event handler + */ + addEvent: function (el, event, fn) { + $(el).bind(event, fn); + }, + + /** + * Remove event added with addEvent + * @param {Object} el The object + * @param {String} eventType The event type. Leave blank to remove all events. + * @param {Function} handler The function to remove + */ + removeEvent: function (el, eventType, handler) { + // workaround for jQuery issue with unbinding custom events: + // http://forum.jQuery.com/topic/javascript-error-when-unbinding-a-custom-event-using-jQuery-1-4-2 + var func = doc.removeEventListener ? 'removeEventListener' : 'detachEvent'; + if (doc[func] && el && !el[func]) { + el[func] = function () {}; + } + + $(el).unbind(eventType, handler); + }, + + /** + * Fire an event on a custom object + * @param {Object} el + * @param {String} type + * @param {Object} eventArguments + * @param {Function} defaultFunction + */ + fireEvent: function (el, type, eventArguments, defaultFunction) { + var event = $.Event(type), + detachedType = 'detached' + type, + defaultPrevented; + + // Remove warnings in Chrome when accessing returnValue (#2790), layerX and layerY. Although Highcharts + // never uses these properties, Chrome includes them in the default click event and + // raises the warning when they are copied over in the extend statement below. + // + // To avoid problems in IE (see #1010) where we cannot delete the properties and avoid + // testing if they are there (warning in chrome) the only option is to test if running IE. + if (!isIE && eventArguments) { + delete eventArguments.layerX; + delete eventArguments.layerY; + delete eventArguments.returnValue; + } + + extend(event, eventArguments); + + // Prevent jQuery from triggering the object method that is named the + // same as the event. For example, if the event is 'select', jQuery + // attempts calling el.select and it goes into a loop. + if (el[type]) { + el[detachedType] = el[type]; + el[type] = null; + } + + // Wrap preventDefault and stopPropagation in try/catch blocks in + // order to prevent JS errors when cancelling events on non-DOM + // objects. #615. + /*jslint unparam: true*/ + $.each(['preventDefault', 'stopPropagation'], function (i, fn) { + var base = event[fn]; + event[fn] = function () { + try { + base.call(event); + } catch (e) { + if (fn === 'preventDefault') { + defaultPrevented = true; + } + } + }; + }); + /*jslint unparam: false*/ + + // trigger it + $(el).trigger(event); + + // attach the method + if (el[detachedType]) { + el[type] = el[detachedType]; + el[detachedType] = null; + } + + if (defaultFunction && !event.isDefaultPrevented() && !defaultPrevented) { + defaultFunction(event); + } + }, + + /** + * Extension method needed for MooTools + */ + washMouseEvent: function (e) { + var ret = e.originalEvent || e; + + // computed by jQuery, needed by IE8 + if (ret.pageX === UNDEFINED) { // #1236 + ret.pageX = e.pageX; + ret.pageY = e.pageY; + } + + return ret; + }, + + /** + * Animate a HTML element or SVG element wrapper + * @param {Object} el + * @param {Object} params + * @param {Object} options jQuery-like animation options: duration, easing, callback + */ + animate: function (el, params, options) { + var $el = $(el); + if (!el.style) { + el.style = {}; // #1881 + } + if (params.d) { + el.toD = params.d; // keep the array form for paths, used in $.fx.step.d + params.d = 1; // because in jQuery, animating to an array has a different meaning + } + + $el.stop(); + if (params.opacity !== UNDEFINED && el.attr) { + params.opacity += 'px'; // force jQuery to use same logic as width and height (#2161) + } + el.hasAnim = 1; // #3342 + $el.animate(params, options); + + }, + /** + * Stop running animation + */ + stop: function (el) { + if (el.hasAnim) { // #3342, memory leak on calling $(el) from destroy + $(el).stop(); + } + } + }); +}(win.jQuery)); + + +// check for a custom HighchartsAdapter defined prior to this file +var globalAdapter = win.HighchartsAdapter, + adapter = globalAdapter || {}; + +// Initialize the adapter +if (globalAdapter) { + globalAdapter.init.call(globalAdapter, pathAnim); +} + + +// Utility functions. If the HighchartsAdapter is not defined, adapter is an empty object +// and all the utility functions will be null. In that case they are populated by the +// default adapters below. +var adapterRun = adapter.adapterRun, + getScript = adapter.getScript, + inArray = adapter.inArray, + each = adapter.each, + grep = adapter.grep, + offset = adapter.offset, + map = adapter.map, + addEvent = adapter.addEvent, + removeEvent = adapter.removeEvent, + fireEvent = adapter.fireEvent, + washMouseEvent = adapter.washMouseEvent, + animate = adapter.animate, + stop = adapter.stop; + + + +/* **************************************************************************** + * Handle the options * + *****************************************************************************/ +var + +defaultLabelOptions = { + enabled: true, + // rotation: 0, + // align: 'center', + x: 0, + y: 15, + /*formatter: function () { + return this.value; + },*/ + style: { + color: '#606060', + cursor: 'default', + fontSize: '11px' + } +}; + +defaultOptions = { + colors: ['#7cb5ec', '#434348', '#90ed7d', '#f7a35c', + '#8085e9', '#f15c80', '#e4d354', '#8085e8', '#8d4653', '#91e8e1'], + symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'], + lang: { + loading: 'Loading...', + months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', + 'August', 'September', 'October', 'November', 'December'], + shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + decimalPoint: '.', + numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'], // SI prefixes used in axis labels + resetZoom: 'Reset zoom', + resetZoomTitle: 'Reset zoom level 1:1', + thousandsSep: ',' + }, + global: { + useUTC: true, + //timezoneOffset: 0, + canvasToolsURL: 'http://code.highcharts.com/4.0.4/modules/canvas-tools.js', + VMLRadialGradientURL: 'http://code.highcharts.com/4.0.4/gfx/vml-radial-gradient.png' + }, + chart: { + //animation: true, + //alignTicks: false, + //reflow: true, + //className: null, + //events: { load, selection }, + //margin: [null], + //marginTop: null, + //marginRight: null, + //marginBottom: null, + //marginLeft: null, + borderColor: '#4572A7', + //borderWidth: 0, + borderRadius: 0, + defaultSeriesType: 'line', + ignoreHiddenSeries: true, + //inverted: false, + //shadow: false, + spacing: [10, 10, 15, 10], + //spacingTop: 10, + //spacingRight: 10, + //spacingBottom: 15, + //spacingLeft: 10, + //style: { + // fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif', // default font + // fontSize: '12px' + //}, + backgroundColor: '#FFFFFF', + //plotBackgroundColor: null, + plotBorderColor: '#C0C0C0', + //plotBorderWidth: 0, + //plotShadow: false, + //zoomType: '' + resetZoomButton: { + theme: { + zIndex: 20 + }, + position: { + align: 'right', + x: -10, + //verticalAlign: 'top', + y: 10 + } + // relativeTo: 'plot' + } + }, + title: { + text: 'Chart title', + align: 'center', + // floating: false, + margin: 15, + // x: 0, + // verticalAlign: 'top', + // y: null, + style: { + color: '#333333', + fontSize: '18px' + } + + }, + subtitle: { + text: '', + align: 'center', + // floating: false + // x: 0, + // verticalAlign: 'top', + // y: null, + style: { + color: '#555555' + } + }, + + plotOptions: { + line: { // base series options + allowPointSelect: false, + showCheckbox: false, + animation: { + duration: 1000 + }, + //connectNulls: false, + //cursor: 'default', + //clip: true, + //dashStyle: null, + //enableMouseTracking: true, + events: {}, + //legendIndex: 0, + //linecap: 'round', + lineWidth: 2, + //shadow: false, + // stacking: null, + marker: { + //enabled: true, + //symbol: null, + lineWidth: 0, + radius: 4, + lineColor: '#FFFFFF', + //fillColor: null, + states: { // states for a single point + hover: { + enabled: true, + lineWidthPlus: 1, + radiusPlus: 2 + }, + select: { + fillColor: '#FFFFFF', + lineColor: '#000000', + lineWidth: 2 + } + } + }, + point: { + events: {} + }, + dataLabels: merge(defaultLabelOptions, { + align: 'center', + //defer: true, + enabled: false, + formatter: function () { + return this.y === null ? '' : numberFormat(this.y, -1); + }, + verticalAlign: 'bottom', // above singular point + y: 0 + // backgroundColor: undefined, + // borderColor: undefined, + // borderRadius: undefined, + // borderWidth: undefined, + // padding: 3, + // shadow: false + }), + cropThreshold: 300, // draw points outside the plot area when the number of points is less than this + pointRange: 0, + //pointStart: 0, + //pointInterval: 1, + //showInLegend: null, // auto: true for standalone series, false for linked series + states: { // states for the entire series + hover: { + //enabled: false, + lineWidthPlus: 1, + marker: { + // lineWidth: base + 1, + // radius: base + 1 + }, + halo: { + size: 10, + opacity: 0.25 + } + }, + select: { + marker: {} + } + }, + stickyTracking: true, + //tooltip: { + //pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.y}</b>' + //valueDecimals: null, + //xDateFormat: '%A, %b %e, %Y', + //valuePrefix: '', + //ySuffix: '' + //} + turboThreshold: 1000 + // zIndex: null + } + }, + labels: { + //items: [], + style: { + //font: defaultFont, + position: ABSOLUTE, + color: '#3E576F' + } + }, + legend: { + enabled: true, + align: 'center', + //floating: false, + layout: 'horizontal', + labelFormatter: function () { + return this.name; + }, + //borderWidth: 0, + borderColor: '#909090', + borderRadius: 0, + navigation: { + // animation: true, + activeColor: '#274b6d', + // arrowSize: 12 + inactiveColor: '#CCC' + // style: {} // text styles + }, + // margin: 20, + // reversed: false, + shadow: false, + // backgroundColor: null, + /*style: { + padding: '5px' + },*/ + itemStyle: { + color: '#333333', + fontSize: '12px', + fontWeight: 'bold' + }, + itemHoverStyle: { + //cursor: 'pointer', removed as of #601 + color: '#000' + }, + itemHiddenStyle: { + color: '#CCC' + }, + itemCheckboxStyle: { + position: ABSOLUTE, + width: '13px', // for IE precision + height: '13px' + }, + // itemWidth: undefined, + // symbolRadius: 0, + // symbolWidth: 16, + symbolPadding: 5, + verticalAlign: 'bottom', + // width: undefined, + x: 0, + y: 0, + title: { + //text: null, + style: { + fontWeight: 'bold' + } + } + }, + + loading: { + // hideDuration: 100, + labelStyle: { + fontWeight: 'bold', + position: RELATIVE, + top: '45%' + }, + // showDuration: 0, + style: { + position: ABSOLUTE, + backgroundColor: 'white', + opacity: 0.5, + textAlign: 'center' + } + }, + + tooltip: { + enabled: true, + animation: hasSVG, + //crosshairs: null, + backgroundColor: 'rgba(249, 249, 249, .85)', + borderWidth: 1, + borderRadius: 3, + dateTimeLabelFormats: { + millisecond: '%A, %b %e, %H:%M:%S.%L', + second: '%A, %b %e, %H:%M:%S', + minute: '%A, %b %e, %H:%M', + hour: '%A, %b %e, %H:%M', + day: '%A, %b %e, %Y', + week: 'Week from %A, %b %e, %Y', + month: '%B %Y', + year: '%Y' + }, + //formatter: defaultFormatter, + headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>', + pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>', + shadow: true, + //shape: 'callout', + //shared: false, + snap: isTouchDevice ? 25 : 10, + style: { + color: '#333333', + cursor: 'default', + fontSize: '12px', + padding: '8px', + whiteSpace: 'nowrap' + } + //xDateFormat: '%A, %b %e, %Y', + //valueDecimals: null, + //valuePrefix: '', + //valueSuffix: '' + }, + + credits: { + enabled: true, + text: 'Highcharts.com', + href: 'http://www.highcharts.com', + position: { + align: 'right', + x: -10, + verticalAlign: 'bottom', + y: -5 + }, + style: { + cursor: 'pointer', + color: '#909090', + fontSize: '9px' + } + } +}; + + + + +// Series defaults +var defaultPlotOptions = defaultOptions.plotOptions, + defaultSeriesOptions = defaultPlotOptions.line; + +// set the default time methods +setTimeMethods(); + + + +/** + * Set the time methods globally based on the useUTC option. Time method can be either + * local time or UTC (default). + */ +function setTimeMethods() { + var useUTC = defaultOptions.global.useUTC, + GET = useUTC ? 'getUTC' : 'get', + SET = useUTC ? 'setUTC' : 'set'; + + + Date = defaultOptions.global.Date || window.Date; + timezoneOffset = ((useUTC && defaultOptions.global.timezoneOffset) || 0) * 60000; + makeTime = useUTC ? Date.UTC : function (year, month, date, hours, minutes, seconds) { + return new Date( + year, + month, + pick(date, 1), + pick(hours, 0), + pick(minutes, 0), + pick(seconds, 0) + ).getTime(); + }; + getMinutes = GET + 'Minutes'; + getHours = GET + 'Hours'; + getDay = GET + 'Day'; + getDate = GET + 'Date'; + getMonth = GET + 'Month'; + getFullYear = GET + 'FullYear'; + setMinutes = SET + 'Minutes'; + setHours = SET + 'Hours'; + setDate = SET + 'Date'; + setMonth = SET + 'Month'; + setFullYear = SET + 'FullYear'; + +} + +/** + * Merge the default options with custom options and return the new options structure + * @param {Object} options The new custom options + */ +function setOptions(options) { + + // Copy in the default options + defaultOptions = merge(true, defaultOptions, options); + + // Apply UTC + setTimeMethods(); + + return defaultOptions; +} + +/** + * Get the updated default options. Until 3.0.7, merely exposing defaultOptions for outside modules + * wasn't enough because the setOptions method created a new object. + */ +function getOptions() { + return defaultOptions; +} + + +/** + * Handle color operations. The object methods are chainable. + * @param {String} input The input color in either rbga or hex format + */ +var rgbaRegEx = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/, + hexRegEx = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/, + rgbRegEx = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/; + +var Color = function (input) { + // declare variables + var rgba = [], result, stops; + + /** + * Parse the input color to rgba array + * @param {String} input + */ + function init(input) { + + // Gradients + if (input && input.stops) { + stops = map(input.stops, function (stop) { + return Color(stop[1]); + }); + + // Solid colors + } else { + // rgba + result = rgbaRegEx.exec(input); + if (result) { + rgba = [pInt(result[1]), pInt(result[2]), pInt(result[3]), parseFloat(result[4], 10)]; + } else { + // hex + result = hexRegEx.exec(input); + if (result) { + rgba = [pInt(result[1], 16), pInt(result[2], 16), pInt(result[3], 16), 1]; + } else { + // rgb + result = rgbRegEx.exec(input); + if (result) { + rgba = [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1]; + } + } + } + } + + } + /** + * Return the color a specified format + * @param {String} format + */ + function get(format) { + var ret; + + if (stops) { + ret = merge(input); + ret.stops = [].concat(ret.stops); + each(stops, function (stop, i) { + ret.stops[i] = [ret.stops[i][0], stop.get(format)]; + }); + + // it's NaN if gradient colors on a column chart + } else if (rgba && !isNaN(rgba[0])) { + if (format === 'rgb') { + ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')'; + } else if (format === 'a') { + ret = rgba[3]; + } else { + ret = 'rgba(' + rgba.join(',') + ')'; + } + } else { + ret = input; + } + return ret; + } + + /** + * Brighten the color + * @param {Number} alpha + */ + function brighten(alpha) { + if (stops) { + each(stops, function (stop) { + stop.brighten(alpha); + }); + + } else if (isNumber(alpha) && alpha !== 0) { + var i; + for (i = 0; i < 3; i++) { + rgba[i] += pInt(alpha * 255); + + if (rgba[i] < 0) { + rgba[i] = 0; + } + if (rgba[i] > 255) { + rgba[i] = 255; + } + } + } + return this; + } + /** + * Set the color's opacity to a given alpha value + * @param {Number} alpha + */ + function setOpacity(alpha) { + rgba[3] = alpha; + return this; + } + + // initialize: parse the input + init(input); + + // public methods + return { + get: get, + brighten: brighten, + rgba: rgba, + setOpacity: setOpacity + }; +}; + + +/** + * A wrapper object for SVG elements + */ +function SVGElement() {} + +SVGElement.prototype = { + + // Default base for animation + opacity: 1, + // For labels, these CSS properties are applied to the <text> node directly + textProps: ['fontSize', 'fontWeight', 'fontFamily', 'color', + 'lineHeight', 'width', 'textDecoration', 'textShadow', 'HcTextStroke'], + + /** + * Initialize the SVG renderer + * @param {Object} renderer + * @param {String} nodeName + */ + init: function (renderer, nodeName) { + var wrapper = this; + wrapper.element = nodeName === 'span' ? + createElement(nodeName) : + doc.createElementNS(SVG_NS, nodeName); + wrapper.renderer = renderer; + }, + + /** + * Animate a given attribute + * @param {Object} params + * @param {Number} options The same options as in jQuery animation + * @param {Function} complete Function to perform at the end of animation + */ + animate: function (params, options, complete) { + var animOptions = pick(options, globalAnimation, true); + stop(this); // stop regardless of animation actually running, or reverting to .attr (#607) + if (animOptions) { + animOptions = merge(animOptions, {}); //#2625 + if (complete) { // allows using a callback with the global animation without overwriting it + animOptions.complete = complete; + } + animate(this, params, animOptions); + } else { + this.attr(params); + if (complete) { + complete(); + } + } + return this; + }, + + /** + * Build an SVG gradient out of a common JavaScript configuration object + */ + colorGradient: function (color, prop, elem) { + var renderer = this.renderer, + colorObject, + gradName, + gradAttr, + gradients, + gradientObject, + stops, + stopColor, + stopOpacity, + radialReference, + n, + id, + key = []; + + // Apply linear or radial gradients + if (color.linearGradient) { + gradName = 'linearGradient'; + } else if (color.radialGradient) { + gradName = 'radialGradient'; + } + + if (gradName) { + gradAttr = color[gradName]; + gradients = renderer.gradients; + stops = color.stops; + radialReference = elem.radialReference; + + // Keep < 2.2 kompatibility + if (isArray(gradAttr)) { + color[gradName] = gradAttr = { + x1: gradAttr[0], + y1: gradAttr[1], + x2: gradAttr[2], + y2: gradAttr[3], + gradientUnits: 'userSpaceOnUse' + }; + } + + // Correct the radial gradient for the radial reference system + if (gradName === 'radialGradient' && radialReference && !defined(gradAttr.gradientUnits)) { + gradAttr = merge(gradAttr, { + cx: (radialReference[0] - radialReference[2] / 2) + gradAttr.cx * radialReference[2], + cy: (radialReference[1] - radialReference[2] / 2) + gradAttr.cy * radialReference[2], + r: gradAttr.r * radialReference[2], + gradientUnits: 'userSpaceOnUse' + }); + } + + // Build the unique key to detect whether we need to create a new element (#1282) + for (n in gradAttr) { + if (n !== 'id') { + key.push(n, gradAttr[n]); + } + } + for (n in stops) { + key.push(stops[n]); + } + key = key.join(','); + + // Check if a gradient object with the same config object is created within this renderer + if (gradients[key]) { + id = gradients[key].attr('id'); + + } else { + + // Set the id and create the element + gradAttr.id = id = PREFIX + idCounter++; + gradients[key] = gradientObject = renderer.createElement(gradName) + .attr(gradAttr) + .add(renderer.defs); + + + // The gradient needs to keep a list of stops to be able to destroy them + gradientObject.stops = []; + each(stops, function (stop) { + var stopObject; + if (stop[1].indexOf('rgba') === 0) { + colorObject = Color(stop[1]); + stopColor = colorObject.get('rgb'); + stopOpacity = colorObject.get('a'); + } else { + stopColor = stop[1]; + stopOpacity = 1; + } + stopObject = renderer.createElement('stop').attr({ + offset: stop[0], + 'stop-color': stopColor, + 'stop-opacity': stopOpacity + }).add(gradientObject); + + // Add the stop element to the gradient + gradientObject.stops.push(stopObject); + }); + } + + // Set the reference to the gradient object + elem.setAttribute(prop, 'url(' + renderer.url + '#' + id + ')'); + } + }, + + /** + * Set or get a given attribute + * @param {Object|String} hash + * @param {Mixed|Undefined} val + */ + attr: function (hash, val) { + var key, + value, + element = this.element, + hasSetSymbolSize, + ret = this, + skipAttr; + + // single key-value pair + if (typeof hash === 'string' && val !== UNDEFINED) { + key = hash; + hash = {}; + hash[key] = val; + } + + // used as a getter: first argument is a string, second is undefined + if (typeof hash === 'string') { + ret = (this[hash + 'Getter'] || this._defaultGetter).call(this, hash, element); + + // setter + } else { + + for (key in hash) { + value = hash[key]; + skipAttr = false; + + + + if (this.symbolName && /^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)/.test(key)) { + if (!hasSetSymbolSize) { + this.symbolAttr(hash); + hasSetSymbolSize = true; + } + skipAttr = true; + } + + if (this.rotation && (key === 'x' || key === 'y')) { + this.doTransform = true; + } + + if (!skipAttr) { + (this[key + 'Setter'] || this._defaultSetter).call(this, value, key, element); + } + + // Let the shadow follow the main element + if (this.shadows && /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) { + this.updateShadows(key, value); + } + } + + // Update transform. Do this outside the loop to prevent redundant updating for batch setting + // of attributes. + if (this.doTransform) { + this.updateTransform(); + this.doTransform = false; + } + + } + + return ret; + }, + + updateShadows: function (key, value) { + var shadows = this.shadows, + i = shadows.length; + while (i--) { + shadows[i].setAttribute( + key, + key === 'height' ? + mathMax(value - (shadows[i].cutHeight || 0), 0) : + key === 'd' ? this.d : value + ); + } + }, + + /** + * Add a class name to an element + */ + addClass: function (className) { + var element = this.element, + currentClassName = attr(element, 'class') || ''; + + if (currentClassName.indexOf(className) === -1) { + attr(element, 'class', currentClassName + ' ' + className); + } + return this; + }, + /* hasClass and removeClass are not (yet) needed + hasClass: function (className) { + return attr(this.element, 'class').indexOf(className) !== -1; + }, + removeClass: function (className) { + attr(this.element, 'class', attr(this.element, 'class').replace(className, '')); + return this; + }, + */ + + /** + * If one of the symbol size affecting parameters are changed, + * check all the others only once for each call to an element's + * .attr() method + * @param {Object} hash + */ + symbolAttr: function (hash) { + var wrapper = this; + + each(['x', 'y', 'r', 'start', 'end', 'width', 'height', 'innerR', 'anchorX', 'anchorY'], function (key) { + wrapper[key] = pick(hash[key], wrapper[key]); + }); + + wrapper.attr({ + d: wrapper.renderer.symbols[wrapper.symbolName]( + wrapper.x, + wrapper.y, + wrapper.width, + wrapper.height, + wrapper + ) + }); + }, + + /** + * Apply a clipping path to this object + * @param {String} id + */ + clip: function (clipRect) { + return this.attr('clip-path', clipRect ? 'url(' + this.renderer.url + '#' + clipRect.id + ')' : NONE); + }, + + /** + * Calculate the coordinates needed for drawing a rectangle crisply and return the + * calculated attributes + * @param {Number} strokeWidth + * @param {Number} x + * @param {Number} y + * @param {Number} width + * @param {Number} height + */ + crisp: function (rect) { + + var wrapper = this, + key, + attribs = {}, + normalizer, + strokeWidth = rect.strokeWidth || wrapper.strokeWidth || 0; + + normalizer = mathRound(strokeWidth) % 2 / 2; // mathRound because strokeWidth can sometimes have roundoff errors + + // normalize for crisp edges + rect.x = mathFloor(rect.x || wrapper.x || 0) + normalizer; + rect.y = mathFloor(rect.y || wrapper.y || 0) + normalizer; + rect.width = mathFloor((rect.width || wrapper.width || 0) - 2 * normalizer); + rect.height = mathFloor((rect.height || wrapper.height || 0) - 2 * normalizer); + rect.strokeWidth = strokeWidth; + + for (key in rect) { + if (wrapper[key] !== rect[key]) { // only set attribute if changed + wrapper[key] = attribs[key] = rect[key]; + } + } + + return attribs; + }, + + /** + * Set styles for the element + * @param {Object} styles + */ + css: function (styles) { + var elemWrapper = this, + oldStyles = elemWrapper.styles, + newStyles = {}, + elem = elemWrapper.element, + textWidth, + n, + serializedCss = '', + hyphenate, + hasNew = !oldStyles; + + // convert legacy + if (styles && styles.color) { + styles.fill = styles.color; + } + + // Filter out existing styles to increase performance (#2640) + if (oldStyles) { + for (n in styles) { + if (styles[n] !== oldStyles[n]) { + newStyles[n] = styles[n]; + hasNew = true; + } + } + } + if (hasNew) { + textWidth = elemWrapper.textWidth = styles && styles.width && elem.nodeName.toLowerCase() === 'text' && pInt(styles.width); + + // Merge the new styles with the old ones + if (oldStyles) { + styles = extend( + oldStyles, + newStyles + ); + } + + // store object + elemWrapper.styles = styles; + + if (textWidth && (useCanVG || (!hasSVG && elemWrapper.renderer.forExport))) { + delete styles.width; + } + + // serialize and set style attribute + if (isIE && !hasSVG) { + css(elemWrapper.element, styles); + } else { + /*jslint unparam: true*/ + hyphenate = function (a, b) { return '-' + b.toLowerCase(); }; + /*jslint unparam: false*/ + for (n in styles) { + serializedCss += n.replace(/([A-Z])/g, hyphenate) + ':' + styles[n] + ';'; + } + attr(elem, 'style', serializedCss); // #1881 + } + + + // re-build text + if (textWidth && elemWrapper.added) { + elemWrapper.renderer.buildText(elemWrapper); + } + } + + return elemWrapper; + }, + + /** + * Add an event listener + * @param {String} eventType + * @param {Function} handler + */ + on: function (eventType, handler) { + var svgElement = this, + element = svgElement.element; + + // touch + if (hasTouch && eventType === 'click') { + element.ontouchstart = function (e) { + svgElement.touchEventFired = Date.now(); + e.preventDefault(); + handler.call(element, e); + }; + element.onclick = function (e) { + if (userAgent.indexOf('Android') === -1 || Date.now() - (svgElement.touchEventFired || 0) > 1100) { // #2269 + handler.call(element, e); + } + }; + } else { + // simplest possible event model for internal use + element['on' + eventType] = handler; + } + return this; + }, + + /** + * Set the coordinates needed to draw a consistent radial gradient across + * pie slices regardless of positioning inside the chart. The format is + * [centerX, centerY, diameter] in pixels. + */ + setRadialReference: function (coordinates) { + this.element.radialReference = coordinates; + return this; + }, + + /** + * Move an object and its children by x and y values + * @param {Number} x + * @param {Number} y + */ + translate: function (x, y) { + return this.attr({ + translateX: x, + translateY: y + }); + }, + + /** + * Invert a group, rotate and flip + */ + invert: function () { + var wrapper = this; + wrapper.inverted = true; + wrapper.updateTransform(); + return wrapper; + }, + + /** + * Private method to update the transform attribute based on internal + * properties + */ + updateTransform: function () { + var wrapper = this, + translateX = wrapper.translateX || 0, + translateY = wrapper.translateY || 0, + scaleX = wrapper.scaleX, + scaleY = wrapper.scaleY, + inverted = wrapper.inverted, + rotation = wrapper.rotation, + element = wrapper.element, + transform; + + // flipping affects translate as adjustment for flipping around the group's axis + if (inverted) { + translateX += wrapper.attr('width'); + translateY += wrapper.attr('height'); + } + + // Apply translate. Nearly all transformed elements have translation, so instead + // of checking for translate = 0, do it always (#1767, #1846). + transform = ['translate(' + translateX + ',' + translateY + ')']; + + // apply rotation + if (inverted) { + transform.push('rotate(90) scale(-1,1)'); + } else if (rotation) { // text rotation + transform.push('rotate(' + rotation + ' ' + (element.getAttribute('x') || 0) + ' ' + (element.getAttribute('y') || 0) + ')'); + } + + // apply scale + if (defined(scaleX) || defined(scaleY)) { + transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')'); + } + + if (transform.length) { + element.setAttribute('transform', transform.join(' ')); + } + }, + /** + * Bring the element to the front + */ + toFront: function () { + var element = this.element; + element.parentNode.appendChild(element); + return this; + }, + + + /** + * Break down alignment options like align, verticalAlign, x and y + * to x and y relative to the chart. + * + * @param {Object} alignOptions + * @param {Boolean} alignByTranslate + * @param {String[Object} box The box to align to, needs a width and height. When the + * box is a string, it refers to an object in the Renderer. For example, when + * box is 'spacingBox', it refers to Renderer.spacingBox which holds width, height + * x and y properties. + * + */ + align: function (alignOptions, alignByTranslate, box) { + var align, + vAlign, + x, + y, + attribs = {}, + alignTo, + renderer = this.renderer, + alignedObjects = renderer.alignedObjects; + + // First call on instanciate + if (alignOptions) { + this.alignOptions = alignOptions; + this.alignByTranslate = alignByTranslate; + if (!box || isString(box)) { // boxes other than renderer handle this internally + this.alignTo = alignTo = box || 'renderer'; + erase(alignedObjects, this); // prevent duplicates, like legendGroup after resize + alignedObjects.push(this); + box = null; // reassign it below + } + + // When called on resize, no arguments are supplied + } else { + alignOptions = this.alignOptions; + alignByTranslate = this.alignByTranslate; + alignTo = this.alignTo; + } + + box = pick(box, renderer[alignTo], renderer); + + // Assign variables + align = alignOptions.align; + vAlign = alignOptions.verticalAlign; + x = (box.x || 0) + (alignOptions.x || 0); // default: left align + y = (box.y || 0) + (alignOptions.y || 0); // default: top align + + // Align + if (align === 'right' || align === 'center') { + x += (box.width - (alignOptions.width || 0)) / + { right: 1, center: 2 }[align]; + } + attribs[alignByTranslate ? 'translateX' : 'x'] = mathRound(x); + + + // Vertical align + if (vAlign === 'bottom' || vAlign === 'middle') { + y += (box.height - (alignOptions.height || 0)) / + ({ bottom: 1, middle: 2 }[vAlign] || 1); + + } + attribs[alignByTranslate ? 'translateY' : 'y'] = mathRound(y); + + // Animate only if already placed + this[this.placed ? 'animate' : 'attr'](attribs); + this.placed = true; + this.alignAttr = attribs; + + return this; + }, + + /** + * Get the bounding box (width, height, x and y) for the element + */ + getBBox: function () { + var wrapper = this, + bBox = wrapper.bBox, + renderer = wrapper.renderer, + width, + height, + rotation = wrapper.rotation, + element = wrapper.element, + styles = wrapper.styles, + rad = rotation * deg2rad, + textStr = wrapper.textStr, + cacheKey; + + // Since numbers are monospaced, and numerical labels appear a lot in a chart, + // we assume that a label of n characters has the same bounding box as others + // of the same length. + if (textStr === '' || numRegex.test(textStr)) { + cacheKey = 'num.' + textStr.toString().length + (styles ? ('|' + styles.fontSize + '|' + styles.fontFamily) : ''); + + } //else { // This code block made demo/waterfall fail, related to buildText + // Caching all strings reduces rendering time by 4-5%. + // TODO: Check how this affects places where bBox is found on the element + //cacheKey = textStr + (styles ? ('|' + styles.fontSize + '|' + styles.fontFamily) : ''); + //} + if (cacheKey) { + bBox = renderer.cache[cacheKey]; + } + + // No cache found + if (!bBox) { + + // SVG elements + if (element.namespaceURI === SVG_NS || renderer.forExport) { + try { // Fails in Firefox if the container has display: none. + + bBox = element.getBBox ? + // SVG: use extend because IE9 is not allowed to change width and height in case + // of rotation (below) + extend({}, element.getBBox()) : + // Canvas renderer and legacy IE in export mode + { + width: element.offsetWidth, + height: element.offsetHeight + }; + } catch (e) {} + + // If the bBox is not set, the try-catch block above failed. The other condition + // is for Opera that returns a width of -Infinity on hidden elements. + if (!bBox || bBox.width < 0) { + bBox = { width: 0, height: 0 }; + } + + + // VML Renderer or useHTML within SVG + } else { + + bBox = wrapper.htmlGetBBox(); + + } + + // True SVG elements as well as HTML elements in modern browsers using the .useHTML option + // need to compensated for rotation + if (renderer.isSVG) { + width = bBox.width; + height = bBox.height; + + // Workaround for wrong bounding box in IE9 and IE10 (#1101, #1505, #1669, #2568) + if (isIE && styles && styles.fontSize === '11px' && height.toPrecision(3) === '16.9') { + bBox.height = height = 14; + } + + // Adjust for rotated text + if (rotation) { + bBox.width = mathAbs(height * mathSin(rad)) + mathAbs(width * mathCos(rad)); + bBox.height = mathAbs(height * mathCos(rad)) + mathAbs(width * mathSin(rad)); + } + } + + // Cache it + wrapper.bBox = bBox; + if (cacheKey) { + renderer.cache[cacheKey] = bBox; + } + } + return bBox; + }, + + /** + * Show the element + */ + show: function (inherit) { + // IE9-11 doesn't handle visibilty:inherit well, so we remove the attribute instead (#2881) + if (inherit && this.element.namespaceURI === SVG_NS) { + this.element.removeAttribute('visibility'); + } else { + this.attr({ visibility: inherit ? 'inherit' : VISIBLE }); + } + return this; + }, + + /** + * Hide the element + */ + hide: function () { + return this.attr({ visibility: HIDDEN }); + }, + + fadeOut: function (duration) { + var elemWrapper = this; + elemWrapper.animate({ + opacity: 0 + }, { + duration: duration || 150, + complete: function () { + elemWrapper.attr({ y: -9999 }); // #3088, assuming we're only using this for tooltips + } + }); + }, + + /** + * Add the element + * @param {Object|Undefined} parent Can be an element, an element wrapper or undefined + * to append the element to the renderer.box. + */ + add: function (parent) { + + var renderer = this.renderer, + parentWrapper = parent || renderer, + parentNode = parentWrapper.element || renderer.box, + childNodes, + element = this.element, + zIndex = this.zIndex, + otherElement, + otherZIndex, + i, + inserted; + + if (parent) { + this.parentGroup = parent; + } + + // mark as inverted + this.parentInverted = parent && parent.inverted; + + // build formatted text + if (this.textStr !== undefined) { + renderer.buildText(this); + } + + // mark the container as having z indexed children + if (zIndex) { + parentWrapper.handleZ = true; + zIndex = pInt(zIndex); + } + + // insert according to this and other elements' zIndex + if (parentWrapper.handleZ) { // this element or any of its siblings has a z index + childNodes = parentNode.childNodes; + for (i = 0; i < childNodes.length; i++) { + otherElement = childNodes[i]; + otherZIndex = attr(otherElement, 'zIndex'); + if (otherElement !== element && ( + // insert before the first element with a higher zIndex + pInt(otherZIndex) > zIndex || + // if no zIndex given, insert before the first element with a zIndex + (!defined(zIndex) && defined(otherZIndex)) + + )) { + parentNode.insertBefore(element, otherElement); + inserted = true; + break; + } + } + } + + // default: append at the end + if (!inserted) { + parentNode.appendChild(element); + } + + // mark as added + this.added = true; + + // fire an event for internal hooks + if (this.onAdd) { + this.onAdd(); + } + + return this; + }, + + /** + * Removes a child either by removeChild or move to garbageBin. + * Issue 490; in VML removeChild results in Orphaned nodes according to sIEve, discardElement does not. + */ + safeRemoveChild: function (element) { + var parentNode = element.parentNode; + if (parentNode) { + parentNode.removeChild(element); + } + }, + + /** + * Destroy the element and element wrapper + */ + destroy: function () { + var wrapper = this, + element = wrapper.element || {}, + shadows = wrapper.shadows, + parentToClean = wrapper.renderer.isSVG && element.nodeName === 'SPAN' && wrapper.parentGroup, + grandParent, + key, + i; + + // remove events + element.onclick = element.onmouseout = element.onmouseover = element.onmousemove = element.point = null; + stop(wrapper); // stop running animations + + if (wrapper.clipPath) { + wrapper.clipPath = wrapper.clipPath.destroy(); + } + + // Destroy stops in case this is a gradient object + if (wrapper.stops) { + for (i = 0; i < wrapper.stops.length; i++) { + wrapper.stops[i] = wrapper.stops[i].destroy(); + } + wrapper.stops = null; + } + + // remove element + wrapper.safeRemoveChild(element); + + // destroy shadows + if (shadows) { + each(shadows, function (shadow) { + wrapper.safeRemoveChild(shadow); + }); + } + + // In case of useHTML, clean up empty containers emulating SVG groups (#1960, #2393, #2697). + while (parentToClean && parentToClean.div && parentToClean.div.childNodes.length === 0) { + grandParent = parentToClean.parentGroup; + wrapper.safeRemoveChild(parentToClean.div); + delete parentToClean.div; + parentToClean = grandParent; + } + + // remove from alignObjects + if (wrapper.alignTo) { + erase(wrapper.renderer.alignedObjects, wrapper); + } + + for (key in wrapper) { + delete wrapper[key]; + } + + return null; + }, + + /** + * Add a shadow to the element. Must be done after the element is added to the DOM + * @param {Boolean|Object} shadowOptions + */ + shadow: function (shadowOptions, group, cutOff) { + var shadows = [], + i, + shadow, + element = this.element, + strokeWidth, + shadowWidth, + shadowElementOpacity, + + // compensate for inverted plot area + transform; + + + if (shadowOptions) { + shadowWidth = pick(shadowOptions.width, 3); + shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth; + transform = this.parentInverted ? + '(-1,-1)' : + '(' + pick(shadowOptions.offsetX, 1) + ', ' + pick(shadowOptions.offsetY, 1) + ')'; + for (i = 1; i <= shadowWidth; i++) { + shadow = element.cloneNode(0); + strokeWidth = (shadowWidth * 2) + 1 - (2 * i); + attr(shadow, { + 'isShadow': 'true', + 'stroke': shadowOptions.color || 'black', + 'stroke-opacity': shadowElementOpacity * i, + 'stroke-width': strokeWidth, + 'transform': 'translate' + transform, + 'fill': NONE + }); + if (cutOff) { + attr(shadow, 'height', mathMax(attr(shadow, 'height') - strokeWidth, 0)); + shadow.cutHeight = strokeWidth; + } + + if (group) { + group.element.appendChild(shadow); + } else { + element.parentNode.insertBefore(shadow, element); + } + + shadows.push(shadow); + } + + this.shadows = shadows; + } + return this; + + }, + + xGetter: function (key) { + if (this.element.nodeName === 'circle') { + key = { x: 'cx', y: 'cy' }[key] || key; + } + return this._defaultGetter(key); + }, + + /** + * Get the current value of an attribute or pseudo attribute, used mainly + * for animation. + */ + _defaultGetter: function (key) { + var ret = pick(this[key], this.element ? this.element.getAttribute(key) : null, 0); + + if (/^[\-0-9\.]+$/.test(ret)) { // is numerical + ret = parseFloat(ret); + } + return ret; + }, + + + dSetter: function (value, key, element) { + if (value && value.join) { // join path + value = value.join(' '); + } + if (/(NaN| {2}|^$)/.test(value)) { + value = 'M 0 0'; + } + element.setAttribute(key, value); + + this[key] = value; + }, + dashstyleSetter: function (value) { + var i; + value = value && value.toLowerCase(); + if (value) { + value = value + .replace('shortdashdotdot', '3,1,1,1,1,1,') + .replace('shortdashdot', '3,1,1,1') + .replace('shortdot', '1,1,') + .replace('shortdash', '3,1,') + .replace('longdash', '8,3,') + .replace(/dot/g, '1,3,') + .replace('dash', '4,3,') + .replace(/,$/, '') + .split(','); // ending comma + + i = value.length; + while (i--) { + value[i] = pInt(value[i]) * this['stroke-width']; + } + value = value.join(',') + .replace('NaN', 'none'); // #3226 + this.element.setAttribute('stroke-dasharray', value); + } + }, + alignSetter: function (value) { + this.element.setAttribute('text-anchor', { left: 'start', center: 'middle', right: 'end' }[value]); + }, + opacitySetter: function (value, key, element) { + this[key] = value; + element.setAttribute(key, value); + }, + titleSetter: function (value) { + var titleNode = this.element.getElementsByTagName('title')[0]; + if (!titleNode) { + titleNode = doc.createElementNS(SVG_NS, 'title'); + this.element.appendChild(titleNode); + } + titleNode.textContent = pick(value, '').replace(/<[^>]*>/g, ''); // #3276 + }, + textSetter: function (value) { + if (value !== this.textStr) { + // Delete bBox memo when the text changes + delete this.bBox; + + this.textStr = value; + if (this.added) { + this.renderer.buildText(this); + } + } + }, + fillSetter: function (value, key, element) { + if (typeof value === 'string') { + element.setAttribute(key, value); + } else if (value) { + this.colorGradient(value, key, element); + } + }, + zIndexSetter: function (value, key, element) { + element.setAttribute(key, value); + this[key] = value; + }, + _defaultSetter: function (value, key, element) { + element.setAttribute(key, value); + } +}; + +// Some shared setters and getters +SVGElement.prototype.yGetter = SVGElement.prototype.xGetter; +SVGElement.prototype.translateXSetter = SVGElement.prototype.translateYSetter = + SVGElement.prototype.rotationSetter = SVGElement.prototype.verticalAlignSetter = + SVGElement.prototype.scaleXSetter = SVGElement.prototype.scaleYSetter = function (value, key) { + this[key] = value; + this.doTransform = true; +}; + +// WebKit and Batik have problems with a stroke-width of zero, so in this case we remove the +// stroke attribute altogether. #1270, #1369, #3065, #3072. +SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter = function (value, key, element) { + this[key] = value; + // Only apply the stroke attribute if the stroke width is defined and larger than 0 + if (this.stroke && this['stroke-width']) { + this.strokeWidth = this['stroke-width']; + SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element); // use prototype as instance may be overridden + element.setAttribute('stroke-width', this['stroke-width']); + this.hasStroke = true; + } else if (key === 'stroke-width' && value === 0 && this.hasStroke) { + element.removeAttribute('stroke'); + this.hasStroke = false; + } +}; + + +/** + * The default SVG renderer + */ +var SVGRenderer = function () { + this.init.apply(this, arguments); +}; +SVGRenderer.prototype = { + Element: SVGElement, + + /** + * Initialize the SVGRenderer + * @param {Object} container + * @param {Number} width + * @param {Number} height + * @param {Boolean} forExport + */ + init: function (container, width, height, style, forExport) { + var renderer = this, + loc = location, + boxWrapper, + element, + desc; + + boxWrapper = renderer.createElement('svg') + .attr({ + version: '1.1' + }) + .css(this.getStyle(style)); + element = boxWrapper.element; + container.appendChild(element); + + // For browsers other than IE, add the namespace attribute (#1978) + if (container.innerHTML.indexOf('xmlns') === -1) { + attr(element, 'xmlns', SVG_NS); + } + + // object properties + renderer.isSVG = true; + renderer.box = element; + renderer.boxWrapper = boxWrapper; + renderer.alignedObjects = []; + + // Page url used for internal references. #24, #672, #1070 + renderer.url = (isFirefox || isWebKit) && doc.getElementsByTagName('base').length ? + loc.href + .replace(/#.*?$/, '') // remove the hash + .replace(/([\('\)])/g, '\\$1') // escape parantheses and quotes + .replace(/ /g, '%20') : // replace spaces (needed for Safari only) + ''; + + // Add description + desc = this.createElement('desc').add(); + desc.element.appendChild(doc.createTextNode('Created with ' + PRODUCT + ' ' + VERSION)); + + + renderer.defs = this.createElement('defs').add(); + renderer.forExport = forExport; + renderer.gradients = {}; // Object where gradient SvgElements are stored + renderer.cache = {}; // Cache for numerical bounding boxes + + renderer.setSize(width, height, false); + + + + // Issue 110 workaround: + // In Firefox, if a div is positioned by percentage, its pixel position may land + // between pixels. The container itself doesn't display this, but an SVG element + // inside this container will be drawn at subpixel precision. In order to draw + // sharp lines, this must be compensated for. This doesn't seem to work inside + // iframes though (like in jsFiddle). + var subPixelFix, rect; + if (isFirefox && container.getBoundingClientRect) { + renderer.subPixelFix = subPixelFix = function () { + css(container, { left: 0, top: 0 }); + rect = container.getBoundingClientRect(); + css(container, { + left: (mathCeil(rect.left) - rect.left) + PX, + top: (mathCeil(rect.top) - rect.top) + PX + }); + }; + + // run the fix now + subPixelFix(); + + // run it on resize + addEvent(win, 'resize', subPixelFix); + } + }, + + getStyle: function (style) { + return (this.style = extend({ + fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif', // default font + fontSize: '12px' + }, style)); + }, + + /** + * Detect whether the renderer is hidden. This happens when one of the parent elements + * has display: none. #608. + */ + isHidden: function () { + return !this.boxWrapper.getBBox().width; + }, + + /** + * Destroys the renderer and its allocated members. + */ + destroy: function () { + var renderer = this, + rendererDefs = renderer.defs; + renderer.box = null; + renderer.boxWrapper = renderer.boxWrapper.destroy(); + + // Call destroy on all gradient elements + destroyObjectProperties(renderer.gradients || {}); + renderer.gradients = null; + + // Defs are null in VMLRenderer + // Otherwise, destroy them here. + if (rendererDefs) { + renderer.defs = rendererDefs.destroy(); + } + + // Remove sub pixel fix handler + // We need to check that there is a handler, otherwise all functions that are registered for event 'resize' are removed + // See issue #982 + if (renderer.subPixelFix) { + removeEvent(win, 'resize', renderer.subPixelFix); + } + + renderer.alignedObjects = null; + + return null; + }, + + /** + * Create a wrapper for an SVG element + * @param {Object} nodeName + */ + createElement: function (nodeName) { + var wrapper = new this.Element(); + wrapper.init(this, nodeName); + return wrapper; + }, + + /** + * Dummy function for use in canvas renderer + */ + draw: function () {}, + + /** + * Parse a simple HTML string into SVG tspans + * + * @param {Object} textNode The parent text SVG node + */ + buildText: function (wrapper) { + var textNode = wrapper.element, + renderer = this, + forExport = renderer.forExport, + textStr = pick(wrapper.textStr, '').toString(), + hasMarkup = textStr.indexOf('<') !== -1, + lines, + childNodes = textNode.childNodes, + styleRegex, + hrefRegex, + parentX = attr(textNode, 'x'), + textStyles = wrapper.styles, + width = wrapper.textWidth, + textLineHeight = textStyles && textStyles.lineHeight, + textStroke = textStyles && textStyles.HcTextStroke, + i = childNodes.length, + getLineHeight = function (tspan) { + return textLineHeight ? + pInt(textLineHeight) : + renderer.fontMetrics( + /(px|em)$/.test(tspan && tspan.style.fontSize) ? + tspan.style.fontSize : + ((textStyles && textStyles.fontSize) || renderer.style.fontSize || 12), + tspan + ).h; + }; + + /// remove old text + while (i--) { + textNode.removeChild(childNodes[i]); + } + + // Skip tspans, add text directly to text node. The forceTSpan is a hook + // used in text outline hack. + if (!hasMarkup && !textStroke && textStr.indexOf(' ') === -1) { + textNode.appendChild(doc.createTextNode(textStr)); + return; + + // Complex strings, add more logic + } else { + + styleRegex = /<.*style="([^"]+)".*>/; + hrefRegex = /<.*href="(http[^"]+)".*>/; + + if (width && !wrapper.added) { + this.box.appendChild(textNode); // attach it to the DOM to read offset width + } + + if (hasMarkup) { + lines = textStr + .replace(/<(b|strong)>/g, '<span style="font-weight:bold">') + .replace(/<(i|em)>/g, '<span style="font-style:italic">') + .replace(/<a/g, '<span') + .replace(/<\/(b|strong|i|em|a)>/g, '</span>') + .split(/<br.*?>/g); + + } else { + lines = [textStr]; + } + + + // remove empty line at end + if (lines[lines.length - 1] === '') { + lines.pop(); + } + + + // build the lines + each(lines, function (line, lineNo) { + var spans, spanNo = 0; + + line = line.replace(/<span/g, '|||<span').replace(/<\/span>/g, '</span>|||'); + spans = line.split('|||'); + + each(spans, function (span) { + if (span !== '' || spans.length === 1) { + var attributes = {}, + tspan = doc.createElementNS(SVG_NS, 'tspan'), + spanStyle; // #390 + if (styleRegex.test(span)) { + spanStyle = span.match(styleRegex)[1].replace(/(;| |^)color([ :])/, '$1fill$2'); + attr(tspan, 'style', spanStyle); + } + if (hrefRegex.test(span) && !forExport) { // Not for export - #1529 + attr(tspan, 'onclick', 'location.href=\"' + span.match(hrefRegex)[1] + '\"'); + css(tspan, { cursor: 'pointer' }); + } + + span = (span.replace(/<(.|\n)*?>/g, '') || ' ') + .replace(/</g, '<') + .replace(/>/g, '>'); + + // Nested tags aren't supported, and cause crash in Safari (#1596) + if (span !== ' ') { + + // add the text node + tspan.appendChild(doc.createTextNode(span)); + + if (!spanNo) { // first span in a line, align it to the left + if (lineNo && parentX !== null) { + attributes.x = parentX; + } + } else { + attributes.dx = 0; // #16 + } + + // add attributes + attr(tspan, attributes); + + // Append it + textNode.appendChild(tspan); + + // first span on subsequent line, add the line height + if (!spanNo && lineNo) { + + // allow getting the right offset height in exporting in IE + if (!hasSVG && forExport) { + css(tspan, { display: 'block' }); + } + + // Set the line height based on the font size of either + // the text element or the tspan element + attr( + tspan, + 'dy', + getLineHeight(tspan) + ); + } + + // check width and apply soft breaks + if (width) { + var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273 + hasWhiteSpace = spans.length > 1 || (words.length > 1 && textStyles.whiteSpace !== 'nowrap'), + tooLong, + actualWidth, + hcHeight = textStyles.HcHeight, + rest = [], + dy = getLineHeight(tspan), + softLineNo = 1, + bBox; + + while (hasWhiteSpace && (words.length || rest.length)) { + delete wrapper.bBox; // delete cache + bBox = wrapper.getBBox(); + actualWidth = bBox.width; + + // Old IE cannot measure the actualWidth for SVG elements (#2314) + if (!hasSVG && renderer.forExport) { + actualWidth = renderer.measureSpanWidth(tspan.firstChild.data, wrapper.styles); + } + + tooLong = actualWidth > width; + if (!tooLong || words.length === 1) { // new line needed + words = rest; + rest = []; + if (words.length) { + softLineNo++; + if (hcHeight && softLineNo * dy > hcHeight) { + words = ['...']; + wrapper.attr('title', wrapper.textStr); + } else { + + tspan = doc.createElementNS(SVG_NS, 'tspan'); + attr(tspan, { + dy: dy, + x: parentX + }); + if (spanStyle) { // #390 + attr(tspan, 'style', spanStyle); + } + textNode.appendChild(tspan); + } + } + if (actualWidth > width) { // a single word is pressing it out + width = actualWidth; + } + } else { // append to existing line tspan + tspan.removeChild(tspan.firstChild); + rest.unshift(words.pop()); + } + if (words.length) { + tspan.appendChild(doc.createTextNode(words.join(' ').replace(/- /g, '-'))); + } + } + } + + spanNo++; + } + } + }); + }); + } + }, + + /** + * Create a button with preset states + * @param {String} text + * @param {Number} x + * @param {Number} y + * @param {Function} callback + * @param {Object} normalState + * @param {Object} hoverState + * @param {Object} pressedState + */ + button: function (text, x, y, callback, normalState, hoverState, pressedState, disabledState, shape) { + var label = this.label(text, x, y, shape, null, null, null, null, 'button'), + curState = 0, + stateOptions, + stateStyle, + normalStyle, + hoverStyle, + pressedStyle, + disabledStyle, + verticalGradient = { x1: 0, y1: 0, x2: 0, y2: 1 }; + + // Normal state - prepare the attributes + normalState = merge({ + 'stroke-width': 1, + stroke: '#CCCCCC', + fill: { + linearGradient: verticalGradient, + stops: [ + [0, '#FEFEFE'], + [1, '#F6F6F6'] + ] + }, + r: 2, + padding: 5, + style: { + color: 'black' + } + }, normalState); + normalStyle = normalState.style; + delete normalState.style; + + // Hover state + hoverState = merge(normalState, { + stroke: '#68A', + fill: { + linearGradient: verticalGradient, + stops: [ + [0, '#FFF'], + [1, '#ACF'] + ] + } + }, hoverState); + hoverStyle = hoverState.style; + delete hoverState.style; + + // Pressed state + pressedState = merge(normalState, { + stroke: '#68A', + fill: { + linearGradient: verticalGradient, + stops: [ + [0, '#9BD'], + [1, '#CDF'] + ] + } + }, pressedState); + pressedStyle = pressedState.style; + delete pressedState.style; + + // Disabled state + disabledState = merge(normalState, { + style: { + color: '#CCC' + } + }, disabledState); + disabledStyle = disabledState.style; + delete disabledState.style; + + // Add the events. IE9 and IE10 need mouseover and mouseout to funciton (#667). + addEvent(label.element, isIE ? 'mouseover' : 'mouseenter', function () { + if (curState !== 3) { + label.attr(hoverState) + .css(hoverStyle); + } + }); + addEvent(label.element, isIE ? 'mouseout' : 'mouseleave', function () { + if (curState !== 3) { + stateOptions = [normalState, hoverState, pressedState][curState]; + stateStyle = [normalStyle, hoverStyle, pressedStyle][curState]; + label.attr(stateOptions) + .css(stateStyle); + } + }); + + label.setState = function (state) { + label.state = curState = state; + if (!state) { + label.attr(normalState) + .css(normalStyle); + } else if (state === 2) { + label.attr(pressedState) + .css(pressedStyle); + } else if (state === 3) { + label.attr(disabledState) + .css(disabledStyle); + } + }; + + return label + .on('click', function () { + if (curState !== 3) { + callback.call(label); + } + }) + .attr(normalState) + .css(extend({ cursor: 'default' }, normalStyle)); + }, + + /** + * Make a straight line crisper by not spilling out to neighbour pixels + * @param {Array} points + * @param {Number} width + */ + crispLine: function (points, width) { + // points format: [M, 0, 0, L, 100, 0] + // normalize to a crisp line + if (points[1] === points[4]) { + // Substract due to #1129. Now bottom and left axis gridlines behave the same. + points[1] = points[4] = mathRound(points[1]) - (width % 2 / 2); + } + if (points[2] === points[5]) { + points[2] = points[5] = mathRound(points[2]) + (width % 2 / 2); + } + return points; + }, + + + /** + * Draw a path + * @param {Array} path An SVG path in array form + */ + path: function (path) { + var attr = { + fill: NONE + }; + if (isArray(path)) { + attr.d = path; + } else if (isObject(path)) { // attributes + extend(attr, path); + } + return this.createElement('path').attr(attr); + }, + + /** + * Draw and return an SVG circle + * @param {Number} x The x position + * @param {Number} y The y position + * @param {Number} r The radius + */ + circle: function (x, y, r) { + var attr = isObject(x) ? + x : + { + x: x, + y: y, + r: r + }, + wrapper = this.createElement('circle'); + + wrapper.xSetter = function (value) { + this.element.setAttribute('cx', value); + }; + wrapper.ySetter = function (value) { + this.element.setAttribute('cy', value); + }; + return wrapper.attr(attr); + }, + + /** + * Draw and return an arc + * @param {Number} x X position + * @param {Number} y Y position + * @param {Number} r Radius + * @param {Number} innerR Inner radius like used in donut charts + * @param {Number} start Starting angle + * @param {Number} end Ending angle + */ + arc: function (x, y, r, innerR, start, end) { + var arc; + + if (isObject(x)) { + y = x.y; + r = x.r; + innerR = x.innerR; + start = x.start; + end = x.end; + x = x.x; + } + + // Arcs are defined as symbols for the ability to set + // attributes in attr and animate + arc = this.symbol('arc', x || 0, y || 0, r || 0, r || 0, { + innerR: innerR || 0, + start: start || 0, + end: end || 0 + }); + arc.r = r; // #959 + return arc; + }, + + /** + * Draw and return a rectangle + * @param {Number} x Left position + * @param {Number} y Top position + * @param {Number} width + * @param {Number} height + * @param {Number} r Border corner radius + * @param {Number} strokeWidth A stroke width can be supplied to allow crisp drawing + */ + rect: function (x, y, width, height, r, strokeWidth) { + + r = isObject(x) ? x.r : r; + + var wrapper = this.createElement('rect'), + attribs = isObject(x) ? x : x === UNDEFINED ? {} : { + x: x, + y: y, + width: mathMax(width, 0), + height: mathMax(height, 0) + }; + + if (strokeWidth !== UNDEFINED) { + attribs.strokeWidth = strokeWidth; + attribs = wrapper.crisp(attribs); + } + + if (r) { + attribs.r = r; + } + + wrapper.rSetter = function (value) { + attr(this.element, { + rx: value, + ry: value + }); + }; + + return wrapper.attr(attribs); + }, + + /** + * Resize the box and re-align all aligned elements + * @param {Object} width + * @param {Object} height + * @param {Boolean} animate + * + */ + setSize: function (width, height, animate) { + var renderer = this, + alignedObjects = renderer.alignedObjects, + i = alignedObjects.length; + + renderer.width = width; + renderer.height = height; + + renderer.boxWrapper[pick(animate, true) ? 'animate' : 'attr']({ + width: width, + height: height + }); + + while (i--) { + alignedObjects[i].align(); + } + }, + + /** + * Create a group + * @param {String} name The group will be given a class name of 'highcharts-{name}'. + * This can be used for styling and scripting. + */ + g: function (name) { + var elem = this.createElement('g'); + return defined(name) ? elem.attr({ 'class': PREFIX + name }) : elem; + }, + + /** + * Display an image + * @param {String} src + * @param {Number} x + * @param {Number} y + * @param {Number} width + * @param {Number} height + */ + image: function (src, x, y, width, height) { + var attribs = { + preserveAspectRatio: NONE + }, + elemWrapper; + + // optional properties + if (arguments.length > 1) { + extend(attribs, { + x: x, + y: y, + width: width, + height: height + }); + } + + elemWrapper = this.createElement('image').attr(attribs); + + // set the href in the xlink namespace + if (elemWrapper.element.setAttributeNS) { + elemWrapper.element.setAttributeNS('http://www.w3.org/1999/xlink', + 'href', src); + } else { + // could be exporting in IE + // using href throws "not supported" in ie7 and under, requries regex shim to fix later + elemWrapper.element.setAttribute('hc-svg-href', src); + } + return elemWrapper; + }, + + /** + * Draw a symbol out of pre-defined shape paths from the namespace 'symbol' object. + * + * @param {Object} symbol + * @param {Object} x + * @param {Object} y + * @param {Object} radius + * @param {Object} options + */ + symbol: function (symbol, x, y, width, height, options) { + + var obj, + + // get the symbol definition function + symbolFn = this.symbols[symbol], + + // check if there's a path defined for this symbol + path = symbolFn && symbolFn( + mathRound(x), + mathRound(y), + width, + height, + options + ), + + imageElement, + imageRegex = /^url\((.*?)\)$/, + imageSrc, + imageSize, + centerImage; + + if (path) { + + obj = this.path(path); + // expando properties for use in animate and attr + extend(obj, { + symbolName: symbol, + x: x, + y: y, + width: width, + height: height + }); + if (options) { + extend(obj, options); + } + + + // image symbols + } else if (imageRegex.test(symbol)) { + + // On image load, set the size and position + centerImage = function (img, size) { + if (img.element) { // it may be destroyed in the meantime (#1390) + img.attr({ + width: size[0], + height: size[1] + }); + + if (!img.alignByTranslate) { // #185 + img.translate( + mathRound((width - size[0]) / 2), // #1378 + mathRound((height - size[1]) / 2) + ); + } + } + }; + + imageSrc = symbol.match(imageRegex)[1]; + imageSize = symbolSizes[imageSrc] || (options && options.width && options.height && [options.width, options.height]); + + // Ireate the image synchronously, add attribs async + obj = this.image(imageSrc) + .attr({ + x: x, + y: y + }); + obj.isImg = true; + + if (imageSize) { + centerImage(obj, imageSize); + } else { + // Initialize image to be 0 size so export will still function if there's no cached sizes. + obj.attr({ width: 0, height: 0 }); + + // Create a dummy JavaScript image to get the width and height. Due to a bug in IE < 8, + // the created element must be assigned to a variable in order to load (#292). + imageElement = createElement('img', { + onload: function () { + centerImage(obj, symbolSizes[imageSrc] = [this.width, this.height]); + }, + src: imageSrc + }); + } + } + + return obj; + }, + + /** + * An extendable collection of functions for defining symbol paths. + */ + symbols: { + 'circle': function (x, y, w, h) { + var cpw = 0.166 * w; + return [ + M, x + w / 2, y, + 'C', x + w + cpw, y, x + w + cpw, y + h, x + w / 2, y + h, + 'C', x - cpw, y + h, x - cpw, y, x + w / 2, y, + 'Z' + ]; + }, + + 'square': function (x, y, w, h) { + return [ + M, x, y, + L, x + w, y, + x + w, y + h, + x, y + h, + 'Z' + ]; + }, + + 'triangle': function (x, y, w, h) { + return [ + M, x + w / 2, y, + L, x + w, y + h, + x, y + h, + 'Z' + ]; + }, + + 'triangle-down': function (x, y, w, h) { + return [ + M, x, y, + L, x + w, y, + x + w / 2, y + h, + 'Z' + ]; + }, + 'diamond': function (x, y, w, h) { + return [ + M, x + w / 2, y, + L, x + w, y + h / 2, + x + w / 2, y + h, + x, y + h / 2, + 'Z' + ]; + }, + 'arc': function (x, y, w, h, options) { + var start = options.start, + radius = options.r || w || h, + end = options.end - 0.001, // to prevent cos and sin of start and end from becoming equal on 360 arcs (related: #1561) + innerRadius = options.innerR, + open = options.open, + cosStart = mathCos(start), + sinStart = mathSin(start), + cosEnd = mathCos(end), + sinEnd = mathSin(end), + longArc = options.end - start < mathPI ? 0 : 1; + + return [ + M, + x + radius * cosStart, + y + radius * sinStart, + 'A', // arcTo + radius, // x radius + radius, // y radius + 0, // slanting + longArc, // long or short arc + 1, // clockwise + x + radius * cosEnd, + y + radius * sinEnd, + open ? M : L, + x + innerRadius * cosEnd, + y + innerRadius * sinEnd, + 'A', // arcTo + innerRadius, // x radius + innerRadius, // y radius + 0, // slanting + longArc, // long or short arc + 0, // clockwise + x + innerRadius * cosStart, + y + innerRadius * sinStart, + + open ? '' : 'Z' // close + ]; + }, + + /** + * Callout shape used for default tooltips, also used for rounded rectangles in VML + */ + callout: function (x, y, w, h, options) { + var arrowLength = 6, + halfDistance = 6, + r = mathMin((options && options.r) || 0, w, h), + safeDistance = r + halfDistance, + anchorX = options && options.anchorX, + anchorY = options && options.anchorY, + path, + normalizer = mathRound(options.strokeWidth || 0) % 2 / 2; // mathRound because strokeWidth can sometimes have roundoff errors; + + x += normalizer; + y += normalizer; + path = [ + 'M', x + r, y, + 'L', x + w - r, y, // top side + 'C', x + w, y, x + w, y, x + w, y + r, // top-right corner + 'L', x + w, y + h - r, // right side + 'C', x + w, y + h, x + w, y + h, x + w - r, y + h, // bottom-right corner + 'L', x + r, y + h, // bottom side + 'C', x, y + h, x, y + h, x, y + h - r, // bottom-left corner + 'L', x, y + r, // left side + 'C', x, y, x, y, x + r, y // top-right corner + ]; + + if (anchorX && anchorX > w && anchorY > y + safeDistance && anchorY < y + h - safeDistance) { // replace right side + path.splice(13, 3, + 'L', x + w, anchorY - halfDistance, + x + w + arrowLength, anchorY, + x + w, anchorY + halfDistance, + x + w, y + h - r + ); + } else if (anchorX && anchorX < 0 && anchorY > y + safeDistance && anchorY < y + h - safeDistance) { // replace left side + path.splice(33, 3, + 'L', x, anchorY + halfDistance, + x - arrowLength, anchorY, + x, anchorY - halfDistance, + x, y + r + ); + } else if (anchorY && anchorY > h && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace bottom + path.splice(23, 3, + 'L', anchorX + halfDistance, y + h, + anchorX, y + h + arrowLength, + anchorX - halfDistance, y + h, + x + r, y + h + ); + } else if (anchorY && anchorY < 0 && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace top + path.splice(3, 3, + 'L', anchorX - halfDistance, y, + anchorX, y - arrowLength, + anchorX + halfDistance, y, + w - r, y + ); + } + return path; + } + }, + + /** + * Define a clipping rectangle + * @param {String} id + * @param {Number} x + * @param {Number} y + * @param {Number} width + * @param {Number} height + */ + clipRect: function (x, y, width, height) { + var wrapper, + id = PREFIX + idCounter++, + + clipPath = this.createElement('clipPath').attr({ + id: id + }).add(this.defs); + + wrapper = this.rect(x, y, width, height, 0).add(clipPath); + wrapper.id = id; + wrapper.clipPath = clipPath; + + return wrapper; + }, + + + + + + /** + * Add text to the SVG object + * @param {String} str + * @param {Number} x Left position + * @param {Number} y Top position + * @param {Boolean} useHTML Use HTML to render the text + */ + text: function (str, x, y, useHTML) { + + // declare variables + var renderer = this, + fakeSVG = useCanVG || (!hasSVG && renderer.forExport), + wrapper, + attr = {}; + + if (useHTML && !renderer.forExport) { + return renderer.html(str, x, y); + } + + attr.x = Math.round(x || 0); // X is always needed for line-wrap logic + if (y) { + attr.y = Math.round(y); + } + if (str || str === 0) { + attr.text = str; + } + + wrapper = renderer.createElement('text') + .attr(attr); + + // Prevent wrapping from creating false offsetWidths in export in legacy IE (#1079, #1063) + if (fakeSVG) { + wrapper.css({ + position: ABSOLUTE + }); + } + + if (!useHTML) { + wrapper.xSetter = function (value, key, element) { + var tspans = element.getElementsByTagName('tspan'), + tspan, + parentVal = element.getAttribute(key), + i; + for (i = 0; i < tspans.length; i++) { + tspan = tspans[i]; + // If the x values are equal, the tspan represents a linebreak + if (tspan.getAttribute(key) === parentVal) { + tspan.setAttribute(key, value); + } + } + element.setAttribute(key, value); + }; + } + + return wrapper; + }, + + /** + * Utility to return the baseline offset and total line height from the font size + */ + fontMetrics: function (fontSize, elem) { + fontSize = fontSize || this.style.fontSize; + if (elem && win.getComputedStyle) { + elem = elem.element || elem; // SVGElement + fontSize = win.getComputedStyle(elem, "").fontSize; + } + fontSize = /px/.test(fontSize) ? pInt(fontSize) : /em/.test(fontSize) ? parseFloat(fontSize) * 12 : 12; + + // Empirical values found by comparing font size and bounding box height. + // Applies to the default font family. http://jsfiddle.net/highcharts/7xvn7/ + var lineHeight = fontSize < 24 ? fontSize + 4 : mathRound(fontSize * 1.2), + baseline = mathRound(lineHeight * 0.8); + + return { + h: lineHeight, + b: baseline, + f: fontSize + }; + }, + + /** + * Add a label, a text item that can hold a colored or gradient background + * as well as a border and shadow. + * @param {string} str + * @param {Number} x + * @param {Number} y + * @param {String} shape + * @param {Number} anchorX In case the shape has a pointer, like a flag, this is the + * coordinates it should be pinned to + * @param {Number} anchorY + * @param {Boolean} baseline Whether to position the label relative to the text baseline, + * like renderer.text, or to the upper border of the rectangle. + * @param {String} className Class name for the group + */ + label: function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) { + + var renderer = this, + wrapper = renderer.g(className), + text = renderer.text('', 0, 0, useHTML) + .attr({ + zIndex: 1 + }), + //.add(wrapper), + box, + bBox, + alignFactor = 0, + padding = 3, + paddingLeft = 0, + width, + height, + wrapperX, + wrapperY, + crispAdjust = 0, + deferredAttr = {}, + baselineOffset, + needsBox; + + /** + * This function runs after the label is added to the DOM (when the bounding box is + * available), and after the text of the label is updated to detect the new bounding + * box and reflect it in the border box. + */ + function updateBoxSize() { + var boxX, + boxY, + style = text.element.style; + + bBox = (width === undefined || height === undefined || wrapper.styles.textAlign) && text.textStr && + text.getBBox(); + wrapper.width = (width || bBox.width || 0) + 2 * padding + paddingLeft; + wrapper.height = (height || bBox.height || 0) + 2 * padding; + + // update the label-scoped y offset + baselineOffset = padding + renderer.fontMetrics(style && style.fontSize, text).b; + + + if (needsBox) { + + // create the border box if it is not already present + if (!box) { + boxX = mathRound(-alignFactor * padding); + boxY = baseline ? -baselineOffset : 0; + + wrapper.box = box = shape ? + renderer.symbol(shape, boxX, boxY, wrapper.width, wrapper.height, deferredAttr) : + renderer.rect(boxX, boxY, wrapper.width, wrapper.height, 0, deferredAttr[STROKE_WIDTH]); + box.attr('fill', NONE).add(wrapper); + } + + // apply the box attributes + if (!box.isImg) { // #1630 + box.attr(extend({ + width: mathRound(wrapper.width), + height: mathRound(wrapper.height) + }, deferredAttr)); + } + deferredAttr = null; + } + } + + /** + * This function runs after setting text or padding, but only if padding is changed + */ + function updateTextPadding() { + var styles = wrapper.styles, + textAlign = styles && styles.textAlign, + x = paddingLeft + padding * (1 - alignFactor), + y; + + // determin y based on the baseline + y = baseline ? 0 : baselineOffset; + + // compensate for alignment + if (defined(width) && bBox && (textAlign === 'center' || textAlign === 'right')) { + x += { center: 0.5, right: 1 }[textAlign] * (width - bBox.width); + } + + // update if anything changed + if (x !== text.x || y !== text.y) { + text.attr('x', x); + if (y !== UNDEFINED) { + text.attr('y', y); + } + } + + // record current values + text.x = x; + text.y = y; + } + + /** + * Set a box attribute, or defer it if the box is not yet created + * @param {Object} key + * @param {Object} value + */ + function boxAttr(key, value) { + if (box) { + box.attr(key, value); + } else { + deferredAttr[key] = value; + } + } + + /** + * After the text element is added, get the desired size of the border box + * and add it before the text in the DOM. + */ + wrapper.onAdd = function () { + text.add(wrapper); + wrapper.attr({ + text: (str || str === 0) ? str : '', // alignment is available now // #3295: 0 not rendered if given as a value + x: x, + y: y + }); + + if (box && defined(anchorX)) { + wrapper.attr({ + anchorX: anchorX, + anchorY: anchorY + }); + } + }; + + /* + * Add specific attribute setters. + */ + + // only change local variables + wrapper.widthSetter = function (value) { + width = value; + }; + wrapper.heightSetter = function (value) { + height = value; + }; + wrapper.paddingSetter = function (value) { + if (defined(value) && value !== padding) { + padding = value; + updateTextPadding(); + } + }; + wrapper.paddingLeftSetter = function (value) { + if (defined(value) && value !== paddingLeft) { + paddingLeft = value; + updateTextPadding(); + } + }; + + + // change local variable and prevent setting attribute on the group + wrapper.alignSetter = function (value) { + alignFactor = { left: 0, center: 0.5, right: 1 }[value]; + }; + + // apply these to the box and the text alike + wrapper.textSetter = function (value) { + if (value !== UNDEFINED) { + text.textSetter(value); + } + updateBoxSize(); + updateTextPadding(); + }; + + // apply these to the box but not to the text + wrapper['stroke-widthSetter'] = function (value, key) { + if (value) { + needsBox = true; + } + crispAdjust = value % 2 / 2; + boxAttr(key, value); + }; + wrapper.strokeSetter = wrapper.fillSetter = wrapper.rSetter = function (value, key) { + if (key === 'fill' && value) { + needsBox = true; + } + boxAttr(key, value); + }; + wrapper.anchorXSetter = function (value, key) { + anchorX = value; + boxAttr(key, value + crispAdjust - wrapperX); + }; + wrapper.anchorYSetter = function (value, key) { + anchorY = value; + boxAttr(key, value - wrapperY); + }; + + // rename attributes + wrapper.xSetter = function (value) { + wrapper.x = value; // for animation getter + if (alignFactor) { + value -= alignFactor * ((width || bBox.width) + padding); + } + wrapperX = mathRound(value); + wrapper.attr('translateX', wrapperX); + }; + wrapper.ySetter = function (value) { + wrapperY = wrapper.y = mathRound(value); + wrapper.attr('translateY', wrapperY); + }; + + // Redirect certain methods to either the box or the text + var baseCss = wrapper.css; + return extend(wrapper, { + /** + * Pick up some properties and apply them to the text instead of the wrapper + */ + css: function (styles) { + if (styles) { + var textStyles = {}; + styles = merge(styles); // create a copy to avoid altering the original object (#537) + each(wrapper.textProps, function (prop) { + if (styles[prop] !== UNDEFINED) { + textStyles[prop] = styles[prop]; + delete styles[prop]; + } + }); + text.css(textStyles); + } + return baseCss.call(wrapper, styles); + }, + /** + * Return the bounding box of the box, not the group + */ + getBBox: function () { + return { + width: bBox.width + 2 * padding, + height: bBox.height + 2 * padding, + x: bBox.x - padding, + y: bBox.y - padding + }; + }, + /** + * Apply the shadow to the box + */ + shadow: function (b) { + if (box) { + box.shadow(b); + } + return wrapper; + }, + /** + * Destroy and release memory. + */ + destroy: function () { + + // Added by button implementation + removeEvent(wrapper.element, 'mouseenter'); + removeEvent(wrapper.element, 'mouseleave'); + + if (text) { + text = text.destroy(); + } + if (box) { + box = box.destroy(); + } + // Call base implementation to destroy the rest + SVGElement.prototype.destroy.call(wrapper); + + // Release local pointers (#1298) + wrapper = renderer = updateBoxSize = updateTextPadding = boxAttr = null; + } + }); + } +}; // end SVGRenderer + + +// general renderer +Renderer = SVGRenderer; +// extend SvgElement for useHTML option +extend(SVGElement.prototype, { + /** + * Apply CSS to HTML elements. This is used in text within SVG rendering and + * by the VML renderer + */ + htmlCss: function (styles) { + var wrapper = this, + element = wrapper.element, + textWidth = styles && element.tagName === 'SPAN' && styles.width; + + if (textWidth) { + delete styles.width; + wrapper.textWidth = textWidth; + wrapper.updateTransform(); + } + + wrapper.styles = extend(wrapper.styles, styles); + css(wrapper.element, styles); + + return wrapper; + }, + + /** + * VML and useHTML method for calculating the bounding box based on offsets + * @param {Boolean} refresh Whether to force a fresh value from the DOM or to + * use the cached value + * + * @return {Object} A hash containing values for x, y, width and height + */ + + htmlGetBBox: function () { + var wrapper = this, + element = wrapper.element, + bBox = wrapper.bBox; + + // faking getBBox in exported SVG in legacy IE + if (!bBox) { + // faking getBBox in exported SVG in legacy IE (is this a duplicate of the fix for #1079?) + if (element.nodeName === 'text') { + element.style.position = ABSOLUTE; + } + + bBox = wrapper.bBox = { + x: element.offsetLeft, + y: element.offsetTop, + width: element.offsetWidth, + height: element.offsetHeight + }; + } + + return bBox; + }, + + /** + * VML override private method to update elements based on internal + * properties based on SVG transform + */ + htmlUpdateTransform: function () { + // aligning non added elements is expensive + if (!this.added) { + this.alignOnAdd = true; + return; + } + + var wrapper = this, + renderer = wrapper.renderer, + elem = wrapper.element, + translateX = wrapper.translateX || 0, + translateY = wrapper.translateY || 0, + x = wrapper.x || 0, + y = wrapper.y || 0, + align = wrapper.textAlign || 'left', + alignCorrection = { left: 0, center: 0.5, right: 1 }[align], + shadows = wrapper.shadows; + + // apply translate + css(elem, { + marginLeft: translateX, + marginTop: translateY + }); + if (shadows) { // used in labels/tooltip + each(shadows, function (shadow) { + css(shadow, { + marginLeft: translateX + 1, + marginTop: translateY + 1 + }); + }); + } + + // apply inversion + if (wrapper.inverted) { // wrapper is a group + each(elem.childNodes, function (child) { + renderer.invertChild(child, elem); + }); + } + + if (elem.tagName === 'SPAN') { + + var width, + rotation = wrapper.rotation, + baseline, + textWidth = pInt(wrapper.textWidth), + currentTextTransform = [rotation, align, elem.innerHTML, wrapper.textWidth].join(','); + + if (currentTextTransform !== wrapper.cTT) { // do the calculations and DOM access only if properties changed + + + baseline = renderer.fontMetrics(elem.style.fontSize).b; + + // Renderer specific handling of span rotation + if (defined(rotation)) { + wrapper.setSpanRotation(rotation, alignCorrection, baseline); + } + + width = pick(wrapper.elemWidth, elem.offsetWidth); + + // Update textWidth + if (width > textWidth && /[ \-]/.test(elem.textContent || elem.innerText)) { // #983, #1254 + css(elem, { + width: textWidth + PX, + display: 'block', + whiteSpace: 'normal' + }); + width = textWidth; + } + + wrapper.getSpanCorrection(width, baseline, alignCorrection, rotation, align); + } + + // apply position with correction + css(elem, { + left: (x + (wrapper.xCorr || 0)) + PX, + top: (y + (wrapper.yCorr || 0)) + PX + }); + + // force reflow in webkit to apply the left and top on useHTML element (#1249) + if (isWebKit) { + baseline = elem.offsetHeight; // assigned to baseline for JSLint purpose + } + + // record current text transform + wrapper.cTT = currentTextTransform; + } + }, + + /** + * Set the rotation of an individual HTML span + */ + setSpanRotation: function (rotation, alignCorrection, baseline) { + var rotationStyle = {}, + cssTransformKey = isIE ? '-ms-transform' : isWebKit ? '-webkit-transform' : isFirefox ? 'MozTransform' : isOpera ? '-o-transform' : ''; + + rotationStyle[cssTransformKey] = rotationStyle.transform = 'rotate(' + rotation + 'deg)'; + rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin = (alignCorrection * 100) + '% ' + baseline + 'px'; + css(this.element, rotationStyle); + }, + + /** + * Get the correction in X and Y positioning as the element is rotated. + */ + getSpanCorrection: function (width, baseline, alignCorrection) { + this.xCorr = -width * alignCorrection; + this.yCorr = -baseline; + } +}); + +// Extend SvgRenderer for useHTML option. +extend(SVGRenderer.prototype, { + /** + * Create HTML text node. This is used by the VML renderer as well as the SVG + * renderer through the useHTML option. + * + * @param {String} str + * @param {Number} x + * @param {Number} y + */ + html: function (str, x, y) { + var wrapper = this.createElement('span'), + element = wrapper.element, + renderer = wrapper.renderer; + + // Text setter + wrapper.textSetter = function (value) { + if (value !== element.innerHTML) { + delete this.bBox; + } + element.innerHTML = this.textStr = value; + }; + + // Various setters which rely on update transform + wrapper.xSetter = wrapper.ySetter = wrapper.alignSetter = wrapper.rotationSetter = function (value, key) { + if (key === 'align') { + key = 'textAlign'; // Do not overwrite the SVGElement.align method. Same as VML. + } + wrapper[key] = value; + wrapper.htmlUpdateTransform(); + }; + + // Set the default attributes + wrapper.attr({ + text: str, + x: mathRound(x), + y: mathRound(y) + }) + .css({ + position: ABSOLUTE, + whiteSpace: 'nowrap', + fontFamily: this.style.fontFamily, + fontSize: this.style.fontSize + }); + + // Use the HTML specific .css method + wrapper.css = wrapper.htmlCss; + + // This is specific for HTML within SVG + if (renderer.isSVG) { + wrapper.add = function (svgGroupWrapper) { + + var htmlGroup, + container = renderer.box.parentNode, + parentGroup, + parents = []; + + this.parentGroup = svgGroupWrapper; + + // Create a mock group to hold the HTML elements + if (svgGroupWrapper) { + htmlGroup = svgGroupWrapper.div; + if (!htmlGroup) { + + // Read the parent chain into an array and read from top down + parentGroup = svgGroupWrapper; + while (parentGroup) { + + parents.push(parentGroup); + + // Move up to the next parent group + parentGroup = parentGroup.parentGroup; + } + + // Ensure dynamically updating position when any parent is translated + each(parents.reverse(), function (parentGroup) { + var htmlGroupStyle; + + // Create a HTML div and append it to the parent div to emulate + // the SVG group structure + htmlGroup = parentGroup.div = parentGroup.div || createElement(DIV, { + className: attr(parentGroup.element, 'class') + }, { + position: ABSOLUTE, + left: (parentGroup.translateX || 0) + PX, + top: (parentGroup.translateY || 0) + PX + }, htmlGroup || container); // the top group is appended to container + + // Shortcut + htmlGroupStyle = htmlGroup.style; + + // Set listeners to update the HTML div's position whenever the SVG group + // position is changed + extend(parentGroup, { + translateXSetter: function (value, key) { + htmlGroupStyle.left = value + PX; + parentGroup[key] = value; + parentGroup.doTransform = true; + }, + translateYSetter: function (value, key) { + htmlGroupStyle.top = value + PX; + parentGroup[key] = value; + parentGroup.doTransform = true; + }, + visibilitySetter: function (value, key) { + htmlGroupStyle[key] = value; + } + }); + }); + + } + } else { + htmlGroup = container; + } + + htmlGroup.appendChild(element); + + // Shared with VML: + wrapper.added = true; + if (wrapper.alignOnAdd) { + wrapper.htmlUpdateTransform(); + } + + return wrapper; + }; + } + return wrapper; + } +}); + +/* **************************************************************************** + * * + * START OF INTERNET EXPLORER <= 8 SPECIFIC CODE * + * * + * For applications and websites that don't need IE support, like platform * + * targeted mobile apps and web apps, this code can be removed. * + * * + *****************************************************************************/ + +/** + * @constructor + */ +var VMLRenderer, VMLElement; +if (!hasSVG && !useCanVG) { + +/** + * The VML element wrapper. + */ +VMLElement = { + + /** + * Initialize a new VML element wrapper. It builds the markup as a string + * to minimize DOM traffic. + * @param {Object} renderer + * @param {Object} nodeName + */ + init: function (renderer, nodeName) { + var wrapper = this, + markup = ['<', nodeName, ' filled="f" stroked="f"'], + style = ['position: ', ABSOLUTE, ';'], + isDiv = nodeName === DIV; + + // divs and shapes need size + if (nodeName === 'shape' || isDiv) { + style.push('left:0;top:0;width:1px;height:1px;'); + } + style.push('visibility: ', isDiv ? HIDDEN : VISIBLE); + + markup.push(' style="', style.join(''), '"/>'); + + // create element with default attributes and style + if (nodeName) { + markup = isDiv || nodeName === 'span' || nodeName === 'img' ? + markup.join('') + : renderer.prepVML(markup); + wrapper.element = createElement(markup); + } + + wrapper.renderer = renderer; + }, + + /** + * Add the node to the given parent + * @param {Object} parent + */ + add: function (parent) { + var wrapper = this, + renderer = wrapper.renderer, + element = wrapper.element, + box = renderer.box, + inverted = parent && parent.inverted, + + // get the parent node + parentNode = parent ? + parent.element || parent : + box; + + + // if the parent group is inverted, apply inversion on all children + if (inverted) { // only on groups + renderer.invertChild(element, parentNode); + } + + // append it + parentNode.appendChild(element); + + // align text after adding to be able to read offset + wrapper.added = true; + if (wrapper.alignOnAdd && !wrapper.deferUpdateTransform) { + wrapper.updateTransform(); + } + + // fire an event for internal hooks + if (wrapper.onAdd) { + wrapper.onAdd(); + } + + return wrapper; + }, + + /** + * VML always uses htmlUpdateTransform + */ + updateTransform: SVGElement.prototype.htmlUpdateTransform, + + /** + * Set the rotation of a span with oldIE's filter + */ + setSpanRotation: function () { + // Adjust for alignment and rotation. Rotation of useHTML content is not yet implemented + // but it can probably be implemented for Firefox 3.5+ on user request. FF3.5+ + // has support for CSS3 transform. The getBBox method also needs to be updated + // to compensate for the rotation, like it currently does for SVG. + // Test case: http://jsfiddle.net/highcharts/Ybt44/ + + var rotation = this.rotation, + costheta = mathCos(rotation * deg2rad), + sintheta = mathSin(rotation * deg2rad); + + css(this.element, { + filter: rotation ? ['progid:DXImageTransform.Microsoft.Matrix(M11=', costheta, + ', M12=', -sintheta, ', M21=', sintheta, ', M22=', costheta, + ', sizingMethod=\'auto expand\')'].join('') : NONE + }); + }, + + /** + * Get the positioning correction for the span after rotating. + */ + getSpanCorrection: function (width, baseline, alignCorrection, rotation, align) { + + var costheta = rotation ? mathCos(rotation * deg2rad) : 1, + sintheta = rotation ? mathSin(rotation * deg2rad) : 0, + height = pick(this.elemHeight, this.element.offsetHeight), + quad, + nonLeft = align && align !== 'left'; + + // correct x and y + this.xCorr = costheta < 0 && -width; + this.yCorr = sintheta < 0 && -height; + + // correct for baseline and corners spilling out after rotation + quad = costheta * sintheta < 0; + this.xCorr += sintheta * baseline * (quad ? 1 - alignCorrection : alignCorrection); + this.yCorr -= costheta * baseline * (rotation ? (quad ? alignCorrection : 1 - alignCorrection) : 1); + // correct for the length/height of the text + if (nonLeft) { + this.xCorr -= width * alignCorrection * (costheta < 0 ? -1 : 1); + if (rotation) { + this.yCorr -= height * alignCorrection * (sintheta < 0 ? -1 : 1); + } + css(this.element, { + textAlign: align + }); + } + }, + + /** + * Converts a subset of an SVG path definition to its VML counterpart. Takes an array + * as the parameter and returns a string. + */ + pathToVML: function (value) { + // convert paths + var i = value.length, + path = []; + + while (i--) { + + // Multiply by 10 to allow subpixel precision. + // Substracting half a pixel seems to make the coordinates + // align with SVG, but this hasn't been tested thoroughly + if (isNumber(value[i])) { + path[i] = mathRound(value[i] * 10) - 5; + } else if (value[i] === 'Z') { // close the path + path[i] = 'x'; + } else { + path[i] = value[i]; + + // When the start X and end X coordinates of an arc are too close, + // they are rounded to the same value above. In this case, substract or + // add 1 from the end X and Y positions. #186, #760, #1371, #1410. + if (value.isArc && (value[i] === 'wa' || value[i] === 'at')) { + // Start and end X + if (path[i + 5] === path[i + 7]) { + path[i + 7] += value[i + 7] > value[i + 5] ? 1 : -1; + } + // Start and end Y + if (path[i + 6] === path[i + 8]) { + path[i + 8] += value[i + 8] > value[i + 6] ? 1 : -1; + } + } + } + } + + + // Loop up again to handle path shortcuts (#2132) + /*while (i++ < path.length) { + if (path[i] === 'H') { // horizontal line to + path[i] = 'L'; + path.splice(i + 2, 0, path[i - 1]); + } else if (path[i] === 'V') { // vertical line to + path[i] = 'L'; + path.splice(i + 1, 0, path[i - 2]); + } + }*/ + return path.join(' ') || 'x'; + }, + + /** + * Set the element's clipping to a predefined rectangle + * + * @param {String} id The id of the clip rectangle + */ + clip: function (clipRect) { + var wrapper = this, + clipMembers, + cssRet; + + if (clipRect) { + clipMembers = clipRect.members; + erase(clipMembers, wrapper); // Ensure unique list of elements (#1258) + clipMembers.push(wrapper); + wrapper.destroyClip = function () { + erase(clipMembers, wrapper); + }; + cssRet = clipRect.getCSS(wrapper); + + } else { + if (wrapper.destroyClip) { + wrapper.destroyClip(); + } + cssRet = { clip: docMode8 ? 'inherit' : 'rect(auto)' }; // #1214 + } + + return wrapper.css(cssRet); + + }, + + /** + * Set styles for the element + * @param {Object} styles + */ + css: SVGElement.prototype.htmlCss, + + /** + * Removes a child either by removeChild or move to garbageBin. + * Issue 490; in VML removeChild results in Orphaned nodes according to sIEve, discardElement does not. + */ + safeRemoveChild: function (element) { + // discardElement will detach the node from its parent before attaching it + // to the garbage bin. Therefore it is important that the node is attached and have parent. + if (element.parentNode) { + discardElement(element); + } + }, + + /** + * Extend element.destroy by removing it from the clip members array + */ + destroy: function () { + if (this.destroyClip) { + this.destroyClip(); + } + + return SVGElement.prototype.destroy.apply(this); + }, + + /** + * Add an event listener. VML override for normalizing event parameters. + * @param {String} eventType + * @param {Function} handler + */ + on: function (eventType, handler) { + // simplest possible event model for internal use + this.element['on' + eventType] = function () { + var evt = win.event; + evt.target = evt.srcElement; + handler(evt); + }; + return this; + }, + + /** + * In stacked columns, cut off the shadows so that they don't overlap + */ + cutOffPath: function (path, length) { + + var len; + + path = path.split(/[ ,]/); + len = path.length; + + if (len === 9 || len === 11) { + path[len - 4] = path[len - 2] = pInt(path[len - 2]) - 10 * length; + } + return path.join(' '); + }, + + /** + * Apply a drop shadow by copying elements and giving them different strokes + * @param {Boolean|Object} shadowOptions + */ + shadow: function (shadowOptions, group, cutOff) { + var shadows = [], + i, + element = this.element, + renderer = this.renderer, + shadow, + elemStyle = element.style, + markup, + path = element.path, + strokeWidth, + modifiedPath, + shadowWidth, + shadowElementOpacity; + + // some times empty paths are not strings + if (path && typeof path.value !== 'string') { + path = 'x'; + } + modifiedPath = path; + + if (shadowOptions) { + shadowWidth = pick(shadowOptions.width, 3); + shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth; + for (i = 1; i <= 3; i++) { + + strokeWidth = (shadowWidth * 2) + 1 - (2 * i); + + // Cut off shadows for stacked column items + if (cutOff) { + modifiedPath = this.cutOffPath(path.value, strokeWidth + 0.5); + } + + markup = ['<shape isShadow="true" strokeweight="', strokeWidth, + '" filled="false" path="', modifiedPath, + '" coordsize="10 10" style="', element.style.cssText, '" />']; + + shadow = createElement(renderer.prepVML(markup), + null, { + left: pInt(elemStyle.left) + pick(shadowOptions.offsetX, 1), + top: pInt(elemStyle.top) + pick(shadowOptions.offsetY, 1) + } + ); + if (cutOff) { + shadow.cutOff = strokeWidth + 1; + } + + // apply the opacity + markup = ['<stroke color="', shadowOptions.color || 'black', '" opacity="', shadowElementOpacity * i, '"/>']; + createElement(renderer.prepVML(markup), null, null, shadow); + + + // insert it + if (group) { + group.element.appendChild(shadow); + } else { + element.parentNode.insertBefore(shadow, element); + } + + // record it + shadows.push(shadow); + + } + + this.shadows = shadows; + } + return this; + }, + updateShadows: noop, // Used in SVG only + + setAttr: function (key, value) { + if (docMode8) { // IE8 setAttribute bug + this.element[key] = value; + } else { + this.element.setAttribute(key, value); + } + }, + classSetter: function (value) { + // IE8 Standards mode has problems retrieving the className unless set like this + this.element.className = value; + }, + dashstyleSetter: function (value, key, element) { + var strokeElem = element.getElementsByTagName('stroke')[0] || + createElement(this.renderer.prepVML(['<stroke/>']), null, null, element); + strokeElem[key] = value || 'solid'; + this[key] = value; /* because changing stroke-width will change the dash length + and cause an epileptic effect */ + }, + dSetter: function (value, key, element) { + var i, + shadows = this.shadows; + value = value || []; + this.d = value.join && value.join(' '); // used in getter for animation + + element.path = value = this.pathToVML(value); + + // update shadows + if (shadows) { + i = shadows.length; + while (i--) { + shadows[i].path = shadows[i].cutOff ? this.cutOffPath(value, shadows[i].cutOff) : value; + } + } + this.setAttr(key, value); + }, + fillSetter: function (value, key, element) { + var nodeName = element.nodeName; + if (nodeName === 'SPAN') { // text color + element.style.color = value; + } else if (nodeName !== 'IMG') { // #1336 + element.filled = value !== NONE; + this.setAttr('fillcolor', this.renderer.color(value, element, key, this)); + } + }, + opacitySetter: noop, // Don't bother - animation is too slow and filters introduce artifacts + rotationSetter: function (value, key, element) { + var style = element.style; + this[key] = style[key] = value; // style is for #1873 + + // Correction for the 1x1 size of the shape container. Used in gauge needles. + style.left = -mathRound(mathSin(value * deg2rad) + 1) + PX; + style.top = mathRound(mathCos(value * deg2rad)) + PX; + }, + strokeSetter: function (value, key, element) { + this.setAttr('strokecolor', this.renderer.color(value, element, key)); + }, + 'stroke-widthSetter': function (value, key, element) { + element.stroked = !!value; // VML "stroked" attribute + this[key] = value; // used in getter, issue #113 + if (isNumber(value)) { + value += PX; + } + this.setAttr('strokeweight', value); + }, + titleSetter: function (value, key) { + this.setAttr(key, value); + }, + visibilitySetter: function (value, key, element) { + + // Handle inherited visibility + if (value === 'inherit') { + value = VISIBLE; + } + + // Let the shadow follow the main element + if (this.shadows) { + each(this.shadows, function (shadow) { + shadow.style[key] = value; + }); + } + + // Instead of toggling the visibility CSS property, move the div out of the viewport. + // This works around #61 and #586 + if (element.nodeName === 'DIV') { + value = value === HIDDEN ? '-999em' : 0; + + // In order to redraw, IE7 needs the div to be visible when tucked away + // outside the viewport. So the visibility is actually opposite of + // the expected value. This applies to the tooltip only. + if (!docMode8) { + element.style[key] = value ? VISIBLE : HIDDEN; + } + key = 'top'; + } + element.style[key] = value; + }, + xSetter: function (value, key, element) { + this[key] = value; // used in getter + + if (key === 'x') { + key = 'left'; + } else if (key === 'y') { + key = 'top'; + }/* else { + value = mathMax(0, value); // don't set width or height below zero (#311) + }*/ + + // clipping rectangle special + if (this.updateClipping) { + this[key] = value; // the key is now 'left' or 'top' for 'x' and 'y' + this.updateClipping(); + } else { + // normal + element.style[key] = value; + } + }, + zIndexSetter: function (value, key, element) { + element.style[key] = value; + } +}; +Highcharts.VMLElement = VMLElement = extendClass(SVGElement, VMLElement); + +// Some shared setters +VMLElement.prototype.ySetter = + VMLElement.prototype.widthSetter = + VMLElement.prototype.heightSetter = + VMLElement.prototype.xSetter; + + +/** + * The VML renderer + */ +var VMLRendererExtension = { // inherit SVGRenderer + + Element: VMLElement, + isIE8: userAgent.indexOf('MSIE 8.0') > -1, + + + /** + * Initialize the VMLRenderer + * @param {Object} container + * @param {Number} width + * @param {Number} height + */ + init: function (container, width, height, style) { + var renderer = this, + boxWrapper, + box, + css; + + renderer.alignedObjects = []; + + boxWrapper = renderer.createElement(DIV) + .css(extend(this.getStyle(style), { position: RELATIVE})); + box = boxWrapper.element; + container.appendChild(boxWrapper.element); + + + // generate the containing box + renderer.isVML = true; + renderer.box = box; + renderer.boxWrapper = boxWrapper; + renderer.cache = {}; + + + renderer.setSize(width, height, false); + + // The only way to make IE6 and IE7 print is to use a global namespace. However, + // with IE8 the only way to make the dynamic shapes visible in screen and print mode + // seems to be to add the xmlns attribute and the behaviour style inline. + if (!doc.namespaces.hcv) { + + doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml'); + + // Setup default CSS (#2153, #2368, #2384) + css = 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' + + '{ behavior:url(#default#VML); display: inline-block; } '; + try { + doc.createStyleSheet().cssText = css; + } catch (e) { + doc.styleSheets[0].cssText += css; + } + + } + }, + + + /** + * Detect whether the renderer is hidden. This happens when one of the parent elements + * has display: none + */ + isHidden: function () { + return !this.box.offsetWidth; + }, + + /** + * Define a clipping rectangle. In VML it is accomplished by storing the values + * for setting the CSS style to all associated members. + * + * @param {Number} x + * @param {Number} y + * @param {Number} width + * @param {Number} height + */ + clipRect: function (x, y, width, height) { + + // create a dummy element + var clipRect = this.createElement(), + isObj = isObject(x); + + // mimic a rectangle with its style object for automatic updating in attr + return extend(clipRect, { + members: [], + left: (isObj ? x.x : x) + 1, + top: (isObj ? x.y : y) + 1, + width: (isObj ? x.width : width) - 1, + height: (isObj ? x.height : height) - 1, + getCSS: function (wrapper) { + var element = wrapper.element, + nodeName = element.nodeName, + isShape = nodeName === 'shape', + inverted = wrapper.inverted, + rect = this, + top = rect.top - (isShape ? element.offsetTop : 0), + left = rect.left, + right = left + rect.width, + bottom = top + rect.height, + ret = { + clip: 'rect(' + + mathRound(inverted ? left : top) + 'px,' + + mathRound(inverted ? bottom : right) + 'px,' + + mathRound(inverted ? right : bottom) + 'px,' + + mathRound(inverted ? top : left) + 'px)' + }; + + // issue 74 workaround + if (!inverted && docMode8 && nodeName === 'DIV') { + extend(ret, { + width: right + PX, + height: bottom + PX + }); + } + return ret; + }, + + // used in attr and animation to update the clipping of all members + updateClipping: function () { + each(clipRect.members, function (member) { + if (member.element) { // Deleted series, like in stock/members/series-remove demo. Should be removed from members, but this will do. + member.css(clipRect.getCSS(member)); + } + }); + } + }); + + }, + + + /** + * Take a color and return it if it's a string, make it a gradient if it's a + * gradient configuration object, and apply opacity. + * + * @param {Object} color The color or config object + */ + color: function (color, elem, prop, wrapper) { + var renderer = this, + colorObject, + regexRgba = /^rgba/, + markup, + fillType, + ret = NONE; + + // Check for linear or radial gradient + if (color && color.linearGradient) { + fillType = 'gradient'; + } else if (color && color.radialGradient) { + fillType = 'pattern'; + } + + + if (fillType) { + + var stopColor, + stopOpacity, + gradient = color.linearGradient || color.radialGradient, + x1, + y1, + x2, + y2, + opacity1, + opacity2, + color1, + color2, + fillAttr = '', + stops = color.stops, + firstStop, + lastStop, + colors = [], + addFillNode = function () { + // Add the fill subnode. When colors attribute is used, the meanings of opacity and o:opacity2 + // are reversed. + markup = ['<fill colors="' + colors.join(',') + '" opacity="', opacity2, '" o:opacity2="', opacity1, + '" type="', fillType, '" ', fillAttr, 'focus="100%" method="any" />']; + createElement(renderer.prepVML(markup), null, null, elem); + }; + + // Extend from 0 to 1 + firstStop = stops[0]; + lastStop = stops[stops.length - 1]; + if (firstStop[0] > 0) { + stops.unshift([ + 0, + firstStop[1] + ]); + } + if (lastStop[0] < 1) { + stops.push([ + 1, + lastStop[1] + ]); + } + + // Compute the stops + each(stops, function (stop, i) { + if (regexRgba.test(stop[1])) { + colorObject = Color(stop[1]); + stopColor = colorObject.get('rgb'); + stopOpacity = colorObject.get('a'); + } else { + stopColor = stop[1]; + stopOpacity = 1; + } + + // Build the color attribute + colors.push((stop[0] * 100) + '% ' + stopColor); + + // Only start and end opacities are allowed, so we use the first and the last + if (!i) { + opacity1 = stopOpacity; + color2 = stopColor; + } else { + opacity2 = stopOpacity; + color1 = stopColor; + } + }); + + // Apply the gradient to fills only. + if (prop === 'fill') { + + // Handle linear gradient angle + if (fillType === 'gradient') { + x1 = gradient.x1 || gradient[0] || 0; + y1 = gradient.y1 || gradient[1] || 0; + x2 = gradient.x2 || gradient[2] || 0; + y2 = gradient.y2 || gradient[3] || 0; + fillAttr = 'angle="' + (90 - math.atan( + (y2 - y1) / // y vector + (x2 - x1) // x vector + ) * 180 / mathPI) + '"'; + + addFillNode(); + + // Radial (circular) gradient + } else { + + var r = gradient.r, + sizex = r * 2, + sizey = r * 2, + cx = gradient.cx, + cy = gradient.cy, + radialReference = elem.radialReference, + bBox, + applyRadialGradient = function () { + if (radialReference) { + bBox = wrapper.getBBox(); + cx += (radialReference[0] - bBox.x) / bBox.width - 0.5; + cy += (radialReference[1] - bBox.y) / bBox.height - 0.5; + sizex *= radialReference[2] / bBox.width; + sizey *= radialReference[2] / bBox.height; + } + fillAttr = 'src="' + defaultOptions.global.VMLRadialGradientURL + '" ' + + 'size="' + sizex + ',' + sizey + '" ' + + 'origin="0.5,0.5" ' + + 'position="' + cx + ',' + cy + '" ' + + 'color2="' + color2 + '" '; + + addFillNode(); + }; + + // Apply radial gradient + if (wrapper.added) { + applyRadialGradient(); + } else { + // We need to know the bounding box to get the size and position right + wrapper.onAdd = applyRadialGradient; + } + + // The fill element's color attribute is broken in IE8 standards mode, so we + // need to set the parent shape's fillcolor attribute instead. + ret = color1; + } + + // Gradients are not supported for VML stroke, return the first color. #722. + } else { + ret = stopColor; + } + + // if the color is an rgba color, split it and add a fill node + // to hold the opacity component + } else if (regexRgba.test(color) && elem.tagName !== 'IMG') { + + colorObject = Color(color); + + markup = ['<', prop, ' opacity="', colorObject.get('a'), '"/>']; + createElement(this.prepVML(markup), null, null, elem); + + ret = colorObject.get('rgb'); + + + } else { + var propNodes = elem.getElementsByTagName(prop); // 'stroke' or 'fill' node + if (propNodes.length) { + propNodes[0].opacity = 1; + propNodes[0].type = 'solid'; + } + ret = color; + } + + return ret; + }, + + /** + * Take a VML string and prepare it for either IE8 or IE6/IE7. + * @param {Array} markup A string array of the VML markup to prepare + */ + prepVML: function (markup) { + var vmlStyle = 'display:inline-block;behavior:url(#default#VML);', + isIE8 = this.isIE8; + + markup = markup.join(''); + + if (isIE8) { // add xmlns and style inline + markup = markup.replace('/>', ' xmlns="urn:schemas-microsoft-com:vml" />'); + if (markup.indexOf('style="') === -1) { + markup = markup.replace('/>', ' style="' + vmlStyle + '" />'); + } else { + markup = markup.replace('style="', 'style="' + vmlStyle); + } + + } else { // add namespace + markup = markup.replace('<', '<hcv:'); + } + + return markup; + }, + + /** + * Create rotated and aligned text + * @param {String} str + * @param {Number} x + * @param {Number} y + */ + text: SVGRenderer.prototype.html, + + /** + * Create and return a path element + * @param {Array} path + */ + path: function (path) { + var attr = { + // subpixel precision down to 0.1 (width and height = 1px) + coordsize: '10 10' + }; + if (isArray(path)) { + attr.d = path; + } else if (isObject(path)) { // attributes + extend(attr, path); + } + // create the shape + return this.createElement('shape').attr(attr); + }, + + /** + * Create and return a circle element. In VML circles are implemented as + * shapes, which is faster than v:oval + * @param {Number} x + * @param {Number} y + * @param {Number} r + */ + circle: function (x, y, r) { + var circle = this.symbol('circle'); + if (isObject(x)) { + r = x.r; + y = x.y; + x = x.x; + } + circle.isCircle = true; // Causes x and y to mean center (#1682) + circle.r = r; + return circle.attr({ x: x, y: y }); + }, + + /** + * Create a group using an outer div and an inner v:group to allow rotating + * and flipping. A simple v:group would have problems with positioning + * child HTML elements and CSS clip. + * + * @param {String} name The name of the group + */ + g: function (name) { + var wrapper, + attribs; + + // set the class name + if (name) { + attribs = { 'className': PREFIX + name, 'class': PREFIX + name }; + } + + // the div to hold HTML and clipping + wrapper = this.createElement(DIV).attr(attribs); + + return wrapper; + }, + + /** + * VML override to create a regular HTML image + * @param {String} src + * @param {Number} x + * @param {Number} y + * @param {Number} width + * @param {Number} height + */ + image: function (src, x, y, width, height) { + var obj = this.createElement('img') + .attr({ src: src }); + + if (arguments.length > 1) { + obj.attr({ + x: x, + y: y, + width: width, + height: height + }); + } + return obj; + }, + + /** + * For rectangles, VML uses a shape for rect to overcome bugs and rotation problems + */ + createElement: function (nodeName) { + return nodeName === 'rect' ? this.symbol(nodeName) : SVGRenderer.prototype.createElement.call(this, nodeName); + }, + + /** + * In the VML renderer, each child of an inverted div (group) is inverted + * @param {Object} element + * @param {Object} parentNode + */ + invertChild: function (element, parentNode) { + var ren = this, + parentStyle = parentNode.style, + imgStyle = element.tagName === 'IMG' && element.style; // #1111 + + css(element, { + flip: 'x', + left: pInt(parentStyle.width) - (imgStyle ? pInt(imgStyle.top) : 1), + top: pInt(parentStyle.height) - (imgStyle ? pInt(imgStyle.left) : 1), + rotation: -90 + }); + + // Recursively invert child elements, needed for nested composite shapes like box plots and error bars. #1680, #1806. + each(element.childNodes, function (child) { + ren.invertChild(child, element); + }); + }, + + /** + * Symbol definitions that override the parent SVG renderer's symbols + * + */ + symbols: { + // VML specific arc function + arc: function (x, y, w, h, options) { + var start = options.start, + end = options.end, + radius = options.r || w || h, + innerRadius = options.innerR, + cosStart = mathCos(start), + sinStart = mathSin(start), + cosEnd = mathCos(end), + sinEnd = mathSin(end), + ret; + + if (end - start === 0) { // no angle, don't show it. + return ['x']; + } + + ret = [ + 'wa', // clockwise arc to + x - radius, // left + y - radius, // top + x + radius, // right + y + radius, // bottom + x + radius * cosStart, // start x + y + radius * sinStart, // start y + x + radius * cosEnd, // end x + y + radius * sinEnd // end y + ]; + + if (options.open && !innerRadius) { + ret.push( + 'e', + M, + x,// - innerRadius, + y// - innerRadius + ); + } + + ret.push( + 'at', // anti clockwise arc to + x - innerRadius, // left + y - innerRadius, // top + x + innerRadius, // right + y + innerRadius, // bottom + x + innerRadius * cosEnd, // start x + y + innerRadius * sinEnd, // start y + x + innerRadius * cosStart, // end x + y + innerRadius * sinStart, // end y + 'x', // finish path + 'e' // close + ); + + ret.isArc = true; + return ret; + + }, + // Add circle symbol path. This performs significantly faster than v:oval. + circle: function (x, y, w, h, wrapper) { + + if (wrapper) { + w = h = 2 * wrapper.r; + } + + // Center correction, #1682 + if (wrapper && wrapper.isCircle) { + x -= w / 2; + y -= h / 2; + } + + // Return the path + return [ + 'wa', // clockwisearcto + x, // left + y, // top + x + w, // right + y + h, // bottom + x + w, // start x + y + h / 2, // start y + x + w, // end x + y + h / 2, // end y + //'x', // finish path + 'e' // close + ]; + }, + /** + * Add rectangle symbol path which eases rotation and omits arcsize problems + * compared to the built-in VML roundrect shape. When borders are not rounded, + * use the simpler square path, else use the callout path without the arrow. + */ + rect: function (x, y, w, h, options) { + return SVGRenderer.prototype.symbols[ + !defined(options) || !options.r ? 'square' : 'callout' + ].call(0, x, y, w, h, options); + } + } +}; +Highcharts.VMLRenderer = VMLRenderer = function () { + this.init.apply(this, arguments); +}; +VMLRenderer.prototype = merge(SVGRenderer.prototype, VMLRendererExtension); + + // general renderer + Renderer = VMLRenderer; +} + +// This method is used with exporting in old IE, when emulating SVG (see #2314) +SVGRenderer.prototype.measureSpanWidth = function (text, styles) { + var measuringSpan = doc.createElement('span'), + offsetWidth, + textNode = doc.createTextNode(text); + + measuringSpan.appendChild(textNode); + css(measuringSpan, styles); + this.box.appendChild(measuringSpan); + offsetWidth = measuringSpan.offsetWidth; + discardElement(measuringSpan); // #2463 + return offsetWidth; +}; + + +/* **************************************************************************** + * * + * END OF INTERNET EXPLORER <= 8 SPECIFIC CODE * + * * + *****************************************************************************/ +/* **************************************************************************** + * * + * START OF ANDROID < 3 SPECIFIC CODE. THIS CAN BE REMOVED IF YOU'RE NOT * + * TARGETING THAT SYSTEM. * + * * + *****************************************************************************/ +var CanVGRenderer, + CanVGController; + +if (useCanVG) { + /** + * The CanVGRenderer is empty from start to keep the source footprint small. + * When requested, the CanVGController downloads the rest of the source packaged + * together with the canvg library. + */ + Highcharts.CanVGRenderer = CanVGRenderer = function () { + // Override the global SVG namespace to fake SVG/HTML that accepts CSS + SVG_NS = 'http://www.w3.org/1999/xhtml'; + }; + + /** + * Start with an empty symbols object. This is needed when exporting is used (exporting.src.js will add a few symbols), but + * the implementation from SvgRenderer will not be merged in until first render. + */ + CanVGRenderer.prototype.symbols = {}; + + /** + * Handles on demand download of canvg rendering support. + */ + CanVGController = (function () { + // List of renderering calls + var deferredRenderCalls = []; + + /** + * When downloaded, we are ready to draw deferred charts. + */ + function drawDeferred() { + var callLength = deferredRenderCalls.length, + callIndex; + + // Draw all pending render calls + for (callIndex = 0; callIndex < callLength; callIndex++) { + deferredRenderCalls[callIndex](); + } + // Clear the list + deferredRenderCalls = []; + } + + return { + push: function (func, scriptLocation) { + // Only get the script once + if (deferredRenderCalls.length === 0) { + getScript(scriptLocation, drawDeferred); + } + // Register render call + deferredRenderCalls.push(func); + } + }; + }()); + + Renderer = CanVGRenderer; +} // end CanVGRenderer + +/* **************************************************************************** + * * + * END OF ANDROID < 3 SPECIFIC CODE * + * * + *****************************************************************************/ + +/** + * The Tick class + */ +function Tick(axis, pos, type, noLabel) { + this.axis = axis; + this.pos = pos; + this.type = type || ''; + this.isNew = true; + + if (!type && !noLabel) { + this.addLabel(); + } +} + +Tick.prototype = { + /** + * Write the tick label + */ + addLabel: function () { + var tick = this, + axis = tick.axis, + options = axis.options, + chart = axis.chart, + horiz = axis.horiz, + categories = axis.categories, + names = axis.names, + pos = tick.pos, + labelOptions = options.labels, + rotation = labelOptions.rotation, + str, + tickPositions = axis.tickPositions, + width = (horiz && categories && + !labelOptions.step && !labelOptions.staggerLines && + !labelOptions.rotation && + chart.plotWidth / tickPositions.length) || + (!horiz && (chart.margin[3] || chart.chartWidth * 0.33)), // #1580, #1931 + isFirst = pos === tickPositions[0], + isLast = pos === tickPositions[tickPositions.length - 1], + css, + attr, + value = categories ? + pick(categories[pos], names[pos], pos) : + pos, + label = tick.label, + tickPositionInfo = tickPositions.info, + dateTimeLabelFormat; + + // Set the datetime label format. If a higher rank is set for this position, use that. If not, + // use the general format. + if (axis.isDatetimeAxis && tickPositionInfo) { + dateTimeLabelFormat = options.dateTimeLabelFormats[tickPositionInfo.higherRanks[pos] || tickPositionInfo.unitName]; + } + // set properties for access in render method + tick.isFirst = isFirst; + tick.isLast = isLast; + + // get the string + str = axis.labelFormatter.call({ + axis: axis, + chart: chart, + isFirst: isFirst, + isLast: isLast, + dateTimeLabelFormat: dateTimeLabelFormat, + value: axis.isLog ? correctFloat(lin2log(value)) : value + }); + + // prepare CSS + css = width && { width: mathMax(1, mathRound(width - 2 * (labelOptions.padding || 10))) + PX }; + + // first call + if (!defined(label)) { + attr = { + align: axis.labelAlign + }; + if (isNumber(rotation)) { + attr.rotation = rotation; + } + if (width && labelOptions.ellipsis) { + css.HcHeight = axis.len / tickPositions.length; + } + + tick.label = label = + defined(str) && labelOptions.enabled ? + chart.renderer.text( + str, + 0, + 0, + labelOptions.useHTML + ) + .attr(attr) + // without position absolute, IE export sometimes is wrong + .css(extend(css, labelOptions.style)) + .add(axis.labelGroup) : + null; + + // Set the tick baseline and correct for rotation (#1764) + axis.tickBaseline = chart.renderer.fontMetrics(labelOptions.style.fontSize, label).b; + if (rotation && axis.side === 2) { + axis.tickBaseline *= mathCos(rotation * deg2rad); + } + + + // update + } else if (label) { + label.attr({ + text: str + }) + .css(css); + } + tick.yOffset = label ? pick(labelOptions.y, axis.tickBaseline + (axis.side === 2 ? 8 : -(label.getBBox().height / 2))) : 0; + }, + + /** + * Get the offset height or width of the label + */ + getLabelSize: function () { + var label = this.label, + axis = this.axis; + return label ? + label.getBBox()[axis.horiz ? 'height' : 'width'] : + 0; + }, + + /** + * Find how far the labels extend to the right and left of the tick's x position. Used for anti-collision + * detection with overflow logic. + */ + getLabelSides: function () { + var bBox = this.label.getBBox(), + axis = this.axis, + horiz = axis.horiz, + options = axis.options, + labelOptions = options.labels, + size = horiz ? bBox.width : bBox.height, + leftSide = horiz ? + labelOptions.x - size * { left: 0, center: 0.5, right: 1 }[axis.labelAlign] : + 0, + rightSide = horiz ? + size + leftSide : + size; + + return [leftSide, rightSide]; + }, + + /** + * Handle the label overflow by adjusting the labels to the left and right edge, or + * hide them if they collide into the neighbour label. + */ + handleOverflow: function (index, xy) { + var show = true, + axis = this.axis, + isFirst = this.isFirst, + isLast = this.isLast, + horiz = axis.horiz, + pxPos = horiz ? xy.x : xy.y, + reversed = axis.reversed, + tickPositions = axis.tickPositions, + sides = this.getLabelSides(), + leftSide = sides[0], + rightSide = sides[1], + axisLeft, + axisRight, + neighbour, + neighbourEdge, + line = this.label.line, + lineIndex = line || 0, + labelEdge = axis.labelEdge, + justifyLabel = axis.justifyLabels && (isFirst || isLast), + justifyToPlot; + + // Hide it if it now overlaps the neighbour label + if (labelEdge[lineIndex] === UNDEFINED || pxPos + leftSide > labelEdge[lineIndex]) { + labelEdge[lineIndex] = pxPos + rightSide; + + } else if (!justifyLabel) { + show = false; + } + + if (justifyLabel) { + justifyToPlot = axis.justifyToPlot; + axisLeft = justifyToPlot ? axis.pos : 0; + axisRight = justifyToPlot ? axisLeft + axis.len : axis.chart.chartWidth; + + // Find the firsth neighbour on the same line + do { + index += (isFirst ? 1 : -1); + neighbour = axis.ticks[tickPositions[index]]; + } while (tickPositions[index] && (!neighbour || !neighbour.label || neighbour.label.line !== line)); // #3044 + + neighbourEdge = neighbour && neighbour.label.xy && neighbour.label.xy.x + neighbour.getLabelSides()[isFirst ? 0 : 1]; + + if ((isFirst && !reversed) || (isLast && reversed)) { + // Is the label spilling out to the left of the plot area? + if (pxPos + leftSide < axisLeft) { + + // Align it to plot left + pxPos = axisLeft - leftSide; + + // Hide it if it now overlaps the neighbour label + if (neighbour && pxPos + rightSide > neighbourEdge) { + show = false; + } + } + + } else { + // Is the label spilling out to the right of the plot area? + if (pxPos + rightSide > axisRight) { + + // Align it to plot right + pxPos = axisRight - rightSide; + + // Hide it if it now overlaps the neighbour label + if (neighbour && pxPos + leftSide < neighbourEdge) { + show = false; + } + + } + } + + // Set the modified x position of the label + xy.x = pxPos; + } + return show; + }, + + /** + * Get the x and y position for ticks and labels + */ + getPosition: function (horiz, pos, tickmarkOffset, old) { + var axis = this.axis, + chart = axis.chart, + cHeight = (old && chart.oldChartHeight) || chart.chartHeight; + + return { + x: horiz ? + axis.translate(pos + tickmarkOffset, null, null, old) + axis.transB : + axis.left + axis.offset + (axis.opposite ? ((old && chart.oldChartWidth) || chart.chartWidth) - axis.right - axis.left : 0), + + y: horiz ? + cHeight - axis.bottom + axis.offset - (axis.opposite ? axis.height : 0) : + cHeight - axis.translate(pos + tickmarkOffset, null, null, old) - axis.transB + }; + + }, + + /** + * Get the x, y position of the tick label + */ + getLabelPosition: function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) { + var axis = this.axis, + transA = axis.transA, + reversed = axis.reversed, + staggerLines = axis.staggerLines; + + x = x + labelOptions.x - (tickmarkOffset && horiz ? + tickmarkOffset * transA * (reversed ? -1 : 1) : 0); + y = y + this.yOffset - (tickmarkOffset && !horiz ? + tickmarkOffset * transA * (reversed ? 1 : -1) : 0); + + // Correct for staggered labels + if (staggerLines) { + label.line = (index / (step || 1) % staggerLines); + y += label.line * (axis.labelOffset / staggerLines); + } + + return { + x: x, + y: y + }; + }, + + /** + * Extendible method to return the path of the marker + */ + getMarkPath: function (x, y, tickLength, tickWidth, horiz, renderer) { + return renderer.crispLine([ + M, + x, + y, + L, + x + (horiz ? 0 : -tickLength), + y + (horiz ? tickLength : 0) + ], tickWidth); + }, + + /** + * Put everything in place + * + * @param index {Number} + * @param old {Boolean} Use old coordinates to prepare an animation into new position + */ + render: function (index, old, opacity) { + var tick = this, + axis = tick.axis, + options = axis.options, + chart = axis.chart, + renderer = chart.renderer, + horiz = axis.horiz, + type = tick.type, + label = tick.label, + pos = tick.pos, + labelOptions = options.labels, + gridLine = tick.gridLine, + gridPrefix = type ? type + 'Grid' : 'grid', + tickPrefix = type ? type + 'Tick' : 'tick', + gridLineWidth = options[gridPrefix + 'LineWidth'], + gridLineColor = options[gridPrefix + 'LineColor'], + dashStyle = options[gridPrefix + 'LineDashStyle'], + tickLength = options[tickPrefix + 'Length'], + tickWidth = options[tickPrefix + 'Width'] || 0, + tickColor = options[tickPrefix + 'Color'], + tickPosition = options[tickPrefix + 'Position'], + gridLinePath, + mark = tick.mark, + markPath, + step = labelOptions.step, + attribs, + show = true, + tickmarkOffset = axis.tickmarkOffset, + xy = tick.getPosition(horiz, pos, tickmarkOffset, old), + x = xy.x, + y = xy.y, + reverseCrisp = ((horiz && x === axis.pos + axis.len) || (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687 + + opacity = pick(opacity, 1); + this.isActive = true; + + // create the grid line + if (gridLineWidth) { + gridLinePath = axis.getPlotLinePath(pos + tickmarkOffset, gridLineWidth * reverseCrisp, old, true); + + if (gridLine === UNDEFINED) { + attribs = { + stroke: gridLineColor, + 'stroke-width': gridLineWidth + }; + if (dashStyle) { + attribs.dashstyle = dashStyle; + } + if (!type) { + attribs.zIndex = 1; + } + if (old) { + attribs.opacity = 0; + } + tick.gridLine = gridLine = + gridLineWidth ? + renderer.path(gridLinePath) + .attr(attribs).add(axis.gridGroup) : + null; + } + + // If the parameter 'old' is set, the current call will be followed + // by another call, therefore do not do any animations this time + if (!old && gridLine && gridLinePath) { + gridLine[tick.isNew ? 'attr' : 'animate']({ + d: gridLinePath, + opacity: opacity + }); + } + } + + // create the tick mark + if (tickWidth && tickLength) { + + // negate the length + if (tickPosition === 'inside') { + tickLength = -tickLength; + } + if (axis.opposite) { + tickLength = -tickLength; + } + + markPath = tick.getMarkPath(x, y, tickLength, tickWidth * reverseCrisp, horiz, renderer); + if (mark) { // updating + mark.animate({ + d: markPath, + opacity: opacity + }); + } else { // first time + tick.mark = renderer.path( + markPath + ).attr({ + stroke: tickColor, + 'stroke-width': tickWidth, + opacity: opacity + }).add(axis.axisGroup); + } + } + + // the label is created on init - now move it into place + if (label && !isNaN(x)) { + label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step); + + // Apply show first and show last. If the tick is both first and last, it is + // a single centered tick, in which case we show the label anyway (#2100). + if ((tick.isFirst && !tick.isLast && !pick(options.showFirstLabel, 1)) || + (tick.isLast && !tick.isFirst && !pick(options.showLastLabel, 1))) { + show = false; + + // Handle label overflow and show or hide accordingly + } else if (!axis.isRadial && !labelOptions.step && !labelOptions.rotation && !old && opacity !== 0) { + show = tick.handleOverflow(index, xy); + } + + // apply step + if (step && index % step) { + // show those indices dividable by step + show = false; + } + + // Set the new position, and show or hide + if (show && !isNaN(xy.y)) { + xy.opacity = opacity; + label[tick.isNew ? 'attr' : 'animate'](xy); + tick.isNew = false; + } else { + label.attr('y', -9999); // #1338 + } + } + }, + + /** + * Destructor for the tick prototype + */ + destroy: function () { + destroyObjectProperties(this, this.axis); + } +}; + +/** + * The object wrapper for plot lines and plot bands + * @param {Object} options + */ +Highcharts.PlotLineOrBand = function (axis, options) { + this.axis = axis; + + if (options) { + this.options = options; + this.id = options.id; + } +}; + +Highcharts.PlotLineOrBand.prototype = { + + /** + * Render the plot line or plot band. If it is already existing, + * move it. + */ + render: function () { + var plotLine = this, + axis = plotLine.axis, + horiz = axis.horiz, + halfPointRange = (axis.pointRange || 0) / 2, + options = plotLine.options, + optionsLabel = options.label, + label = plotLine.label, + width = options.width, + to = options.to, + from = options.from, + isBand = defined(from) && defined(to), + value = options.value, + dashStyle = options.dashStyle, + svgElem = plotLine.svgElem, + path = [], + addEvent, + eventType, + xs, + ys, + x, + y, + color = options.color, + zIndex = options.zIndex, + events = options.events, + attribs = {}, + renderer = axis.chart.renderer; + + // logarithmic conversion + if (axis.isLog) { + from = log2lin(from); + to = log2lin(to); + value = log2lin(value); + } + + // plot line + if (width) { + path = axis.getPlotLinePath(value, width); + attribs = { + stroke: color, + 'stroke-width': width + }; + if (dashStyle) { + attribs.dashstyle = dashStyle; + } + } else if (isBand) { // plot band + + // keep within plot area + from = mathMax(from, axis.min - halfPointRange); + to = mathMin(to, axis.max + halfPointRange); + + path = axis.getPlotBandPath(from, to, options); + if (color) { + attribs.fill = color; + } + if (options.borderWidth) { + attribs.stroke = options.borderColor; + attribs['stroke-width'] = options.borderWidth; + } + } else { + return; + } + // zIndex + if (defined(zIndex)) { + attribs.zIndex = zIndex; + } + + // common for lines and bands + if (svgElem) { + if (path) { + svgElem.animate({ + d: path + }, null, svgElem.onGetPath); + } else { + svgElem.hide(); + svgElem.onGetPath = function () { + svgElem.show(); + }; + if (label) { + plotLine.label = label = label.destroy(); + } + } + } else if (path && path.length) { + plotLine.svgElem = svgElem = renderer.path(path) + .attr(attribs).add(); + + // events + if (events) { + addEvent = function (eventType) { + svgElem.on(eventType, function (e) { + events[eventType].apply(plotLine, [e]); + }); + }; + for (eventType in events) { + addEvent(eventType); + } + } + } + + // the plot band/line label + if (optionsLabel && defined(optionsLabel.text) && path && path.length && axis.width > 0 && axis.height > 0) { + // apply defaults + optionsLabel = merge({ + align: horiz && isBand && 'center', + x: horiz ? !isBand && 4 : 10, + verticalAlign : !horiz && isBand && 'middle', + y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4, + rotation: horiz && !isBand && 90 + }, optionsLabel); + + // add the SVG element + if (!label) { + attribs = { + align: optionsLabel.textAlign || optionsLabel.align, + rotation: optionsLabel.rotation + }; + if (defined(zIndex)) { + attribs.zIndex = zIndex; + } + plotLine.label = label = renderer.text( + optionsLabel.text, + 0, + 0, + optionsLabel.useHTML + ) + .attr(attribs) + .css(optionsLabel.style) + .add(); + } + + // get the bounding box and align the label + // #3000 changed to better handle choice between plotband or plotline + xs = [path[1], path[4], (isBand ? path[6] : path[1])]; + ys = [path[2], path[5], (isBand ? path[7] : path[2])]; + x = arrayMin(xs); + y = arrayMin(ys); + + label.align(optionsLabel, false, { + x: x, + y: y, + width: arrayMax(xs) - x, + height: arrayMax(ys) - y + }); + label.show(); + + } else if (label) { // move out of sight + label.hide(); + } + + // chainable + return plotLine; + }, + + /** + * Remove the plot line or band + */ + destroy: function () { + // remove it from the lookup + erase(this.axis.plotLinesAndBands, this); + + delete this.axis; + destroyObjectProperties(this); + } +}; + +/** + * Object with members for extending the Axis prototype + */ + +AxisPlotLineOrBandExtension = { + + /** + * Create the path for a plot band + */ + getPlotBandPath: function (from, to) { + var toPath = this.getPlotLinePath(to), + path = this.getPlotLinePath(from); + + if (path && toPath) { + path.push( + toPath[4], + toPath[5], + toPath[1], + toPath[2] + ); + } else { // outside the axis area + path = null; + } + + return path; + }, + + addPlotBand: function (options) { + return this.addPlotBandOrLine(options, 'plotBands'); + }, + + addPlotLine: function (options) { + return this.addPlotBandOrLine(options, 'plotLines'); + }, + + /** + * Add a plot band or plot line after render time + * + * @param options {Object} The plotBand or plotLine configuration object + */ + addPlotBandOrLine: function (options, coll) { + var obj = new Highcharts.PlotLineOrBand(this, options).render(), + userOptions = this.userOptions; + + if (obj) { // #2189 + // Add it to the user options for exporting and Axis.update + if (coll) { + userOptions[coll] = userOptions[coll] || []; + userOptions[coll].push(options); + } + this.plotLinesAndBands.push(obj); + } + + return obj; + }, + + /** + * Remove a plot band or plot line from the chart by id + * @param {Object} id + */ + removePlotBandOrLine: function (id) { + var plotLinesAndBands = this.plotLinesAndBands, + options = this.options, + userOptions = this.userOptions, + i = plotLinesAndBands.length; + while (i--) { + if (plotLinesAndBands[i].id === id) { + plotLinesAndBands[i].destroy(); + } + } + each([options.plotLines || [], userOptions.plotLines || [], options.plotBands || [], userOptions.plotBands || []], function (arr) { + i = arr.length; + while (i--) { + if (arr[i].id === id) { + erase(arr, arr[i]); + } + } + }); + } +}; + +/** + * Create a new axis object + * @param {Object} chart + * @param {Object} options + */ +function Axis() { + this.init.apply(this, arguments); +} + +Axis.prototype = { + + /** + * Default options for the X axis - the Y axis has extended defaults + */ + defaultOptions: { + // allowDecimals: null, + // alternateGridColor: null, + // categories: [], + dateTimeLabelFormats: { + millisecond: '%H:%M:%S.%L', + second: '%H:%M:%S', + minute: '%H:%M', + hour: '%H:%M', + day: '%e. %b', + week: '%e. %b', + month: '%b \'%y', + year: '%Y' + }, + endOnTick: false, + gridLineColor: '#C0C0C0', + // gridLineDashStyle: 'solid', + // gridLineWidth: 0, + // reversed: false, + + labels: defaultLabelOptions, + // { step: null }, + lineColor: '#C0D0E0', + lineWidth: 1, + //linkedTo: null, + //max: undefined, + //min: undefined, + minPadding: 0.01, + maxPadding: 0.01, + //minRange: null, + minorGridLineColor: '#E0E0E0', + // minorGridLineDashStyle: null, + minorGridLineWidth: 1, + minorTickColor: '#A0A0A0', + //minorTickInterval: null, + minorTickLength: 2, + minorTickPosition: 'outside', // inside or outside + //minorTickWidth: 0, + //opposite: false, + //offset: 0, + //plotBands: [{ + // events: {}, + // zIndex: 1, + // labels: { align, x, verticalAlign, y, style, rotation, textAlign } + //}], + //plotLines: [{ + // events: {} + // dashStyle: {} + // zIndex: + // labels: { align, x, verticalAlign, y, style, rotation, textAlign } + //}], + //reversed: false, + // showFirstLabel: true, + // showLastLabel: true, + startOfWeek: 1, + startOnTick: false, + tickColor: '#C0D0E0', + //tickInterval: null, + tickLength: 10, + tickmarkPlacement: 'between', // on or between + tickPixelInterval: 100, + tickPosition: 'outside', + tickWidth: 1, + title: { + //text: null, + align: 'middle', // low, middle or high + //margin: 0 for horizontal, 10 for vertical axes, + //rotation: 0, + //side: 'outside', + style: { + color: '#707070' + } + //x: 0, + //y: 0 + }, + type: 'linear' // linear, logarithmic or datetime + }, + + /** + * This options set extends the defaultOptions for Y axes + */ + defaultYAxisOptions: { + endOnTick: true, + gridLineWidth: 1, + tickPixelInterval: 72, + showLastLabel: true, + labels: { + x: -8, + y: 3 + }, + lineWidth: 0, + maxPadding: 0.05, + minPadding: 0.05, + startOnTick: true, + tickWidth: 0, + title: { + rotation: 270, + text: 'Values' + }, + stackLabels: { + enabled: false, + //align: dynamic, + //y: dynamic, + //x: dynamic, + //verticalAlign: dynamic, + //textAlign: dynamic, + //rotation: 0, + formatter: function () { + return numberFormat(this.total, -1); + }, + style: defaultLabelOptions.style + } + }, + + /** + * These options extend the defaultOptions for left axes + */ + defaultLeftAxisOptions: { + labels: { + x: -15, + y: null + }, + title: { + rotation: 270 + } + }, + + /** + * These options extend the defaultOptions for right axes + */ + defaultRightAxisOptions: { + labels: { + x: 15, + y: null + }, + title: { + rotation: 90 + } + }, + + /** + * These options extend the defaultOptions for bottom axes + */ + defaultBottomAxisOptions: { + labels: { + x: 0, + y: null // based on font size + // overflow: undefined, + // staggerLines: null + }, + title: { + rotation: 0 + } + }, + /** + * These options extend the defaultOptions for left axes + */ + defaultTopAxisOptions: { + labels: { + x: 0, + y: -15 + // overflow: undefined + // staggerLines: null + }, + title: { + rotation: 0 + } + }, + + /** + * Initialize the axis + */ + init: function (chart, userOptions) { + + + var isXAxis = userOptions.isX, + axis = this; + + // Flag, is the axis horizontal + axis.horiz = chart.inverted ? !isXAxis : isXAxis; + + // Flag, isXAxis + axis.isXAxis = isXAxis; + axis.coll = isXAxis ? 'xAxis' : 'yAxis'; + + axis.opposite = userOptions.opposite; // needed in setOptions + axis.side = userOptions.side || (axis.horiz ? + (axis.opposite ? 0 : 2) : // top : bottom + (axis.opposite ? 1 : 3)); // right : left + + axis.setOptions(userOptions); + + + var options = this.options, + type = options.type, + isDatetimeAxis = type === 'datetime'; + + axis.labelFormatter = options.labels.formatter || axis.defaultLabelFormatter; // can be overwritten by dynamic format + + + // Flag, stagger lines or not + axis.userOptions = userOptions; + + //axis.axisTitleMargin = UNDEFINED,// = options.title.margin, + axis.minPixelPadding = 0; + //axis.ignoreMinPadding = UNDEFINED; // can be set to true by a column or bar series + //axis.ignoreMaxPadding = UNDEFINED; + + axis.chart = chart; + axis.reversed = options.reversed; + axis.zoomEnabled = options.zoomEnabled !== false; + + // Initial categories + axis.categories = options.categories || type === 'category'; + axis.names = []; + + // Elements + //axis.axisGroup = UNDEFINED; + //axis.gridGroup = UNDEFINED; + //axis.axisTitle = UNDEFINED; + //axis.axisLine = UNDEFINED; + + // Shorthand types + axis.isLog = type === 'logarithmic'; + axis.isDatetimeAxis = isDatetimeAxis; + + // Flag, if axis is linked to another axis + axis.isLinked = defined(options.linkedTo); + // Linked axis. + //axis.linkedParent = UNDEFINED; + + // Tick positions + //axis.tickPositions = UNDEFINED; // array containing predefined positions + // Tick intervals + //axis.tickInterval = UNDEFINED; + //axis.minorTickInterval = UNDEFINED; + + axis.tickmarkOffset = (axis.categories && options.tickmarkPlacement === 'between' && + pick(options.tickInterval, 1) === 1) ? 0.5 : 0; // #3202 + + // Major ticks + axis.ticks = {}; + axis.labelEdge = []; + // Minor ticks + axis.minorTicks = {}; + //axis.tickAmount = UNDEFINED; + + // List of plotLines/Bands + axis.plotLinesAndBands = []; + + // Alternate bands + axis.alternateBands = {}; + + // Axis metrics + //axis.left = UNDEFINED; + //axis.top = UNDEFINED; + //axis.width = UNDEFINED; + //axis.height = UNDEFINED; + //axis.bottom = UNDEFINED; + //axis.right = UNDEFINED; + //axis.transA = UNDEFINED; + //axis.transB = UNDEFINED; + //axis.oldTransA = UNDEFINED; + axis.len = 0; + //axis.oldMin = UNDEFINED; + //axis.oldMax = UNDEFINED; + //axis.oldUserMin = UNDEFINED; + //axis.oldUserMax = UNDEFINED; + //axis.oldAxisLength = UNDEFINED; + axis.minRange = axis.userMinRange = options.minRange || options.maxZoom; + axis.range = options.range; + axis.offset = options.offset || 0; + + + // Dictionary for stacks + axis.stacks = {}; + axis.oldStacks = {}; + + // Min and max in the data + //axis.dataMin = UNDEFINED, + //axis.dataMax = UNDEFINED, + + // The axis range + axis.max = null; + axis.min = null; + + // User set min and max + //axis.userMin = UNDEFINED, + //axis.userMax = UNDEFINED, + + // Crosshair options + axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false); + // Run Axis + + var eventType, + events = axis.options.events; + + // Register + if (inArray(axis, chart.axes) === -1) { // don't add it again on Axis.update() + if (isXAxis && !this.isColorAxis) { // #2713 + chart.axes.splice(chart.xAxis.length, 0, axis); + } else { + chart.axes.push(axis); + } + + chart[axis.coll].push(axis); + } + + axis.series = axis.series || []; // populated by Series + + // inverted charts have reversed xAxes as default + if (chart.inverted && isXAxis && axis.reversed === UNDEFINED) { + axis.reversed = true; + } + + axis.removePlotBand = axis.removePlotBandOrLine; + axis.removePlotLine = axis.removePlotBandOrLine; + + + // register event listeners + for (eventType in events) { + addEvent(axis, eventType, events[eventType]); + } + + // extend logarithmic axis + if (axis.isLog) { + axis.val2lin = log2lin; + axis.lin2val = lin2log; + } + }, + + /** + * Merge and set options + */ + setOptions: function (userOptions) { + this.options = merge( + this.defaultOptions, + this.isXAxis ? {} : this.defaultYAxisOptions, + [this.defaultTopAxisOptions, this.defaultRightAxisOptions, + this.defaultBottomAxisOptions, this.defaultLeftAxisOptions][this.side], + merge( + defaultOptions[this.coll], // if set in setOptions (#1053) + userOptions + ) + ); + }, + + /** + * The default label formatter. The context is a special config object for the label. + */ + defaultLabelFormatter: function () { + var axis = this.axis, + value = this.value, + categories = axis.categories, + dateTimeLabelFormat = this.dateTimeLabelFormat, + numericSymbols = defaultOptions.lang.numericSymbols, + i = numericSymbols && numericSymbols.length, + multi, + ret, + formatOption = axis.options.labels.format, + + // make sure the same symbol is added for all labels on a linear axis + numericSymbolDetector = axis.isLog ? value : axis.tickInterval; + + if (formatOption) { + ret = format(formatOption, this); + + } else if (categories) { + ret = value; + + } else if (dateTimeLabelFormat) { // datetime axis + ret = dateFormat(dateTimeLabelFormat, value); + + } else if (i && numericSymbolDetector >= 1000) { + // Decide whether we should add a numeric symbol like k (thousands) or M (millions). + // If we are to enable this in tooltip or other places as well, we can move this + // logic to the numberFormatter and enable it by a parameter. + while (i-- && ret === UNDEFINED) { + multi = Math.pow(1000, i + 1); + if (numericSymbolDetector >= multi && numericSymbols[i] !== null) { + ret = numberFormat(value / multi, -1) + numericSymbols[i]; + } + } + } + + if (ret === UNDEFINED) { + if (mathAbs(value) >= 10000) { // add thousands separators + ret = numberFormat(value, 0); + + } else { // small numbers + ret = numberFormat(value, -1, UNDEFINED, ''); // #2466 + } + } + + return ret; + }, + + /** + * Get the minimum and maximum for the series of each axis + */ + getSeriesExtremes: function () { + var axis = this, + chart = axis.chart; + + axis.hasVisibleSeries = false; + + // Reset properties in case we're redrawing (#3353) + axis.dataMin = axis.dataMax = axis.ignoreMinPadding = axis.ignoreMaxPadding = null; + + if (axis.buildStacks) { + axis.buildStacks(); + } + + // loop through this axis' series + each(axis.series, function (series) { + + if (series.visible || !chart.options.chart.ignoreHiddenSeries) { + + var seriesOptions = series.options, + xData, + threshold = seriesOptions.threshold, + seriesDataMin, + seriesDataMax; + + axis.hasVisibleSeries = true; + + // Validate threshold in logarithmic axes + if (axis.isLog && threshold <= 0) { + threshold = null; + } + + // Get dataMin and dataMax for X axes + if (axis.isXAxis) { + xData = series.xData; + if (xData.length) { + axis.dataMin = mathMin(pick(axis.dataMin, xData[0]), arrayMin(xData)); + axis.dataMax = mathMax(pick(axis.dataMax, xData[0]), arrayMax(xData)); + } + + // Get dataMin and dataMax for Y axes, as well as handle stacking and processed data + } else { + + // Get this particular series extremes + series.getExtremes(); + seriesDataMax = series.dataMax; + seriesDataMin = series.dataMin; + + // Get the dataMin and dataMax so far. If percentage is used, the min and max are + // always 0 and 100. If seriesDataMin and seriesDataMax is null, then series + // doesn't have active y data, we continue with nulls + if (defined(seriesDataMin) && defined(seriesDataMax)) { + axis.dataMin = mathMin(pick(axis.dataMin, seriesDataMin), seriesDataMin); + axis.dataMax = mathMax(pick(axis.dataMax, seriesDataMax), seriesDataMax); + } + + // Adjust to threshold + if (defined(threshold)) { + if (axis.dataMin >= threshold) { + axis.dataMin = threshold; + axis.ignoreMinPadding = true; + } else if (axis.dataMax < threshold) { + axis.dataMax = threshold; + axis.ignoreMaxPadding = true; + } + } + } + } + }); + }, + + /** + * Translate from axis value to pixel position on the chart, or back + * + */ + translate: function (val, backwards, cvsCoord, old, handleLog, pointPlacement) { + var axis = this, + sign = 1, + cvsOffset = 0, + localA = old ? axis.oldTransA : axis.transA, + localMin = old ? axis.oldMin : axis.min, + returnValue, + minPixelPadding = axis.minPixelPadding, + postTranslate = (axis.options.ordinal || (axis.isLog && handleLog)) && axis.lin2val; + + if (!localA) { + localA = axis.transA; + } + + // In vertical axes, the canvas coordinates start from 0 at the top like in + // SVG. + if (cvsCoord) { + sign *= -1; // canvas coordinates inverts the value + cvsOffset = axis.len; + } + + // Handle reversed axis + if (axis.reversed) { + sign *= -1; + cvsOffset -= sign * (axis.sector || axis.len); + } + + // From pixels to value + if (backwards) { // reverse translation + + val = val * sign + cvsOffset; + val -= minPixelPadding; + returnValue = val / localA + localMin; // from chart pixel to value + if (postTranslate) { // log and ordinal axes + returnValue = axis.lin2val(returnValue); + } + + // From value to pixels + } else { + if (postTranslate) { // log and ordinal axes + val = axis.val2lin(val); + } + if (pointPlacement === 'between') { + pointPlacement = 0.5; + } + returnValue = sign * (val - localMin) * localA + cvsOffset + (sign * minPixelPadding) + + (isNumber(pointPlacement) ? localA * pointPlacement * axis.pointRange : 0); + } + + return returnValue; + }, + + /** + * Utility method to translate an axis value to pixel position. + * @param {Number} value A value in terms of axis units + * @param {Boolean} paneCoordinates Whether to return the pixel coordinate relative to the chart + * or just the axis/pane itself. + */ + toPixels: function (value, paneCoordinates) { + return this.translate(value, false, !this.horiz, null, true) + (paneCoordinates ? 0 : this.pos); + }, + + /* + * Utility method to translate a pixel position in to an axis value + * @param {Number} pixel The pixel value coordinate + * @param {Boolean} paneCoordiantes Whether the input pixel is relative to the chart or just the + * axis/pane itself. + */ + toValue: function (pixel, paneCoordinates) { + return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true); + }, + + /** + * Create the path for a plot line that goes from the given value on + * this axis, across the plot to the opposite side + * @param {Number} value + * @param {Number} lineWidth Used for calculation crisp line + * @param {Number] old Use old coordinates (for resizing and rescaling) + */ + getPlotLinePath: function (value, lineWidth, old, force, translatedValue) { + var axis = this, + chart = axis.chart, + axisLeft = axis.left, + axisTop = axis.top, + x1, + y1, + x2, + y2, + cHeight = (old && chart.oldChartHeight) || chart.chartHeight, + cWidth = (old && chart.oldChartWidth) || chart.chartWidth, + skip, + transB = axis.transB; + + translatedValue = pick(translatedValue, axis.translate(value, null, null, old)); + x1 = x2 = mathRound(translatedValue + transB); + y1 = y2 = mathRound(cHeight - translatedValue - transB); + + if (isNaN(translatedValue)) { // no min or max + skip = true; + + } else if (axis.horiz) { + y1 = axisTop; + y2 = cHeight - axis.bottom; + if (x1 < axisLeft || x1 > axisLeft + axis.width) { + skip = true; + } + } else { + x1 = axisLeft; + x2 = cWidth - axis.right; + + if (y1 < axisTop || y1 > axisTop + axis.height) { + skip = true; + } + } + return skip && !force ? + null : + chart.renderer.crispLine([M, x1, y1, L, x2, y2], lineWidth || 1); + }, + + /** + * Set the tick positions of a linear axis to round values like whole tens or every five. + */ + getLinearTickPositions: function (tickInterval, min, max) { + var pos, + lastPos, + roundedMin = correctFloat(mathFloor(min / tickInterval) * tickInterval), + roundedMax = correctFloat(mathCeil(max / tickInterval) * tickInterval), + tickPositions = []; + + // For single points, add a tick regardless of the relative position (#2662) + if (min === max && isNumber(min)) { + return [min]; + } + + // Populate the intermediate values + pos = roundedMin; + while (pos <= roundedMax) { + + // Place the tick on the rounded value + tickPositions.push(pos); + + // Always add the raw tickInterval, not the corrected one. + pos = correctFloat(pos + tickInterval); + + // If the interval is not big enough in the current min - max range to actually increase + // the loop variable, we need to break out to prevent endless loop. Issue #619 + if (pos === lastPos) { + break; + } + + // Record the last value + lastPos = pos; + } + return tickPositions; + }, + + /** + * Return the minor tick positions. For logarithmic axes, reuse the same logic + * as for major ticks. + */ + getMinorTickPositions: function () { + var axis = this, + options = axis.options, + tickPositions = axis.tickPositions, + minorTickInterval = axis.minorTickInterval, + minorTickPositions = [], + pos, + i, + len; + + if (axis.isLog) { + len = tickPositions.length; + for (i = 1; i < len; i++) { + minorTickPositions = minorTickPositions.concat( + axis.getLogTickPositions(minorTickInterval, tickPositions[i - 1], tickPositions[i], true) + ); + } + } else if (axis.isDatetimeAxis && options.minorTickInterval === 'auto') { // #1314 + minorTickPositions = minorTickPositions.concat( + axis.getTimeTicks( + axis.normalizeTimeTickInterval(minorTickInterval), + axis.min, + axis.max, + options.startOfWeek + ) + ); + if (minorTickPositions[0] < axis.min) { + minorTickPositions.shift(); + } + } else { + for (pos = axis.min + (tickPositions[0] - axis.min) % minorTickInterval; pos <= axis.max; pos += minorTickInterval) { + minorTickPositions.push(pos); + } + } + return minorTickPositions; + }, + + /** + * Adjust the min and max for the minimum range. Keep in mind that the series data is + * not yet processed, so we don't have information on data cropping and grouping, or + * updated axis.pointRange or series.pointRange. The data can't be processed until + * we have finally established min and max. + */ + adjustForMinRange: function () { + var axis = this, + options = axis.options, + min = axis.min, + max = axis.max, + zoomOffset, + spaceAvailable = axis.dataMax - axis.dataMin >= axis.minRange, + closestDataRange, + i, + distance, + xData, + loopLength, + minArgs, + maxArgs; + + // Set the automatic minimum range based on the closest point distance + if (axis.isXAxis && axis.minRange === UNDEFINED && !axis.isLog) { + + if (defined(options.min) || defined(options.max)) { + axis.minRange = null; // don't do this again + + } else { + + // Find the closest distance between raw data points, as opposed to + // closestPointRange that applies to processed points (cropped and grouped) + each(axis.series, function (series) { + xData = series.xData; + loopLength = series.xIncrement ? 1 : xData.length - 1; + for (i = loopLength; i > 0; i--) { + distance = xData[i] - xData[i - 1]; + if (closestDataRange === UNDEFINED || distance < closestDataRange) { + closestDataRange = distance; + } + } + }); + axis.minRange = mathMin(closestDataRange * 5, axis.dataMax - axis.dataMin); + } + } + + // if minRange is exceeded, adjust + if (max - min < axis.minRange) { + var minRange = axis.minRange; + zoomOffset = (minRange - max + min) / 2; + + // if min and max options have been set, don't go beyond it + minArgs = [min - zoomOffset, pick(options.min, min - zoomOffset)]; + if (spaceAvailable) { // if space is available, stay within the data range + minArgs[2] = axis.dataMin; + } + min = arrayMax(minArgs); + + maxArgs = [min + minRange, pick(options.max, min + minRange)]; + if (spaceAvailable) { // if space is availabe, stay within the data range + maxArgs[2] = axis.dataMax; + } + + max = arrayMin(maxArgs); + + // now if the max is adjusted, adjust the min back + if (max - min < minRange) { + minArgs[0] = max - minRange; + minArgs[1] = pick(options.min, max - minRange); + min = arrayMax(minArgs); + } + } + + // Record modified extremes + axis.min = min; + axis.max = max; + }, + + /** + * Update translation information + */ + setAxisTranslation: function (saveOld) { + var axis = this, + range = axis.max - axis.min, + pointRange = axis.axisPointRange || 0, + closestPointRange, + minPointOffset = 0, + pointRangePadding = 0, + linkedParent = axis.linkedParent, + ordinalCorrection, + hasCategories = !!axis.categories, + transA = axis.transA; + + // Adjust translation for padding. Y axis with categories need to go through the same (#1784). + if (axis.isXAxis || hasCategories || pointRange) { + if (linkedParent) { + minPointOffset = linkedParent.minPointOffset; + pointRangePadding = linkedParent.pointRangePadding; + + } else { + each(axis.series, function (series) { + var seriesPointRange = hasCategories ? 1 : (axis.isXAxis ? series.pointRange : (axis.axisPointRange || 0)), // #2806 + pointPlacement = series.options.pointPlacement, + seriesClosestPointRange = series.closestPointRange; + + if (seriesPointRange > range) { // #1446 + seriesPointRange = 0; + } + pointRange = mathMax(pointRange, seriesPointRange); + + // minPointOffset is the value padding to the left of the axis in order to make + // room for points with a pointRange, typically columns. When the pointPlacement option + // is 'between' or 'on', this padding does not apply. + minPointOffset = mathMax( + minPointOffset, + isString(pointPlacement) ? 0 : seriesPointRange / 2 + ); + + // Determine the total padding needed to the length of the axis to make room for the + // pointRange. If the series' pointPlacement is 'on', no padding is added. + pointRangePadding = mathMax( + pointRangePadding, + pointPlacement === 'on' ? 0 : seriesPointRange + ); + + // Set the closestPointRange + if (!series.noSharedTooltip && defined(seriesClosestPointRange)) { + closestPointRange = defined(closestPointRange) ? + mathMin(closestPointRange, seriesClosestPointRange) : + seriesClosestPointRange; + } + }); + } + + // Record minPointOffset and pointRangePadding + ordinalCorrection = axis.ordinalSlope && closestPointRange ? axis.ordinalSlope / closestPointRange : 1; // #988, #1853 + axis.minPointOffset = minPointOffset = minPointOffset * ordinalCorrection; + axis.pointRangePadding = pointRangePadding = pointRangePadding * ordinalCorrection; + + // pointRange means the width reserved for each point, like in a column chart + axis.pointRange = mathMin(pointRange, range); + + // closestPointRange means the closest distance between points. In columns + // it is mostly equal to pointRange, but in lines pointRange is 0 while closestPointRange + // is some other value + axis.closestPointRange = closestPointRange; + } + + // Secondary values + if (saveOld) { + axis.oldTransA = transA; + } + axis.translationSlope = axis.transA = transA = axis.len / ((range + pointRangePadding) || 1); + axis.transB = axis.horiz ? axis.left : axis.bottom; // translation addend + axis.minPixelPadding = transA * minPointOffset; + }, + + /** + * Set the tick positions to round values and optionally extend the extremes + * to the nearest tick + */ + setTickPositions: function (secondPass) { + var axis = this, + chart = axis.chart, + options = axis.options, + startOnTick = options.startOnTick, + endOnTick = options.endOnTick, + isLog = axis.isLog, + isDatetimeAxis = axis.isDatetimeAxis, + isXAxis = axis.isXAxis, + isLinked = axis.isLinked, + tickPositioner = axis.options.tickPositioner, + maxPadding = options.maxPadding, + minPadding = options.minPadding, + length, + linkedParentExtremes, + tickIntervalOption = options.tickInterval, + minTickIntervalOption = options.minTickInterval, + tickPixelIntervalOption = options.tickPixelInterval, + tickPositions, + keepTwoTicksOnly, + categories = axis.categories; + + // linked axis gets the extremes from the parent axis + if (isLinked) { + axis.linkedParent = chart[axis.coll][options.linkedTo]; + linkedParentExtremes = axis.linkedParent.getExtremes(); + axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin); + axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax); + if (options.type !== axis.linkedParent.options.type) { + error(11, 1); // Can't link axes of different type + } + } else { // initial min and max from the extreme data values + axis.min = pick(axis.userMin, options.min, axis.dataMin); + axis.max = pick(axis.userMax, options.max, axis.dataMax); + } + + if (isLog) { + if (!secondPass && mathMin(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978 + error(10, 1); // Can't plot negative values on log axis + } + axis.min = correctFloat(log2lin(axis.min)); // correctFloat cures #934 + axis.max = correctFloat(log2lin(axis.max)); + } + + // handle zoomed range + if (axis.range && defined(axis.max)) { + axis.userMin = axis.min = mathMax(axis.min, axis.max - axis.range); // #618 + axis.userMax = axis.max; + + axis.range = null; // don't use it when running setExtremes + } + + // Hook for adjusting this.min and this.max. Used by bubble series. + if (axis.beforePadding) { + axis.beforePadding(); + } + + // adjust min and max for the minimum range + axis.adjustForMinRange(); + + // Pad the values to get clear of the chart's edges. To avoid tickInterval taking the padding + // into account, we do this after computing tick interval (#1337). + if (!categories && !axis.axisPointRange && !axis.usePercentage && !isLinked && defined(axis.min) && defined(axis.max)) { + length = axis.max - axis.min; + if (length) { + if (!defined(options.min) && !defined(axis.userMin) && minPadding && (axis.dataMin < 0 || !axis.ignoreMinPadding)) { + axis.min -= length * minPadding; + } + if (!defined(options.max) && !defined(axis.userMax) && maxPadding && (axis.dataMax > 0 || !axis.ignoreMaxPadding)) { + axis.max += length * maxPadding; + } + } + } + + // Stay within floor and ceiling + if (isNumber(options.floor)) { + axis.min = mathMax(axis.min, options.floor); + } + if (isNumber(options.ceiling)) { + axis.max = mathMin(axis.max, options.ceiling); + } + + // get tickInterval + if (axis.min === axis.max || axis.min === undefined || axis.max === undefined) { + axis.tickInterval = 1; + } else if (isLinked && !tickIntervalOption && + tickPixelIntervalOption === axis.linkedParent.options.tickPixelInterval) { + axis.tickInterval = axis.linkedParent.tickInterval; + } else { + axis.tickInterval = pick( + tickIntervalOption, + categories ? // for categoried axis, 1 is default, for linear axis use tickPix + 1 : + // don't let it be more than the data range + (axis.max - axis.min) * tickPixelIntervalOption / mathMax(axis.len, tickPixelIntervalOption) + ); + // For squished axes, set only two ticks + if (!defined(tickIntervalOption) && axis.len < tickPixelIntervalOption && !this.isRadial && + !this.isLog && !categories && startOnTick && endOnTick) { + keepTwoTicksOnly = true; + axis.tickInterval /= 4; // tick extremes closer to the real values + } + } + + // Now we're finished detecting min and max, crop and group series data. This + // is in turn needed in order to find tick positions in ordinal axes. + if (isXAxis && !secondPass) { + each(axis.series, function (series) { + series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax); + }); + } + + // set the translation factor used in translate function + axis.setAxisTranslation(true); + + // hook for ordinal axes and radial axes + if (axis.beforeSetTickPositions) { + axis.beforeSetTickPositions(); + } + + // hook for extensions, used in Highstock ordinal axes + if (axis.postProcessTickInterval) { + axis.tickInterval = axis.postProcessTickInterval(axis.tickInterval); + } + + // In column-like charts, don't cramp in more ticks than there are points (#1943) + if (axis.pointRange) { + axis.tickInterval = mathMax(axis.pointRange, axis.tickInterval); + } + + // Before normalizing the tick interval, handle minimum tick interval. This applies only if tickInterval is not defined. + if (!tickIntervalOption && axis.tickInterval < minTickIntervalOption) { + axis.tickInterval = minTickIntervalOption; + } + + // for linear axes, get magnitude and normalize the interval + if (!isDatetimeAxis && !isLog) { // linear + if (!tickIntervalOption) { + axis.tickInterval = normalizeTickInterval( + axis.tickInterval, + null, + getMagnitude(axis.tickInterval), + // If the tick interval is between 1 and 5 and the axis max is in the order of + // thousands, chances are we are dealing with years. Don't allow decimals. #3363. + pick(options.allowDecimals, !(axis.tickInterval > 1 && axis.tickInterval < 5 && axis.max > 1000 && axis.max < 9999)) + ); + } + } + + // get minorTickInterval + axis.minorTickInterval = options.minorTickInterval === 'auto' && axis.tickInterval ? + axis.tickInterval / 5 : options.minorTickInterval; + + // find the tick positions + axis.tickPositions = tickPositions = options.tickPositions ? + [].concat(options.tickPositions) : // Work on a copy (#1565) + (tickPositioner && tickPositioner.apply(axis, [axis.min, axis.max])); + if (!tickPositions) { + + // Too many ticks + if (!axis.ordinalPositions && (axis.max - axis.min) / axis.tickInterval > mathMax(2 * axis.len, 200)) { + error(19, true); + } + + if (isDatetimeAxis) { + tickPositions = axis.getTimeTicks( + axis.normalizeTimeTickInterval(axis.tickInterval, options.units), + axis.min, + axis.max, + options.startOfWeek, + axis.ordinalPositions, + axis.closestPointRange, + true + ); + } else if (isLog) { + tickPositions = axis.getLogTickPositions(axis.tickInterval, axis.min, axis.max); + } else { + tickPositions = axis.getLinearTickPositions(axis.tickInterval, axis.min, axis.max); + } + + if (keepTwoTicksOnly) { + tickPositions.splice(1, tickPositions.length - 2); + } + + axis.tickPositions = tickPositions; + } + + if (!isLinked) { + + // reset min/max or remove extremes based on start/end on tick + var roundedMin = tickPositions[0], + roundedMax = tickPositions[tickPositions.length - 1], + minPointOffset = axis.minPointOffset || 0, + singlePad; + + if (startOnTick) { + axis.min = roundedMin; + } else if (axis.min - minPointOffset > roundedMin) { + tickPositions.shift(); + } + + if (endOnTick) { + axis.max = roundedMax; + } else if (axis.max + minPointOffset < roundedMax) { + tickPositions.pop(); + } + + // If no tick are left, set one tick in the middle (#3195) + if (tickPositions.length === 0 && defined(roundedMin)) { + tickPositions.push((roundedMax + roundedMin) / 2); + } + + // When there is only one point, or all points have the same value on this axis, then min + // and max are equal and tickPositions.length is 0 or 1. In this case, add some padding + // in order to center the point, but leave it with one tick. #1337. + if (tickPositions.length === 1) { + singlePad = mathAbs(axis.max) > 10e12 ? 1 : 0.001; // The lowest possible number to avoid extra padding on columns (#2619, #2846) + axis.min -= singlePad; + axis.max += singlePad; + } + } + }, + + /** + * Set the max ticks of either the x and y axis collection + */ + setMaxTicks: function () { + + var chart = this.chart, + maxTicks = chart.maxTicks || {}, + tickPositions = this.tickPositions, + key = this._maxTicksKey = [this.coll, this.pos, this.len].join('-'); + + if (!this.isLinked && !this.isDatetimeAxis && tickPositions && tickPositions.length > (maxTicks[key] || 0) && this.options.alignTicks !== false) { + maxTicks[key] = tickPositions.length; + } + chart.maxTicks = maxTicks; + }, + + /** + * When using multiple axes, adjust the number of ticks to match the highest + * number of ticks in that group + */ + adjustTickAmount: function () { + var axis = this, + chart = axis.chart, + key = axis._maxTicksKey, + tickPositions = axis.tickPositions, + maxTicks = chart.maxTicks; + + if (maxTicks && maxTicks[key] && !axis.isDatetimeAxis && !axis.categories && !axis.isLinked && + axis.options.alignTicks !== false && this.min !== UNDEFINED) { + var oldTickAmount = axis.tickAmount, + calculatedTickAmount = tickPositions.length, + tickAmount; + + // set the axis-level tickAmount to use below + axis.tickAmount = tickAmount = maxTicks[key]; + + if (calculatedTickAmount < tickAmount) { + while (tickPositions.length < tickAmount) { + tickPositions.push(correctFloat( + tickPositions[tickPositions.length - 1] + axis.tickInterval + )); + } + axis.transA *= (calculatedTickAmount - 1) / (tickAmount - 1); + axis.max = tickPositions[tickPositions.length - 1]; + + } + if (defined(oldTickAmount) && tickAmount !== oldTickAmount) { + axis.isDirty = true; + } + } + }, + + /** + * Set the scale based on data min and max, user set min and max or options + * + */ + setScale: function () { + var axis = this, + stacks = axis.stacks, + type, + i, + isDirtyData, + isDirtyAxisLength; + + axis.oldMin = axis.min; + axis.oldMax = axis.max; + axis.oldAxisLength = axis.len; + + // set the new axisLength + axis.setAxisSize(); + //axisLength = horiz ? axisWidth : axisHeight; + isDirtyAxisLength = axis.len !== axis.oldAxisLength; + + // is there new data? + each(axis.series, function (series) { + if (series.isDirtyData || series.isDirty || + series.xAxis.isDirty) { // when x axis is dirty, we need new data extremes for y as well + isDirtyData = true; + } + }); + + // do we really need to go through all this? + if (isDirtyAxisLength || isDirtyData || axis.isLinked || axis.forceRedraw || + axis.userMin !== axis.oldUserMin || axis.userMax !== axis.oldUserMax) { + + // reset stacks + if (!axis.isXAxis) { + for (type in stacks) { + for (i in stacks[type]) { + stacks[type][i].total = null; + stacks[type][i].cum = 0; + } + } + } + + axis.forceRedraw = false; + + // get data extremes if needed + axis.getSeriesExtremes(); + + // get fixed positions based on tickInterval + axis.setTickPositions(); + + // record old values to decide whether a rescale is necessary later on (#540) + axis.oldUserMin = axis.userMin; + axis.oldUserMax = axis.userMax; + + // Mark as dirty if it is not already set to dirty and extremes have changed. #595. + if (!axis.isDirty) { + axis.isDirty = isDirtyAxisLength || axis.min !== axis.oldMin || axis.max !== axis.oldMax; + } + } else if (!axis.isXAxis) { + if (axis.oldStacks) { + stacks = axis.stacks = axis.oldStacks; + } + + // reset stacks + for (type in stacks) { + for (i in stacks[type]) { + stacks[type][i].cum = stacks[type][i].total; + } + } + } + + // Set the maximum tick amount + axis.setMaxTicks(); + }, + + /** + * Set the extremes and optionally redraw + * @param {Number} newMin + * @param {Number} newMax + * @param {Boolean} redraw + * @param {Boolean|Object} animation Whether to apply animation, and optionally animation + * configuration + * @param {Object} eventArguments + * + */ + setExtremes: function (newMin, newMax, redraw, animation, eventArguments) { + var axis = this, + chart = axis.chart; + + redraw = pick(redraw, true); // defaults to true + + // Extend the arguments with min and max + eventArguments = extend(eventArguments, { + min: newMin, + max: newMax + }); + + // Fire the event + fireEvent(axis, 'setExtremes', eventArguments, function () { // the default event handler + + axis.userMin = newMin; + axis.userMax = newMax; + axis.eventArgs = eventArguments; + + // Mark for running afterSetExtremes + axis.isDirtyExtremes = true; + + // redraw + if (redraw) { + chart.redraw(animation); + } + }); + }, + + /** + * Overridable method for zooming chart. Pulled out in a separate method to allow overriding + * in stock charts. + */ + zoom: function (newMin, newMax) { + var dataMin = this.dataMin, + dataMax = this.dataMax, + options = this.options; + + // Prevent pinch zooming out of range. Check for defined is for #1946. #1734. + if (!this.allowZoomOutside) { + if (defined(dataMin) && newMin <= mathMin(dataMin, pick(options.min, dataMin))) { + newMin = UNDEFINED; + } + if (defined(dataMax) && newMax >= mathMax(dataMax, pick(options.max, dataMax))) { + newMax = UNDEFINED; + } + } + + // In full view, displaying the reset zoom button is not required + this.displayBtn = newMin !== UNDEFINED || newMax !== UNDEFINED; + + // Do it + this.setExtremes( + newMin, + newMax, + false, + UNDEFINED, + { trigger: 'zoom' } + ); + return true; + }, + + /** + * Update the axis metrics + */ + setAxisSize: function () { + var chart = this.chart, + options = this.options, + offsetLeft = options.offsetLeft || 0, + offsetRight = options.offsetRight || 0, + horiz = this.horiz, + width = pick(options.width, chart.plotWidth - offsetLeft + offsetRight), + height = pick(options.height, chart.plotHeight), + top = pick(options.top, chart.plotTop), + left = pick(options.left, chart.plotLeft + offsetLeft), + percentRegex = /%$/; + + // Check for percentage based input values + if (percentRegex.test(height)) { + height = parseInt(height, 10) / 100 * chart.plotHeight; + } + if (percentRegex.test(top)) { + top = parseInt(top, 10) / 100 * chart.plotHeight + chart.plotTop; + } + + // Expose basic values to use in Series object and navigator + this.left = left; + this.top = top; + this.width = width; + this.height = height; + this.bottom = chart.chartHeight - height - top; + this.right = chart.chartWidth - width - left; + + // Direction agnostic properties + this.len = mathMax(horiz ? width : height, 0); // mathMax fixes #905 + this.pos = horiz ? left : top; // distance from SVG origin + }, + + /** + * Get the actual axis extremes + */ + getExtremes: function () { + var axis = this, + isLog = axis.isLog; + + return { + min: isLog ? correctFloat(lin2log(axis.min)) : axis.min, + max: isLog ? correctFloat(lin2log(axis.max)) : axis.max, + dataMin: axis.dataMin, + dataMax: axis.dataMax, + userMin: axis.userMin, + userMax: axis.userMax + }; + }, + + /** + * Get the zero plane either based on zero or on the min or max value. + * Used in bar and area plots + */ + getThreshold: function (threshold) { + var axis = this, + isLog = axis.isLog; + + var realMin = isLog ? lin2log(axis.min) : axis.min, + realMax = isLog ? lin2log(axis.max) : axis.max; + + if (realMin > threshold || threshold === null) { + threshold = realMin; + } else if (realMax < threshold) { + threshold = realMax; + } + + return axis.translate(threshold, 0, 1, 0, 1); + }, + + /** + * Compute auto alignment for the axis label based on which side the axis is on + * and the given rotation for the label + */ + autoLabelAlign: function (rotation) { + var ret, + angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360; + + if (angle > 15 && angle < 165) { + ret = 'right'; + } else if (angle > 195 && angle < 345) { + ret = 'left'; + } else { + ret = 'center'; + } + return ret; + }, + + /** + * Render the tick labels to a preliminary position to get their sizes + */ + getOffset: function () { + var axis = this, + chart = axis.chart, + renderer = chart.renderer, + options = axis.options, + tickPositions = axis.tickPositions, + ticks = axis.ticks, + horiz = axis.horiz, + side = axis.side, + invertedSide = chart.inverted ? [1, 0, 3, 2][side] : side, + hasData, + showAxis, + titleOffset = 0, + titleOffsetOption, + titleMargin = 0, + axisTitleOptions = options.title, + labelOptions = options.labels, + labelOffset = 0, // reset + labelOffsetPadded, + axisOffset = chart.axisOffset, + clipOffset = chart.clipOffset, + directionFactor = [-1, 1, 1, -1][side], + n, + i, + autoStaggerLines = 1, + maxStaggerLines = pick(labelOptions.maxStaggerLines, 5), + sortedPositions, + lastRight, + overlap, + pos, + bBox, + x, + w, + lineNo, + lineHeightCorrection; + + // For reuse in Axis.render + axis.hasData = hasData = (axis.hasVisibleSeries || (defined(axis.min) && defined(axis.max) && !!tickPositions)); + axis.showAxis = showAxis = hasData || pick(options.showEmpty, true); + + // Set/reset staggerLines + axis.staggerLines = axis.horiz && labelOptions.staggerLines; + + // Create the axisGroup and gridGroup elements on first iteration + if (!axis.axisGroup) { + axis.gridGroup = renderer.g('grid') + .attr({ zIndex: options.gridZIndex || 1 }) + .add(); + axis.axisGroup = renderer.g('axis') + .attr({ zIndex: options.zIndex || 2 }) + .add(); + axis.labelGroup = renderer.g('axis-labels') + .attr({ zIndex: labelOptions.zIndex || 7 }) + .addClass(PREFIX + axis.coll.toLowerCase() + '-labels') + .add(); + } + + if (hasData || axis.isLinked) { + + // Set the explicit or automatic label alignment + axis.labelAlign = pick(labelOptions.align || axis.autoLabelAlign(labelOptions.rotation)); + + // Generate ticks + each(tickPositions, function (pos) { + if (!ticks[pos]) { + ticks[pos] = new Tick(axis, pos); + } else { + ticks[pos].addLabel(); // update labels depending on tick interval + } + }); + + // Handle automatic stagger lines + if (axis.horiz && !axis.staggerLines && maxStaggerLines && !labelOptions.rotation) { + sortedPositions = axis.reversed ? [].concat(tickPositions).reverse() : tickPositions; + while (autoStaggerLines < maxStaggerLines) { + lastRight = []; + overlap = false; + + for (i = 0; i < sortedPositions.length; i++) { + pos = sortedPositions[i]; + bBox = ticks[pos].label && ticks[pos].label.getBBox(); + w = bBox ? bBox.width : 0; + lineNo = i % autoStaggerLines; + + if (w) { + x = axis.translate(pos); // don't handle log + if (lastRight[lineNo] !== UNDEFINED && x < lastRight[lineNo]) { + overlap = true; + } + lastRight[lineNo] = x + w; + } + } + if (overlap) { + autoStaggerLines++; + } else { + break; + } + } + + if (autoStaggerLines > 1) { + axis.staggerLines = autoStaggerLines; + } + } + + + each(tickPositions, function (pos) { + // left side must be align: right and right side must have align: left for labels + if (side === 0 || side === 2 || { 1: 'left', 3: 'right' }[side] === axis.labelAlign) { + + // get the highest offset + labelOffset = mathMax( + ticks[pos].getLabelSize(), + labelOffset + ); + } + }); + + if (axis.staggerLines) { + labelOffset *= axis.staggerLines; + axis.labelOffset = labelOffset; + } + + + } else { // doesn't have data + for (n in ticks) { + ticks[n].destroy(); + delete ticks[n]; + } + } + + if (axisTitleOptions && axisTitleOptions.text && axisTitleOptions.enabled !== false) { + if (!axis.axisTitle) { + axis.axisTitle = renderer.text( + axisTitleOptions.text, + 0, + 0, + axisTitleOptions.useHTML + ) + .attr({ + zIndex: 7, + rotation: axisTitleOptions.rotation || 0, + align: + axisTitleOptions.textAlign || + { low: 'left', middle: 'center', high: 'right' }[axisTitleOptions.align] + }) + .addClass(PREFIX + this.coll.toLowerCase() + '-title') + .css(axisTitleOptions.style) + .add(axis.axisGroup); + axis.axisTitle.isNew = true; + } + + if (showAxis) { + titleOffset = axis.axisTitle.getBBox()[horiz ? 'height' : 'width']; + titleOffsetOption = axisTitleOptions.offset; + titleMargin = defined(titleOffsetOption) ? 0 : pick(axisTitleOptions.margin, horiz ? 5 : 10); + } + + // hide or show the title depending on whether showEmpty is set + axis.axisTitle[showAxis ? 'show' : 'hide'](); + } + + // handle automatic or user set offset + axis.offset = directionFactor * pick(options.offset, axisOffset[side]); + + lineHeightCorrection = side === 2 ? axis.tickBaseline : 0; + labelOffsetPadded = labelOffset + titleMargin + + (labelOffset && (directionFactor * (horiz ? pick(labelOptions.y, axis.tickBaseline + 8) : labelOptions.x) - lineHeightCorrection)); + axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded); + + axisOffset[side] = mathMax( + axisOffset[side], + axis.axisTitleMargin + titleOffset + directionFactor * axis.offset, + labelOffsetPadded // #3027 + ); + clipOffset[invertedSide] = mathMax(clipOffset[invertedSide], mathFloor(options.lineWidth / 2) * 2); + }, + + /** + * Get the path for the axis line + */ + getLinePath: function (lineWidth) { + var chart = this.chart, + opposite = this.opposite, + offset = this.offset, + horiz = this.horiz, + lineLeft = this.left + (opposite ? this.width : 0) + offset, + lineTop = chart.chartHeight - this.bottom - (opposite ? this.height : 0) + offset; + + if (opposite) { + lineWidth *= -1; // crispify the other way - #1480, #1687 + } + + return chart.renderer.crispLine([ + M, + horiz ? + this.left : + lineLeft, + horiz ? + lineTop : + this.top, + L, + horiz ? + chart.chartWidth - this.right : + lineLeft, + horiz ? + lineTop : + chart.chartHeight - this.bottom + ], lineWidth); + }, + + /** + * Position the title + */ + getTitlePosition: function () { + // compute anchor points for each of the title align options + var horiz = this.horiz, + axisLeft = this.left, + axisTop = this.top, + axisLength = this.len, + axisTitleOptions = this.options.title, + margin = horiz ? axisLeft : axisTop, + opposite = this.opposite, + offset = this.offset, + fontSize = pInt(axisTitleOptions.style.fontSize || 12), + + // the position in the length direction of the axis + alongAxis = { + low: margin + (horiz ? 0 : axisLength), + middle: margin + axisLength / 2, + high: margin + (horiz ? axisLength : 0) + }[axisTitleOptions.align], + + // the position in the perpendicular direction of the axis + offAxis = (horiz ? axisTop + this.height : axisLeft) + + (horiz ? 1 : -1) * // horizontal axis reverses the margin + (opposite ? -1 : 1) * // so does opposite axes + this.axisTitleMargin + + (this.side === 2 ? fontSize : 0); + + return { + x: horiz ? + alongAxis : + offAxis + (opposite ? this.width : 0) + offset + + (axisTitleOptions.x || 0), // x + y: horiz ? + offAxis - (opposite ? this.height : 0) + offset : + alongAxis + (axisTitleOptions.y || 0) // y + }; + }, + + /** + * Render the axis + */ + render: function () { + var axis = this, + horiz = axis.horiz, + reversed = axis.reversed, + chart = axis.chart, + renderer = chart.renderer, + options = axis.options, + isLog = axis.isLog, + isLinked = axis.isLinked, + tickPositions = axis.tickPositions, + sortedPositions, + axisTitle = axis.axisTitle, + ticks = axis.ticks, + minorTicks = axis.minorTicks, + alternateBands = axis.alternateBands, + stackLabelOptions = options.stackLabels, + alternateGridColor = options.alternateGridColor, + tickmarkOffset = axis.tickmarkOffset, + lineWidth = options.lineWidth, + linePath, + hasRendered = chart.hasRendered, + slideInTicks = hasRendered && defined(axis.oldMin) && !isNaN(axis.oldMin), + hasData = axis.hasData, + showAxis = axis.showAxis, + from, + overflow = options.labels.overflow, + justifyLabels = axis.justifyLabels = horiz && overflow !== false, + to; + + // Reset + axis.labelEdge.length = 0; + axis.justifyToPlot = overflow === 'justify'; + + // Mark all elements inActive before we go over and mark the active ones + each([ticks, minorTicks, alternateBands], function (coll) { + var pos; + for (pos in coll) { + coll[pos].isActive = false; + } + }); + + // If the series has data draw the ticks. Else only the line and title + if (hasData || isLinked) { + + // minor ticks + if (axis.minorTickInterval && !axis.categories) { + each(axis.getMinorTickPositions(), function (pos) { + if (!minorTicks[pos]) { + minorTicks[pos] = new Tick(axis, pos, 'minor'); + } + + // render new ticks in old position + if (slideInTicks && minorTicks[pos].isNew) { + minorTicks[pos].render(null, true); + } + + minorTicks[pos].render(null, false, 1); + }); + } + + // Major ticks. Pull out the first item and render it last so that + // we can get the position of the neighbour label. #808. + if (tickPositions.length) { // #1300 + sortedPositions = tickPositions.slice(); + if ((horiz && reversed) || (!horiz && !reversed)) { + sortedPositions.reverse(); + } + if (justifyLabels) { + sortedPositions = sortedPositions.slice(1).concat([sortedPositions[0]]); + } + each(sortedPositions, function (pos, i) { + + // Reorganize the indices + if (justifyLabels) { + i = (i === sortedPositions.length - 1) ? 0 : i + 1; + } + + // linked axes need an extra check to find out if + if (!isLinked || (pos >= axis.min && pos <= axis.max)) { + + if (!ticks[pos]) { + ticks[pos] = new Tick(axis, pos); + } + + // render new ticks in old position + if (slideInTicks && ticks[pos].isNew) { + ticks[pos].render(i, true, 0.1); + } + + ticks[pos].render(i); + } + + }); + // In a categorized axis, the tick marks are displayed between labels. So + // we need to add a tick mark and grid line at the left edge of the X axis. + if (tickmarkOffset && axis.min === 0) { + if (!ticks[-1]) { + ticks[-1] = new Tick(axis, -1, null, true); + } + ticks[-1].render(-1); + } + + } + + // alternate grid color + if (alternateGridColor) { + each(tickPositions, function (pos, i) { + if (i % 2 === 0 && pos < axis.max) { + if (!alternateBands[pos]) { + alternateBands[pos] = new Highcharts.PlotLineOrBand(axis); + } + from = pos + tickmarkOffset; // #949 + to = tickPositions[i + 1] !== UNDEFINED ? tickPositions[i + 1] + tickmarkOffset : axis.max; + alternateBands[pos].options = { + from: isLog ? lin2log(from) : from, + to: isLog ? lin2log(to) : to, + color: alternateGridColor + }; + alternateBands[pos].render(); + alternateBands[pos].isActive = true; + } + }); + } + + // custom plot lines and bands + if (!axis._addedPlotLB) { // only first time + each((options.plotLines || []).concat(options.plotBands || []), function (plotLineOptions) { + axis.addPlotBandOrLine(plotLineOptions); + }); + axis._addedPlotLB = true; + } + + } // end if hasData + + // Remove inactive ticks + each([ticks, minorTicks, alternateBands], function (coll) { + var pos, + i, + forDestruction = [], + delay = globalAnimation ? globalAnimation.duration || 500 : 0, + destroyInactiveItems = function () { + i = forDestruction.length; + while (i--) { + // When resizing rapidly, the same items may be destroyed in different timeouts, + // or the may be reactivated + if (coll[forDestruction[i]] && !coll[forDestruction[i]].isActive) { + coll[forDestruction[i]].destroy(); + delete coll[forDestruction[i]]; + } + } + + }; + + for (pos in coll) { + + if (!coll[pos].isActive) { + // Render to zero opacity + coll[pos].render(pos, false, 0); + coll[pos].isActive = false; + forDestruction.push(pos); + } + } + + // When the objects are finished fading out, destroy them + if (coll === alternateBands || !chart.hasRendered || !delay) { + destroyInactiveItems(); + } else if (delay) { + setTimeout(destroyInactiveItems, delay); + } + }); + + // Static items. As the axis group is cleared on subsequent calls + // to render, these items are added outside the group. + // axis line + if (lineWidth) { + linePath = axis.getLinePath(lineWidth); + if (!axis.axisLine) { + axis.axisLine = renderer.path(linePath) + .attr({ + stroke: options.lineColor, + 'stroke-width': lineWidth, + zIndex: 7 + }) + .add(axis.axisGroup); + } else { + axis.axisLine.animate({ d: linePath }); + } + + // show or hide the line depending on options.showEmpty + axis.axisLine[showAxis ? 'show' : 'hide'](); + } + + if (axisTitle && showAxis) { + + axisTitle[axisTitle.isNew ? 'attr' : 'animate']( + axis.getTitlePosition() + ); + axisTitle.isNew = false; + } + + // Stacked totals: + if (stackLabelOptions && stackLabelOptions.enabled) { + axis.renderStackTotals(); + } + // End stacked totals + + axis.isDirty = false; + }, + + /** + * Redraw the axis to reflect changes in the data or axis extremes + */ + redraw: function () { + + // render the axis + this.render(); + + // move plot lines and bands + each(this.plotLinesAndBands, function (plotLine) { + plotLine.render(); + }); + + // mark associated series as dirty and ready for redraw + each(this.series, function (series) { + series.isDirty = true; + }); + + }, + + /** + * Destroys an Axis instance. + */ + destroy: function (keepEvents) { + var axis = this, + stacks = axis.stacks, + stackKey, + plotLinesAndBands = axis.plotLinesAndBands, + i; + + // Remove the events + if (!keepEvents) { + removeEvent(axis); + } + + // Destroy each stack total + for (stackKey in stacks) { + destroyObjectProperties(stacks[stackKey]); + + stacks[stackKey] = null; + } + + // Destroy collections + each([axis.ticks, axis.minorTicks, axis.alternateBands], function (coll) { + destroyObjectProperties(coll); + }); + i = plotLinesAndBands.length; + while (i--) { // #1975 + plotLinesAndBands[i].destroy(); + } + + // Destroy local variables + each(['stackTotalGroup', 'axisLine', 'axisTitle', 'axisGroup', 'cross', 'gridGroup', 'labelGroup'], function (prop) { + if (axis[prop]) { + axis[prop] = axis[prop].destroy(); + } + }); + + // Destroy crosshair + if (this.cross) { + this.cross.destroy(); + } + }, + + /** + * Draw the crosshair + */ + drawCrosshair: function (e, point) { + if (!this.crosshair) { return; }// Do not draw crosshairs if you don't have too. + + if ((defined(point) || !pick(this.crosshair.snap, true)) === false) { + this.hideCrosshair(); + return; + } + + var path, + options = this.crosshair, + animation = options.animation, + pos; + + // Get the path + if (!pick(options.snap, true)) { + pos = (this.horiz ? e.chartX - this.pos : this.len - e.chartY + this.pos); + } else if (defined(point)) { + /*jslint eqeq: true*/ + pos = (this.chart.inverted != this.horiz) ? point.plotX : this.len - point.plotY; + /*jslint eqeq: false*/ + } + + if (this.isRadial) { + path = this.getPlotLinePath(this.isXAxis ? point.x : pick(point.stackY, point.y)); + } else { + path = this.getPlotLinePath(null, null, null, null, pos); + } + + if (path === null) { + this.hideCrosshair(); + return; + } + + // Draw the cross + if (this.cross) { + this.cross + .attr({ visibility: VISIBLE })[animation ? 'animate' : 'attr']({ d: path }, animation); + } else { + var attribs = { + 'stroke-width': options.width || 1, + stroke: options.color || '#C0C0C0', + zIndex: options.zIndex || 2 + }; + if (options.dashStyle) { + attribs.dashstyle = options.dashStyle; + } + this.cross = this.chart.renderer.path(path).attr(attribs).add(); + } + }, + + /** + * Hide the crosshair. + */ + hideCrosshair: function () { + if (this.cross) { + this.cross.hide(); + } + } +}; // end Axis + +extend(Axis.prototype, AxisPlotLineOrBandExtension); + +/** + * Set the tick positions to a time unit that makes sense, for example + * on the first of each month or on every Monday. Return an array + * with the time positions. Used in datetime axes as well as for grouping + * data on a datetime axis. + * + * @param {Object} normalizedInterval The interval in axis values (ms) and the count + * @param {Number} min The minimum in axis values + * @param {Number} max The maximum in axis values + * @param {Number} startOfWeek + */ +Axis.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) { + var tickPositions = [], + i, + higherRanks = {}, + useUTC = defaultOptions.global.useUTC, + minYear, // used in months and years as a basis for Date.UTC() + minDate = new Date(min - timezoneOffset), + interval = normalizedInterval.unitRange, + count = normalizedInterval.count; + + if (defined(min)) { // #1300 + if (interval >= timeUnits.second) { // second + minDate.setMilliseconds(0); + minDate.setSeconds(interval >= timeUnits.minute ? 0 : + count * mathFloor(minDate.getSeconds() / count)); + } + + if (interval >= timeUnits.minute) { // minute + minDate[setMinutes](interval >= timeUnits.hour ? 0 : + count * mathFloor(minDate[getMinutes]() / count)); + } + + if (interval >= timeUnits.hour) { // hour + minDate[setHours](interval >= timeUnits.day ? 0 : + count * mathFloor(minDate[getHours]() / count)); + } + + if (interval >= timeUnits.day) { // day + minDate[setDate](interval >= timeUnits.month ? 1 : + count * mathFloor(minDate[getDate]() / count)); + } + + if (interval >= timeUnits.month) { // month + minDate[setMonth](interval >= timeUnits.year ? 0 : + count * mathFloor(minDate[getMonth]() / count)); + minYear = minDate[getFullYear](); + } + + if (interval >= timeUnits.year) { // year + minYear -= minYear % count; + minDate[setFullYear](minYear); + } + + // week is a special case that runs outside the hierarchy + if (interval === timeUnits.week) { + // get start of current week, independent of count + minDate[setDate](minDate[getDate]() - minDate[getDay]() + + pick(startOfWeek, 1)); + } + + + // get tick positions + i = 1; + if (timezoneOffset) { + minDate = new Date(minDate.getTime() + timezoneOffset); + } + minYear = minDate[getFullYear](); + var time = minDate.getTime(), + minMonth = minDate[getMonth](), + minDateDate = minDate[getDate](), + localTimezoneOffset = (timeUnits.day + + (useUTC ? timezoneOffset : minDate.getTimezoneOffset() * 60 * 1000) + ) % timeUnits.day; // #950, #3359 + + // iterate and add tick positions at appropriate values + while (time < max) { + tickPositions.push(time); + + // if the interval is years, use Date.UTC to increase years + if (interval === timeUnits.year) { + time = makeTime(minYear + i * count, 0); + + // if the interval is months, use Date.UTC to increase months + } else if (interval === timeUnits.month) { + time = makeTime(minYear, minMonth + i * count); + + // if we're using global time, the interval is not fixed as it jumps + // one hour at the DST crossover + } else if (!useUTC && (interval === timeUnits.day || interval === timeUnits.week)) { + time = makeTime(minYear, minMonth, minDateDate + + i * count * (interval === timeUnits.day ? 1 : 7)); + + // else, the interval is fixed and we use simple addition + } else { + time += interval * count; + } + + i++; + } + + // push the last time + tickPositions.push(time); + + + // mark new days if the time is dividible by day (#1649, #1760) + each(grep(tickPositions, function (time) { + return interval <= timeUnits.hour && time % timeUnits.day === localTimezoneOffset; + }), function (time) { + higherRanks[time] = 'day'; + }); + } + + + // record information on the chosen unit - for dynamic label formatter + tickPositions.info = extend(normalizedInterval, { + higherRanks: higherRanks, + totalRange: interval * count + }); + + return tickPositions; +}; + +/** + * Get a normalized tick interval for dates. Returns a configuration object with + * unit range (interval), count and name. Used to prepare data for getTimeTicks. + * Previously this logic was part of getTimeTicks, but as getTimeTicks now runs + * of segments in stock charts, the normalizing logic was extracted in order to + * prevent it for running over again for each segment having the same interval. + * #662, #697. + */ +Axis.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) { + var units = unitsOption || [[ + 'millisecond', // unit name + [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples + ], [ + 'second', + [1, 2, 5, 10, 15, 30] + ], [ + 'minute', + [1, 2, 5, 10, 15, 30] + ], [ + 'hour', + [1, 2, 3, 4, 6, 8, 12] + ], [ + 'day', + [1, 2] + ], [ + 'week', + [1, 2] + ], [ + 'month', + [1, 2, 3, 4, 6] + ], [ + 'year', + null + ]], + unit = units[units.length - 1], // default unit is years + interval = timeUnits[unit[0]], + multiples = unit[1], + count, + i; + + // loop through the units to find the one that best fits the tickInterval + for (i = 0; i < units.length; i++) { + unit = units[i]; + interval = timeUnits[unit[0]]; + multiples = unit[1]; + + + if (units[i + 1]) { + // lessThan is in the middle between the highest multiple and the next unit. + var lessThan = (interval * multiples[multiples.length - 1] + + timeUnits[units[i + 1][0]]) / 2; + + // break and keep the current unit + if (tickInterval <= lessThan) { + break; + } + } + } + + // prevent 2.5 years intervals, though 25, 250 etc. are allowed + if (interval === timeUnits.year && tickInterval < 5 * interval) { + multiples = [1, 2, 5]; + } + + // get the count + count = normalizeTickInterval( + tickInterval / interval, + multiples, + unit[0] === 'year' ? mathMax(getMagnitude(tickInterval / interval), 1) : 1 // #1913, #2360 + ); + + return { + unitRange: interval, + count: count, + unitName: unit[0] + }; +};/** + * Methods defined on the Axis prototype + */ + +/** + * Set the tick positions of a logarithmic axis + */ +Axis.prototype.getLogTickPositions = function (interval, min, max, minor) { + var axis = this, + options = axis.options, + axisLength = axis.len, + // Since we use this method for both major and minor ticks, + // use a local variable and return the result + positions = []; + + // Reset + if (!minor) { + axis._minorAutoInterval = null; + } + + // First case: All ticks fall on whole logarithms: 1, 10, 100 etc. + if (interval >= 0.5) { + interval = mathRound(interval); + positions = axis.getLinearTickPositions(interval, min, max); + + // Second case: We need intermediary ticks. For example + // 1, 2, 4, 6, 8, 10, 20, 40 etc. + } else if (interval >= 0.08) { + var roundedMin = mathFloor(min), + intermediate, + i, + j, + len, + pos, + lastPos, + break2; + + if (interval > 0.3) { + intermediate = [1, 2, 4]; + } else if (interval > 0.15) { // 0.2 equals five minor ticks per 1, 10, 100 etc + intermediate = [1, 2, 4, 6, 8]; + } else { // 0.1 equals ten minor ticks per 1, 10, 100 etc + intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + } + + for (i = roundedMin; i < max + 1 && !break2; i++) { + len = intermediate.length; + for (j = 0; j < len && !break2; j++) { + pos = log2lin(lin2log(i) * intermediate[j]); + if (pos > min && (!minor || lastPos <= max) && lastPos !== UNDEFINED) { // #1670, lastPos is #3113 + positions.push(lastPos); + } + + if (lastPos > max) { + break2 = true; + } + lastPos = pos; + } + } + + // Third case: We are so deep in between whole logarithmic values that + // we might as well handle the tick positions like a linear axis. For + // example 1.01, 1.02, 1.03, 1.04. + } else { + var realMin = lin2log(min), + realMax = lin2log(max), + tickIntervalOption = options[minor ? 'minorTickInterval' : 'tickInterval'], + filteredTickIntervalOption = tickIntervalOption === 'auto' ? null : tickIntervalOption, + tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1), + totalPixelLength = minor ? axisLength / axis.tickPositions.length : axisLength; + + interval = pick( + filteredTickIntervalOption, + axis._minorAutoInterval, + (realMax - realMin) * tickPixelIntervalOption / (totalPixelLength || 1) + ); + + interval = normalizeTickInterval( + interval, + null, + getMagnitude(interval) + ); + + positions = map(axis.getLinearTickPositions( + interval, + realMin, + realMax + ), log2lin); + + if (!minor) { + axis._minorAutoInterval = interval / 5; + } + } + + // Set the axis-level tickInterval variable + if (!minor) { + axis.tickInterval = interval; + } + return positions; +};/** + * The tooltip object + * @param {Object} chart The chart instance + * @param {Object} options Tooltip options + */ +var Tooltip = Highcharts.Tooltip = function () { + this.init.apply(this, arguments); +}; + +Tooltip.prototype = { + + init: function (chart, options) { + + var borderWidth = options.borderWidth, + style = options.style, + padding = pInt(style.padding); + + // Save the chart and options + this.chart = chart; + this.options = options; + + // Keep track of the current series + //this.currentSeries = UNDEFINED; + + // List of crosshairs + this.crosshairs = []; + + // Current values of x and y when animating + this.now = { x: 0, y: 0 }; + + // The tooltip is initially hidden + this.isHidden = true; + + + // create the label + this.label = chart.renderer.label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, 'tooltip') + .attr({ + padding: padding, + fill: options.backgroundColor, + 'stroke-width': borderWidth, + r: options.borderRadius, + zIndex: 8 + }) + .css(style) + .css({ padding: 0 }) // Remove it from VML, the padding is applied as an attribute instead (#1117) + .add() + .attr({ y: -9999 }); // #2301, #2657 + + // When using canVG the shadow shows up as a gray circle + // even if the tooltip is hidden. + if (!useCanVG) { + this.label.shadow(options.shadow); + } + + // Public property for getting the shared state. + this.shared = options.shared; + }, + + /** + * Destroy the tooltip and its elements. + */ + destroy: function () { + // Destroy and clear local variables + if (this.label) { + this.label = this.label.destroy(); + } + clearTimeout(this.hideTimer); + clearTimeout(this.tooltipTimeout); + }, + + /** + * Provide a soft movement for the tooltip + * + * @param {Number} x + * @param {Number} y + * @private + */ + move: function (x, y, anchorX, anchorY) { + var tooltip = this, + now = tooltip.now, + animate = tooltip.options.animation !== false && !tooltip.isHidden && + // When we get close to the target position, abort animation and land on the right place (#3056) + (mathAbs(x - now.x) > 1 || mathAbs(y - now.y) > 1), + skipAnchor = tooltip.followPointer || tooltip.len > 1; + + // Get intermediate values for animation + extend(now, { + x: animate ? (2 * now.x + x) / 3 : x, + y: animate ? (now.y + y) / 2 : y, + anchorX: skipAnchor ? UNDEFINED : animate ? (2 * now.anchorX + anchorX) / 3 : anchorX, + anchorY: skipAnchor ? UNDEFINED : animate ? (now.anchorY + anchorY) / 2 : anchorY + }); + + // Move to the intermediate value + tooltip.label.attr(now); + + + // Run on next tick of the mouse tracker + if (animate) { + + // Never allow two timeouts + clearTimeout(this.tooltipTimeout); + + // Set the fixed interval ticking for the smooth tooltip + this.tooltipTimeout = setTimeout(function () { + // The interval function may still be running during destroy, so check that the chart is really there before calling. + if (tooltip) { + tooltip.move(x, y, anchorX, anchorY); + } + }, 32); + + } + }, + + /** + * Hide the tooltip + */ + hide: function (delay) { + var tooltip = this, + hoverPoints; + + clearTimeout(this.hideTimer); // disallow duplicate timers (#1728, #1766) + if (!this.isHidden) { + hoverPoints = this.chart.hoverPoints; + + this.hideTimer = setTimeout(function () { + tooltip.label.fadeOut(); + tooltip.isHidden = true; + }, pick(delay, this.options.hideDelay, 500)); + + // hide previous hoverPoints and set new + if (hoverPoints) { + each(hoverPoints, function (point) { + point.setState(); + }); + } + + this.chart.hoverPoints = null; + } + }, + + /** + * Extendable method to get the anchor position of the tooltip + * from a point or set of points + */ + getAnchor: function (points, mouseEvent) { + var ret, + chart = this.chart, + inverted = chart.inverted, + plotTop = chart.plotTop, + plotX = 0, + plotY = 0, + yAxis; + + points = splat(points); + + // Pie uses a special tooltipPos + ret = points[0].tooltipPos; + + // When tooltip follows mouse, relate the position to the mouse + if (this.followPointer && mouseEvent) { + if (mouseEvent.chartX === UNDEFINED) { + mouseEvent = chart.pointer.normalize(mouseEvent); + } + ret = [ + mouseEvent.chartX - chart.plotLeft, + mouseEvent.chartY - plotTop + ]; + } + // When shared, use the average position + if (!ret) { + each(points, function (point) { + yAxis = point.series.yAxis; + plotX += point.plotX; + plotY += (point.plotLow ? (point.plotLow + point.plotHigh) / 2 : point.plotY) + + (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151 + }); + + plotX /= points.length; + plotY /= points.length; + + ret = [ + inverted ? chart.plotWidth - plotY : plotX, + this.shared && !inverted && points.length > 1 && mouseEvent ? + mouseEvent.chartY - plotTop : // place shared tooltip next to the mouse (#424) + inverted ? chart.plotHeight - plotX : plotY + ]; + } + + return map(ret, mathRound); + }, + + /** + * Place the tooltip in a chart without spilling over + * and not covering the point it self. + */ + getPosition: function (boxWidth, boxHeight, point) { + + var chart = this.chart, + distance = this.distance, + ret = {}, + swapped, + first = ['y', chart.chartHeight, boxHeight, point.plotY + chart.plotTop], + second = ['x', chart.chartWidth, boxWidth, point.plotX + chart.plotLeft], + // The far side is right or bottom + preferFarSide = point.ttBelow || (chart.inverted && !point.negative) || (!chart.inverted && point.negative), + /** + * Handle the preferred dimension. When the preferred dimension is tooltip + * on top or bottom of the point, it will look for space there. + */ + firstDimension = function (dim, outerSize, innerSize, point) { + var roomLeft = innerSize < point - distance, + roomRight = point + distance + innerSize < outerSize, + alignedLeft = point - distance - innerSize, + alignedRight = point + distance; + + if (preferFarSide && roomRight) { + ret[dim] = alignedRight; + } else if (!preferFarSide && roomLeft) { + ret[dim] = alignedLeft; + } else if (roomLeft) { + ret[dim] = alignedLeft; + } else if (roomRight) { + ret[dim] = alignedRight; + } else { + return false; + } + }, + /** + * Handle the secondary dimension. If the preferred dimension is tooltip + * on top or bottom of the point, the second dimension is to align the tooltip + * above the point, trying to align center but allowing left or right + * align within the chart box. + */ + secondDimension = function (dim, outerSize, innerSize, point) { + // Too close to the edge, return false and swap dimensions + if (point < distance || point > outerSize - distance) { + return false; + + // Align left/top + } else if (point < innerSize / 2) { + ret[dim] = 1; + // Align right/bottom + } else if (point > outerSize - innerSize / 2) { + ret[dim] = outerSize - innerSize - 2; + // Align center + } else { + ret[dim] = point - innerSize / 2; + } + }, + /** + * Swap the dimensions + */ + swap = function (count) { + var temp = first; + first = second; + second = temp; + swapped = count; + }, + run = function () { + if (firstDimension.apply(0, first) !== false) { + if (secondDimension.apply(0, second) === false && !swapped) { + swap(true); + run(); + } + } else if (!swapped) { + swap(true); + run(); + } else { + ret.x = ret.y = 0; + } + }; + + // Under these conditions, prefer the tooltip on the side of the point + if (chart.inverted || this.len > 1) { + swap(); + } + run(); + + return ret; + + }, + + /** + * In case no user defined formatter is given, this will be used. Note that the context + * here is an object holding point, series, x, y etc. + */ + defaultFormatter: function (tooltip) { + var items = this.points || splat(this), + series = items[0].series, + s; + + // build the header + s = [tooltip.tooltipHeaderFormatter(items[0])]; + + // build the values + each(items, function (item) { + series = item.series; + s.push((series.tooltipFormatter && series.tooltipFormatter(item)) || + item.point.tooltipFormatter(series.tooltipOptions.pointFormat)); + }); + + // footer + s.push(tooltip.options.footerFormat || ''); + + return s.join(''); + }, + + /** + * Refresh the tooltip's text and position. + * @param {Object} point + */ + refresh: function (point, mouseEvent) { + var tooltip = this, + chart = tooltip.chart, + label = tooltip.label, + options = tooltip.options, + x, + y, + anchor, + textConfig = {}, + text, + pointConfig = [], + formatter = options.formatter || tooltip.defaultFormatter, + hoverPoints = chart.hoverPoints, + borderColor, + shared = tooltip.shared, + currentSeries; + + clearTimeout(this.hideTimer); + + // get the reference point coordinates (pie charts use tooltipPos) + tooltip.followPointer = splat(point)[0].series.tooltipOptions.followPointer; + anchor = tooltip.getAnchor(point, mouseEvent); + x = anchor[0]; + y = anchor[1]; + + // shared tooltip, array is sent over + if (shared && !(point.series && point.series.noSharedTooltip)) { + + // hide previous hoverPoints and set new + + chart.hoverPoints = point; + if (hoverPoints) { + each(hoverPoints, function (point) { + point.setState(); + }); + } + + each(point, function (item) { + item.setState(HOVER_STATE); + + pointConfig.push(item.getLabelConfig()); + }); + + textConfig = { + x: point[0].category, + y: point[0].y + }; + textConfig.points = pointConfig; + this.len = pointConfig.length; + point = point[0]; + + // single point tooltip + } else { + textConfig = point.getLabelConfig(); + } + text = formatter.call(textConfig, tooltip); + + // register the current series + currentSeries = point.series; + this.distance = pick(currentSeries.tooltipOptions.distance, 16); + + // update the inner HTML + if (text === false) { + this.hide(); + } else { + + // show it + if (tooltip.isHidden) { + stop(label); + label.attr('opacity', 1).show(); + } + + // update text + label.attr({ + text: text + }); + + // set the stroke color of the box + borderColor = options.borderColor || point.color || currentSeries.color || '#606060'; + label.attr({ + stroke: borderColor + }); + + tooltip.updatePosition({ plotX: x, plotY: y, negative: point.negative, ttBelow: point.ttBelow }); + + this.isHidden = false; + } + fireEvent(chart, 'tooltipRefresh', { + text: text, + x: x + chart.plotLeft, + y: y + chart.plotTop, + borderColor: borderColor + }); + }, + + /** + * Find the new position and perform the move + */ + updatePosition: function (point) { + var chart = this.chart, + label = this.label, + pos = (this.options.positioner || this.getPosition).call( + this, + label.width, + label.height, + point + ); + + // do the move + this.move( + mathRound(pos.x), + mathRound(pos.y), + point.plotX + chart.plotLeft, + point.plotY + chart.plotTop + ); + }, + + + /** + * Format the header of the tooltip + */ + tooltipHeaderFormatter: function (point) { + var series = point.series, + tooltipOptions = series.tooltipOptions, + dateTimeLabelFormats = tooltipOptions.dateTimeLabelFormats, + xDateFormat = tooltipOptions.xDateFormat, + xAxis = series.xAxis, + isDateTime = xAxis && xAxis.options.type === 'datetime' && isNumber(point.key), + headerFormat = tooltipOptions.headerFormat, + closestPointRange = xAxis && xAxis.closestPointRange, + n; + + // Guess the best date format based on the closest point distance (#568) + if (isDateTime && !xDateFormat) { + if (closestPointRange) { + for (n in timeUnits) { + if (timeUnits[n] >= closestPointRange || + // If the point is placed every day at 23:59, we need to show + // the minutes as well. This logic only works for time units less than + // a day, since all higher time units are dividable by those. #2637. + (timeUnits[n] <= timeUnits.day && point.key % timeUnits[n] > 0)) { + xDateFormat = dateTimeLabelFormats[n]; + break; + } + } + } else { + xDateFormat = dateTimeLabelFormats.day; + } + + xDateFormat = xDateFormat || dateTimeLabelFormats.year; // #2546, 2581 + + } + + // Insert the header date format if any + if (isDateTime && xDateFormat) { + headerFormat = headerFormat.replace('{point.key}', '{point.key:' + xDateFormat + '}'); + } + + return format(headerFormat, { + point: point, + series: series + }); + } +}; + +var hoverChartIndex; + +// Global flag for touch support +hasTouch = doc.documentElement.ontouchstart !== UNDEFINED; + +/** + * The mouse tracker object. All methods starting with "on" are primary DOM event handlers. + * Subsequent methods should be named differently from what they are doing. + * @param {Object} chart The Chart instance + * @param {Object} options The root options object + */ +var Pointer = Highcharts.Pointer = function (chart, options) { + this.init(chart, options); +}; + +Pointer.prototype = { + /** + * Initialize Pointer + */ + init: function (chart, options) { + + var chartOptions = options.chart, + chartEvents = chartOptions.events, + zoomType = useCanVG ? '' : chartOptions.zoomType, + inverted = chart.inverted, + zoomX, + zoomY; + + // Store references + this.options = options; + this.chart = chart; + + // Zoom status + this.zoomX = zoomX = /x/.test(zoomType); + this.zoomY = zoomY = /y/.test(zoomType); + this.zoomHor = (zoomX && !inverted) || (zoomY && inverted); + this.zoomVert = (zoomY && !inverted) || (zoomX && inverted); + this.hasZoom = zoomX || zoomY; + + // Do we need to handle click on a touch device? + this.runChartClick = chartEvents && !!chartEvents.click; + + this.pinchDown = []; + this.lastValidTouch = {}; + + if (Highcharts.Tooltip && options.tooltip.enabled) { + chart.tooltip = new Tooltip(chart, options.tooltip); + this.followTouchMove = options.tooltip.followTouchMove; + } + + this.setDOMEvents(); + }, + + /** + * Add crossbrowser support for chartX and chartY + * @param {Object} e The event object in standard browsers + */ + normalize: function (e, chartPosition) { + var chartX, + chartY, + ePos; + + // common IE normalizing + e = e || window.event; + + // Framework specific normalizing (#1165) + e = washMouseEvent(e); + + // More IE normalizing, needs to go after washMouseEvent + if (!e.target) { + e.target = e.srcElement; + } + + // iOS (#2757) + ePos = e.touches ? (e.touches.length ? e.touches.item(0) : e.changedTouches[0]) : e; + + // Get mouse position + if (!chartPosition) { + this.chartPosition = chartPosition = offset(this.chart.container); + } + + // chartX and chartY + if (ePos.pageX === UNDEFINED) { // IE < 9. #886. + chartX = mathMax(e.x, e.clientX - chartPosition.left); // #2005, #2129: the second case is + // for IE10 quirks mode within framesets + chartY = e.y; + } else { + chartX = ePos.pageX - chartPosition.left; + chartY = ePos.pageY - chartPosition.top; + } + + return extend(e, { + chartX: mathRound(chartX), + chartY: mathRound(chartY) + }); + }, + + /** + * Get the click position in terms of axis values. + * + * @param {Object} e A pointer event + */ + getCoordinates: function (e) { + var coordinates = { + xAxis: [], + yAxis: [] + }; + + each(this.chart.axes, function (axis) { + coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({ + axis: axis, + value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY']) + }); + }); + return coordinates; + }, + + /** + * Return the index in the tooltipPoints array, corresponding to pixel position in + * the plot area. + */ + getIndex: function (e) { + var chart = this.chart; + return chart.inverted ? + chart.plotHeight + chart.plotTop - e.chartY : + e.chartX - chart.plotLeft; + }, + + /** + * With line type charts with a single tracker, get the point closest to the mouse. + * Run Point.onMouseOver and display tooltip for the point or points. + */ + runPointActions: function (e) { + var pointer = this, + chart = pointer.chart, + series = chart.series, + tooltip = chart.tooltip, + followPointer, + point, + points, + hoverPoint = chart.hoverPoint, + hoverSeries = chart.hoverSeries, + i, + j, + distance = chart.chartWidth, + index = pointer.getIndex(e), + anchor; + + // shared tooltip + if (tooltip && pointer.options.tooltip.shared && !(hoverSeries && hoverSeries.noSharedTooltip)) { + points = []; + + // loop over all series and find the ones with points closest to the mouse + i = series.length; + for (j = 0; j < i; j++) { + if (series[j].visible && + series[j].options.enableMouseTracking !== false && + !series[j].noSharedTooltip && series[j].singularTooltips !== true && series[j].tooltipPoints.length) { + point = series[j].tooltipPoints[index]; + if (point && point.series) { // not a dummy point, #1544 + point._dist = mathAbs(index - point.clientX); + distance = mathMin(distance, point._dist); + points.push(point); + } + } + } + // remove furthest points + i = points.length; + while (i--) { + if (points[i]._dist > distance) { + points.splice(i, 1); + } + } + // refresh the tooltip if necessary + if (points.length && (points[0].clientX !== pointer.hoverX)) { + tooltip.refresh(points, e); + pointer.hoverX = points[0].clientX; + } + } + + // Separate tooltip and general mouse events + followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer; + if (hoverSeries && hoverSeries.tracker && !followPointer) { // #2584, #2830 + + // get the point + point = hoverSeries.tooltipPoints[index]; + + // a new point is hovered, refresh the tooltip + if (point && point !== hoverPoint) { + + // trigger the events + point.onMouseOver(e); + + } + + } else if (tooltip && followPointer && !tooltip.isHidden) { + anchor = tooltip.getAnchor([{}], e); + tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] }); + } + + // Start the event listener to pick up the tooltip + if (tooltip && !pointer._onDocumentMouseMove) { + pointer._onDocumentMouseMove = function (e) { + if (charts[hoverChartIndex]) { + charts[hoverChartIndex].pointer.onDocumentMouseMove(e); + } + }; + addEvent(doc, 'mousemove', pointer._onDocumentMouseMove); + } + + // Draw independent crosshairs + each(chart.axes, function (axis) { + axis.drawCrosshair(e, pick(point, hoverPoint)); + }); + }, + + + + /** + * Reset the tracking by hiding the tooltip, the hover series state and the hover point + * + * @param allowMove {Boolean} Instead of destroying the tooltip altogether, allow moving it if possible + */ + reset: function (allowMove, delay) { + var pointer = this, + chart = pointer.chart, + hoverSeries = chart.hoverSeries, + hoverPoint = chart.hoverPoint, + tooltip = chart.tooltip, + tooltipPoints = tooltip && tooltip.shared ? chart.hoverPoints : hoverPoint; + + // Narrow in allowMove + allowMove = allowMove && tooltip && tooltipPoints; + + // Check if the points have moved outside the plot area, #1003 + if (allowMove && splat(tooltipPoints)[0].plotX === UNDEFINED) { + allowMove = false; + } + + // Just move the tooltip, #349 + if (allowMove) { + tooltip.refresh(tooltipPoints); + if (hoverPoint) { // #2500 + hoverPoint.setState(hoverPoint.state, true); + } + + // Full reset + } else { + + if (hoverPoint) { + hoverPoint.onMouseOut(); + } + + if (hoverSeries) { + hoverSeries.onMouseOut(); + } + + if (tooltip) { + tooltip.hide(delay); + } + + if (pointer._onDocumentMouseMove) { + removeEvent(doc, 'mousemove', pointer._onDocumentMouseMove); + pointer._onDocumentMouseMove = null; + } + + // Remove crosshairs + each(chart.axes, function (axis) { + axis.hideCrosshair(); + }); + + pointer.hoverX = null; + + } + }, + + /** + * Scale series groups to a certain scale and translation + */ + scaleGroups: function (attribs, clip) { + + var chart = this.chart, + seriesAttribs; + + // Scale each series + each(chart.series, function (series) { + seriesAttribs = attribs || series.getPlotBox(); // #1701 + if (series.xAxis && series.xAxis.zoomEnabled) { + series.group.attr(seriesAttribs); + if (series.markerGroup) { + series.markerGroup.attr(seriesAttribs); + series.markerGroup.clip(clip ? chart.clipRect : null); + } + if (series.dataLabelsGroup) { + series.dataLabelsGroup.attr(seriesAttribs); + } + } + }); + + // Clip + chart.clipRect.attr(clip || chart.clipBox); + }, + + /** + * Start a drag operation + */ + dragStart: function (e) { + var chart = this.chart; + + // Record the start position + chart.mouseIsDown = e.type; + chart.cancelClick = false; + chart.mouseDownX = this.mouseDownX = e.chartX; + chart.mouseDownY = this.mouseDownY = e.chartY; + }, + + /** + * Perform a drag operation in response to a mousemove event while the mouse is down + */ + drag: function (e) { + + var chart = this.chart, + chartOptions = chart.options.chart, + chartX = e.chartX, + chartY = e.chartY, + zoomHor = this.zoomHor, + zoomVert = this.zoomVert, + plotLeft = chart.plotLeft, + plotTop = chart.plotTop, + plotWidth = chart.plotWidth, + plotHeight = chart.plotHeight, + clickedInside, + size, + mouseDownX = this.mouseDownX, + mouseDownY = this.mouseDownY, + panKey = chartOptions.panKey && e[chartOptions.panKey + 'Key']; + + // If the mouse is outside the plot area, adjust to cooordinates + // inside to prevent the selection marker from going outside + if (chartX < plotLeft) { + chartX = plotLeft; + } else if (chartX > plotLeft + plotWidth) { + chartX = plotLeft + plotWidth; + } + + if (chartY < plotTop) { + chartY = plotTop; + } else if (chartY > plotTop + plotHeight) { + chartY = plotTop + plotHeight; + } + + // determine if the mouse has moved more than 10px + this.hasDragged = Math.sqrt( + Math.pow(mouseDownX - chartX, 2) + + Math.pow(mouseDownY - chartY, 2) + ); + + if (this.hasDragged > 10) { + clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop); + + // make a selection + if (chart.hasCartesianSeries && (this.zoomX || this.zoomY) && clickedInside && !panKey) { + if (!this.selectionMarker) { + this.selectionMarker = chart.renderer.rect( + plotLeft, + plotTop, + zoomHor ? 1 : plotWidth, + zoomVert ? 1 : plotHeight, + 0 + ) + .attr({ + fill: chartOptions.selectionMarkerFill || 'rgba(69,114,167,0.25)', + zIndex: 7 + }) + .add(); + } + } + + // adjust the width of the selection marker + if (this.selectionMarker && zoomHor) { + size = chartX - mouseDownX; + this.selectionMarker.attr({ + width: mathAbs(size), + x: (size > 0 ? 0 : size) + mouseDownX + }); + } + // adjust the height of the selection marker + if (this.selectionMarker && zoomVert) { + size = chartY - mouseDownY; + this.selectionMarker.attr({ + height: mathAbs(size), + y: (size > 0 ? 0 : size) + mouseDownY + }); + } + + // panning + if (clickedInside && !this.selectionMarker && chartOptions.panning) { + chart.pan(e, chartOptions.panning); + } + } + }, + + /** + * On mouse up or touch end across the entire document, drop the selection. + */ + drop: function (e) { + var chart = this.chart, + hasPinched = this.hasPinched; + + if (this.selectionMarker) { + var selectionData = { + xAxis: [], + yAxis: [], + originalEvent: e.originalEvent || e + }, + selectionBox = this.selectionMarker, + selectionLeft = selectionBox.attr ? selectionBox.attr('x') : selectionBox.x, + selectionTop = selectionBox.attr ? selectionBox.attr('y') : selectionBox.y, + selectionWidth = selectionBox.attr ? selectionBox.attr('width') : selectionBox.width, + selectionHeight = selectionBox.attr ? selectionBox.attr('height') : selectionBox.height, + runZoom; + + // a selection has been made + if (this.hasDragged || hasPinched) { + + // record each axis' min and max + each(chart.axes, function (axis) { + if (axis.zoomEnabled) { + var horiz = axis.horiz, + minPixelPadding = e.type === 'touchend' ? axis.minPixelPadding: 0, // #1207, #3075 + selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) + minPixelPadding), + selectionMax = axis.toValue((horiz ? selectionLeft + selectionWidth : selectionTop + selectionHeight) - minPixelPadding); + + if (!isNaN(selectionMin) && !isNaN(selectionMax)) { // #859 + selectionData[axis.coll].push({ + axis: axis, + min: mathMin(selectionMin, selectionMax), // for reversed axes, + max: mathMax(selectionMin, selectionMax) + }); + runZoom = true; + } + } + }); + if (runZoom) { + fireEvent(chart, 'selection', selectionData, function (args) { + chart.zoom(extend(args, hasPinched ? { animation: false } : null)); + }); + } + + } + this.selectionMarker = this.selectionMarker.destroy(); + + // Reset scaling preview + if (hasPinched) { + this.scaleGroups(); + } + } + + // Reset all + if (chart) { // it may be destroyed on mouse up - #877 + css(chart.container, { cursor: chart._cursor }); + chart.cancelClick = this.hasDragged > 10; // #370 + chart.mouseIsDown = this.hasDragged = this.hasPinched = false; + this.pinchDown = []; + } + }, + + onContainerMouseDown: function (e) { + + e = this.normalize(e); + + // issue #295, dragging not always working in Firefox + if (e.preventDefault) { + e.preventDefault(); + } + + this.dragStart(e); + }, + + + + onDocumentMouseUp: function (e) { + if (charts[hoverChartIndex]) { + charts[hoverChartIndex].pointer.drop(e); + } + }, + + /** + * Special handler for mouse move that will hide the tooltip when the mouse leaves the plotarea. + * Issue #149 workaround. The mouseleave event does not always fire. + */ + onDocumentMouseMove: function (e) { + var chart = this.chart, + chartPosition = this.chartPosition, + hoverSeries = chart.hoverSeries; + + e = this.normalize(e, chartPosition); + + // If we're outside, hide the tooltip + if (chartPosition && hoverSeries && !this.inClass(e.target, 'highcharts-tracker') && + !chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) { + this.reset(); + } + }, + + /** + * When mouse leaves the container, hide the tooltip. + */ + onContainerMouseLeave: function () { + var chart = charts[hoverChartIndex]; + if (chart) { + chart.pointer.reset(); + chart.pointer.chartPosition = null; // also reset the chart position, used in #149 fix + } + }, + + // The mousemove, touchmove and touchstart event handler + onContainerMouseMove: function (e) { + + var chart = this.chart; + + hoverChartIndex = chart.index; + + e = this.normalize(e); + e.returnValue = false; // #2251, #3224 + + if (chart.mouseIsDown === 'mousedown') { + this.drag(e); + } + + // Show the tooltip and run mouse over events (#977) + if ((this.inClass(e.target, 'highcharts-tracker') || + chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) && !chart.openMenu) { + this.runPointActions(e); + } + }, + + /** + * Utility to detect whether an element has, or has a parent with, a specific + * class name. Used on detection of tracker objects and on deciding whether + * hovering the tooltip should cause the active series to mouse out. + */ + inClass: function (element, className) { + var elemClassName; + while (element) { + elemClassName = attr(element, 'class'); + if (elemClassName) { + if (elemClassName.indexOf(className) !== -1) { + return true; + } else if (elemClassName.indexOf(PREFIX + 'container') !== -1) { + return false; + } + } + element = element.parentNode; + } + }, + + onTrackerMouseOut: function (e) { + var series = this.chart.hoverSeries, + relatedTarget = e.relatedTarget || e.toElement, + relatedSeries = relatedTarget && relatedTarget.point && relatedTarget.point.series; // #2499 + + if (series && !series.options.stickyTracking && !this.inClass(relatedTarget, PREFIX + 'tooltip') && + relatedSeries !== series) { + series.onMouseOut(); + } + }, + + onContainerClick: function (e) { + var chart = this.chart, + hoverPoint = chart.hoverPoint, + plotLeft = chart.plotLeft, + plotTop = chart.plotTop; + + e = this.normalize(e); + e.cancelBubble = true; // IE specific + + if (!chart.cancelClick) { + + // On tracker click, fire the series and point events. #783, #1583 + if (hoverPoint && this.inClass(e.target, PREFIX + 'tracker')) { + + // the series click event + fireEvent(hoverPoint.series, 'click', extend(e, { + point: hoverPoint + })); + + // the point click event + if (chart.hoverPoint) { // it may be destroyed (#1844) + hoverPoint.firePointEvent('click', e); + } + + // When clicking outside a tracker, fire a chart event + } else { + extend(e, this.getCoordinates(e)); + + // fire a click event in the chart + if (chart.isInsidePlot(e.chartX - plotLeft, e.chartY - plotTop)) { + fireEvent(chart, 'click', e); + } + } + + + } + }, + + /** + * Set the JS DOM events on the container and document. This method should contain + * a one-to-one assignment between methods and their handlers. Any advanced logic should + * be moved to the handler reflecting the event's name. + */ + setDOMEvents: function () { + + var pointer = this, + container = pointer.chart.container; + + container.onmousedown = function (e) { + pointer.onContainerMouseDown(e); + }; + container.onmousemove = function (e) { + pointer.onContainerMouseMove(e); + }; + container.onclick = function (e) { + pointer.onContainerClick(e); + }; + addEvent(container, 'mouseleave', pointer.onContainerMouseLeave); + if (chartCount === 1) { + addEvent(doc, 'mouseup', pointer.onDocumentMouseUp); + } + if (hasTouch) { + container.ontouchstart = function (e) { + pointer.onContainerTouchStart(e); + }; + container.ontouchmove = function (e) { + pointer.onContainerTouchMove(e); + }; + if (chartCount === 1) { + addEvent(doc, 'touchend', pointer.onDocumentTouchEnd); + } + } + + }, + + /** + * Destroys the Pointer object and disconnects DOM events. + */ + destroy: function () { + var prop; + + removeEvent(this.chart.container, 'mouseleave', this.onContainerMouseLeave); + if (!chartCount) { + removeEvent(doc, 'mouseup', this.onDocumentMouseUp); + removeEvent(doc, 'touchend', this.onDocumentTouchEnd); + } + + // memory and CPU leak + clearInterval(this.tooltipTimeout); + + for (prop in this) { + this[prop] = null; + } + } +}; + + +/* Support for touch devices */ +extend(Highcharts.Pointer.prototype, { + + /** + * Run translation operations + */ + pinchTranslate: function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) { + if (this.zoomHor || this.pinchHor) { + this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch); + } + if (this.zoomVert || this.pinchVert) { + this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch); + } + }, + + /** + * Run translation operations for each direction (horizontal and vertical) independently + */ + pinchTranslateDirection: function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) { + var chart = this.chart, + xy = horiz ? 'x' : 'y', + XY = horiz ? 'X' : 'Y', + sChartXY = 'chart' + XY, + wh = horiz ? 'width' : 'height', + plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')], + selectionWH, + selectionXY, + clipXY, + scale = forcedScale || 1, + inverted = chart.inverted, + bounds = chart.bounds[horiz ? 'h' : 'v'], + singleTouch = pinchDown.length === 1, + touch0Start = pinchDown[0][sChartXY], + touch0Now = touches[0][sChartXY], + touch1Start = !singleTouch && pinchDown[1][sChartXY], + touch1Now = !singleTouch && touches[1][sChartXY], + outOfBounds, + transformScale, + scaleKey, + setScale = function () { + if (!singleTouch && mathAbs(touch0Start - touch1Start) > 20) { // Don't zoom if fingers are too close on this axis + scale = forcedScale || mathAbs(touch0Now - touch1Now) / mathAbs(touch0Start - touch1Start); + } + + clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start; + selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale; + }; + + // Set the scale, first pass + setScale(); + + selectionXY = clipXY; // the clip position (x or y) is altered if out of bounds, the selection position is not + + // Out of bounds + if (selectionXY < bounds.min) { + selectionXY = bounds.min; + outOfBounds = true; + } else if (selectionXY + selectionWH > bounds.max) { + selectionXY = bounds.max - selectionWH; + outOfBounds = true; + } + + // Is the chart dragged off its bounds, determined by dataMin and dataMax? + if (outOfBounds) { + + // Modify the touchNow position in order to create an elastic drag movement. This indicates + // to the user that the chart is responsive but can't be dragged further. + touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]); + if (!singleTouch) { + touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]); + } + + // Set the scale, second pass to adapt to the modified touchNow positions + setScale(); + + } else { + lastValidTouch[xy] = [touch0Now, touch1Now]; + } + + // Set geometry for clipping, selection and transformation + if (!inverted) { // TODO: implement clipping for inverted charts + clip[xy] = clipXY - plotLeftTop; + clip[wh] = selectionWH; + } + scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY; + transformScale = inverted ? 1 / scale : scale; + + selectionMarker[wh] = selectionWH; + selectionMarker[xy] = selectionXY; + transform[scaleKey] = scale; + transform['translate' + XY] = (transformScale * plotLeftTop) + (touch0Now - (transformScale * touch0Start)); + }, + + /** + * Handle touch events with two touches + */ + pinch: function (e) { + + var self = this, + chart = self.chart, + pinchDown = self.pinchDown, + followTouchMove = self.followTouchMove, + touches = e.touches, + touchesLength = touches.length, + lastValidTouch = self.lastValidTouch, + hasZoom = self.hasZoom, + selectionMarker = self.selectionMarker, + transform = {}, + fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, PREFIX + 'tracker') && + chart.runTrackerClick) || self.runChartClick), + clip = {}; + + // On touch devices, only proceed to trigger click if a handler is defined + if ((hasZoom || followTouchMove) && !fireClickEvent) { + e.preventDefault(); + } + + // Normalize each touch + map(touches, function (e) { + return self.normalize(e); + }); + + // Register the touch start position + if (e.type === 'touchstart') { + each(touches, function (e, i) { + pinchDown[i] = { chartX: e.chartX, chartY: e.chartY }; + }); + lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] && pinchDown[1].chartX]; + lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] && pinchDown[1].chartY]; + + // Identify the data bounds in pixels + each(chart.axes, function (axis) { + if (axis.zoomEnabled) { + var bounds = chart.bounds[axis.horiz ? 'h' : 'v'], + minPixelPadding = axis.minPixelPadding, + min = axis.toPixels(pick(axis.options.min, axis.dataMin)), + max = axis.toPixels(pick(axis.options.max, axis.dataMax)), + absMin = mathMin(min, max), + absMax = mathMax(min, max); + + // Store the bounds for use in the touchmove handler + bounds.min = mathMin(axis.pos, absMin - minPixelPadding); + bounds.max = mathMax(axis.pos + axis.len, absMax + minPixelPadding); + } + }); + self.res = true; // reset on next move + + // Event type is touchmove, handle panning and pinching + } else if (pinchDown.length) { // can be 0 when releasing, if touchend fires first + + + // Set the marker + if (!selectionMarker) { + self.selectionMarker = selectionMarker = extend({ + destroy: noop + }, chart.plotBox); + } + + self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch); + + self.hasPinched = hasZoom; + + // Scale and translate the groups to provide visual feedback during pinching + self.scaleGroups(transform, clip); + + // Optionally move the tooltip on touchmove + if (!hasZoom && followTouchMove && touchesLength === 1) { + this.runPointActions(self.normalize(e)); + } else if (self.res) { + self.res = false; + this.reset(false, 0); + } + } + }, + + onContainerTouchStart: function (e) { + var chart = this.chart; + + hoverChartIndex = chart.index; + + if (e.touches.length === 1) { + + e = this.normalize(e); + + if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) { + + // Run mouse events and display tooltip etc + this.runPointActions(e); + + this.pinch(e); + + } else { + // Hide the tooltip on touching outside the plot area (#1203) + this.reset(); + } + + } else if (e.touches.length === 2) { + this.pinch(e); + } + }, + + onContainerTouchMove: function (e) { + if (e.touches.length === 1 || e.touches.length === 2) { + this.pinch(e); + } + }, + + onDocumentTouchEnd: function (e) { + if (charts[hoverChartIndex]) { + charts[hoverChartIndex].pointer.drop(e); + } + } + +}); +if (win.PointerEvent || win.MSPointerEvent) { + + // The touches object keeps track of the points being touched at all times + var touches = {}, + hasPointerEvent = !!win.PointerEvent, + getWebkitTouches = function () { + var key, fake = []; + fake.item = function (i) { return this[i]; }; + for (key in touches) { + if (touches.hasOwnProperty(key)) { + fake.push({ + pageX: touches[key].pageX, + pageY: touches[key].pageY, + target: touches[key].target + }); + } + } + return fake; + }, + translateMSPointer = function (e, method, wktype, callback) { + var p; + e = e.originalEvent || e; + if ((e.pointerType === 'touch' || e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[hoverChartIndex]) { + callback(e); + p = charts[hoverChartIndex].pointer; + p[method]({ + type: wktype, + target: e.currentTarget, + preventDefault: noop, + touches: getWebkitTouches() + }); + } + }; + + /** + * Extend the Pointer prototype with methods for each event handler and more + */ + extend(Pointer.prototype, { + onContainerPointerDown: function (e) { + translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) { + touches[e.pointerId] = { pageX: e.pageX, pageY: e.pageY, target: e.currentTarget }; + }); + }, + onContainerPointerMove: function (e) { + translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) { + touches[e.pointerId] = { pageX: e.pageX, pageY: e.pageY }; + if (!touches[e.pointerId].target) { + touches[e.pointerId].target = e.currentTarget; + } + }); + }, + onDocumentPointerUp: function (e) { + translateMSPointer(e, 'onContainerTouchEnd', 'touchend', function (e) { + delete touches[e.pointerId]; + }); + }, + + /** + * Add or remove the MS Pointer specific events + */ + batchMSEvents: function (fn) { + fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown); + fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove); + fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp); + } + }); + + // Disable default IE actions for pinch and such on chart element + wrap(Pointer.prototype, 'init', function (proceed, chart, options) { + proceed.call(this, chart, options); + if (this.hasZoom || this.followTouchMove) { + css(chart.container, { + '-ms-touch-action': NONE, + 'touch-action': NONE + }); + } + }); + + // Add IE specific touch events to chart + wrap(Pointer.prototype, 'setDOMEvents', function (proceed) { + proceed.apply(this); + if (this.hasZoom || this.followTouchMove) { + this.batchMSEvents(addEvent); + } + }); + // Destroy MS events also + wrap(Pointer.prototype, 'destroy', function (proceed) { + this.batchMSEvents(removeEvent); + proceed.call(this); + }); +} +/** + * The overview of the chart's series + */ +var Legend = Highcharts.Legend = function (chart, options) { + this.init(chart, options); +}; + +Legend.prototype = { + + /** + * Initialize the legend + */ + init: function (chart, options) { + + var legend = this, + itemStyle = options.itemStyle, + padding = pick(options.padding, 8), + itemMarginTop = options.itemMarginTop || 0; + + this.options = options; + + if (!options.enabled) { + return; + } + + legend.itemStyle = itemStyle; + legend.itemHiddenStyle = merge(itemStyle, options.itemHiddenStyle); + legend.itemMarginTop = itemMarginTop; + legend.padding = padding; + legend.initialItemX = padding; + legend.initialItemY = padding - 5; // 5 is the number of pixels above the text + legend.maxItemWidth = 0; + legend.chart = chart; + legend.itemHeight = 0; + legend.lastLineHeight = 0; + legend.symbolWidth = pick(options.symbolWidth, 16); + legend.pages = []; + + + // Render it + legend.render(); + + // move checkboxes + addEvent(legend.chart, 'endResize', function () { + legend.positionCheckboxes(); + }); + + }, + + /** + * Set the colors for the legend item + * @param {Object} item A Series or Point instance + * @param {Object} visible Dimmed or colored + */ + colorizeItem: function (item, visible) { + var legend = this, + options = legend.options, + legendItem = item.legendItem, + legendLine = item.legendLine, + legendSymbol = item.legendSymbol, + hiddenColor = legend.itemHiddenStyle.color, + textColor = visible ? options.itemStyle.color : hiddenColor, + symbolColor = visible ? (item.legendColor || item.color || '#CCC') : hiddenColor, + markerOptions = item.options && item.options.marker, + symbolAttr = { fill: symbolColor }, + key, + val; + + if (legendItem) { + legendItem.css({ fill: textColor, color: textColor }); // color for #1553, oldIE + } + if (legendLine) { + legendLine.attr({ stroke: symbolColor }); + } + + if (legendSymbol) { + + // Apply marker options + if (markerOptions && legendSymbol.isMarker) { // #585 + symbolAttr.stroke = symbolColor; + markerOptions = item.convertAttribs(markerOptions); + for (key in markerOptions) { + val = markerOptions[key]; + if (val !== UNDEFINED) { + symbolAttr[key] = val; + } + } + } + + legendSymbol.attr(symbolAttr); + } + }, + + /** + * Position the legend item + * @param {Object} item A Series or Point instance + */ + positionItem: function (item) { + var legend = this, + options = legend.options, + symbolPadding = options.symbolPadding, + ltr = !options.rtl, + legendItemPos = item._legendItemPos, + itemX = legendItemPos[0], + itemY = legendItemPos[1], + checkbox = item.checkbox; + + if (item.legendGroup) { + item.legendGroup.translate( + ltr ? itemX : legend.legendWidth - itemX - 2 * symbolPadding - 4, + itemY + ); + } + + if (checkbox) { + checkbox.x = itemX; + checkbox.y = itemY; + } + }, + + /** + * Destroy a single legend item + * @param {Object} item The series or point + */ + destroyItem: function (item) { + var checkbox = item.checkbox; + + // destroy SVG elements + each(['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'], function (key) { + if (item[key]) { + item[key] = item[key].destroy(); + } + }); + + if (checkbox) { + discardElement(item.checkbox); + } + }, + + /** + * Destroys the legend. + */ + destroy: function () { + var legend = this, + legendGroup = legend.group, + box = legend.box; + + if (box) { + legend.box = box.destroy(); + } + + if (legendGroup) { + legend.group = legendGroup.destroy(); + } + }, + + /** + * Position the checkboxes after the width is determined + */ + positionCheckboxes: function (scrollOffset) { + var alignAttr = this.group.alignAttr, + translateY, + clipHeight = this.clipHeight || this.legendHeight; + + if (alignAttr) { + translateY = alignAttr.translateY; + each(this.allItems, function (item) { + var checkbox = item.checkbox, + top; + + if (checkbox) { + top = (translateY + checkbox.y + (scrollOffset || 0) + 3); + css(checkbox, { + left: (alignAttr.translateX + item.checkboxOffset + checkbox.x - 20) + PX, + top: top + PX, + display: top > translateY - 6 && top < translateY + clipHeight - 6 ? '' : NONE + }); + } + }); + } + }, + + /** + * Render the legend title on top of the legend + */ + renderTitle: function () { + var options = this.options, + padding = this.padding, + titleOptions = options.title, + titleHeight = 0, + bBox; + + if (titleOptions.text) { + if (!this.title) { + this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, null, null, 'legend-title') + .attr({ zIndex: 1 }) + .css(titleOptions.style) + .add(this.group); + } + bBox = this.title.getBBox(); + titleHeight = bBox.height; + this.offsetWidth = bBox.width; // #1717 + this.contentGroup.attr({ translateY: titleHeight }); + } + this.titleHeight = titleHeight; + }, + + /** + * Render a single specific legend item + * @param {Object} item A series or point + */ + renderItem: function (item) { + var legend = this, + chart = legend.chart, + renderer = chart.renderer, + options = legend.options, + horizontal = options.layout === 'horizontal', + symbolWidth = legend.symbolWidth, + symbolPadding = options.symbolPadding, + itemStyle = legend.itemStyle, + itemHiddenStyle = legend.itemHiddenStyle, + padding = legend.padding, + itemDistance = horizontal ? pick(options.itemDistance, 20) : 0, + ltr = !options.rtl, + itemHeight, + widthOption = options.width, + itemMarginBottom = options.itemMarginBottom || 0, + itemMarginTop = legend.itemMarginTop, + initialItemX = legend.initialItemX, + bBox, + itemWidth, + li = item.legendItem, + series = item.series && item.series.drawLegendSymbol ? item.series : item, + seriesOptions = series.options, + showCheckbox = legend.createCheckboxForItem && seriesOptions && seriesOptions.showCheckbox, + useHTML = options.useHTML; + + if (!li) { // generate it once, later move it + + // Generate the group box + // A group to hold the symbol and text. Text is to be appended in Legend class. + item.legendGroup = renderer.g('legend-item') + .attr({ zIndex: 1 }) + .add(legend.scrollGroup); + + // Generate the list item text and add it to the group + item.legendItem = li = renderer.text( + options.labelFormat ? format(options.labelFormat, item) : options.labelFormatter.call(item), + ltr ? symbolWidth + symbolPadding : -symbolPadding, + legend.baseline || 0, + useHTML + ) + .css(merge(item.visible ? itemStyle : itemHiddenStyle)) // merge to prevent modifying original (#1021) + .attr({ + align: ltr ? 'left' : 'right', + zIndex: 2 + }) + .add(item.legendGroup); + + // Get the baseline for the first item - the font size is equal for all + if (!legend.baseline) { + legend.baseline = renderer.fontMetrics(itemStyle.fontSize, li).f + 3 + itemMarginTop; + li.attr('y', legend.baseline); + } + + // Draw the legend symbol inside the group box + series.drawLegendSymbol(legend, item); + + if (legend.setItemEvents) { + legend.setItemEvents(item, li, useHTML, itemStyle, itemHiddenStyle); + } + + // Colorize the items + legend.colorizeItem(item, item.visible); + + // add the HTML checkbox on top + if (showCheckbox) { + legend.createCheckboxForItem(item); + } + } + + // calculate the positions for the next line + bBox = li.getBBox(); + + itemWidth = item.checkboxOffset = + options.itemWidth || + item.legendItemWidth || + symbolWidth + symbolPadding + bBox.width + itemDistance + (showCheckbox ? 20 : 0); + legend.itemHeight = itemHeight = mathRound(item.legendItemHeight || bBox.height); + + // if the item exceeds the width, start a new line + if (horizontal && legend.itemX - initialItemX + itemWidth > + (widthOption || (chart.chartWidth - 2 * padding - initialItemX - options.x))) { + legend.itemX = initialItemX; + legend.itemY += itemMarginTop + legend.lastLineHeight + itemMarginBottom; + legend.lastLineHeight = 0; // reset for next line + } + + // If the item exceeds the height, start a new column + /*if (!horizontal && legend.itemY + options.y + itemHeight > chart.chartHeight - spacingTop - spacingBottom) { + legend.itemY = legend.initialItemY; + legend.itemX += legend.maxItemWidth; + legend.maxItemWidth = 0; + }*/ + + // Set the edge positions + legend.maxItemWidth = mathMax(legend.maxItemWidth, itemWidth); + legend.lastItemY = itemMarginTop + legend.itemY + itemMarginBottom; + legend.lastLineHeight = mathMax(itemHeight, legend.lastLineHeight); // #915 + + // cache the position of the newly generated or reordered items + item._legendItemPos = [legend.itemX, legend.itemY]; + + // advance + if (horizontal) { + legend.itemX += itemWidth; + + } else { + legend.itemY += itemMarginTop + itemHeight + itemMarginBottom; + legend.lastLineHeight = itemHeight; + } + + // the width of the widest item + legend.offsetWidth = widthOption || mathMax( + (horizontal ? legend.itemX - initialItemX - itemDistance : itemWidth) + padding, + legend.offsetWidth + ); + }, + + /** + * Get all items, which is one item per series for normal series and one item per point + * for pie series. + */ + getAllItems: function () { + var allItems = []; + each(this.chart.series, function (series) { + var seriesOptions = series.options; + + // Handle showInLegend. If the series is linked to another series, defaults to false. + if (!pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? UNDEFINED : false, true)) { + return; + } + + // use points or series for the legend item depending on legendType + allItems = allItems.concat( + series.legendItems || + (seriesOptions.legendType === 'point' ? + series.data : + series) + ); + }); + return allItems; + }, + + /** + * Render the legend. This method can be called both before and after + * chart.render. If called after, it will only rearrange items instead + * of creating new ones. + */ + render: function () { + var legend = this, + chart = legend.chart, + renderer = chart.renderer, + legendGroup = legend.group, + allItems, + display, + legendWidth, + legendHeight, + box = legend.box, + options = legend.options, + padding = legend.padding, + legendBorderWidth = options.borderWidth, + legendBackgroundColor = options.backgroundColor; + + legend.itemX = legend.initialItemX; + legend.itemY = legend.initialItemY; + legend.offsetWidth = 0; + legend.lastItemY = 0; + + if (!legendGroup) { + legend.group = legendGroup = renderer.g('legend') + .attr({ zIndex: 7 }) + .add(); + legend.contentGroup = renderer.g() + .attr({ zIndex: 1 }) // above background + .add(legendGroup); + legend.scrollGroup = renderer.g() + .add(legend.contentGroup); + } + + legend.renderTitle(); + + // add each series or point + allItems = legend.getAllItems(); + + // sort by legendIndex + stableSort(allItems, function (a, b) { + return ((a.options && a.options.legendIndex) || 0) - ((b.options && b.options.legendIndex) || 0); + }); + + // reversed legend + if (options.reversed) { + allItems.reverse(); + } + + legend.allItems = allItems; + legend.display = display = !!allItems.length; + + // render the items + each(allItems, function (item) { + legend.renderItem(item); + }); + + // Draw the border + legendWidth = options.width || legend.offsetWidth; + legendHeight = legend.lastItemY + legend.lastLineHeight + legend.titleHeight; + + + legendHeight = legend.handleOverflow(legendHeight); + + if (legendBorderWidth || legendBackgroundColor) { + legendWidth += padding; + legendHeight += padding; + + if (!box) { + legend.box = box = renderer.rect( + 0, + 0, + legendWidth, + legendHeight, + options.borderRadius, + legendBorderWidth || 0 + ).attr({ + stroke: options.borderColor, + 'stroke-width': legendBorderWidth || 0, + fill: legendBackgroundColor || NONE + }) + .add(legendGroup) + .shadow(options.shadow); + box.isNew = true; + + } else if (legendWidth > 0 && legendHeight > 0) { + box[box.isNew ? 'attr' : 'animate']( + box.crisp({ width: legendWidth, height: legendHeight }) + ); + box.isNew = false; + } + + // hide the border if no items + box[display ? 'show' : 'hide'](); + } + + legend.legendWidth = legendWidth; + legend.legendHeight = legendHeight; + + // Now that the legend width and height are established, put the items in the + // final position + each(allItems, function (item) { + legend.positionItem(item); + }); + + // 1.x compatibility: positioning based on style + /*var props = ['left', 'right', 'top', 'bottom'], + prop, + i = 4; + while (i--) { + prop = props[i]; + if (options.style[prop] && options.style[prop] !== 'auto') { + options[i < 2 ? 'align' : 'verticalAlign'] = prop; + options[i < 2 ? 'x' : 'y'] = pInt(options.style[prop]) * (i % 2 ? -1 : 1); + } + }*/ + + if (display) { + legendGroup.align(extend({ + width: legendWidth, + height: legendHeight + }, options), true, 'spacingBox'); + } + + if (!chart.isResizing) { + this.positionCheckboxes(); + } + }, + + /** + * Set up the overflow handling by adding navigation with up and down arrows below the + * legend. + */ + handleOverflow: function (legendHeight) { + var legend = this, + chart = this.chart, + renderer = chart.renderer, + options = this.options, + optionsY = options.y, + alignTop = options.verticalAlign === 'top', + spaceHeight = chart.spacingBox.height + (alignTop ? -optionsY : optionsY) - this.padding, + maxHeight = options.maxHeight, + clipHeight, + clipRect = this.clipRect, + navOptions = options.navigation, + animation = pick(navOptions.animation, true), + arrowSize = navOptions.arrowSize || 12, + nav = this.nav, + pages = this.pages, + lastY, + allItems = this.allItems; + + // Adjust the height + if (options.layout === 'horizontal') { + spaceHeight /= 2; + } + if (maxHeight) { + spaceHeight = mathMin(spaceHeight, maxHeight); + } + + // Reset the legend height and adjust the clipping rectangle + pages.length = 0; + if (legendHeight > spaceHeight && !options.useHTML) { + + this.clipHeight = clipHeight = mathMax(spaceHeight - 20 - this.titleHeight - this.padding, 0); + this.currentPage = pick(this.currentPage, 1); + this.fullHeight = legendHeight; + + // Fill pages with Y positions so that the top of each a legend item defines + // the scroll top for each page (#2098) + each(allItems, function (item, i) { + var y = item._legendItemPos[1], + h = mathRound(item.legendItem.getBBox().height), + len = pages.length; + + if (!len || (y - pages[len - 1] > clipHeight && (lastY || y) !== pages[len - 1])) { + pages.push(lastY || y); + len++; + } + + if (i === allItems.length - 1 && y + h - pages[len - 1] > clipHeight) { + pages.push(y); + } + if (y !== lastY) { + lastY = y; + } + }); + + // Only apply clipping if needed. Clipping causes blurred legend in PDF export (#1787) + if (!clipRect) { + clipRect = legend.clipRect = renderer.clipRect(0, this.padding, 9999, 0); + legend.contentGroup.clip(clipRect); + } + clipRect.attr({ + height: clipHeight + }); + + // Add navigation elements + if (!nav) { + this.nav = nav = renderer.g().attr({ zIndex: 1 }).add(this.group); + this.up = renderer.symbol('triangle', 0, 0, arrowSize, arrowSize) + .on('click', function () { + legend.scroll(-1, animation); + }) + .add(nav); + this.pager = renderer.text('', 15, 10) + .css(navOptions.style) + .add(nav); + this.down = renderer.symbol('triangle-down', 0, 0, arrowSize, arrowSize) + .on('click', function () { + legend.scroll(1, animation); + }) + .add(nav); + } + + // Set initial position + legend.scroll(0); + + legendHeight = spaceHeight; + + } else if (nav) { + clipRect.attr({ + height: chart.chartHeight + }); + nav.hide(); + this.scrollGroup.attr({ + translateY: 1 + }); + this.clipHeight = 0; // #1379 + } + + return legendHeight; + }, + + /** + * Scroll the legend by a number of pages + * @param {Object} scrollBy + * @param {Object} animation + */ + scroll: function (scrollBy, animation) { + var pages = this.pages, + pageCount = pages.length, + currentPage = this.currentPage + scrollBy, + clipHeight = this.clipHeight, + navOptions = this.options.navigation, + activeColor = navOptions.activeColor, + inactiveColor = navOptions.inactiveColor, + pager = this.pager, + padding = this.padding, + scrollOffset; + + // When resizing while looking at the last page + if (currentPage > pageCount) { + currentPage = pageCount; + } + + if (currentPage > 0) { + + if (animation !== UNDEFINED) { + setAnimation(animation, this.chart); + } + + this.nav.attr({ + translateX: padding, + translateY: clipHeight + this.padding + 7 + this.titleHeight, + visibility: VISIBLE + }); + this.up.attr({ + fill: currentPage === 1 ? inactiveColor : activeColor + }) + .css({ + cursor: currentPage === 1 ? 'default' : 'pointer' + }); + pager.attr({ + text: currentPage + '/' + pageCount + }); + this.down.attr({ + x: 18 + this.pager.getBBox().width, // adjust to text width + fill: currentPage === pageCount ? inactiveColor : activeColor + }) + .css({ + cursor: currentPage === pageCount ? 'default' : 'pointer' + }); + + scrollOffset = -pages[currentPage - 1] + this.initialItemY; + + this.scrollGroup.animate({ + translateY: scrollOffset + }); + + this.currentPage = currentPage; + this.positionCheckboxes(scrollOffset); + } + + } + +}; + +/* + * LegendSymbolMixin + */ + +var LegendSymbolMixin = Highcharts.LegendSymbolMixin = { + + /** + * Get the series' symbol in the legend + * + * @param {Object} legend The legend object + * @param {Object} item The series (this) or point + */ + drawRectangle: function (legend, item) { + var symbolHeight = legend.options.symbolHeight || 12; + + item.legendSymbol = this.chart.renderer.rect( + 0, + legend.baseline - 5 - (symbolHeight / 2), + legend.symbolWidth, + symbolHeight, + legend.options.symbolRadius || 0 + ).attr({ + zIndex: 3 + }).add(item.legendGroup); + + }, + + /** + * Get the series' symbol in the legend. This method should be overridable to create custom + * symbols through Highcharts.seriesTypes[type].prototype.drawLegendSymbols. + * + * @param {Object} legend The legend object + */ + drawLineMarker: function (legend) { + + var options = this.options, + markerOptions = options.marker, + radius, + legendOptions = legend.options, + legendSymbol, + symbolWidth = legend.symbolWidth, + renderer = this.chart.renderer, + legendItemGroup = this.legendGroup, + verticalCenter = legend.baseline - mathRound(renderer.fontMetrics(legendOptions.itemStyle.fontSize, this.legendItem).b * 0.3), + attr; + + // Draw the line + if (options.lineWidth) { + attr = { + 'stroke-width': options.lineWidth + }; + if (options.dashStyle) { + attr.dashstyle = options.dashStyle; + } + this.legendLine = renderer.path([ + M, + 0, + verticalCenter, + L, + symbolWidth, + verticalCenter + ]) + .attr(attr) + .add(legendItemGroup); + } + + // Draw the marker + if (markerOptions && markerOptions.enabled !== false) { + radius = markerOptions.radius; + this.legendSymbol = legendSymbol = renderer.symbol( + this.symbol, + (symbolWidth / 2) - radius, + verticalCenter - radius, + 2 * radius, + 2 * radius + ) + .add(legendItemGroup); + legendSymbol.isMarker = true; + } + } +}; + +// Workaround for #2030, horizontal legend items not displaying in IE11 Preview, +// and for #2580, a similar drawing flaw in Firefox 26. +// TODO: Explore if there's a general cause for this. The problem may be related +// to nested group elements, as the legend item texts are within 4 group elements. +if (/Trident\/7\.0/.test(userAgent) || isFirefox) { + wrap(Legend.prototype, 'positionItem', function (proceed, item) { + var legend = this, + runPositionItem = function () { // If chart destroyed in sync, this is undefined (#2030) + if (item._legendItemPos) { + proceed.call(legend, item); + } + }; + + // Do it now, for export and to get checkbox placement + runPositionItem(); + + // Do it after to work around the core issue + setTimeout(runPositionItem); + }); +} +/** + * The chart class + * @param {Object} options + * @param {Function} callback Function to run when the chart has loaded + */ +function Chart() { + this.init.apply(this, arguments); +} + +Chart.prototype = { + + /** + * Initialize the chart + */ + init: function (userOptions, callback) { + + // Handle regular options + var options, + seriesOptions = userOptions.series; // skip merging data points to increase performance + + userOptions.series = null; + options = merge(defaultOptions, userOptions); // do the merge + options.series = userOptions.series = seriesOptions; // set back the series data + this.userOptions = userOptions; + + var optionsChart = options.chart; + + // Create margin & spacing array + this.margin = this.splashArray('margin', optionsChart); + this.spacing = this.splashArray('spacing', optionsChart); + + var chartEvents = optionsChart.events; + + //this.runChartClick = chartEvents && !!chartEvents.click; + this.bounds = { h: {}, v: {} }; // Pixel data bounds for touch zoom + + this.callback = callback; + this.isResizing = 0; + this.options = options; + //chartTitleOptions = UNDEFINED; + //chartSubtitleOptions = UNDEFINED; + + this.axes = []; + this.series = []; + this.hasCartesianSeries = optionsChart.showAxes; + //this.axisOffset = UNDEFINED; + //this.maxTicks = UNDEFINED; // handle the greatest amount of ticks on grouped axes + //this.inverted = UNDEFINED; + //this.loadingShown = UNDEFINED; + //this.container = UNDEFINED; + //this.chartWidth = UNDEFINED; + //this.chartHeight = UNDEFINED; + //this.marginRight = UNDEFINED; + //this.marginBottom = UNDEFINED; + //this.containerWidth = UNDEFINED; + //this.containerHeight = UNDEFINED; + //this.oldChartWidth = UNDEFINED; + //this.oldChartHeight = UNDEFINED; + + //this.renderTo = UNDEFINED; + //this.renderToClone = UNDEFINED; + + //this.spacingBox = UNDEFINED + + //this.legend = UNDEFINED; + + // Elements + //this.chartBackground = UNDEFINED; + //this.plotBackground = UNDEFINED; + //this.plotBGImage = UNDEFINED; + //this.plotBorder = UNDEFINED; + //this.loadingDiv = UNDEFINED; + //this.loadingSpan = UNDEFINED; + + var chart = this, + eventType; + + // Add the chart to the global lookup + chart.index = charts.length; + charts.push(chart); + chartCount++; + + // Set up auto resize + if (optionsChart.reflow !== false) { + addEvent(chart, 'load', function () { + chart.initReflow(); + }); + } + + // Chart event handlers + if (chartEvents) { + for (eventType in chartEvents) { + addEvent(chart, eventType, chartEvents[eventType]); + } + } + + chart.xAxis = []; + chart.yAxis = []; + + // Expose methods and variables + chart.animation = useCanVG ? false : pick(optionsChart.animation, true); + chart.pointCount = chart.colorCounter = chart.symbolCounter = 0; + + chart.firstRender(); + }, + + /** + * Initialize an individual series, called internally before render time + */ + initSeries: function (options) { + var chart = this, + optionsChart = chart.options.chart, + type = options.type || optionsChart.type || optionsChart.defaultSeriesType, + series, + constr = seriesTypes[type]; + + // No such series type + if (!constr) { + error(17, true); + } + + series = new constr(); + series.init(this, options); + return series; + }, + + /** + * Check whether a given point is within the plot area + * + * @param {Number} plotX Pixel x relative to the plot area + * @param {Number} plotY Pixel y relative to the plot area + * @param {Boolean} inverted Whether the chart is inverted + */ + isInsidePlot: function (plotX, plotY, inverted) { + var x = inverted ? plotY : plotX, + y = inverted ? plotX : plotY; + + return x >= 0 && + x <= this.plotWidth && + y >= 0 && + y <= this.plotHeight; + }, + + /** + * Adjust all axes tick amounts + */ + adjustTickAmounts: function () { + if (this.options.chart.alignTicks !== false) { + each(this.axes, function (axis) { + axis.adjustTickAmount(); + }); + } + this.maxTicks = null; + }, + + /** + * Redraw legend, axes or series based on updated data + * + * @param {Boolean|Object} animation Whether to apply animation, and optionally animation + * configuration + */ + redraw: function (animation) { + var chart = this, + axes = chart.axes, + series = chart.series, + pointer = chart.pointer, + legend = chart.legend, + redrawLegend = chart.isDirtyLegend, + hasStackedSeries, + hasDirtyStacks, + hasCartesianSeries = chart.hasCartesianSeries, + isDirtyBox = chart.isDirtyBox, // todo: check if it has actually changed? + seriesLength = series.length, + i = seriesLength, + serie, + renderer = chart.renderer, + isHiddenChart = renderer.isHidden(), + afterRedraw = []; + + setAnimation(animation, chart); + + if (isHiddenChart) { + chart.cloneRenderTo(); + } + + // Adjust title layout (reflow multiline text) + chart.layOutTitles(); + + // link stacked series + while (i--) { + serie = series[i]; + + if (serie.options.stacking) { + hasStackedSeries = true; + + if (serie.isDirty) { + hasDirtyStacks = true; + break; + } + } + } + if (hasDirtyStacks) { // mark others as dirty + i = seriesLength; + while (i--) { + serie = series[i]; + if (serie.options.stacking) { + serie.isDirty = true; + } + } + } + + // handle updated data in the series + each(series, function (serie) { + if (serie.isDirty) { // prepare the data so axis can read it + if (serie.options.legendType === 'point') { + redrawLegend = true; + } + } + }); + + // handle added or removed series + if (redrawLegend && legend.options.enabled) { // series or pie points are added or removed + // draw legend graphics + legend.render(); + + chart.isDirtyLegend = false; + } + + // reset stacks + if (hasStackedSeries) { + chart.getStacks(); + } + + + if (hasCartesianSeries) { + if (!chart.isResizing) { + + // reset maxTicks + chart.maxTicks = null; + + // set axes scales + each(axes, function (axis) { + axis.setScale(); + }); + } + + chart.adjustTickAmounts(); + } + + chart.getMargins(); // #3098 + + if (hasCartesianSeries) { + // If one axis is dirty, all axes must be redrawn (#792, #2169) + each(axes, function (axis) { + if (axis.isDirty) { + isDirtyBox = true; + } + }); + + // redraw axes + each(axes, function (axis) { + + // Fire 'afterSetExtremes' only if extremes are set + if (axis.isDirtyExtremes) { // #821 + axis.isDirtyExtremes = false; + afterRedraw.push(function () { // prevent a recursive call to chart.redraw() (#1119) + fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751 + delete axis.eventArgs; + }); + } + + if (isDirtyBox || hasStackedSeries) { + axis.redraw(); + } + }); + } + + // the plot areas size has changed + if (isDirtyBox) { + chart.drawChartBox(); + } + + + // redraw affected series + each(series, function (serie) { + if (serie.isDirty && serie.visible && + (!serie.isCartesian || serie.xAxis)) { // issue #153 + serie.redraw(); + } + }); + + // move tooltip or reset + if (pointer) { + pointer.reset(true); + } + + // redraw if canvas + renderer.draw(); + + // fire the event + fireEvent(chart, 'redraw'); // jQuery breaks this when calling it from addEvent. Overwrites chart.redraw + + if (isHiddenChart) { + chart.cloneRenderTo(true); + } + + // Fire callbacks that are put on hold until after the redraw + each(afterRedraw, function (callback) { + callback.call(); + }); + }, + + /** + * Get an axis, series or point object by id. + * @param id {String} The id as given in the configuration options + */ + get: function (id) { + var chart = this, + axes = chart.axes, + series = chart.series; + + var i, + j, + points; + + // search axes + for (i = 0; i < axes.length; i++) { + if (axes[i].options.id === id) { + return axes[i]; + } + } + + // search series + for (i = 0; i < series.length; i++) { + if (series[i].options.id === id) { + return series[i]; + } + } + + // search points + for (i = 0; i < series.length; i++) { + points = series[i].points || []; + for (j = 0; j < points.length; j++) { + if (points[j].id === id) { + return points[j]; + } + } + } + return null; + }, + + /** + * Create the Axis instances based on the config options + */ + getAxes: function () { + var chart = this, + options = this.options, + xAxisOptions = options.xAxis = splat(options.xAxis || {}), + yAxisOptions = options.yAxis = splat(options.yAxis || {}), + optionsArray, + axis; + + // make sure the options are arrays and add some members + each(xAxisOptions, function (axis, i) { + axis.index = i; + axis.isX = true; + }); + + each(yAxisOptions, function (axis, i) { + axis.index = i; + }); + + // concatenate all axis options into one array + optionsArray = xAxisOptions.concat(yAxisOptions); + + each(optionsArray, function (axisOptions) { + axis = new Axis(chart, axisOptions); + }); + + chart.adjustTickAmounts(); + }, + + + /** + * Get the currently selected points from all series + */ + getSelectedPoints: function () { + var points = []; + each(this.series, function (serie) { + points = points.concat(grep(serie.points || [], function (point) { + return point.selected; + })); + }); + return points; + }, + + /** + * Get the currently selected series + */ + getSelectedSeries: function () { + return grep(this.series, function (serie) { + return serie.selected; + }); + }, + + /** + * Generate stacks for each series and calculate stacks total values + */ + getStacks: function () { + var chart = this; + + // reset stacks for each yAxis + each(chart.yAxis, function (axis) { + if (axis.stacks && axis.hasVisibleSeries) { + axis.oldStacks = axis.stacks; + } + }); + + each(chart.series, function (series) { + if (series.options.stacking && (series.visible === true || chart.options.chart.ignoreHiddenSeries === false)) { + series.stackKey = series.type + pick(series.options.stack, ''); + } + }); + }, + + /** + * Show the title and subtitle of the chart + * + * @param titleOptions {Object} New title options + * @param subtitleOptions {Object} New subtitle options + * + */ + setTitle: function (titleOptions, subtitleOptions, redraw) { + var chart = this, + options = chart.options, + chartTitleOptions, + chartSubtitleOptions; + + chartTitleOptions = options.title = merge(options.title, titleOptions); + chartSubtitleOptions = options.subtitle = merge(options.subtitle, subtitleOptions); + + // add title and subtitle + each([ + ['title', titleOptions, chartTitleOptions], + ['subtitle', subtitleOptions, chartSubtitleOptions] + ], function (arr) { + var name = arr[0], + title = chart[name], + titleOptions = arr[1], + chartTitleOptions = arr[2]; + + if (title && titleOptions) { + chart[name] = title = title.destroy(); // remove old + } + + if (chartTitleOptions && chartTitleOptions.text && !title) { + chart[name] = chart.renderer.text( + chartTitleOptions.text, + 0, + 0, + chartTitleOptions.useHTML + ) + .attr({ + align: chartTitleOptions.align, + 'class': PREFIX + name, + zIndex: chartTitleOptions.zIndex || 4 + }) + .css(chartTitleOptions.style) + .add(); + } + }); + chart.layOutTitles(redraw); + }, + + /** + * Lay out the chart titles and cache the full offset height for use in getMargins + */ + layOutTitles: function (redraw) { + var titleOffset = 0, + title = this.title, + subtitle = this.subtitle, + options = this.options, + titleOptions = options.title, + subtitleOptions = options.subtitle, + requiresDirtyBox, + renderer = this.renderer, + autoWidth = this.spacingBox.width - 44; // 44 makes room for default context button + + if (title) { + title + .css({ width: (titleOptions.width || autoWidth) + PX }) + .align(extend({ + y: renderer.fontMetrics(titleOptions.style.fontSize, title).b - 3 + }, titleOptions), false, 'spacingBox'); + + if (!titleOptions.floating && !titleOptions.verticalAlign) { + titleOffset = title.getBBox().height; + } + } + if (subtitle) { + subtitle + .css({ width: (subtitleOptions.width || autoWidth) + PX }) + .align(extend({ + y: titleOffset + (titleOptions.margin - 13) + renderer.fontMetrics(titleOptions.style.fontSize, subtitle).b + }, subtitleOptions), false, 'spacingBox'); + + if (!subtitleOptions.floating && !subtitleOptions.verticalAlign) { + titleOffset = mathCeil(titleOffset + subtitle.getBBox().height); + } + } + + requiresDirtyBox = this.titleOffset !== titleOffset; + this.titleOffset = titleOffset; // used in getMargins + + if (!this.isDirtyBox && requiresDirtyBox) { + this.isDirtyBox = requiresDirtyBox; + // Redraw if necessary (#2719, #2744) + if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) { + this.redraw(); + } + } + }, + + /** + * Get chart width and height according to options and container size + */ + getChartSize: function () { + var chart = this, + optionsChart = chart.options.chart, + widthOption = optionsChart.width, + heightOption = optionsChart.height, + renderTo = chart.renderToClone || chart.renderTo; + + // get inner width and height from jQuery (#824) + if (!defined(widthOption)) { + chart.containerWidth = adapterRun(renderTo, 'width'); + } + if (!defined(heightOption)) { + chart.containerHeight = adapterRun(renderTo, 'height'); + } + + chart.chartWidth = mathMax(0, widthOption || chart.containerWidth || 600); // #1393, 1460 + chart.chartHeight = mathMax(0, pick(heightOption, + // the offsetHeight of an empty container is 0 in standard browsers, but 19 in IE7: + chart.containerHeight > 19 ? chart.containerHeight : 400)); + }, + + /** + * Create a clone of the chart's renderTo div and place it outside the viewport to allow + * size computation on chart.render and chart.redraw + */ + cloneRenderTo: function (revert) { + var clone = this.renderToClone, + container = this.container; + + // Destroy the clone and bring the container back to the real renderTo div + if (revert) { + if (clone) { + this.renderTo.appendChild(container); + discardElement(clone); + delete this.renderToClone; + } + + // Set up the clone + } else { + if (container && container.parentNode === this.renderTo) { + this.renderTo.removeChild(container); // do not clone this + } + this.renderToClone = clone = this.renderTo.cloneNode(0); + css(clone, { + position: ABSOLUTE, + top: '-9999px', + display: 'block' // #833 + }); + if (clone.style.setProperty) { // #2631 + clone.style.setProperty('display', 'block', 'important'); + } + doc.body.appendChild(clone); + if (container) { + clone.appendChild(container); + } + } + }, + + /** + * Get the containing element, determine the size and create the inner container + * div to hold the chart + */ + getContainer: function () { + var chart = this, + container, + optionsChart = chart.options.chart, + chartWidth, + chartHeight, + renderTo, + indexAttrName = 'data-highcharts-chart', + oldChartIndex, + containerId; + + chart.renderTo = renderTo = optionsChart.renderTo; + containerId = PREFIX + idCounter++; + + if (isString(renderTo)) { + chart.renderTo = renderTo = doc.getElementById(renderTo); + } + + // Display an error if the renderTo is wrong + if (!renderTo) { + error(13, true); + } + + // If the container already holds a chart, destroy it. The check for hasRendered is there + // because web pages that are saved to disk from the browser, will preserve the data-highcharts-chart + // attribute and the SVG contents, but not an interactive chart. So in this case, + // charts[oldChartIndex] will point to the wrong chart if any (#2609). + oldChartIndex = pInt(attr(renderTo, indexAttrName)); + if (!isNaN(oldChartIndex) && charts[oldChartIndex] && charts[oldChartIndex].hasRendered) { + charts[oldChartIndex].destroy(); + } + + // Make a reference to the chart from the div + attr(renderTo, indexAttrName, chart.index); + + // remove previous chart + renderTo.innerHTML = ''; + + // If the container doesn't have an offsetWidth, it has or is a child of a node + // that has display:none. We need to temporarily move it out to a visible + // state to determine the size, else the legend and tooltips won't render + // properly. The allowClone option is used in sparklines as a micro optimization, + // saving about 1-2 ms each chart. + if (!optionsChart.skipClone && !renderTo.offsetWidth) { + chart.cloneRenderTo(); + } + + // get the width and height + chart.getChartSize(); + chartWidth = chart.chartWidth; + chartHeight = chart.chartHeight; + + // create the inner container + chart.container = container = createElement(DIV, { + className: PREFIX + 'container' + + (optionsChart.className ? ' ' + optionsChart.className : ''), + id: containerId + }, extend({ + position: RELATIVE, + overflow: HIDDEN, // needed for context menu (avoid scrollbars) and + // content overflow in IE + width: chartWidth + PX, + height: chartHeight + PX, + textAlign: 'left', + lineHeight: 'normal', // #427 + zIndex: 0, // #1072 + '-webkit-tap-highlight-color': 'rgba(0,0,0,0)' + }, optionsChart.style), + chart.renderToClone || renderTo + ); + + // cache the cursor (#1650) + chart._cursor = container.style.cursor; + + // Initialize the renderer + chart.renderer = + optionsChart.forExport ? // force SVG, used for SVG export + new SVGRenderer(container, chartWidth, chartHeight, optionsChart.style, true) : + new Renderer(container, chartWidth, chartHeight, optionsChart.style); + + if (useCanVG) { + // If we need canvg library, extend and configure the renderer + // to get the tracker for translating mouse events + chart.renderer.create(chart, container, chartWidth, chartHeight); + } + }, + + /** + * Calculate margins by rendering axis labels in a preliminary position. Title, + * subtitle and legend have already been rendered at this stage, but will be + * moved into their final positions + */ + getMargins: function () { + var chart = this, + spacing = chart.spacing, + axisOffset, + legend = chart.legend, + margin = chart.margin, + legendOptions = chart.options.legend, + legendMargin = pick(legendOptions.margin, 20), + legendX = legendOptions.x, + legendY = legendOptions.y, + align = legendOptions.align, + verticalAlign = legendOptions.verticalAlign, + titleOffset = chart.titleOffset; + + chart.resetMargins(); + axisOffset = chart.axisOffset; + + // Adjust for title and subtitle + if (titleOffset && !defined(margin[0])) { + chart.plotTop = mathMax(chart.plotTop, titleOffset + chart.options.title.margin + spacing[0]); + } + + // Adjust for legend + if (legend.display && !legendOptions.floating) { + if (align === 'right') { // horizontal alignment handled first + if (!defined(margin[1])) { + chart.marginRight = mathMax( + chart.marginRight, + legend.legendWidth - legendX + legendMargin + spacing[1] + ); + } + } else if (align === 'left') { + if (!defined(margin[3])) { + chart.plotLeft = mathMax( + chart.plotLeft, + legend.legendWidth + legendX + legendMargin + spacing[3] + ); + } + + } else if (verticalAlign === 'top') { + if (!defined(margin[0])) { + chart.plotTop = mathMax( + chart.plotTop, + legend.legendHeight + legendY + legendMargin + spacing[0] + ); + } + + } else if (verticalAlign === 'bottom') { + if (!defined(margin[2])) { + chart.marginBottom = mathMax( + chart.marginBottom, + legend.legendHeight - legendY + legendMargin + spacing[2] + ); + } + } + } + + // adjust for scroller + if (chart.extraBottomMargin) { + chart.marginBottom += chart.extraBottomMargin; + } + if (chart.extraTopMargin) { + chart.plotTop += chart.extraTopMargin; + } + + // pre-render axes to get labels offset width + if (chart.hasCartesianSeries) { + each(chart.axes, function (axis) { + axis.getOffset(); + }); + } + + if (!defined(margin[3])) { + chart.plotLeft += axisOffset[3]; + } + if (!defined(margin[0])) { + chart.plotTop += axisOffset[0]; + } + if (!defined(margin[2])) { + chart.marginBottom += axisOffset[2]; + } + if (!defined(margin[1])) { + chart.marginRight += axisOffset[1]; + } + + chart.setChartSize(); + + }, + + /** + * Resize the chart to its container if size is not explicitly set + */ + reflow: function (e) { + var chart = this, + optionsChart = chart.options.chart, + renderTo = chart.renderTo, + width = optionsChart.width || adapterRun(renderTo, 'width'), + height = optionsChart.height || adapterRun(renderTo, 'height'), + target = e ? e.target : win, // #805 - MooTools doesn't supply e + doReflow = function () { + if (chart.container) { // It may have been destroyed in the meantime (#1257) + chart.setSize(width, height, false); + chart.hasUserSize = null; + } + }; + + // Width and height checks for display:none. Target is doc in IE8 and Opera, + // win in Firefox, Chrome and IE9. + if (!chart.hasUserSize && width && height && (target === win || target === doc)) { + if (width !== chart.containerWidth || height !== chart.containerHeight) { + clearTimeout(chart.reflowTimeout); + if (e) { // Called from window.resize + chart.reflowTimeout = setTimeout(doReflow, 100); + } else { // Called directly (#2224) + doReflow(); + } + } + chart.containerWidth = width; + chart.containerHeight = height; + } + }, + + /** + * Add the event handlers necessary for auto resizing + */ + initReflow: function () { + var chart = this, + reflow = function (e) { + chart.reflow(e); + }; + + + addEvent(win, 'resize', reflow); + addEvent(chart, 'destroy', function () { + removeEvent(win, 'resize', reflow); + }); + }, + + /** + * Resize the chart to a given width and height + * @param {Number} width + * @param {Number} height + * @param {Object|Boolean} animation + */ + setSize: function (width, height, animation) { + var chart = this, + chartWidth, + chartHeight, + fireEndResize; + + // Handle the isResizing counter + chart.isResizing += 1; + fireEndResize = function () { + if (chart) { + fireEvent(chart, 'endResize', null, function () { + chart.isResizing -= 1; + }); + } + }; + + // set the animation for the current process + setAnimation(animation, chart); + + chart.oldChartHeight = chart.chartHeight; + chart.oldChartWidth = chart.chartWidth; + if (defined(width)) { + chart.chartWidth = chartWidth = mathMax(0, mathRound(width)); + chart.hasUserSize = !!chartWidth; + } + if (defined(height)) { + chart.chartHeight = chartHeight = mathMax(0, mathRound(height)); + } + + // Resize the container with the global animation applied if enabled (#2503) + (globalAnimation ? animate : css)(chart.container, { + width: chartWidth + PX, + height: chartHeight + PX + }, globalAnimation); + + chart.setChartSize(true); + chart.renderer.setSize(chartWidth, chartHeight, animation); + + // handle axes + chart.maxTicks = null; + each(chart.axes, function (axis) { + axis.isDirty = true; + axis.setScale(); + }); + + // make sure non-cartesian series are also handled + each(chart.series, function (serie) { + serie.isDirty = true; + }); + + chart.isDirtyLegend = true; // force legend redraw + chart.isDirtyBox = true; // force redraw of plot and chart border + + chart.layOutTitles(); // #2857 + chart.getMargins(); + + chart.redraw(animation); + + + chart.oldChartHeight = null; + fireEvent(chart, 'resize'); + + // fire endResize and set isResizing back + // If animation is disabled, fire without delay + if (globalAnimation === false) { + fireEndResize(); + } else { // else set a timeout with the animation duration + setTimeout(fireEndResize, (globalAnimation && globalAnimation.duration) || 500); + } + }, + + /** + * Set the public chart properties. This is done before and after the pre-render + * to determine margin sizes + */ + setChartSize: function (skipAxes) { + var chart = this, + inverted = chart.inverted, + renderer = chart.renderer, + chartWidth = chart.chartWidth, + chartHeight = chart.chartHeight, + optionsChart = chart.options.chart, + spacing = chart.spacing, + clipOffset = chart.clipOffset, + clipX, + clipY, + plotLeft, + plotTop, + plotWidth, + plotHeight, + plotBorderWidth; + + chart.plotLeft = plotLeft = mathRound(chart.plotLeft); + chart.plotTop = plotTop = mathRound(chart.plotTop); + chart.plotWidth = plotWidth = mathMax(0, mathRound(chartWidth - plotLeft - chart.marginRight)); + chart.plotHeight = plotHeight = mathMax(0, mathRound(chartHeight - plotTop - chart.marginBottom)); + + chart.plotSizeX = inverted ? plotHeight : plotWidth; + chart.plotSizeY = inverted ? plotWidth : plotHeight; + + chart.plotBorderWidth = optionsChart.plotBorderWidth || 0; + + // Set boxes used for alignment + chart.spacingBox = renderer.spacingBox = { + x: spacing[3], + y: spacing[0], + width: chartWidth - spacing[3] - spacing[1], + height: chartHeight - spacing[0] - spacing[2] + }; + chart.plotBox = renderer.plotBox = { + x: plotLeft, + y: plotTop, + width: plotWidth, + height: plotHeight + }; + + plotBorderWidth = 2 * mathFloor(chart.plotBorderWidth / 2); + clipX = mathCeil(mathMax(plotBorderWidth, clipOffset[3]) / 2); + clipY = mathCeil(mathMax(plotBorderWidth, clipOffset[0]) / 2); + chart.clipBox = { + x: clipX, + y: clipY, + width: mathFloor(chart.plotSizeX - mathMax(plotBorderWidth, clipOffset[1]) / 2 - clipX), + height: mathMax(0, mathFloor(chart.plotSizeY - mathMax(plotBorderWidth, clipOffset[2]) / 2 - clipY)) + }; + + if (!skipAxes) { + each(chart.axes, function (axis) { + axis.setAxisSize(); + axis.setAxisTranslation(); + }); + } + }, + + /** + * Initial margins before auto size margins are applied + */ + resetMargins: function () { + var chart = this, + spacing = chart.spacing, + margin = chart.margin; + + chart.plotTop = pick(margin[0], spacing[0]); + chart.marginRight = pick(margin[1], spacing[1]); + chart.marginBottom = pick(margin[2], spacing[2]); + chart.plotLeft = pick(margin[3], spacing[3]); + chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left + chart.clipOffset = [0, 0, 0, 0]; + }, + + /** + * Draw the borders and backgrounds for chart and plot area + */ + drawChartBox: function () { + var chart = this, + optionsChart = chart.options.chart, + renderer = chart.renderer, + chartWidth = chart.chartWidth, + chartHeight = chart.chartHeight, + chartBackground = chart.chartBackground, + plotBackground = chart.plotBackground, + plotBorder = chart.plotBorder, + plotBGImage = chart.plotBGImage, + chartBorderWidth = optionsChart.borderWidth || 0, + chartBackgroundColor = optionsChart.backgroundColor, + plotBackgroundColor = optionsChart.plotBackgroundColor, + plotBackgroundImage = optionsChart.plotBackgroundImage, + plotBorderWidth = optionsChart.plotBorderWidth || 0, + mgn, + bgAttr, + plotLeft = chart.plotLeft, + plotTop = chart.plotTop, + plotWidth = chart.plotWidth, + plotHeight = chart.plotHeight, + plotBox = chart.plotBox, + clipRect = chart.clipRect, + clipBox = chart.clipBox; + + // Chart area + mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0); + + if (chartBorderWidth || chartBackgroundColor) { + if (!chartBackground) { + + bgAttr = { + fill: chartBackgroundColor || NONE + }; + if (chartBorderWidth) { // #980 + bgAttr.stroke = optionsChart.borderColor; + bgAttr['stroke-width'] = chartBorderWidth; + } + chart.chartBackground = renderer.rect(mgn / 2, mgn / 2, chartWidth - mgn, chartHeight - mgn, + optionsChart.borderRadius, chartBorderWidth) + .attr(bgAttr) + .addClass(PREFIX + 'background') + .add() + .shadow(optionsChart.shadow); + + } else { // resize + chartBackground.animate( + chartBackground.crisp({ width: chartWidth - mgn, height: chartHeight - mgn }) + ); + } + } + + + // Plot background + if (plotBackgroundColor) { + if (!plotBackground) { + chart.plotBackground = renderer.rect(plotLeft, plotTop, plotWidth, plotHeight, 0) + .attr({ + fill: plotBackgroundColor + }) + .add() + .shadow(optionsChart.plotShadow); + } else { + plotBackground.animate(plotBox); + } + } + if (plotBackgroundImage) { + if (!plotBGImage) { + chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight) + .add(); + } else { + plotBGImage.animate(plotBox); + } + } + + // Plot clip + if (!clipRect) { + chart.clipRect = renderer.clipRect(clipBox); + } else { + clipRect.animate({ + width: clipBox.width, + height: clipBox.height + }); + } + + // Plot area border + if (plotBorderWidth) { + if (!plotBorder) { + chart.plotBorder = renderer.rect(plotLeft, plotTop, plotWidth, plotHeight, 0, -plotBorderWidth) + .attr({ + stroke: optionsChart.plotBorderColor, + 'stroke-width': plotBorderWidth, + fill: NONE, + zIndex: 1 + }) + .add(); + } else { + plotBorder.animate( + plotBorder.crisp({ x: plotLeft, y: plotTop, width: plotWidth, height: plotHeight, strokeWidth: -plotBorderWidth }) //#3282 plotBorder should be negative + ); + } + } + + // reset + chart.isDirtyBox = false; + }, + + /** + * Detect whether a certain chart property is needed based on inspecting its options + * and series. This mainly applies to the chart.invert property, and in extensions to + * the chart.angular and chart.polar properties. + */ + propFromSeries: function () { + var chart = this, + optionsChart = chart.options.chart, + klass, + seriesOptions = chart.options.series, + i, + value; + + + each(['inverted', 'angular', 'polar'], function (key) { + + // The default series type's class + klass = seriesTypes[optionsChart.type || optionsChart.defaultSeriesType]; + + // Get the value from available chart-wide properties + value = ( + chart[key] || // 1. it is set before + optionsChart[key] || // 2. it is set in the options + (klass && klass.prototype[key]) // 3. it's default series class requires it + ); + + // 4. Check if any the chart's series require it + i = seriesOptions && seriesOptions.length; + while (!value && i--) { + klass = seriesTypes[seriesOptions[i].type]; + if (klass && klass.prototype[key]) { + value = true; + } + } + + // Set the chart property + chart[key] = value; + }); + + }, + + /** + * Link two or more series together. This is done initially from Chart.render, + * and after Chart.addSeries and Series.remove. + */ + linkSeries: function () { + var chart = this, + chartSeries = chart.series; + + // Reset links + each(chartSeries, function (series) { + series.linkedSeries.length = 0; + }); + + // Apply new links + each(chartSeries, function (series) { + var linkedTo = series.options.linkedTo; + if (isString(linkedTo)) { + if (linkedTo === ':previous') { + linkedTo = chart.series[series.index - 1]; + } else { + linkedTo = chart.get(linkedTo); + } + if (linkedTo) { + linkedTo.linkedSeries.push(series); + series.linkedParent = linkedTo; + } + } + }); + }, + + /** + * Render series for the chart + */ + renderSeries: function () { + each(this.series, function (serie) { + serie.translate(); + if (serie.setTooltipPoints) { + serie.setTooltipPoints(); + } + serie.render(); + }); + }, + + /** + * Render labels for the chart + */ + renderLabels: function () { + var chart = this, + labels = chart.options.labels; + if (labels.items) { + each(labels.items, function (label) { + var style = extend(labels.style, label.style), + x = pInt(style.left) + chart.plotLeft, + y = pInt(style.top) + chart.plotTop + 12; + + // delete to prevent rewriting in IE + delete style.left; + delete style.top; + + chart.renderer.text( + label.html, + x, + y + ) + .attr({ zIndex: 2 }) + .css(style) + .add(); + + }); + } + }, + + /** + * Render all graphics for the chart + */ + render: function () { + var chart = this, + axes = chart.axes, + renderer = chart.renderer, + options = chart.options; + + // Title + chart.setTitle(); + + + // Legend + chart.legend = new Legend(chart, options.legend); + + chart.getStacks(); // render stacks + + // Get margins by pre-rendering axes + // set axes scales + each(axes, function (axis) { + axis.setScale(); + }); + + chart.getMargins(); + + chart.maxTicks = null; // reset for second pass + each(axes, function (axis) { + axis.setTickPositions(true); // update to reflect the new margins + axis.setMaxTicks(); + }); + chart.adjustTickAmounts(); + chart.getMargins(); // second pass to check for new labels + + + // Draw the borders and backgrounds + chart.drawChartBox(); + + + // Axes + if (chart.hasCartesianSeries) { + each(axes, function (axis) { + axis.render(); + }); + } + + // The series + if (!chart.seriesGroup) { + chart.seriesGroup = renderer.g('series-group') + .attr({ zIndex: 3 }) + .add(); + } + chart.renderSeries(); + + // Labels + chart.renderLabels(); + + // Credits + chart.showCredits(options.credits); + + // Set flag + chart.hasRendered = true; + + }, + + /** + * Show chart credits based on config options + */ + showCredits: function (credits) { + if (credits.enabled && !this.credits) { + this.credits = this.renderer.text( + credits.text, + 0, + 0 + ) + .on('click', function () { + if (credits.href) { + location.href = credits.href; + } + }) + .attr({ + align: credits.position.align, + zIndex: 8 + }) + .css(credits.style) + .add() + .align(credits.position); + } + }, + + /** + * Clean up memory usage + */ + destroy: function () { + var chart = this, + axes = chart.axes, + series = chart.series, + container = chart.container, + i, + parentNode = container && container.parentNode; + + // fire the chart.destoy event + fireEvent(chart, 'destroy'); + + // Delete the chart from charts lookup array + charts[chart.index] = UNDEFINED; + chartCount--; + chart.renderTo.removeAttribute('data-highcharts-chart'); + + // remove events + removeEvent(chart); + + // ==== Destroy collections: + // Destroy axes + i = axes.length; + while (i--) { + axes[i] = axes[i].destroy(); + } + + // Destroy each series + i = series.length; + while (i--) { + series[i] = series[i].destroy(); + } + + // ==== Destroy chart properties: + each(['title', 'subtitle', 'chartBackground', 'plotBackground', 'plotBGImage', + 'plotBorder', 'seriesGroup', 'clipRect', 'credits', 'pointer', 'scroller', + 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip', 'renderer'], function (name) { + var prop = chart[name]; + + if (prop && prop.destroy) { + chart[name] = prop.destroy(); + } + }); + + // remove container and all SVG + if (container) { // can break in IE when destroyed before finished loading + container.innerHTML = ''; + removeEvent(container); + if (parentNode) { + discardElement(container); + } + + } + + // clean it all up + for (i in chart) { + delete chart[i]; + } + + }, + + + /** + * VML namespaces can't be added until after complete. Listening + * for Perini's doScroll hack is not enough. + */ + isReadyToRender: function () { + var chart = this; + + // Note: in spite of JSLint's complaints, win == win.top is required + /*jslint eqeq: true*/ + if ((!hasSVG && (win == win.top && doc.readyState !== 'complete')) || (useCanVG && !win.canvg)) { + /*jslint eqeq: false*/ + if (useCanVG) { + // Delay rendering until canvg library is downloaded and ready + CanVGController.push(function () { chart.firstRender(); }, chart.options.global.canvasToolsURL); + } else { + doc.attachEvent('onreadystatechange', function () { + doc.detachEvent('onreadystatechange', chart.firstRender); + if (doc.readyState === 'complete') { + chart.firstRender(); + } + }); + } + return false; + } + return true; + }, + + /** + * Prepare for first rendering after all data are loaded + */ + firstRender: function () { + var chart = this, + options = chart.options, + callback = chart.callback; + + // Check whether the chart is ready to render + if (!chart.isReadyToRender()) { + return; + } + + // Create the container + chart.getContainer(); + + // Run an early event after the container and renderer are established + fireEvent(chart, 'init'); + + + chart.resetMargins(); + chart.setChartSize(); + + // Set the common chart properties (mainly invert) from the given series + chart.propFromSeries(); + + // get axes + chart.getAxes(); + + // Initialize the series + each(options.series || [], function (serieOptions) { + chart.initSeries(serieOptions); + }); + + chart.linkSeries(); + + // Run an event after axes and series are initialized, but before render. At this stage, + // the series data is indexed and cached in the xData and yData arrays, so we can access + // those before rendering. Used in Highstock. + fireEvent(chart, 'beforeRender'); + + // depends on inverted and on margins being set + if (Highcharts.Pointer) { + chart.pointer = new Pointer(chart, options); + } + + chart.render(); + + // add canvas + chart.renderer.draw(); + // run callbacks + if (callback) { + callback.apply(chart, [chart]); + } + each(chart.callbacks, function (fn) { + fn.apply(chart, [chart]); + }); + + + // If the chart was rendered outside the top container, put it back in + chart.cloneRenderTo(true); + + fireEvent(chart, 'load'); + + }, + + /** + * Creates arrays for spacing and margin from given options. + */ + splashArray: function (target, options) { + var oVar = options[target], + tArray = isObject(oVar) ? oVar : [oVar, oVar, oVar, oVar]; + + return [pick(options[target + 'Top'], tArray[0]), + pick(options[target + 'Right'], tArray[1]), + pick(options[target + 'Bottom'], tArray[2]), + pick(options[target + 'Left'], tArray[3])]; + } +}; // end Chart + +// Hook for exporting module +Chart.prototype.callbacks = []; + +var CenteredSeriesMixin = Highcharts.CenteredSeriesMixin = { + /** + * Get the center of the pie based on the size and center options relative to the + * plot area. Borrowed by the polar and gauge series types. + */ + getCenter: function () { + + var options = this.options, + chart = this.chart, + slicingRoom = 2 * (options.slicedOffset || 0), + handleSlicingRoom, + plotWidth = chart.plotWidth - 2 * slicingRoom, + plotHeight = chart.plotHeight - 2 * slicingRoom, + centerOption = options.center, + positions = [pick(centerOption[0], '50%'), pick(centerOption[1], '50%'), options.size || '100%', options.innerSize || 0], + smallestSize = mathMin(plotWidth, plotHeight), + isPercent; + + return map(positions, function (length, i) { + isPercent = /%$/.test(length); + handleSlicingRoom = i < 2 || (i === 2 && isPercent); + return (isPercent ? + // i == 0: centerX, relative to width + // i == 1: centerY, relative to height + // i == 2: size, relative to smallestSize + // i == 4: innerSize, relative to smallestSize + [plotWidth, plotHeight, smallestSize, smallestSize][i] * + pInt(length) / 100 : + length) + (handleSlicingRoom ? slicingRoom : 0); + }); + } +}; + +/** + * The Point object and prototype. Inheritable and used as base for PiePoint + */ +var Point = function () {}; +Point.prototype = { + + /** + * Initialize the point + * @param {Object} series The series object containing this point + * @param {Object} options The data in either number, array or object format + */ + init: function (series, options, x) { + + var point = this, + colors; + point.series = series; + point.applyOptions(options, x); + point.pointAttr = {}; + + if (series.options.colorByPoint) { + colors = series.options.colors || series.chart.options.colors; + point.color = point.color || colors[series.colorCounter++]; + // loop back to zero + if (series.colorCounter === colors.length) { + series.colorCounter = 0; + } + } + + series.chart.pointCount++; + return point; + }, + /** + * Apply the options containing the x and y data and possible some extra properties. + * This is called on point init or from point.update. + * + * @param {Object} options + */ + applyOptions: function (options, x) { + var point = this, + series = point.series, + pointValKey = series.options.pointValKey || series.pointValKey; + + options = Point.prototype.optionsToObject.call(this, options); + + // copy options directly to point + extend(point, options); + point.options = point.options ? extend(point.options, options) : options; + + // For higher dimension series types. For instance, for ranges, point.y is mapped to point.low. + if (pointValKey) { + point.y = point[pointValKey]; + } + + // If no x is set by now, get auto incremented value. All points must have an + // x value, however the y value can be null to create a gap in the series + if (point.x === UNDEFINED && series) { + point.x = x === UNDEFINED ? series.autoIncrement() : x; + } + + return point; + }, + + /** + * Transform number or array configs into objects + */ + optionsToObject: function (options) { + var ret = {}, + series = this.series, + pointArrayMap = series.pointArrayMap || ['y'], + valueCount = pointArrayMap.length, + firstItemType, + i = 0, + j = 0; + + if (typeof options === 'number' || options === null) { + ret[pointArrayMap[0]] = options; + + } else if (isArray(options)) { + // with leading x value + if (options.length > valueCount) { + firstItemType = typeof options[0]; + if (firstItemType === 'string') { + ret.name = options[0]; + } else if (firstItemType === 'number') { + ret.x = options[0]; + } + i++; + } + while (j < valueCount) { + ret[pointArrayMap[j++]] = options[i++]; + } + } else if (typeof options === 'object') { + ret = options; + + // This is the fastest way to detect if there are individual point dataLabels that need + // to be considered in drawDataLabels. These can only occur in object configs. + if (options.dataLabels) { + series._hasPointLabels = true; + } + + // Same approach as above for markers + if (options.marker) { + series._hasPointMarkers = true; + } + } + return ret; + }, + + /** + * Destroy a point to clear memory. Its reference still stays in series.data. + */ + destroy: function () { + var point = this, + series = point.series, + chart = series.chart, + hoverPoints = chart.hoverPoints, + prop; + + chart.pointCount--; + + if (hoverPoints) { + point.setState(); + erase(hoverPoints, point); + if (!hoverPoints.length) { + chart.hoverPoints = null; + } + + } + if (point === chart.hoverPoint) { + point.onMouseOut(); + } + + // remove all events + if (point.graphic || point.dataLabel) { // removeEvent and destroyElements are performance expensive + removeEvent(point); + point.destroyElements(); + } + + if (point.legendItem) { // pies have legend items + chart.legend.destroyItem(point); + } + + for (prop in point) { + point[prop] = null; + } + + + }, + + /** + * Destroy SVG elements associated with the point + */ + destroyElements: function () { + var point = this, + props = ['graphic', 'dataLabel', 'dataLabelUpper', 'group', 'connector', 'shadowGroup'], + prop, + i = 6; + while (i--) { + prop = props[i]; + if (point[prop]) { + point[prop] = point[prop].destroy(); + } + } + }, + + /** + * Return the configuration hash needed for the data label and tooltip formatters + */ + getLabelConfig: function () { + var point = this; + return { + x: point.category, + y: point.y, + key: point.name || point.category, + series: point.series, + point: point, + percentage: point.percentage, + total: point.total || point.stackTotal + }; + }, + + /** + * Extendable method for formatting each point's tooltip line + * + * @return {String} A string to be concatenated in to the common tooltip text + */ + tooltipFormatter: function (pointFormat) { + + // Insert options for valueDecimals, valuePrefix, and valueSuffix + var series = this.series, + seriesTooltipOptions = series.tooltipOptions, + valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), + valuePrefix = seriesTooltipOptions.valuePrefix || '', + valueSuffix = seriesTooltipOptions.valueSuffix || ''; + + // Loop over the point array map and replace unformatted values with sprintf formatting markup + each(series.pointArrayMap || ['y'], function (key) { + key = '{point.' + key; // without the closing bracket + if (valuePrefix || valueSuffix) { + pointFormat = pointFormat.replace(key + '}', valuePrefix + key + '}' + valueSuffix); + } + pointFormat = pointFormat.replace(key + '}', key + ':,.' + valueDecimals + 'f}'); + }); + + return format(pointFormat, { + point: this, + series: this.series + }); + }, + + /** + * Fire an event on the Point object. Must not be renamed to fireEvent, as this + * causes a name clash in MooTools + * @param {String} eventType + * @param {Object} eventArgs Additional event arguments + * @param {Function} defaultFunction Default event handler + */ + firePointEvent: function (eventType, eventArgs, defaultFunction) { + var point = this, + series = this.series, + seriesOptions = series.options; + + // load event handlers on demand to save time on mouseover/out + if (seriesOptions.point.events[eventType] || (point.options && point.options.events && point.options.events[eventType])) { + this.importEvents(); + } + + // add default handler if in selection mode + if (eventType === 'click' && seriesOptions.allowPointSelect) { + defaultFunction = function (event) { + // Control key is for Windows, meta (= Cmd key) for Mac, Shift for Opera + point.select(null, event.ctrlKey || event.metaKey || event.shiftKey); + }; + } + + fireEvent(this, eventType, eventArgs, defaultFunction); + } +};/** + * @classDescription The base function which all other series types inherit from. The data in the series is stored + * in various arrays. + * + * - First, series.options.data contains all the original config options for + * each point whether added by options or methods like series.addPoint. + * - Next, series.data contains those values converted to points, but in case the series data length + * exceeds the cropThreshold, or if the data is grouped, series.data doesn't contain all the points. It + * only contains the points that have been created on demand. + * - Then there's series.points that contains all currently visible point objects. In case of cropping, + * the cropped-away points are not part of this array. The series.points array starts at series.cropStart + * compared to series.data and series.options.data. If however the series data is grouped, these can't + * be correlated one to one. + * - series.xData and series.processedXData contain clean x values, equivalent to series.data and series.points. + * - series.yData and series.processedYData contain clean x values, equivalent to series.data and series.points. + * + * @param {Object} chart + * @param {Object} options + */ +var Series = function () {}; + +Series.prototype = { + + isCartesian: true, + type: 'line', + pointClass: Point, + sorted: true, // requires the data to be sorted + requireSorting: true, + pointAttrToOptions: { // mapping between SVG attributes and the corresponding options + stroke: 'lineColor', + 'stroke-width': 'lineWidth', + fill: 'fillColor', + r: 'radius' + }, + axisTypes: ['xAxis', 'yAxis'], + colorCounter: 0, + parallelArrays: ['x', 'y'], // each point's x and y values are stored in this.xData and this.yData + init: function (chart, options) { + var series = this, + eventType, + events, + chartSeries = chart.series, + sortByIndex = function (a, b) { + return pick(a.options.index, a._i) - pick(b.options.index, b._i); + }; + + series.chart = chart; + series.options = options = series.setOptions(options); // merge with plotOptions + series.linkedSeries = []; + + // bind the axes + series.bindAxes(); + + // set some variables + extend(series, { + name: options.name, + state: NORMAL_STATE, + pointAttr: {}, + visible: options.visible !== false, // true by default + selected: options.selected === true // false by default + }); + + // special + if (useCanVG) { + options.animation = false; + } + + // register event listeners + events = options.events; + for (eventType in events) { + addEvent(series, eventType, events[eventType]); + } + if ( + (events && events.click) || + (options.point && options.point.events && options.point.events.click) || + options.allowPointSelect + ) { + chart.runTrackerClick = true; + } + + series.getColor(); + series.getSymbol(); + + // Set the data + each(series.parallelArrays, function (key) { + series[key + 'Data'] = []; + }); + series.setData(options.data, false); + + // Mark cartesian + if (series.isCartesian) { + chart.hasCartesianSeries = true; + } + + // Register it in the chart + chartSeries.push(series); + series._i = chartSeries.length - 1; + + // Sort series according to index option (#248, #1123, #2456) + stableSort(chartSeries, sortByIndex); + if (this.yAxis) { + stableSort(this.yAxis.series, sortByIndex); + } + + each(chartSeries, function (series, i) { + series.index = i; + series.name = series.name || 'Series ' + (i + 1); + }); + + }, + + /** + * Set the xAxis and yAxis properties of cartesian series, and register the series + * in the axis.series array + */ + bindAxes: function () { + var series = this, + seriesOptions = series.options, + chart = series.chart, + axisOptions; + + each(series.axisTypes || [], function (AXIS) { // repeat for xAxis and yAxis + + each(chart[AXIS], function (axis) { // loop through the chart's axis objects + axisOptions = axis.options; + + // apply if the series xAxis or yAxis option mathches the number of the + // axis, or if undefined, use the first axis + if ((seriesOptions[AXIS] === axisOptions.index) || + (seriesOptions[AXIS] !== UNDEFINED && seriesOptions[AXIS] === axisOptions.id) || + (seriesOptions[AXIS] === UNDEFINED && axisOptions.index === 0)) { + + // register this series in the axis.series lookup + axis.series.push(series); + + // set this series.xAxis or series.yAxis reference + series[AXIS] = axis; + + // mark dirty for redraw + axis.isDirty = true; + } + }); + + // The series needs an X and an Y axis + if (!series[AXIS] && series.optionalAxis !== AXIS) { + error(18, true); + } + + }); + }, + + /** + * For simple series types like line and column, the data values are held in arrays like + * xData and yData for quick lookup to find extremes and more. For multidimensional series + * like bubble and map, this can be extended with arrays like zData and valueData by + * adding to the series.parallelArrays array. + */ + updateParallelArrays: function (point, i) { + var series = point.series, + args = arguments, + fn = typeof i === 'number' ? + // Insert the value in the given position + function (key) { + var val = key === 'y' && series.toYData ? series.toYData(point) : point[key]; + series[key + 'Data'][i] = val; + } : + // Apply the method specified in i with the following arguments as arguments + function (key) { + Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2)); + }; + + each(series.parallelArrays, fn); + }, + + /** + * Return an auto incremented x value based on the pointStart and pointInterval options. + * This is only used if an x value is not given for the point that calls autoIncrement. + */ + autoIncrement: function () { + var series = this, + options = series.options, + xIncrement = series.xIncrement; + + xIncrement = pick(xIncrement, options.pointStart, 0); + + series.pointInterval = pick(series.pointInterval, options.pointInterval, 1); + + series.xIncrement = xIncrement + series.pointInterval; + return xIncrement; + }, + + /** + * Divide the series data into segments divided by null values. + */ + getSegments: function () { + var series = this, + lastNull = -1, + segments = [], + i, + points = series.points, + pointsLength = points.length; + + if (pointsLength) { // no action required for [] + + // if connect nulls, just remove null points + if (series.options.connectNulls) { + i = pointsLength; + while (i--) { + if (points[i].y === null) { + points.splice(i, 1); + } + } + if (points.length) { + segments = [points]; + } + + // else, split on null points + } else { + each(points, function (point, i) { + if (point.y === null) { + if (i > lastNull + 1) { + segments.push(points.slice(lastNull + 1, i)); + } + lastNull = i; + } else if (i === pointsLength - 1) { // last value + segments.push(points.slice(lastNull + 1, i + 1)); + } + }); + } + } + + // register it + series.segments = segments; + }, + + /** + * Set the series options by merging from the options tree + * @param {Object} itemOptions + */ + setOptions: function (itemOptions) { + var chart = this.chart, + chartOptions = chart.options, + plotOptions = chartOptions.plotOptions, + userOptions = chart.userOptions || {}, + userPlotOptions = userOptions.plotOptions || {}, + typeOptions = plotOptions[this.type], + options; + + this.userOptions = itemOptions; + + options = merge( + typeOptions, + plotOptions.series, + itemOptions + ); + + // The tooltip options are merged between global and series specific options + this.tooltipOptions = merge( + defaultOptions.tooltip, + defaultOptions.plotOptions[this.type].tooltip, + userOptions.tooltip, + userPlotOptions.series && userPlotOptions.series.tooltip, + userPlotOptions[this.type] && userPlotOptions[this.type].tooltip, + itemOptions.tooltip + ); + + // Delete marker object if not allowed (#1125) + if (typeOptions.marker === null) { + delete options.marker; + } + + return options; + + }, + + getCyclic: function (prop, value, defaults) { + var i, + userOptions = this.userOptions, + indexName = '_' + prop + 'Index', + counterName = prop + 'Counter'; + + if (!value) { + if (defined(userOptions[indexName])) { // after Series.update() + i = userOptions[indexName]; + } else { + userOptions[indexName] = i = this.chart[counterName] % defaults.length; + this.chart[counterName] += 1; + } + value = defaults[i]; + } + this[prop] = value; + }, + + /** + * Get the series' color + */ + getColor: function () { + if (!this.options.colorByPoint) { + this.getCyclic('color', this.options.color || defaultPlotOptions[this.type].color, this.chart.options.colors); + } + }, + /** + * Get the series' symbol + */ + getSymbol: function () { + var seriesMarkerOption = this.options.marker; + + this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols); + + // don't substract radius in image symbols (#604) + if (/^url/.test(this.symbol)) { + seriesMarkerOption.radius = 0; + } + }, + + drawLegendSymbol: LegendSymbolMixin.drawLineMarker, + + /** + * Replace the series data with a new set of data + * @param {Object} data + * @param {Object} redraw + */ + setData: function (data, redraw, animation, updatePoints) { + var series = this, + oldData = series.points, + oldDataLength = (oldData && oldData.length) || 0, + dataLength, + options = series.options, + chart = series.chart, + firstPoint = null, + xAxis = series.xAxis, + hasCategories = xAxis && !!xAxis.categories, + tooltipPoints = series.tooltipPoints, + i, + turboThreshold = options.turboThreshold, + pt, + xData = this.xData, + yData = this.yData, + pointArrayMap = series.pointArrayMap, + valueCount = pointArrayMap && pointArrayMap.length; + + data = data || []; + dataLength = data.length; + redraw = pick(redraw, true); + + // If the point count is the same as is was, just run Point.update which is + // cheaper, allows animation, and keeps references to points. + if (updatePoints !== false && dataLength && oldDataLength === dataLength && !series.cropped && !series.hasGroupedData) { + each(data, function (point, i) { + oldData[i].update(point, false, null, false); + }); + + } else { + + // Reset properties + series.xIncrement = null; + series.pointRange = hasCategories ? 1 : options.pointRange; + + series.colorCounter = 0; // for series with colorByPoint (#1547) + + // Update parallel arrays + each(this.parallelArrays, function (key) { + series[key + 'Data'].length = 0; + }); + + // In turbo mode, only one- or twodimensional arrays of numbers are allowed. The + // first value is tested, and we assume that all the rest are defined the same + // way. Although the 'for' loops are similar, they are repeated inside each + // if-else conditional for max performance. + if (turboThreshold && dataLength > turboThreshold) { + + // find the first non-null point + i = 0; + while (firstPoint === null && i < dataLength) { + firstPoint = data[i]; + i++; + } + + + if (isNumber(firstPoint)) { // assume all points are numbers + var x = pick(options.pointStart, 0), + pointInterval = pick(options.pointInterval, 1); + + for (i = 0; i < dataLength; i++) { + xData[i] = x; + yData[i] = data[i]; + x += pointInterval; + } + series.xIncrement = x; + } else if (isArray(firstPoint)) { // assume all points are arrays + if (valueCount) { // [x, low, high] or [x, o, h, l, c] + for (i = 0; i < dataLength; i++) { + pt = data[i]; + xData[i] = pt[0]; + yData[i] = pt.slice(1, valueCount + 1); + } + } else { // [x, y] + for (i = 0; i < dataLength; i++) { + pt = data[i]; + xData[i] = pt[0]; + yData[i] = pt[1]; + } + } + } else { + error(12); // Highcharts expects configs to be numbers or arrays in turbo mode + } + } else { + for (i = 0; i < dataLength; i++) { + if (data[i] !== UNDEFINED) { // stray commas in oldIE + pt = { series: series }; + series.pointClass.prototype.applyOptions.apply(pt, [data[i]]); + series.updateParallelArrays(pt, i); + if (hasCategories && pt.name) { + xAxis.names[pt.x] = pt.name; // #2046 + } + } + } + } + + // Forgetting to cast strings to numbers is a common caveat when handling CSV or JSON + if (isString(yData[0])) { + error(14, true); + } + + series.data = []; + series.options.data = data; + //series.zData = zData; + + // destroy old points + i = oldDataLength; + while (i--) { + if (oldData[i] && oldData[i].destroy) { + oldData[i].destroy(); + } + } + if (tooltipPoints) { // #2594 + tooltipPoints.length = 0; + } + + // reset minRange (#878) + if (xAxis) { + xAxis.minRange = xAxis.userMinRange; + } + + // redraw + series.isDirty = series.isDirtyData = chart.isDirtyBox = true; + animation = false; + } + + if (redraw) { + chart.redraw(animation); + } + }, + + /** + * Process the data by cropping away unused data points if the series is longer + * than the crop threshold. This saves computing time for lage series. + */ + processData: function (force) { + var series = this, + processedXData = series.xData, // copied during slice operation below + processedYData = series.yData, + dataLength = processedXData.length, + croppedData, + cropStart = 0, + cropped, + distance, + closestPointRange, + xAxis = series.xAxis, + i, // loop variable + options = series.options, + cropThreshold = options.cropThreshold, + activePointCount = 0, + isCartesian = series.isCartesian, + xExtremes, + min, + max; + + // If the series data or axes haven't changed, don't go through this. Return false to pass + // the message on to override methods like in data grouping. + if (isCartesian && !series.isDirty && !xAxis.isDirty && !series.yAxis.isDirty && !force) { + return false; + } + + if (xAxis) { + xExtremes = xAxis.getExtremes(); // corrected for log axis (#3053) + min = xExtremes.min; + max = xExtremes.max; + } + + // optionally filter out points outside the plot area + if (isCartesian && series.sorted && (!cropThreshold || dataLength > cropThreshold || series.forceCrop)) { + + // it's outside current extremes + if (processedXData[dataLength - 1] < min || processedXData[0] > max) { + processedXData = []; + processedYData = []; + + // only crop if it's actually spilling out + } else if (processedXData[0] < min || processedXData[dataLength - 1] > max) { + croppedData = this.cropData(series.xData, series.yData, min, max); + processedXData = croppedData.xData; + processedYData = croppedData.yData; + cropStart = croppedData.start; + cropped = true; + activePointCount = processedXData.length; + } + } + + + // Find the closest distance between processed points + for (i = processedXData.length - 1; i >= 0; i--) { + distance = processedXData[i] - processedXData[i - 1]; + + if (!cropped && processedXData[i] > min && processedXData[i] < max) { + activePointCount++; + } + + if (distance > 0 && (closestPointRange === UNDEFINED || distance < closestPointRange)) { + closestPointRange = distance; + + // Unsorted data is not supported by the line tooltip, as well as data grouping and + // navigation in Stock charts (#725) and width calculation of columns (#1900) + } else if (distance < 0 && series.requireSorting) { + error(15); + } + } + + // Record the properties + series.cropped = cropped; // undefined or true + series.cropStart = cropStart; + series.processedXData = processedXData; + series.processedYData = processedYData; + series.activePointCount = activePointCount; + + if (options.pointRange === null) { // null means auto, as for columns, candlesticks and OHLC + series.pointRange = closestPointRange || 1; + } + series.closestPointRange = closestPointRange; + + }, + + /** + * Iterate over xData and crop values between min and max. Returns object containing crop start/end + * cropped xData with corresponding part of yData, dataMin and dataMax within the cropped range + */ + cropData: function (xData, yData, min, max) { + var dataLength = xData.length, + cropStart = 0, + cropEnd = dataLength, + cropShoulder = pick(this.cropShoulder, 1), // line-type series need one point outside + i; + + // iterate up to find slice start + for (i = 0; i < dataLength; i++) { + if (xData[i] >= min) { + cropStart = mathMax(0, i - cropShoulder); + break; + } + } + + // proceed to find slice end + for (; i < dataLength; i++) { + if (xData[i] > max) { + cropEnd = i + cropShoulder; + break; + } + } + + return { + xData: xData.slice(cropStart, cropEnd), + yData: yData.slice(cropStart, cropEnd), + start: cropStart, + end: cropEnd + }; + }, + + + /** + * Generate the data point after the data has been processed by cropping away + * unused points and optionally grouped in Highcharts Stock. + */ + generatePoints: function () { + var series = this, + options = series.options, + dataOptions = options.data, + data = series.data, + dataLength, + processedXData = series.processedXData, + processedYData = series.processedYData, + pointClass = series.pointClass, + processedDataLength = processedXData.length, + cropStart = series.cropStart || 0, + cursor, + hasGroupedData = series.hasGroupedData, + point, + points = [], + i; + + if (!data && !hasGroupedData) { + var arr = []; + arr.length = dataOptions.length; + data = series.data = arr; + } + + for (i = 0; i < processedDataLength; i++) { + cursor = cropStart + i; + if (!hasGroupedData) { + if (data[cursor]) { + point = data[cursor]; + } else if (dataOptions[cursor] !== UNDEFINED) { // #970 + data[cursor] = point = (new pointClass()).init(series, dataOptions[cursor], processedXData[i]); + } + points[i] = point; + } else { + // splat the y data in case of ohlc data array + points[i] = (new pointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i]))); + } + points[i].index = cursor; // For faster access in Point.update + } + + // Hide cropped-away points - this only runs when the number of points is above cropThreshold, or when + // swithching view from non-grouped data to grouped data (#637) + if (data && (processedDataLength !== (dataLength = data.length) || hasGroupedData)) { + for (i = 0; i < dataLength; i++) { + if (i === cropStart && !hasGroupedData) { // when has grouped data, clear all points + i += processedDataLength; + } + if (data[i]) { + data[i].destroyElements(); + data[i].plotX = UNDEFINED; // #1003 + } + } + } + + series.data = data; + series.points = points; + }, + + /** + * Calculate Y extremes for visible data + */ + getExtremes: function (yData) { + var xAxis = this.xAxis, + yAxis = this.yAxis, + xData = this.processedXData, + yDataLength, + activeYData = [], + activeCounter = 0, + xExtremes = xAxis.getExtremes(), // #2117, need to compensate for log X axis + xMin = xExtremes.min, + xMax = xExtremes.max, + validValue, + withinRange, + dataMin, + dataMax, + x, + y, + i, + j; + + yData = yData || this.stackedYData || this.processedYData; + yDataLength = yData.length; + + for (i = 0; i < yDataLength; i++) { + + x = xData[i]; + y = yData[i]; + + // For points within the visible range, including the first point outside the + // visible range, consider y extremes + validValue = y !== null && y !== UNDEFINED && (!yAxis.isLog || (y.length || y > 0)); + withinRange = this.getExtremesFromAll || this.cropped || ((xData[i + 1] || x) >= xMin && + (xData[i - 1] || x) <= xMax); + + if (validValue && withinRange) { + + j = y.length; + if (j) { // array, like ohlc or range data + while (j--) { + if (y[j] !== null) { + activeYData[activeCounter++] = y[j]; + } + } + } else { + activeYData[activeCounter++] = y; + } + } + } + this.dataMin = pick(dataMin, arrayMin(activeYData)); + this.dataMax = pick(dataMax, arrayMax(activeYData)); + }, + + /** + * Translate data points from raw data values to chart specific positioning data + * needed later in drawPoints, drawGraph and drawTracker. + */ + translate: function () { + if (!this.processedXData) { // hidden series + this.processData(); + } + this.generatePoints(); + var series = this, + options = series.options, + stacking = options.stacking, + xAxis = series.xAxis, + categories = xAxis.categories, + yAxis = series.yAxis, + points = series.points, + dataLength = points.length, + hasModifyValue = !!series.modifyValue, + i, + pointPlacement = options.pointPlacement, + dynamicallyPlaced = pointPlacement === 'between' || isNumber(pointPlacement), + threshold = options.threshold; + + // Translate each point + for (i = 0; i < dataLength; i++) { + var point = points[i], + xValue = point.x, + yValue = point.y, + yBottom = point.low, + stack = stacking && yAxis.stacks[(series.negStacks && yValue < threshold ? '-' : '') + series.stackKey], + pointStack, + stackValues; + + // Discard disallowed y values for log axes + if (yAxis.isLog && yValue <= 0) { + point.y = yValue = null; + error(10); + } + + // Get the plotX translation + point.plotX = xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags'); // Math.round fixes #591 + + + // Calculate the bottom y value for stacked series + if (stacking && series.visible && stack && stack[xValue]) { + + pointStack = stack[xValue]; + stackValues = pointStack.points[series.index + ',' + i]; + yBottom = stackValues[0]; + yValue = stackValues[1]; + + if (yBottom === 0) { + yBottom = pick(threshold, yAxis.min); + } + if (yAxis.isLog && yBottom <= 0) { // #1200, #1232 + yBottom = null; + } + + point.total = point.stackTotal = pointStack.total; + point.percentage = pointStack.total && (point.y / pointStack.total * 100); + point.stackY = yValue; + + // Place the stack label + pointStack.setOffset(series.pointXOffset || 0, series.barW || 0); + + } + + // Set translated yBottom or remove it + point.yBottom = defined(yBottom) ? + yAxis.translate(yBottom, 0, 1, 0, 1) : + null; + + // general hook, used for Highstock compare mode + if (hasModifyValue) { + yValue = series.modifyValue(yValue, point); + } + + // Set the the plotY value, reset it for redraws + point.plotY = (typeof yValue === 'number' && yValue !== Infinity) ? + //mathRound(yAxis.translate(yValue, 0, 1, 0, 1) * 10) / 10 : // Math.round fixes #591 + yAxis.translate(yValue, 0, 1, 0, 1) : + UNDEFINED; + + // Set client related positions for mouse tracking + point.clientX = dynamicallyPlaced ? xAxis.translate(xValue, 0, 0, 0, 1) : point.plotX; // #1514 + + point.negative = point.y < (threshold || 0); + + // some API data + point.category = categories && categories[point.x] !== UNDEFINED ? + categories[point.x] : point.x; + + } + + // now that we have the cropped data, build the segments + series.getSegments(); + }, + + /** + * Animate in the series + */ + animate: function (init) { + var series = this, + chart = series.chart, + renderer = chart.renderer, + clipRect, + markerClipRect, + animation = series.options.animation, + clipBox = series.clipBox || chart.clipBox, + inverted = chart.inverted, + sharedClipKey; + + // Animation option is set to true + if (animation && !isObject(animation)) { + animation = defaultPlotOptions[series.type].animation; + } + sharedClipKey = ['_sharedClip', animation.duration, animation.easing, clipBox.height].join(','); + + // Initialize the animation. Set up the clipping rectangle. + if (init) { + + // If a clipping rectangle with the same properties is currently present in the chart, use that. + clipRect = chart[sharedClipKey]; + markerClipRect = chart[sharedClipKey + 'm']; + if (!clipRect) { + chart[sharedClipKey] = clipRect = renderer.clipRect( + extend(clipBox, { width: 0 }) + ); + + chart[sharedClipKey + 'm'] = markerClipRect = renderer.clipRect( + -99, // include the width of the first marker + inverted ? -chart.plotLeft : -chart.plotTop, + 99, + inverted ? chart.chartWidth : chart.chartHeight + ); + } + series.group.clip(clipRect); + series.markerGroup.clip(markerClipRect); + series.sharedClipKey = sharedClipKey; + + // Run the animation + } else { + clipRect = chart[sharedClipKey]; + if (clipRect) { + clipRect.animate({ + width: chart.plotSizeX + }, animation); + } + if (chart[sharedClipKey + 'm']) { + chart[sharedClipKey + 'm'].animate({ + width: chart.plotSizeX + 99 + }, animation); + } + + // Delete this function to allow it only once + series.animate = null; + + } + }, + + /** + * This runs after animation to land on the final plot clipping + */ + afterAnimate: function () { + var chart = this.chart, + sharedClipKey = this.sharedClipKey, + group = this.group, + clipBox = this.clipBox; + + if (group && this.options.clip !== false) { + if (!sharedClipKey || !clipBox) { + group.clip(clipBox ? chart.renderer.clipRect(clipBox) : chart.clipRect); + } + this.markerGroup.clip(); // no clip + } + + fireEvent(this, 'afterAnimate'); + + // Remove the shared clipping rectancgle when all series are shown + setTimeout(function () { + if (sharedClipKey && chart[sharedClipKey]) { + if (!clipBox) { + chart[sharedClipKey] = chart[sharedClipKey].destroy(); + } + if (chart[sharedClipKey + 'm']) { + chart[sharedClipKey + 'm'] = chart[sharedClipKey + 'm'].destroy(); + } + } + }, 100); + }, + + /** + * Draw the markers + */ + drawPoints: function () { + var series = this, + pointAttr, + points = series.points, + chart = series.chart, + plotX, + plotY, + i, + point, + radius, + symbol, + isImage, + graphic, + options = series.options, + seriesMarkerOptions = options.marker, + seriesPointAttr = series.pointAttr[''], + pointMarkerOptions, + hasPointMarker, + enabled, + isInside, + markerGroup = series.markerGroup, + globallyEnabled = pick( + seriesMarkerOptions.enabled, + !series.requireSorting || series.activePointCount < (0.5 * series.xAxis.len / seriesMarkerOptions.radius) + ); + + if (seriesMarkerOptions.enabled !== false || series._hasPointMarkers) { + + i = points.length; + while (i--) { + point = points[i]; + plotX = mathFloor(point.plotX); // #1843 + plotY = point.plotY; + graphic = point.graphic; + pointMarkerOptions = point.marker || {}; + hasPointMarker = !!point.marker; + enabled = (globallyEnabled && pointMarkerOptions.enabled === UNDEFINED) || pointMarkerOptions.enabled; + isInside = chart.isInsidePlot(mathRound(plotX), plotY, chart.inverted); // #1858 + + // only draw the point if y is defined + if (enabled && plotY !== UNDEFINED && !isNaN(plotY) && point.y !== null) { + + // shortcuts + pointAttr = point.pointAttr[point.selected ? SELECT_STATE : NORMAL_STATE] || seriesPointAttr; + radius = pointAttr.r; + symbol = pick(pointMarkerOptions.symbol, series.symbol); + isImage = symbol.indexOf('url') === 0; + + if (graphic) { // update + graphic[isInside ? 'show' : 'hide'](true) // Since the marker group isn't clipped, each individual marker must be toggled + .animate(extend({ + x: plotX - radius, + y: plotY - radius + }, graphic.symbolName ? { // don't apply to image symbols #507 + width: 2 * radius, + height: 2 * radius + } : {})); + } else if (isInside && (radius > 0 || isImage)) { + point.graphic = graphic = chart.renderer.symbol( + symbol, + plotX - radius, + plotY - radius, + 2 * radius, + 2 * radius, + hasPointMarker ? pointMarkerOptions : seriesMarkerOptions + ) + .attr(pointAttr) + .add(markerGroup); + } + + } else if (graphic) { + point.graphic = graphic.destroy(); // #1269 + } + } + } + + }, + + /** + * Convert state properties from API naming conventions to SVG attributes + * + * @param {Object} options API options object + * @param {Object} base1 SVG attribute object to inherit from + * @param {Object} base2 Second level SVG attribute object to inherit from + */ + convertAttribs: function (options, base1, base2, base3) { + var conversion = this.pointAttrToOptions, + attr, + option, + obj = {}; + + options = options || {}; + base1 = base1 || {}; + base2 = base2 || {}; + base3 = base3 || {}; + + for (attr in conversion) { + option = conversion[attr]; + obj[attr] = pick(options[option], base1[attr], base2[attr], base3[attr]); + } + return obj; + }, + + /** + * Get the state attributes. Each series type has its own set of attributes + * that are allowed to change on a point's state change. Series wide attributes are stored for + * all series, and additionally point specific attributes are stored for all + * points with individual marker options. If such options are not defined for the point, + * a reference to the series wide attributes is stored in point.pointAttr. + */ + getAttribs: function () { + var series = this, + seriesOptions = series.options, + normalOptions = defaultPlotOptions[series.type].marker ? seriesOptions.marker : seriesOptions, + stateOptions = normalOptions.states, + stateOptionsHover = stateOptions[HOVER_STATE], + pointStateOptionsHover, + seriesColor = series.color, + normalDefaults = { + stroke: seriesColor, + fill: seriesColor + }, + points = series.points || [], // #927 + i, + point, + seriesPointAttr = [], + pointAttr, + pointAttrToOptions = series.pointAttrToOptions, + hasPointSpecificOptions = series.hasPointSpecificOptions, + negativeColor = seriesOptions.negativeColor, + defaultLineColor = normalOptions.lineColor, + defaultFillColor = normalOptions.fillColor, + turboThreshold = seriesOptions.turboThreshold, + attr, + key; + + // series type specific modifications + if (seriesOptions.marker) { // line, spline, area, areaspline, scatter + + // if no hover radius is given, default to normal radius + 2 + stateOptionsHover.radius = stateOptionsHover.radius || normalOptions.radius + stateOptionsHover.radiusPlus; + stateOptionsHover.lineWidth = stateOptionsHover.lineWidth || normalOptions.lineWidth + stateOptionsHover.lineWidthPlus; + + } else { // column, bar, pie + + // if no hover color is given, brighten the normal color + stateOptionsHover.color = stateOptionsHover.color || + Color(stateOptionsHover.color || seriesColor) + .brighten(stateOptionsHover.brightness).get(); + } + + // general point attributes for the series normal state + seriesPointAttr[NORMAL_STATE] = series.convertAttribs(normalOptions, normalDefaults); + + // HOVER_STATE and SELECT_STATE states inherit from normal state except the default radius + each([HOVER_STATE, SELECT_STATE], function (state) { + seriesPointAttr[state] = + series.convertAttribs(stateOptions[state], seriesPointAttr[NORMAL_STATE]); + }); + + // set it + series.pointAttr = seriesPointAttr; + + + // Generate the point-specific attribute collections if specific point + // options are given. If not, create a referance to the series wide point + // attributes + i = points.length; + if (!turboThreshold || i < turboThreshold || hasPointSpecificOptions) { + while (i--) { + point = points[i]; + normalOptions = (point.options && point.options.marker) || point.options; + if (normalOptions && normalOptions.enabled === false) { + normalOptions.radius = 0; + } + + if (point.negative && negativeColor) { + point.color = point.fillColor = negativeColor; + } + + hasPointSpecificOptions = seriesOptions.colorByPoint || point.color; // #868 + + // check if the point has specific visual options + if (point.options) { + for (key in pointAttrToOptions) { + if (defined(normalOptions[pointAttrToOptions[key]])) { + hasPointSpecificOptions = true; + } + } + } + + // a specific marker config object is defined for the individual point: + // create it's own attribute collection + if (hasPointSpecificOptions) { + normalOptions = normalOptions || {}; + pointAttr = []; + stateOptions = normalOptions.states || {}; // reassign for individual point + pointStateOptionsHover = stateOptions[HOVER_STATE] = stateOptions[HOVER_STATE] || {}; + + // Handle colors for column and pies + if (!seriesOptions.marker) { // column, bar, point + // If no hover color is given, brighten the normal color. #1619, #2579 + pointStateOptionsHover.color = pointStateOptionsHover.color || (!point.options.color && stateOptionsHover.color) || + Color(point.color) + .brighten(pointStateOptionsHover.brightness || stateOptionsHover.brightness) + .get(); + } + + // normal point state inherits series wide normal state + attr = { color: point.color }; // #868 + if (!defaultFillColor) { // Individual point color or negative color markers (#2219) + attr.fillColor = point.color; + } + if (!defaultLineColor) { + attr.lineColor = point.color; // Bubbles take point color, line markers use white + } + pointAttr[NORMAL_STATE] = series.convertAttribs(extend(attr, normalOptions), seriesPointAttr[NORMAL_STATE]); + + // inherit from point normal and series hover + pointAttr[HOVER_STATE] = series.convertAttribs( + stateOptions[HOVER_STATE], + seriesPointAttr[HOVER_STATE], + pointAttr[NORMAL_STATE] + ); + + // inherit from point normal and series hover + pointAttr[SELECT_STATE] = series.convertAttribs( + stateOptions[SELECT_STATE], + seriesPointAttr[SELECT_STATE], + pointAttr[NORMAL_STATE] + ); + + + // no marker config object is created: copy a reference to the series-wide + // attribute collection + } else { + pointAttr = seriesPointAttr; + } + + point.pointAttr = pointAttr; + } + } + }, + + /** + * Clear DOM objects and free up memory + */ + destroy: function () { + var series = this, + chart = series.chart, + issue134 = /AppleWebKit\/533/.test(userAgent), + destroy, + i, + data = series.data || [], + point, + prop, + axis; + + // add event hook + fireEvent(series, 'destroy'); + + // remove all events + removeEvent(series); + + // erase from axes + each(series.axisTypes || [], function (AXIS) { + axis = series[AXIS]; + if (axis) { + erase(axis.series, series); + axis.isDirty = axis.forceRedraw = true; + } + }); + + // remove legend items + if (series.legendItem) { + series.chart.legend.destroyItem(series); + } + + // destroy all points with their elements + i = data.length; + while (i--) { + point = data[i]; + if (point && point.destroy) { + point.destroy(); + } + } + series.points = null; + + // Clear the animation timeout if we are destroying the series during initial animation + clearTimeout(series.animationTimeout); + + // destroy all SVGElements associated to the series + each(['area', 'graph', 'dataLabelsGroup', 'group', 'markerGroup', 'tracker', + 'graphNeg', 'areaNeg', 'posClip', 'negClip'], function (prop) { + if (series[prop]) { + + // issue 134 workaround + destroy = issue134 && prop === 'group' ? + 'hide' : + 'destroy'; + + series[prop][destroy](); + } + }); + + // remove from hoverSeries + if (chart.hoverSeries === series) { + chart.hoverSeries = null; + } + erase(chart.series, series); + + // clear all members + for (prop in series) { + delete series[prop]; + } + }, + + /** + * Return the graph path of a segment + */ + getSegmentPath: function (segment) { + var series = this, + segmentPath = [], + step = series.options.step; + + // build the segment line + each(segment, function (point, i) { + + var plotX = point.plotX, + plotY = point.plotY, + lastPoint; + + if (series.getPointSpline) { // generate the spline as defined in the SplineSeries object + segmentPath.push.apply(segmentPath, series.getPointSpline(segment, point, i)); + + } else { + + // moveTo or lineTo + segmentPath.push(i ? L : M); + + // step line? + if (step && i) { + lastPoint = segment[i - 1]; + if (step === 'right') { + segmentPath.push( + lastPoint.plotX, + plotY + ); + + } else if (step === 'center') { + segmentPath.push( + (lastPoint.plotX + plotX) / 2, + lastPoint.plotY, + (lastPoint.plotX + plotX) / 2, + plotY + ); + + } else { + segmentPath.push( + plotX, + lastPoint.plotY + ); + } + } + + // normal line to next point + segmentPath.push( + point.plotX, + point.plotY + ); + } + }); + + return segmentPath; + }, + + /** + * Get the graph path + */ + getGraphPath: function () { + var series = this, + graphPath = [], + segmentPath, + singlePoints = []; // used in drawTracker + + // Divide into segments and build graph and area paths + each(series.segments, function (segment) { + + segmentPath = series.getSegmentPath(segment); + + // add the segment to the graph, or a single point for tracking + if (segment.length > 1) { + graphPath = graphPath.concat(segmentPath); + } else { + singlePoints.push(segment[0]); + } + }); + + // Record it for use in drawGraph and drawTracker, and return graphPath + series.singlePoints = singlePoints; + series.graphPath = graphPath; + + return graphPath; + + }, + + /** + * Draw the actual graph + */ + drawGraph: function () { + var series = this, + options = this.options, + props = [['graph', options.lineColor || this.color]], + lineWidth = options.lineWidth, + dashStyle = options.dashStyle, + roundCap = options.linecap !== 'square', + graphPath = this.getGraphPath(), + negativeColor = options.negativeColor; + + if (negativeColor) { + props.push(['graphNeg', negativeColor]); + } + + // draw the graph + each(props, function (prop, i) { + var graphKey = prop[0], + graph = series[graphKey], + attribs; + + if (graph) { + stop(graph); // cancel running animations, #459 + graph.animate({ d: graphPath }); + + } else if (lineWidth && graphPath.length) { // #1487 + attribs = { + stroke: prop[1], + 'stroke-width': lineWidth, + fill: NONE, + zIndex: 1 // #1069 + }; + if (dashStyle) { + attribs.dashstyle = dashStyle; + } else if (roundCap) { + attribs['stroke-linecap'] = attribs['stroke-linejoin'] = 'round'; + } + + series[graphKey] = series.chart.renderer.path(graphPath) + .attr(attribs) + .add(series.group) + .shadow(!i && options.shadow); + } + }); + }, + + /** + * Clip the graphs into the positive and negative coloured graphs + */ + clipNeg: function () { + var options = this.options, + chart = this.chart, + renderer = chart.renderer, + negativeColor = options.negativeColor || options.negativeFillColor, + translatedThreshold, + posAttr, + negAttr, + graph = this.graph, + area = this.area, + posClip = this.posClip, + negClip = this.negClip, + chartWidth = chart.chartWidth, + chartHeight = chart.chartHeight, + chartSizeMax = mathMax(chartWidth, chartHeight), + yAxis = this.yAxis, + above, + below; + + if (negativeColor && (graph || area)) { + translatedThreshold = mathRound(yAxis.toPixels(options.threshold || 0, true)); + if (translatedThreshold < 0) { + chartSizeMax -= translatedThreshold; // #2534 + } + above = { + x: 0, + y: 0, + width: chartSizeMax, + height: translatedThreshold + }; + below = { + x: 0, + y: translatedThreshold, + width: chartSizeMax, + height: chartSizeMax + }; + + if (chart.inverted) { + + above.height = below.y = chart.plotWidth - translatedThreshold; + if (renderer.isVML) { + above = { + x: chart.plotWidth - translatedThreshold - chart.plotLeft, + y: 0, + width: chartWidth, + height: chartHeight + }; + below = { + x: translatedThreshold + chart.plotLeft - chartWidth, + y: 0, + width: chart.plotLeft + translatedThreshold, + height: chartWidth + }; + } + } + + if (yAxis.reversed) { + posAttr = below; + negAttr = above; + } else { + posAttr = above; + negAttr = below; + } + + if (posClip) { // update + posClip.animate(posAttr); + negClip.animate(negAttr); + } else { + + this.posClip = posClip = renderer.clipRect(posAttr); + this.negClip = negClip = renderer.clipRect(negAttr); + + if (graph && this.graphNeg) { + graph.clip(posClip); + this.graphNeg.clip(negClip); + } + + if (area) { + area.clip(posClip); + this.areaNeg.clip(negClip); + } + } + } + }, + + /** + * Initialize and perform group inversion on series.group and series.markerGroup + */ + invertGroups: function () { + var series = this, + chart = series.chart; + + // Pie, go away (#1736) + if (!series.xAxis) { + return; + } + + // A fixed size is needed for inversion to work + function setInvert() { + var size = { + width: series.yAxis.len, + height: series.xAxis.len + }; + + each(['group', 'markerGroup'], function (groupName) { + if (series[groupName]) { + series[groupName].attr(size).invert(); + } + }); + } + + addEvent(chart, 'resize', setInvert); // do it on resize + addEvent(series, 'destroy', function () { + removeEvent(chart, 'resize', setInvert); + }); + + // Do it now + setInvert(); // do it now + + // On subsequent render and redraw, just do setInvert without setting up events again + series.invertGroups = setInvert; + }, + + /** + * General abstraction for creating plot groups like series.group, series.dataLabelsGroup and + * series.markerGroup. On subsequent calls, the group will only be adjusted to the updated plot size. + */ + plotGroup: function (prop, name, visibility, zIndex, parent) { + var group = this[prop], + isNew = !group; + + // Generate it on first call + if (isNew) { + this[prop] = group = this.chart.renderer.g(name) + .attr({ + visibility: visibility, + zIndex: zIndex || 0.1 // IE8 needs this + }) + .add(parent); + } + // Place it on first and subsequent (redraw) calls + group[isNew ? 'attr' : 'animate'](this.getPlotBox()); + return group; + }, + + /** + * Get the translation and scale for the plot area of this series + */ + getPlotBox: function () { + var chart = this.chart, + xAxis = this.xAxis, + yAxis = this.yAxis; + + // Swap axes for inverted (#2339) + if (chart.inverted) { + xAxis = yAxis; + yAxis = this.xAxis; + } + return { + translateX: xAxis ? xAxis.left : chart.plotLeft, + translateY: yAxis ? yAxis.top : chart.plotTop, + scaleX: 1, // #1623 + scaleY: 1 + }; + }, + + /** + * Render the graph and markers + */ + render: function () { + var series = this, + chart = series.chart, + group, + options = series.options, + animation = options.animation, + // Animation doesn't work in IE8 quirks when the group div is hidden, + // and looks bad in other oldIE + animDuration = (animation && !!series.animate && chart.renderer.isSVG && pick(animation.duration, 500)) || 0, + visibility = series.visible ? VISIBLE : HIDDEN, + zIndex = options.zIndex, + hasRendered = series.hasRendered, + chartSeriesGroup = chart.seriesGroup; + + // the group + group = series.plotGroup( + 'group', + 'series', + visibility, + zIndex, + chartSeriesGroup + ); + + series.markerGroup = series.plotGroup( + 'markerGroup', + 'markers', + visibility, + zIndex, + chartSeriesGroup + ); + + // initiate the animation + if (animDuration) { + series.animate(true); + } + + // cache attributes for shapes + series.getAttribs(); + + // SVGRenderer needs to know this before drawing elements (#1089, #1795) + group.inverted = series.isCartesian ? chart.inverted : false; + + // draw the graph if any + if (series.drawGraph) { + series.drawGraph(); + series.clipNeg(); + } + + each(series.points, function (point) { + if (point.redraw) { + point.redraw(); + } + }); + + // draw the data labels (inn pies they go before the points) + if (series.drawDataLabels) { + series.drawDataLabels(); + } + + // draw the points + if (series.visible) { + series.drawPoints(); + } + + + // draw the mouse tracking area + if (series.drawTracker && series.options.enableMouseTracking !== false) { + series.drawTracker(); + } + + // Handle inverted series and tracker groups + if (chart.inverted) { + series.invertGroups(); + } + + // Initial clipping, must be defined after inverting groups for VML + if (options.clip !== false && !series.sharedClipKey && !hasRendered) { + group.clip(chart.clipRect); + } + + // Run the animation + if (animDuration) { + series.animate(); + } + + // Call the afterAnimate function on animation complete (but don't overwrite the animation.complete option + // which should be available to the user). + if (!hasRendered) { + if (animDuration) { + series.animationTimeout = setTimeout(function () { + series.afterAnimate(); + }, animDuration); + } else { + series.afterAnimate(); + } + } + + series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see + // (See #322) series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see + series.hasRendered = true; + }, + + /** + * Redraw the series after an update in the axes. + */ + redraw: function () { + var series = this, + chart = series.chart, + wasDirtyData = series.isDirtyData, // cache it here as it is set to false in render, but used after + group = series.group, + xAxis = series.xAxis, + yAxis = series.yAxis; + + // reposition on resize + if (group) { + if (chart.inverted) { + group.attr({ + width: chart.plotWidth, + height: chart.plotHeight + }); + } + + group.animate({ + translateX: pick(xAxis && xAxis.left, chart.plotLeft), + translateY: pick(yAxis && yAxis.top, chart.plotTop) + }); + } + + series.translate(); + if (series.setTooltipPoints) { + series.setTooltipPoints(true); + } + series.render(); + + if (wasDirtyData) { + fireEvent(series, 'updatedData'); + } + } +}; // end Series prototype + +/** + * The class for stack items + */ +function StackItem(axis, options, isNegative, x, stackOption) { + + var inverted = axis.chart.inverted; + + this.axis = axis; + + // Tells if the stack is negative + this.isNegative = isNegative; + + // Save the options to be able to style the label + this.options = options; + + // Save the x value to be able to position the label later + this.x = x; + + // Initialize total value + this.total = null; + + // This will keep each points' extremes stored by series.index and point index + this.points = {}; + + // Save the stack option on the series configuration object, and whether to treat it as percent + this.stack = stackOption; + + // The align options and text align varies on whether the stack is negative and + // if the chart is inverted or not. + // First test the user supplied value, then use the dynamic. + this.alignOptions = { + align: options.align || (inverted ? (isNegative ? 'left' : 'right') : 'center'), + verticalAlign: options.verticalAlign || (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')), + y: pick(options.y, inverted ? 4 : (isNegative ? 14 : -6)), + x: pick(options.x, inverted ? (isNegative ? -6 : 6) : 0) + }; + + this.textAlign = options.textAlign || (inverted ? (isNegative ? 'right' : 'left') : 'center'); +} + +StackItem.prototype = { + destroy: function () { + destroyObjectProperties(this, this.axis); + }, + + /** + * Renders the stack total label and adds it to the stack label group. + */ + render: function (group) { + var options = this.options, + formatOption = options.format, + str = formatOption ? + format(formatOption, this) : + options.formatter.call(this); // format the text in the label + + // Change the text to reflect the new total and set visibility to hidden in case the serie is hidden + if (this.label) { + this.label.attr({text: str, visibility: HIDDEN}); + // Create new label + } else { + this.label = + this.axis.chart.renderer.text(str, null, null, options.useHTML) // dummy positions, actual position updated with setOffset method in columnseries + .css(options.style) // apply style + .attr({ + align: this.textAlign, // fix the text-anchor + rotation: options.rotation, // rotation + visibility: HIDDEN // hidden until setOffset is called + }) + .add(group); // add to the labels-group + } + }, + + /** + * Sets the offset that the stack has from the x value and repositions the label. + */ + setOffset: function (xOffset, xWidth) { + var stackItem = this, + axis = stackItem.axis, + chart = axis.chart, + inverted = chart.inverted, + neg = this.isNegative, // special treatment is needed for negative stacks + y = axis.translate(axis.usePercentage ? 100 : this.total, 0, 0, 0, 1), // stack value translated mapped to chart coordinates + yZero = axis.translate(0), // stack origin + h = mathAbs(y - yZero), // stack height + x = chart.xAxis[0].translate(this.x) + xOffset, // stack x position + plotHeight = chart.plotHeight, + stackBox = { // this is the box for the complete stack + x: inverted ? (neg ? y : y - h) : x, + y: inverted ? plotHeight - x - xWidth : (neg ? (plotHeight - y - h) : plotHeight - y), + width: inverted ? h : xWidth, + height: inverted ? xWidth : h + }, + label = this.label, + alignAttr; + + if (label) { + label.align(this.alignOptions, null, stackBox); // align the label to the box + + // Set visibility (#678) + alignAttr = label.alignAttr; + label[this.options.crop === false || chart.isInsidePlot(alignAttr.x, alignAttr.y) ? 'show' : 'hide'](true); + } + } +}; + + +// Stacking methods defined on the Axis prototype + +/** + * Build the stacks from top down + */ +Axis.prototype.buildStacks = function () { + var series = this.series, + reversedStacks = pick(this.options.reversedStacks, true), + i = series.length; + if (!this.isXAxis) { + this.usePercentage = false; + while (i--) { + series[reversedStacks ? i : series.length - i - 1].setStackedPoints(); + } + // Loop up again to compute percent stack + if (this.usePercentage) { + for (i = 0; i < series.length; i++) { + series[i].setPercentStacks(); + } + } + } +}; + +Axis.prototype.renderStackTotals = function () { + var axis = this, + chart = axis.chart, + renderer = chart.renderer, + stacks = axis.stacks, + stackKey, + oneStack, + stackCategory, + stackTotalGroup = axis.stackTotalGroup; + + // Create a separate group for the stack total labels + if (!stackTotalGroup) { + axis.stackTotalGroup = stackTotalGroup = + renderer.g('stack-labels') + .attr({ + visibility: VISIBLE, + zIndex: 6 + }) + .add(); + } + + // plotLeft/Top will change when y axis gets wider so we need to translate the + // stackTotalGroup at every render call. See bug #506 and #516 + stackTotalGroup.translate(chart.plotLeft, chart.plotTop); + + // Render each stack total + for (stackKey in stacks) { + oneStack = stacks[stackKey]; + for (stackCategory in oneStack) { + oneStack[stackCategory].render(stackTotalGroup); + } + } +}; + + +// Stacking methods defnied for Series prototype + +/** + * Adds series' points value to corresponding stack + */ +Series.prototype.setStackedPoints = function () { + if (!this.options.stacking || (this.visible !== true && this.chart.options.chart.ignoreHiddenSeries !== false)) { + return; + } + + var series = this, + xData = series.processedXData, + yData = series.processedYData, + stackedYData = [], + yDataLength = yData.length, + seriesOptions = series.options, + threshold = seriesOptions.threshold, + stackOption = seriesOptions.stack, + stacking = seriesOptions.stacking, + stackKey = series.stackKey, + negKey = '-' + stackKey, + negStacks = series.negStacks, + yAxis = series.yAxis, + stacks = yAxis.stacks, + oldStacks = yAxis.oldStacks, + isNegative, + stack, + other, + key, + pointKey, + i, + x, + y; + + // loop over the non-null y values and read them into a local array + for (i = 0; i < yDataLength; i++) { + x = xData[i]; + y = yData[i]; + pointKey = series.index + ',' + i; + + // Read stacked values into a stack based on the x value, + // the sign of y and the stack key. Stacking is also handled for null values (#739) + isNegative = negStacks && y < threshold; + key = isNegative ? negKey : stackKey; + + // Create empty object for this stack if it doesn't exist yet + if (!stacks[key]) { + stacks[key] = {}; + } + + // Initialize StackItem for this x + if (!stacks[key][x]) { + if (oldStacks[key] && oldStacks[key][x]) { + stacks[key][x] = oldStacks[key][x]; + stacks[key][x].total = null; + } else { + stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption); + } + } + + // If the StackItem doesn't exist, create it first + stack = stacks[key][x]; + stack.points[pointKey] = [stack.cum || 0]; + + // Add value to the stack total + if (stacking === 'percent') { + + // Percent stacked column, totals are the same for the positive and negative stacks + other = isNegative ? stackKey : negKey; + if (negStacks && stacks[other] && stacks[other][x]) { + other = stacks[other][x]; + stack.total = other.total = mathMax(other.total, stack.total) + mathAbs(y) || 0; + + // Percent stacked areas + } else { + stack.total = correctFloat(stack.total + (mathAbs(y) || 0)); + } + } else { + stack.total = correctFloat(stack.total + (y || 0)); + } + + stack.cum = (stack.cum || 0) + (y || 0); + + stack.points[pointKey].push(stack.cum); + stackedYData[i] = stack.cum; + + } + + if (stacking === 'percent') { + yAxis.usePercentage = true; + } + + this.stackedYData = stackedYData; // To be used in getExtremes + + // Reset old stacks + yAxis.oldStacks = {}; +}; + +/** + * Iterate over all stacks and compute the absolute values to percent + */ +Series.prototype.setPercentStacks = function () { + var series = this, + stackKey = series.stackKey, + stacks = series.yAxis.stacks, + processedXData = series.processedXData; + + each([stackKey, '-' + stackKey], function (key) { + var i = processedXData.length, + x, + stack, + pointExtremes, + totalFactor; + + while (i--) { + x = processedXData[i]; + stack = stacks[key] && stacks[key][x]; + pointExtremes = stack && stack.points[series.index + ',' + i]; + if (pointExtremes) { + totalFactor = stack.total ? 100 / stack.total : 0; + pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor); // Y bottom value + pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor); // Y value + series.stackedYData[i] = pointExtremes[1]; + } + } + }); +}; + +// Extend the Chart prototype for dynamic methods +extend(Chart.prototype, { + + /** + * Add a series dynamically after time + * + * @param {Object} options The config options + * @param {Boolean} redraw Whether to redraw the chart after adding. Defaults to true. + * @param {Boolean|Object} animation Whether to apply animation, and optionally animation + * configuration + * + * @return {Object} series The newly created series object + */ + addSeries: function (options, redraw, animation) { + var series, + chart = this; + + if (options) { + redraw = pick(redraw, true); // defaults to true + + fireEvent(chart, 'addSeries', { options: options }, function () { + series = chart.initSeries(options); + + chart.isDirtyLegend = true; // the series array is out of sync with the display + chart.linkSeries(); + if (redraw) { + chart.redraw(animation); + } + }); + } + + return series; + }, + + /** + * Add an axis to the chart + * @param {Object} options The axis option + * @param {Boolean} isX Whether it is an X axis or a value axis + */ + addAxis: function (options, isX, redraw, animation) { + var key = isX ? 'xAxis' : 'yAxis', + chartOptions = this.options, + axis; + + /*jslint unused: false*/ + axis = new Axis(this, merge(options, { + index: this[key].length, + isX: isX + })); + /*jslint unused: true*/ + + // Push the new axis options to the chart options + chartOptions[key] = splat(chartOptions[key] || {}); + chartOptions[key].push(options); + + if (pick(redraw, true)) { + this.redraw(animation); + } + }, + + /** + * Dim the chart and show a loading text or symbol + * @param {String} str An optional text to show in the loading label instead of the default one + */ + showLoading: function (str) { + var chart = this, + options = chart.options, + loadingDiv = chart.loadingDiv, + loadingOptions = options.loading, + setLoadingSize = function () { + if (loadingDiv) { + css(loadingDiv, { + left: chart.plotLeft + PX, + top: chart.plotTop + PX, + width: chart.plotWidth + PX, + height: chart.plotHeight + PX + }); + } + }; + + // create the layer at the first call + if (!loadingDiv) { + chart.loadingDiv = loadingDiv = createElement(DIV, { + className: PREFIX + 'loading' + }, extend(loadingOptions.style, { + zIndex: 10, + display: NONE + }), chart.container); + + chart.loadingSpan = createElement( + 'span', + null, + loadingOptions.labelStyle, + loadingDiv + ); + addEvent(chart, 'redraw', setLoadingSize); // #1080 + } + + // update text + chart.loadingSpan.innerHTML = str || options.lang.loading; + + // show it + if (!chart.loadingShown) { + css(loadingDiv, { + opacity: 0, + display: '' + }); + animate(loadingDiv, { + opacity: loadingOptions.style.opacity + }, { + duration: loadingOptions.showDuration || 0 + }); + chart.loadingShown = true; + } + setLoadingSize(); + }, + + /** + * Hide the loading layer + */ + hideLoading: function () { + var options = this.options, + loadingDiv = this.loadingDiv; + + if (loadingDiv) { + animate(loadingDiv, { + opacity: 0 + }, { + duration: options.loading.hideDuration || 100, + complete: function () { + css(loadingDiv, { display: NONE }); + } + }); + } + this.loadingShown = false; + } +}); + +// extend the Point prototype for dynamic methods +extend(Point.prototype, { + /** + * Update the point with new options (typically x/y data) and optionally redraw the series. + * + * @param {Object} options Point options as defined in the series.data array + * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call + * @param {Boolean|Object} animation Whether to apply animation, and optionally animation + * configuration + * + */ + update: function (options, redraw, animation, runEvent) { + var point = this, + series = point.series, + graphic = point.graphic, + i, + chart = series.chart, + seriesOptions = series.options; + + redraw = pick(redraw, true); + + function update() { + + point.applyOptions(options); + + // Update visuals + if (isObject(options) && !isArray(options)) { + // Defer the actual redraw until getAttribs has been called (#3260) + point.redraw = function () { + if (graphic) { + if (options && options.marker && options.marker.symbol) { + point.graphic = graphic.destroy(); + } else { + graphic.attr(point.pointAttr[point.state || '']); + } + } + if (options && options.dataLabels && point.dataLabel) { // #2468 + point.dataLabel = point.dataLabel.destroy(); + } + point.redraw = null; + }; + } + + // record changes in the parallel arrays + i = point.index; + series.updateParallelArrays(point, i); + + seriesOptions.data[i] = point.options; + + // redraw + series.isDirty = series.isDirtyData = true; + if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320 + chart.isDirtyBox = true; + } + + if (seriesOptions.legendType === 'point') { // #1831, #1885 + chart.legend.destroyItem(point); + } + if (redraw) { + chart.redraw(animation); + } + } + + // Fire the event with a default handler of doing the update + if (runEvent === false) { // When called from setData + update(); + } else { + point.firePointEvent('update', { options: options }, update); + } + }, + + /** + * Remove a point and optionally redraw the series and if necessary the axes + * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call + * @param {Boolean|Object} animation Whether to apply animation, and optionally animation + * configuration + */ + remove: function (redraw, animation) { + var point = this, + series = point.series, + points = series.points, + chart = series.chart, + i, + data = series.data; + + setAnimation(animation, chart); + redraw = pick(redraw, true); + + // fire the event with a default handler of removing the point + point.firePointEvent('remove', null, function () { + + // splice all the parallel arrays + i = inArray(point, data); + if (data.length === points.length) { + points.splice(i, 1); + } + data.splice(i, 1); + series.options.data.splice(i, 1); + series.updateParallelArrays(point, 'splice', i, 1); + + point.destroy(); + + // redraw + series.isDirty = true; + series.isDirtyData = true; + if (redraw) { + chart.redraw(); + } + }); + } +}); + +// Extend the series prototype for dynamic methods +extend(Series.prototype, { + /** + * Add a point dynamically after chart load time + * @param {Object} options Point options as given in series.data + * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call + * @param {Boolean} shift If shift is true, a point is shifted off the start + * of the series as one is appended to the end. + * @param {Boolean|Object} animation Whether to apply animation, and optionally animation + * configuration + */ + addPoint: function (options, redraw, shift, animation) { + var series = this, + seriesOptions = series.options, + data = series.data, + graph = series.graph, + area = series.area, + chart = series.chart, + names = series.xAxis && series.xAxis.names, + currentShift = (graph && graph.shift) || 0, + dataOptions = seriesOptions.data, + point, + isInTheMiddle, + xData = series.xData, + x, + i; + + setAnimation(animation, chart); + + // Make graph animate sideways + if (shift) { + each([graph, area, series.graphNeg, series.areaNeg], function (shape) { + if (shape) { + shape.shift = currentShift + 1; + } + }); + } + if (area) { + area.isArea = true; // needed in animation, both with and without shift + } + + // Optional redraw, defaults to true + redraw = pick(redraw, true); + + // Get options and push the point to xData, yData and series.options. In series.generatePoints + // the Point instance will be created on demand and pushed to the series.data array. + point = { series: series }; + series.pointClass.prototype.applyOptions.apply(point, [options]); + x = point.x; + + // Get the insertion point + i = xData.length; + if (series.requireSorting && x < xData[i - 1]) { + isInTheMiddle = true; + while (i && xData[i - 1] > x) { + i--; + } + } + + series.updateParallelArrays(point, 'splice', i, 0, 0); // insert undefined item + series.updateParallelArrays(point, i); // update it + + if (names && point.name) { + names[x] = point.name; + } + dataOptions.splice(i, 0, options); + + if (isInTheMiddle) { + series.data.splice(i, 0, null); + series.processData(); + } + + // Generate points to be added to the legend (#1329) + if (seriesOptions.legendType === 'point') { + series.generatePoints(); + } + + // Shift the first point off the parallel arrays + // todo: consider series.removePoint(i) method + if (shift) { + if (data[0] && data[0].remove) { + data[0].remove(false); + } else { + data.shift(); + series.updateParallelArrays(point, 'shift'); + + dataOptions.shift(); + } + } + + // redraw + series.isDirty = true; + series.isDirtyData = true; + if (redraw) { + series.getAttribs(); // #1937 + chart.redraw(); + } + }, + + /** + * Remove a series and optionally redraw the chart + * + * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call + * @param {Boolean|Object} animation Whether to apply animation, and optionally animation + * configuration + */ + + remove: function (redraw, animation) { + var series = this, + chart = series.chart; + redraw = pick(redraw, true); + + if (!series.isRemoving) { /* prevent triggering native event in jQuery + (calling the remove function from the remove event) */ + series.isRemoving = true; + + // fire the event with a default handler of removing the point + fireEvent(series, 'remove', null, function () { + + + // destroy elements + series.destroy(); + + + // redraw + chart.isDirtyLegend = chart.isDirtyBox = true; + chart.linkSeries(); + + if (redraw) { + chart.redraw(animation); + } + }); + + } + series.isRemoving = false; + }, + + /** + * Update the series with a new set of options + */ + update: function (newOptions, redraw) { + var series = this, + chart = this.chart, + // must use user options when changing type because this.options is merged + // in with type specific plotOptions + oldOptions = this.userOptions, + oldType = this.type, + proto = seriesTypes[oldType].prototype, + preserve = ['group', 'markerGroup', 'dataLabelsGroup'], + n; + + // Make sure groups are not destroyed (#3094) + each(preserve, function (prop) { + preserve[prop] = series[prop]; + delete series[prop]; + }); + + // Do the merge, with some forced options + newOptions = merge(oldOptions, { + animation: false, + index: this.index, + pointStart: this.xData[0] // when updating after addPoint + }, { data: this.options.data }, newOptions); + + // Destroy the series and reinsert methods from the type prototype + this.remove(false); + for (n in proto) { // Overwrite series-type specific methods (#2270) + if (proto.hasOwnProperty(n)) { + this[n] = UNDEFINED; + } + } + extend(this, seriesTypes[newOptions.type || oldType].prototype); + + // Re-register groups (#3094) + each(preserve, function (prop) { + series[prop] = preserve[prop]; + }); + + + this.init(chart, newOptions); + chart.linkSeries(); // Links are lost in this.remove (#3028) + if (pick(redraw, true)) { + chart.redraw(false); + } + } +}); + +// Extend the Axis.prototype for dynamic methods +extend(Axis.prototype, { + + /** + * Update the axis with a new options structure + */ + update: function (newOptions, redraw) { + var chart = this.chart; + + newOptions = chart.options[this.coll][this.options.index] = merge(this.userOptions, newOptions); + + this.destroy(true); + this._addedPlotLB = UNDEFINED; // #1611, #2887 + + this.init(chart, extend(newOptions, { events: UNDEFINED })); + + chart.isDirtyBox = true; + if (pick(redraw, true)) { + chart.redraw(); + } + }, + + /** + * Remove the axis from the chart + */ + remove: function (redraw) { + var chart = this.chart, + key = this.coll, // xAxis or yAxis + axisSeries = this.series, + i = axisSeries.length; + + // Remove associated series (#2687) + while (i--) { + if (axisSeries[i]) { + axisSeries[i].remove(false); + } + } + + // Remove the axis + erase(chart.axes, this); + erase(chart[key], this); + chart.options[key].splice(this.options.index, 1); + each(chart[key], function (axis, i) { // Re-index, #1706 + axis.options.index = i; + }); + this.destroy(); + chart.isDirtyBox = true; + + if (pick(redraw, true)) { + chart.redraw(); + } + }, + + /** + * Update the axis title by options + */ + setTitle: function (newTitleOptions, redraw) { + this.update({ title: newTitleOptions }, redraw); + }, + + /** + * Set new axis categories and optionally redraw + * @param {Array} categories + * @param {Boolean} redraw + */ + setCategories: function (categories, redraw) { + this.update({ categories: categories }, redraw); + } + +}); + + +/** + * LineSeries object + */ +var LineSeries = extendClass(Series); +seriesTypes.line = LineSeries; + +/** + * Set the default options for area + */ +defaultPlotOptions.area = merge(defaultSeriesOptions, { + threshold: 0 + // trackByArea: false, + // lineColor: null, // overrides color, but lets fillColor be unaltered + // fillOpacity: 0.75, + // fillColor: null +}); + +/** + * AreaSeries object + */ +var AreaSeries = extendClass(Series, { + type: 'area', + /** + * For stacks, don't split segments on null values. Instead, draw null values with + * no marker. Also insert dummy points for any X position that exists in other series + * in the stack. + */ + getSegments: function () { + var series = this, + segments = [], + segment = [], + keys = [], + xAxis = this.xAxis, + yAxis = this.yAxis, + stack = yAxis.stacks[this.stackKey], + pointMap = {}, + plotX, + plotY, + points = this.points, + connectNulls = this.options.connectNulls, + i, + x; + + if (this.options.stacking && !this.cropped) { // cropped causes artefacts in Stock, and perf issue + // Create a map where we can quickly look up the points by their X value. + for (i = 0; i < points.length; i++) { + pointMap[points[i].x] = points[i]; + } + + // Sort the keys (#1651) + for (x in stack) { + if (stack[x].total !== null) { // nulled after switching between grouping and not (#1651, #2336) + keys.push(+x); + } + } + keys.sort(function (a, b) { + return a - b; + }); + + each(keys, function (x) { + var y = 0, + stackPoint; + + if (connectNulls && (!pointMap[x] || pointMap[x].y === null)) { // #1836 + return; + + // The point exists, push it to the segment + } else if (pointMap[x]) { + segment.push(pointMap[x]); + + // There is no point for this X value in this series, so we + // insert a dummy point in order for the areas to be drawn + // correctly. + } else { + + // Loop down the stack to find the series below this one that has + // a value (#1991) + for (i = series.index; i <= yAxis.series.length; i++) { + stackPoint = stack[x].points[i + ',' + x]; + if (stackPoint) { + y = stackPoint[1]; + break; + } + } + + plotX = xAxis.translate(x); + plotY = yAxis.toPixels(y, true); + segment.push({ + y: null, + plotX: plotX, + clientX: plotX, + plotY: plotY, + yBottom: plotY, + onMouseOver: noop + }); + } + }); + + if (segment.length) { + segments.push(segment); + } + + } else { + Series.prototype.getSegments.call(this); + segments = this.segments; + } + + this.segments = segments; + }, + + /** + * Extend the base Series getSegmentPath method by adding the path for the area. + * This path is pushed to the series.areaPath property. + */ + getSegmentPath: function (segment) { + + var segmentPath = Series.prototype.getSegmentPath.call(this, segment), // call base method + areaSegmentPath = [].concat(segmentPath), // work on a copy for the area path + i, + options = this.options, + segLength = segmentPath.length, + translatedThreshold = this.yAxis.getThreshold(options.threshold), // #2181 + yBottom; + + if (segLength === 3) { // for animation from 1 to two points + areaSegmentPath.push(L, segmentPath[1], segmentPath[2]); + } + if (options.stacking && !this.closedStacks) { + + // Follow stack back. Todo: implement areaspline. A general solution could be to + // reverse the entire graphPath of the previous series, though may be hard with + // splines and with series with different extremes + for (i = segment.length - 1; i >= 0; i--) { + + yBottom = pick(segment[i].yBottom, translatedThreshold); + + // step line? + if (i < segment.length - 1 && options.step) { + areaSegmentPath.push(segment[i + 1].plotX, yBottom); + } + + areaSegmentPath.push(segment[i].plotX, yBottom); + } + + } else { // follow zero line back + this.closeSegment(areaSegmentPath, segment, translatedThreshold); + } + this.areaPath = this.areaPath.concat(areaSegmentPath); + return segmentPath; + }, + + /** + * Extendable method to close the segment path of an area. This is overridden in polar + * charts. + */ + closeSegment: function (path, segment, translatedThreshold) { + path.push( + L, + segment[segment.length - 1].plotX, + translatedThreshold, + L, + segment[0].plotX, + translatedThreshold + ); + }, + + /** + * Draw the graph and the underlying area. This method calls the Series base + * function and adds the area. The areaPath is calculated in the getSegmentPath + * method called from Series.prototype.drawGraph. + */ + drawGraph: function () { + + // Define or reset areaPath + this.areaPath = []; + + // Call the base method + Series.prototype.drawGraph.apply(this); + + // Define local variables + var series = this, + areaPath = this.areaPath, + options = this.options, + negativeColor = options.negativeColor, + negativeFillColor = options.negativeFillColor, + props = [['area', this.color, options.fillColor]]; // area name, main color, fill color + + if (negativeColor || negativeFillColor) { + props.push(['areaNeg', negativeColor, negativeFillColor]); + } + + each(props, function (prop) { + var areaKey = prop[0], + area = series[areaKey]; + + // Create or update the area + if (area) { // update + area.animate({ d: areaPath }); + + } else { // create + series[areaKey] = series.chart.renderer.path(areaPath) + .attr({ + fill: pick( + prop[2], + Color(prop[1]).setOpacity(pick(options.fillOpacity, 0.75)).get() + ), + zIndex: 0 // #1069 + }).add(series.group); + } + }); + }, + + drawLegendSymbol: LegendSymbolMixin.drawRectangle +}); + +seriesTypes.area = AreaSeries; +/** + * Set the default options for spline + */ +defaultPlotOptions.spline = merge(defaultSeriesOptions); + +/** + * SplineSeries object + */ +var SplineSeries = extendClass(Series, { + type: 'spline', + + /** + * Get the spline segment from a given point's previous neighbour to the given point + */ + getPointSpline: function (segment, point, i) { + var smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc + denom = smoothing + 1, + plotX = point.plotX, + plotY = point.plotY, + lastPoint = segment[i - 1], + nextPoint = segment[i + 1], + leftContX, + leftContY, + rightContX, + rightContY, + ret; + + // find control points + if (lastPoint && nextPoint) { + + var lastX = lastPoint.plotX, + lastY = lastPoint.plotY, + nextX = nextPoint.plotX, + nextY = nextPoint.plotY, + correction; + + leftContX = (smoothing * plotX + lastX) / denom; + leftContY = (smoothing * plotY + lastY) / denom; + rightContX = (smoothing * plotX + nextX) / denom; + rightContY = (smoothing * plotY + nextY) / denom; + + // have the two control points make a straight line through main point + correction = ((rightContY - leftContY) * (rightContX - plotX)) / + (rightContX - leftContX) + plotY - rightContY; + + leftContY += correction; + rightContY += correction; + + // to prevent false extremes, check that control points are between + // neighbouring points' y values + if (leftContY > lastY && leftContY > plotY) { + leftContY = mathMax(lastY, plotY); + rightContY = 2 * plotY - leftContY; // mirror of left control point + } else if (leftContY < lastY && leftContY < plotY) { + leftContY = mathMin(lastY, plotY); + rightContY = 2 * plotY - leftContY; + } + if (rightContY > nextY && rightContY > plotY) { + rightContY = mathMax(nextY, plotY); + leftContY = 2 * plotY - rightContY; + } else if (rightContY < nextY && rightContY < plotY) { + rightContY = mathMin(nextY, plotY); + leftContY = 2 * plotY - rightContY; + } + + // record for drawing in next point + point.rightContX = rightContX; + point.rightContY = rightContY; + + } + + // Visualize control points for debugging + /* + if (leftContX) { + this.chart.renderer.circle(leftContX + this.chart.plotLeft, leftContY + this.chart.plotTop, 2) + .attr({ + stroke: 'red', + 'stroke-width': 1, + fill: 'none' + }) + .add(); + this.chart.renderer.path(['M', leftContX + this.chart.plotLeft, leftContY + this.chart.plotTop, + 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop]) + .attr({ + stroke: 'red', + 'stroke-width': 1 + }) + .add(); + this.chart.renderer.circle(rightContX + this.chart.plotLeft, rightContY + this.chart.plotTop, 2) + .attr({ + stroke: 'green', + 'stroke-width': 1, + fill: 'none' + }) + .add(); + this.chart.renderer.path(['M', rightContX + this.chart.plotLeft, rightContY + this.chart.plotTop, + 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop]) + .attr({ + stroke: 'green', + 'stroke-width': 1 + }) + .add(); + } + */ + + // moveTo or lineTo + if (!i) { + ret = [M, plotX, plotY]; + } else { // curve from last point to this + ret = [ + 'C', + lastPoint.rightContX || lastPoint.plotX, + lastPoint.rightContY || lastPoint.plotY, + leftContX || plotX, + leftContY || plotY, + plotX, + plotY + ]; + lastPoint.rightContX = lastPoint.rightContY = null; // reset for updating series later + } + return ret; + } +}); +seriesTypes.spline = SplineSeries; + +/** + * Set the default options for areaspline + */ +defaultPlotOptions.areaspline = merge(defaultPlotOptions.area); + +/** + * AreaSplineSeries object + */ +var areaProto = AreaSeries.prototype, + AreaSplineSeries = extendClass(SplineSeries, { + type: 'areaspline', + closedStacks: true, // instead of following the previous graph back, follow the threshold back + + // Mix in methods from the area series + getSegmentPath: areaProto.getSegmentPath, + closeSegment: areaProto.closeSegment, + drawGraph: areaProto.drawGraph, + drawLegendSymbol: LegendSymbolMixin.drawRectangle + }); + +seriesTypes.areaspline = AreaSplineSeries; + +/** + * Set the default options for column + */ +defaultPlotOptions.column = merge(defaultSeriesOptions, { + borderColor: '#FFFFFF', + //borderWidth: 1, + borderRadius: 0, + //colorByPoint: undefined, + groupPadding: 0.2, + //grouping: true, + marker: null, // point options are specified in the base options + pointPadding: 0.1, + //pointWidth: null, + minPointLength: 0, + cropThreshold: 50, // when there are more points, they will not animate out of the chart on xAxis.setExtremes + pointRange: null, // null means auto, meaning 1 in a categorized axis and least distance between points if not categories + states: { + hover: { + brightness: 0.1, + shadow: false, + halo: false + }, + select: { + color: '#C0C0C0', + borderColor: '#000000', + shadow: false + } + }, + dataLabels: { + align: null, // auto + verticalAlign: null, // auto + y: null + }, + stickyTracking: false, + tooltip: { + distance: 6 + }, + threshold: 0 +}); + +/** + * ColumnSeries object + */ +var ColumnSeries = extendClass(Series, { + type: 'column', + pointAttrToOptions: { // mapping between SVG attributes and the corresponding options + stroke: 'borderColor', + fill: 'color', + r: 'borderRadius' + }, + cropShoulder: 0, + trackerGroups: ['group', 'dataLabelsGroup'], + negStacks: true, // use separate negative stacks, unlike area stacks where a negative + // point is substracted from previous (#1910) + + /** + * Initialize the series + */ + init: function () { + Series.prototype.init.apply(this, arguments); + + var series = this, + chart = series.chart; + + // if the series is added dynamically, force redraw of other + // series affected by a new column + if (chart.hasRendered) { + each(chart.series, function (otherSeries) { + if (otherSeries.type === series.type) { + otherSeries.isDirty = true; + } + }); + } + }, + + /** + * Return the width and x offset of the columns adjusted for grouping, groupPadding, pointPadding, + * pointWidth etc. + */ + getColumnMetrics: function () { + + var series = this, + options = series.options, + xAxis = series.xAxis, + yAxis = series.yAxis, + reversedXAxis = xAxis.reversed, + stackKey, + stackGroups = {}, + columnIndex, + columnCount = 0; + + // Get the total number of column type series. + // This is called on every series. Consider moving this logic to a + // chart.orderStacks() function and call it on init, addSeries and removeSeries + if (options.grouping === false) { + columnCount = 1; + } else { + each(series.chart.series, function (otherSeries) { + var otherOptions = otherSeries.options, + otherYAxis = otherSeries.yAxis; + if (otherSeries.type === series.type && otherSeries.visible && + yAxis.len === otherYAxis.len && yAxis.pos === otherYAxis.pos) { // #642, #2086 + if (otherOptions.stacking) { + stackKey = otherSeries.stackKey; + if (stackGroups[stackKey] === UNDEFINED) { + stackGroups[stackKey] = columnCount++; + } + columnIndex = stackGroups[stackKey]; + } else if (otherOptions.grouping !== false) { // #1162 + columnIndex = columnCount++; + } + otherSeries.columnIndex = columnIndex; + } + }); + } + + var categoryWidth = mathMin( + mathAbs(xAxis.transA) * (xAxis.ordinalSlope || options.pointRange || xAxis.closestPointRange || xAxis.tickInterval || 1), // #2610 + xAxis.len // #1535 + ), + groupPadding = categoryWidth * options.groupPadding, + groupWidth = categoryWidth - 2 * groupPadding, + pointOffsetWidth = groupWidth / columnCount, + optionPointWidth = options.pointWidth, + pointPadding = defined(optionPointWidth) ? (pointOffsetWidth - optionPointWidth) / 2 : + pointOffsetWidth * options.pointPadding, + pointWidth = pick(optionPointWidth, pointOffsetWidth - 2 * pointPadding), // exact point width, used in polar charts + colIndex = (reversedXAxis ? + columnCount - (series.columnIndex || 0) : // #1251 + series.columnIndex) || 0, + pointXOffset = pointPadding + (groupPadding + colIndex * + pointOffsetWidth - (categoryWidth / 2)) * + (reversedXAxis ? -1 : 1); + + // Save it for reading in linked series (Error bars particularly) + return (series.columnMetrics = { + width: pointWidth, + offset: pointXOffset + }); + + }, + + /** + * Translate each point to the plot area coordinate system and find shape positions + */ + translate: function () { + var series = this, + chart = series.chart, + options = series.options, + borderWidth = series.borderWidth = pick( + options.borderWidth, + series.activePointCount > 0.5 * series.xAxis.len ? 0 : 1 + ), + yAxis = series.yAxis, + threshold = options.threshold, + translatedThreshold = series.translatedThreshold = yAxis.getThreshold(threshold), + minPointLength = pick(options.minPointLength, 5), + metrics = series.getColumnMetrics(), + pointWidth = metrics.width, + seriesBarW = series.barW = mathMax(pointWidth, 1 + 2 * borderWidth), // postprocessed for border width + pointXOffset = series.pointXOffset = metrics.offset, + xCrisp = -(borderWidth % 2 ? 0.5 : 0), + yCrisp = borderWidth % 2 ? 0.5 : 1; + + if (chart.renderer.isVML && chart.inverted) { + yCrisp += 1; + } + + // When the pointPadding is 0, we want the columns to be packed tightly, so we allow individual + // columns to have individual sizes. When pointPadding is greater, we strive for equal-width + // columns (#2694). + if (options.pointPadding) { + seriesBarW = mathCeil(seriesBarW); + } + + Series.prototype.translate.apply(series); + + // Record the new values + each(series.points, function (point) { + var yBottom = pick(point.yBottom, translatedThreshold), + plotY = mathMin(mathMax(-999 - yBottom, point.plotY), yAxis.len + 999 + yBottom), // Don't draw too far outside plot area (#1303, #2241) + barX = point.plotX + pointXOffset, + barW = seriesBarW, + barY = mathMin(plotY, yBottom), + right, + bottom, + fromTop, + barH = mathMax(plotY, yBottom) - barY; + + // Handle options.minPointLength + if (mathAbs(barH) < minPointLength) { + if (minPointLength) { + barH = minPointLength; + barY = + mathRound(mathAbs(barY - translatedThreshold) > minPointLength ? // stacked + yBottom - minPointLength : // keep position + translatedThreshold - (yAxis.translate(point.y, 0, 1, 0, 1) <= translatedThreshold ? minPointLength : 0)); // use exact yAxis.translation (#1485) + } + } + + // Cache for access in polar + point.barX = barX; + point.pointWidth = pointWidth; + + // Fix the tooltip on center of grouped columns (#1216, #424) + point.tooltipPos = chart.inverted ? + [yAxis.len - plotY, series.xAxis.len - barX - barW / 2] : + [barX + barW / 2, plotY + yAxis.pos - chart.plotTop]; + + // Round off to obtain crisp edges and avoid overlapping with neighbours (#2694) + right = mathRound(barX + barW) + xCrisp; + barX = mathRound(barX) + xCrisp; + barW = right - barX; + + fromTop = mathAbs(barY) < 0.5; + bottom = mathRound(barY + barH) + yCrisp; + barY = mathRound(barY) + yCrisp; + barH = bottom - barY; + + // Top edges are exceptions + if (fromTop) { + barY -= 1; + barH += 1; + } + + // Register shape type and arguments to be used in drawPoints + point.shapeType = 'rect'; + point.shapeArgs = { + x: barX, + y: barY, + width: barW, + height: barH + }; + + }); + + }, + + getSymbol: noop, + + /** + * Use a solid rectangle like the area series types + */ + drawLegendSymbol: LegendSymbolMixin.drawRectangle, + + + /** + * Columns have no graph + */ + drawGraph: noop, + + /** + * Draw the columns. For bars, the series.group is rotated, so the same coordinates + * apply for columns and bars. This method is inherited by scatter series. + * + */ + drawPoints: function () { + var series = this, + chart = this.chart, + options = series.options, + renderer = chart.renderer, + animationLimit = options.animationLimit || 250, + shapeArgs, + pointAttr; + + // draw the columns + each(series.points, function (point) { + var plotY = point.plotY, + graphic = point.graphic, + borderAttr; + + if (plotY !== UNDEFINED && !isNaN(plotY) && point.y !== null) { + shapeArgs = point.shapeArgs; + + borderAttr = defined(series.borderWidth) ? { + 'stroke-width': series.borderWidth + } : {}; + + pointAttr = point.pointAttr[point.selected ? SELECT_STATE : NORMAL_STATE] || series.pointAttr[NORMAL_STATE]; + + if (graphic) { // update + stop(graphic); + graphic.attr(borderAttr)[chart.pointCount < animationLimit ? 'animate' : 'attr'](merge(shapeArgs)); + + } else { + point.graphic = graphic = renderer[point.shapeType](shapeArgs) + .attr(pointAttr) + .attr(borderAttr) + .add(series.group) + .shadow(options.shadow, null, options.stacking && !options.borderRadius); + } + + } else if (graphic) { + point.graphic = graphic.destroy(); // #1269 + } + }); + }, + + /** + * Animate the column heights one by one from zero + * @param {Boolean} init Whether to initialize the animation or run it + */ + animate: function (init) { + var series = this, + yAxis = this.yAxis, + options = series.options, + inverted = this.chart.inverted, + attr = {}, + translatedThreshold; + + if (hasSVG) { // VML is too slow anyway + if (init) { + attr.scaleY = 0.001; + translatedThreshold = mathMin(yAxis.pos + yAxis.len, mathMax(yAxis.pos, yAxis.toPixels(options.threshold))); + if (inverted) { + attr.translateX = translatedThreshold - yAxis.len; + } else { + attr.translateY = translatedThreshold; + } + series.group.attr(attr); + + } else { // run the animation + + attr.scaleY = 1; + attr[inverted ? 'translateX' : 'translateY'] = yAxis.pos; + series.group.animate(attr, series.options.animation); + + // delete this function to allow it only once + series.animate = null; + } + } + }, + + /** + * Remove this series from the chart + */ + remove: function () { + var series = this, + chart = series.chart; + + // column and bar series affects other series of the same type + // as they are either stacked or grouped + if (chart.hasRendered) { + each(chart.series, function (otherSeries) { + if (otherSeries.type === series.type) { + otherSeries.isDirty = true; + } + }); + } + + Series.prototype.remove.apply(series, arguments); + } +}); +seriesTypes.column = ColumnSeries; +/** + * Set the default options for bar + */ +defaultPlotOptions.bar = merge(defaultPlotOptions.column); +/** + * The Bar series class + */ +var BarSeries = extendClass(ColumnSeries, { + type: 'bar', + inverted: true +}); +seriesTypes.bar = BarSeries; + +/** + * Set the default options for scatter + */ +defaultPlotOptions.scatter = merge(defaultSeriesOptions, { + lineWidth: 0, + tooltip: { + headerFormat: '<span style="color:{series.color}">\u25CF</span> <span style="font-size: 10px;"> {series.name}</span><br/>', + pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>' + }, + stickyTracking: false +}); + +/** + * The scatter series class + */ +var ScatterSeries = extendClass(Series, { + type: 'scatter', + sorted: false, + requireSorting: false, + noSharedTooltip: true, + trackerGroups: ['markerGroup', 'dataLabelsGroup'], + takeOrdinalPosition: false, // #2342 + singularTooltips: true, + drawGraph: function () { + if (this.options.lineWidth) { + Series.prototype.drawGraph.call(this); + } + } +}); + +seriesTypes.scatter = ScatterSeries; + +/** + * Set the default options for pie + */ +defaultPlotOptions.pie = merge(defaultSeriesOptions, { + borderColor: '#FFFFFF', + borderWidth: 1, + center: [null, null], + clip: false, + colorByPoint: true, // always true for pies + dataLabels: { + // align: null, + // connectorWidth: 1, + // connectorColor: point.color, + // connectorPadding: 5, + distance: 30, + enabled: true, + formatter: function () { // #2945 + return this.point.name; + } + // softConnector: true, + //y: 0 + }, + ignoreHiddenPoint: true, + //innerSize: 0, + legendType: 'point', + marker: null, // point options are specified in the base options + size: null, + showInLegend: false, + slicedOffset: 10, + states: { + hover: { + brightness: 0.1, + shadow: false + } + }, + stickyTracking: false, + tooltip: { + followPointer: true + } +}); + +/** + * Extended point object for pies + */ +var PiePoint = extendClass(Point, { + /** + * Initiate the pie slice + */ + init: function () { + + Point.prototype.init.apply(this, arguments); + + var point = this, + toggleSlice; + + // Disallow negative values (#1530) + if (point.y < 0) { + point.y = null; + } + + //visible: options.visible !== false, + extend(point, { + visible: point.visible !== false, + name: pick(point.name, 'Slice') + }); + + // add event listener for select + toggleSlice = function (e) { + point.slice(e.type === 'select'); + }; + addEvent(point, 'select', toggleSlice); + addEvent(point, 'unselect', toggleSlice); + + return point; + }, + + /** + * Toggle the visibility of the pie slice + * @param {Boolean} vis Whether to show the slice or not. If undefined, the + * visibility is toggled + */ + setVisible: function (vis) { + var point = this, + series = point.series, + chart = series.chart; + + // if called without an argument, toggle visibility + point.visible = point.options.visible = vis = vis === UNDEFINED ? !point.visible : vis; + series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data + + // Show and hide associated elements + each(['graphic', 'dataLabel', 'connector', 'shadowGroup'], function (key) { + if (point[key]) { + point[key][vis ? 'show' : 'hide'](true); + } + }); + + if (point.legendItem) { + chart.legend.colorizeItem(point, vis); + } + + // Handle ignore hidden slices + if (!series.isDirty && series.options.ignoreHiddenPoint) { + series.isDirty = true; + chart.redraw(); + } + }, + + /** + * Set or toggle whether the slice is cut out from the pie + * @param {Boolean} sliced When undefined, the slice state is toggled + * @param {Boolean} redraw Whether to redraw the chart. True by default. + */ + slice: function (sliced, redraw, animation) { + var point = this, + series = point.series, + chart = series.chart, + translation; + + setAnimation(animation, chart); + + // redraw is true by default + redraw = pick(redraw, true); + + // if called without an argument, toggle + point.sliced = point.options.sliced = sliced = defined(sliced) ? sliced : !point.sliced; + series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data + + translation = sliced ? point.slicedTranslation : { + translateX: 0, + translateY: 0 + }; + + point.graphic.animate(translation); + + if (point.shadowGroup) { + point.shadowGroup.animate(translation); + } + + }, + + haloPath: function (size) { + var shapeArgs = this.shapeArgs, + chart = this.series.chart; + + return this.sliced || !this.visible ? [] : this.series.chart.renderer.symbols.arc(chart.plotLeft + shapeArgs.x, chart.plotTop + shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, { + innerR: this.shapeArgs.r, + start: shapeArgs.start, + end: shapeArgs.end + }); + } +}); + +/** + * The Pie series class + */ +var PieSeries = { + type: 'pie', + isCartesian: false, + pointClass: PiePoint, + requireSorting: false, + noSharedTooltip: true, + trackerGroups: ['group', 'dataLabelsGroup'], + axisTypes: [], + pointAttrToOptions: { // mapping between SVG attributes and the corresponding options + stroke: 'borderColor', + 'stroke-width': 'borderWidth', + fill: 'color' + }, + singularTooltips: true, + + /** + * Pies have one color each point + */ + getColor: noop, + + /** + * Animate the pies in + */ + animate: function (init) { + var series = this, + points = series.points, + startAngleRad = series.startAngleRad; + + if (!init) { + each(points, function (point) { + var graphic = point.graphic, + args = point.shapeArgs; + + if (graphic) { + // start values + graphic.attr({ + r: series.center[3] / 2, // animate from inner radius (#779) + start: startAngleRad, + end: startAngleRad + }); + + // animate + graphic.animate({ + r: args.r, + start: args.start, + end: args.end + }, series.options.animation); + } + }); + + // delete this function to allow it only once + series.animate = null; + } + }, + + /** + * Extend the basic setData method by running processData and generatePoints immediately, + * in order to access the points from the legend. + */ + setData: function (data, redraw, animation, updatePoints) { + Series.prototype.setData.call(this, data, false, animation, updatePoints); + this.processData(); + this.generatePoints(); + if (pick(redraw, true)) { + this.chart.redraw(animation); + } + }, + + /** + * Extend the generatePoints method by adding total and percentage properties to each point + */ + generatePoints: function () { + var i, + total = 0, + points, + len, + point, + ignoreHiddenPoint = this.options.ignoreHiddenPoint; + + Series.prototype.generatePoints.call(this); + + // Populate local vars + points = this.points; + len = points.length; + + // Get the total sum + for (i = 0; i < len; i++) { + point = points[i]; + total += (ignoreHiddenPoint && !point.visible) ? 0 : point.y; + } + this.total = total; + + // Set each point's properties + for (i = 0; i < len; i++) { + point = points[i]; + point.percentage = total > 0 ? (point.y / total) * 100 : 0; + point.total = total; + } + + }, + + /** + * Do translation for pie slices + */ + translate: function (positions) { + this.generatePoints(); + + var series = this, + cumulative = 0, + precision = 1000, // issue #172 + options = series.options, + slicedOffset = options.slicedOffset, + connectorOffset = slicedOffset + options.borderWidth, + start, + end, + angle, + startAngle = options.startAngle || 0, + startAngleRad = series.startAngleRad = mathPI / 180 * (startAngle - 90), + endAngleRad = series.endAngleRad = mathPI / 180 * ((pick(options.endAngle, startAngle + 360)) - 90), + circ = endAngleRad - startAngleRad, //2 * mathPI, + points = series.points, + radiusX, // the x component of the radius vector for a given point + radiusY, + labelDistance = options.dataLabels.distance, + ignoreHiddenPoint = options.ignoreHiddenPoint, + i, + len = points.length, + point; + + // Get positions - either an integer or a percentage string must be given. + // If positions are passed as a parameter, we're in a recursive loop for adjusting + // space for data labels. + if (!positions) { + series.center = positions = series.getCenter(); + } + + // utility for getting the x value from a given y, used for anticollision logic in data labels + series.getX = function (y, left) { + + angle = math.asin(mathMin((y - positions[1]) / (positions[2] / 2 + labelDistance), 1)); + + return positions[0] + + (left ? -1 : 1) * + (mathCos(angle) * (positions[2] / 2 + labelDistance)); + }; + + // Calculate the geometry for each point + for (i = 0; i < len; i++) { + + point = points[i]; + + // set start and end angle + start = startAngleRad + (cumulative * circ); + if (!ignoreHiddenPoint || point.visible) { + cumulative += point.percentage / 100; + } + end = startAngleRad + (cumulative * circ); + + // set the shape + point.shapeType = 'arc'; + point.shapeArgs = { + x: positions[0], + y: positions[1], + r: positions[2] / 2, + innerR: positions[3] / 2, + start: mathRound(start * precision) / precision, + end: mathRound(end * precision) / precision + }; + + // The angle must stay within -90 and 270 (#2645) + angle = (end + start) / 2; + if (angle > 1.5 * mathPI) { + angle -= 2 * mathPI; + } else if (angle < -mathPI / 2) { + angle += 2 * mathPI; + } + + // Center for the sliced out slice + point.slicedTranslation = { + translateX: mathRound(mathCos(angle) * slicedOffset), + translateY: mathRound(mathSin(angle) * slicedOffset) + }; + + // set the anchor point for tooltips + radiusX = mathCos(angle) * positions[2] / 2; + radiusY = mathSin(angle) * positions[2] / 2; + point.tooltipPos = [ + positions[0] + radiusX * 0.7, + positions[1] + radiusY * 0.7 + ]; + + point.half = angle < -mathPI / 2 || angle > mathPI / 2 ? 1 : 0; + point.angle = angle; + + // set the anchor point for data labels + connectorOffset = mathMin(connectorOffset, labelDistance / 2); // #1678 + point.labelPos = [ + positions[0] + radiusX + mathCos(angle) * labelDistance, // first break of connector + positions[1] + radiusY + mathSin(angle) * labelDistance, // a/a + positions[0] + radiusX + mathCos(angle) * connectorOffset, // second break, right outside pie + positions[1] + radiusY + mathSin(angle) * connectorOffset, // a/a + positions[0] + radiusX, // landing point for connector + positions[1] + radiusY, // a/a + labelDistance < 0 ? // alignment + 'center' : + point.half ? 'right' : 'left', // alignment + angle // center angle + ]; + + } + }, + + drawGraph: null, + + /** + * Draw the data points + */ + drawPoints: function () { + var series = this, + chart = series.chart, + renderer = chart.renderer, + groupTranslation, + //center, + graphic, + //group, + shadow = series.options.shadow, + shadowGroup, + shapeArgs; + + if (shadow && !series.shadowGroup) { + series.shadowGroup = renderer.g('shadow') + .add(series.group); + } + + // draw the slices + each(series.points, function (point) { + graphic = point.graphic; + shapeArgs = point.shapeArgs; + shadowGroup = point.shadowGroup; + + // put the shadow behind all points + if (shadow && !shadowGroup) { + shadowGroup = point.shadowGroup = renderer.g('shadow') + .add(series.shadowGroup); + } + + // if the point is sliced, use special translation, else use plot area traslation + groupTranslation = point.sliced ? point.slicedTranslation : { + translateX: 0, + translateY: 0 + }; + + //group.translate(groupTranslation[0], groupTranslation[1]); + if (shadowGroup) { + shadowGroup.attr(groupTranslation); + } + + // draw the slice + if (graphic) { + graphic.animate(extend(shapeArgs, groupTranslation)); + } else { + point.graphic = graphic = renderer[point.shapeType](shapeArgs) + .setRadialReference(series.center) + .attr( + point.pointAttr[point.selected ? SELECT_STATE : NORMAL_STATE] + ) + .attr({ + 'stroke-linejoin': 'round' + //zIndex: 1 // #2722 (reversed) + }) + .attr(groupTranslation) + .add(series.group) + .shadow(shadow, shadowGroup); + } + + // detect point specific visibility (#2430) + if (point.visible !== undefined) { + point.setVisible(point.visible); + } + + }); + + }, + + /** + * Utility for sorting data labels + */ + sortByAngle: function (points, sign) { + points.sort(function (a, b) { + return a.angle !== undefined && (b.angle - a.angle) * sign; + }); + }, + + /** + * Use a simple symbol from LegendSymbolMixin + */ + drawLegendSymbol: LegendSymbolMixin.drawRectangle, + + /** + * Use the getCenter method from drawLegendSymbol + */ + getCenter: CenteredSeriesMixin.getCenter, + + /** + * Pies don't have point marker symbols + */ + getSymbol: noop + +}; +PieSeries = extendClass(Series, PieSeries); +seriesTypes.pie = PieSeries; + +/** + * Draw the data labels + */ +Series.prototype.drawDataLabels = function () { + + var series = this, + seriesOptions = series.options, + cursor = seriesOptions.cursor, + options = seriesOptions.dataLabels, + points = series.points, + pointOptions, + generalOptions, + hasRendered = series.hasRendered || 0, + str, + dataLabelsGroup; + + if (options.enabled || series._hasPointLabels) { + + // Process default alignment of data labels for columns + if (series.dlProcessOptions) { + series.dlProcessOptions(options); + } + + // Create a separate group for the data labels to avoid rotation + dataLabelsGroup = series.plotGroup( + 'dataLabelsGroup', + 'data-labels', + options.defer ? HIDDEN : VISIBLE, + options.zIndex || 6 + ); + + if (pick(options.defer, true)) { + dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300 + if (!hasRendered) { + addEvent(series, 'afterAnimate', function () { + if (series.visible) { // #3023, #3024 + dataLabelsGroup.show(); + } + dataLabelsGroup[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, { duration: 200 }); + }); + } + } + + // Make the labels for each point + generalOptions = options; + each(points, function (point) { + + var enabled, + dataLabel = point.dataLabel, + labelConfig, + attr, + name, + rotation, + connector = point.connector, + isNew = true; + + // Determine if each data label is enabled + pointOptions = point.options && point.options.dataLabels; + enabled = pick(pointOptions && pointOptions.enabled, generalOptions.enabled); // #2282 + + + // If the point is outside the plot area, destroy it. #678, #820 + if (dataLabel && !enabled) { + point.dataLabel = dataLabel.destroy(); + + // Individual labels are disabled if the are explicitly disabled + // in the point options, or if they fall outside the plot area. + } else if (enabled) { + + // Create individual options structure that can be extended without + // affecting others + options = merge(generalOptions, pointOptions); + + rotation = options.rotation; + + // Get the string + labelConfig = point.getLabelConfig(); + str = options.format ? + format(options.format, labelConfig) : + options.formatter.call(labelConfig, options); + + // Determine the color + options.style.color = pick(options.color, options.style.color, series.color, 'black'); + + + // update existing label + if (dataLabel) { + + if (defined(str)) { + dataLabel + .attr({ + text: str + }); + isNew = false; + + } else { // #1437 - the label is shown conditionally + point.dataLabel = dataLabel = dataLabel.destroy(); + if (connector) { + point.connector = connector.destroy(); + } + } + + // create new label + } else if (defined(str)) { + attr = { + //align: align, + fill: options.backgroundColor, + stroke: options.borderColor, + 'stroke-width': options.borderWidth, + r: options.borderRadius || 0, + rotation: rotation, + padding: options.padding, + zIndex: 1 + }; + // Remove unused attributes (#947) + for (name in attr) { + if (attr[name] === UNDEFINED) { + delete attr[name]; + } + } + + dataLabel = point.dataLabel = series.chart.renderer[rotation ? 'text' : 'label']( // labels don't support rotation + str, + 0, + -999, + null, + null, + null, + options.useHTML + ) + .attr(attr) + .css(extend(options.style, cursor && { cursor: cursor })) + .add(dataLabelsGroup) + .shadow(options.shadow); + + } + + if (dataLabel) { + // Now the data label is created and placed at 0,0, so we need to align it + series.alignDataLabel(point, dataLabel, options, null, isNew); + } + } + }); + } +}; + +/** + * Align each individual data label + */ +Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) { + var chart = this.chart, + inverted = chart.inverted, + plotX = pick(point.plotX, -999), + plotY = pick(point.plotY, -999), + bBox = dataLabel.getBBox(), + // Math.round for rounding errors (#2683), alignTo to allow column labels (#2700) + visible = this.visible && (point.series.forceDL || chart.isInsidePlot(plotX, mathRound(plotY), inverted) || + (alignTo && chart.isInsidePlot(plotX, inverted ? alignTo.x + 1 : alignTo.y + alignTo.height - 1, inverted))), + alignAttr; // the final position; + + if (visible) { + + // The alignment box is a singular point + alignTo = extend({ + x: inverted ? chart.plotWidth - plotY : plotX, + y: mathRound(inverted ? chart.plotHeight - plotX : plotY), + width: 0, + height: 0 + }, alignTo); + + // Add the text size for alignment calculation + extend(options, { + width: bBox.width, + height: bBox.height + }); + + // Allow a hook for changing alignment in the last moment, then do the alignment + if (options.rotation) { // Fancy box alignment isn't supported for rotated text + dataLabel[isNew ? 'attr' : 'animate']({ + x: alignTo.x + options.x + alignTo.width / 2, + y: alignTo.y + options.y + alignTo.height / 2 + }) + .attr({ // #3003 + align: options.align + }); + } else { + dataLabel.align(options, null, alignTo); + alignAttr = dataLabel.alignAttr; + + // Handle justify or crop + if (pick(options.overflow, 'justify') === 'justify') { + this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew); + + } else if (pick(options.crop, true)) { + // Now check that the data label is within the plot area + visible = chart.isInsidePlot(alignAttr.x, alignAttr.y) && chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height); + + } + } + } + + // Show or hide based on the final aligned position + if (!visible) { + dataLabel.attr({ y: -999 }); + dataLabel.placed = false; // don't animate back in + } + +}; + +/** + * If data labels fall partly outside the plot area, align them back in, in a way that + * doesn't hide the point. + */ +Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) { + var chart = this.chart, + align = options.align, + verticalAlign = options.verticalAlign, + off, + justified; + + // Off left + off = alignAttr.x; + if (off < 0) { + if (align === 'right') { + options.align = 'left'; + } else { + options.x = -off; + } + justified = true; + } + + // Off right + off = alignAttr.x + bBox.width; + if (off > chart.plotWidth) { + if (align === 'left') { + options.align = 'right'; + } else { + options.x = chart.plotWidth - off; + } + justified = true; + } + + // Off top + off = alignAttr.y; + if (off < 0) { + if (verticalAlign === 'bottom') { + options.verticalAlign = 'top'; + } else { + options.y = -off; + } + justified = true; + } + + // Off bottom + off = alignAttr.y + bBox.height; + if (off > chart.plotHeight) { + if (verticalAlign === 'top') { + options.verticalAlign = 'bottom'; + } else { + options.y = chart.plotHeight - off; + } + justified = true; + } + + if (justified) { + dataLabel.placed = !isNew; + dataLabel.align(options, null, alignTo); + } +}; + +/** + * Override the base drawDataLabels method by pie specific functionality + */ +if (seriesTypes.pie) { + seriesTypes.pie.prototype.drawDataLabels = function () { + var series = this, + data = series.data, + point, + chart = series.chart, + options = series.options.dataLabels, + connectorPadding = pick(options.connectorPadding, 10), + connectorWidth = pick(options.connectorWidth, 1), + plotWidth = chart.plotWidth, + plotHeight = chart.plotHeight, + connector, + connectorPath, + softConnector = pick(options.softConnector, true), + distanceOption = options.distance, + seriesCenter = series.center, + radius = seriesCenter[2] / 2, + centerY = seriesCenter[1], + outside = distanceOption > 0, + dataLabel, + dataLabelWidth, + labelPos, + labelHeight, + halves = [// divide the points into right and left halves for anti collision + [], // right + [] // left + ], + x, + y, + visibility, + rankArr, + i, + j, + overflow = [0, 0, 0, 0], // top, right, bottom, left + sort = function (a, b) { + return b.y - a.y; + }; + + // get out if not enabled + if (!series.visible || (!options.enabled && !series._hasPointLabels)) { + return; + } + + // run parent method + Series.prototype.drawDataLabels.apply(series); + + // arrange points for detection collision + each(data, function (point) { + if (point.dataLabel && point.visible) { // #407, #2510 + halves[point.half].push(point); + } + }); + + /* Loop over the points in each half, starting from the top and bottom + * of the pie to detect overlapping labels. + */ + i = 2; + while (i--) { + + var slots = [], + slotsLength, + usedSlots = [], + points = halves[i], + pos, + bottom, + length = points.length, + slotIndex; + + if (!length) { + continue; + } + + // Sort by angle + series.sortByAngle(points, i - 0.5); + + // Assume equal label heights on either hemisphere (#2630) + j = labelHeight = 0; + while (!labelHeight && points[j]) { // #1569 + labelHeight = points[j] && points[j].dataLabel && (points[j].dataLabel.getBBox().height || 21); // 21 is for #968 + j++; + } + + // Only do anti-collision when we are outside the pie and have connectors (#856) + if (distanceOption > 0) { + + // Build the slots + bottom = mathMin(centerY + radius + distanceOption, chart.plotHeight); + for (pos = mathMax(0, centerY - radius - distanceOption); pos <= bottom; pos += labelHeight) { + slots.push(pos); + } + slotsLength = slots.length; + + + /* Visualize the slots + if (!series.slotElements) { + series.slotElements = []; + } + if (i === 1) { + series.slotElements.forEach(function (elem) { + elem.destroy(); + }); + series.slotElements.length = 0; + } + + slots.forEach(function (pos, no) { + var slotX = series.getX(pos, i) + chart.plotLeft - (i ? 100 : 0), + slotY = pos + chart.plotTop; + + if (!isNaN(slotX)) { + series.slotElements.push(chart.renderer.rect(slotX, slotY - 7, 100, labelHeight, 1) + .attr({ + 'stroke-width': 1, + stroke: 'silver', + fill: 'rgba(0,0,255,0.1)' + }) + .add()); + series.slotElements.push(chart.renderer.text('Slot '+ no, slotX, slotY + 4) + .attr({ + fill: 'silver' + }).add()); + } + }); + // */ + + // if there are more values than available slots, remove lowest values + if (length > slotsLength) { + // create an array for sorting and ranking the points within each quarter + rankArr = [].concat(points); + rankArr.sort(sort); + j = length; + while (j--) { + rankArr[j].rank = j; + } + j = length; + while (j--) { + if (points[j].rank >= slotsLength) { + points.splice(j, 1); + } + } + length = points.length; + } + + // The label goes to the nearest open slot, but not closer to the edge than + // the label's index. + for (j = 0; j < length; j++) { + + point = points[j]; + labelPos = point.labelPos; + + var closest = 9999, + distance, + slotI; + + // find the closest slot index + for (slotI = 0; slotI < slotsLength; slotI++) { + distance = mathAbs(slots[slotI] - labelPos[1]); + if (distance < closest) { + closest = distance; + slotIndex = slotI; + } + } + + // if that slot index is closer to the edges of the slots, move it + // to the closest appropriate slot + if (slotIndex < j && slots[j] !== null) { // cluster at the top + slotIndex = j; + } else if (slotsLength < length - j + slotIndex && slots[j] !== null) { // cluster at the bottom + slotIndex = slotsLength - length + j; + while (slots[slotIndex] === null) { // make sure it is not taken + slotIndex++; + } + } else { + // Slot is taken, find next free slot below. In the next run, the next slice will find the + // slot above these, because it is the closest one + while (slots[slotIndex] === null) { // make sure it is not taken + slotIndex++; + } + } + + usedSlots.push({ i: slotIndex, y: slots[slotIndex] }); + slots[slotIndex] = null; // mark as taken + } + // sort them in order to fill in from the top + usedSlots.sort(sort); + } + + // now the used slots are sorted, fill them up sequentially + for (j = 0; j < length; j++) { + + var slot, naturalY; + + point = points[j]; + labelPos = point.labelPos; + dataLabel = point.dataLabel; + visibility = point.visible === false ? HIDDEN : VISIBLE; + naturalY = labelPos[1]; + + if (distanceOption > 0) { + slot = usedSlots.pop(); + slotIndex = slot.i; + + // if the slot next to currrent slot is free, the y value is allowed + // to fall back to the natural position + y = slot.y; + if ((naturalY > y && slots[slotIndex + 1] !== null) || + (naturalY < y && slots[slotIndex - 1] !== null)) { + y = mathMin(mathMax(0, naturalY), chart.plotHeight); + } + + } else { + y = naturalY; + } + + // get the x - use the natural x position for first and last slot, to prevent the top + // and botton slice connectors from touching each other on either side + x = options.justify ? + seriesCenter[0] + (i ? -1 : 1) * (radius + distanceOption) : + series.getX(y === centerY - radius - distanceOption || y === centerY + radius + distanceOption ? naturalY : y, i); + + + // Record the placement and visibility + dataLabel._attr = { + visibility: visibility, + align: labelPos[6] + }; + dataLabel._pos = { + x: x + options.x + + ({ left: connectorPadding, right: -connectorPadding }[labelPos[6]] || 0), + y: y + options.y - 10 // 10 is for the baseline (label vs text) + }; + dataLabel.connX = x; + dataLabel.connY = y; + + + // Detect overflowing data labels + if (this.options.size === null) { + dataLabelWidth = dataLabel.width; + // Overflow left + if (x - dataLabelWidth < connectorPadding) { + overflow[3] = mathMax(mathRound(dataLabelWidth - x + connectorPadding), overflow[3]); + + // Overflow right + } else if (x + dataLabelWidth > plotWidth - connectorPadding) { + overflow[1] = mathMax(mathRound(x + dataLabelWidth - plotWidth + connectorPadding), overflow[1]); + } + + // Overflow top + if (y - labelHeight / 2 < 0) { + overflow[0] = mathMax(mathRound(-y + labelHeight / 2), overflow[0]); + + // Overflow left + } else if (y + labelHeight / 2 > plotHeight) { + overflow[2] = mathMax(mathRound(y + labelHeight / 2 - plotHeight), overflow[2]); + } + } + } // for each point + } // for each half + + // Do not apply the final placement and draw the connectors until we have verified + // that labels are not spilling over. + if (arrayMax(overflow) === 0 || this.verifyDataLabelOverflow(overflow)) { + + // Place the labels in the final position + this.placeDataLabels(); + + // Draw the connectors + if (outside && connectorWidth) { + each(this.points, function (point) { + connector = point.connector; + labelPos = point.labelPos; + dataLabel = point.dataLabel; + + if (dataLabel && dataLabel._pos) { + visibility = dataLabel._attr.visibility; + x = dataLabel.connX; + y = dataLabel.connY; + connectorPath = softConnector ? [ + M, + x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label + 'C', + x, y, // first break, next to the label + 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5], + labelPos[2], labelPos[3], // second break + L, + labelPos[4], labelPos[5] // base + ] : [ + M, + x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label + L, + labelPos[2], labelPos[3], // second break + L, + labelPos[4], labelPos[5] // base + ]; + + if (connector) { + connector.animate({ d: connectorPath }); + connector.attr('visibility', visibility); + + } else { + point.connector = connector = series.chart.renderer.path(connectorPath).attr({ + 'stroke-width': connectorWidth, + stroke: options.connectorColor || point.color || '#606060', + visibility: visibility + //zIndex: 0 // #2722 (reversed) + }) + .add(series.dataLabelsGroup); + } + } else if (connector) { + point.connector = connector.destroy(); + } + }); + } + } + }; + /** + * Perform the final placement of the data labels after we have verified that they + * fall within the plot area. + */ + seriesTypes.pie.prototype.placeDataLabels = function () { + each(this.points, function (point) { + var dataLabel = point.dataLabel, + _pos; + + if (dataLabel) { + _pos = dataLabel._pos; + if (_pos) { + dataLabel.attr(dataLabel._attr); + dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos); + dataLabel.moved = true; + } else if (dataLabel) { + dataLabel.attr({ y: -999 }); + } + } + }); + }; + + seriesTypes.pie.prototype.alignDataLabel = noop; + + /** + * Verify whether the data labels are allowed to draw, or we should run more translation and data + * label positioning to keep them inside the plot area. Returns true when data labels are ready + * to draw. + */ + seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) { + + var center = this.center, + options = this.options, + centerOption = options.center, + minSize = options.minSize || 80, + newSize = minSize, + ret; + + // Handle horizontal size and center + if (centerOption[0] !== null) { // Fixed center + newSize = mathMax(center[2] - mathMax(overflow[1], overflow[3]), minSize); + + } else { // Auto center + newSize = mathMax( + center[2] - overflow[1] - overflow[3], // horizontal overflow + minSize + ); + center[0] += (overflow[3] - overflow[1]) / 2; // horizontal center + } + + // Handle vertical size and center + if (centerOption[1] !== null) { // Fixed center + newSize = mathMax(mathMin(newSize, center[2] - mathMax(overflow[0], overflow[2])), minSize); + + } else { // Auto center + newSize = mathMax( + mathMin( + newSize, + center[2] - overflow[0] - overflow[2] // vertical overflow + ), + minSize + ); + center[1] += (overflow[0] - overflow[2]) / 2; // vertical center + } + + // If the size must be decreased, we need to run translate and drawDataLabels again + if (newSize < center[2]) { + center[2] = newSize; + this.translate(center); + each(this.points, function (point) { + if (point.dataLabel) { + point.dataLabel._pos = null; // reset + } + }); + + if (this.drawDataLabels) { + this.drawDataLabels(); + } + // Else, return true to indicate that the pie and its labels is within the plot area + } else { + ret = true; + } + return ret; + }; +} + +if (seriesTypes.column) { + + /** + * Override the basic data label alignment by adjusting for the position of the column + */ + seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) { + var chart = this.chart, + inverted = chart.inverted, + dlBox = point.dlBox || point.shapeArgs, // data label box for alignment + below = point.below || (point.plotY > pick(this.translatedThreshold, chart.plotSizeY)), + inside = pick(options.inside, !!this.options.stacking); // draw it inside the box? + + // Align to the column itself, or the top of it + if (dlBox) { // Area range uses this method but not alignTo + alignTo = merge(dlBox); + + if (inverted) { + alignTo = { + x: chart.plotWidth - alignTo.y - alignTo.height, + y: chart.plotHeight - alignTo.x - alignTo.width, + width: alignTo.height, + height: alignTo.width + }; + } + + // Compute the alignment box + if (!inside) { + if (inverted) { + alignTo.x += below ? 0 : alignTo.width; + alignTo.width = 0; + } else { + alignTo.y += below ? alignTo.height : 0; + alignTo.height = 0; + } + } + } + + + // When alignment is undefined (typically columns and bars), display the individual + // point below or above the point depending on the threshold + options.align = pick( + options.align, + !inverted || inside ? 'center' : below ? 'right' : 'left' + ); + options.verticalAlign = pick( + options.verticalAlign, + inverted || inside ? 'middle' : below ? 'top' : 'bottom' + ); + + // Call the parent method + Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew); + }; +} + + + +/** + * TrackerMixin for points and graphs + */ + +var TrackerMixin = Highcharts.TrackerMixin = { + + drawTrackerPoint: function () { + var series = this, + chart = series.chart, + pointer = chart.pointer, + cursor = series.options.cursor, + css = cursor && { cursor: cursor }, + onMouseOver = function (e) { + var target = e.target, + point; + + if (chart.hoverSeries !== series) { + series.onMouseOver(); + } + + while (target && !point) { + point = target.point; + target = target.parentNode; + } + + if (point !== UNDEFINED && point !== chart.hoverPoint) { // undefined on graph in scatterchart + point.onMouseOver(e); + } + }; + + // Add reference to the point + each(series.points, function (point) { + if (point.graphic) { + point.graphic.element.point = point; + } + if (point.dataLabel) { + point.dataLabel.element.point = point; + } + }); + + // Add the event listeners, we need to do this only once + if (!series._hasTracking) { + each(series.trackerGroups, function (key) { + if (series[key]) { // we don't always have dataLabelsGroup + series[key] + .addClass(PREFIX + 'tracker') + .on('mouseover', onMouseOver) + .on('mouseout', function (e) { pointer.onTrackerMouseOut(e); }) + .css(css); + if (hasTouch) { + series[key].on('touchstart', onMouseOver); + } + } + }); + series._hasTracking = true; + } + }, + + /** + * Draw the tracker object that sits above all data labels and markers to + * track mouse events on the graph or points. For the line type charts + * the tracker uses the same graphPath, but with a greater stroke width + * for better control. + */ + drawTrackerGraph: function () { + var series = this, + options = series.options, + trackByArea = options.trackByArea, + trackerPath = [].concat(trackByArea ? series.areaPath : series.graphPath), + trackerPathLength = trackerPath.length, + chart = series.chart, + pointer = chart.pointer, + renderer = chart.renderer, + snap = chart.options.tooltip.snap, + tracker = series.tracker, + cursor = options.cursor, + css = cursor && { cursor: cursor }, + singlePoints = series.singlePoints, + singlePoint, + i, + onMouseOver = function () { + if (chart.hoverSeries !== series) { + series.onMouseOver(); + } + }, + /* + * Empirical lowest possible opacities for TRACKER_FILL for an element to stay invisible but clickable + * IE6: 0.002 + * IE7: 0.002 + * IE8: 0.002 + * IE9: 0.00000000001 (unlimited) + * IE10: 0.0001 (exporting only) + * FF: 0.00000000001 (unlimited) + * Chrome: 0.000001 + * Safari: 0.000001 + * Opera: 0.00000000001 (unlimited) + */ + TRACKER_FILL = 'rgba(192,192,192,' + (hasSVG ? 0.0001 : 0.002) + ')'; + + // Extend end points. A better way would be to use round linecaps, + // but those are not clickable in VML. + if (trackerPathLength && !trackByArea) { + i = trackerPathLength + 1; + while (i--) { + if (trackerPath[i] === M) { // extend left side + trackerPath.splice(i + 1, 0, trackerPath[i + 1] - snap, trackerPath[i + 2], L); + } + if ((i && trackerPath[i] === M) || i === trackerPathLength) { // extend right side + trackerPath.splice(i, 0, L, trackerPath[i - 2] + snap, trackerPath[i - 1]); + } + } + } + + // handle single points + for (i = 0; i < singlePoints.length; i++) { + singlePoint = singlePoints[i]; + trackerPath.push(M, singlePoint.plotX - snap, singlePoint.plotY, + L, singlePoint.plotX + snap, singlePoint.plotY); + } + + // draw the tracker + if (tracker) { + tracker.attr({ d: trackerPath }); + } else { // create + + series.tracker = renderer.path(trackerPath) + .attr({ + 'stroke-linejoin': 'round', // #1225 + visibility: series.visible ? VISIBLE : HIDDEN, + stroke: TRACKER_FILL, + fill: trackByArea ? TRACKER_FILL : NONE, + 'stroke-width' : options.lineWidth + (trackByArea ? 0 : 2 * snap), + zIndex: 2 + }) + .add(series.group); + + // The tracker is added to the series group, which is clipped, but is covered + // by the marker group. So the marker group also needs to capture events. + each([series.tracker, series.markerGroup], function (tracker) { + tracker.addClass(PREFIX + 'tracker') + .on('mouseover', onMouseOver) + .on('mouseout', function (e) { pointer.onTrackerMouseOut(e); }) + .css(css); + + if (hasTouch) { + tracker.on('touchstart', onMouseOver); + } + }); + } + } +}; +/* End TrackerMixin */ + + +/** + * Add tracking event listener to the series group, so the point graphics + * themselves act as trackers + */ + +if (seriesTypes.column) { + ColumnSeries.prototype.drawTracker = TrackerMixin.drawTrackerPoint; +} + +if (seriesTypes.pie) { + seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint; +} + +if (seriesTypes.scatter) { + ScatterSeries.prototype.drawTracker = TrackerMixin.drawTrackerPoint; +} + +/* + * Extend Legend for item events + */ +extend(Legend.prototype, { + + setItemEvents: function (item, legendItem, useHTML, itemStyle, itemHiddenStyle) { + var legend = this; + // Set the events on the item group, or in case of useHTML, the item itself (#1249) + (useHTML ? legendItem : item.legendGroup).on('mouseover', function () { + item.setState(HOVER_STATE); + legendItem.css(legend.options.itemHoverStyle); + }) + .on('mouseout', function () { + legendItem.css(item.visible ? itemStyle : itemHiddenStyle); + item.setState(); + }) + .on('click', function (event) { + var strLegendItemClick = 'legendItemClick', + fnLegendItemClick = function () { + item.setVisible(); + }; + + // Pass over the click/touch event. #4. + event = { + browserEvent: event + }; + + // click the name or symbol + if (item.firePointEvent) { // point + item.firePointEvent(strLegendItemClick, event, fnLegendItemClick); + } else { + fireEvent(item, strLegendItemClick, event, fnLegendItemClick); + } + }); + }, + + createCheckboxForItem: function (item) { + var legend = this; + + item.checkbox = createElement('input', { + type: 'checkbox', + checked: item.selected, + defaultChecked: item.selected // required by IE7 + }, legend.options.itemCheckboxStyle, legend.chart.container); + + addEvent(item.checkbox, 'click', function (event) { + var target = event.target; + fireEvent(item, 'checkboxClick', { + checked: target.checked + }, + function () { + item.select(); + } + ); + }); + } +}); + +/* + * Add pointer cursor to legend itemstyle in defaultOptions + */ +defaultOptions.legend.itemStyle.cursor = 'pointer'; + + +/* + * Extend the Chart object with interaction + */ + +extend(Chart.prototype, { + /** + * Display the zoom button + */ + showResetZoom: function () { + var chart = this, + lang = defaultOptions.lang, + btnOptions = chart.options.chart.resetZoomButton, + theme = btnOptions.theme, + states = theme.states, + alignTo = btnOptions.relativeTo === 'chart' ? null : 'plotBox'; + + this.resetZoomButton = chart.renderer.button(lang.resetZoom, null, null, function () { chart.zoomOut(); }, theme, states && states.hover) + .attr({ + align: btnOptions.position.align, + title: lang.resetZoomTitle + }) + .add() + .align(btnOptions.position, false, alignTo); + + }, + + /** + * Zoom out to 1:1 + */ + zoomOut: function () { + var chart = this; + fireEvent(chart, 'selection', { resetSelection: true }, function () { + chart.zoom(); + }); + }, + + /** + * Zoom into a given portion of the chart given by axis coordinates + * @param {Object} event + */ + zoom: function (event) { + var chart = this, + hasZoomed, + pointer = chart.pointer, + displayButton = false, + resetZoomButton; + + // If zoom is called with no arguments, reset the axes + if (!event || event.resetSelection) { + each(chart.axes, function (axis) { + hasZoomed = axis.zoom(); + }); + } else { // else, zoom in on all axes + each(event.xAxis.concat(event.yAxis), function (axisData) { + var axis = axisData.axis, + isXAxis = axis.isXAxis; + + // don't zoom more than minRange + if (pointer[isXAxis ? 'zoomX' : 'zoomY'] || pointer[isXAxis ? 'pinchX' : 'pinchY']) { + hasZoomed = axis.zoom(axisData.min, axisData.max); + if (axis.displayBtn) { + displayButton = true; + } + } + }); + } + + // Show or hide the Reset zoom button + resetZoomButton = chart.resetZoomButton; + if (displayButton && !resetZoomButton) { + chart.showResetZoom(); + } else if (!displayButton && isObject(resetZoomButton)) { + chart.resetZoomButton = resetZoomButton.destroy(); + } + + + // Redraw + if (hasZoomed) { + chart.redraw( + pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100) // animation + ); + } + }, + + /** + * Pan the chart by dragging the mouse across the pane. This function is called + * on mouse move, and the distance to pan is computed from chartX compared to + * the first chartX position in the dragging operation. + */ + pan: function (e, panning) { + + var chart = this, + hoverPoints = chart.hoverPoints, + doRedraw; + + // remove active points for shared tooltip + if (hoverPoints) { + each(hoverPoints, function (point) { + point.setState(); + }); + } + + each(panning === 'xy' ? [1, 0] : [1], function (isX) { // xy is used in maps + var mousePos = e[isX ? 'chartX' : 'chartY'], + axis = chart[isX ? 'xAxis' : 'yAxis'][0], + startPos = chart[isX ? 'mouseDownX' : 'mouseDownY'], + halfPointRange = (axis.pointRange || 0) / 2, + extremes = axis.getExtremes(), + newMin = axis.toValue(startPos - mousePos, true) + halfPointRange, + newMax = axis.toValue(startPos + chart[isX ? 'plotWidth' : 'plotHeight'] - mousePos, true) - halfPointRange; + + if (axis.series.length && newMin > mathMin(extremes.dataMin, extremes.min) && newMax < mathMax(extremes.dataMax, extremes.max)) { + axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' }); + doRedraw = true; + } + + chart[isX ? 'mouseDownX' : 'mouseDownY'] = mousePos; // set new reference for next run + }); + + if (doRedraw) { + chart.redraw(false); + } + css(chart.container, { cursor: 'move' }); + } +}); + +/* + * Extend the Point object with interaction + */ +extend(Point.prototype, { + /** + * Toggle the selection status of a point + * @param {Boolean} selected Whether to select or unselect the point. + * @param {Boolean} accumulate Whether to add to the previous selection. By default, + * this happens if the control key (Cmd on Mac) was pressed during clicking. + */ + select: function (selected, accumulate) { + var point = this, + series = point.series, + chart = series.chart; + + selected = pick(selected, !point.selected); + + // fire the event with the defalut handler + point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () { + point.selected = point.options.selected = selected; + series.options.data[inArray(point, series.data)] = point.options; + + point.setState(selected && SELECT_STATE); + + // unselect all other points unless Ctrl or Cmd + click + if (!accumulate) { + each(chart.getSelectedPoints(), function (loopPoint) { + if (loopPoint.selected && loopPoint !== point) { + loopPoint.selected = loopPoint.options.selected = false; + series.options.data[inArray(loopPoint, series.data)] = loopPoint.options; + loopPoint.setState(NORMAL_STATE); + loopPoint.firePointEvent('unselect'); + } + }); + } + }); + }, + + /** + * Runs on mouse over the point + */ + onMouseOver: function (e) { + var point = this, + series = point.series, + chart = series.chart, + tooltip = chart.tooltip, + hoverPoint = chart.hoverPoint; + + // set normal state to previous series + if (hoverPoint && hoverPoint !== point) { + hoverPoint.onMouseOut(); + } + + // trigger the event + point.firePointEvent('mouseOver'); + + // update the tooltip + if (tooltip && (!tooltip.shared || series.noSharedTooltip)) { + tooltip.refresh(point, e); + } + + // hover this + point.setState(HOVER_STATE); + chart.hoverPoint = point; + }, + + /** + * Runs on mouse out from the point + */ + onMouseOut: function () { + var chart = this.series.chart, + hoverPoints = chart.hoverPoints; + + this.firePointEvent('mouseOut'); + + if (!hoverPoints || inArray(this, hoverPoints) === -1) { // #887, #2240 + this.setState(); + chart.hoverPoint = null; + } + }, + + /** + * Import events from the series' and point's options. Only do it on + * demand, to save processing time on hovering. + */ + importEvents: function () { + if (!this.hasImportedEvents) { + var point = this, + options = merge(point.series.options.point, point.options), + events = options.events, + eventType; + + point.events = events; + + for (eventType in events) { + addEvent(point, eventType, events[eventType]); + } + this.hasImportedEvents = true; + + } + }, + + /** + * Set the point's state + * @param {String} state + */ + setState: function (state, move) { + var point = this, + plotX = point.plotX, + plotY = point.plotY, + series = point.series, + stateOptions = series.options.states, + markerOptions = defaultPlotOptions[series.type].marker && series.options.marker, + normalDisabled = markerOptions && !markerOptions.enabled, + markerStateOptions = markerOptions && markerOptions.states[state], + stateDisabled = markerStateOptions && markerStateOptions.enabled === false, + stateMarkerGraphic = series.stateMarkerGraphic, + pointMarker = point.marker || {}, + chart = series.chart, + radius, + halo = series.halo, + haloOptions, + newSymbol, + pointAttr; + + state = state || NORMAL_STATE; // empty string + pointAttr = point.pointAttr[state] || series.pointAttr[state]; + + if ( + // already has this state + (state === point.state && !move) || + // selected points don't respond to hover + (point.selected && state !== SELECT_STATE) || + // series' state options is disabled + (stateOptions[state] && stateOptions[state].enabled === false) || + // general point marker's state options is disabled + (state && (stateDisabled || (normalDisabled && markerStateOptions.enabled === false))) || + // individual point marker's state options is disabled + (state && pointMarker.states && pointMarker.states[state] && pointMarker.states[state].enabled === false) // #1610 + + ) { + return; + } + + // apply hover styles to the existing point + if (point.graphic) { + radius = markerOptions && point.graphic.symbolName && pointAttr.r; + point.graphic.attr(merge( + pointAttr, + radius ? { // new symbol attributes (#507, #612) + x: plotX - radius, + y: plotY - radius, + width: 2 * radius, + height: 2 * radius + } : {} + )); + + // Zooming in from a range with no markers to a range with markers + if (stateMarkerGraphic) { + stateMarkerGraphic.hide(); + } + } else { + // if a graphic is not applied to each point in the normal state, create a shared + // graphic for the hover state + if (state && markerStateOptions) { + radius = markerStateOptions.radius; + newSymbol = pointMarker.symbol || series.symbol; + + // If the point has another symbol than the previous one, throw away the + // state marker graphic and force a new one (#1459) + if (stateMarkerGraphic && stateMarkerGraphic.currentSymbol !== newSymbol) { + stateMarkerGraphic = stateMarkerGraphic.destroy(); + } + + // Add a new state marker graphic + if (!stateMarkerGraphic) { + if (newSymbol) { + series.stateMarkerGraphic = stateMarkerGraphic = chart.renderer.symbol( + newSymbol, + plotX - radius, + plotY - radius, + 2 * radius, + 2 * radius + ) + .attr(pointAttr) + .add(series.markerGroup); + stateMarkerGraphic.currentSymbol = newSymbol; + } + + // Move the existing graphic + } else { + stateMarkerGraphic[move ? 'animate' : 'attr']({ // #1054 + x: plotX - radius, + y: plotY - radius + }); + } + } + + if (stateMarkerGraphic) { + stateMarkerGraphic[state && chart.isInsidePlot(plotX, plotY, chart.inverted) ? 'show' : 'hide'](); // #2450 + } + } + + // Show me your halo + haloOptions = stateOptions[state] && stateOptions[state].halo; + if (haloOptions && haloOptions.size) { + if (!halo) { + series.halo = halo = chart.renderer.path() + .add(series.seriesGroup); + } + halo.attr(extend({ + fill: Color(point.color || series.color).setOpacity(haloOptions.opacity).get() + }, haloOptions.attributes))[move ? 'animate' : 'attr']({ + d: point.haloPath(haloOptions.size) + }); + } else if (halo) { + halo.attr({ d: [] }); + } + + point.state = state; + }, + + haloPath: function (size) { + var series = this.series, + chart = series.chart, + plotBox = series.getPlotBox(), + inverted = chart.inverted; + + return chart.renderer.symbols.circle( + plotBox.translateX + (inverted ? series.yAxis.len - this.plotY : this.plotX) - size, + plotBox.translateY + (inverted ? series.xAxis.len - this.plotX : this.plotY) - size, + size * 2, + size * 2 + ); + } +}); + +/* + * Extend the Series object with interaction + */ + +extend(Series.prototype, { + /** + * Series mouse over handler + */ + onMouseOver: function () { + var series = this, + chart = series.chart, + hoverSeries = chart.hoverSeries; + + // set normal state to previous series + if (hoverSeries && hoverSeries !== series) { + hoverSeries.onMouseOut(); + } + + // trigger the event, but to save processing time, + // only if defined + if (series.options.events.mouseOver) { + fireEvent(series, 'mouseOver'); + } + + // hover this + series.setState(HOVER_STATE); + chart.hoverSeries = series; + }, + + /** + * Series mouse out handler + */ + onMouseOut: function () { + // trigger the event only if listeners exist + var series = this, + options = series.options, + chart = series.chart, + tooltip = chart.tooltip, + hoverPoint = chart.hoverPoint; + + // trigger mouse out on the point, which must be in this series + if (hoverPoint) { + hoverPoint.onMouseOut(); + } + + // fire the mouse out event + if (series && options.events.mouseOut) { + fireEvent(series, 'mouseOut'); + } + + + // hide the tooltip + if (tooltip && !options.stickyTracking && (!tooltip.shared || series.noSharedTooltip)) { + tooltip.hide(); + } + + // set normal state + series.setState(); + chart.hoverSeries = null; + }, + + /** + * Set the state of the graph + */ + setState: function (state) { + var series = this, + options = series.options, + graph = series.graph, + graphNeg = series.graphNeg, + stateOptions = options.states, + lineWidth = options.lineWidth, + attribs; + + state = state || NORMAL_STATE; + + if (series.state !== state) { + series.state = state; + + if (stateOptions[state] && stateOptions[state].enabled === false) { + return; + } + + if (state) { + lineWidth = stateOptions[state].lineWidth || lineWidth + (stateOptions[state].lineWidthPlus || 0); + } + + if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML + attribs = { + 'stroke-width': lineWidth + }; + // use attr because animate will cause any other animation on the graph to stop + graph.attr(attribs); + if (graphNeg) { + graphNeg.attr(attribs); + } + } + } + }, + + /** + * Set the visibility of the graph + * + * @param vis {Boolean} True to show the series, false to hide. If UNDEFINED, + * the visibility is toggled. + */ + setVisible: function (vis, redraw) { + var series = this, + chart = series.chart, + legendItem = series.legendItem, + showOrHide, + ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries, + oldVisibility = series.visible; + + // if called without an argument, toggle visibility + series.visible = vis = series.userOptions.visible = vis === UNDEFINED ? !oldVisibility : vis; + showOrHide = vis ? 'show' : 'hide'; + + // show or hide elements + each(['group', 'dataLabelsGroup', 'markerGroup', 'tracker'], function (key) { + if (series[key]) { + series[key][showOrHide](); + } + }); + + + // hide tooltip (#1361) + if (chart.hoverSeries === series) { + series.onMouseOut(); + } + + + if (legendItem) { + chart.legend.colorizeItem(series, vis); + } + + + // rescale or adapt to resized chart + series.isDirty = true; + // in a stack, all other series are affected + if (series.options.stacking) { + each(chart.series, function (otherSeries) { + if (otherSeries.options.stacking && otherSeries.visible) { + otherSeries.isDirty = true; + } + }); + } + + // show or hide linked series + each(series.linkedSeries, function (otherSeries) { + otherSeries.setVisible(vis, false); + }); + + if (ignoreHiddenSeries) { + chart.isDirtyBox = true; + } + if (redraw !== false) { + chart.redraw(); + } + + fireEvent(series, showOrHide); + }, + + /** + * Memorize tooltip texts and positions + */ + setTooltipPoints: function (renew) { + var series = this, + points = [], + pointsLength, + low, + high, + xAxis = series.xAxis, + xExtremes = xAxis && xAxis.getExtremes(), + axisLength = xAxis ? (xAxis.tooltipLen || xAxis.len) : series.chart.plotSizeX, // tooltipLen and tooltipPosName used in polar + point, + pointX, + nextPoint, + i, + tooltipPoints = []; // a lookup array for each pixel in the x dimension + + // don't waste resources if tracker is disabled + if (series.options.enableMouseTracking === false || series.singularTooltips) { + return; + } + + // renew + if (renew) { + series.tooltipPoints = null; + } + + // concat segments to overcome null values + each(series.segments || series.points, function (segment) { + points = points.concat(segment); + }); + + // Reverse the points in case the X axis is reversed + if (xAxis && xAxis.reversed) { + points = points.reverse(); + } + + // Polar needs additional shaping + if (series.orderTooltipPoints) { + series.orderTooltipPoints(points); + } + + // Assign each pixel position to the nearest point + pointsLength = points.length; + for (i = 0; i < pointsLength; i++) { + point = points[i]; + pointX = point.x; + if (pointX >= xExtremes.min && pointX <= xExtremes.max) { // #1149 + nextPoint = points[i + 1]; + + // Set this range's low to the last range's high plus one + low = high === UNDEFINED ? 0 : high + 1; + // Now find the new high + high = points[i + 1] ? + mathMin(mathMax(0, mathFloor( // #2070 + (point.clientX + (nextPoint ? (nextPoint.wrappedClientX || nextPoint.clientX) : axisLength)) / 2 + )), axisLength) : + axisLength; + + while (low >= 0 && low <= high) { + tooltipPoints[low++] = point; + } + } + } + series.tooltipPoints = tooltipPoints; + }, + + /** + * Show the graph + */ + show: function () { + this.setVisible(true); + }, + + /** + * Hide the graph + */ + hide: function () { + this.setVisible(false); + }, + + + /** + * Set the selected state of the graph + * + * @param selected {Boolean} True to select the series, false to unselect. If + * UNDEFINED, the selection state is toggled. + */ + select: function (selected) { + var series = this; + // if called without an argument, toggle + series.selected = selected = (selected === UNDEFINED) ? !series.selected : selected; + + if (series.checkbox) { + series.checkbox.checked = selected; + } + + fireEvent(series, selected ? 'select' : 'unselect'); + }, + + drawTracker: TrackerMixin.drawTrackerGraph +}); +// global variables +extend(Highcharts, { + + // Constructors + Axis: Axis, + Chart: Chart, + Color: Color, + Point: Point, + Tick: Tick, + Renderer: Renderer, + Series: Series, + SVGElement: SVGElement, + SVGRenderer: SVGRenderer, + + // Various + arrayMin: arrayMin, + arrayMax: arrayMax, + charts: charts, + dateFormat: dateFormat, + format: format, + pathAnim: pathAnim, + getOptions: getOptions, + hasBidiBug: hasBidiBug, + isTouchDevice: isTouchDevice, + numberFormat: numberFormat, + seriesTypes: seriesTypes, + setOptions: setOptions, + addEvent: addEvent, + removeEvent: removeEvent, + createElement: createElement, + discardElement: discardElement, + css: css, + each: each, + extend: extend, + map: map, + merge: merge, + pick: pick, + splat: splat, + extendClass: extendClass, + pInt: pInt, + wrap: wrap, + svg: hasSVG, + canvas: useCanVG, + vml: !hasSVG && !useCanVG, + product: PRODUCT, + version: VERSION +}); + +}()); diff --git a/html/includes/js/jquery-1.11.1.min.js b/html/includes/js/jquery-1.11.1.min.js new file mode 100644 index 0000000..ab28a24 --- /dev/null +++ b/html/includes/js/jquery-1.11.1.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; +if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==cb()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===cb()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?ab:bb):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:bb,isPropagationStopped:bb,isImmediatePropagationStopped:bb,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=ab,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=ab,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=ab,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=bb;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=bb),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function db(a){var b=eb.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var eb="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fb=/ jQuery\d+="(?:null|\d+)"/g,gb=new RegExp("<(?:"+eb+")[\\s/>]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/<tbody/i,lb=/<|&#?\w+;/,mb=/<(?:script|style|link)/i,nb=/checked\s*(?:[^=]|=\s*.checked.)/i,ob=/^$|\/(?:java|ecma)script/i,pb=/^true\/(.*)/,qb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,rb={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?"<table>"!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Cb[0].contentWindow||Cb[0].contentDocument).document,b.write(),b.close(),c=Eb(a,b),Cb.detach()),Db[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Gb=/^margin/,Hb=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ib,Jb,Kb=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ib=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Hb.test(g)&&Gb.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ib=function(a){return a.currentStyle},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Hb.test(g)&&!Kb.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function Lb(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Mb=/alpha\([^)]*\)/i,Nb=/opacity\s*=\s*([^)]*)/,Ob=/^(none|table(?!-c[ea]).+)/,Pb=new RegExp("^("+S+")(.*)$","i"),Qb=new RegExp("^([+-])=("+S+")","i"),Rb={position:"absolute",visibility:"hidden",display:"block"},Sb={letterSpacing:"0",fontWeight:"400"},Tb=["Webkit","O","Moz","ms"];function Ub(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Tb.length;while(e--)if(b=Tb[e]+c,b in a)return b;return d}function Vb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fb(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wb(a,b,c){var d=Pb.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Yb(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ib(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Jb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Hb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xb(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Jb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ub(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ub(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Jb(a,b,d)),"normal"===f&&b in Sb&&(f=Sb[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Ob.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Rb,function(){return Yb(a,b,d)}):Yb(a,b,d):void 0},set:function(a,c,d){var e=d&&Ib(a);return Wb(a,c,d?Xb(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Mb.test(f)?f.replace(Mb,e):f+" "+e)}}),m.cssHooks.marginRight=Lb(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Jb,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Gb.test(a)||(m.cssHooks[a+b].set=Wb)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ib(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Vb(this,!0)},hide:function(){return Vb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Zb(a,b,c,d,e){return new Zb.prototype.init(a,b,c,d,e)}m.Tween=Zb,Zb.prototype={constructor:Zb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px") +},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kc(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cc.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gc(b,!0),a,d,e)}}),m.each({slideDown:gc("show"),slideUp:gc("hide"),slideToggle:gc("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($b=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$b=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_b||(_b=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_b),_b=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lc=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mc,nc,oc=m.expr.attrHandle,pc=/^(?:checked|selected)$/i,qc=k.getSetAttribute,rc=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nc:mc)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rc&&qc||!pc.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qc?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nc={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rc&&qc||!pc.test(c)?a.setAttribute(!qc&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=oc[b]||m.find.attr;oc[b]=rc&&qc||!pc.test(b)?function(a,b,d){var e,f;return d||(f=oc[b],oc[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,oc[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rc&&qc||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mc&&mc.set(a,b,c)}}),qc||(mc={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},oc.id=oc.name=oc.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mc.set},m.attrHooks.contenteditable={set:function(a,b,c){mc.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sc=/^(?:input|select|textarea|button|object)$/i,tc=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sc.test(a.nodeName)||tc.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var uc=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(uc," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vc=m.now(),wc=/\?/,xc=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xc,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yc,zc,Ac=/#.*$/,Bc=/([?&])_=[^&]*/,Cc=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Dc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ec=/^(?:GET|HEAD)$/,Fc=/^\/\//,Gc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hc={},Ic={},Jc="*/".concat("*");try{zc=location.href}catch(Kc){zc=y.createElement("a"),zc.href="",zc=zc.href}yc=Gc.exec(zc.toLowerCase())||[];function Lc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mc(a,b,c,d){var e={},f=a===Ic;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nc(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Oc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zc,type:"GET",isLocal:Dc.test(yc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nc(Nc(a,m.ajaxSettings),b):Nc(m.ajaxSettings,a)},ajaxPrefilter:Lc(Hc),ajaxTransport:Lc(Ic),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cc.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zc)+"").replace(Ac,"").replace(Fc,yc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gc.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yc[1]&&c[2]===yc[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yc[3]||("http:"===yc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mc(Hc,k,b,v),2===t)return v;h=k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Ec.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wc.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bc.test(e)?e.replace(Bc,"$1_="+vc++):e+(wc.test(e)?"&":"?")+"_="+vc++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jc+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mc(Ic,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Oc(k,v,c)),u=Pc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qc=/%20/g,Rc=/\[\]$/,Sc=/\r?\n/g,Tc=/^(?:submit|button|image|reset|file)$/i,Uc=/^(?:input|select|textarea|keygen)/i;function Vc(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rc.test(a)?d(a,e):Vc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vc(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vc(c,a[c],b,e);return d.join("&").replace(Qc,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Uc.test(this.nodeName)&&!Tc.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sc,"\r\n")}}):{name:b.name,value:c.replace(Sc,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zc()||$c()}:Zc;var Wc=0,Xc={},Yc=m.ajaxSettings.xhr();a.ActiveXObject&&m(a).on("unload",function(){for(var a in Xc)Xc[a](void 0,!0)}),k.cors=!!Yc&&"withCredentials"in Yc,Yc=k.ajax=!!Yc,Yc&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xc[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xc[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zc(){try{return new a.XMLHttpRequest}catch(b){}}function $c(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _c=[],ad=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_c.pop()||m.expando+"_"+vc++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ad.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ad.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ad,"$1"+e):b.jsonp!==!1&&(b.url+=(wc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_c.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bd=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bd)return bd.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m}); diff --git a/html/includes/js/jquery.tooltip.js b/html/includes/js/jquery.tooltip.js new file mode 100644 index 0000000..b8976e2 --- /dev/null +++ b/html/includes/js/jquery.tooltip.js @@ -0,0 +1,119 @@ +/*! + * jquery.tooltip.js 0.0.1 - https://github.com/yckart/jquery.tooltip.js + * The tooltip to use, ready for mobile! + * + * Copyright (c) 2013 Yannick Albert (http://yckart.com) + * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php). + * 2013/02/09 +*/ +(function ($, window, document) { + 'use strict'; + + var pluginName = 'tooltip', + defaults = { + fade: false, + fallback: '', + align: 'autoTop', + html: false, + attr: 'title', + trigger: { + show: 'ontouchend' in document ? 'touchstart' : 'mouseenter', + hide: 'ontouchend' in document ? 'touchend' : 'mouseleave' + }, + delay: { + show: 0, + hide: 0 + } + }; + + function Plugin(el, options) { + + options = $.extend({}, defaults, options); + + var elem = $(el), + timeout; + + elem.on('tooltip:show ' + options.trigger.show, function(){ + $.data(this, 'cancel.tooltip', true); + + var tip = $.data(this, 'active.tooltip'); + if (!tip) { + tip = $('<div class="tooltip"><div class="tooltip-inner"/></div>').css({position:'absolute', zIndex:100000}); + $.data(this, 'active.tooltip', tip); + } + + if (elem.attr('title') || typeof (elem.attr('original-title')) !== 'string') { + elem.attr('original-title', elem.attr('title') || '').removeAttr('title'); + } + + var title; + if (typeof options.attr === 'string') { + title = elem.attr(options.attr === 'title' ? 'original-title' : options.attr); + } else if (typeof options.attr == 'function') { + title = options.attr.call(this); + } + + tip.find('.tooltip-inner')[options.html ? 'html' : 'text'](title || options.fallback); + + var pos = $.extend({}, elem.offset(), {width: this.offsetWidth, height: this.offsetHeight}); + + tip[0].className = 'tooltip'; + tip.remove().css({ + top: 0, + left: 0, + opacity: 0 + }).appendTo(document.body); + + var actualWidth = tip[0].offsetWidth, + actualHeight = tip[0].offsetHeight, + dir = options.align === 'autoTop' ? + pos.top > ($(document).scrollTop() + $(window).height() / 2) ? 't' : 'b' : + pos.left > ($(document).scrollLeft() + $(window).width() / 2) ? 'l' : 'r'; + + switch (options.align.charAt(0) === 'a' ? dir : options.align.charAt(0)) { + case 'b': + tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tooltip-bottom'); + break; + case 't': + tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tooltip-top'); + break; + case 'l': + tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tooltip-left'); + break; + case 'r': + tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tooltip-right'); + break; + } + + clearTimeout(timeout); + tip.stop().delay(options.delay.show).fadeTo(options.fade ? options.fade.duration : 0, options.fade.opacity || 0.8, options.fade.complete); + }); + + elem.on('tooltip:hide ' + options.trigger.hide, function(){ + $.data(this, 'cancel.tooltip', false); + var self = this; + timeout = setTimeout(function () { + if ($.data(self, 'cancel.tooltip')) return; + var tip = $.data(self, 'active.tooltip'); + if (options.fade) { + tip.stop().fadeTo(options.fade.duration, 0, function () { + tip.remove(); + if(options.fade.complete) options.fade.complete(true); + }); + } else { + tip.remove(); + } + }, options.delay.hide); + }); + + } + + $.fn[pluginName] = function (options) { + return this.each(function () { + if (!$.data(this, "plugin_" + pluginName)) { + $.data(this, "plugin_" + pluginName, new Plugin(this, options)); + } + }); + }; + +}(jQuery, window, document));
\ No newline at end of file diff --git a/html/includes/js/jquery.tooltipster.js b/html/includes/js/jquery.tooltipster.js new file mode 100644 index 0000000..60171db --- /dev/null +++ b/html/includes/js/jquery.tooltipster.js @@ -0,0 +1,1327 @@ +/* + +Tooltipster 3.3.0 | 2014-11-08 +A rockin' custom tooltip jQuery plugin + +Developed by Caleb Jacob under the MIT license http://opensource.org/licenses/MIT + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +;(function ($, window, document) { + + var pluginName = "tooltipster", + defaults = { + animation: 'fade', + arrow: true, + arrowColor: '', + autoClose: true, + content: null, + contentAsHTML: false, + contentCloning: true, + debug: true, + delay: 200, + minWidth: 0, + maxWidth: null, + functionInit: function(origin, content) {}, + functionBefore: function(origin, continueTooltip) { + continueTooltip(); + }, + functionReady: function(origin, tooltip) {}, + functionAfter: function(origin) {}, + hideOnClick: false, + icon: '(?)', + iconCloning: true, + iconDesktop: false, + iconTouch: false, + iconTheme: 'tooltipster-icon', + interactive: false, + interactiveTolerance: 350, + multiple: false, + offsetX: 0, + offsetY: 0, + onlyOne: false, + position: 'top', + positionTracker: false, + positionTrackerCallback: function(origin){ + // the default tracker callback will close the tooltip when the trigger is + // 'hover' (see https://github.com/iamceege/tooltipster/pull/253) + if(this.option('trigger') == 'hover' && this.option('autoClose')) { + this.hide(); + } + }, + restoration: 'current', + speed: 350, + timer: 0, + theme: 'tooltipster-default', + touchDevices: true, + trigger: 'hover', + updateAnimation: true + }; + + function Plugin(element, options) { + + // list of instance variables + + this.bodyOverflowX; + // stack of custom callbacks provided as parameters to API methods + this.callbacks = { + hide: [], + show: [] + }; + this.checkInterval = null; + // this will be the user content shown in the tooltip. A capital "C" is used because there is also a method called content() + this.Content; + // this is the original element which is being applied the tooltipster plugin + this.$el = $(element); + // this will be the element which triggers the appearance of the tooltip on hover/click/custom events. + // it will be the same as this.$el if icons are not used (see in the options), otherwise it will correspond to the created icon + this.$elProxy; + this.elProxyPosition; + this.enabled = true; + this.options = $.extend({}, defaults, options); + this.mouseIsOverProxy = false; + // a unique namespace per instance, for easy selective unbinding + this.namespace = 'tooltipster-'+ Math.round(Math.random()*100000); + // Status (capital S) can be either : appearing, shown, disappearing, hidden + this.Status = 'hidden'; + this.timerHide = null; + this.timerShow = null; + // this will be the tooltip element (jQuery wrapped HTML element) + this.$tooltip; + + // for backward compatibility + this.options.iconTheme = this.options.iconTheme.replace('.', ''); + this.options.theme = this.options.theme.replace('.', ''); + + // launch + + this._init(); + } + + Plugin.prototype = { + + _init: function() { + + var self = this; + + // disable the plugin on old browsers (including IE7 and lower) + if (document.querySelector) { + + // note : the content is null (empty) by default and can stay that way if the plugin remains initialized but not fed any content. The tooltip will just not appear. + + // let's save the initial value of the title attribute for later restoration if need be. + var initialTitle = null; + // it will already have been saved in case of multiple tooltips + if (self.$el.data('tooltipster-initialTitle') === undefined) { + + initialTitle = self.$el.attr('title'); + + // we do not want initialTitle to have the value "undefined" because of how jQuery's .data() method works + if (initialTitle === undefined) initialTitle = null; + + self.$el.data('tooltipster-initialTitle', initialTitle); + } + + // if content is provided in the options, its has precedence over the title attribute. + // Note : an empty string is considered content, only 'null' represents the absence of content. + // Also, an existing title="" attribute will result in an empty string content + if (self.options.content !== null){ + self._content_set(self.options.content); + } + else { + self._content_set(initialTitle); + } + + var c = self.options.functionInit.call(self.$el, self.$el, self.Content); + if(typeof c !== 'undefined') self._content_set(c); + + self.$el + // strip the title off of the element to prevent the default tooltips from popping up + .removeAttr('title') + // to be able to find all instances on the page later (upon window events in particular) + .addClass('tooltipstered'); + + // detect if we're changing the tooltip origin to an icon + // note about this condition : if the device has touch capability and self.options.iconTouch is false, you'll have no icons event though you may consider your device as a desktop if it also has a mouse. Not sure why someone would have this use case though. + if ((!deviceHasTouchCapability && self.options.iconDesktop) || (deviceHasTouchCapability && self.options.iconTouch)) { + + // TODO : the tooltip should be automatically be given an absolute position to be near the origin. Otherwise, when the origin is floating or what, it's going to be nowhere near it and disturb the position flow of the page elements. It will imply that the icon also detects when its origin moves, to follow it : not trivial. + // Until it's done, the icon feature does not really make sense since the user still has most of the work to do by himself + + // if the icon provided is in the form of a string + if(typeof self.options.icon === 'string'){ + // wrap it in a span with the icon class + self.$elProxy = $('<span class="'+ self.options.iconTheme +'"></span>'); + self.$elProxy.text(self.options.icon); + } + // if it is an object (sensible choice) + else { + // (deep) clone the object if iconCloning == true, to make sure every instance has its own proxy. We use the icon without wrapping, no need to. We do not give it a class either, as the user will undoubtedly style the object on his own and since our css properties may conflict with his own + if (self.options.iconCloning) self.$elProxy = self.options.icon.clone(true); + else self.$elProxy = self.options.icon; + } + + self.$elProxy.insertAfter(self.$el); + } + else { + self.$elProxy = self.$el; + } + + // for 'click' and 'hover' triggers : bind on events to open the tooltip. Closing is now handled in _showNow() because of its bindings. + // Notes about touch events : + // - mouseenter, mouseleave and clicks happen even on pure touch devices because they are emulated. deviceIsPureTouch() is a simple attempt to detect them. + // - on hybrid devices, we do not prevent touch gesture from opening tooltips. It would be too complex to differentiate real mouse events from emulated ones. + // - we check deviceIsPureTouch() at each event rather than prior to binding because the situation may change during browsing + if (self.options.trigger == 'hover') { + + // these binding are for mouse interaction only + self.$elProxy + .on('mouseenter.'+ self.namespace, function() { + if (!deviceIsPureTouch() || self.options.touchDevices) { + self.mouseIsOverProxy = true; + self._show(); + } + }) + .on('mouseleave.'+ self.namespace, function() { + if (!deviceIsPureTouch() || self.options.touchDevices) { + self.mouseIsOverProxy = false; + } + }); + + // for touch interaction only + if (deviceHasTouchCapability && self.options.touchDevices) { + + // for touch devices, we immediately display the tooltip because we cannot rely on mouseleave to handle the delay + self.$elProxy.on('touchstart.'+ self.namespace, function() { + self._showNow(); + }); + } + } + else if (self.options.trigger == 'click') { + + // note : for touch devices, we do not bind on touchstart, we only rely on the emulated clicks (triggered by taps) + self.$elProxy.on('click.'+ self.namespace, function() { + if (!deviceIsPureTouch() || self.options.touchDevices) { + self._show(); + } + }); + } + } + }, + + // this function will schedule the opening of the tooltip after the delay, if there is one + _show: function() { + + var self = this; + + if (self.Status != 'shown' && self.Status != 'appearing') { + + if (self.options.delay) { + self.timerShow = setTimeout(function(){ + + // for hover trigger, we check if the mouse is still over the proxy, otherwise we do not show anything + if (self.options.trigger == 'click' || (self.options.trigger == 'hover' && self.mouseIsOverProxy)) { + self._showNow(); + } + }, self.options.delay); + } + else self._showNow(); + } + }, + + // this function will open the tooltip right away + _showNow: function(callback) { + + var self = this; + + // call our constructor custom function before continuing + self.options.functionBefore.call(self.$el, self.$el, function() { + + // continue only if the tooltip is enabled and has any content + if (self.enabled && self.Content !== null) { + + // save the method callback and cancel hide method callbacks + if (callback) self.callbacks.show.push(callback); + self.callbacks.hide = []; + + //get rid of any appearance timer + clearTimeout(self.timerShow); + self.timerShow = null; + clearTimeout(self.timerHide); + self.timerHide = null; + + // if we only want one tooltip open at a time, close all auto-closing tooltips currently open and not already disappearing + if (self.options.onlyOne) { + $('.tooltipstered').not(self.$el).each(function(i,el) { + + var $el = $(el), + nss = $el.data('tooltipster-ns'); + + // iterate on all tooltips of the element + $.each(nss, function(i, ns){ + var instance = $el.data(ns), + // we have to use the public methods here + s = instance.status(), + ac = instance.option('autoClose'); + + if (s !== 'hidden' && s !== 'disappearing' && ac) { + instance.hide(); + } + }); + }); + } + + var finish = function() { + self.Status = 'shown'; + + // trigger any show method custom callbacks and reset them + $.each(self.callbacks.show, function(i,c) { c.call(self.$el); }); + self.callbacks.show = []; + }; + + // if this origin already has its tooltip open + if (self.Status !== 'hidden') { + + // the timer (if any) will start (or restart) right now + var extraTime = 0; + + // if it was disappearing, cancel that + if (self.Status === 'disappearing') { + + self.Status = 'appearing'; + + if (supportsTransitions()) { + + self.$tooltip + .clearQueue() + .removeClass('tooltipster-dying') + .addClass('tooltipster-'+ self.options.animation +'-show'); + + if (self.options.speed > 0) self.$tooltip.delay(self.options.speed); + + self.$tooltip.queue(finish); + } + else { + // in case the tooltip was currently fading out, bring it back to life + self.$tooltip + .stop() + .fadeIn(finish); + } + } + // if the tooltip is already open, we still need to trigger the method custom callback + else if(self.Status === 'shown') { + finish(); + } + } + // if the tooltip isn't already open, open that sucker up! + else { + + self.Status = 'appearing'; + + // the timer (if any) will start when the tooltip has fully appeared after its transition + var extraTime = self.options.speed; + + // disable horizontal scrollbar to keep overflowing tooltips from jacking with it and then restore it to its previous value + self.bodyOverflowX = $('body').css('overflow-x'); + $('body').css('overflow-x', 'hidden'); + + // get some other settings related to building the tooltip + var animation = 'tooltipster-' + self.options.animation, + animationSpeed = '-webkit-transition-duration: '+ self.options.speed +'ms; -webkit-animation-duration: '+ self.options.speed +'ms; -moz-transition-duration: '+ self.options.speed +'ms; -moz-animation-duration: '+ self.options.speed +'ms; -o-transition-duration: '+ self.options.speed +'ms; -o-animation-duration: '+ self.options.speed +'ms; -ms-transition-duration: '+ self.options.speed +'ms; -ms-animation-duration: '+ self.options.speed +'ms; transition-duration: '+ self.options.speed +'ms; animation-duration: '+ self.options.speed +'ms;', + minWidth = self.options.minWidth ? 'min-width:'+ Math.round(self.options.minWidth) +'px;' : '', + maxWidth = self.options.maxWidth ? 'max-width:'+ Math.round(self.options.maxWidth) +'px;' : '', + pointerEvents = self.options.interactive ? 'pointer-events: auto;' : ''; + + // build the base of our tooltip + self.$tooltip = $('<div class="tooltipster-base '+ self.options.theme +'" style="'+ minWidth +' '+ maxWidth +' '+ pointerEvents +' '+ animationSpeed +'"><div class="tooltipster-content"></div></div>'); + + // only add the animation class if the user has a browser that supports animations + if (supportsTransitions()) self.$tooltip.addClass(animation); + + // insert the content + self._content_insert(); + + // attach + self.$tooltip.appendTo('body'); + + // do all the crazy calculations and positioning + self.reposition(); + + // call our custom callback since the content of the tooltip is now part of the DOM + self.options.functionReady.call(self.$el, self.$el, self.$tooltip); + + // animate in the tooltip + if (supportsTransitions()) { + + self.$tooltip.addClass(animation + '-show'); + + if(self.options.speed > 0) self.$tooltip.delay(self.options.speed); + + self.$tooltip.queue(finish); + } + else { + self.$tooltip.css('display', 'none').fadeIn(self.options.speed, finish); + } + + // will check if our tooltip origin is removed while the tooltip is shown + self._interval_set(); + + // reposition on scroll (otherwise position:fixed element's tooltips will move away form their origin) and on resize (in case position can/has to be changed) + $(window).on('scroll.'+ self.namespace +' resize.'+ self.namespace, function() { + self.reposition(); + }); + + // auto-close bindings + if (self.options.autoClose) { + + // in case a listener is already bound for autoclosing (mouse or touch, hover or click), unbind it first + $('body').off('.'+ self.namespace); + + // here we'll have to set different sets of bindings for both touch and mouse + if (self.options.trigger == 'hover') { + + // if the user touches the body, hide + if (deviceHasTouchCapability) { + // timeout 0 : explanation below in click section + setTimeout(function() { + // we don't want to bind on click here because the initial touchstart event has not yet triggered its click event, which is thus about to happen + $('body').on('touchstart.'+ self.namespace, function() { + self.hide(); + }); + }, 0); + } + + // if we have to allow interaction + if (self.options.interactive) { + + // touch events inside the tooltip must not close it + if (deviceHasTouchCapability) { + self.$tooltip.on('touchstart.'+ self.namespace, function(event) { + event.stopPropagation(); + }); + } + + // as for mouse interaction, we get rid of the tooltip only after the mouse has spent some time out of it + var tolerance = null; + + self.$elProxy.add(self.$tooltip) + // hide after some time out of the proxy and the tooltip + .on('mouseleave.'+ self.namespace + '-autoClose', function() { + clearTimeout(tolerance); + tolerance = setTimeout(function(){ + self.hide(); + }, self.options.interactiveTolerance); + }) + // suspend timeout when the mouse is over the proxy or the tooltip + .on('mouseenter.'+ self.namespace + '-autoClose', function() { + clearTimeout(tolerance); + }); + } + // if this is a non-interactive tooltip, get rid of it if the mouse leaves + else { + self.$elProxy.on('mouseleave.'+ self.namespace + '-autoClose', function() { + self.hide(); + }); + } + + // close the tooltip when the proxy gets a click (common behavior of native tooltips) + if (self.options.hideOnClick) { + + self.$elProxy.on('click.'+ self.namespace + '-autoClose', function() { + self.hide(); + }); + } + } + // here we'll set the same bindings for both clicks and touch on the body to hide the tooltip + else if(self.options.trigger == 'click'){ + + // use a timeout to prevent immediate closing if the method was called on a click event and if options.delay == 0 (because of bubbling) + setTimeout(function() { + $('body').on('click.'+ self.namespace +' touchstart.'+ self.namespace, function() { + self.hide(); + }); + }, 0); + + // if interactive, we'll stop the events that were emitted from inside the tooltip to stop autoClosing + if (self.options.interactive) { + + // note : the touch events will just not be used if the plugin is not enabled on touch devices + self.$tooltip.on('click.'+ self.namespace +' touchstart.'+ self.namespace, function(event) { + event.stopPropagation(); + }); + } + } + } + } + + // if we have a timer set, let the countdown begin + if (self.options.timer > 0) { + + self.timerHide = setTimeout(function() { + self.timerHide = null; + self.hide(); + }, self.options.timer + extraTime); + } + } + }); + }, + + _interval_set: function() { + + var self = this; + + self.checkInterval = setInterval(function() { + + // if the tooltip and/or its interval should be stopped + if ( + // if the origin has been removed + $('body').find(self.$el).length === 0 + // if the elProxy has been removed + || $('body').find(self.$elProxy).length === 0 + // if the tooltip has been closed + || self.Status == 'hidden' + // if the tooltip has somehow been removed + || $('body').find(self.$tooltip).length === 0 + ) { + // remove the tooltip if it's still here + if (self.Status == 'shown' || self.Status == 'appearing') self.hide(); + + // clear this interval as it is no longer necessary + self._interval_cancel(); + } + // if everything is alright + else { + // compare the former and current positions of the elProxy to reposition the tooltip if need be + if(self.options.positionTracker){ + + var p = self._repositionInfo(self.$elProxy), + identical = false; + + // compare size first (a change requires repositioning too) + if(areEqual(p.dimension, self.elProxyPosition.dimension)){ + + // for elements with a fixed position, we track the top and left properties (relative to window) + if(self.$elProxy.css('position') === 'fixed'){ + if(areEqual(p.position, self.elProxyPosition.position)) identical = true; + } + // otherwise, track total offset (relative to document) + else { + if(areEqual(p.offset, self.elProxyPosition.offset)) identical = true; + } + } + + if(!identical){ + self.reposition(); + self.options.positionTrackerCallback.call(self, self.$el); + } + } + } + }, 200); + }, + + _interval_cancel: function() { + clearInterval(this.checkInterval); + // clean delete + this.checkInterval = null; + }, + + _content_set: function(content) { + // clone if asked. Cloning the object makes sure that each instance has its own version of the content (in case a same object were provided for several instances) + // reminder : typeof null === object + if (typeof content === 'object' && content !== null && this.options.contentCloning) { + content = content.clone(true); + } + this.Content = content; + }, + + _content_insert: function() { + + var self = this, + $d = this.$tooltip.find('.tooltipster-content'); + + if (typeof self.Content === 'string' && !self.options.contentAsHTML) { + $d.text(self.Content); + } + else { + $d + .empty() + .append(self.Content); + } + }, + + _update: function(content) { + + var self = this; + + // change the content + self._content_set(content); + + if (self.Content !== null) { + + // update the tooltip if it is open + if (self.Status !== 'hidden') { + + // reset the content in the tooltip + self._content_insert(); + + // reposition and resize the tooltip + self.reposition(); + + // if we want to play a little animation showing the content changed + if (self.options.updateAnimation) { + + if (supportsTransitions()) { + + self.$tooltip.css({ + 'width': '', + '-webkit-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', + '-moz-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', + '-o-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', + '-ms-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', + 'transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms' + }).addClass('tooltipster-content-changing'); + + // reset the CSS transitions and finish the change animation + setTimeout(function() { + + if(self.Status != 'hidden'){ + + self.$tooltip.removeClass('tooltipster-content-changing'); + + // after the changing animation has completed, reset the CSS transitions + setTimeout(function() { + + if(self.Status !== 'hidden'){ + self.$tooltip.css({ + '-webkit-transition': self.options.speed + 'ms', + '-moz-transition': self.options.speed + 'ms', + '-o-transition': self.options.speed + 'ms', + '-ms-transition': self.options.speed + 'ms', + 'transition': self.options.speed + 'ms' + }); + } + }, self.options.speed); + } + }, self.options.speed); + } + else { + self.$tooltip.fadeTo(self.options.speed, 0.5, function() { + if(self.Status != 'hidden'){ + self.$tooltip.fadeTo(self.options.speed, 1); + } + }); + } + } + } + } + else { + self.hide(); + } + }, + + _repositionInfo: function($el) { + return { + dimension: { + height: $el.outerHeight(false), + width: $el.outerWidth(false) + }, + offset: $el.offset(), + position: { + left: parseInt($el.css('left')), + top: parseInt($el.css('top')) + } + }; + }, + + hide: function(callback) { + + var self = this; + + // save the method custom callback and cancel any show method custom callbacks + if (callback) self.callbacks.hide.push(callback); + self.callbacks.show = []; + + // get rid of any appearance timeout + clearTimeout(self.timerShow); + self.timerShow = null; + clearTimeout(self.timerHide); + self.timerHide = null; + + var finishCallbacks = function() { + // trigger any hide method custom callbacks and reset them + $.each(self.callbacks.hide, function(i,c) { c.call(self.$el); }); + self.callbacks.hide = []; + }; + + // hide + if (self.Status == 'shown' || self.Status == 'appearing') { + + self.Status = 'disappearing'; + + var finish = function() { + + self.Status = 'hidden'; + + // detach our content object first, so the next jQuery's remove() call does not unbind its event handlers + if (typeof self.Content == 'object' && self.Content !== null) { + self.Content.detach(); + } + + self.$tooltip.remove(); + self.$tooltip = null; + + // unbind orientationchange, scroll and resize listeners + $(window).off('.'+ self.namespace); + + $('body') + // unbind any auto-closing click/touch listeners + .off('.'+ self.namespace) + .css('overflow-x', self.bodyOverflowX); + + // unbind any auto-closing click/touch listeners + $('body').off('.'+ self.namespace); + + // unbind any auto-closing hover listeners + self.$elProxy.off('.'+ self.namespace + '-autoClose'); + + // call our constructor custom callback function + self.options.functionAfter.call(self.$el, self.$el); + + // call our method custom callbacks functions + finishCallbacks(); + }; + + if (supportsTransitions()) { + + self.$tooltip + .clearQueue() + .removeClass('tooltipster-' + self.options.animation + '-show') + // for transitions only + .addClass('tooltipster-dying'); + + if(self.options.speed > 0) self.$tooltip.delay(self.options.speed); + + self.$tooltip.queue(finish); + } + else { + self.$tooltip + .stop() + .fadeOut(self.options.speed, finish); + } + } + // if the tooltip is already hidden, we still need to trigger the method custom callback + else if(self.Status == 'hidden') { + finishCallbacks(); + } + + return self; + }, + + // the public show() method is actually an alias for the private showNow() method + show: function(callback) { + this._showNow(callback); + return this; + }, + + // 'update' is deprecated in favor of 'content' but is kept for backward compatibility + update: function(c) { + return this.content(c); + }, + content: function(c) { + // getter method + if(typeof c === 'undefined'){ + return this.Content; + } + // setter method + else { + this._update(c); + return this; + } + }, + + reposition: function() { + + var self = this; + + // in case the tooltip has been removed from DOM manually + if ($('body').find(self.$tooltip).length !== 0) { + + // reset width + self.$tooltip.css('width', ''); + + // find variables to determine placement + self.elProxyPosition = self._repositionInfo(self.$elProxy); + var arrowReposition = null, + windowWidth = $(window).width(), + // shorthand + proxy = self.elProxyPosition, + tooltipWidth = self.$tooltip.outerWidth(false), + tooltipInnerWidth = self.$tooltip.innerWidth() + 1, // this +1 stops FireFox from sometimes forcing an additional text line + tooltipHeight = self.$tooltip.outerHeight(false); + + // if this is an <area> tag inside a <map>, all hell breaks loose. Recalculate all the measurements based on coordinates + if (self.$elProxy.is('area')) { + var areaShape = self.$elProxy.attr('shape'), + mapName = self.$elProxy.parent().attr('name'), + map = $('img[usemap="#'+ mapName +'"]'), + mapOffsetLeft = map.offset().left, + mapOffsetTop = map.offset().top, + areaMeasurements = self.$elProxy.attr('coords') !== undefined ? self.$elProxy.attr('coords').split(',') : undefined; + + if (areaShape == 'circle') { + var areaLeft = parseInt(areaMeasurements[0]), + areaTop = parseInt(areaMeasurements[1]), + areaWidth = parseInt(areaMeasurements[2]); + proxy.dimension.height = areaWidth * 2; + proxy.dimension.width = areaWidth * 2; + proxy.offset.top = mapOffsetTop + areaTop - areaWidth; + proxy.offset.left = mapOffsetLeft + areaLeft - areaWidth; + } + else if (areaShape == 'rect') { + var areaLeft = parseInt(areaMeasurements[0]), + areaTop = parseInt(areaMeasurements[1]), + areaRight = parseInt(areaMeasurements[2]), + areaBottom = parseInt(areaMeasurements[3]); + proxy.dimension.height = areaBottom - areaTop; + proxy.dimension.width = areaRight - areaLeft; + proxy.offset.top = mapOffsetTop + areaTop; + proxy.offset.left = mapOffsetLeft + areaLeft; + } + else if (areaShape == 'poly') { + var areaXs = [], + areaYs = [], + areaSmallestX = 0, + areaSmallestY = 0, + areaGreatestX = 0, + areaGreatestY = 0, + arrayAlternate = 'even'; + + for (var i = 0; i < areaMeasurements.length; i++) { + var areaNumber = parseInt(areaMeasurements[i]); + + if (arrayAlternate == 'even') { + if (areaNumber > areaGreatestX) { + areaGreatestX = areaNumber; + if (i === 0) { + areaSmallestX = areaGreatestX; + } + } + + if (areaNumber < areaSmallestX) { + areaSmallestX = areaNumber; + } + + arrayAlternate = 'odd'; + } + else { + if (areaNumber > areaGreatestY) { + areaGreatestY = areaNumber; + if (i == 1) { + areaSmallestY = areaGreatestY; + } + } + + if (areaNumber < areaSmallestY) { + areaSmallestY = areaNumber; + } + + arrayAlternate = 'even'; + } + } + + proxy.dimension.height = areaGreatestY - areaSmallestY; + proxy.dimension.width = areaGreatestX - areaSmallestX; + proxy.offset.top = mapOffsetTop + areaSmallestY; + proxy.offset.left = mapOffsetLeft + areaSmallestX; + } + else { + proxy.dimension.height = map.outerHeight(false); + proxy.dimension.width = map.outerWidth(false); + proxy.offset.top = mapOffsetTop; + proxy.offset.left = mapOffsetLeft; + } + } + + // our function and global vars for positioning our tooltip + var myLeft = 0, + myLeftMirror = 0, + myTop = 0, + offsetY = parseInt(self.options.offsetY), + offsetX = parseInt(self.options.offsetX), + // this is the arrow position that will eventually be used. It may differ from the position option if the tooltip cannot be displayed in this position + practicalPosition = self.options.position; + + // a function to detect if the tooltip is going off the screen horizontally. If so, reposition the crap out of it! + function dontGoOffScreenX() { + + var windowLeft = $(window).scrollLeft(); + + // if the tooltip goes off the left side of the screen, line it up with the left side of the window + if((myLeft - windowLeft) < 0) { + arrowReposition = myLeft - windowLeft; + myLeft = windowLeft; + } + + // if the tooltip goes off the right of the screen, line it up with the right side of the window + if (((myLeft + tooltipWidth) - windowLeft) > windowWidth) { + arrowReposition = myLeft - ((windowWidth + windowLeft) - tooltipWidth); + myLeft = (windowWidth + windowLeft) - tooltipWidth; + } + } + + // a function to detect if the tooltip is going off the screen vertically. If so, switch to the opposite! + function dontGoOffScreenY(switchTo, switchFrom) { + // if it goes off the top off the page + if(((proxy.offset.top - $(window).scrollTop() - tooltipHeight - offsetY - 12) < 0) && (switchFrom.indexOf('top') > -1)) { + practicalPosition = switchTo; + } + + // if it goes off the bottom of the page + if (((proxy.offset.top + proxy.dimension.height + tooltipHeight + 12 + offsetY) > ($(window).scrollTop() + $(window).height())) && (switchFrom.indexOf('bottom') > -1)) { + practicalPosition = switchTo; + myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; + } + } + + if(practicalPosition == 'top') { + var leftDifference = (proxy.offset.left + tooltipWidth) - (proxy.offset.left + proxy.dimension.width); + myLeft = (proxy.offset.left + offsetX) - (leftDifference / 2); + myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; + dontGoOffScreenX(); + dontGoOffScreenY('bottom', 'top'); + } + + if(practicalPosition == 'top-left') { + myLeft = proxy.offset.left + offsetX; + myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; + dontGoOffScreenX(); + dontGoOffScreenY('bottom-left', 'top-left'); + } + + if(practicalPosition == 'top-right') { + myLeft = (proxy.offset.left + proxy.dimension.width + offsetX) - tooltipWidth; + myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; + dontGoOffScreenX(); + dontGoOffScreenY('bottom-right', 'top-right'); + } + + if(practicalPosition == 'bottom') { + var leftDifference = (proxy.offset.left + tooltipWidth) - (proxy.offset.left + proxy.dimension.width); + myLeft = proxy.offset.left - (leftDifference / 2) + offsetX; + myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12; + dontGoOffScreenX(); + dontGoOffScreenY('top', 'bottom'); + } + + if(practicalPosition == 'bottom-left') { + myLeft = proxy.offset.left + offsetX; + myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12; + dontGoOffScreenX(); + dontGoOffScreenY('top-left', 'bottom-left'); + } + + if(practicalPosition == 'bottom-right') { + myLeft = (proxy.offset.left + proxy.dimension.width + offsetX) - tooltipWidth; + myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12; + dontGoOffScreenX(); + dontGoOffScreenY('top-right', 'bottom-right'); + } + + if(practicalPosition == 'left') { + myLeft = proxy.offset.left - offsetX - tooltipWidth - 12; + myLeftMirror = proxy.offset.left + offsetX + proxy.dimension.width + 12; + var topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); + myTop = proxy.offset.top - (topDifference / 2) - offsetY; + + // if the tooltip goes off boths sides of the page + if((myLeft < 0) && ((myLeftMirror + tooltipWidth) > windowWidth)) { + var borderWidth = parseFloat(self.$tooltip.css('border-width')) * 2, + newWidth = (tooltipWidth + myLeft) - borderWidth; + self.$tooltip.css('width', newWidth + 'px'); + + tooltipHeight = self.$tooltip.outerHeight(false); + myLeft = proxy.offset.left - offsetX - newWidth - 12 - borderWidth; + topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); + myTop = proxy.offset.top - (topDifference / 2) - offsetY; + } + + // if it only goes off one side, flip it to the other side + else if(myLeft < 0) { + myLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12; + arrowReposition = 'left'; + } + } + + if(practicalPosition == 'right') { + myLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12; + myLeftMirror = proxy.offset.left - offsetX - tooltipWidth - 12; + var topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); + myTop = proxy.offset.top - (topDifference / 2) - offsetY; + + // if the tooltip goes off boths sides of the page + if(((myLeft + tooltipWidth) > windowWidth) && (myLeftMirror < 0)) { + var borderWidth = parseFloat(self.$tooltip.css('border-width')) * 2, + newWidth = (windowWidth - myLeft) - borderWidth; + self.$tooltip.css('width', newWidth + 'px'); + + tooltipHeight = self.$tooltip.outerHeight(false); + topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); + myTop = proxy.offset.top - (topDifference / 2) - offsetY; + } + + // if it only goes off one side, flip it to the other side + else if((myLeft + tooltipWidth) > windowWidth) { + myLeft = proxy.offset.left - offsetX - tooltipWidth - 12; + arrowReposition = 'right'; + } + } + + // if arrow is set true, style it and append it + if (self.options.arrow) { + + var arrowClass = 'tooltipster-arrow-' + practicalPosition; + + // set color of the arrow + if(self.options.arrowColor.length < 1) { + var arrowColor = self.$tooltip.css('background-color'); + } + else { + var arrowColor = self.options.arrowColor; + } + + // if the tooltip was going off the page and had to re-adjust, we need to update the arrow's position + if (!arrowReposition) { + arrowReposition = ''; + } + else if (arrowReposition == 'left') { + arrowClass = 'tooltipster-arrow-right'; + arrowReposition = ''; + } + else if (arrowReposition == 'right') { + arrowClass = 'tooltipster-arrow-left'; + arrowReposition = ''; + } + else { + arrowReposition = 'left:'+ Math.round(arrowReposition) +'px;'; + } + + // building the logic to create the border around the arrow of the tooltip + if ((practicalPosition == 'top') || (practicalPosition == 'top-left') || (practicalPosition == 'top-right')) { + var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-bottom-width')), + tooltipBorderColor = self.$tooltip.css('border-bottom-color'); + } + else if ((practicalPosition == 'bottom') || (practicalPosition == 'bottom-left') || (practicalPosition == 'bottom-right')) { + var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-top-width')), + tooltipBorderColor = self.$tooltip.css('border-top-color'); + } + else if (practicalPosition == 'left') { + var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-right-width')), + tooltipBorderColor = self.$tooltip.css('border-right-color'); + } + else if (practicalPosition == 'right') { + var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-left-width')), + tooltipBorderColor = self.$tooltip.css('border-left-color'); + } + else { + var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-bottom-width')), + tooltipBorderColor = self.$tooltip.css('border-bottom-color'); + } + + if (tooltipBorderWidth > 1) { + tooltipBorderWidth++; + } + + var arrowBorder = ''; + if (tooltipBorderWidth !== 0) { + var arrowBorderSize = '', + arrowBorderColor = 'border-color: '+ tooltipBorderColor +';'; + if (arrowClass.indexOf('bottom') !== -1) { + arrowBorderSize = 'margin-top: -'+ Math.round(tooltipBorderWidth) +'px;'; + } + else if (arrowClass.indexOf('top') !== -1) { + arrowBorderSize = 'margin-bottom: -'+ Math.round(tooltipBorderWidth) +'px;'; + } + else if (arrowClass.indexOf('left') !== -1) { + arrowBorderSize = 'margin-right: -'+ Math.round(tooltipBorderWidth) +'px;'; + } + else if (arrowClass.indexOf('right') !== -1) { + arrowBorderSize = 'margin-left: -'+ Math.round(tooltipBorderWidth) +'px;'; + } + arrowBorder = '<span class="tooltipster-arrow-border" style="'+ arrowBorderSize +' '+ arrowBorderColor +';"></span>'; + } + + // if the arrow already exists, remove and replace it + self.$tooltip.find('.tooltipster-arrow').remove(); + + // build out the arrow and append it + var arrowConstruct = '<div class="'+ arrowClass +' tooltipster-arrow" style="'+ arrowReposition +'">'+ arrowBorder +'<span style="border-color:'+ arrowColor +';"></span></div>'; + self.$tooltip.append(arrowConstruct); + } + + // position the tooltip + self.$tooltip.css({'top': Math.round(myTop) + 'px', 'left': Math.round(myLeft) + 'px'}); + } + + return self; + }, + + enable: function() { + this.enabled = true; + return this; + }, + + disable: function() { + // hide first, in case the tooltip would not disappear on its own (autoClose false) + this.hide(); + this.enabled = false; + return this; + }, + + destroy: function() { + + var self = this; + + self.hide(); + + // remove the icon, if any + if (self.$el[0] !== self.$elProxy[0]) { + self.$elProxy.remove(); + } + + self.$el + .removeData(self.namespace) + .off('.'+ self.namespace); + + var ns = self.$el.data('tooltipster-ns'); + + // if there are no more tooltips on this element + if(ns.length === 1){ + + // optional restoration of a title attribute + var title = null; + if (self.options.restoration === 'previous'){ + title = self.$el.data('tooltipster-initialTitle'); + } + else if(self.options.restoration === 'current'){ + + // old school technique to stringify when outerHTML is not supported + title = + (typeof self.Content === 'string') ? + self.Content : + $('<div></div>').append(self.Content).html(); + } + + if (title) { + self.$el.attr('title', title); + } + + // final cleaning + self.$el + .removeClass('tooltipstered') + .removeData('tooltipster-ns') + .removeData('tooltipster-initialTitle'); + } + else { + // remove the instance namespace from the list of namespaces of tooltips present on the element + ns = $.grep(ns, function(el, i){ + return el !== self.namespace; + }); + self.$el.data('tooltipster-ns', ns); + } + + return self; + }, + + elementIcon: function() { + return (this.$el[0] !== this.$elProxy[0]) ? this.$elProxy[0] : undefined; + }, + + elementTooltip: function() { + return this.$tooltip ? this.$tooltip[0] : undefined; + }, + + // public methods but for internal use only + // getter if val is ommitted, setter otherwise + option: function(o, val) { + if (typeof val == 'undefined') return this.options[o]; + else { + this.options[o] = val; + return this; + } + }, + status: function() { + return this.Status; + } + }; + + $.fn[pluginName] = function () { + + // for using in closures + var args = arguments; + + // if we are not in the context of jQuery wrapped HTML element(s) : + // this happens when calling static methods in the form $.fn.tooltipster('methodName'), or when calling $(sel).tooltipster('methodName or options') where $(sel) does not match anything + if (this.length === 0) { + + // if the first argument is a method name + if (typeof args[0] === 'string') { + + var methodIsStatic = true; + + // list static methods here (usable by calling $.fn.tooltipster('methodName');) + switch (args[0]) { + + case 'setDefaults': + // change default options for all future instances + $.extend(defaults, args[1]); + break; + + default: + methodIsStatic = false; + break; + } + + // $.fn.tooltipster('methodName') calls will return true + if (methodIsStatic) return true; + // $(sel).tooltipster('methodName') calls will return the list of objects event though it's empty because chaining should work on empty lists + else return this; + } + // the first argument is undefined or an object of options : we are initalizing but there is no element matched by selector + else { + // still chainable : same as above + return this; + } + } + // this happens when calling $(sel).tooltipster('methodName or options') where $(sel) matches one or more elements + else { + + // method calls + if (typeof args[0] === 'string') { + + var v = '#*$~&'; + + this.each(function() { + + // retrieve the namepaces of the tooltip(s) that exist on that element. We will interact with the first tooltip only. + var ns = $(this).data('tooltipster-ns'), + // self represents the instance of the first tooltipster plugin associated to the current HTML object of the loop + self = ns ? $(this).data(ns[0]) : null; + + // if the current element holds a tooltipster instance + if (self) { + + if (typeof self[args[0]] === 'function') { + // note : args[1] and args[2] may not be defined + var resp = self[args[0]](args[1], args[2]); + } + else { + throw new Error('Unknown method .tooltipster("' + args[0] + '")'); + } + + // if the function returned anything other than the instance itself (which implies chaining) + if (resp !== self){ + v = resp; + // return false to stop .each iteration on the first element matched by the selector + return false; + } + } + else { + throw new Error('You called Tooltipster\'s "' + args[0] + '" method on an uninitialized element'); + } + }); + + return (v !== '#*$~&') ? v : this; + } + // first argument is undefined or an object : the tooltip is initializing + else { + + var instances = [], + // is there a defined value for the multiple option in the options object ? + multipleIsSet = args[0] && typeof args[0].multiple !== 'undefined', + // if the multiple option is set to true, or if it's not defined but set to true in the defaults + multiple = (multipleIsSet && args[0].multiple) || (!multipleIsSet && defaults.multiple), + // same for debug + debugIsSet = args[0] && typeof args[0].debug !== 'undefined', + debug = (debugIsSet && args[0].debug) || (!debugIsSet && defaults.debug); + + // initialize a tooltipster instance for each element if it doesn't already have one or if the multiple option is set, and attach the object to it + this.each(function () { + + var go = false, + ns = $(this).data('tooltipster-ns'), + instance = null; + + if (!ns) { + go = true; + } + else if (multiple) { + go = true; + } + else if (debug) { + console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.'); + } + + if (go) { + instance = new Plugin(this, args[0]); + + // save the reference of the new instance + if (!ns) ns = []; + ns.push(instance.namespace); + $(this).data('tooltipster-ns', ns) + + // save the instance itself + $(this).data(instance.namespace, instance); + } + + instances.push(instance); + }); + + if (multiple) return instances; + else return this; + } + } + }; + + // quick & dirty compare function (not bijective nor multidimensional) + function areEqual(a,b) { + var same = true; + $.each(a, function(i, el){ + if(typeof b[i] === 'undefined' || a[i] !== b[i]){ + same = false; + return false; + } + }); + return same; + } + + // detect if this device can trigger touch events + var deviceHasTouchCapability = !!('ontouchstart' in window); + + // we'll assume the device has no mouse until we detect any mouse movement + var deviceHasMouse = false; + $('body').one('mousemove', function() { + deviceHasMouse = true; + }); + + function deviceIsPureTouch() { + return (!deviceHasMouse && deviceHasTouchCapability); + } + + // detecting support for CSS transitions + function supportsTransitions() { + var b = document.body || document.documentElement, + s = b.style, + p = 'transition'; + + if(typeof s[p] == 'string') {return true; } + + v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'], + p = p.charAt(0).toUpperCase() + p.substr(1); + for(var i=0; i<v.length; i++) { + if(typeof s[v[i] + p] == 'string') { return true; } + } + return false; + } +})( jQuery, window, document ); diff --git a/html/includes/js/jquery.tooltipster.min.js b/html/includes/js/jquery.tooltipster.min.js new file mode 100644 index 0000000..ff8dab1 --- /dev/null +++ b/html/includes/js/jquery.tooltipster.min.js @@ -0,0 +1 @@ +/* Tooltipster v3.3.0 */;(function(e,t,n){function s(t,n){this.bodyOverflowX;this.callbacks={hide:[],show:[]};this.checkInterval=null;this.Content;this.$el=e(t);this.$elProxy;this.elProxyPosition;this.enabled=true;this.options=e.extend({},i,n);this.mouseIsOverProxy=false;this.namespace="tooltipster-"+Math.round(Math.random()*1e5);this.Status="hidden";this.timerHide=null;this.timerShow=null;this.$tooltip;this.options.iconTheme=this.options.iconTheme.replace(".","");this.options.theme=this.options.theme.replace(".","");this._init()}function o(t,n){var r=true;e.each(t,function(e,i){if(typeof n[e]==="undefined"||t[e]!==n[e]){r=false;return false}});return r}function f(){return!a&&u}function l(){var e=n.body||n.documentElement,t=e.style,r="transition";if(typeof t[r]=="string"){return true}v=["Moz","Webkit","Khtml","O","ms"],r=r.charAt(0).toUpperCase()+r.substr(1);for(var i=0;i<v.length;i++){if(typeof t[v[i]+r]=="string"){return true}}return false}var r="tooltipster",i={animation:"fade",arrow:true,arrowColor:"",autoClose:true,content:null,contentAsHTML:false,contentCloning:true,debug:true,delay:200,minWidth:0,maxWidth:null,functionInit:function(e,t){},functionBefore:function(e,t){t()},functionReady:function(e,t){},functionAfter:function(e){},hideOnClick:false,icon:"(?)",iconCloning:true,iconDesktop:false,iconTouch:false,iconTheme:"tooltipster-icon",interactive:false,interactiveTolerance:350,multiple:false,offsetX:0,offsetY:0,onlyOne:false,position:"top",positionTracker:false,positionTrackerCallback:function(e){if(this.option("trigger")=="hover"&&this.option("autoClose")){this.hide()}},restoration:"current",speed:350,timer:0,theme:"tooltipster-default",touchDevices:true,trigger:"hover",updateAnimation:true};s.prototype={_init:function(){var t=this;if(n.querySelector){var r=null;if(t.$el.data("tooltipster-initialTitle")===undefined){r=t.$el.attr("title");if(r===undefined)r=null;t.$el.data("tooltipster-initialTitle",r)}if(t.options.content!==null){t._content_set(t.options.content)}else{t._content_set(r)}var i=t.options.functionInit.call(t.$el,t.$el,t.Content);if(typeof i!=="undefined")t._content_set(i);t.$el.removeAttr("title").addClass("tooltipstered");if(!u&&t.options.iconDesktop||u&&t.options.iconTouch){if(typeof t.options.icon==="string"){t.$elProxy=e('<span class="'+t.options.iconTheme+'"></span>');t.$elProxy.text(t.options.icon)}else{if(t.options.iconCloning)t.$elProxy=t.options.icon.clone(true);else t.$elProxy=t.options.icon}t.$elProxy.insertAfter(t.$el)}else{t.$elProxy=t.$el}if(t.options.trigger=="hover"){t.$elProxy.on("mouseenter."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=true;t._show()}}).on("mouseleave."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=false}});if(u&&t.options.touchDevices){t.$elProxy.on("touchstart."+t.namespace,function(){t._showNow()})}}else if(t.options.trigger=="click"){t.$elProxy.on("click."+t.namespace,function(){if(!f()||t.options.touchDevices){t._show()}})}}},_show:function(){var e=this;if(e.Status!="shown"&&e.Status!="appearing"){if(e.options.delay){e.timerShow=setTimeout(function(){if(e.options.trigger=="click"||e.options.trigger=="hover"&&e.mouseIsOverProxy){e._showNow()}},e.options.delay)}else e._showNow()}},_showNow:function(n){var r=this;r.options.functionBefore.call(r.$el,r.$el,function(){if(r.enabled&&r.Content!==null){if(n)r.callbacks.show.push(n);r.callbacks.hide=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;if(r.options.onlyOne){e(".tooltipstered").not(r.$el).each(function(t,n){var r=e(n),i=r.data("tooltipster-ns");e.each(i,function(e,t){var n=r.data(t),i=n.status(),s=n.option("autoClose");if(i!=="hidden"&&i!=="disappearing"&&s){n.hide()}})})}var i=function(){r.Status="shown";e.each(r.callbacks.show,function(e,t){t.call(r.$el)});r.callbacks.show=[]};if(r.Status!=="hidden"){var s=0;if(r.Status==="disappearing"){r.Status="appearing";if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-dying").addClass("tooltipster-"+r.options.animation+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.stop().fadeIn(i)}}else if(r.Status==="shown"){i()}}else{r.Status="appearing";var s=r.options.speed;r.bodyOverflowX=e("body").css("overflow-x");e("body").css("overflow-x","hidden");var o="tooltipster-"+r.options.animation,a="-webkit-transition-duration: "+r.options.speed+"ms; -webkit-animation-duration: "+r.options.speed+"ms; -moz-transition-duration: "+r.options.speed+"ms; -moz-animation-duration: "+r.options.speed+"ms; -o-transition-duration: "+r.options.speed+"ms; -o-animation-duration: "+r.options.speed+"ms; -ms-transition-duration: "+r.options.speed+"ms; -ms-animation-duration: "+r.options.speed+"ms; transition-duration: "+r.options.speed+"ms; animation-duration: "+r.options.speed+"ms;",f=r.options.minWidth?"min-width:"+Math.round(r.options.minWidth)+"px;":"",c=r.options.maxWidth?"max-width:"+Math.round(r.options.maxWidth)+"px;":"",h=r.options.interactive?"pointer-events: auto;":"";r.$tooltip=e('<div class="tooltipster-base '+r.options.theme+'" style="'+f+" "+c+" "+h+" "+a+'"><div class="tooltipster-content"></div></div>');if(l())r.$tooltip.addClass(o);r._content_insert();r.$tooltip.appendTo("body");r.reposition();r.options.functionReady.call(r.$el,r.$el,r.$tooltip);if(l()){r.$tooltip.addClass(o+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.css("display","none").fadeIn(r.options.speed,i)}r._interval_set();e(t).on("scroll."+r.namespace+" resize."+r.namespace,function(){r.reposition()});if(r.options.autoClose){e("body").off("."+r.namespace);if(r.options.trigger=="hover"){if(u){setTimeout(function(){e("body").on("touchstart."+r.namespace,function(){r.hide()})},0)}if(r.options.interactive){if(u){r.$tooltip.on("touchstart."+r.namespace,function(e){e.stopPropagation()})}var p=null;r.$elProxy.add(r.$tooltip).on("mouseleave."+r.namespace+"-autoClose",function(){clearTimeout(p);p=setTimeout(function(){r.hide()},r.options.interactiveTolerance)}).on("mouseenter."+r.namespace+"-autoClose",function(){clearTimeout(p)})}else{r.$elProxy.on("mouseleave."+r.namespace+"-autoClose",function(){r.hide()})}if(r.options.hideOnClick){r.$elProxy.on("click."+r.namespace+"-autoClose",function(){r.hide()})}}else if(r.options.trigger=="click"){setTimeout(function(){e("body").on("click."+r.namespace+" touchstart."+r.namespace,function(){r.hide()})},0);if(r.options.interactive){r.$tooltip.on("click."+r.namespace+" touchstart."+r.namespace,function(e){e.stopPropagation()})}}}}if(r.options.timer>0){r.timerHide=setTimeout(function(){r.timerHide=null;r.hide()},r.options.timer+s)}}})},_interval_set:function(){var t=this;t.checkInterval=setInterval(function(){if(e("body").find(t.$el).length===0||e("body").find(t.$elProxy).length===0||t.Status=="hidden"||e("body").find(t.$tooltip).length===0){if(t.Status=="shown"||t.Status=="appearing")t.hide();t._interval_cancel()}else{if(t.options.positionTracker){var n=t._repositionInfo(t.$elProxy),r=false;if(o(n.dimension,t.elProxyPosition.dimension)){if(t.$elProxy.css("position")==="fixed"){if(o(n.position,t.elProxyPosition.position))r=true}else{if(o(n.offset,t.elProxyPosition.offset))r=true}}if(!r){t.reposition();t.options.positionTrackerCallback.call(t,t.$el)}}}},200)},_interval_cancel:function(){clearInterval(this.checkInterval);this.checkInterval=null},_content_set:function(e){if(typeof e==="object"&&e!==null&&this.options.contentCloning){e=e.clone(true)}this.Content=e},_content_insert:function(){var e=this,t=this.$tooltip.find(".tooltipster-content");if(typeof e.Content==="string"&&!e.options.contentAsHTML){t.text(e.Content)}else{t.empty().append(e.Content)}},_update:function(e){var t=this;t._content_set(e);if(t.Content!==null){if(t.Status!=="hidden"){t._content_insert();t.reposition();if(t.options.updateAnimation){if(l()){t.$tooltip.css({width:"","-webkit-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-moz-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-o-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-ms-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms",transition:"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms"}).addClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!="hidden"){t.$tooltip.removeClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!=="hidden"){t.$tooltip.css({"-webkit-transition":t.options.speed+"ms","-moz-transition":t.options.speed+"ms","-o-transition":t.options.speed+"ms","-ms-transition":t.options.speed+"ms",transition:t.options.speed+"ms"})}},t.options.speed)}},t.options.speed)}else{t.$tooltip.fadeTo(t.options.speed,.5,function(){if(t.Status!="hidden"){t.$tooltip.fadeTo(t.options.speed,1)}})}}}}else{t.hide()}},_repositionInfo:function(e){return{dimension:{height:e.outerHeight(false),width:e.outerWidth(false)},offset:e.offset(),position:{left:parseInt(e.css("left")),top:parseInt(e.css("top"))}}},hide:function(n){var r=this;if(n)r.callbacks.hide.push(n);r.callbacks.show=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;var i=function(){e.each(r.callbacks.hide,function(e,t){t.call(r.$el)});r.callbacks.hide=[]};if(r.Status=="shown"||r.Status=="appearing"){r.Status="disappearing";var s=function(){r.Status="hidden";if(typeof r.Content=="object"&&r.Content!==null){r.Content.detach()}r.$tooltip.remove();r.$tooltip=null;e(t).off("."+r.namespace);e("body").off("."+r.namespace).css("overflow-x",r.bodyOverflowX);e("body").off("."+r.namespace);r.$elProxy.off("."+r.namespace+"-autoClose");r.options.functionAfter.call(r.$el,r.$el);i()};if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-"+r.options.animation+"-show").addClass("tooltipster-dying");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(s)}else{r.$tooltip.stop().fadeOut(r.options.speed,s)}}else if(r.Status=="hidden"){i()}return r},show:function(e){this._showNow(e);return this},update:function(e){return this.content(e)},content:function(e){if(typeof e==="undefined"){return this.Content}else{this._update(e);return this}},reposition:function(){var n=this;if(e("body").find(n.$tooltip).length!==0){n.$tooltip.css("width","");n.elProxyPosition=n._repositionInfo(n.$elProxy);var r=null,i=e(t).width(),s=n.elProxyPosition,o=n.$tooltip.outerWidth(false),u=n.$tooltip.innerWidth()+1,a=n.$tooltip.outerHeight(false);if(n.$elProxy.is("area")){var f=n.$elProxy.attr("shape"),l=n.$elProxy.parent().attr("name"),c=e('img[usemap="#'+l+'"]'),h=c.offset().left,p=c.offset().top,d=n.$elProxy.attr("coords")!==undefined?n.$elProxy.attr("coords").split(","):undefined;if(f=="circle"){var v=parseInt(d[0]),m=parseInt(d[1]),g=parseInt(d[2]);s.dimension.height=g*2;s.dimension.width=g*2;s.offset.top=p+m-g;s.offset.left=h+v-g}else if(f=="rect"){var v=parseInt(d[0]),m=parseInt(d[1]),y=parseInt(d[2]),b=parseInt(d[3]);s.dimension.height=b-m;s.dimension.width=y-v;s.offset.top=p+m;s.offset.left=h+v}else if(f=="poly"){var w=[],E=[],S=0,x=0,T=0,N=0,C="even";for(var k=0;k<d.length;k++){var L=parseInt(d[k]);if(C=="even"){if(L>T){T=L;if(k===0){S=T}}if(L<S){S=L}C="odd"}else{if(L>N){N=L;if(k==1){x=N}}if(L<x){x=L}C="even"}}s.dimension.height=N-x;s.dimension.width=T-S;s.offset.top=p+x;s.offset.left=h+S}else{s.dimension.height=c.outerHeight(false);s.dimension.width=c.outerWidth(false);s.offset.top=p;s.offset.left=h}}var A=0,O=0,M=0,_=parseInt(n.options.offsetY),D=parseInt(n.options.offsetX),P=n.options.position;function H(){var n=e(t).scrollLeft();if(A-n<0){r=A-n;A=n}if(A+o-n>i){r=A-(i+n-o);A=i+n-o}}function B(n,r){if(s.offset.top-e(t).scrollTop()-a-_-12<0&&r.indexOf("top")>-1){P=n}if(s.offset.top+s.dimension.height+a+12+_>e(t).scrollTop()+e(t).height()&&r.indexOf("bottom")>-1){P=n;M=s.offset.top-a-_-12}}if(P=="top"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left+D-j/2;M=s.offset.top-a-_-12;H();B("bottom","top")}if(P=="top-left"){A=s.offset.left+D;M=s.offset.top-a-_-12;H();B("bottom-left","top-left")}if(P=="top-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top-a-_-12;H();B("bottom-right","top-right")}if(P=="bottom"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left-j/2+D;M=s.offset.top+s.dimension.height+_+12;H();B("top","bottom")}if(P=="bottom-left"){A=s.offset.left+D;M=s.offset.top+s.dimension.height+_+12;H();B("top-left","bottom-left")}if(P=="bottom-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top+s.dimension.height+_+12;H();B("top-right","bottom-right")}if(P=="left"){A=s.offset.left-D-o-12;O=s.offset.left+D+s.dimension.width+12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A<0&&O+o>i){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=o+A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);A=s.offset.left-D-q-12-I;F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A<0){A=s.offset.left+D+s.dimension.width+12;r="left"}}if(P=="right"){A=s.offset.left+D+s.dimension.width+12;O=s.offset.left-D-o-12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A+o>i&&O<0){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=i-A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A+o>i){A=s.offset.left-D-o-12;r="right"}}if(n.options.arrow){var R="tooltipster-arrow-"+P;if(n.options.arrowColor.length<1){var U=n.$tooltip.css("background-color")}else{var U=n.options.arrowColor}if(!r){r=""}else if(r=="left"){R="tooltipster-arrow-right";r=""}else if(r=="right"){R="tooltipster-arrow-left";r=""}else{r="left:"+Math.round(r)+"px;"}if(P=="top"||P=="top-left"||P=="top-right"){var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}else if(P=="bottom"||P=="bottom-left"||P=="bottom-right"){var z=parseFloat(n.$tooltip.css("border-top-width")),W=n.$tooltip.css("border-top-color")}else if(P=="left"){var z=parseFloat(n.$tooltip.css("border-right-width")),W=n.$tooltip.css("border-right-color")}else if(P=="right"){var z=parseFloat(n.$tooltip.css("border-left-width")),W=n.$tooltip.css("border-left-color")}else{var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}if(z>1){z++}var X="";if(z!==0){var V="",J="border-color: "+W+";";if(R.indexOf("bottom")!==-1){V="margin-top: -"+Math.round(z)+"px;"}else if(R.indexOf("top")!==-1){V="margin-bottom: -"+Math.round(z)+"px;"}else if(R.indexOf("left")!==-1){V="margin-right: -"+Math.round(z)+"px;"}else if(R.indexOf("right")!==-1){V="margin-left: -"+Math.round(z)+"px;"}X='<span class="tooltipster-arrow-border" style="'+V+" "+J+';"></span>'}n.$tooltip.find(".tooltipster-arrow").remove();var K='<div class="'+R+' tooltipster-arrow" style="'+r+'">'+X+'<span style="border-color:'+U+';"></span></div>';n.$tooltip.append(K)}n.$tooltip.css({top:Math.round(M)+"px",left:Math.round(A)+"px"})}return n},enable:function(){this.enabled=true;return this},disable:function(){this.hide();this.enabled=false;return this},destroy:function(){var t=this;t.hide();if(t.$el[0]!==t.$elProxy[0]){t.$elProxy.remove()}t.$el.removeData(t.namespace).off("."+t.namespace);var n=t.$el.data("tooltipster-ns");if(n.length===1){var r=null;if(t.options.restoration==="previous"){r=t.$el.data("tooltipster-initialTitle")}else if(t.options.restoration==="current"){r=typeof t.Content==="string"?t.Content:e("<div></div>").append(t.Content).html()}if(r){t.$el.attr("title",r)}t.$el.removeClass("tooltipstered").removeData("tooltipster-ns").removeData("tooltipster-initialTitle")}else{n=e.grep(n,function(e,n){return e!==t.namespace});t.$el.data("tooltipster-ns",n)}return t},elementIcon:function(){return this.$el[0]!==this.$elProxy[0]?this.$elProxy[0]:undefined},elementTooltip:function(){return this.$tooltip?this.$tooltip[0]:undefined},option:function(e,t){if(typeof t=="undefined")return this.options[e];else{this.options[e]=t;return this}},status:function(){return this.Status}};e.fn[r]=function(){var t=arguments;if(this.length===0){if(typeof t[0]==="string"){var n=true;switch(t[0]){case"setDefaults":e.extend(i,t[1]);break;default:n=false;break}if(n)return true;else return this}else{return this}}else{if(typeof t[0]==="string"){var r="#*$~&";this.each(function(){var n=e(this).data("tooltipster-ns"),i=n?e(this).data(n[0]):null;if(i){if(typeof i[t[0]]==="function"){var s=i[t[0]](t[1],t[2])}else{throw new Error('Unknown method .tooltipster("'+t[0]+'")')}if(s!==i){r=s;return false}}else{throw new Error("You called Tooltipster's \""+t[0]+'" method on an uninitialized element')}});return r!=="#*$~&"?r:this}else{var o=[],u=t[0]&&typeof t[0].multiple!=="undefined",a=u&&t[0].multiple||!u&&i.multiple,f=t[0]&&typeof t[0].debug!=="undefined",l=f&&t[0].debug||!f&&i.debug;this.each(function(){var n=false,r=e(this).data("tooltipster-ns"),i=null;if(!r){n=true}else if(a){n=true}else if(l){console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.')}if(n){i=new s(this,t[0]);if(!r)r=[];r.push(i.namespace);e(this).data("tooltipster-ns",r);e(this).data(i.namespace,i)}o.push(i)});if(a)return o;else return this}}};var u=!!("ontouchstart"in t);var a=false;e("body").one("mousemove",function(){a=true})})(jQuery,window,document);
\ No newline at end of file diff --git a/html/includes/js/modules/canvas-tools.js b/html/includes/js/modules/canvas-tools.js new file mode 100644 index 0000000..3b71dc2 --- /dev/null +++ b/html/includes/js/modules/canvas-tools.js @@ -0,0 +1,133 @@ +/* + A class to parse color values + @author Stoyan Stefanov <sstoo@gmail.com> + @link http://www.phpied.com/rgb-color-parser-in-javascript/ + Use it if you like it + + canvg.js - Javascript SVG parser and renderer on Canvas + MIT Licensed + Gabe Lerner (gabelerner@gmail.com) + http://code.google.com/p/canvg/ + + Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/ + + Highcharts JS v4.0.4 (2014-09-02) + CanVGRenderer Extension module + + (c) 2011-2012 Torstein Honsi, Erik Olsson + + License: www.highcharts.com/license +*/ +function RGBColor(m){this.ok=!1;m.charAt(0)=="#"&&(m=m.substr(1,6));var m=m.replace(/ /g,""),m=m.toLowerCase(),a={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b", +darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff", +gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa", +lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080", +oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd", +slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},c;for(c in a)m==c&&(m=a[c]);var d=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(b){return[parseInt(b[1]),parseInt(b[2]),parseInt(b[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/, +example:["#00ff00","336699"],process:function(b){return[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(b){return[parseInt(b[1]+b[1],16),parseInt(b[2]+b[2],16),parseInt(b[3]+b[3],16)]}}];for(c=0;c<d.length;c++){var b=d[c].process,k=d[c].re.exec(m);if(k)channels=b(k),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r;this.g=this.g<0||isNaN(this.g)?0: +this.g>255?255:this.g;this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b;this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var b=this.r.toString(16),a=this.g.toString(16),d=this.b.toString(16);b.length==1&&(b="0"+b);a.length==1&&(a="0"+a);d.length==1&&(d="0"+d);return"#"+b+a+d};this.getHelpXML=function(){for(var b=[],k=0;k<d.length;k++)for(var c=d[k].example,j=0;j<c.length;j++)b[b.length]=c[j];for(var h in a)b[b.length]=h;c=document.createElement("ul"); +c.setAttribute("id","rgbcolor-examples");for(k=0;k<b.length;k++)try{var l=document.createElement("li"),o=new RGBColor(b[k]),n=document.createElement("div");n.style.cssText="margin: 3px; border: 1px solid black; background:"+o.toHex()+"; color:"+o.toHex();n.appendChild(document.createTextNode("test"));var q=document.createTextNode(" "+b[k]+" -> "+o.toRGB()+" -> "+o.toHex());l.appendChild(n);l.appendChild(q);c.appendChild(l)}catch(p){}return c}} +if(!window.console)window.console={},window.console.log=function(){},window.console.dir=function(){};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(m){for(var a=0;a<this.length;a++)if(this[a]==m)return a;return-1}; +(function(){function m(){var a={FRAMERATE:30,MAX_VIRTUAL_PIXELS:3E4};a.init=function(c){a.Definitions={};a.Styles={};a.Animations=[];a.Images=[];a.ctx=c;a.ViewPort=new function(){this.viewPorts=[];this.Clear=function(){this.viewPorts=[]};this.SetCurrent=function(a,b){this.viewPorts.push({width:a,height:b})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height}; +this.ComputeSize=function(a){return a!=null&&typeof a=="number"?a:a=="x"?this.width():a=="y"?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};a.init();a.ImagesLoaded=function(){for(var c=0;c<a.Images.length;c++)if(!a.Images[c].loaded)return!1;return!0};a.trim=function(a){return a.replace(/^\s+|\s+$/g,"")};a.compressSpaces=function(a){return a.replace(/[\s\r\t\n]+/gm," ")};a.ajax=function(a){var d;return(d=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"))? +(d.open("GET",a,!1),d.send(null),d.responseText):null};a.parseXml=function(a){if(window.DOMParser)return(new DOMParser).parseFromString(a,"text/xml");else{var a=a.replace(/<!DOCTYPE svg[^>]*>/,""),d=new ActiveXObject("Microsoft.XMLDOM");d.async="false";d.loadXML(a);return d}};a.Property=function(c,d){this.name=c;this.value=d;this.hasValue=function(){return this.value!=null&&this.value!==""};this.numValue=function(){if(!this.hasValue())return 0;var b=parseFloat(this.value);(this.value+"").match(/%$/)&& +(b/=100);return b};this.valueOrDefault=function(b){return this.hasValue()?this.value:b};this.numValueOrDefault=function(b){return this.hasValue()?this.numValue():b};var b=this;this.Color={addOpacity:function(d){var c=b.value;if(d!=null&&d!=""){var f=new RGBColor(b.value);f.ok&&(c="rgba("+f.r+", "+f.g+", "+f.b+", "+d+")")}return new a.Property(b.name,c)}};this.Definition={getDefinition:function(){var d=b.value.replace(/^(url\()?#([^\)]+)\)?$/,"$2");return a.Definitions[d]},isUrl:function(){return b.value.indexOf("url(")== +0},getFillStyle:function(b){var d=this.getDefinition();return d!=null&&d.createGradient?d.createGradient(a.ctx,b):d!=null&&d.createPattern?d.createPattern(a.ctx,b):null}};this.Length={DPI:function(){return 96},EM:function(b){var d=12,c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);c.hasValue()&&(d=c.Length.toPixels(b));return d},toPixels:function(d){if(!b.hasValue())return 0;var c=b.value+"";return c.match(/em$/)?b.numValue()*this.EM(d):c.match(/ex$/)?b.numValue()*this.EM(d)/2:c.match(/px$/)? +b.numValue():c.match(/pt$/)?b.numValue()*1.25:c.match(/pc$/)?b.numValue()*15:c.match(/cm$/)?b.numValue()*this.DPI(d)/2.54:c.match(/mm$/)?b.numValue()*this.DPI(d)/25.4:c.match(/in$/)?b.numValue()*this.DPI(d):c.match(/%$/)?b.numValue()*a.ViewPort.ComputeSize(d):b.numValue()}};this.Time={toMilliseconds:function(){if(!b.hasValue())return 0;var a=b.value+"";if(a.match(/s$/))return b.numValue()*1E3;a.match(/ms$/);return b.numValue()}};this.Angle={toRadians:function(){if(!b.hasValue())return 0;var a=b.value+ +"";return a.match(/deg$/)?b.numValue()*(Math.PI/180):a.match(/grad$/)?b.numValue()*(Math.PI/200):a.match(/rad$/)?b.numValue():b.numValue()*(Math.PI/180)}}};a.Font=new function(){this.Styles=["normal","italic","oblique","inherit"];this.Variants=["normal","small-caps","inherit"];this.Weights="normal,bold,bolder,lighter,100,200,300,400,500,600,700,800,900,inherit".split(",");this.CreateFont=function(d,b,c,e,f,g){g=g!=null?this.Parse(g):this.CreateFont("","","","","",a.ctx.font);return{fontFamily:f|| +g.fontFamily,fontSize:e||g.fontSize,fontStyle:d||g.fontStyle,fontWeight:c||g.fontWeight,fontVariant:b||g.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var c=this;this.Parse=function(d){for(var b={},d=a.trim(a.compressSpaces(d||"")).split(" "),k=!1,e=!1,f=!1,g=!1,j="",h=0;h<d.length;h++)if(!e&&c.Styles.indexOf(d[h])!=-1){if(d[h]!="inherit")b.fontStyle=d[h];e=!0}else if(!g&&c.Variants.indexOf(d[h])!=-1){if(d[h]!="inherit")b.fontVariant= +d[h];e=g=!0}else if(!f&&c.Weights.indexOf(d[h])!=-1){if(d[h]!="inherit")b.fontWeight=d[h];e=g=f=!0}else if(k)d[h]!="inherit"&&(j+=d[h]);else{if(d[h]!="inherit")b.fontSize=d[h].split("/")[0];e=g=f=k=!0}if(j!="")b.fontFamily=j;return b}};a.ToNumberArray=function(c){for(var c=a.trim(a.compressSpaces((c||"").replace(/,/g," "))).split(" "),d=0;d<c.length;d++)c[d]=parseFloat(c[d]);return c};a.Point=function(a,d){this.x=a;this.y=d;this.angleTo=function(b){return Math.atan2(b.y-this.y,b.x-this.x)};this.applyTransform= +function(b){var a=this.x*b[1]+this.y*b[3]+b[5];this.x=this.x*b[0]+this.y*b[2]+b[4];this.y=a}};a.CreatePoint=function(c){c=a.ToNumberArray(c);return new a.Point(c[0],c[1])};a.CreatePath=function(c){for(var c=a.ToNumberArray(c),d=[],b=0;b<c.length;b+=2)d.push(new a.Point(c[b],c[b+1]));return d};a.BoundingBox=function(a,d,b,k){this.y2=this.x2=this.y1=this.x1=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2- +this.y1};this.addPoint=function(b,a){if(b!=null){if(isNaN(this.x1)||isNaN(this.x2))this.x2=this.x1=b;if(b<this.x1)this.x1=b;if(b>this.x2)this.x2=b}if(a!=null){if(isNaN(this.y1)||isNaN(this.y2))this.y2=this.y1=a;if(a<this.y1)this.y1=a;if(a>this.y2)this.y2=a}};this.addX=function(b){this.addPoint(b,null)};this.addY=function(b){this.addPoint(null,b)};this.addBoundingBox=function(b){this.addPoint(b.x1,b.y1);this.addPoint(b.x2,b.y2)};this.addQuadraticCurve=function(b,a,d,c,k,l){d=b+2/3*(d-b);c=a+2/3*(c- +a);this.addBezierCurve(b,a,d,d+1/3*(k-b),c,c+1/3*(l-a),k,l)};this.addBezierCurve=function(b,a,d,c,k,l,o,n){var q=[b,a],p=[d,c],t=[k,l],m=[o,n];this.addPoint(q[0],q[1]);this.addPoint(m[0],m[1]);for(i=0;i<=1;i++)b=function(b){return Math.pow(1-b,3)*q[i]+3*Math.pow(1-b,2)*b*p[i]+3*(1-b)*Math.pow(b,2)*t[i]+Math.pow(b,3)*m[i]},a=6*q[i]-12*p[i]+6*t[i],d=-3*q[i]+9*p[i]-9*t[i]+3*m[i],c=3*p[i]-3*q[i],d==0?a!=0&&(a=-c/a,0<a&&a<1&&(i==0&&this.addX(b(a)),i==1&&this.addY(b(a)))):(c=Math.pow(a,2)-4*c*d,c<0||(k= +(-a+Math.sqrt(c))/(2*d),0<k&&k<1&&(i==0&&this.addX(b(k)),i==1&&this.addY(b(k))),a=(-a-Math.sqrt(c))/(2*d),0<a&&a<1&&(i==0&&this.addX(b(a)),i==1&&this.addY(b(a)))))};this.isPointInBox=function(b,a){return this.x1<=b&&b<=this.x2&&this.y1<=a&&a<=this.y2};this.addPoint(a,d);this.addPoint(b,k)};a.Transform=function(c){var d=this;this.Type={};this.Type.translate=function(b){this.p=a.CreatePoint(b);this.apply=function(b){b.translate(this.p.x||0,this.p.y||0)};this.applyToPoint=function(b){b.applyTransform([1, +0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(b){b=a.ToNumberArray(b);this.angle=new a.Property("angle",b[0]);this.cx=b[1]||0;this.cy=b[2]||0;this.apply=function(b){b.translate(this.cx,this.cy);b.rotate(this.angle.Angle.toRadians());b.translate(-this.cx,-this.cy)};this.applyToPoint=function(b){var a=this.angle.Angle.toRadians();b.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);b.applyTransform([Math.cos(a),Math.sin(a),-Math.sin(a),Math.cos(a),0,0]);b.applyTransform([1,0,0,1,-this.p.x|| +0,-this.p.y||0])}};this.Type.scale=function(b){this.p=a.CreatePoint(b);this.apply=function(b){b.scale(this.p.x||1,this.p.y||this.p.x||1)};this.applyToPoint=function(b){b.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(b){this.m=a.ToNumberArray(b);this.apply=function(b){b.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.applyToPoint=function(b){b.applyTransform(this.m)}};this.Type.SkewBase=function(b){this.base=d.Type.matrix;this.base(b);this.angle= +new a.Property("angle",b)};this.Type.SkewBase.prototype=new this.Type.matrix;this.Type.skewX=function(b){this.base=d.Type.SkewBase;this.base(b);this.m=[1,0,Math.tan(this.angle.Angle.toRadians()),1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(b){this.base=d.Type.SkewBase;this.base(b);this.m=[1,Math.tan(this.angle.Angle.toRadians()),0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(b){for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(b)}; +this.applyToPoint=function(b){for(var a=0;a<this.transforms.length;a++)this.transforms[a].applyToPoint(b)};for(var c=a.trim(a.compressSpaces(c)).split(/\s(?=[a-z])/),b=0;b<c.length;b++){var k=c[b].split("(")[0],e=c[b].split("(")[1].replace(")","");this.transforms.push(new this.Type[k](e))}};a.AspectRatio=function(c,d,b,k,e,f,g,j,h,l){var d=a.compressSpaces(d),d=d.replace(/^defer\s/,""),o=d.split(" ")[0]||"xMidYMid",d=d.split(" ")[1]||"meet",n=b/k,q=e/f,p=Math.min(n,q),m=Math.max(n,q);d=="meet"&&(k*= +p,f*=p);d=="slice"&&(k*=m,f*=m);h=new a.Property("refX",h);l=new a.Property("refY",l);h.hasValue()&&l.hasValue()?c.translate(-p*h.Length.toPixels("x"),-p*l.Length.toPixels("y")):(o.match(/^xMid/)&&(d=="meet"&&p==q||d=="slice"&&m==q)&&c.translate(b/2-k/2,0),o.match(/YMid$/)&&(d=="meet"&&p==n||d=="slice"&&m==n)&&c.translate(0,e/2-f/2),o.match(/^xMax/)&&(d=="meet"&&p==q||d=="slice"&&m==q)&&c.translate(b-k,0),o.match(/YMax$/)&&(d=="meet"&&p==n||d=="slice"&&m==n)&&c.translate(0,e-f));o=="none"?c.scale(n, +q):d=="meet"?c.scale(p,p):d=="slice"&&c.scale(m,m);c.translate(g==null?0:-g,j==null?0:-j)};a.Element={};a.Element.ElementBase=function(c){this.attributes={};this.styles={};this.children=[];this.attribute=function(b,d){var c=this.attributes[b];if(c!=null)return c;c=new a.Property(b,"");d==!0&&(this.attributes[b]=c);return c};this.style=function(b,d){var c=this.styles[b];if(c!=null)return c;c=this.attribute(b);if(c!=null&&c.hasValue())return c;c=this.parent;if(c!=null&&(c=c.style(b),c!=null&&c.hasValue()))return c; +c=new a.Property(b,"");d==!0&&(this.styles[b]=c);return c};this.render=function(b){if(this.style("display").value!="none"&&this.attribute("visibility").value!="hidden"){b.save();this.setContext(b);if(this.attribute("mask").hasValue()){var a=this.attribute("mask").Definition.getDefinition();a!=null&&a.apply(b,this)}else this.style("filter").hasValue()?(a=this.style("filter").Definition.getDefinition(),a!=null&&a.apply(b,this)):this.renderChildren(b);this.clearContext(b);b.restore()}};this.setContext= +function(){};this.clearContext=function(){};this.renderChildren=function(b){for(var a=0;a<this.children.length;a++)this.children[a].render(b)};this.addChild=function(b,d){var c=b;d&&(c=a.CreateElement(b));c.parent=this;this.children.push(c)};if(c!=null&&c.nodeType==1){for(var d=0;d<c.childNodes.length;d++){var b=c.childNodes[d];b.nodeType==1&&this.addChild(b,!0)}for(d=0;d<c.attributes.length;d++)b=c.attributes[d],this.attributes[b.nodeName]=new a.Property(b.nodeName,b.nodeValue);b=a.Styles[c.nodeName]; +if(b!=null)for(var k in b)this.styles[k]=b[k];if(this.attribute("class").hasValue())for(var d=a.compressSpaces(this.attribute("class").value).split(" "),e=0;e<d.length;e++){b=a.Styles["."+d[e]];if(b!=null)for(k in b)this.styles[k]=b[k];b=a.Styles[c.nodeName+"."+d[e]];if(b!=null)for(k in b)this.styles[k]=b[k]}if(this.attribute("style").hasValue()){b=this.attribute("style").value.split(";");for(d=0;d<b.length;d++)a.trim(b[d])!=""&&(c=b[d].split(":"),k=a.trim(c[0]),c=a.trim(c[1]),this.styles[k]=new a.Property(k, +c))}this.attribute("id").hasValue()&&a.Definitions[this.attribute("id").value]==null&&(a.Definitions[this.attribute("id").value]=this)}};a.Element.RenderedElementBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.setContext=function(d){if(this.style("fill").Definition.isUrl()){var b=this.style("fill").Definition.getFillStyle(this);if(b!=null)d.fillStyle=b}else if(this.style("fill").hasValue())b=this.style("fill"),this.style("fill-opacity").hasValue()&&(b=b.Color.addOpacity(this.style("fill-opacity").value)), +d.fillStyle=b.value=="none"?"rgba(0,0,0,0)":b.value;if(this.style("stroke").Definition.isUrl()){if(b=this.style("stroke").Definition.getFillStyle(this),b!=null)d.strokeStyle=b}else if(this.style("stroke").hasValue())b=this.style("stroke"),this.style("stroke-opacity").hasValue()&&(b=b.Color.addOpacity(this.style("stroke-opacity").value)),d.strokeStyle=b.value=="none"?"rgba(0,0,0,0)":b.value;if(this.style("stroke-width").hasValue())d.lineWidth=this.style("stroke-width").Length.toPixels();if(this.style("stroke-linecap").hasValue())d.lineCap= +this.style("stroke-linecap").value;if(this.style("stroke-linejoin").hasValue())d.lineJoin=this.style("stroke-linejoin").value;if(this.style("stroke-miterlimit").hasValue())d.miterLimit=this.style("stroke-miterlimit").value;if(typeof d.font!="undefined")d.font=a.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").Length.toPixels()+"px":"",this.style("font-family").value).toString(); +this.attribute("transform").hasValue()&&(new a.Transform(this.attribute("transform").value)).apply(d);this.attribute("clip-path").hasValue()&&(b=this.attribute("clip-path").Definition.getDefinition(),b!=null&&b.apply(d));if(this.style("opacity").hasValue())d.globalAlpha=this.style("opacity").numValue()}};a.Element.RenderedElementBase.prototype=new a.Element.ElementBase;a.Element.PathElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.path=function(d){d!=null&&d.beginPath(); +return new a.BoundingBox};this.renderChildren=function(d){this.path(d);a.Mouse.checkPath(this,d);d.fillStyle!=""&&d.fill();d.strokeStyle!=""&&d.stroke();var b=this.getMarkers();if(b!=null){if(this.style("marker-start").Definition.isUrl()){var c=this.style("marker-start").Definition.getDefinition();c.render(d,b[0][0],b[0][1])}if(this.style("marker-mid").Definition.isUrl())for(var c=this.style("marker-mid").Definition.getDefinition(),e=1;e<b.length-1;e++)c.render(d,b[e][0],b[e][1]);this.style("marker-end").Definition.isUrl()&& +(c=this.style("marker-end").Definition.getDefinition(),c.render(d,b[b.length-1][0],b[b.length-1][1]))}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};a.Element.PathElementBase.prototype=new a.Element.RenderedElementBase;a.Element.svg=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseClearContext=this.clearContext;this.clearContext=function(d){this.baseClearContext(d);a.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext; +this.setContext=function(d){d.strokeStyle="rgba(0,0,0,0)";d.lineCap="butt";d.lineJoin="miter";d.miterLimit=4;this.baseSetContext(d);this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&d.translate(this.attribute("x").Length.toPixels("x"),this.attribute("y").Length.toPixels("y"));var b=a.ViewPort.width(),c=a.ViewPort.height();if(typeof this.root=="undefined"&&this.attribute("width").hasValue()&&this.attribute("height").hasValue()){var b=this.attribute("width").Length.toPixels("x"),c=this.attribute("height").Length.toPixels("y"), +e=0,f=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(e=-this.attribute("refX").Length.toPixels("x"),f=-this.attribute("refY").Length.toPixels("y"));d.beginPath();d.moveTo(e,f);d.lineTo(b,f);d.lineTo(b,c);d.lineTo(e,c);d.closePath();d.clip()}a.ViewPort.SetCurrent(b,c);if(this.attribute("viewBox").hasValue()){var e=a.ToNumberArray(this.attribute("viewBox").value),f=e[0],g=e[1],b=e[2],c=e[3];a.AspectRatio(d,this.attribute("preserveAspectRatio").value,a.ViewPort.width(),b,a.ViewPort.height(), +c,f,g,this.attribute("refX").value,this.attribute("refY").value);a.ViewPort.RemoveCurrent();a.ViewPort.SetCurrent(e[2],e[3])}}};a.Element.svg.prototype=new a.Element.RenderedElementBase;a.Element.rect=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(d){var b=this.attribute("x").Length.toPixels("x"),c=this.attribute("y").Length.toPixels("y"),e=this.attribute("width").Length.toPixels("x"),f=this.attribute("height").Length.toPixels("y"),g=this.attribute("rx").Length.toPixels("x"), +j=this.attribute("ry").Length.toPixels("y");this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(j=g);this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(g=j);d!=null&&(d.beginPath(),d.moveTo(b+g,c),d.lineTo(b+e-g,c),d.quadraticCurveTo(b+e,c,b+e,c+j),d.lineTo(b+e,c+f-j),d.quadraticCurveTo(b+e,c+f,b+e-g,c+f),d.lineTo(b+g,c+f),d.quadraticCurveTo(b,c+f,b,c+f-j),d.lineTo(b,c+j),d.quadraticCurveTo(b,c,b+g,c),d.closePath());return new a.BoundingBox(b,c,b+e,c+f)}};a.Element.rect.prototype= +new a.Element.PathElementBase;a.Element.circle=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(d){var b=this.attribute("cx").Length.toPixels("x"),c=this.attribute("cy").Length.toPixels("y"),e=this.attribute("r").Length.toPixels();d!=null&&(d.beginPath(),d.arc(b,c,e,0,Math.PI*2,!0),d.closePath());return new a.BoundingBox(b-e,c-e,b+e,c+e)}};a.Element.circle.prototype=new a.Element.PathElementBase;a.Element.ellipse=function(c){this.base=a.Element.PathElementBase;this.base(c); +this.path=function(d){var b=4*((Math.sqrt(2)-1)/3),c=this.attribute("rx").Length.toPixels("x"),e=this.attribute("ry").Length.toPixels("y"),f=this.attribute("cx").Length.toPixels("x"),g=this.attribute("cy").Length.toPixels("y");d!=null&&(d.beginPath(),d.moveTo(f,g-e),d.bezierCurveTo(f+b*c,g-e,f+c,g-b*e,f+c,g),d.bezierCurveTo(f+c,g+b*e,f+b*c,g+e,f,g+e),d.bezierCurveTo(f-b*c,g+e,f-c,g+b*e,f-c,g),d.bezierCurveTo(f-c,g-b*e,f-b*c,g-e,f,g-e),d.closePath());return new a.BoundingBox(f-c,g-e,f+c,g+e)}};a.Element.ellipse.prototype= +new a.Element.PathElementBase;a.Element.line=function(c){this.base=a.Element.PathElementBase;this.base(c);this.getPoints=function(){return[new a.Point(this.attribute("x1").Length.toPixels("x"),this.attribute("y1").Length.toPixels("y")),new a.Point(this.attribute("x2").Length.toPixels("x"),this.attribute("y2").Length.toPixels("y"))]};this.path=function(d){var b=this.getPoints();d!=null&&(d.beginPath(),d.moveTo(b[0].x,b[0].y),d.lineTo(b[1].x,b[1].y));return new a.BoundingBox(b[0].x,b[0].y,b[1].x,b[1].y)}; +this.getMarkers=function(){var a=this.getPoints(),b=a[0].angleTo(a[1]);return[[a[0],b],[a[1],b]]}};a.Element.line.prototype=new a.Element.PathElementBase;a.Element.polyline=function(c){this.base=a.Element.PathElementBase;this.base(c);this.points=a.CreatePath(this.attribute("points").value);this.path=function(d){var b=new a.BoundingBox(this.points[0].x,this.points[0].y);d!=null&&(d.beginPath(),d.moveTo(this.points[0].x,this.points[0].y));for(var c=1;c<this.points.length;c++)b.addPoint(this.points[c].x, +this.points[c].y),d!=null&&d.lineTo(this.points[c].x,this.points[c].y);return b};this.getMarkers=function(){for(var a=[],b=0;b<this.points.length-1;b++)a.push([this.points[b],this.points[b].angleTo(this.points[b+1])]);a.push([this.points[this.points.length-1],a[a.length-1][1]]);return a}};a.Element.polyline.prototype=new a.Element.PathElementBase;a.Element.polygon=function(c){this.base=a.Element.polyline;this.base(c);this.basePath=this.path;this.path=function(a){var b=this.basePath(a);a!=null&&(a.lineTo(this.points[0].x, +this.points[0].y),a.closePath());return b}};a.Element.polygon.prototype=new a.Element.polyline;a.Element.path=function(c){this.base=a.Element.PathElementBase;this.base(c);c=this.attribute("d").value;c=c.replace(/,/gm," ");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");c=c.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([0-9])([+\-])/gm, +"$1 $2");c=c.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");c=c.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");c=a.compressSpaces(c);c=a.trim(c);this.PathParser=new function(d){this.tokens=d.split(" ");this.reset=function(){this.i=-1;this.previousCommand=this.command="";this.start=new a.Point(0,0);this.control=new a.Point(0,0);this.current=new a.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){return this.isEnd()? +!0:this.tokens[this.i+1].match(/^[A-Za-z]$/)!=null};this.isRelativeCommand=function(){return this.command==this.command.toLowerCase()};this.getToken=function(){this.i+=1;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=this.getToken()};this.getPoint=function(){return this.makeAbsolute(new a.Point(this.getScalar(),this.getScalar()))};this.getAsControlPoint=function(){var b=this.getPoint(); +return this.control=b};this.getAsCurrentPoint=function(){var b=this.getPoint();return this.current=b};this.getReflectedControlPoint=function(){return this.previousCommand.toLowerCase()!="c"&&this.previousCommand.toLowerCase()!="s"?this.current:new a.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)};this.makeAbsolute=function(b){if(this.isRelativeCommand())b.x=this.current.x+b.x,b.y=this.current.y+b.y;return b};this.addMarker=function(b,a,d){d!=null&&this.angles.length>0&&this.angles[this.angles.length- +1]==null&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(d));this.addMarkerAngle(b,a==null?null:a.angleTo(b))};this.addMarkerAngle=function(b,a){this.points.push(b);this.angles.push(a)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var b=0;b<this.angles.length;b++)if(this.angles[b]==null)for(var a=b+1;a<this.angles.length;a++)if(this.angles[a]!=null){this.angles[b]=this.angles[a];break}return this.angles}}(c);this.path=function(d){var b= +this.PathParser;b.reset();var c=new a.BoundingBox;for(d!=null&&d.beginPath();!b.isEnd();)switch(b.nextCommand(),b.command.toUpperCase()){case "M":var e=b.getAsCurrentPoint();b.addMarker(e);c.addPoint(e.x,e.y);d!=null&&d.moveTo(e.x,e.y);for(b.start=b.current;!b.isCommandOrEnd();)e=b.getAsCurrentPoint(),b.addMarker(e,b.start),c.addPoint(e.x,e.y),d!=null&&d.lineTo(e.x,e.y);break;case "L":for(;!b.isCommandOrEnd();){var f=b.current,e=b.getAsCurrentPoint();b.addMarker(e,f);c.addPoint(e.x,e.y);d!=null&& +d.lineTo(e.x,e.y)}break;case "H":for(;!b.isCommandOrEnd();)e=new a.Point((b.isRelativeCommand()?b.current.x:0)+b.getScalar(),b.current.y),b.addMarker(e,b.current),b.current=e,c.addPoint(b.current.x,b.current.y),d!=null&&d.lineTo(b.current.x,b.current.y);break;case "V":for(;!b.isCommandOrEnd();)e=new a.Point(b.current.x,(b.isRelativeCommand()?b.current.y:0)+b.getScalar()),b.addMarker(e,b.current),b.current=e,c.addPoint(b.current.x,b.current.y),d!=null&&d.lineTo(b.current.x,b.current.y);break;case "C":for(;!b.isCommandOrEnd();){var g= +b.current,f=b.getPoint(),j=b.getAsControlPoint(),e=b.getAsCurrentPoint();b.addMarker(e,j,f);c.addBezierCurve(g.x,g.y,f.x,f.y,j.x,j.y,e.x,e.y);d!=null&&d.bezierCurveTo(f.x,f.y,j.x,j.y,e.x,e.y)}break;case "S":for(;!b.isCommandOrEnd();)g=b.current,f=b.getReflectedControlPoint(),j=b.getAsControlPoint(),e=b.getAsCurrentPoint(),b.addMarker(e,j,f),c.addBezierCurve(g.x,g.y,f.x,f.y,j.x,j.y,e.x,e.y),d!=null&&d.bezierCurveTo(f.x,f.y,j.x,j.y,e.x,e.y);break;case "Q":for(;!b.isCommandOrEnd();)g=b.current,j=b.getAsControlPoint(), +e=b.getAsCurrentPoint(),b.addMarker(e,j,j),c.addQuadraticCurve(g.x,g.y,j.x,j.y,e.x,e.y),d!=null&&d.quadraticCurveTo(j.x,j.y,e.x,e.y);break;case "T":for(;!b.isCommandOrEnd();)g=b.current,j=b.getReflectedControlPoint(),b.control=j,e=b.getAsCurrentPoint(),b.addMarker(e,j,j),c.addQuadraticCurve(g.x,g.y,j.x,j.y,e.x,e.y),d!=null&&d.quadraticCurveTo(j.x,j.y,e.x,e.y);break;case "A":for(;!b.isCommandOrEnd();){var g=b.current,h=b.getScalar(),l=b.getScalar(),f=b.getScalar()*(Math.PI/180),o=b.getScalar(),j=b.getScalar(), +e=b.getAsCurrentPoint(),n=new a.Point(Math.cos(f)*(g.x-e.x)/2+Math.sin(f)*(g.y-e.y)/2,-Math.sin(f)*(g.x-e.x)/2+Math.cos(f)*(g.y-e.y)/2),q=Math.pow(n.x,2)/Math.pow(h,2)+Math.pow(n.y,2)/Math.pow(l,2);q>1&&(h*=Math.sqrt(q),l*=Math.sqrt(q));o=(o==j?-1:1)*Math.sqrt((Math.pow(h,2)*Math.pow(l,2)-Math.pow(h,2)*Math.pow(n.y,2)-Math.pow(l,2)*Math.pow(n.x,2))/(Math.pow(h,2)*Math.pow(n.y,2)+Math.pow(l,2)*Math.pow(n.x,2)));isNaN(o)&&(o=0);var p=new a.Point(o*h*n.y/l,o*-l*n.x/h),g=new a.Point((g.x+e.x)/2+Math.cos(f)* +p.x-Math.sin(f)*p.y,(g.y+e.y)/2+Math.sin(f)*p.x+Math.cos(f)*p.y),m=function(b,a){return(b[0]*a[0]+b[1]*a[1])/(Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2))*Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)))},s=function(b,a){return(b[0]*a[1]<b[1]*a[0]?-1:1)*Math.acos(m(b,a))},o=s([1,0],[(n.x-p.x)/h,(n.y-p.y)/l]),q=[(n.x-p.x)/h,(n.y-p.y)/l],p=[(-n.x-p.x)/h,(-n.y-p.y)/l],n=s(q,p);if(m(q,p)<=-1)n=Math.PI;m(q,p)>=1&&(n=0);j==0&&n>0&&(n-=2*Math.PI);j==1&&n<0&&(n+=2*Math.PI);q=new a.Point(g.x-h*Math.cos((o+n)/ +2),g.y-l*Math.sin((o+n)/2));b.addMarkerAngle(q,(o+n)/2+(j==0?1:-1)*Math.PI/2);b.addMarkerAngle(e,n+(j==0?1:-1)*Math.PI/2);c.addPoint(e.x,e.y);d!=null&&(m=h>l?h:l,e=h>l?1:h/l,h=h>l?l/h:1,d.translate(g.x,g.y),d.rotate(f),d.scale(e,h),d.arc(0,0,m,o,o+n,1-j),d.scale(1/e,1/h),d.rotate(-f),d.translate(-g.x,-g.y))}break;case "Z":d!=null&&d.closePath(),b.current=b.start}return c};this.getMarkers=function(){for(var a=this.PathParser.getMarkerPoints(),b=this.PathParser.getMarkerAngles(),c=[],e=0;e<a.length;e++)c.push([a[e], +b[e]]);return c}};a.Element.path.prototype=new a.Element.PathElementBase;a.Element.pattern=function(c){this.base=a.Element.ElementBase;this.base(c);this.createPattern=function(d){var b=new a.Element.svg;b.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);b.attributes.x=new a.Property("x",this.attribute("x").value);b.attributes.y=new a.Property("y",this.attribute("y").value);b.attributes.width=new a.Property("width",this.attribute("width").value);b.attributes.height=new a.Property("height", +this.attribute("height").value);b.children=this.children;var c=document.createElement("canvas");c.width=this.attribute("width").Length.toPixels("x");c.height=this.attribute("height").Length.toPixels("y");b.render(c.getContext("2d"));return d.createPattern(c,"repeat")}};a.Element.pattern.prototype=new a.Element.ElementBase;a.Element.marker=function(c){this.base=a.Element.ElementBase;this.base(c);this.baseRender=this.render;this.render=function(d,b,c){d.translate(b.x,b.y);this.attribute("orient").valueOrDefault("auto")== +"auto"&&d.rotate(c);this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&d.scale(d.lineWidth,d.lineWidth);d.save();var e=new a.Element.svg;e.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);e.attributes.refX=new a.Property("refX",this.attribute("refX").value);e.attributes.refY=new a.Property("refY",this.attribute("refY").value);e.attributes.width=new a.Property("width",this.attribute("markerWidth").value);e.attributes.height=new a.Property("height", +this.attribute("markerHeight").value);e.attributes.fill=new a.Property("fill",this.attribute("fill").valueOrDefault("black"));e.attributes.stroke=new a.Property("stroke",this.attribute("stroke").valueOrDefault("none"));e.children=this.children;e.render(d);d.restore();this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&d.scale(1/d.lineWidth,1/d.lineWidth);this.attribute("orient").valueOrDefault("auto")=="auto"&&d.rotate(-c);d.translate(-b.x,-b.y)}};a.Element.marker.prototype= +new a.Element.ElementBase;a.Element.defs=function(c){this.base=a.Element.ElementBase;this.base(c);this.render=function(){}};a.Element.defs.prototype=new a.Element.ElementBase;a.Element.GradientBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.gradientUnits=this.attribute("gradientUnits").valueOrDefault("objectBoundingBox");this.stops=[];for(c=0;c<this.children.length;c++)this.stops.push(this.children[c]);this.getGradient=function(){};this.createGradient=function(d,b){var c=this;this.attribute("xlink:href").hasValue()&& +(c=this.attribute("xlink:href").Definition.getDefinition());for(var e=this.getGradient(d,b),f=0;f<c.stops.length;f++)e.addColorStop(c.stops[f].offset,c.stops[f].color);if(this.attribute("gradientTransform").hasValue()){c=a.ViewPort.viewPorts[0];f=new a.Element.rect;f.attributes.x=new a.Property("x",-a.MAX_VIRTUAL_PIXELS/3);f.attributes.y=new a.Property("y",-a.MAX_VIRTUAL_PIXELS/3);f.attributes.width=new a.Property("width",a.MAX_VIRTUAL_PIXELS);f.attributes.height=new a.Property("height",a.MAX_VIRTUAL_PIXELS); +var g=new a.Element.g;g.attributes.transform=new a.Property("transform",this.attribute("gradientTransform").value);g.children=[f];f=new a.Element.svg;f.attributes.x=new a.Property("x",0);f.attributes.y=new a.Property("y",0);f.attributes.width=new a.Property("width",c.width);f.attributes.height=new a.Property("height",c.height);f.children=[g];g=document.createElement("canvas");g.width=c.width;g.height=c.height;c=g.getContext("2d");c.fillStyle=e;f.render(c);return c.createPattern(g,"no-repeat")}return e}}; +a.Element.GradientBase.prototype=new a.Element.ElementBase;a.Element.linearGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.getGradient=function(a,b){var c=b.getBoundingBox(),e=this.gradientUnits=="objectBoundingBox"?c.x()+c.width()*this.attribute("x1").numValue():this.attribute("x1").Length.toPixels("x"),f=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("y1").numValue():this.attribute("y1").Length.toPixels("y"),g=this.gradientUnits=="objectBoundingBox"? +c.x()+c.width()*this.attribute("x2").numValue():this.attribute("x2").Length.toPixels("x"),c=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("y2").numValue():this.attribute("y2").Length.toPixels("y");return a.createLinearGradient(e,f,g,c)}};a.Element.linearGradient.prototype=new a.Element.GradientBase;a.Element.radialGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.getGradient=function(a,b){var c=b.getBoundingBox(),e=this.gradientUnits=="objectBoundingBox"? +c.x()+c.width()*this.attribute("cx").numValue():this.attribute("cx").Length.toPixels("x"),f=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("cy").numValue():this.attribute("cy").Length.toPixels("y"),g=e,j=f;this.attribute("fx").hasValue()&&(g=this.gradientUnits=="objectBoundingBox"?c.x()+c.width()*this.attribute("fx").numValue():this.attribute("fx").Length.toPixels("x"));this.attribute("fy").hasValue()&&(j=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("fy").numValue(): +this.attribute("fy").Length.toPixels("y"));c=this.gradientUnits=="objectBoundingBox"?(c.width()+c.height())/2*this.attribute("r").numValue():this.attribute("r").Length.toPixels();return a.createRadialGradient(g,j,0,e,f,c)}};a.Element.radialGradient.prototype=new a.Element.GradientBase;a.Element.stop=function(c){this.base=a.Element.ElementBase;this.base(c);this.offset=this.attribute("offset").numValue();c=this.style("stop-color");this.style("stop-opacity").hasValue()&&(c=c.Color.addOpacity(this.style("stop-opacity").value)); +this.color=c.value};a.Element.stop.prototype=new a.Element.ElementBase;a.Element.AnimateBase=function(c){this.base=a.Element.ElementBase;this.base(c);a.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").Time.toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").Time.toMilliseconds();this.getProperty=function(){var a=this.attribute("attributeType").value,b=this.attribute("attributeName").value;return a=="CSS"?this.parent.style(b,!0):this.parent.attribute(b,!0)};this.initialValue= +null;this.removed=!1;this.calcValue=function(){return""};this.update=function(a){if(this.initialValue==null)this.initialValue=this.getProperty().value;if(this.duration>this.maxDuration)if(this.attribute("repeatCount").value=="indefinite")this.duration=0;else return this.attribute("fill").valueOrDefault("remove")=="remove"&&!this.removed?(this.removed=!0,this.getProperty().value=this.initialValue,!0):!1;this.duration+=a;a=!1;if(this.begin<this.duration)a=this.calcValue(),this.attribute("type").hasValue()&& +(a=this.attribute("type").value+"("+a+")"),this.getProperty().value=a,a=!0;return a};this.progress=function(){return(this.duration-this.begin)/(this.maxDuration-this.begin)}};a.Element.AnimateBase.prototype=new a.Element.ElementBase;a.Element.animate=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.attribute("from").numValue(),b=this.attribute("to").numValue();return a+(b-a)*this.progress()}};a.Element.animate.prototype=new a.Element.AnimateBase;a.Element.animateColor= +function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=new RGBColor(this.attribute("from").value),b=new RGBColor(this.attribute("to").value);if(a.ok&&b.ok){var c=a.r+(b.r-a.r)*this.progress(),e=a.g+(b.g-a.g)*this.progress(),a=a.b+(b.b-a.b)*this.progress();return"rgb("+parseInt(c,10)+","+parseInt(e,10)+","+parseInt(a,10)+")"}return this.attribute("from").value}};a.Element.animateColor.prototype=new a.Element.AnimateBase;a.Element.animateTransform=function(c){this.base= +a.Element.animate;this.base(c)};a.Element.animateTransform.prototype=new a.Element.animate;a.Element.font=function(c){this.base=a.Element.ElementBase;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.isArabic=this.isRTL=!1;this.missingGlyph=this.fontFace=null;this.glyphs=[];for(c=0;c<this.children.length;c++){var d=this.children[c];if(d.type=="font-face")this.fontFace=d,d.style("font-family").hasValue()&&(a.Definitions[d.style("font-family").value]=this);else if(d.type=="missing-glyph")this.missingGlyph= +d;else if(d.type=="glyph")d.arabicForm!=""?(this.isArabic=this.isRTL=!0,typeof this.glyphs[d.unicode]=="undefined"&&(this.glyphs[d.unicode]=[]),this.glyphs[d.unicode][d.arabicForm]=d):this.glyphs[d.unicode]=d}};a.Element.font.prototype=new a.Element.ElementBase;a.Element.fontface=function(c){this.base=a.Element.ElementBase;this.base(c);this.ascent=this.attribute("ascent").value;this.descent=this.attribute("descent").value;this.unitsPerEm=this.attribute("units-per-em").numValue()};a.Element.fontface.prototype= +new a.Element.ElementBase;a.Element.missingglyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=0};a.Element.missingglyph.prototype=new a.Element.path;a.Element.glyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.unicode=this.attribute("unicode").value;this.arabicForm=this.attribute("arabic-form").value};a.Element.glyph.prototype=new a.Element.path;a.Element.text=function(c){this.base=a.Element.RenderedElementBase; +this.base(c);if(c!=null){this.children=[];for(var d=0;d<c.childNodes.length;d++){var b=c.childNodes[d];b.nodeType==1?this.addChild(b,!0):b.nodeType==3&&this.addChild(new a.Element.tspan(b),!1)}}this.baseSetContext=this.setContext;this.setContext=function(b){this.baseSetContext(b);if(this.style("dominant-baseline").hasValue())b.textBaseline=this.style("dominant-baseline").value;if(this.style("alignment-baseline").hasValue())b.textBaseline=this.style("alignment-baseline").value};this.renderChildren= +function(b){for(var a=this.style("text-anchor").valueOrDefault("start"),c=this.attribute("x").Length.toPixels("x"),d=this.attribute("y").Length.toPixels("y"),j=0;j<this.children.length;j++){var h=this.children[j];h.attribute("x").hasValue()?h.x=h.attribute("x").Length.toPixels("x"):(h.attribute("dx").hasValue()&&(c+=h.attribute("dx").Length.toPixels("x")),h.x=c);c=h.measureText(b);if(a!="start"&&(j==0||h.attribute("x").hasValue())){for(var l=c,o=j+1;o<this.children.length;o++){var n=this.children[o]; +if(n.attribute("x").hasValue())break;l+=n.measureText(b)}h.x-=a=="end"?l:l/2}c=h.x+c;h.attribute("y").hasValue()?h.y=h.attribute("y").Length.toPixels("y"):(h.attribute("dy").hasValue()&&(d+=h.attribute("dy").Length.toPixels("y")),h.y=d);d=h.y;h.render(b)}}};a.Element.text.prototype=new a.Element.RenderedElementBase;a.Element.TextElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getGlyph=function(a,b,c){var e=b[c],f=null;if(a.isArabic){var g="isolated";if((c==0||b[c- +1]==" ")&&c<b.length-2&&b[c+1]!=" ")g="terminal";c>0&&b[c-1]!=" "&&c<b.length-2&&b[c+1]!=" "&&(g="medial");if(c>0&&b[c-1]!=" "&&(c==b.length-1||b[c+1]==" "))g="initial";typeof a.glyphs[e]!="undefined"&&(f=a.glyphs[e][g],f==null&&a.glyphs[e].type=="glyph"&&(f=a.glyphs[e]))}else f=a.glyphs[e];if(f==null)f=a.missingGlyph;return f};this.renderChildren=function(c){var b=this.parent.style("font-family").Definition.getDefinition();if(b!=null){var k=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize), +e=this.parent.style("font-style").valueOrDefault(a.Font.Parse(a.ctx.font).fontStyle),f=this.getText();b.isRTL&&(f=f.split("").reverse().join(""));for(var g=a.ToNumberArray(this.parent.attribute("dx").value),j=0;j<f.length;j++){var h=this.getGlyph(b,f,j),l=k/b.fontFace.unitsPerEm;c.translate(this.x,this.y);c.scale(l,-l);var o=c.lineWidth;c.lineWidth=c.lineWidth*b.fontFace.unitsPerEm/k;e=="italic"&&c.transform(1,0,0.4,1,0,0);h.render(c);e=="italic"&&c.transform(1,0,-0.4,1,0,0);c.lineWidth=o;c.scale(1/ +l,-1/l);c.translate(-this.x,-this.y);this.x+=k*(h.horizAdvX||b.horizAdvX)/b.fontFace.unitsPerEm;typeof g[j]!="undefined"&&!isNaN(g[j])&&(this.x+=g[j])}}else c.strokeStyle!=""&&c.strokeText(a.compressSpaces(this.getText()),this.x,this.y),c.fillStyle!=""&&c.fillText(a.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureText=function(c){var b=this.parent.style("font-family").Definition.getDefinition();if(b!=null){var c=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize), +k=0,e=this.getText();b.isRTL&&(e=e.split("").reverse().join(""));for(var f=a.ToNumberArray(this.parent.attribute("dx").value),g=0;g<e.length;g++){var j=this.getGlyph(b,e,g);k+=(j.horizAdvX||b.horizAdvX)*c/b.fontFace.unitsPerEm;typeof f[g]!="undefined"&&!isNaN(f[g])&&(k+=f[g])}return k}b=a.compressSpaces(this.getText());if(!c.measureText)return b.length*10;c.save();this.setContext(c);b=c.measureText(b).width;c.restore();return b}};a.Element.TextElementBase.prototype=new a.Element.RenderedElementBase; +a.Element.tspan=function(c){this.base=a.Element.TextElementBase;this.base(c);this.text=c.nodeType==3?c.nodeValue:c.childNodes.length>0?c.childNodes[0].nodeValue:c.text;this.getText=function(){return this.text}};a.Element.tspan.prototype=new a.Element.TextElementBase;a.Element.tref=function(c){this.base=a.Element.TextElementBase;this.base(c);this.getText=function(){var a=this.attribute("xlink:href").Definition.getDefinition();if(a!=null)return a.children[0].getText()}};a.Element.tref.prototype=new a.Element.TextElementBase; +a.Element.a=function(c){this.base=a.Element.TextElementBase;this.base(c);this.hasText=!0;for(var d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeType!=3)this.hasText=!1;this.text=this.hasText?c.childNodes[0].nodeValue:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(b){if(this.hasText){this.baseRenderChildren(b);var c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);a.Mouse.checkBoundingBox(this,new a.BoundingBox(this.x, +this.y-c.Length.toPixels("y"),this.x+this.measureText(b),this.y))}else c=new a.Element.g,c.children=this.children,c.parent=this,c.render(b)};this.onclick=function(){window.open(this.attribute("xlink:href").value)};this.onmousemove=function(){a.ctx.canvas.style.cursor="pointer"}};a.Element.a.prototype=new a.Element.TextElementBase;a.Element.image=function(c){this.base=a.Element.RenderedElementBase;this.base(c);a.Images.push(this);this.img=document.createElement("img");this.loaded=!1;var d=this;this.img.onload= +function(){d.loaded=!0};this.img.src=this.attribute("xlink:href").value;this.renderChildren=function(b){var c=this.attribute("x").Length.toPixels("x"),d=this.attribute("y").Length.toPixels("y"),f=this.attribute("width").Length.toPixels("x"),g=this.attribute("height").Length.toPixels("y");f==0||g==0||(b.save(),b.translate(c,d),a.AspectRatio(b,this.attribute("preserveAspectRatio").value,f,this.img.width,g,this.img.height,0,0),b.drawImage(this.img,0,0),b.restore())}};a.Element.image.prototype=new a.Element.RenderedElementBase; +a.Element.g=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getBoundingBox=function(){for(var c=new a.BoundingBox,b=0;b<this.children.length;b++)c.addBoundingBox(this.children[b].getBoundingBox());return c}};a.Element.g.prototype=new a.Element.RenderedElementBase;a.Element.symbol=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(c){this.baseSetContext(c);if(this.attribute("viewBox").hasValue()){var b= +a.ToNumberArray(this.attribute("viewBox").value),k=b[0],e=b[1];width=b[2];height=b[3];a.AspectRatio(c,this.attribute("preserveAspectRatio").value,this.attribute("width").Length.toPixels("x"),width,this.attribute("height").Length.toPixels("y"),height,k,e);a.ViewPort.SetCurrent(b[2],b[3])}}};a.Element.symbol.prototype=new a.Element.RenderedElementBase;a.Element.style=function(c){this.base=a.Element.ElementBase;this.base(c);for(var c=c.childNodes[0].nodeValue+(c.childNodes.length>1?c.childNodes[1].nodeValue: +""),c=c.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,""),c=a.compressSpaces(c),c=c.split("}"),d=0;d<c.length;d++)if(a.trim(c[d])!="")for(var b=c[d].split("{"),k=b[0].split(","),b=b[1].split(";"),e=0;e<k.length;e++){var f=a.trim(k[e]);if(f!=""){for(var g={},j=0;j<b.length;j++){var h=b[j].indexOf(":"),l=b[j].substr(0,h),h=b[j].substr(h+1,b[j].length-h);l!=null&&h!=null&&(g[a.trim(l)]=new a.Property(a.trim(l),a.trim(h)))}a.Styles[f]=g;if(f=="@font-face"){f=g["font-family"].value.replace(/"/g, +"");g=g.src.value.split(",");for(j=0;j<g.length;j++)if(g[j].indexOf('format("svg")')>0){l=g[j].indexOf("url");h=g[j].indexOf(")",l);l=g[j].substr(l+5,h-l-6);l=a.parseXml(a.ajax(l)).getElementsByTagName("font");for(h=0;h<l.length;h++){var o=a.CreateElement(l[h]);a.Definitions[f]=o}}}}}};a.Element.style.prototype=new a.Element.ElementBase;a.Element.use=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(a){this.baseSetContext(a); +this.attribute("x").hasValue()&&a.translate(this.attribute("x").Length.toPixels("x"),0);this.attribute("y").hasValue()&&a.translate(0,this.attribute("y").Length.toPixels("y"))};this.getDefinition=function(){var a=this.attribute("xlink:href").Definition.getDefinition();if(this.attribute("width").hasValue())a.attribute("width",!0).value=this.attribute("width").value;if(this.attribute("height").hasValue())a.attribute("height",!0).value=this.attribute("height").value;return a};this.path=function(a){var b= +this.getDefinition();b!=null&&b.path(a)};this.renderChildren=function(a){var b=this.getDefinition();b!=null&&b.render(a)}};a.Element.use.prototype=new a.Element.RenderedElementBase;a.Element.mask=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,b){var c=this.attribute("x").Length.toPixels("x"),e=this.attribute("y").Length.toPixels("y"),f=this.attribute("width").Length.toPixels("x"),g=this.attribute("height").Length.toPixels("y"),j=b.attribute("mask").value;b.attribute("mask").value= +"";var h=document.createElement("canvas");h.width=c+f;h.height=e+g;var l=h.getContext("2d");this.renderChildren(l);var o=document.createElement("canvas");o.width=c+f;o.height=e+g;var n=o.getContext("2d");b.render(n);n.globalCompositeOperation="destination-in";n.fillStyle=l.createPattern(h,"no-repeat");n.fillRect(0,0,c+f,e+g);a.fillStyle=n.createPattern(o,"no-repeat");a.fillRect(0,0,c+f,e+g);b.attribute("mask").value=j};this.render=function(){}};a.Element.mask.prototype=new a.Element.ElementBase;a.Element.clipPath= +function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a){for(var b=0;b<this.children.length;b++)this.children[b].path&&(this.children[b].path(a),a.clip())};this.render=function(){}};a.Element.clipPath.prototype=new a.Element.ElementBase;a.Element.filter=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,b){var c=b.getBoundingBox(),e=this.attribute("x").Length.toPixels("x"),f=this.attribute("y").Length.toPixels("y");if(e==0||f==0)e=c.x1,f=c.y1;var g= +this.attribute("width").Length.toPixels("x"),j=this.attribute("height").Length.toPixels("y");if(g==0||j==0)g=c.width(),j=c.height();c=b.style("filter").value;b.style("filter").value="";var h=0.2*g,l=0.2*j,o=document.createElement("canvas");o.width=g+2*h;o.height=j+2*l;var n=o.getContext("2d");n.translate(-e+h,-f+l);b.render(n);for(var q=0;q<this.children.length;q++)this.children[q].apply(n,0,0,g+2*h,j+2*l);a.drawImage(o,0,0,g+2*h,j+2*l,e-h,f-l,g+2*h,j+2*l);b.style("filter",!0).value=c};this.render= +function(){}};a.Element.filter.prototype=new a.Element.ElementBase;a.Element.feGaussianBlur=function(c){function d(a,c,d,f,g){for(var j=0;j<g;j++)for(var h=0;h<f;h++)for(var l=a[j*f*4+h*4+3]/255,o=0;o<4;o++){for(var n=d[0]*(l==0?255:a[j*f*4+h*4+o])*(l==0||o==3?1:l),q=1;q<d.length;q++){var p=Math.max(h-q,0),m=a[j*f*4+p*4+3]/255,p=Math.min(h+q,f-1),p=a[j*f*4+p*4+3]/255,s=d[q],r;m==0?r=255:(r=Math.max(h-q,0),r=a[j*f*4+r*4+o]);m=r*(m==0||o==3?1:m);p==0?r=255:(r=Math.min(h+q,f-1),r=a[j*f*4+r*4+o]);n+= +s*(m+r*(p==0||o==3?1:p))}c[h*g*4+j*4+o]=n}}this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,e,f,g){var e=this.attribute("stdDeviation").numValue(),c=a.getImageData(0,0,f,g),e=Math.max(e,0.01),j=Math.ceil(e*4)+1;mask=[];for(var h=0;h<j;h++)mask[h]=Math.exp(-0.5*(h/e)*(h/e));e=mask;j=0;for(h=1;h<e.length;h++)j+=Math.abs(e[h]);j=2*j+Math.abs(e[0]);for(h=0;h<e.length;h++)e[h]/=j;tmp=[];d(c.data,tmp,e,f,g);d(tmp,c.data,e,g,f);a.clearRect(0,0,f,g);a.putImageData(c,0,0)}};a.Element.filter.prototype= +new a.Element.feGaussianBlur;a.Element.title=function(){};a.Element.title.prototype=new a.Element.ElementBase;a.Element.desc=function(){};a.Element.desc.prototype=new a.Element.ElementBase;a.Element.MISSING=function(a){console.log("ERROR: Element '"+a.nodeName+"' not yet implemented.")};a.Element.MISSING.prototype=new a.Element.ElementBase;a.CreateElement=function(c){var d=c.nodeName.replace(/^[^:]+:/,""),d=d.replace(/\-/g,""),b=null,b=typeof a.Element[d]!="undefined"?new a.Element[d](c):new a.Element.MISSING(c); +b.type=c.nodeName;return b};a.load=function(c,d){a.loadXml(c,a.ajax(d))};a.loadXml=function(c,d){a.loadXmlDoc(c,a.parseXml(d))};a.loadXmlDoc=function(c,d){a.init(c);var b=function(a){for(var b=c.canvas;b;)a.x-=b.offsetLeft,a.y-=b.offsetTop,b=b.offsetParent;window.scrollX&&(a.x+=window.scrollX);window.scrollY&&(a.y+=window.scrollY);return a};if(a.opts.ignoreMouse!=!0)c.canvas.onclick=function(c){c=b(new a.Point(c!=null?c.clientX:event.clientX,c!=null?c.clientY:event.clientY));a.Mouse.onclick(c.x,c.y)}, +c.canvas.onmousemove=function(c){c=b(new a.Point(c!=null?c.clientX:event.clientX,c!=null?c.clientY:event.clientY));a.Mouse.onmousemove(c.x,c.y)};var k=a.CreateElement(d.documentElement),e=k.root=!0,f=function(){a.ViewPort.Clear();c.canvas.parentNode&&a.ViewPort.SetCurrent(c.canvas.parentNode.clientWidth,c.canvas.parentNode.clientHeight);if(a.opts.ignoreDimensions!=!0){if(k.style("width").hasValue())c.canvas.width=k.style("width").Length.toPixels("x"),c.canvas.style.width=c.canvas.width+"px";if(k.style("height").hasValue())c.canvas.height= +k.style("height").Length.toPixels("y"),c.canvas.style.height=c.canvas.height+"px"}var b=c.canvas.clientWidth||c.canvas.width,d=c.canvas.clientHeight||c.canvas.height;a.ViewPort.SetCurrent(b,d);if(a.opts!=null&&a.opts.offsetX!=null)k.attribute("x",!0).value=a.opts.offsetX;if(a.opts!=null&&a.opts.offsetY!=null)k.attribute("y",!0).value=a.opts.offsetY;if(a.opts!=null&&a.opts.scaleWidth!=null&&a.opts.scaleHeight!=null){var f=1,g=1;k.attribute("width").hasValue()&&(f=k.attribute("width").Length.toPixels("x")/ +a.opts.scaleWidth);k.attribute("height").hasValue()&&(g=k.attribute("height").Length.toPixels("y")/a.opts.scaleHeight);k.attribute("width",!0).value=a.opts.scaleWidth;k.attribute("height",!0).value=a.opts.scaleHeight;k.attribute("viewBox",!0).value="0 0 "+b*f+" "+d*g;k.attribute("preserveAspectRatio",!0).value="none"}a.opts.ignoreClear!=!0&&c.clearRect(0,0,b,d);k.render(c);e&&(e=!1,a.opts!=null&&typeof a.opts.renderCallback=="function"&&a.opts.renderCallback())},g=!0;a.ImagesLoaded()&&(g=!1,f()); +a.intervalID=setInterval(function(){var b=!1;g&&a.ImagesLoaded()&&(g=!1,b=!0);a.opts.ignoreMouse!=!0&&(b|=a.Mouse.hasEvents());if(a.opts.ignoreAnimation!=!0)for(var c=0;c<a.Animations.length;c++)b|=a.Animations[c].update(1E3/a.FRAMERATE);a.opts!=null&&typeof a.opts.forceRedraw=="function"&&a.opts.forceRedraw()==!0&&(b=!0);b&&(f(),a.Mouse.runEvents())},1E3/a.FRAMERATE)};a.stop=function(){a.intervalID&&clearInterval(a.intervalID)};a.Mouse=new function(){this.events=[];this.hasEvents=function(){return this.events.length!= +0};this.onclick=function(a,d){this.events.push({type:"onclick",x:a,y:d,run:function(a){if(a.onclick)a.onclick()}})};this.onmousemove=function(a,d){this.events.push({type:"onmousemove",x:a,y:d,run:function(a){if(a.onmousemove)a.onmousemove()}})};this.eventElements=[];this.checkPath=function(a,d){for(var b=0;b<this.events.length;b++){var k=this.events[b];d.isPointInPath&&d.isPointInPath(k.x,k.y)&&(this.eventElements[b]=a)}};this.checkBoundingBox=function(a,d){for(var b=0;b<this.events.length;b++){var k= +this.events[b];d.isPointInBox(k.x,k.y)&&(this.eventElements[b]=a)}};this.runEvents=function(){a.ctx.canvas.style.cursor="";for(var c=0;c<this.events.length;c++)for(var d=this.events[c],b=this.eventElements[c];b;)d.run(b),b=b.parent;this.events=[];this.eventElements=[]}};return a}this.canvg=function(a,c,d){if(a==null&&c==null&&d==null)for(var c=document.getElementsByTagName("svg"),b=0;b<c.length;b++){a=c[b];d=document.createElement("canvas");d.width=a.clientWidth;d.height=a.clientHeight;a.parentNode.insertBefore(d, +a);a.parentNode.removeChild(a);var k=document.createElement("div");k.appendChild(a);canvg(d,k.innerHTML)}else d=d||{},typeof a=="string"&&(a=document.getElementById(a)),a.svg==null?(b=m(),a.svg=b):(b=a.svg,b.stop()),b.opts=d,a=a.getContext("2d"),typeof c.documentElement!="undefined"?b.loadXmlDoc(a,c):c.substr(0,1)=="<"?b.loadXml(a,c):b.load(a,c)}})(); +if(CanvasRenderingContext2D)CanvasRenderingContext2D.prototype.drawSvg=function(m,a,c,d,b){canvg(this.canvas,m,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:a,offsetY:c,scaleWidth:d,scaleHeight:b})}; +(function(m){var a=m.css,c=m.CanVGRenderer,d=m.SVGRenderer,b=m.extend,k=m.merge,e=m.addEvent,f=m.createElement,g=m.discardElement;b(c.prototype,d.prototype);b(c.prototype,{create:function(a,b,c,d){this.setContainer(b,c,d);this.configure(a)},setContainer:function(a,b,c){var d=a.style,e=a.parentNode,g=d.left,d=d.top,k=a.offsetWidth,m=a.offsetHeight,s={visibility:"hidden",position:"absolute"};this.init.apply(this,[a,b,c]);this.canvas=f("canvas",{width:k,height:m},{position:"relative",left:g,top:d},a); +this.ttLine=f("div",null,s,e);this.ttDiv=f("div",null,s,e);this.ttTimer=void 0;this.hiddenSvg=a=f("div",{width:k,height:m},{visibility:"hidden",left:g,top:d},e);a.appendChild(this.box)},configure:function(b){var c=this,d=b.options.tooltip,f=d.borderWidth,g=c.ttDiv,m=d.style,p=c.ttLine,t=parseInt(m.padding,10),m=k(m,{padding:t+"px","background-color":d.backgroundColor,"border-style":"solid","border-width":f+"px","border-radius":d.borderRadius+"px"});d.shadow&&(m=k(m,{"box-shadow":"1px 1px 3px gray", +"-webkit-box-shadow":"1px 1px 3px gray"}));a(g,m);a(p,{"border-left":"1px solid darkgray"});e(b,"tooltipRefresh",function(d){var e=b.container,f=e.offsetLeft,e=e.offsetTop,k;g.innerHTML=d.text;k=b.tooltip.getPosition(g.offsetWidth,g.offsetHeight,{plotX:d.x,plotY:d.y});a(g,{visibility:"visible",left:k.x+"px",top:k.y+"px","border-color":d.borderColor});a(p,{visibility:"visible",left:f+d.x+"px",top:e+b.plotTop+"px",height:b.plotHeight+"px"});c.ttTimer!==void 0&&clearTimeout(c.ttTimer);c.ttTimer=setTimeout(function(){a(g, +{visibility:"hidden"});a(p,{visibility:"hidden"})},3E3)})},destroy:function(){g(this.canvas);this.ttTimer!==void 0&&clearTimeout(this.ttTimer);g(this.ttLine);g(this.ttDiv);g(this.hiddenSvg);return d.prototype.destroy.apply(this)},color:function(a,b,c){a&&a.linearGradient&&(a=a.stops[a.stops.length-1][1]);return d.prototype.color.call(this,a,b,c)},draw:function(){window.canvg(this.canvas,this.hiddenSvg.innerHTML)}})})(Highcharts); diff --git a/html/includes/js/modules/canvas-tools.src.js b/html/includes/js/modules/canvas-tools.src.js new file mode 100644 index 0000000..3725c02 --- /dev/null +++ b/html/includes/js/modules/canvas-tools.src.js @@ -0,0 +1,3113 @@ +/** + * @license A class to parse color values + * @author Stoyan Stefanov <sstoo@gmail.com> + * @link http://www.phpied.com/rgb-color-parser-in-javascript/ + * Use it if you like it + * + */ +function RGBColor(color_string) +{ + this.ok = false; + + // strip any leading # + if (color_string.charAt(0) == '#') { // remove # if any + color_string = color_string.substr(1,6); + } + + color_string = color_string.replace(/ /g,''); + color_string = color_string.toLowerCase(); + + // before getting into regexps, try simple matches + // and overwrite the input + var simple_colors = { + aliceblue: 'f0f8ff', + antiquewhite: 'faebd7', + aqua: '00ffff', + aquamarine: '7fffd4', + azure: 'f0ffff', + beige: 'f5f5dc', + bisque: 'ffe4c4', + black: '000000', + blanchedalmond: 'ffebcd', + blue: '0000ff', + blueviolet: '8a2be2', + brown: 'a52a2a', + burlywood: 'deb887', + cadetblue: '5f9ea0', + chartreuse: '7fff00', + chocolate: 'd2691e', + coral: 'ff7f50', + cornflowerblue: '6495ed', + cornsilk: 'fff8dc', + crimson: 'dc143c', + cyan: '00ffff', + darkblue: '00008b', + darkcyan: '008b8b', + darkgoldenrod: 'b8860b', + darkgray: 'a9a9a9', + darkgreen: '006400', + darkkhaki: 'bdb76b', + darkmagenta: '8b008b', + darkolivegreen: '556b2f', + darkorange: 'ff8c00', + darkorchid: '9932cc', + darkred: '8b0000', + darksalmon: 'e9967a', + darkseagreen: '8fbc8f', + darkslateblue: '483d8b', + darkslategray: '2f4f4f', + darkturquoise: '00ced1', + darkviolet: '9400d3', + deeppink: 'ff1493', + deepskyblue: '00bfff', + dimgray: '696969', + dodgerblue: '1e90ff', + feldspar: 'd19275', + firebrick: 'b22222', + floralwhite: 'fffaf0', + forestgreen: '228b22', + fuchsia: 'ff00ff', + gainsboro: 'dcdcdc', + ghostwhite: 'f8f8ff', + gold: 'ffd700', + goldenrod: 'daa520', + gray: '808080', + green: '008000', + greenyellow: 'adff2f', + honeydew: 'f0fff0', + hotpink: 'ff69b4', + indianred : 'cd5c5c', + indigo : '4b0082', + ivory: 'fffff0', + khaki: 'f0e68c', + lavender: 'e6e6fa', + lavenderblush: 'fff0f5', + lawngreen: '7cfc00', + lemonchiffon: 'fffacd', + lightblue: 'add8e6', + lightcoral: 'f08080', + lightcyan: 'e0ffff', + lightgoldenrodyellow: 'fafad2', + lightgrey: 'd3d3d3', + lightgreen: '90ee90', + lightpink: 'ffb6c1', + lightsalmon: 'ffa07a', + lightseagreen: '20b2aa', + lightskyblue: '87cefa', + lightslateblue: '8470ff', + lightslategray: '778899', + lightsteelblue: 'b0c4de', + lightyellow: 'ffffe0', + lime: '00ff00', + limegreen: '32cd32', + linen: 'faf0e6', + magenta: 'ff00ff', + maroon: '800000', + mediumaquamarine: '66cdaa', + mediumblue: '0000cd', + mediumorchid: 'ba55d3', + mediumpurple: '9370d8', + mediumseagreen: '3cb371', + mediumslateblue: '7b68ee', + mediumspringgreen: '00fa9a', + mediumturquoise: '48d1cc', + mediumvioletred: 'c71585', + midnightblue: '191970', + mintcream: 'f5fffa', + mistyrose: 'ffe4e1', + moccasin: 'ffe4b5', + navajowhite: 'ffdead', + navy: '000080', + oldlace: 'fdf5e6', + olive: '808000', + olivedrab: '6b8e23', + orange: 'ffa500', + orangered: 'ff4500', + orchid: 'da70d6', + palegoldenrod: 'eee8aa', + palegreen: '98fb98', + paleturquoise: 'afeeee', + palevioletred: 'd87093', + papayawhip: 'ffefd5', + peachpuff: 'ffdab9', + peru: 'cd853f', + pink: 'ffc0cb', + plum: 'dda0dd', + powderblue: 'b0e0e6', + purple: '800080', + red: 'ff0000', + rosybrown: 'bc8f8f', + royalblue: '4169e1', + saddlebrown: '8b4513', + salmon: 'fa8072', + sandybrown: 'f4a460', + seagreen: '2e8b57', + seashell: 'fff5ee', + sienna: 'a0522d', + silver: 'c0c0c0', + skyblue: '87ceeb', + slateblue: '6a5acd', + slategray: '708090', + snow: 'fffafa', + springgreen: '00ff7f', + steelblue: '4682b4', + tan: 'd2b48c', + teal: '008080', + thistle: 'd8bfd8', + tomato: 'ff6347', + turquoise: '40e0d0', + violet: 'ee82ee', + violetred: 'd02090', + wheat: 'f5deb3', + white: 'ffffff', + whitesmoke: 'f5f5f5', + yellow: 'ffff00', + yellowgreen: '9acd32' + }; + for (var key in simple_colors) { + if (color_string == key) { + color_string = simple_colors[key]; + } + } + // emd of simple type-in colors + + // array of color definition objects + var color_defs = [ + { + re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, + example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], + process: function (bits){ + return [ + parseInt(bits[1]), + parseInt(bits[2]), + parseInt(bits[3]) + ]; + } + }, + { + re: /^(\w{2})(\w{2})(\w{2})$/, + example: ['#00ff00', '336699'], + process: function (bits){ + return [ + parseInt(bits[1], 16), + parseInt(bits[2], 16), + parseInt(bits[3], 16) + ]; + } + }, + { + re: /^(\w{1})(\w{1})(\w{1})$/, + example: ['#fb0', 'f0f'], + process: function (bits){ + return [ + parseInt(bits[1] + bits[1], 16), + parseInt(bits[2] + bits[2], 16), + parseInt(bits[3] + bits[3], 16) + ]; + } + } + ]; + + // search through the definitions to find a match + for (var i = 0; i < color_defs.length; i++) { + var re = color_defs[i].re; + var processor = color_defs[i].process; + var bits = re.exec(color_string); + if (bits) { + channels = processor(bits); + this.r = channels[0]; + this.g = channels[1]; + this.b = channels[2]; + this.ok = true; + } + + } + + // validate/cleanup values + this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r); + this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g); + this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b); + + // some getters + this.toRGB = function () { + return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')'; + } + this.toHex = function () { + var r = this.r.toString(16); + var g = this.g.toString(16); + var b = this.b.toString(16); + if (r.length == 1) r = '0' + r; + if (g.length == 1) g = '0' + g; + if (b.length == 1) b = '0' + b; + return '#' + r + g + b; + } + + // help + this.getHelpXML = function () { + + var examples = new Array(); + // add regexps + for (var i = 0; i < color_defs.length; i++) { + var example = color_defs[i].example; + for (var j = 0; j < example.length; j++) { + examples[examples.length] = example[j]; + } + } + // add type-in colors + for (var sc in simple_colors) { + examples[examples.length] = sc; + } + + var xml = document.createElement('ul'); + xml.setAttribute('id', 'rgbcolor-examples'); + for (var i = 0; i < examples.length; i++) { + try { + var list_item = document.createElement('li'); + var list_color = new RGBColor(examples[i]); + var example_div = document.createElement('div'); + example_div.style.cssText = + 'margin: 3px; ' + + 'border: 1px solid black; ' + + 'background:' + list_color.toHex() + '; ' + + 'color:' + list_color.toHex() + ; + example_div.appendChild(document.createTextNode('test')); + var list_item_value = document.createTextNode( + ' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex() + ); + list_item.appendChild(example_div); + list_item.appendChild(list_item_value); + xml.appendChild(list_item); + + } catch(e){} + } + return xml; + + } + +} + +/** + * @license canvg.js - Javascript SVG parser and renderer on Canvas + * MIT Licensed + * Gabe Lerner (gabelerner@gmail.com) + * http://code.google.com/p/canvg/ + * + * Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/ + * + */ +if(!window.console) { + window.console = {}; + window.console.log = function(str) {}; + window.console.dir = function(str) {}; +} + +if(!Array.prototype.indexOf){ + Array.prototype.indexOf = function(obj){ + for(var i=0; i<this.length; i++){ + if(this[i]==obj){ + return i; + } + } + return -1; + } +} + +(function(){ + // canvg(target, s) + // empty parameters: replace all 'svg' elements on page with 'canvas' elements + // target: canvas element or the id of a canvas element + // s: svg string, url to svg file, or xml document + // opts: optional hash of options + // ignoreMouse: true => ignore mouse events + // ignoreAnimation: true => ignore animations + // ignoreDimensions: true => does not try to resize canvas + // ignoreClear: true => does not clear canvas + // offsetX: int => draws at a x offset + // offsetY: int => draws at a y offset + // scaleWidth: int => scales horizontally to width + // scaleHeight: int => scales vertically to height + // renderCallback: function => will call the function after the first render is completed + // forceRedraw: function => will call the function on every frame, if it returns true, will redraw + this.canvg = function (target, s, opts) { + // no parameters + if (target == null && s == null && opts == null) { + var svgTags = document.getElementsByTagName('svg'); + for (var i=0; i<svgTags.length; i++) { + var svgTag = svgTags[i]; + var c = document.createElement('canvas'); + c.width = svgTag.clientWidth; + c.height = svgTag.clientHeight; + svgTag.parentNode.insertBefore(c, svgTag); + svgTag.parentNode.removeChild(svgTag); + var div = document.createElement('div'); + div.appendChild(svgTag); + canvg(c, div.innerHTML); + } + return; + } + opts = opts || {}; + + if (typeof target == 'string') { + target = document.getElementById(target); + } + + // reuse class per canvas + var svg; + if (target.svg == null) { + svg = build(); + target.svg = svg; + } + else { + svg = target.svg; + svg.stop(); + } + svg.opts = opts; + + var ctx = target.getContext('2d'); + if (typeof(s.documentElement) != 'undefined') { + // load from xml doc + svg.loadXmlDoc(ctx, s); + } + else if (s.substr(0,1) == '<') { + // load from xml string + svg.loadXml(ctx, s); + } + else { + // load from url + svg.load(ctx, s); + } + } + + function build() { + var svg = { }; + + svg.FRAMERATE = 30; + svg.MAX_VIRTUAL_PIXELS = 30000; + + // globals + svg.init = function(ctx) { + svg.Definitions = {}; + svg.Styles = {}; + svg.Animations = []; + svg.Images = []; + svg.ctx = ctx; + svg.ViewPort = new (function () { + this.viewPorts = []; + this.Clear = function() { this.viewPorts = []; } + this.SetCurrent = function(width, height) { this.viewPorts.push({ width: width, height: height }); } + this.RemoveCurrent = function() { this.viewPorts.pop(); } + this.Current = function() { return this.viewPorts[this.viewPorts.length - 1]; } + this.width = function() { return this.Current().width; } + this.height = function() { return this.Current().height; } + this.ComputeSize = function(d) { + if (d != null && typeof(d) == 'number') return d; + if (d == 'x') return this.width(); + if (d == 'y') return this.height(); + return Math.sqrt(Math.pow(this.width(), 2) + Math.pow(this.height(), 2)) / Math.sqrt(2); + } + }); + } + svg.init(); + + // images loaded + svg.ImagesLoaded = function() { + for (var i=0; i<svg.Images.length; i++) { + if (!svg.Images[i].loaded) return false; + } + return true; + } + + // trim + svg.trim = function(s) { return s.replace(/^\s+|\s+$/g, ''); } + + // compress spaces + svg.compressSpaces = function(s) { return s.replace(/[\s\r\t\n]+/gm,' '); } + + // ajax + svg.ajax = function(url) { + var AJAX; + if(window.XMLHttpRequest){AJAX=new XMLHttpRequest();} + else{AJAX=new ActiveXObject('Microsoft.XMLHTTP');} + if(AJAX){ + AJAX.open('GET',url,false); + AJAX.send(null); + return AJAX.responseText; + } + return null; + } + + // parse xml + svg.parseXml = function(xml) { + if (window.DOMParser) + { + var parser = new DOMParser(); + return parser.parseFromString(xml, 'text/xml'); + } + else + { + xml = xml.replace(/<!DOCTYPE svg[^>]*>/, ''); + var xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); + xmlDoc.async = 'false'; + xmlDoc.loadXML(xml); + return xmlDoc; + } + } + + svg.Property = function(name, value) { + this.name = name; + this.value = value; + + this.hasValue = function() { + return (this.value != null && this.value !== ''); + } + + // return the numerical value of the property + this.numValue = function() { + if (!this.hasValue()) return 0; + + var n = parseFloat(this.value); + if ((this.value + '').match(/%$/)) { + n = n / 100.0; + } + return n; + } + + this.valueOrDefault = function(def) { + if (this.hasValue()) return this.value; + return def; + } + + this.numValueOrDefault = function(def) { + if (this.hasValue()) return this.numValue(); + return def; + } + + /* EXTENSIONS */ + var that = this; + + // color extensions + this.Color = { + // augment the current color value with the opacity + addOpacity: function(opacity) { + var newValue = that.value; + if (opacity != null && opacity != '') { + var color = new RGBColor(that.value); + if (color.ok) { + newValue = 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + opacity + ')'; + } + } + return new svg.Property(that.name, newValue); + } + } + + // definition extensions + this.Definition = { + // get the definition from the definitions table + getDefinition: function() { + var name = that.value.replace(/^(url\()?#([^\)]+)\)?$/, '$2'); + return svg.Definitions[name]; + }, + + isUrl: function() { + return that.value.indexOf('url(') == 0 + }, + + getFillStyle: function(e) { + var def = this.getDefinition(); + + // gradient + if (def != null && def.createGradient) { + return def.createGradient(svg.ctx, e); + } + + // pattern + if (def != null && def.createPattern) { + return def.createPattern(svg.ctx, e); + } + + return null; + } + } + + // length extensions + this.Length = { + DPI: function(viewPort) { + return 96.0; // TODO: compute? + }, + + EM: function(viewPort) { + var em = 12; + + var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize); + if (fontSize.hasValue()) em = fontSize.Length.toPixels(viewPort); + + return em; + }, + + // get the length as pixels + toPixels: function(viewPort) { + if (!that.hasValue()) return 0; + var s = that.value+''; + if (s.match(/em$/)) return that.numValue() * this.EM(viewPort); + if (s.match(/ex$/)) return that.numValue() * this.EM(viewPort) / 2.0; + if (s.match(/px$/)) return that.numValue(); + if (s.match(/pt$/)) return that.numValue() * 1.25; + if (s.match(/pc$/)) return that.numValue() * 15; + if (s.match(/cm$/)) return that.numValue() * this.DPI(viewPort) / 2.54; + if (s.match(/mm$/)) return that.numValue() * this.DPI(viewPort) / 25.4; + if (s.match(/in$/)) return that.numValue() * this.DPI(viewPort); + if (s.match(/%$/)) return that.numValue() * svg.ViewPort.ComputeSize(viewPort); + return that.numValue(); + } + } + + // time extensions + this.Time = { + // get the time as milliseconds + toMilliseconds: function() { + if (!that.hasValue()) return 0; + var s = that.value+''; + if (s.match(/s$/)) return that.numValue() * 1000; + if (s.match(/ms$/)) return that.numValue(); + return that.numValue(); + } + } + + // angle extensions + this.Angle = { + // get the angle as radians + toRadians: function() { + if (!that.hasValue()) return 0; + var s = that.value+''; + if (s.match(/deg$/)) return that.numValue() * (Math.PI / 180.0); + if (s.match(/grad$/)) return that.numValue() * (Math.PI / 200.0); + if (s.match(/rad$/)) return that.numValue(); + return that.numValue() * (Math.PI / 180.0); + } + } + } + + // fonts + svg.Font = new (function() { + this.Styles = ['normal','italic','oblique','inherit']; + this.Variants = ['normal','small-caps','inherit']; + this.Weights = ['normal','bold','bolder','lighter','100','200','300','400','500','600','700','800','900','inherit']; + + this.CreateFont = function(fontStyle, fontVariant, fontWeight, fontSize, fontFamily, inherit) { + var f = inherit != null ? this.Parse(inherit) : this.CreateFont('', '', '', '', '', svg.ctx.font); + return { + fontFamily: fontFamily || f.fontFamily, + fontSize: fontSize || f.fontSize, + fontStyle: fontStyle || f.fontStyle, + fontWeight: fontWeight || f.fontWeight, + fontVariant: fontVariant || f.fontVariant, + toString: function () { return [this.fontStyle, this.fontVariant, this.fontWeight, this.fontSize, this.fontFamily].join(' ') } + } + } + + var that = this; + this.Parse = function(s) { + var f = {}; + var d = svg.trim(svg.compressSpaces(s || '')).split(' '); + var set = { fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false } + var ff = ''; + for (var i=0; i<d.length; i++) { + if (!set.fontStyle && that.Styles.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontStyle = d[i]; set.fontStyle = true; } + else if (!set.fontVariant && that.Variants.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontVariant = d[i]; set.fontStyle = set.fontVariant = true; } + else if (!set.fontWeight && that.Weights.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontWeight = d[i]; set.fontStyle = set.fontVariant = set.fontWeight = true; } + else if (!set.fontSize) { if (d[i] != 'inherit') f.fontSize = d[i].split('/')[0]; set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true; } + else { if (d[i] != 'inherit') ff += d[i]; } + } if (ff != '') f.fontFamily = ff; + return f; + } + }); + + // points and paths + svg.ToNumberArray = function(s) { + var a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' '); + for (var i=0; i<a.length; i++) { + a[i] = parseFloat(a[i]); + } + return a; + } + svg.Point = function(x, y) { + this.x = x; + this.y = y; + + this.angleTo = function(p) { + return Math.atan2(p.y - this.y, p.x - this.x); + } + + this.applyTransform = function(v) { + var xp = this.x * v[0] + this.y * v[2] + v[4]; + var yp = this.x * v[1] + this.y * v[3] + v[5]; + this.x = xp; + this.y = yp; + } + } + svg.CreatePoint = function(s) { + var a = svg.ToNumberArray(s); + return new svg.Point(a[0], a[1]); + } + svg.CreatePath = function(s) { + var a = svg.ToNumberArray(s); + var path = []; + for (var i=0; i<a.length; i+=2) { + path.push(new svg.Point(a[i], a[i+1])); + } + return path; + } + + // bounding box + svg.BoundingBox = function(x1, y1, x2, y2) { // pass in initial points if you want + this.x1 = Number.NaN; + this.y1 = Number.NaN; + this.x2 = Number.NaN; + this.y2 = Number.NaN; + + this.x = function() { return this.x1; } + this.y = function() { return this.y1; } + this.width = function() { return this.x2 - this.x1; } + this.height = function() { return this.y2 - this.y1; } + + this.addPoint = function(x, y) { + if (x != null) { + if (isNaN(this.x1) || isNaN(this.x2)) { + this.x1 = x; + this.x2 = x; + } + if (x < this.x1) this.x1 = x; + if (x > this.x2) this.x2 = x; + } + + if (y != null) { + if (isNaN(this.y1) || isNaN(this.y2)) { + this.y1 = y; + this.y2 = y; + } + if (y < this.y1) this.y1 = y; + if (y > this.y2) this.y2 = y; + } + } + this.addX = function(x) { this.addPoint(x, null); } + this.addY = function(y) { this.addPoint(null, y); } + + this.addBoundingBox = function(bb) { + this.addPoint(bb.x1, bb.y1); + this.addPoint(bb.x2, bb.y2); + } + + this.addQuadraticCurve = function(p0x, p0y, p1x, p1y, p2x, p2y) { + var cp1x = p0x + 2/3 * (p1x - p0x); // CP1 = QP0 + 2/3 *(QP1-QP0) + var cp1y = p0y + 2/3 * (p1y - p0y); // CP1 = QP0 + 2/3 *(QP1-QP0) + var cp2x = cp1x + 1/3 * (p2x - p0x); // CP2 = CP1 + 1/3 *(QP2-QP0) + var cp2y = cp1y + 1/3 * (p2y - p0y); // CP2 = CP1 + 1/3 *(QP2-QP0) + this.addBezierCurve(p0x, p0y, cp1x, cp2x, cp1y, cp2y, p2x, p2y); + } + + this.addBezierCurve = function(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) { + // from http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html + var p0 = [p0x, p0y], p1 = [p1x, p1y], p2 = [p2x, p2y], p3 = [p3x, p3y]; + this.addPoint(p0[0], p0[1]); + this.addPoint(p3[0], p3[1]); + + for (i=0; i<=1; i++) { + var f = function(t) { + return Math.pow(1-t, 3) * p0[i] + + 3 * Math.pow(1-t, 2) * t * p1[i] + + 3 * (1-t) * Math.pow(t, 2) * p2[i] + + Math.pow(t, 3) * p3[i]; + } + + var b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i]; + var a = -3 * p0[i] + 9 * p1[i] - 9 * p2[i] + 3 * p3[i]; + var c = 3 * p1[i] - 3 * p0[i]; + + if (a == 0) { + if (b == 0) continue; + var t = -c / b; + if (0 < t && t < 1) { + if (i == 0) this.addX(f(t)); + if (i == 1) this.addY(f(t)); + } + continue; + } + + var b2ac = Math.pow(b, 2) - 4 * c * a; + if (b2ac < 0) continue; + var t1 = (-b + Math.sqrt(b2ac)) / (2 * a); + if (0 < t1 && t1 < 1) { + if (i == 0) this.addX(f(t1)); + if (i == 1) this.addY(f(t1)); + } + var t2 = (-b - Math.sqrt(b2ac)) / (2 * a); + if (0 < t2 && t2 < 1) { + if (i == 0) this.addX(f(t2)); + if (i == 1) this.addY(f(t2)); + } + } + } + + this.isPointInBox = function(x, y) { + return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2); + } + + this.addPoint(x1, y1); + this.addPoint(x2, y2); + } + + // transforms + svg.Transform = function(v) { + var that = this; + this.Type = {} + + // translate + this.Type.translate = function(s) { + this.p = svg.CreatePoint(s); + this.apply = function(ctx) { + ctx.translate(this.p.x || 0.0, this.p.y || 0.0); + } + this.applyToPoint = function(p) { + p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]); + } + } + + // rotate + this.Type.rotate = function(s) { + var a = svg.ToNumberArray(s); + this.angle = new svg.Property('angle', a[0]); + this.cx = a[1] || 0; + this.cy = a[2] || 0; + this.apply = function(ctx) { + ctx.translate(this.cx, this.cy); + ctx.rotate(this.angle.Angle.toRadians()); + ctx.translate(-this.cx, -this.cy); + } + this.applyToPoint = function(p) { + var a = this.angle.Angle.toRadians(); + p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]); + p.applyTransform([Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]); + p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]); + } + } + + this.Type.scale = function(s) { + this.p = svg.CreatePoint(s); + this.apply = function(ctx) { + ctx.scale(this.p.x || 1.0, this.p.y || this.p.x || 1.0); + } + this.applyToPoint = function(p) { + p.applyTransform([this.p.x || 0.0, 0, 0, this.p.y || 0.0, 0, 0]); + } + } + + this.Type.matrix = function(s) { + this.m = svg.ToNumberArray(s); + this.apply = function(ctx) { + ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]); + } + this.applyToPoint = function(p) { + p.applyTransform(this.m); + } + } + + this.Type.SkewBase = function(s) { + this.base = that.Type.matrix; + this.base(s); + this.angle = new svg.Property('angle', s); + } + this.Type.SkewBase.prototype = new this.Type.matrix; + + this.Type.skewX = function(s) { + this.base = that.Type.SkewBase; + this.base(s); + this.m = [1, 0, Math.tan(this.angle.Angle.toRadians()), 1, 0, 0]; + } + this.Type.skewX.prototype = new this.Type.SkewBase; + + this.Type.skewY = function(s) { + this.base = that.Type.SkewBase; + this.base(s); + this.m = [1, Math.tan(this.angle.Angle.toRadians()), 0, 1, 0, 0]; + } + this.Type.skewY.prototype = new this.Type.SkewBase; + + this.transforms = []; + + this.apply = function(ctx) { + for (var i=0; i<this.transforms.length; i++) { + this.transforms[i].apply(ctx); + } + } + + this.applyToPoint = function(p) { + for (var i=0; i<this.transforms.length; i++) { + this.transforms[i].applyToPoint(p); + } + } + + var data = svg.trim(svg.compressSpaces(v)).split(/\s(?=[a-z])/); + for (var i=0; i<data.length; i++) { + var type = data[i].split('(')[0]; + var s = data[i].split('(')[1].replace(')',''); + var transform = new this.Type[type](s); + this.transforms.push(transform); + } + } + + // aspect ratio + svg.AspectRatio = function(ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY) { + // aspect ratio - http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute + aspectRatio = svg.compressSpaces(aspectRatio); + aspectRatio = aspectRatio.replace(/^defer\s/,''); // ignore defer + var align = aspectRatio.split(' ')[0] || 'xMidYMid'; + var meetOrSlice = aspectRatio.split(' ')[1] || 'meet'; + + // calculate scale + var scaleX = width / desiredWidth; + var scaleY = height / desiredHeight; + var scaleMin = Math.min(scaleX, scaleY); + var scaleMax = Math.max(scaleX, scaleY); + if (meetOrSlice == 'meet') { desiredWidth *= scaleMin; desiredHeight *= scaleMin; } + if (meetOrSlice == 'slice') { desiredWidth *= scaleMax; desiredHeight *= scaleMax; } + + refX = new svg.Property('refX', refX); + refY = new svg.Property('refY', refY); + if (refX.hasValue() && refY.hasValue()) { + ctx.translate(-scaleMin * refX.Length.toPixels('x'), -scaleMin * refY.Length.toPixels('y')); + } + else { + // align + if (align.match(/^xMid/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0); + if (align.match(/YMid$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0); + if (align.match(/^xMax/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width - desiredWidth, 0); + if (align.match(/YMax$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height - desiredHeight); + } + + // scale + if (align == 'none') ctx.scale(scaleX, scaleY); + else if (meetOrSlice == 'meet') ctx.scale(scaleMin, scaleMin); + else if (meetOrSlice == 'slice') ctx.scale(scaleMax, scaleMax); + + // translate + ctx.translate(minX == null ? 0 : -minX, minY == null ? 0 : -minY); + } + + // elements + svg.Element = {} + + svg.Element.ElementBase = function(node) { + this.attributes = {}; + this.styles = {}; + this.children = []; + + // get or create attribute + this.attribute = function(name, createIfNotExists) { + var a = this.attributes[name]; + if (a != null) return a; + + a = new svg.Property(name, ''); + if (createIfNotExists == true) this.attributes[name] = a; + return a; + } + + // get or create style, crawls up node tree + this.style = function(name, createIfNotExists) { + var s = this.styles[name]; + if (s != null) return s; + + var a = this.attribute(name); + if (a != null && a.hasValue()) { + return a; + } + + var p = this.parent; + if (p != null) { + var ps = p.style(name); + if (ps != null && ps.hasValue()) { + return ps; + } + } + + s = new svg.Property(name, ''); + if (createIfNotExists == true) this.styles[name] = s; + return s; + } + + // base render + this.render = function(ctx) { + // don't render display=none + if (this.style('display').value == 'none') return; + + // don't render visibility=hidden + if (this.attribute('visibility').value == 'hidden') return; + + ctx.save(); + this.setContext(ctx); + // mask + if (this.attribute('mask').hasValue()) { + var mask = this.attribute('mask').Definition.getDefinition(); + if (mask != null) mask.apply(ctx, this); + } + else if (this.style('filter').hasValue()) { + var filter = this.style('filter').Definition.getDefinition(); + if (filter != null) filter.apply(ctx, this); + } + else this.renderChildren(ctx); + this.clearContext(ctx); + ctx.restore(); + } + + // base set context + this.setContext = function(ctx) { + // OVERRIDE ME! + } + + // base clear context + this.clearContext = function(ctx) { + // OVERRIDE ME! + } + + // base render children + this.renderChildren = function(ctx) { + for (var i=0; i<this.children.length; i++) { + this.children[i].render(ctx); + } + } + + this.addChild = function(childNode, create) { + var child = childNode; + if (create) child = svg.CreateElement(childNode); + child.parent = this; + this.children.push(child); + } + + if (node != null && node.nodeType == 1) { //ELEMENT_NODE + // add children + for (var i=0; i<node.childNodes.length; i++) { + var childNode = node.childNodes[i]; + if (childNode.nodeType == 1) this.addChild(childNode, true); //ELEMENT_NODE + } + + // add attributes + for (var i=0; i<node.attributes.length; i++) { + var attribute = node.attributes[i]; + this.attributes[attribute.nodeName] = new svg.Property(attribute.nodeName, attribute.nodeValue); + } + + // add tag styles + var styles = svg.Styles[node.nodeName]; + if (styles != null) { + for (var name in styles) { + this.styles[name] = styles[name]; + } + } + + // add class styles + if (this.attribute('class').hasValue()) { + var classes = svg.compressSpaces(this.attribute('class').value).split(' '); + for (var j=0; j<classes.length; j++) { + styles = svg.Styles['.'+classes[j]]; + if (styles != null) { + for (var name in styles) { + this.styles[name] = styles[name]; + } + } + styles = svg.Styles[node.nodeName+'.'+classes[j]]; + if (styles != null) { + for (var name in styles) { + this.styles[name] = styles[name]; + } + } + } + } + + // add inline styles + if (this.attribute('style').hasValue()) { + var styles = this.attribute('style').value.split(';'); + for (var i=0; i<styles.length; i++) { + if (svg.trim(styles[i]) != '') { + var style = styles[i].split(':'); + var name = svg.trim(style[0]); + var value = svg.trim(style[1]); + this.styles[name] = new svg.Property(name, value); + } + } + } + + // add id + if (this.attribute('id').hasValue()) { + if (svg.Definitions[this.attribute('id').value] == null) { + svg.Definitions[this.attribute('id').value] = this; + } + } + } + } + + svg.Element.RenderedElementBase = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.setContext = function(ctx) { + // fill + if (this.style('fill').Definition.isUrl()) { + var fs = this.style('fill').Definition.getFillStyle(this); + if (fs != null) ctx.fillStyle = fs; + } + else if (this.style('fill').hasValue()) { + var fillStyle = this.style('fill'); + if (this.style('fill-opacity').hasValue()) fillStyle = fillStyle.Color.addOpacity(this.style('fill-opacity').value); + ctx.fillStyle = (fillStyle.value == 'none' ? 'rgba(0,0,0,0)' : fillStyle.value); + } + + // stroke + if (this.style('stroke').Definition.isUrl()) { + var fs = this.style('stroke').Definition.getFillStyle(this); + if (fs != null) ctx.strokeStyle = fs; + } + else if (this.style('stroke').hasValue()) { + var strokeStyle = this.style('stroke'); + if (this.style('stroke-opacity').hasValue()) strokeStyle = strokeStyle.Color.addOpacity(this.style('stroke-opacity').value); + ctx.strokeStyle = (strokeStyle.value == 'none' ? 'rgba(0,0,0,0)' : strokeStyle.value); + } + if (this.style('stroke-width').hasValue()) ctx.lineWidth = this.style('stroke-width').Length.toPixels(); + if (this.style('stroke-linecap').hasValue()) ctx.lineCap = this.style('stroke-linecap').value; + if (this.style('stroke-linejoin').hasValue()) ctx.lineJoin = this.style('stroke-linejoin').value; + if (this.style('stroke-miterlimit').hasValue()) ctx.miterLimit = this.style('stroke-miterlimit').value; + + // font + if (typeof(ctx.font) != 'undefined') { + ctx.font = svg.Font.CreateFont( + this.style('font-style').value, + this.style('font-variant').value, + this.style('font-weight').value, + this.style('font-size').hasValue() ? this.style('font-size').Length.toPixels() + 'px' : '', + this.style('font-family').value).toString(); + } + + // transform + if (this.attribute('transform').hasValue()) { + var transform = new svg.Transform(this.attribute('transform').value); + transform.apply(ctx); + } + + // clip + if (this.attribute('clip-path').hasValue()) { + var clip = this.attribute('clip-path').Definition.getDefinition(); + if (clip != null) clip.apply(ctx); + } + + // opacity + if (this.style('opacity').hasValue()) { + ctx.globalAlpha = this.style('opacity').numValue(); + } + } + } + svg.Element.RenderedElementBase.prototype = new svg.Element.ElementBase; + + svg.Element.PathElementBase = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + this.path = function(ctx) { + if (ctx != null) ctx.beginPath(); + return new svg.BoundingBox(); + } + + this.renderChildren = function(ctx) { + this.path(ctx); + svg.Mouse.checkPath(this, ctx); + if (ctx.fillStyle != '') ctx.fill(); + if (ctx.strokeStyle != '') ctx.stroke(); + + var markers = this.getMarkers(); + if (markers != null) { + if (this.style('marker-start').Definition.isUrl()) { + var marker = this.style('marker-start').Definition.getDefinition(); + marker.render(ctx, markers[0][0], markers[0][1]); + } + if (this.style('marker-mid').Definition.isUrl()) { + var marker = this.style('marker-mid').Definition.getDefinition(); + for (var i=1;i<markers.length-1;i++) { + marker.render(ctx, markers[i][0], markers[i][1]); + } + } + if (this.style('marker-end').Definition.isUrl()) { + var marker = this.style('marker-end').Definition.getDefinition(); + marker.render(ctx, markers[markers.length-1][0], markers[markers.length-1][1]); + } + } + } + + this.getBoundingBox = function() { + return this.path(); + } + + this.getMarkers = function() { + return null; + } + } + svg.Element.PathElementBase.prototype = new svg.Element.RenderedElementBase; + + // svg element + svg.Element.svg = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + this.baseClearContext = this.clearContext; + this.clearContext = function(ctx) { + this.baseClearContext(ctx); + svg.ViewPort.RemoveCurrent(); + } + + this.baseSetContext = this.setContext; + this.setContext = function(ctx) { + // initial values + ctx.strokeStyle = 'rgba(0,0,0,0)'; + ctx.lineCap = 'butt'; + ctx.lineJoin = 'miter'; + ctx.miterLimit = 4; + + this.baseSetContext(ctx); + + // create new view port + if (this.attribute('x').hasValue() && this.attribute('y').hasValue()) { + ctx.translate(this.attribute('x').Length.toPixels('x'), this.attribute('y').Length.toPixels('y')); + } + + var width = svg.ViewPort.width(); + var height = svg.ViewPort.height(); + if (typeof(this.root) == 'undefined' && this.attribute('width').hasValue() && this.attribute('height').hasValue()) { + width = this.attribute('width').Length.toPixels('x'); + height = this.attribute('height').Length.toPixels('y'); + + var x = 0; + var y = 0; + if (this.attribute('refX').hasValue() && this.attribute('refY').hasValue()) { + x = -this.attribute('refX').Length.toPixels('x'); + y = -this.attribute('refY').Length.toPixels('y'); + } + + ctx.beginPath(); + ctx.moveTo(x, y); + ctx.lineTo(width, y); + ctx.lineTo(width, height); + ctx.lineTo(x, height); + ctx.closePath(); + ctx.clip(); + } + svg.ViewPort.SetCurrent(width, height); + + // viewbox + if (this.attribute('viewBox').hasValue()) { + var viewBox = svg.ToNumberArray(this.attribute('viewBox').value); + var minX = viewBox[0]; + var minY = viewBox[1]; + width = viewBox[2]; + height = viewBox[3]; + + svg.AspectRatio(ctx, + this.attribute('preserveAspectRatio').value, + svg.ViewPort.width(), + width, + svg.ViewPort.height(), + height, + minX, + minY, + this.attribute('refX').value, + this.attribute('refY').value); + + svg.ViewPort.RemoveCurrent(); + svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]); + } + } + } + svg.Element.svg.prototype = new svg.Element.RenderedElementBase; + + // rect element + svg.Element.rect = function(node) { + this.base = svg.Element.PathElementBase; + this.base(node); + + this.path = function(ctx) { + var x = this.attribute('x').Length.toPixels('x'); + var y = this.attribute('y').Length.toPixels('y'); + var width = this.attribute('width').Length.toPixels('x'); + var height = this.attribute('height').Length.toPixels('y'); + var rx = this.attribute('rx').Length.toPixels('x'); + var ry = this.attribute('ry').Length.toPixels('y'); + if (this.attribute('rx').hasValue() && !this.attribute('ry').hasValue()) ry = rx; + if (this.attribute('ry').hasValue() && !this.attribute('rx').hasValue()) rx = ry; + + if (ctx != null) { + ctx.beginPath(); + ctx.moveTo(x + rx, y); + ctx.lineTo(x + width - rx, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + ry) + ctx.lineTo(x + width, y + height - ry); + ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height) + ctx.lineTo(x + rx, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - ry) + ctx.lineTo(x, y + ry); + ctx.quadraticCurveTo(x, y, x + rx, y) + ctx.closePath(); + } + + return new svg.BoundingBox(x, y, x + width, y + height); + } + } + svg.Element.rect.prototype = new svg.Element.PathElementBase; + + // circle element + svg.Element.circle = function(node) { + this.base = svg.Element.PathElementBase; + this.base(node); + + this.path = function(ctx) { + var cx = this.attribute('cx').Length.toPixels('x'); + var cy = this.attribute('cy').Length.toPixels('y'); + var r = this.attribute('r').Length.toPixels(); + + if (ctx != null) { + ctx.beginPath(); + ctx.arc(cx, cy, r, 0, Math.PI * 2, true); + ctx.closePath(); + } + + return new svg.BoundingBox(cx - r, cy - r, cx + r, cy + r); + } + } + svg.Element.circle.prototype = new svg.Element.PathElementBase; + + // ellipse element + svg.Element.ellipse = function(node) { + this.base = svg.Element.PathElementBase; + this.base(node); + + this.path = function(ctx) { + var KAPPA = 4 * ((Math.sqrt(2) - 1) / 3); + var rx = this.attribute('rx').Length.toPixels('x'); + var ry = this.attribute('ry').Length.toPixels('y'); + var cx = this.attribute('cx').Length.toPixels('x'); + var cy = this.attribute('cy').Length.toPixels('y'); + + if (ctx != null) { + ctx.beginPath(); + ctx.moveTo(cx, cy - ry); + ctx.bezierCurveTo(cx + (KAPPA * rx), cy - ry, cx + rx, cy - (KAPPA * ry), cx + rx, cy); + ctx.bezierCurveTo(cx + rx, cy + (KAPPA * ry), cx + (KAPPA * rx), cy + ry, cx, cy + ry); + ctx.bezierCurveTo(cx - (KAPPA * rx), cy + ry, cx - rx, cy + (KAPPA * ry), cx - rx, cy); + ctx.bezierCurveTo(cx - rx, cy - (KAPPA * ry), cx - (KAPPA * rx), cy - ry, cx, cy - ry); + ctx.closePath(); + } + + return new svg.BoundingBox(cx - rx, cy - ry, cx + rx, cy + ry); + } + } + svg.Element.ellipse.prototype = new svg.Element.PathElementBase; + + // line element + svg.Element.line = function(node) { + this.base = svg.Element.PathElementBase; + this.base(node); + + this.getPoints = function() { + return [ + new svg.Point(this.attribute('x1').Length.toPixels('x'), this.attribute('y1').Length.toPixels('y')), + new svg.Point(this.attribute('x2').Length.toPixels('x'), this.attribute('y2').Length.toPixels('y'))]; + } + + this.path = function(ctx) { + var points = this.getPoints(); + + if (ctx != null) { + ctx.beginPath(); + ctx.moveTo(points[0].x, points[0].y); + ctx.lineTo(points[1].x, points[1].y); + } + + return new svg.BoundingBox(points[0].x, points[0].y, points[1].x, points[1].y); + } + + this.getMarkers = function() { + var points = this.getPoints(); + var a = points[0].angleTo(points[1]); + return [[points[0], a], [points[1], a]]; + } + } + svg.Element.line.prototype = new svg.Element.PathElementBase; + + // polyline element + svg.Element.polyline = function(node) { + this.base = svg.Element.PathElementBase; + this.base(node); + + this.points = svg.CreatePath(this.attribute('points').value); + this.path = function(ctx) { + var bb = new svg.BoundingBox(this.points[0].x, this.points[0].y); + if (ctx != null) { + ctx.beginPath(); + ctx.moveTo(this.points[0].x, this.points[0].y); + } + for (var i=1; i<this.points.length; i++) { + bb.addPoint(this.points[i].x, this.points[i].y); + if (ctx != null) ctx.lineTo(this.points[i].x, this.points[i].y); + } + return bb; + } + + this.getMarkers = function() { + var markers = []; + for (var i=0; i<this.points.length - 1; i++) { + markers.push([this.points[i], this.points[i].angleTo(this.points[i+1])]); + } + markers.push([this.points[this.points.length-1], markers[markers.length-1][1]]); + return markers; + } + } + svg.Element.polyline.prototype = new svg.Element.PathElementBase; + + // polygon element + svg.Element.polygon = function(node) { + this.base = svg.Element.polyline; + this.base(node); + + this.basePath = this.path; + this.path = function(ctx) { + var bb = this.basePath(ctx); + if (ctx != null) { + ctx.lineTo(this.points[0].x, this.points[0].y); + ctx.closePath(); + } + return bb; + } + } + svg.Element.polygon.prototype = new svg.Element.polyline; + + // path element + svg.Element.path = function(node) { + this.base = svg.Element.PathElementBase; + this.base(node); + + var d = this.attribute('d').value; + // TODO: convert to real lexer based on http://www.w3.org/TR/SVG11/paths.html#PathDataBNF + d = d.replace(/,/gm,' '); // get rid of all commas + d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from commands + d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from commands + d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,'$1 $2'); // separate commands from points + d = d.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from points + d = d.replace(/([0-9])([+\-])/gm,'$1 $2'); // separate digits when no comma + d = d.replace(/(\.[0-9]*)(\.)/gm,'$1 $2'); // separate digits when no comma + d = d.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,'$1 $3 $4 '); // shorthand elliptical arc path syntax + d = svg.compressSpaces(d); // compress multiple spaces + d = svg.trim(d); + this.PathParser = new (function(d) { + this.tokens = d.split(' '); + + this.reset = function() { + this.i = -1; + this.command = ''; + this.previousCommand = ''; + this.start = new svg.Point(0, 0); + this.control = new svg.Point(0, 0); + this.current = new svg.Point(0, 0); + this.points = []; + this.angles = []; + } + + this.isEnd = function() { + return this.i >= this.tokens.length - 1; + } + + this.isCommandOrEnd = function() { + if (this.isEnd()) return true; + return this.tokens[this.i + 1].match(/^[A-Za-z]$/) != null; + } + + this.isRelativeCommand = function() { + return this.command == this.command.toLowerCase(); + } + + this.getToken = function() { + this.i = this.i + 1; + return this.tokens[this.i]; + } + + this.getScalar = function() { + return parseFloat(this.getToken()); + } + + this.nextCommand = function() { + this.previousCommand = this.command; + this.command = this.getToken(); + } + + this.getPoint = function() { + var p = new svg.Point(this.getScalar(), this.getScalar()); + return this.makeAbsolute(p); + } + + this.getAsControlPoint = function() { + var p = this.getPoint(); + this.control = p; + return p; + } + + this.getAsCurrentPoint = function() { + var p = this.getPoint(); + this.current = p; + return p; + } + + this.getReflectedControlPoint = function() { + if (this.previousCommand.toLowerCase() != 'c' && this.previousCommand.toLowerCase() != 's') { + return this.current; + } + + // reflect point + var p = new svg.Point(2 * this.current.x - this.control.x, 2 * this.current.y - this.control.y); + return p; + } + + this.makeAbsolute = function(p) { + if (this.isRelativeCommand()) { + p.x = this.current.x + p.x; + p.y = this.current.y + p.y; + } + return p; + } + + this.addMarker = function(p, from, priorTo) { + // if the last angle isn't filled in because we didn't have this point yet ... + if (priorTo != null && this.angles.length > 0 && this.angles[this.angles.length-1] == null) { + this.angles[this.angles.length-1] = this.points[this.points.length-1].angleTo(priorTo); + } + this.addMarkerAngle(p, from == null ? null : from.angleTo(p)); + } + + this.addMarkerAngle = function(p, a) { + this.points.push(p); + this.angles.push(a); + } + + this.getMarkerPoints = function() { return this.points; } + this.getMarkerAngles = function() { + for (var i=0; i<this.angles.length; i++) { + if (this.angles[i] == null) { + for (var j=i+1; j<this.angles.length; j++) { + if (this.angles[j] != null) { + this.angles[i] = this.angles[j]; + break; + } + } + } + } + return this.angles; + } + })(d); + + this.path = function(ctx) { + var pp = this.PathParser; + pp.reset(); + + var bb = new svg.BoundingBox(); + if (ctx != null) ctx.beginPath(); + while (!pp.isEnd()) { + pp.nextCommand(); + switch (pp.command.toUpperCase()) { + case 'M': + var p = pp.getAsCurrentPoint(); + pp.addMarker(p); + bb.addPoint(p.x, p.y); + if (ctx != null) ctx.moveTo(p.x, p.y); + pp.start = pp.current; + while (!pp.isCommandOrEnd()) { + var p = pp.getAsCurrentPoint(); + pp.addMarker(p, pp.start); + bb.addPoint(p.x, p.y); + if (ctx != null) ctx.lineTo(p.x, p.y); + } + break; + case 'L': + while (!pp.isCommandOrEnd()) { + var c = pp.current; + var p = pp.getAsCurrentPoint(); + pp.addMarker(p, c); + bb.addPoint(p.x, p.y); + if (ctx != null) ctx.lineTo(p.x, p.y); + } + break; + case 'H': + while (!pp.isCommandOrEnd()) { + var newP = new svg.Point((pp.isRelativeCommand() ? pp.current.x : 0) + pp.getScalar(), pp.current.y); + pp.addMarker(newP, pp.current); + pp.current = newP; + bb.addPoint(pp.current.x, pp.current.y); + if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y); + } + break; + case 'V': + while (!pp.isCommandOrEnd()) { + var newP = new svg.Point(pp.current.x, (pp.isRelativeCommand() ? pp.current.y : 0) + pp.getScalar()); + pp.addMarker(newP, pp.current); + pp.current = newP; + bb.addPoint(pp.current.x, pp.current.y); + if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y); + } + break; + case 'C': + while (!pp.isCommandOrEnd()) { + var curr = pp.current; + var p1 = pp.getPoint(); + var cntrl = pp.getAsControlPoint(); + var cp = pp.getAsCurrentPoint(); + pp.addMarker(cp, cntrl, p1); + bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); + if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); + } + break; + case 'S': + while (!pp.isCommandOrEnd()) { + var curr = pp.current; + var p1 = pp.getReflectedControlPoint(); + var cntrl = pp.getAsControlPoint(); + var cp = pp.getAsCurrentPoint(); + pp.addMarker(cp, cntrl, p1); + bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); + if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); + } + break; + case 'Q': + while (!pp.isCommandOrEnd()) { + var curr = pp.current; + var cntrl = pp.getAsControlPoint(); + var cp = pp.getAsCurrentPoint(); + pp.addMarker(cp, cntrl, cntrl); + bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y); + if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y); + } + break; + case 'T': + while (!pp.isCommandOrEnd()) { + var curr = pp.current; + var cntrl = pp.getReflectedControlPoint(); + pp.control = cntrl; + var cp = pp.getAsCurrentPoint(); + pp.addMarker(cp, cntrl, cntrl); + bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y); + if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y); + } + break; + case 'A': + while (!pp.isCommandOrEnd()) { + var curr = pp.current; + var rx = pp.getScalar(); + var ry = pp.getScalar(); + var xAxisRotation = pp.getScalar() * (Math.PI / 180.0); + var largeArcFlag = pp.getScalar(); + var sweepFlag = pp.getScalar(); + var cp = pp.getAsCurrentPoint(); + + // Conversion from endpoint to center parameterization + // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes + // x1', y1' + var currp = new svg.Point( + Math.cos(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.sin(xAxisRotation) * (curr.y - cp.y) / 2.0, + -Math.sin(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.cos(xAxisRotation) * (curr.y - cp.y) / 2.0 + ); + // adjust radii + var l = Math.pow(currp.x,2)/Math.pow(rx,2)+Math.pow(currp.y,2)/Math.pow(ry,2); + if (l > 1) { + rx *= Math.sqrt(l); + ry *= Math.sqrt(l); + } + // cx', cy' + var s = (largeArcFlag == sweepFlag ? -1 : 1) * Math.sqrt( + ((Math.pow(rx,2)*Math.pow(ry,2))-(Math.pow(rx,2)*Math.pow(currp.y,2))-(Math.pow(ry,2)*Math.pow(currp.x,2))) / + (Math.pow(rx,2)*Math.pow(currp.y,2)+Math.pow(ry,2)*Math.pow(currp.x,2)) + ); + if (isNaN(s)) s = 0; + var cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx); + // cx, cy + var centp = new svg.Point( + (curr.x + cp.x) / 2.0 + Math.cos(xAxisRotation) * cpp.x - Math.sin(xAxisRotation) * cpp.y, + (curr.y + cp.y) / 2.0 + Math.sin(xAxisRotation) * cpp.x + Math.cos(xAxisRotation) * cpp.y + ); + // vector magnitude + var m = function(v) { return Math.sqrt(Math.pow(v[0],2) + Math.pow(v[1],2)); } + // ratio between two vectors + var r = function(u, v) { return (u[0]*v[0]+u[1]*v[1]) / (m(u)*m(v)) } + // angle between two vectors + var a = function(u, v) { return (u[0]*v[1] < u[1]*v[0] ? -1 : 1) * Math.acos(r(u,v)); } + // initial angle + var a1 = a([1,0], [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]); + // angle delta + var u = [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]; + var v = [(-currp.x-cpp.x)/rx,(-currp.y-cpp.y)/ry]; + var ad = a(u, v); + if (r(u,v) <= -1) ad = Math.PI; + if (r(u,v) >= 1) ad = 0; + + if (sweepFlag == 0 && ad > 0) ad = ad - 2 * Math.PI; + if (sweepFlag == 1 && ad < 0) ad = ad + 2 * Math.PI; + + // for markers + var halfWay = new svg.Point( + centp.x - rx * Math.cos((a1 + ad) / 2), + centp.y - ry * Math.sin((a1 + ad) / 2) + ); + pp.addMarkerAngle(halfWay, (a1 + ad) / 2 + (sweepFlag == 0 ? 1 : -1) * Math.PI / 2); + pp.addMarkerAngle(cp, ad + (sweepFlag == 0 ? 1 : -1) * Math.PI / 2); + + bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better + if (ctx != null) { + var r = rx > ry ? rx : ry; + var sx = rx > ry ? 1 : rx / ry; + var sy = rx > ry ? ry / rx : 1; + + ctx.translate(centp.x, centp.y); + ctx.rotate(xAxisRotation); + ctx.scale(sx, sy); + ctx.arc(0, 0, r, a1, a1 + ad, 1 - sweepFlag); + ctx.scale(1/sx, 1/sy); + ctx.rotate(-xAxisRotation); + ctx.translate(-centp.x, -centp.y); + } + } + break; + case 'Z': + if (ctx != null) ctx.closePath(); + pp.current = pp.start; + } + } + + return bb; + } + + this.getMarkers = function() { + var points = this.PathParser.getMarkerPoints(); + var angles = this.PathParser.getMarkerAngles(); + + var markers = []; + for (var i=0; i<points.length; i++) { + markers.push([points[i], angles[i]]); + } + return markers; + } + } + svg.Element.path.prototype = new svg.Element.PathElementBase; + + // pattern element + svg.Element.pattern = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.createPattern = function(ctx, element) { + // render me using a temporary svg element + var tempSvg = new svg.Element.svg(); + tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value); + tempSvg.attributes['x'] = new svg.Property('x', this.attribute('x').value); + tempSvg.attributes['y'] = new svg.Property('y', this.attribute('y').value); + tempSvg.attributes['width'] = new svg.Property('width', this.attribute('width').value); + tempSvg.attributes['height'] = new svg.Property('height', this.attribute('height').value); + tempSvg.children = this.children; + + var c = document.createElement('canvas'); + c.width = this.attribute('width').Length.toPixels('x'); + c.height = this.attribute('height').Length.toPixels('y'); + tempSvg.render(c.getContext('2d')); + return ctx.createPattern(c, 'repeat'); + } + } + svg.Element.pattern.prototype = new svg.Element.ElementBase; + + // marker element + svg.Element.marker = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.baseRender = this.render; + this.render = function(ctx, point, angle) { + ctx.translate(point.x, point.y); + if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(angle); + if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(ctx.lineWidth, ctx.lineWidth); + ctx.save(); + + // render me using a temporary svg element + var tempSvg = new svg.Element.svg(); + tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value); + tempSvg.attributes['refX'] = new svg.Property('refX', this.attribute('refX').value); + tempSvg.attributes['refY'] = new svg.Property('refY', this.attribute('refY').value); + tempSvg.attributes['width'] = new svg.Property('width', this.attribute('markerWidth').value); + tempSvg.attributes['height'] = new svg.Property('height', this.attribute('markerHeight').value); + tempSvg.attributes['fill'] = new svg.Property('fill', this.attribute('fill').valueOrDefault('black')); + tempSvg.attributes['stroke'] = new svg.Property('stroke', this.attribute('stroke').valueOrDefault('none')); + tempSvg.children = this.children; + tempSvg.render(ctx); + + ctx.restore(); + if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(1/ctx.lineWidth, 1/ctx.lineWidth); + if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(-angle); + ctx.translate(-point.x, -point.y); + } + } + svg.Element.marker.prototype = new svg.Element.ElementBase; + + // definitions element + svg.Element.defs = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.render = function(ctx) { + // NOOP + } + } + svg.Element.defs.prototype = new svg.Element.ElementBase; + + // base for gradients + svg.Element.GradientBase = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.gradientUnits = this.attribute('gradientUnits').valueOrDefault('objectBoundingBox'); + + this.stops = []; + for (var i=0; i<this.children.length; i++) { + var child = this.children[i]; + this.stops.push(child); + } + + this.getGradient = function() { + // OVERRIDE ME! + } + + this.createGradient = function(ctx, element) { + var stopsContainer = this; + if (this.attribute('xlink:href').hasValue()) { + stopsContainer = this.attribute('xlink:href').Definition.getDefinition(); + } + + var g = this.getGradient(ctx, element); + for (var i=0; i<stopsContainer.stops.length; i++) { + g.addColorStop(stopsContainer.stops[i].offset, stopsContainer.stops[i].color); + } + + if (this.attribute('gradientTransform').hasValue()) { + // render as transformed pattern on temporary canvas + var rootView = svg.ViewPort.viewPorts[0]; + + var rect = new svg.Element.rect(); + rect.attributes['x'] = new svg.Property('x', -svg.MAX_VIRTUAL_PIXELS/3.0); + rect.attributes['y'] = new svg.Property('y', -svg.MAX_VIRTUAL_PIXELS/3.0); + rect.attributes['width'] = new svg.Property('width', svg.MAX_VIRTUAL_PIXELS); + rect.attributes['height'] = new svg.Property('height', svg.MAX_VIRTUAL_PIXELS); + + var group = new svg.Element.g(); + group.attributes['transform'] = new svg.Property('transform', this.attribute('gradientTransform').value); + group.children = [ rect ]; + + var tempSvg = new svg.Element.svg(); + tempSvg.attributes['x'] = new svg.Property('x', 0); + tempSvg.attributes['y'] = new svg.Property('y', 0); + tempSvg.attributes['width'] = new svg.Property('width', rootView.width); + tempSvg.attributes['height'] = new svg.Property('height', rootView.height); + tempSvg.children = [ group ]; + + var c = document.createElement('canvas'); + c.width = rootView.width; + c.height = rootView.height; + var tempCtx = c.getContext('2d'); + tempCtx.fillStyle = g; + tempSvg.render(tempCtx); + return tempCtx.createPattern(c, 'no-repeat'); + } + + return g; + } + } + svg.Element.GradientBase.prototype = new svg.Element.ElementBase; + + // linear gradient element + svg.Element.linearGradient = function(node) { + this.base = svg.Element.GradientBase; + this.base(node); + + this.getGradient = function(ctx, element) { + var bb = element.getBoundingBox(); + + var x1 = (this.gradientUnits == 'objectBoundingBox' + ? bb.x() + bb.width() * this.attribute('x1').numValue() + : this.attribute('x1').Length.toPixels('x')); + var y1 = (this.gradientUnits == 'objectBoundingBox' + ? bb.y() + bb.height() * this.attribute('y1').numValue() + : this.attribute('y1').Length.toPixels('y')); + var x2 = (this.gradientUnits == 'objectBoundingBox' + ? bb.x() + bb.width() * this.attribute('x2').numValue() + : this.attribute('x2').Length.toPixels('x')); + var y2 = (this.gradientUnits == 'objectBoundingBox' + ? bb.y() + bb.height() * this.attribute('y2').numValue() + : this.attribute('y2').Length.toPixels('y')); + + return ctx.createLinearGradient(x1, y1, x2, y2); + } + } + svg.Element.linearGradient.prototype = new svg.Element.GradientBase; + + // radial gradient element + svg.Element.radialGradient = function(node) { + this.base = svg.Element.GradientBase; + this.base(node); + + this.getGradient = function(ctx, element) { + var bb = element.getBoundingBox(); + + var cx = (this.gradientUnits == 'objectBoundingBox' + ? bb.x() + bb.width() * this.attribute('cx').numValue() + : this.attribute('cx').Length.toPixels('x')); + var cy = (this.gradientUnits == 'objectBoundingBox' + ? bb.y() + bb.height() * this.attribute('cy').numValue() + : this.attribute('cy').Length.toPixels('y')); + + var fx = cx; + var fy = cy; + if (this.attribute('fx').hasValue()) { + fx = (this.gradientUnits == 'objectBoundingBox' + ? bb.x() + bb.width() * this.attribute('fx').numValue() + : this.attribute('fx').Length.toPixels('x')); + } + if (this.attribute('fy').hasValue()) { + fy = (this.gradientUnits == 'objectBoundingBox' + ? bb.y() + bb.height() * this.attribute('fy').numValue() + : this.attribute('fy').Length.toPixels('y')); + } + + var r = (this.gradientUnits == 'objectBoundingBox' + ? (bb.width() + bb.height()) / 2.0 * this.attribute('r').numValue() + : this.attribute('r').Length.toPixels()); + + return ctx.createRadialGradient(fx, fy, 0, cx, cy, r); + } + } + svg.Element.radialGradient.prototype = new svg.Element.GradientBase; + + // gradient stop element + svg.Element.stop = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.offset = this.attribute('offset').numValue(); + + var stopColor = this.style('stop-color'); + if (this.style('stop-opacity').hasValue()) stopColor = stopColor.Color.addOpacity(this.style('stop-opacity').value); + this.color = stopColor.value; + } + svg.Element.stop.prototype = new svg.Element.ElementBase; + + // animation base element + svg.Element.AnimateBase = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + svg.Animations.push(this); + + this.duration = 0.0; + this.begin = this.attribute('begin').Time.toMilliseconds(); + this.maxDuration = this.begin + this.attribute('dur').Time.toMilliseconds(); + + this.getProperty = function() { + var attributeType = this.attribute('attributeType').value; + var attributeName = this.attribute('attributeName').value; + + if (attributeType == 'CSS') { + return this.parent.style(attributeName, true); + } + return this.parent.attribute(attributeName, true); + }; + + this.initialValue = null; + this.removed = false; + + this.calcValue = function() { + // OVERRIDE ME! + return ''; + } + + this.update = function(delta) { + // set initial value + if (this.initialValue == null) { + this.initialValue = this.getProperty().value; + } + + // if we're past the end time + if (this.duration > this.maxDuration) { + // loop for indefinitely repeating animations + if (this.attribute('repeatCount').value == 'indefinite') { + this.duration = 0.0 + } + else if (this.attribute('fill').valueOrDefault('remove') == 'remove' && !this.removed) { + this.removed = true; + this.getProperty().value = this.initialValue; + return true; + } + else { + return false; // no updates made + } + } + this.duration = this.duration + delta; + + // if we're past the begin time + var updated = false; + if (this.begin < this.duration) { + var newValue = this.calcValue(); // tween + + if (this.attribute('type').hasValue()) { + // for transform, etc. + var type = this.attribute('type').value; + newValue = type + '(' + newValue + ')'; + } + + this.getProperty().value = newValue; + updated = true; + } + + return updated; + } + + // fraction of duration we've covered + this.progress = function() { + return ((this.duration - this.begin) / (this.maxDuration - this.begin)); + } + } + svg.Element.AnimateBase.prototype = new svg.Element.ElementBase; + + // animate element + svg.Element.animate = function(node) { + this.base = svg.Element.AnimateBase; + this.base(node); + + this.calcValue = function() { + var from = this.attribute('from').numValue(); + var to = this.attribute('to').numValue(); + + // tween value linearly + return from + (to - from) * this.progress(); + }; + } + svg.Element.animate.prototype = new svg.Element.AnimateBase; + + // animate color element + svg.Element.animateColor = function(node) { + this.base = svg.Element.AnimateBase; + this.base(node); + + this.calcValue = function() { + var from = new RGBColor(this.attribute('from').value); + var to = new RGBColor(this.attribute('to').value); + + if (from.ok && to.ok) { + // tween color linearly + var r = from.r + (to.r - from.r) * this.progress(); + var g = from.g + (to.g - from.g) * this.progress(); + var b = from.b + (to.b - from.b) * this.progress(); + return 'rgb('+parseInt(r,10)+','+parseInt(g,10)+','+parseInt(b,10)+')'; + } + return this.attribute('from').value; + }; + } + svg.Element.animateColor.prototype = new svg.Element.AnimateBase; + + // animate transform element + svg.Element.animateTransform = function(node) { + this.base = svg.Element.animate; + this.base(node); + } + svg.Element.animateTransform.prototype = new svg.Element.animate; + + // font element + svg.Element.font = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.horizAdvX = this.attribute('horiz-adv-x').numValue(); + + this.isRTL = false; + this.isArabic = false; + this.fontFace = null; + this.missingGlyph = null; + this.glyphs = []; + for (var i=0; i<this.children.length; i++) { + var child = this.children[i]; + if (child.type == 'font-face') { + this.fontFace = child; + if (child.style('font-family').hasValue()) { + svg.Definitions[child.style('font-family').value] = this; + } + } + else if (child.type == 'missing-glyph') this.missingGlyph = child; + else if (child.type == 'glyph') { + if (child.arabicForm != '') { + this.isRTL = true; + this.isArabic = true; + if (typeof(this.glyphs[child.unicode]) == 'undefined') this.glyphs[child.unicode] = []; + this.glyphs[child.unicode][child.arabicForm] = child; + } + else { + this.glyphs[child.unicode] = child; + } + } + } + } + svg.Element.font.prototype = new svg.Element.ElementBase; + + // font-face element + svg.Element.fontface = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.ascent = this.attribute('ascent').value; + this.descent = this.attribute('descent').value; + this.unitsPerEm = this.attribute('units-per-em').numValue(); + } + svg.Element.fontface.prototype = new svg.Element.ElementBase; + + // missing-glyph element + svg.Element.missingglyph = function(node) { + this.base = svg.Element.path; + this.base(node); + + this.horizAdvX = 0; + } + svg.Element.missingglyph.prototype = new svg.Element.path; + + // glyph element + svg.Element.glyph = function(node) { + this.base = svg.Element.path; + this.base(node); + + this.horizAdvX = this.attribute('horiz-adv-x').numValue(); + this.unicode = this.attribute('unicode').value; + this.arabicForm = this.attribute('arabic-form').value; + } + svg.Element.glyph.prototype = new svg.Element.path; + + // text element + svg.Element.text = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + if (node != null) { + // add children + this.children = []; + for (var i=0; i<node.childNodes.length; i++) { + var childNode = node.childNodes[i]; + if (childNode.nodeType == 1) { // capture tspan and tref nodes + this.addChild(childNode, true); + } + else if (childNode.nodeType == 3) { // capture text + this.addChild(new svg.Element.tspan(childNode), false); + } + } + } + + this.baseSetContext = this.setContext; + this.setContext = function(ctx) { + this.baseSetContext(ctx); + if (this.style('dominant-baseline').hasValue()) ctx.textBaseline = this.style('dominant-baseline').value; + if (this.style('alignment-baseline').hasValue()) ctx.textBaseline = this.style('alignment-baseline').value; + } + + this.renderChildren = function(ctx) { + var textAnchor = this.style('text-anchor').valueOrDefault('start'); + var x = this.attribute('x').Length.toPixels('x'); + var y = this.attribute('y').Length.toPixels('y'); + for (var i=0; i<this.children.length; i++) { + var child = this.children[i]; + + if (child.attribute('x').hasValue()) { + child.x = child.attribute('x').Length.toPixels('x'); + } + else { + if (child.attribute('dx').hasValue()) x += child.attribute('dx').Length.toPixels('x'); + child.x = x; + } + + var childLength = child.measureText(ctx); + if (textAnchor != 'start' && (i==0 || child.attribute('x').hasValue())) { // new group? + // loop through rest of children + var groupLength = childLength; + for (var j=i+1; j<this.children.length; j++) { + var childInGroup = this.children[j]; + if (childInGroup.attribute('x').hasValue()) break; // new group + groupLength += childInGroup.measureText(ctx); + } + child.x -= (textAnchor == 'end' ? groupLength : groupLength / 2.0); + } + x = child.x + childLength; + + if (child.attribute('y').hasValue()) { + child.y = child.attribute('y').Length.toPixels('y'); + } + else { + if (child.attribute('dy').hasValue()) y += child.attribute('dy').Length.toPixels('y'); + child.y = y; + } + y = child.y; + + child.render(ctx); + } + } + } + svg.Element.text.prototype = new svg.Element.RenderedElementBase; + + // text base + svg.Element.TextElementBase = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + this.getGlyph = function(font, text, i) { + var c = text[i]; + var glyph = null; + if (font.isArabic) { + var arabicForm = 'isolated'; + if ((i==0 || text[i-1]==' ') && i<text.length-2 && text[i+1]!=' ') arabicForm = 'terminal'; + if (i>0 && text[i-1]!=' ' && i<text.length-2 && text[i+1]!=' ') arabicForm = 'medial'; + if (i>0 && text[i-1]!=' ' && (i == text.length-1 || text[i+1]==' ')) arabicForm = 'initial'; + if (typeof(font.glyphs[c]) != 'undefined') { + glyph = font.glyphs[c][arabicForm]; + if (glyph == null && font.glyphs[c].type == 'glyph') glyph = font.glyphs[c]; + } + } + else { + glyph = font.glyphs[c]; + } + if (glyph == null) glyph = font.missingGlyph; + return glyph; + } + + this.renderChildren = function(ctx) { + var customFont = this.parent.style('font-family').Definition.getDefinition(); + if (customFont != null) { + var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize); + var fontStyle = this.parent.style('font-style').valueOrDefault(svg.Font.Parse(svg.ctx.font).fontStyle); + var text = this.getText(); + if (customFont.isRTL) text = text.split("").reverse().join(""); + + var dx = svg.ToNumberArray(this.parent.attribute('dx').value); + for (var i=0; i<text.length; i++) { + var glyph = this.getGlyph(customFont, text, i); + var scale = fontSize / customFont.fontFace.unitsPerEm; + ctx.translate(this.x, this.y); + ctx.scale(scale, -scale); + var lw = ctx.lineWidth; + ctx.lineWidth = ctx.lineWidth * customFont.fontFace.unitsPerEm / fontSize; + if (fontStyle == 'italic') ctx.transform(1, 0, .4, 1, 0, 0); + glyph.render(ctx); + if (fontStyle == 'italic') ctx.transform(1, 0, -.4, 1, 0, 0); + ctx.lineWidth = lw; + ctx.scale(1/scale, -1/scale); + ctx.translate(-this.x, -this.y); + + this.x += fontSize * (glyph.horizAdvX || customFont.horizAdvX) / customFont.fontFace.unitsPerEm; + if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) { + this.x += dx[i]; + } + } + return; + } + + if (ctx.strokeStyle != '') ctx.strokeText(svg.compressSpaces(this.getText()), this.x, this.y); + if (ctx.fillStyle != '') ctx.fillText(svg.compressSpaces(this.getText()), this.x, this.y); + } + + this.getText = function() { + // OVERRIDE ME + } + + this.measureText = function(ctx) { + var customFont = this.parent.style('font-family').Definition.getDefinition(); + if (customFont != null) { + var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize); + var measure = 0; + var text = this.getText(); + if (customFont.isRTL) text = text.split("").reverse().join(""); + var dx = svg.ToNumberArray(this.parent.attribute('dx').value); + for (var i=0; i<text.length; i++) { + var glyph = this.getGlyph(customFont, text, i); + measure += (glyph.horizAdvX || customFont.horizAdvX) * fontSize / customFont.fontFace.unitsPerEm; + if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) { + measure += dx[i]; + } + } + return measure; + } + + var textToMeasure = svg.compressSpaces(this.getText()); + if (!ctx.measureText) return textToMeasure.length * 10; + + ctx.save(); + this.setContext(ctx); + var width = ctx.measureText(textToMeasure).width; + ctx.restore(); + return width; + } + } + svg.Element.TextElementBase.prototype = new svg.Element.RenderedElementBase; + + // tspan + svg.Element.tspan = function(node) { + this.base = svg.Element.TextElementBase; + this.base(node); + + this.text = node.nodeType == 3 ? node.nodeValue : // text + node.childNodes.length > 0 ? node.childNodes[0].nodeValue : // element + node.text; + this.getText = function() { + return this.text; + } + } + svg.Element.tspan.prototype = new svg.Element.TextElementBase; + + // tref + svg.Element.tref = function(node) { + this.base = svg.Element.TextElementBase; + this.base(node); + + this.getText = function() { + var element = this.attribute('xlink:href').Definition.getDefinition(); + if (element != null) return element.children[0].getText(); + } + } + svg.Element.tref.prototype = new svg.Element.TextElementBase; + + // a element + svg.Element.a = function(node) { + this.base = svg.Element.TextElementBase; + this.base(node); + + this.hasText = true; + for (var i=0; i<node.childNodes.length; i++) { + if (node.childNodes[i].nodeType != 3) this.hasText = false; + } + + // this might contain text + this.text = this.hasText ? node.childNodes[0].nodeValue : ''; + this.getText = function() { + return this.text; + } + + this.baseRenderChildren = this.renderChildren; + this.renderChildren = function(ctx) { + if (this.hasText) { + // render as text element + this.baseRenderChildren(ctx); + var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize); + svg.Mouse.checkBoundingBox(this, new svg.BoundingBox(this.x, this.y - fontSize.Length.toPixels('y'), this.x + this.measureText(ctx), this.y)); + } + else { + // render as temporary group + var g = new svg.Element.g(); + g.children = this.children; + g.parent = this; + g.render(ctx); + } + } + + this.onclick = function() { + window.open(this.attribute('xlink:href').value); + } + + this.onmousemove = function() { + svg.ctx.canvas.style.cursor = 'pointer'; + } + } + svg.Element.a.prototype = new svg.Element.TextElementBase; + + // image element + svg.Element.image = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + svg.Images.push(this); + this.img = document.createElement('img'); + this.loaded = false; + var that = this; + this.img.onload = function() { that.loaded = true; } + this.img.src = this.attribute('xlink:href').value; + + this.renderChildren = function(ctx) { + var x = this.attribute('x').Length.toPixels('x'); + var y = this.attribute('y').Length.toPixels('y'); + + var width = this.attribute('width').Length.toPixels('x'); + var height = this.attribute('height').Length.toPixels('y'); + if (width == 0 || height == 0) return; + + ctx.save(); + ctx.translate(x, y); + svg.AspectRatio(ctx, + this.attribute('preserveAspectRatio').value, + width, + this.img.width, + height, + this.img.height, + 0, + 0); + ctx.drawImage(this.img, 0, 0); + ctx.restore(); + } + } + svg.Element.image.prototype = new svg.Element.RenderedElementBase; + + // group element + svg.Element.g = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + this.getBoundingBox = function() { + var bb = new svg.BoundingBox(); + for (var i=0; i<this.children.length; i++) { + bb.addBoundingBox(this.children[i].getBoundingBox()); + } + return bb; + }; + } + svg.Element.g.prototype = new svg.Element.RenderedElementBase; + + // symbol element + svg.Element.symbol = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + this.baseSetContext = this.setContext; + this.setContext = function(ctx) { + this.baseSetContext(ctx); + + // viewbox + if (this.attribute('viewBox').hasValue()) { + var viewBox = svg.ToNumberArray(this.attribute('viewBox').value); + var minX = viewBox[0]; + var minY = viewBox[1]; + width = viewBox[2]; + height = viewBox[3]; + + svg.AspectRatio(ctx, + this.attribute('preserveAspectRatio').value, + this.attribute('width').Length.toPixels('x'), + width, + this.attribute('height').Length.toPixels('y'), + height, + minX, + minY); + + svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]); + } + } + } + svg.Element.symbol.prototype = new svg.Element.RenderedElementBase; + + // style element + svg.Element.style = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + // text, or spaces then CDATA + var css = node.childNodes[0].nodeValue + (node.childNodes.length > 1 ? node.childNodes[1].nodeValue : ''); + css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments + css = svg.compressSpaces(css); // replace whitespace + var cssDefs = css.split('}'); + for (var i=0; i<cssDefs.length; i++) { + if (svg.trim(cssDefs[i]) != '') { + var cssDef = cssDefs[i].split('{'); + var cssClasses = cssDef[0].split(','); + var cssProps = cssDef[1].split(';'); + for (var j=0; j<cssClasses.length; j++) { + var cssClass = svg.trim(cssClasses[j]); + if (cssClass != '') { + var props = {}; + for (var k=0; k<cssProps.length; k++) { + var prop = cssProps[k].indexOf(':'); + var name = cssProps[k].substr(0, prop); + var value = cssProps[k].substr(prop + 1, cssProps[k].length - prop); + if (name != null && value != null) { + props[svg.trim(name)] = new svg.Property(svg.trim(name), svg.trim(value)); + } + } + svg.Styles[cssClass] = props; + if (cssClass == '@font-face') { + var fontFamily = props['font-family'].value.replace(/"/g,''); + var srcs = props['src'].value.split(','); + for (var s=0; s<srcs.length; s++) { + if (srcs[s].indexOf('format("svg")') > 0) { + var urlStart = srcs[s].indexOf('url'); + var urlEnd = srcs[s].indexOf(')', urlStart); + var url = srcs[s].substr(urlStart + 5, urlEnd - urlStart - 6); + var doc = svg.parseXml(svg.ajax(url)); + var fonts = doc.getElementsByTagName('font'); + for (var f=0; f<fonts.length; f++) { + var font = svg.CreateElement(fonts[f]); + svg.Definitions[fontFamily] = font; + } + } + } + } + } + } + } + } + } + svg.Element.style.prototype = new svg.Element.ElementBase; + + // use element + svg.Element.use = function(node) { + this.base = svg.Element.RenderedElementBase; + this.base(node); + + this.baseSetContext = this.setContext; + this.setContext = function(ctx) { + this.baseSetContext(ctx); + if (this.attribute('x').hasValue()) ctx.translate(this.attribute('x').Length.toPixels('x'), 0); + if (this.attribute('y').hasValue()) ctx.translate(0, this.attribute('y').Length.toPixels('y')); + } + + this.getDefinition = function() { + var element = this.attribute('xlink:href').Definition.getDefinition(); + if (this.attribute('width').hasValue()) element.attribute('width', true).value = this.attribute('width').value; + if (this.attribute('height').hasValue()) element.attribute('height', true).value = this.attribute('height').value; + return element; + } + + this.path = function(ctx) { + var element = this.getDefinition(); + if (element != null) element.path(ctx); + } + + this.renderChildren = function(ctx) { + var element = this.getDefinition(); + if (element != null) element.render(ctx); + } + } + svg.Element.use.prototype = new svg.Element.RenderedElementBase; + + // mask element + svg.Element.mask = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.apply = function(ctx, element) { + // render as temp svg + var x = this.attribute('x').Length.toPixels('x'); + var y = this.attribute('y').Length.toPixels('y'); + var width = this.attribute('width').Length.toPixels('x'); + var height = this.attribute('height').Length.toPixels('y'); + + // temporarily remove mask to avoid recursion + var mask = element.attribute('mask').value; + element.attribute('mask').value = ''; + + var cMask = document.createElement('canvas'); + cMask.width = x + width; + cMask.height = y + height; + var maskCtx = cMask.getContext('2d'); + this.renderChildren(maskCtx); + + var c = document.createElement('canvas'); + c.width = x + width; + c.height = y + height; + var tempCtx = c.getContext('2d'); + element.render(tempCtx); + tempCtx.globalCompositeOperation = 'destination-in'; + tempCtx.fillStyle = maskCtx.createPattern(cMask, 'no-repeat'); + tempCtx.fillRect(0, 0, x + width, y + height); + + ctx.fillStyle = tempCtx.createPattern(c, 'no-repeat'); + ctx.fillRect(0, 0, x + width, y + height); + + // reassign mask + element.attribute('mask').value = mask; + } + + this.render = function(ctx) { + // NO RENDER + } + } + svg.Element.mask.prototype = new svg.Element.ElementBase; + + // clip element + svg.Element.clipPath = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.apply = function(ctx) { + for (var i=0; i<this.children.length; i++) { + if (this.children[i].path) { + this.children[i].path(ctx); + ctx.clip(); + } + } + } + + this.render = function(ctx) { + // NO RENDER + } + } + svg.Element.clipPath.prototype = new svg.Element.ElementBase; + + // filters + svg.Element.filter = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + this.apply = function(ctx, element) { + // render as temp svg + var bb = element.getBoundingBox(); + var x = this.attribute('x').Length.toPixels('x'); + var y = this.attribute('y').Length.toPixels('y'); + if (x == 0 || y == 0) { + x = bb.x1; + y = bb.y1; + } + var width = this.attribute('width').Length.toPixels('x'); + var height = this.attribute('height').Length.toPixels('y'); + if (width == 0 || height == 0) { + width = bb.width(); + height = bb.height(); + } + + // temporarily remove filter to avoid recursion + var filter = element.style('filter').value; + element.style('filter').value = ''; + + // max filter distance + var extraPercent = .20; + var px = extraPercent * width; + var py = extraPercent * height; + + var c = document.createElement('canvas'); + c.width = width + 2*px; + c.height = height + 2*py; + var tempCtx = c.getContext('2d'); + tempCtx.translate(-x + px, -y + py); + element.render(tempCtx); + + // apply filters + for (var i=0; i<this.children.length; i++) { + this.children[i].apply(tempCtx, 0, 0, width + 2*px, height + 2*py); + } + + // render on me + ctx.drawImage(c, 0, 0, width + 2*px, height + 2*py, x - px, y - py, width + 2*px, height + 2*py); + + // reassign filter + element.style('filter', true).value = filter; + } + + this.render = function(ctx) { + // NO RENDER + } + } + svg.Element.filter.prototype = new svg.Element.ElementBase; + + svg.Element.feGaussianBlur = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + function make_fgauss(sigma) { + sigma = Math.max(sigma, 0.01); + var len = Math.ceil(sigma * 4.0) + 1; + mask = []; + for (var i = 0; i < len; i++) { + mask[i] = Math.exp(-0.5 * (i / sigma) * (i / sigma)); + } + return mask; + } + + function normalize(mask) { + var sum = 0; + for (var i = 1; i < mask.length; i++) { + sum += Math.abs(mask[i]); + } + sum = 2 * sum + Math.abs(mask[0]); + for (var i = 0; i < mask.length; i++) { + mask[i] /= sum; + } + return mask; + } + + function convolve_even(src, dst, mask, width, height) { + for (var y = 0; y < height; y++) { + for (var x = 0; x < width; x++) { + var a = imGet(src, x, y, width, height, 3)/255; + for (var rgba = 0; rgba < 4; rgba++) { + var sum = mask[0] * (a==0?255:imGet(src, x, y, width, height, rgba)) * (a==0||rgba==3?1:a); + for (var i = 1; i < mask.length; i++) { + var a1 = imGet(src, Math.max(x-i,0), y, width, height, 3)/255; + var a2 = imGet(src, Math.min(x+i, width-1), y, width, height, 3)/255; + sum += mask[i] * + ((a1==0?255:imGet(src, Math.max(x-i,0), y, width, height, rgba)) * (a1==0||rgba==3?1:a1) + + (a2==0?255:imGet(src, Math.min(x+i, width-1), y, width, height, rgba)) * (a2==0||rgba==3?1:a2)); + } + imSet(dst, y, x, height, width, rgba, sum); + } + } + } + } + + function imGet(img, x, y, width, height, rgba) { + return img[y*width*4 + x*4 + rgba]; + } + + function imSet(img, x, y, width, height, rgba, val) { + img[y*width*4 + x*4 + rgba] = val; + } + + function blur(ctx, width, height, sigma) + { + var srcData = ctx.getImageData(0, 0, width, height); + var mask = make_fgauss(sigma); + mask = normalize(mask); + tmp = []; + convolve_even(srcData.data, tmp, mask, width, height); + convolve_even(tmp, srcData.data, mask, height, width); + ctx.clearRect(0, 0, width, height); + ctx.putImageData(srcData, 0, 0); + } + + this.apply = function(ctx, x, y, width, height) { + // assuming x==0 && y==0 for now + blur(ctx, width, height, this.attribute('stdDeviation').numValue()); + } + } + svg.Element.filter.prototype = new svg.Element.feGaussianBlur; + + // title element, do nothing + svg.Element.title = function(node) { + } + svg.Element.title.prototype = new svg.Element.ElementBase; + + // desc element, do nothing + svg.Element.desc = function(node) { + } + svg.Element.desc.prototype = new svg.Element.ElementBase; + + svg.Element.MISSING = function(node) { + console.log('ERROR: Element \'' + node.nodeName + '\' not yet implemented.'); + } + svg.Element.MISSING.prototype = new svg.Element.ElementBase; + + // element factory + svg.CreateElement = function(node) { + var className = node.nodeName.replace(/^[^:]+:/,''); // remove namespace + className = className.replace(/\-/g,''); // remove dashes + var e = null; + if (typeof(svg.Element[className]) != 'undefined') { + e = new svg.Element[className](node); + } + else { + e = new svg.Element.MISSING(node); + } + + e.type = node.nodeName; + return e; + } + + // load from url + svg.load = function(ctx, url) { + svg.loadXml(ctx, svg.ajax(url)); + } + + // load from xml + svg.loadXml = function(ctx, xml) { + svg.loadXmlDoc(ctx, svg.parseXml(xml)); + } + + svg.loadXmlDoc = function(ctx, dom) { + svg.init(ctx); + + var mapXY = function(p) { + var e = ctx.canvas; + while (e) { + p.x -= e.offsetLeft; + p.y -= e.offsetTop; + e = e.offsetParent; + } + if (window.scrollX) p.x += window.scrollX; + if (window.scrollY) p.y += window.scrollY; + return p; + } + + // bind mouse + if (svg.opts['ignoreMouse'] != true) { + ctx.canvas.onclick = function(e) { + var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY)); + svg.Mouse.onclick(p.x, p.y); + }; + ctx.canvas.onmousemove = function(e) { + var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY)); + svg.Mouse.onmousemove(p.x, p.y); + }; + } + + var e = svg.CreateElement(dom.documentElement); + e.root = true; + + // render loop + var isFirstRender = true; + var draw = function() { + svg.ViewPort.Clear(); + if (ctx.canvas.parentNode) svg.ViewPort.SetCurrent(ctx.canvas.parentNode.clientWidth, ctx.canvas.parentNode.clientHeight); + + if (svg.opts['ignoreDimensions'] != true) { + // set canvas size + if (e.style('width').hasValue()) { + ctx.canvas.width = e.style('width').Length.toPixels('x'); + ctx.canvas.style.width = ctx.canvas.width + 'px'; + } + if (e.style('height').hasValue()) { + ctx.canvas.height = e.style('height').Length.toPixels('y'); + ctx.canvas.style.height = ctx.canvas.height + 'px'; + } + } + var cWidth = ctx.canvas.clientWidth || ctx.canvas.width; + var cHeight = ctx.canvas.clientHeight || ctx.canvas.height; + svg.ViewPort.SetCurrent(cWidth, cHeight); + + if (svg.opts != null && svg.opts['offsetX'] != null) e.attribute('x', true).value = svg.opts['offsetX']; + if (svg.opts != null && svg.opts['offsetY'] != null) e.attribute('y', true).value = svg.opts['offsetY']; + if (svg.opts != null && svg.opts['scaleWidth'] != null && svg.opts['scaleHeight'] != null) { + var xRatio = 1, yRatio = 1; + if (e.attribute('width').hasValue()) xRatio = e.attribute('width').Length.toPixels('x') / svg.opts['scaleWidth']; + if (e.attribute('height').hasValue()) yRatio = e.attribute('height').Length.toPixels('y') / svg.opts['scaleHeight']; + + e.attribute('width', true).value = svg.opts['scaleWidth']; + e.attribute('height', true).value = svg.opts['scaleHeight']; + e.attribute('viewBox', true).value = '0 0 ' + (cWidth * xRatio) + ' ' + (cHeight * yRatio); + e.attribute('preserveAspectRatio', true).value = 'none'; + } + + // clear and render + if (svg.opts['ignoreClear'] != true) { + ctx.clearRect(0, 0, cWidth, cHeight); + } + e.render(ctx); + if (isFirstRender) { + isFirstRender = false; + if (svg.opts != null && typeof(svg.opts['renderCallback']) == 'function') svg.opts['renderCallback'](); + } + } + + var waitingForImages = true; + if (svg.ImagesLoaded()) { + waitingForImages = false; + draw(); + } + svg.intervalID = setInterval(function() { + var needUpdate = false; + + if (waitingForImages && svg.ImagesLoaded()) { + waitingForImages = false; + needUpdate = true; + } + + // need update from mouse events? + if (svg.opts['ignoreMouse'] != true) { + needUpdate = needUpdate | svg.Mouse.hasEvents(); + } + + // need update from animations? + if (svg.opts['ignoreAnimation'] != true) { + for (var i=0; i<svg.Animations.length; i++) { + needUpdate = needUpdate | svg.Animations[i].update(1000 / svg.FRAMERATE); + } + } + + // need update from redraw? + if (svg.opts != null && typeof(svg.opts['forceRedraw']) == 'function') { + if (svg.opts['forceRedraw']() == true) needUpdate = true; + } + + // render if needed + if (needUpdate) { + draw(); + svg.Mouse.runEvents(); // run and clear our events + } + }, 1000 / svg.FRAMERATE); + } + + svg.stop = function() { + if (svg.intervalID) { + clearInterval(svg.intervalID); + } + } + + svg.Mouse = new (function() { + this.events = []; + this.hasEvents = function() { return this.events.length != 0; } + + this.onclick = function(x, y) { + this.events.push({ type: 'onclick', x: x, y: y, + run: function(e) { if (e.onclick) e.onclick(); } + }); + } + + this.onmousemove = function(x, y) { + this.events.push({ type: 'onmousemove', x: x, y: y, + run: function(e) { if (e.onmousemove) e.onmousemove(); } + }); + } + + this.eventElements = []; + + this.checkPath = function(element, ctx) { + for (var i=0; i<this.events.length; i++) { + var e = this.events[i]; + if (ctx.isPointInPath && ctx.isPointInPath(e.x, e.y)) this.eventElements[i] = element; + } + } + + this.checkBoundingBox = function(element, bb) { + for (var i=0; i<this.events.length; i++) { + var e = this.events[i]; + if (bb.isPointInBox(e.x, e.y)) this.eventElements[i] = element; + } + } + + this.runEvents = function() { + svg.ctx.canvas.style.cursor = ''; + + for (var i=0; i<this.events.length; i++) { + var e = this.events[i]; + var element = this.eventElements[i]; + while (element) { + e.run(element); + element = element.parent; + } + } + + // done running, clear + this.events = []; + this.eventElements = []; + } + }); + + return svg; + } +})(); + +if (CanvasRenderingContext2D) { + CanvasRenderingContext2D.prototype.drawSvg = function(s, dx, dy, dw, dh) { + canvg(this.canvas, s, { + ignoreMouse: true, + ignoreAnimation: true, + ignoreDimensions: true, + ignoreClear: true, + offsetX: dx, + offsetY: dy, + scaleWidth: dw, + scaleHeight: dh + }); + } +}/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * CanVGRenderer Extension module + * + * (c) 2011-2012 Torstein Honsi, Erik Olsson + * + * License: www.highcharts.com/license + */ + +// JSLint options: +/*global Highcharts */ + +(function (Highcharts) { // encapsulate + var UNDEFINED, + DIV = 'div', + ABSOLUTE = 'absolute', + RELATIVE = 'relative', + HIDDEN = 'hidden', + VISIBLE = 'visible', + PX = 'px', + css = Highcharts.css, + CanVGRenderer = Highcharts.CanVGRenderer, + SVGRenderer = Highcharts.SVGRenderer, + extend = Highcharts.extend, + merge = Highcharts.merge, + addEvent = Highcharts.addEvent, + createElement = Highcharts.createElement, + discardElement = Highcharts.discardElement; + + // Extend CanVG renderer on demand, inherit from SVGRenderer + extend(CanVGRenderer.prototype, SVGRenderer.prototype); + + // Add additional functionality: + extend(CanVGRenderer.prototype, { + create: function (chart, container, chartWidth, chartHeight) { + this.setContainer(container, chartWidth, chartHeight); + this.configure(chart); + }, + setContainer: function (container, chartWidth, chartHeight) { + var containerStyle = container.style, + containerParent = container.parentNode, + containerLeft = containerStyle.left, + containerTop = containerStyle.top, + containerOffsetWidth = container.offsetWidth, + containerOffsetHeight = container.offsetHeight, + canvas, + initialHiddenStyle = { visibility: HIDDEN, position: ABSOLUTE }; + + this.init.apply(this, [container, chartWidth, chartHeight]); + + // add the canvas above it + canvas = createElement('canvas', { + width: containerOffsetWidth, + height: containerOffsetHeight + }, { + position: RELATIVE, + left: containerLeft, + top: containerTop + }, container); + this.canvas = canvas; + + // Create the tooltip line and div, they are placed as siblings to + // the container (and as direct childs to the div specified in the html page) + this.ttLine = createElement(DIV, null, initialHiddenStyle, containerParent); + this.ttDiv = createElement(DIV, null, initialHiddenStyle, containerParent); + this.ttTimer = UNDEFINED; + + // Move away the svg node to a new div inside the container's parent so we can hide it. + var hiddenSvg = createElement(DIV, { + width: containerOffsetWidth, + height: containerOffsetHeight + }, { + visibility: HIDDEN, + left: containerLeft, + top: containerTop + }, containerParent); + this.hiddenSvg = hiddenSvg; + hiddenSvg.appendChild(this.box); + }, + + /** + * Configures the renderer with the chart. Attach a listener to the event tooltipRefresh. + **/ + configure: function (chart) { + var renderer = this, + options = chart.options.tooltip, + borderWidth = options.borderWidth, + tooltipDiv = renderer.ttDiv, + tooltipDivStyle = options.style, + tooltipLine = renderer.ttLine, + padding = parseInt(tooltipDivStyle.padding, 10); + + // Add border styling from options to the style + tooltipDivStyle = merge(tooltipDivStyle, { + padding: padding + PX, + 'background-color': options.backgroundColor, + 'border-style': 'solid', + 'border-width': borderWidth + PX, + 'border-radius': options.borderRadius + PX + }); + + // Optionally add shadow + if (options.shadow) { + tooltipDivStyle = merge(tooltipDivStyle, { + 'box-shadow': '1px 1px 3px gray', // w3c + '-webkit-box-shadow': '1px 1px 3px gray' // webkit + }); + } + css(tooltipDiv, tooltipDivStyle); + + // Set simple style on the line + css(tooltipLine, { + 'border-left': '1px solid darkgray' + }); + + // This event is triggered when a new tooltip should be shown + addEvent(chart, 'tooltipRefresh', function (args) { + var chartContainer = chart.container, + offsetLeft = chartContainer.offsetLeft, + offsetTop = chartContainer.offsetTop, + position; + + // Set the content of the tooltip + tooltipDiv.innerHTML = args.text; + + // Compute the best position for the tooltip based on the divs size and container size. + position = chart.tooltip.getPosition(tooltipDiv.offsetWidth, tooltipDiv.offsetHeight, {plotX: args.x, plotY: args.y}); + + css(tooltipDiv, { + visibility: VISIBLE, + left: position.x + PX, + top: position.y + PX, + 'border-color': args.borderColor + }); + + // Position the tooltip line + css(tooltipLine, { + visibility: VISIBLE, + left: offsetLeft + args.x + PX, + top: offsetTop + chart.plotTop + PX, + height: chart.plotHeight + PX + }); + + // This timeout hides the tooltip after 3 seconds + // First clear any existing timer + if (renderer.ttTimer !== UNDEFINED) { + clearTimeout(renderer.ttTimer); + } + + // Start a new timer that hides tooltip and line + renderer.ttTimer = setTimeout(function () { + css(tooltipDiv, { visibility: HIDDEN }); + css(tooltipLine, { visibility: HIDDEN }); + }, 3000); + }); + }, + + /** + * Extend SVGRenderer.destroy to also destroy the elements added by CanVGRenderer. + */ + destroy: function () { + var renderer = this; + + // Remove the canvas + discardElement(renderer.canvas); + + // Kill the timer + if (renderer.ttTimer !== UNDEFINED) { + clearTimeout(renderer.ttTimer); + } + + // Remove the divs for tooltip and line + discardElement(renderer.ttLine); + discardElement(renderer.ttDiv); + discardElement(renderer.hiddenSvg); + + // Continue with base class + return SVGRenderer.prototype.destroy.apply(renderer); + }, + + /** + * Take a color and return it if it's a string, do not make it a gradient even if it is a + * gradient. Currently canvg cannot render gradients (turns out black), + * see: http://code.google.com/p/canvg/issues/detail?id=104 + * + * @param {Object} color The color or config object + */ + color: function (color, elem, prop) { + if (color && color.linearGradient) { + // Pick the end color and forward to base implementation + color = color.stops[color.stops.length - 1][1]; + } + return SVGRenderer.prototype.color.call(this, color, elem, prop); + }, + + /** + * Draws the SVG on the canvas or adds a draw invokation to the deferred list. + */ + draw: function () { + var renderer = this; + window.canvg(renderer.canvas, renderer.hiddenSvg.innerHTML); + } + }); +}(Highcharts)); diff --git a/html/includes/js/modules/data.js b/html/includes/js/modules/data.js new file mode 100644 index 0000000..8a90423 --- /dev/null +++ b/html/includes/js/modules/data.js @@ -0,0 +1,24 @@ +/* + Data plugin for Highcharts + + (c) 2012-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(g){var j=g.each,q=HighchartsAdapter.inArray,s=g.splat,l,n=function(a,b){this.init(a,b)};g.extend(n.prototype,{init:function(a,b){this.options=a;this.chartOptions=b;this.columns=a.columns||this.rowsToColumns(a.rows)||[];this.rawColumns=[];this.columns.length?this.dataFound():(this.parseCSV(),this.parseTable(),this.parseGoogleSpreadsheet())},getColumnDistribution:function(){var a=this.chartOptions,b=this.options,c=[],f=function(a){return(g.seriesTypes[a||"line"].prototype.pointArrayMap||[0]).length}, +e=a&&a.chart&&a.chart.type,d=[],i=[],p,h;j(a&&a.series||[],function(a){d.push(f(a.type||e))});j(b&&b.seriesMapping||[],function(a){c.push(a.x||0)});c.length===0&&c.push(0);j(b&&b.seriesMapping||[],function(b){var c=new l,m,j=d[p]||f(e),o=g.seriesTypes[((a&&a.series||[])[p]||{}).type||e||"line"].prototype.pointArrayMap||["y"];c.addColumnReader(b.x,"x");for(m in b)b.hasOwnProperty(m)&&m!=="x"&&c.addColumnReader(b[m],m);for(h=0;h<j;h++)c.hasReader(o[h])||c.addColumnReader(void 0,o[h]);i.push(c);p++}); +b=g.seriesTypes[e||"line"].prototype.pointArrayMap;b===void 0&&(b=["y"]);this.valueCount={global:f(e),xColumns:c,individual:d,seriesBuilders:i,globalPointArrayMap:b}},dataFound:function(){if(this.options.switchRowsAndColumns)this.columns=this.rowsToColumns(this.columns);this.getColumnDistribution();this.parseTypes();this.findHeaderRow();this.parsed()!==!1&&this.complete()},parseCSV:function(){var a=this,b=this.options,c=b.csv,f=this.columns,e=b.startRow||0,d=b.endRow||Number.MAX_VALUE,i=b.startColumn|| +0,p=b.endColumn||Number.MAX_VALUE,h,g,r=0;c&&(g=c.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split(b.lineDelimiter||"\n"),h=b.itemDelimiter||(c.indexOf("\t")!==-1?"\t":","),j(g,function(b,c){var g=a.trim(b),t=g.indexOf("#")===0;c>=e&&c<=d&&!t&&g!==""&&(g=b.split(h),j(g,function(a,b){b>=i&&b<=p&&(f[b-i]||(f[b-i]=[]),f[b-i][r]=a)}),r+=1)}),this.dataFound())},parseTable:function(){var a=this.options,b=a.table,c=this.columns,f=a.startRow||0,e=a.endRow||Number.MAX_VALUE,d=a.startColumn||0,i=a.endColumn|| +Number.MAX_VALUE;b&&(typeof b==="string"&&(b=document.getElementById(b)),j(b.getElementsByTagName("tr"),function(a,b){b>=f&&b<=e&&j(a.children,function(a,e){if((a.tagName==="TD"||a.tagName==="TH")&&e>=d&&e<=i)c[e-d]||(c[e-d]=[]),c[e-d][b-f]=a.innerHTML})}),this.dataFound())},parseGoogleSpreadsheet:function(){var a=this,b=this.options,c=b.googleSpreadsheetKey,f=this.columns,e=b.startRow||0,d=b.endRow||Number.MAX_VALUE,i=b.startColumn||0,g=b.endColumn||Number.MAX_VALUE,h,j;c&&jQuery.ajax({dataType:"json", +url:"https://spreadsheets.google.com/feeds/cells/"+c+"/"+(b.googleSpreadsheetWorksheet||"od6")+"/public/values?alt=json-in-script&callback=?",error:b.error,success:function(b){var b=b.feed.entry,c,l=b.length,o=0,n=0,k;for(k=0;k<l;k++)c=b[k],o=Math.max(o,c.gs$cell.col),n=Math.max(n,c.gs$cell.row);for(k=0;k<o;k++)if(k>=i&&k<=g)f[k-i]=[],f[k-i].length=Math.min(n,d-e);for(k=0;k<l;k++)if(c=b[k],h=c.gs$cell.row-1,j=c.gs$cell.col-1,j>=i&&j<=g&&h>=e&&h<=d)f[j-i][h-e]=c.content.$t;a.dataFound()}})},findHeaderRow:function(){var a= +0;j(this.columns,function(b){b.isNumeric&&typeof b[0]!=="string"&&(a=null)});this.headerRow=a},trim:function(a){return typeof a==="string"?a.replace(/^\s+|\s+$/g,""):a},parseTypes:function(){for(var a=this.columns,b=this.rawColumns,c=a.length,f,e,d,i,g,h,j=[],l,m=this.chartOptions;c--;){f=a[c].length;b[c]=[];for(l=(g=q(c,this.valueCount.xColumns)!==-1)&&m&&m.xAxis&&s(m.xAxis)[0].type==="category";f--;)if(e=j[f]||a[c][f],d=parseFloat(e),i=b[c][f]=this.trim(e),l)a[c][f]=i;else if(i==d)a[c][f]=d,d>31536E6? +a[c].isDatetime=!0:a[c].isNumeric=!0;else if(d=this.parseDate(e),g&&typeof d==="number"&&!isNaN(d)){if(j[f]=e,a[c][f]=d,a[c].isDatetime=!0,a[c][f+1]!==void 0){e=d>a[c][f+1];if(e!==h&&h!==void 0)this.alternativeFormat?(this.dateFormat=this.alternativeFormat,f=a[c].length,this.alternativeFormat=this.dateFormats[this.dateFormat].alternative):a[c].unsorted=!0;h=e}}else if(a[c][f]=i===""?null:i,f!==0&&(a[c].isDatetime||a[c].isNumeric))a[c].mixed=!0;g&&a[c].mixed&&(a[c]=b[c])}if(a[0].isDatetime&&h){b=typeof a[0][0]!== +"number";for(c=0;c<a.length;c++)a[c].reverse(),b&&a[c].unshift(a[c].pop())}},dateFormats:{"YYYY-mm-dd":{regex:/^([0-9]{4})[\-\/\.]([0-9]{2})[\-\/\.]([0-9]{2})$/,parser:function(a){return Date.UTC(+a[1],a[2]-1,+a[3])}},"dd/mm/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(a){return Date.UTC(+a[3],a[2]-1,+a[1])},alternative:"mm/dd/YYYY"},"mm/dd/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(a){return Date.UTC(+a[3],a[1]-1,+a[2])}}, +"dd/mm/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,parser:function(a){return Date.UTC(+a[3]+2E3,a[2]-1,+a[1])},alternative:"mm/dd/YY"},"mm/dd/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,parser:function(a){console.log(a);return Date.UTC(+a[3]+2E3,a[1]-1,+a[2])}}},parseDate:function(a){var b=this.options.parseDate,c,f,e=this.options.dateFormat||this.dateFormat,d;b&&(c=b(a));if(typeof a==="string"){if(e)b=this.dateFormats[e],(d=a.match(b.regex))&&(c=b.parser(d)); +else for(f in this.dateFormats)if(b=this.dateFormats[f],d=a.match(b.regex)){this.dateFormat=f;this.alternativeFormat=b.alternative;c=b.parser(d);break}d||(d=Date.parse(a),typeof d==="object"&&d!==null&&d.getTime?c=d.getTime()-d.getTimezoneOffset()*6E4:typeof d==="number"&&!isNaN(d)&&(c=d-(new Date(d)).getTimezoneOffset()*6E4))}return c},rowsToColumns:function(a){var b,c,f,e,d;if(a){d=[];c=a.length;for(b=0;b<c;b++){e=a[b].length;for(f=0;f<e;f++)d[f]||(d[f]=[]),d[f][b]=a[b][f]}}return d},parsed:function(){if(this.options.parsed)return this.options.parsed.call(this, +this.columns)},getFreeIndexes:function(a,b){var c,f,e=[],d=[],i;for(f=0;f<a;f+=1)e.push(!0);for(c=0;c<b.length;c+=1){i=b[c].getReferencedColumnIndexes();for(f=0;f<i.length;f+=1)e[i[f]]=!1}for(f=0;f<e.length;f+=1)e[f]&&d.push(f);return d},complete:function(){var a=this.columns,b,c=this.options,f,e,d,i,g=[],h;if(c.complete||c.afterComplete){for(d=0;d<a.length;d++)if(this.headerRow===0)a[d].name=a[d].shift();f=[];e=this.getFreeIndexes(a.length,this.valueCount.seriesBuilders);for(d=0;d<this.valueCount.seriesBuilders.length;d++)h= +this.valueCount.seriesBuilders[d],h.populateColumns(e)&&g.push(h);for(;e.length>0;){h=new l;h.addColumnReader(0,"x");d=q(0,e);d!==-1&&e.splice(d,1);for(d=0;d<this.valueCount.global;d++)h.addColumnReader(void 0,this.valueCount.globalPointArrayMap[d]);h.populateColumns(e)&&g.push(h)}g.length>0&&g[0].readers.length>0&&(h=a[g[0].readers[0].columnIndex],h!==void 0&&(h.isDatetime?b="datetime":h.isNumeric||(b="category")));if(b==="category")for(d=0;d<g.length;d++){h=g[d];for(e=0;e<h.readers.length;e++)if(h.readers[e].configName=== +"x")h.readers[e].configName="name"}for(d=0;d<g.length;d++){h=g[d];e=[];for(i=0;i<a[0].length;i++)e[i]=h.read(a,i);f[d]={data:e};if(h.name)f[d].name=h.name}a={xAxis:{type:b},series:f};c.complete&&c.complete(a);c.afterComplete&&c.afterComplete(a)}}});g.Data=n;g.data=function(a,b){return new n(a,b)};g.wrap(g.Chart.prototype,"init",function(a,b,c){var f=this;b&&b.data?g.data(g.extend(b.data,{afterComplete:function(e){var d,i;if(b.hasOwnProperty("series"))if(typeof b.series==="object")for(d=Math.max(b.series.length, +e.series.length);d--;)i=b.series[d]||{},b.series[d]=g.merge(i,e.series[d]);else delete b.series;b=g.merge(e,b);a.call(f,b,c)}}),b):a.call(f,b,c)});l=function(){this.readers=[];this.pointIsArray=!0};l.prototype.populateColumns=function(a){var b=!0;j(this.readers,function(b){if(b.columnIndex===void 0)b.columnIndex=a.shift()});j(this.readers,function(a){a.columnIndex===void 0&&(b=!1)});return b};l.prototype.read=function(a,b){var c=this.pointIsArray,f=c?[]:{},e;j(this.readers,function(d){var e=a[d.columnIndex][b]; +c?f.push(e):f[d.configName]=e});if(this.name===void 0&&this.readers.length>=2&&(e=this.getReferencedColumnIndexes(),e.length>=2))e.shift(),e.sort(),this.name=a[e.shift()].name;return f};l.prototype.addColumnReader=function(a,b){this.readers.push({columnIndex:a,configName:b});if(!(b==="x"||b==="y"||b===void 0))this.pointIsArray=!1};l.prototype.getReferencedColumnIndexes=function(){var a,b=[],c;for(a=0;a<this.readers.length;a+=1)c=this.readers[a],c.columnIndex!==void 0&&b.push(c.columnIndex);return b}; +l.prototype.hasReader=function(a){var b,c;for(b=0;b<this.readers.length;b+=1)if(c=this.readers[b],c.configName===a)return!0}})(Highcharts); diff --git a/html/includes/js/modules/data.src.js b/html/includes/js/modules/data.src.js new file mode 100644 index 0000000..471307f --- /dev/null +++ b/html/includes/js/modules/data.src.js @@ -0,0 +1,1025 @@ +/** + * @license Data plugin for Highcharts + * + * (c) 2012-2014 Torstein Honsi + * + * License: www.highcharts.com/license + */ + +/* + * The Highcharts Data plugin is a utility to ease parsing of input sources like + * CSV, HTML tables or grid views into basic configuration options for use + * directly in the Highcharts constructor. + * + * Demo: http://jsfiddle.net/highcharts/SnLFj/ + * + * --- OPTIONS --- + * + * - columns : Array<Array<Mixed>> + * A two-dimensional array representing the input data on tabular form. This input can + * be used when the data is already parsed, for example from a grid view component. + * Each cell can be a string or number. If not switchRowsAndColumns is set, the columns + * are interpreted as series. See also the rows option. + * + * - complete : Function(chartOptions) + * The callback that is evaluated when the data is finished loading, optionally from an + * external source, and parsed. The first argument passed is a finished chart options + * object, containing the series. Thise options + * can be extended with additional options and passed directly to the chart constructor. This is + * related to the parsed callback, that goes in at an earlier stage. + * + * - csv : String + * A comma delimited string to be parsed. Related options are startRow, endRow, startColumn + * and endColumn to delimit what part of the table is used. The lineDelimiter and + * itemDelimiter options define the CSV delimiter formats. + * + * - dateFormat: String + * Which of the predefined date formats in Date.prototype.dateFormats to use to parse date + * columns, for example "dd/mm/YYYY" or "YYYY-mm-dd". Defaults to a best guess based on + * what format gives valid dates, and prefers ordered dates. + * + * - endColumn : Integer + * In tabular input data, the first row (indexed by 0) to use. Defaults to the last + * column containing data. + * + * - endRow : Integer + * In tabular input data, the last row (indexed by 0) to use. Defaults to the last row + * containing data. + * + * - googleSpreadsheetKey : String + * A Google Spreadsheet key. See https://developers.google.com/gdata/samples/spreadsheet_sample + * for general information on GS. + * + * - googleSpreadsheetWorksheet : String + * The Google Spreadsheet worksheet. The available id's can be read from + * https://spreadsheets.google.com/feeds/worksheets/{key}/public/basic + * + * - itemDelimiter : String + * Item or cell delimiter for parsing CSV. Defaults to the tab character "\t" if a tab character + * is found in the CSV string, if not it defaults to ",". + * + * - lineDelimiter : String + * Line delimiter for parsing CSV. Defaults to "\n". + * + * - parsed : Function + * A callback function to access the parsed columns, the two-dimentional input data + * array directly, before they are interpreted into series data and categories. See also + * the complete callback, that goes in on a later stage where the raw columns are interpreted + * into a Highcharts option structure. Return false to stop completion, or call this.complete() + * to continue async. + * + * - parseDate : Function + * A callback function to parse string representations of dates into JavaScript timestamps. + * Return an integer on success. + * + * - rows : Array<Array<Mixed>> + * The same as the columns input option, but defining rows intead of columns. + * + * - seriesMapping : Array<Object> + * An array containing object with Point property names along with what column id the + * property should be taken from. + * + * - startColumn : Integer + * In tabular input data, the first column (indexed by 0) to use. + * + * - startRow : Integer + * In tabular input data, the first row (indexed by 0) to use. + * + * - switchRowsAndColumns : Boolean + * Switch rows and columns of the input data, so that this.columns effectively becomes the + * rows of the data set, and the rows are interpreted as series. + * + * - table : String|HTMLElement + * A HTML table or the id of such to be parsed as input data. Related options ara startRow, + * endRow, startColumn and endColumn to delimit what part of the table is used. + */ + +/* + * TODO: + * - Handle various date formats + * - http://jsfiddle.net/highcharts/114wejdx/ + * - http://jsfiddle.net/highcharts/ryv67bkq/ + */ + +// JSLint options: +/*global jQuery, HighchartsAdapter */ + +(function (Highcharts) { // docs + + // Utilities + var each = Highcharts.each, + inArray = HighchartsAdapter.inArray, + splat = Highcharts.splat, + SeriesBuilder; + + + // The Data constructor + var Data = function (dataOptions, chartOptions) { + this.init(dataOptions, chartOptions); + }; + + // Set the prototype properties + Highcharts.extend(Data.prototype, { + + /** + * Initialize the Data object with the given options + */ + init: function (options, chartOptions) { + this.options = options; + this.chartOptions = chartOptions; + this.columns = options.columns || this.rowsToColumns(options.rows) || []; + + // This is a two-dimensional array holding the raw, trimmed string values + // with the same organisation as the columns array. It makes it possible + // for example to revert from interpreted timestamps to string-based + // categories. + this.rawColumns = []; + + // No need to parse or interpret anything + if (this.columns.length) { + this.dataFound(); + + // Parse and interpret + } else { + + // Parse a CSV string if options.csv is given + this.parseCSV(); + + // Parse a HTML table if options.table is given + this.parseTable(); + + // Parse a Google Spreadsheet + this.parseGoogleSpreadsheet(); + } + + }, + + /** + * Get the column distribution. For example, a line series takes a single column for + * Y values. A range series takes two columns for low and high values respectively, + * and an OHLC series takes four columns. + */ + getColumnDistribution: function () { + var chartOptions = this.chartOptions, + options = this.options, + xColumns = [], + getValueCount = function (type) { + return (Highcharts.seriesTypes[type || 'line'].prototype.pointArrayMap || [0]).length; + }, + getPointArrayMap = function (type) { + return Highcharts.seriesTypes[type || 'line'].prototype.pointArrayMap; + }, + globalType = chartOptions && chartOptions.chart && chartOptions.chart.type, + individualCounts = [], + seriesBuilders = [], + seriesIndex, + i; + + each((chartOptions && chartOptions.series) || [], function (series) { + individualCounts.push(getValueCount(series.type || globalType)); + }); + + // Collect the x-column indexes from seriesMapping + each((options && options.seriesMapping) || [], function (mapping) { + xColumns.push(mapping.x || 0); + }); + + // If there are no defined series with x-columns, use the first column as x column + if (xColumns.length === 0) { + xColumns.push(0); + } + + // Loop all seriesMappings and constructs SeriesBuilders from + // the mapping options. + each((options && options.seriesMapping) || [], function (mapping) { + var builder = new SeriesBuilder(), + name, + numberOfValueColumnsNeeded = individualCounts[seriesIndex] || getValueCount(globalType), + seriesArr = (chartOptions && chartOptions.series) || [], + series = seriesArr[seriesIndex] || {}, + pointArrayMap = getPointArrayMap(series.type || globalType) || ['y']; + + // Add an x reader from the x property or from an undefined column + // if the property is not set. It will then be auto populated later. + builder.addColumnReader(mapping.x, 'x'); + + // Add all column mappings + for (name in mapping) { + if (mapping.hasOwnProperty(name) && name !== 'x') { + builder.addColumnReader(mapping[name], name); + } + } + + // Add missing columns + for (i = 0; i < numberOfValueColumnsNeeded; i++) { + if (!builder.hasReader(pointArrayMap[i])) { + //builder.addNextColumnReader(pointArrayMap[i]); + // Create and add a column reader for the next free column index + builder.addColumnReader(undefined, pointArrayMap[i]); + } + } + + seriesBuilders.push(builder); + seriesIndex++; + }); + + var globalPointArrayMap = getPointArrayMap(globalType); + if (globalPointArrayMap === undefined) { + globalPointArrayMap = ['y']; + } + + this.valueCount = { + global: getValueCount(globalType), + xColumns: xColumns, + individual: individualCounts, + seriesBuilders: seriesBuilders, + globalPointArrayMap: globalPointArrayMap + }; + }, + + /** + * When the data is parsed into columns, either by CSV, table, GS or direct input, + * continue with other operations. + */ + dataFound: function () { + + if (this.options.switchRowsAndColumns) { + this.columns = this.rowsToColumns(this.columns); + } + + // Interpret the info about series and columns + this.getColumnDistribution(); + + // Interpret the values into right types + this.parseTypes(); + + // Use first row for series names? + this.findHeaderRow(); + + // Handle columns if a handleColumns callback is given + if (this.parsed() !== false) { + + // Complete if a complete callback is given + this.complete(); + } + + }, + + /** + * Parse a CSV input string + */ + parseCSV: function () { + var self = this, + options = this.options, + csv = options.csv, + columns = this.columns, + startRow = options.startRow || 0, + endRow = options.endRow || Number.MAX_VALUE, + startColumn = options.startColumn || 0, + endColumn = options.endColumn || Number.MAX_VALUE, + itemDelimiter, + lines, + activeRowNo = 0; + + if (csv) { + + lines = csv + .replace(/\r\n/g, "\n") // Unix + .replace(/\r/g, "\n") // Mac + .split(options.lineDelimiter || "\n"); + + itemDelimiter = options.itemDelimiter || (csv.indexOf('\t') !== -1 ? '\t' : ','); + + each(lines, function (line, rowNo) { + var trimmed = self.trim(line), + isComment = trimmed.indexOf('#') === 0, + isBlank = trimmed === '', + items; + + if (rowNo >= startRow && rowNo <= endRow && !isComment && !isBlank) { + items = line.split(itemDelimiter); + each(items, function (item, colNo) { + if (colNo >= startColumn && colNo <= endColumn) { + if (!columns[colNo - startColumn]) { + columns[colNo - startColumn] = []; + } + + columns[colNo - startColumn][activeRowNo] = item; + } + }); + activeRowNo += 1; + } + }); + + this.dataFound(); + } + }, + + /** + * Parse a HTML table + */ + parseTable: function () { + var options = this.options, + table = options.table, + columns = this.columns, + startRow = options.startRow || 0, + endRow = options.endRow || Number.MAX_VALUE, + startColumn = options.startColumn || 0, + endColumn = options.endColumn || Number.MAX_VALUE; + + if (table) { + + if (typeof table === 'string') { + table = document.getElementById(table); + } + + each(table.getElementsByTagName('tr'), function (tr, rowNo) { + if (rowNo >= startRow && rowNo <= endRow) { + each(tr.children, function (item, colNo) { + if ((item.tagName === 'TD' || item.tagName === 'TH') && colNo >= startColumn && colNo <= endColumn) { + if (!columns[colNo - startColumn]) { + columns[colNo - startColumn] = []; + } + + columns[colNo - startColumn][rowNo - startRow] = item.innerHTML; + } + }); + } + }); + + this.dataFound(); // continue + } + }, + + /** + */ + parseGoogleSpreadsheet: function () { + var self = this, + options = this.options, + googleSpreadsheetKey = options.googleSpreadsheetKey, + columns = this.columns, + startRow = options.startRow || 0, + endRow = options.endRow || Number.MAX_VALUE, + startColumn = options.startColumn || 0, + endColumn = options.endColumn || Number.MAX_VALUE, + gr, // google row + gc; // google column + + if (googleSpreadsheetKey) { + jQuery.ajax({ + dataType: 'json', + url: 'https://spreadsheets.google.com/feeds/cells/' + + googleSpreadsheetKey + '/' + (options.googleSpreadsheetWorksheet || 'od6') + + '/public/values?alt=json-in-script&callback=?', + error: options.error, + success: function (json) { + // Prepare the data from the spreadsheat + var cells = json.feed.entry, + cell, + cellCount = cells.length, + colCount = 0, + rowCount = 0, + i; + + // First, find the total number of columns and rows that + // are actually filled with data + for (i = 0; i < cellCount; i++) { + cell = cells[i]; + colCount = Math.max(colCount, cell.gs$cell.col); + rowCount = Math.max(rowCount, cell.gs$cell.row); + } + + // Set up arrays containing the column data + for (i = 0; i < colCount; i++) { + if (i >= startColumn && i <= endColumn) { + // Create new columns with the length of either end-start or rowCount + columns[i - startColumn] = []; + + // Setting the length to avoid jslint warning + columns[i - startColumn].length = Math.min(rowCount, endRow - startRow); + } + } + + // Loop over the cells and assign the value to the right + // place in the column arrays + for (i = 0; i < cellCount; i++) { + cell = cells[i]; + gr = cell.gs$cell.row - 1; // rows start at 1 + gc = cell.gs$cell.col - 1; // columns start at 1 + + // If both row and col falls inside start and end + // set the transposed cell value in the newly created columns + if (gc >= startColumn && gc <= endColumn && + gr >= startRow && gr <= endRow) { + columns[gc - startColumn][gr - startRow] = cell.content.$t; + } + } + self.dataFound(); + } + }); + } + }, + + /** + * Find the header row. For now, we just check whether the first row contains + * numbers or strings. Later we could loop down and find the first row with + * numbers. + */ + findHeaderRow: function () { + var headerRow = 0; + each(this.columns, function (column) { + if (column.isNumeric && typeof column[0] !== 'string') { + headerRow = null; + } + }); + this.headerRow = headerRow; + }, + + /** + * Trim a string from whitespace + */ + trim: function (str) { + return typeof str === 'string' ? str.replace(/^\s+|\s+$/g, '') : str; + }, + + /** + * Parse numeric cells in to number types and date types in to true dates. + */ + parseTypes: function () { + var columns = this.columns, + rawColumns = this.rawColumns, + col = columns.length, + row, + val, + floatVal, + trimVal, + isXColumn, + dateVal, + descending, + backup = [], + diff, + hasHeaderRow, + forceCategory, + chartOptions = this.chartOptions; + + while (col--) { + row = columns[col].length; + rawColumns[col] = []; + isXColumn = inArray(col, this.valueCount.xColumns) !== -1; + forceCategory = isXColumn && chartOptions && chartOptions.xAxis && splat(chartOptions.xAxis)[0].type === 'category'; + while (row--) { + val = backup[row] || columns[col][row]; + floatVal = parseFloat(val); + trimVal = rawColumns[col][row] = this.trim(val); + + // Disable number or date parsing by setting the X axis type to category + if (forceCategory) { + columns[col][row] = trimVal; + + /*jslint eqeq: true*/ + } else if (trimVal == floatVal) { // is numeric + /*jslint eqeq: false*/ + columns[col][row] = floatVal; + + // If the number is greater than milliseconds in a year, assume datetime + if (floatVal > 365 * 24 * 3600 * 1000) { + columns[col].isDatetime = true; + } else { + columns[col].isNumeric = true; + } + + } else { // string, continue to determine if it is a date string or really a string + dateVal = this.parseDate(val); + // Only allow parsing of dates if this column is an x-column + if (isXColumn && typeof dateVal === 'number' && !isNaN(dateVal)) { // is date + backup[row] = val; + columns[col][row] = dateVal; + columns[col].isDatetime = true; + + // Check if the dates are uniformly descending or ascending. If they + // are not, chances are that they are a different time format, so check + // for alternative. + if (columns[col][row + 1] !== undefined) { + diff = dateVal > columns[col][row + 1]; + if (diff !== descending && descending !== undefined) { + if (this.alternativeFormat) { + this.dateFormat = this.alternativeFormat; + row = columns[col].length; + this.alternativeFormat = this.dateFormats[this.dateFormat].alternative; + } else { + columns[col].unsorted = true; + } + } + descending = diff; + } + + } else { // string + columns[col][row] = trimVal === '' ? null : trimVal; + if (row !== 0 && (columns[col].isDatetime || columns[col].isNumeric)) { + columns[col].mixed = true; + } + } + } + } + + // If strings are intermixed with numbers or dates in a parsed column, it is an indication + // that parsing went wrong or the data was not intended to display as numbers or dates and + // parsing is too aggressive. Fall back to categories. Demonstrated in the + // highcharts/demo/column-drilldown sample. + if (isXColumn && columns[col].mixed) { + columns[col] = rawColumns[col]; + } + } + + // If the 0 column is date and descending, reverse all columns. + // TODO: probably this should apply to xColumns, not 0 column alone. + if (columns[0].isDatetime && descending) { + hasHeaderRow = typeof columns[0][0] !== 'number'; + for (col = 0; col < columns.length; col++) { + columns[col].reverse(); + if (hasHeaderRow) { + columns[col].unshift(columns[col].pop()); + } + } + } + }, + + /** + * A collection of available date formats, extendable from the outside to support + * custom date formats. + */ + dateFormats: { + 'YYYY-mm-dd': { + regex: /^([0-9]{4})[\-\/\.]([0-9]{2})[\-\/\.]([0-9]{2})$/, + parser: function (match) { + return Date.UTC(+match[1], match[2] - 1, +match[3]); + } + }, + 'dd/mm/YYYY': { + regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/, + parser: function (match) { + return Date.UTC(+match[3], match[2] - 1, +match[1]); + }, + alternative: 'mm/dd/YYYY' // different format with the same regex + }, + 'mm/dd/YYYY': { + regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/, + parser: function (match) { + return Date.UTC(+match[3], match[1] - 1, +match[2]); + } + }, + 'dd/mm/YY': { + regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/, + parser: function (match) { + return Date.UTC(+match[3] + 2000, match[2] - 1, +match[1]); + }, + alternative: 'mm/dd/YY' // different format with the same regex + }, + 'mm/dd/YY': { + regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/, + parser: function (match) { + console.log(match) + return Date.UTC(+match[3] + 2000, match[1] - 1, +match[2]); + } + } + }, + + /** + * Parse a date and return it as a number. Overridable through options.parseDate. + */ + parseDate: function (val) { + var parseDate = this.options.parseDate, + ret, + key, + format, + dateFormat = this.options.dateFormat || this.dateFormat, + match; + + if (parseDate) { + ret = parseDate(val); + } + + if (typeof val === 'string') { + // Auto-detect the date format the first time + if (!dateFormat) { + for (key in this.dateFormats) { + format = this.dateFormats[key]; + match = val.match(format.regex); + if (match) { + this.dateFormat = dateFormat = key; + this.alternativeFormat = format.alternative; + ret = format.parser(match); + break; + } + } + // Next time, use the one previously found + } else { + format = this.dateFormats[dateFormat]; + match = val.match(format.regex); + if (match) { + ret = format.parser(match); + } + } + // Fall back to Date.parse + if (!match) { + match = Date.parse(val); + // External tools like Date.js and MooTools extend Date object and + // returns a date. + if (typeof match === 'object' && match !== null && match.getTime) { + ret = match.getTime() - match.getTimezoneOffset() * 60000; + + // Timestamp + } else if (typeof match === 'number' && !isNaN(match)) { + ret = match - (new Date(match)).getTimezoneOffset() * 60000; + } + } + } + return ret; + }, + + /** + * Reorganize rows into columns + */ + rowsToColumns: function (rows) { + var row, + rowsLength, + col, + colsLength, + columns; + + if (rows) { + columns = []; + rowsLength = rows.length; + for (row = 0; row < rowsLength; row++) { + colsLength = rows[row].length; + for (col = 0; col < colsLength; col++) { + if (!columns[col]) { + columns[col] = []; + } + columns[col][row] = rows[row][col]; + } + } + } + return columns; + }, + + /** + * A hook for working directly on the parsed columns + */ + parsed: function () { + if (this.options.parsed) { + return this.options.parsed.call(this, this.columns); + } + }, + + getFreeIndexes: function (numberOfColumns, seriesBuilders) { + var s, + i, + freeIndexes = [], + freeIndexValues = [], + referencedIndexes; + + // Add all columns as free + for (i = 0; i < numberOfColumns; i = i + 1) { + freeIndexes.push(true); + } + + // Loop all defined builders and remove their referenced columns + for (s = 0; s < seriesBuilders.length; s = s + 1) { + referencedIndexes = seriesBuilders[s].getReferencedColumnIndexes(); + + for (i = 0; i < referencedIndexes.length; i = i + 1) { + freeIndexes[referencedIndexes[i]] = false; + } + } + + // Collect the values for the free indexes + for (i = 0; i < freeIndexes.length; i = i + 1) { + if (freeIndexes[i]) { + freeIndexValues.push(i); + } + } + + return freeIndexValues; + }, + + /** + * If a complete callback function is provided in the options, interpret the + * columns into a Highcharts options object. + */ + complete: function () { + + var columns = this.columns, + xColumns = [], + type, + options = this.options, + series, + data, + i, + j, + r, + seriesIndex, + chartOptions, + allSeriesBuilders = [], + builder, + freeIndexes, + typeCol, + index; + + xColumns.length = columns.length; + if (options.complete || options.afterComplete) { + + // Get the names and shift the top row + for (i = 0; i < columns.length; i++) { + if (this.headerRow === 0) { + columns[i].name = columns[i].shift(); + } + } + + // Use the next columns for series + series = []; + freeIndexes = this.getFreeIndexes(columns.length, this.valueCount.seriesBuilders); + + // Populate defined series + for (seriesIndex = 0; seriesIndex < this.valueCount.seriesBuilders.length; seriesIndex++) { + builder = this.valueCount.seriesBuilders[seriesIndex]; + + // If the builder can be populated with remaining columns, then add it to allBuilders + if (builder.populateColumns(freeIndexes)) { + allSeriesBuilders.push(builder); + } + } + + // Populate dynamic series + while (freeIndexes.length > 0) { + builder = new SeriesBuilder(); + builder.addColumnReader(0, 'x'); + + // Mark index as used (not free) + index = inArray(0, freeIndexes); + if (index !== -1) { + freeIndexes.splice(index, 1); + } + + for (i = 0; i < this.valueCount.global; i++) { + // Create and add a column reader for the next free column index + builder.addColumnReader(undefined, this.valueCount.globalPointArrayMap[i]); + } + + // If the builder can be populated with remaining columns, then add it to allBuilders + if (builder.populateColumns(freeIndexes)) { + allSeriesBuilders.push(builder); + } + } + + // Get the data-type from the first series x column + if (allSeriesBuilders.length > 0 && allSeriesBuilders[0].readers.length > 0) { + typeCol = columns[allSeriesBuilders[0].readers[0].columnIndex]; + if (typeCol !== undefined) { + if (typeCol.isDatetime) { + type = 'datetime'; + } else if (!typeCol.isNumeric) { + type = 'category'; + } + } + } + // Axis type is category, then the "x" column should be called "name" + if (type === 'category') { + for (seriesIndex = 0; seriesIndex < allSeriesBuilders.length; seriesIndex++) { + builder = allSeriesBuilders[seriesIndex]; + for (r = 0; r < builder.readers.length; r++) { + if (builder.readers[r].configName === 'x') { + builder.readers[r].configName = 'name'; + } + } + } + } + + // Read data for all builders + for (seriesIndex = 0; seriesIndex < allSeriesBuilders.length; seriesIndex++) { + builder = allSeriesBuilders[seriesIndex]; + + // Iterate down the cells of each column and add data to the series + data = []; + for (j = 0; j < columns[0].length; j++) { // TODO: which column's length should we use here + data[j] = builder.read(columns, j); + } + + // Add the series + series[seriesIndex] = { + data: data + }; + if (builder.name) { + series[seriesIndex].name = builder.name; + } + } + + + + // Do the callback + chartOptions = { + xAxis: { + type: type + }, + series: series + }; + if (options.complete) { + options.complete(chartOptions); + } + + // The afterComplete hook is used internally to avoid conflict with the externally + // available complete option. + if (options.afterComplete) { + options.afterComplete(chartOptions); + } + } + } + }); + + // Register the Data prototype and data function on Highcharts + Highcharts.Data = Data; + Highcharts.data = function (options, chartOptions) { + return new Data(options, chartOptions); + }; + + // Extend Chart.init so that the Chart constructor accepts a new configuration + // option group, data. + Highcharts.wrap(Highcharts.Chart.prototype, 'init', function (proceed, userOptions, callback) { + var chart = this; + + if (userOptions && userOptions.data) { + Highcharts.data(Highcharts.extend(userOptions.data, { + + afterComplete: function (dataOptions) { + var i, series; + + // Merge series configs + if (userOptions.hasOwnProperty('series')) { + if (typeof userOptions.series === 'object') { + i = Math.max(userOptions.series.length, dataOptions.series.length); + while (i--) { + series = userOptions.series[i] || {}; + userOptions.series[i] = Highcharts.merge(series, dataOptions.series[i]); + } + } else { // Allow merging in dataOptions.series (#2856) + delete userOptions.series; + } + } + + // Do the merge + userOptions = Highcharts.merge(dataOptions, userOptions); + + proceed.call(chart, userOptions, callback); + } + }), userOptions); + } else { + proceed.call(chart, userOptions, callback); + } + }); + + /** + * Creates a new SeriesBuilder. A SeriesBuilder consists of a number + * of ColumnReaders that reads columns and give them a name. + * Ex: A series builder can be constructed to read column 3 as 'x' and + * column 7 and 8 as 'y1' and 'y2'. + * The output would then be points/rows of the form {x: 11, y1: 22, y2: 33} + * + * The name of the builder is taken from the second column. In the above + * example it would be the column with index 7. + * @constructor + */ + SeriesBuilder = function () { + this.readers = []; + this.pointIsArray = true; + }; + + /** + * Populates readers with column indexes. A reader can be added without + * a specific index and for those readers the index is taken sequentially + * from the free columns (this is handled by the ColumnCursor instance). + * @returns {boolean} + */ + SeriesBuilder.prototype.populateColumns = function (freeIndexes) { + var builder = this, + enoughColumns = true; + + // Loop each reader and give it an index if its missing. + // The freeIndexes.shift() will return undefined if there + // are no more columns. + each(builder.readers, function (reader) { + if (reader.columnIndex === undefined) { + reader.columnIndex = freeIndexes.shift(); + } + }); + + // Now, all readers should have columns mapped. If not + // then return false to signal that this series should + // not be added. + each(builder.readers, function (reader) { + if (reader.columnIndex === undefined) { + enoughColumns = false; + } + }); + + return enoughColumns; + }; + + /** + * Reads a row from the dataset and returns a point or array depending + * on the names of the readers. + * @param columns + * @param rowIndex + * @returns {Array | Object} + */ + SeriesBuilder.prototype.read = function (columns, rowIndex) { + var builder = this, + pointIsArray = builder.pointIsArray, + point = pointIsArray ? [] : {}, + columnIndexes; + + // Loop each reader and ask it to read its value. + // Then, build an array or point based on the readers names. + each(builder.readers, function (reader) { + var value = columns[reader.columnIndex][rowIndex]; + if (pointIsArray) { + point.push(value); + } else { + point[reader.configName] = value; + } + }); + + // The name comes from the first column (excluding the x column) + if (this.name === undefined && builder.readers.length >= 2) { + columnIndexes = builder.getReferencedColumnIndexes(); + if (columnIndexes.length >= 2) { + // remove the first one (x col) + columnIndexes.shift(); + + // Sort the remaining + columnIndexes.sort(); + + // Now use the lowest index as name column + this.name = columns[columnIndexes.shift()].name; + } + } + + return point; + }; + + /** + * Creates and adds ColumnReader from the given columnIndex and configName. + * ColumnIndex can be undefined and in that case the reader will be given + * an index when columns are populated. + * @param columnIndex {Number | undefined} + * @param configName + */ + SeriesBuilder.prototype.addColumnReader = function (columnIndex, configName) { + this.readers.push({ + columnIndex: columnIndex, + configName: configName + }); + + if (!(configName === 'x' || configName === 'y' || configName === undefined)) { + this.pointIsArray = false; + } + }; + + /** + * Returns an array of column indexes that the builder will use when + * reading data. + * @returns {Array} + */ + SeriesBuilder.prototype.getReferencedColumnIndexes = function () { + var i, + referencedColumnIndexes = [], + columnReader; + + for (i = 0; i < this.readers.length; i = i + 1) { + columnReader = this.readers[i]; + if (columnReader.columnIndex !== undefined) { + referencedColumnIndexes.push(columnReader.columnIndex); + } + } + + return referencedColumnIndexes; + }; + + /** + * Returns true if the builder has a reader for the given configName. + * @param configName + * @returns {boolean} + */ + SeriesBuilder.prototype.hasReader = function (configName) { + var i, columnReader; + for (i = 0; i < this.readers.length; i = i + 1) { + columnReader = this.readers[i]; + if (columnReader.configName === configName) { + return true; + } + } + // Else return undefined + }; + + + +}(Highcharts)); diff --git a/html/includes/js/modules/drilldown.js b/html/includes/js/modules/drilldown.js new file mode 100644 index 0000000..4388a1e --- /dev/null +++ b/html/includes/js/modules/drilldown.js @@ -0,0 +1,15 @@ +(function(g){function t(a,b,d){return"rgba("+[Math.round(a[0]+(b[0]-a[0])*d),Math.round(a[1]+(b[1]-a[1])*d),Math.round(a[2]+(b[2]-a[2])*d),a[3]+(b[3]-a[3])*d].join(",")+")"}var u=function(){},o=g.getOptions(),i=g.each,p=g.extend,z=g.format,A=g.pick,q=g.wrap,l=g.Chart,n=g.seriesTypes,v=n.pie,m=n.column,w=HighchartsAdapter.fireEvent,x=HighchartsAdapter.inArray,r=[];p(o.lang,{drillUpText:"◁ Back to {series.name}"});o.drilldown={activeAxisLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold", +textDecoration:"underline"},activeDataLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold",textDecoration:"underline"},animation:{duration:500},drillUpButton:{position:{align:"right",x:-10,y:10}}};g.SVGRenderer.prototype.Element.prototype.fadeIn=function(a){this.attr({opacity:0.1,visibility:"inherit"}).animate({opacity:A(this.newOpacity,1)},a||{duration:250})};l.prototype.addSeriesAsDrilldown=function(a,b){this.addSingleSeriesAsDrilldown(a,b);this.applyDrilldown()};l.prototype.addSingleSeriesAsDrilldown= +function(a,b){var d=a.series,c=d.xAxis,f=d.yAxis,h;h=a.color||d.color;var e,y=[],g=[],k;k=d.levelNumber||0;b=p({color:h},b);e=x(a,d.points);i(d.chart.series,function(a){if(a.xAxis===c)y.push(a),g.push(a.userOptions),a.levelNumber=a.levelNumber||k});h={levelNumber:k,seriesOptions:d.userOptions,levelSeriesOptions:g,levelSeries:y,shapeArgs:a.shapeArgs,bBox:a.graphic.getBBox(),color:h,lowerSeriesOptions:b,pointOptions:d.options.data[e],pointIndex:e,oldExtremes:{xMin:c&&c.userMin,xMax:c&&c.userMax,yMin:f&& +f.userMin,yMax:f&&f.userMax}};if(!this.drilldownLevels)this.drilldownLevels=[];this.drilldownLevels.push(h);h=h.lowerSeries=this.addSeries(b,!1);h.levelNumber=k+1;if(c)c.oldPos=c.pos,c.userMin=c.userMax=null,f.userMin=f.userMax=null;if(d.type===h.type)h.animate=h.animateDrilldown||u,h.options.animation=!0};l.prototype.applyDrilldown=function(){var a=this.drilldownLevels,b;if(a&&a.length>0)b=a[a.length-1].levelNumber,i(this.drilldownLevels,function(a){a.levelNumber===b&&i(a.levelSeries,function(a){a.levelNumber=== +b&&a.remove(!1)})});this.redraw();this.showDrillUpButton()};l.prototype.getDrilldownBackText=function(){var a=this.drilldownLevels;if(a&&a.length>0)return a=a[a.length-1],a.series=a.seriesOptions,z(this.options.lang.drillUpText,a)};l.prototype.showDrillUpButton=function(){var a=this,b=this.getDrilldownBackText(),d=a.options.drilldown.drillUpButton,c,f;this.drillUpButton?this.drillUpButton.attr({text:b}).align():(f=(c=d.theme)&&c.states,this.drillUpButton=this.renderer.button(b,null,null,function(){a.drillUp()}, +c,f&&f.hover,f&&f.select).attr({align:d.position.align,zIndex:9}).add().align(d.position,!1,d.relativeTo||"plotBox"))};l.prototype.drillUp=function(){for(var a=this,b=a.drilldownLevels,d=b[b.length-1].levelNumber,c=b.length,f=a.series,h=f.length,e,g,j,k,l=function(b){var c;i(f,function(a){a.userOptions===b&&(c=a)});c=c||a.addSeries(b,!1);if(c.type===g.type&&c.animateDrillupTo)c.animate=c.animateDrillupTo;b===e.seriesOptions&&(j=c)};c--;)if(e=b[c],e.levelNumber===d){b.pop();g=e.lowerSeries;if(!g.chart)for(;h--;)if(f[h].options.id=== +e.lowerSeriesOptions.id){g=f[h];break}g.xData=[];i(e.levelSeriesOptions,l);w(a,"drillup",{seriesOptions:e.seriesOptions});if(j.type===g.type)j.drilldownLevel=e,j.options.animation=a.options.drilldown.animation,g.animateDrillupFrom&&g.animateDrillupFrom(e);j.levelNumber=d;g.remove(!1);if(j.xAxis)k=e.oldExtremes,j.xAxis.setExtremes(k.xMin,k.xMax,!1),j.yAxis.setExtremes(k.yMin,k.yMax,!1)}this.redraw();this.drilldownLevels.length===0?this.drillUpButton=this.drillUpButton.destroy():this.drillUpButton.attr({text:this.getDrilldownBackText()}).align(); +r.length=[]};m.prototype.supportsDrilldown=!0;m.prototype.animateDrillupTo=function(a){if(!a){var b=this,d=b.drilldownLevel;i(this.points,function(a){a.graphic.hide();a.dataLabel&&a.dataLabel.hide();a.connector&&a.connector.hide()});setTimeout(function(){i(b.points,function(a,b){var h=b===(d&&d.pointIndex)?"show":"fadeIn",e=h==="show"?!0:void 0;a.graphic[h](e);if(a.dataLabel)a.dataLabel[h](e);if(a.connector)a.connector[h](e)})},Math.max(this.chart.options.drilldown.animation.duration-50,0));this.animate= +u}};m.prototype.animateDrilldown=function(a){var b=this,d=this.chart.drilldownLevels,c=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1].shapeArgs,f=this.chart.options.drilldown.animation;if(!a)i(d,function(a){if(b.userOptions===a.lowerSeriesOptions)c=a.shapeArgs}),c.x+=this.xAxis.oldPos-this.xAxis.pos,i(this.points,function(a){a.graphic&&a.graphic.attr(c).animate(a.shapeArgs,f);a.dataLabel&&a.dataLabel.fadeIn(f)}),this.animate=null};m.prototype.animateDrillupFrom=function(a){var b= +this.chart.options.drilldown.animation,d=this.group,c=this;i(c.trackerGroups,function(a){if(c[a])c[a].on("mouseover")});delete this.group;i(this.points,function(c){var h=c.graphic,e=g.Color(c.color).rgba,i=g.Color(a.color).rgba,j=function(){h.destroy();d&&(d=d.destroy())};h&&(delete c.graphic,b?h.animate(a.shapeArgs,g.merge(b,{step:function(a,b){b.prop==="start"&&e.length===4&&i.length===4&&this.attr({fill:t(e,i,b.pos)})},complete:j})):(h.attr(a.shapeArgs),j()))})};v&&p(v.prototype,{supportsDrilldown:!0, +animateDrillupTo:m.prototype.animateDrillupTo,animateDrillupFrom:m.prototype.animateDrillupFrom,animateDrilldown:function(a){var b=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],d=this.chart.options.drilldown.animation,c=b.shapeArgs,f=c.start,h=(c.end-f)/this.points.length,e=g.Color(b.color).rgba;if(!a)i(this.points,function(a,b){var i=g.Color(a.color).rgba;a.graphic.attr(g.merge(c,{start:f+b*h,end:f+(b+1)*h}))[d?"animate":"attr"](a.shapeArgs,g.merge(d,{step:function(a,b){b.prop=== +"start"&&e.length===4&&i.length===4&&this.attr({fill:t(e,i,b.pos)})}}))}),this.animate=null}});g.Point.prototype.doDrilldown=function(a){for(var b=this.series.chart,d=b.options.drilldown,c=(d.series||[]).length,f;c--&&!f;)d.series[c].id===this.drilldown&&x(this.drilldown,r)===-1&&(f=d.series[c],r.push(this.drilldown));w(b,"drilldown",{point:this,seriesOptions:f});f&&(a?b.addSingleSeriesAsDrilldown(this,f):b.addSeriesAsDrilldown(this,f))};q(g.Point.prototype,"init",function(a,b,d,c){var f=a.call(this, +b,d,c),h=b.chart,e=(a=b.xAxis&&b.xAxis.ticks[c])&&a.label;if(f.drilldown){if(g.addEvent(f,"click",function(){f.doDrilldown()}),e){if(!e.basicStyles)e.basicStyles=g.merge(e.styles);e.addClass("highcharts-drilldown-axis-label").css(h.options.drilldown.activeAxisLabelStyle).on("click",function(){i(e.ddPoints,function(a){a.doDrilldown&&a.doDrilldown(!0)});h.applyDrilldown()});if(!e.ddPoints)e.ddPoints=[];e.ddPoints.push(f)}}else if(e&&e.basicStyles)e.styles={},e.css(e.basicStyles);return f});q(g.Series.prototype, +"drawDataLabels",function(a){var b=this.chart.options.drilldown.activeDataLabelStyle;a.call(this);i(this.points,function(a){if(a.drilldown&&a.dataLabel)a.dataLabel.attr({"class":"highcharts-drilldown-data-label"}).css(b).on("click",function(){a.doDrilldown()})})});var s,o=function(a){a.call(this);i(this.points,function(a){a.drilldown&&a.graphic&&a.graphic.attr({"class":"highcharts-drilldown-point"}).css({cursor:"pointer"})})};for(s in n)n[s].prototype.supportsDrilldown&&q(n[s].prototype,"drawTracker", +o)})(Highcharts); diff --git a/html/includes/js/modules/drilldown.src.js b/html/includes/js/modules/drilldown.src.js new file mode 100644 index 0000000..cd3522c --- /dev/null +++ b/html/includes/js/modules/drilldown.src.js @@ -0,0 +1,606 @@ +/** + * Highcharts Drilldown plugin + * + * Author: Torstein Honsi + * License: MIT License + * + * Demo: http://jsfiddle.net/highcharts/Vf3yT/ + */ + +/*global HighchartsAdapter*/ +(function (H) { + + "use strict"; + + var noop = function () {}, + defaultOptions = H.getOptions(), + each = H.each, + extend = H.extend, + format = H.format, + pick = H.pick, + wrap = H.wrap, + Chart = H.Chart, + seriesTypes = H.seriesTypes, + PieSeries = seriesTypes.pie, + ColumnSeries = seriesTypes.column, + fireEvent = HighchartsAdapter.fireEvent, + inArray = HighchartsAdapter.inArray, + dupes = []; + + // Utilities + function tweenColors(startColor, endColor, pos) { + var rgba = [ + Math.round(startColor[0] + (endColor[0] - startColor[0]) * pos), + Math.round(startColor[1] + (endColor[1] - startColor[1]) * pos), + Math.round(startColor[2] + (endColor[2] - startColor[2]) * pos), + startColor[3] + (endColor[3] - startColor[3]) * pos + ]; + return 'rgba(' + rgba.join(',') + ')'; + } + + // Add language + extend(defaultOptions.lang, { + drillUpText: '◁ Back to {series.name}' + }); + defaultOptions.drilldown = { + activeAxisLabelStyle: { + cursor: 'pointer', + color: '#0d233a', + fontWeight: 'bold', + textDecoration: 'underline' + }, + activeDataLabelStyle: { + cursor: 'pointer', + color: '#0d233a', + fontWeight: 'bold', + textDecoration: 'underline' + }, + animation: { + duration: 500 + }, + drillUpButton: { + position: { + align: 'right', + x: -10, + y: 10 + } + // relativeTo: 'plotBox' + // theme + } + }; + + /** + * A general fadeIn method + */ + H.SVGRenderer.prototype.Element.prototype.fadeIn = function (animation) { + this + .attr({ + opacity: 0.1, + visibility: 'inherit' + }) + .animate({ + opacity: pick(this.newOpacity, 1) // newOpacity used in maps + }, animation || { + duration: 250 + }); + }; + + Chart.prototype.addSeriesAsDrilldown = function (point, ddOptions) { + this.addSingleSeriesAsDrilldown(point, ddOptions); + this.applyDrilldown(); + }; + Chart.prototype.addSingleSeriesAsDrilldown = function (point, ddOptions) { + var oldSeries = point.series, + xAxis = oldSeries.xAxis, + yAxis = oldSeries.yAxis, + newSeries, + color = point.color || oldSeries.color, + pointIndex, + levelSeries = [], + levelSeriesOptions = [], + level, + levelNumber; + + levelNumber = oldSeries.levelNumber || 0; + + ddOptions = extend({ + color: color + }, ddOptions); + pointIndex = inArray(point, oldSeries.points); + + // Record options for all current series + each(oldSeries.chart.series, function (series) { + if (series.xAxis === xAxis) { + levelSeries.push(series); + levelSeriesOptions.push(series.userOptions); + series.levelNumber = series.levelNumber || levelNumber; // #3182 + } + }); + + // Add a record of properties for each drilldown level + level = { + levelNumber: levelNumber, + seriesOptions: oldSeries.userOptions, + levelSeriesOptions: levelSeriesOptions, + levelSeries: levelSeries, + shapeArgs: point.shapeArgs, + bBox: point.graphic.getBBox(), + color: color, + lowerSeriesOptions: ddOptions, + pointOptions: oldSeries.options.data[pointIndex], + pointIndex: pointIndex, + oldExtremes: { + xMin: xAxis && xAxis.userMin, + xMax: xAxis && xAxis.userMax, + yMin: yAxis && yAxis.userMin, + yMax: yAxis && yAxis.userMax + } + }; + + // Generate and push it to a lookup array + if (!this.drilldownLevels) { + this.drilldownLevels = []; + } + this.drilldownLevels.push(level); + + newSeries = level.lowerSeries = this.addSeries(ddOptions, false); + newSeries.levelNumber = levelNumber + 1; + if (xAxis) { + xAxis.oldPos = xAxis.pos; + xAxis.userMin = xAxis.userMax = null; + yAxis.userMin = yAxis.userMax = null; + } + + // Run fancy cross-animation on supported and equal types + if (oldSeries.type === newSeries.type) { + newSeries.animate = newSeries.animateDrilldown || noop; + newSeries.options.animation = true; + } + }; + + Chart.prototype.applyDrilldown = function () { + var drilldownLevels = this.drilldownLevels, + levelToRemove; + + if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading + levelToRemove = drilldownLevels[drilldownLevels.length - 1].levelNumber; + each(this.drilldownLevels, function (level) { + if (level.levelNumber === levelToRemove) { + each(level.levelSeries, function (series) { + if (series.levelNumber === levelToRemove) { // Not removed, not added as part of a multi-series drilldown + series.remove(false); + } + }); + } + }); + } + + this.redraw(); + this.showDrillUpButton(); + }; + + Chart.prototype.getDrilldownBackText = function () { + var drilldownLevels = this.drilldownLevels, + lastLevel; + if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading + lastLevel = drilldownLevels[drilldownLevels.length - 1]; + lastLevel.series = lastLevel.seriesOptions; + return format(this.options.lang.drillUpText, lastLevel); + } + + }; + + Chart.prototype.showDrillUpButton = function () { + var chart = this, + backText = this.getDrilldownBackText(), + buttonOptions = chart.options.drilldown.drillUpButton, + attr, + states; + + + if (!this.drillUpButton) { + attr = buttonOptions.theme; + states = attr && attr.states; + + this.drillUpButton = this.renderer.button( + backText, + null, + null, + function () { + chart.drillUp(); + }, + attr, + states && states.hover, + states && states.select + ) + .attr({ + align: buttonOptions.position.align, + zIndex: 9 + }) + .add() + .align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox'); + } else { + this.drillUpButton.attr({ + text: backText + }) + .align(); + } + }; + + Chart.prototype.drillUp = function () { + var chart = this, + drilldownLevels = chart.drilldownLevels, + levelNumber = drilldownLevels[drilldownLevels.length - 1].levelNumber, + i = drilldownLevels.length, + chartSeries = chart.series, + seriesI = chartSeries.length, + level, + oldSeries, + newSeries, + oldExtremes, + addSeries = function (seriesOptions) { + var addedSeries; + each(chartSeries, function (series) { + if (series.userOptions === seriesOptions) { + addedSeries = series; + } + }); + + addedSeries = addedSeries || chart.addSeries(seriesOptions, false); + if (addedSeries.type === oldSeries.type && addedSeries.animateDrillupTo) { + addedSeries.animate = addedSeries.animateDrillupTo; + } + if (seriesOptions === level.seriesOptions) { + newSeries = addedSeries; + } + }; + + while (i--) { + + level = drilldownLevels[i]; + if (level.levelNumber === levelNumber) { + drilldownLevels.pop(); + + // Get the lower series by reference or id + oldSeries = level.lowerSeries; + if (!oldSeries.chart) { // #2786 + while (seriesI--) { + if (chartSeries[seriesI].options.id === level.lowerSeriesOptions.id) { + oldSeries = chartSeries[seriesI]; + break; + } + } + } + oldSeries.xData = []; // Overcome problems with minRange (#2898) + + each(level.levelSeriesOptions, addSeries); + + fireEvent(chart, 'drillup', { seriesOptions: level.seriesOptions }); + + if (newSeries.type === oldSeries.type) { + newSeries.drilldownLevel = level; + newSeries.options.animation = chart.options.drilldown.animation; + + if (oldSeries.animateDrillupFrom) { + oldSeries.animateDrillupFrom(level); + } + } + newSeries.levelNumber = levelNumber; + + oldSeries.remove(false); + + // Reset the zoom level of the upper series + if (newSeries.xAxis) { + oldExtremes = level.oldExtremes; + newSeries.xAxis.setExtremes(oldExtremes.xMin, oldExtremes.xMax, false); + newSeries.yAxis.setExtremes(oldExtremes.yMin, oldExtremes.yMax, false); + } + } + } + + this.redraw(); + + if (this.drilldownLevels.length === 0) { + this.drillUpButton = this.drillUpButton.destroy(); + } else { + this.drillUpButton.attr({ + text: this.getDrilldownBackText() + }) + .align(); + } + + dupes.length = []; // #3315 + }; + + + ColumnSeries.prototype.supportsDrilldown = true; + + /** + * When drilling up, keep the upper series invisible until the lower series has + * moved into place + */ + ColumnSeries.prototype.animateDrillupTo = function (init) { + if (!init) { + var newSeries = this, + level = newSeries.drilldownLevel; + + each(this.points, function (point) { + point.graphic.hide(); + if (point.dataLabel) { + point.dataLabel.hide(); + } + if (point.connector) { + point.connector.hide(); + } + }); + + + // Do dummy animation on first point to get to complete + setTimeout(function () { + each(newSeries.points, function (point, i) { + // Fade in other points + var verb = i === (level && level.pointIndex) ? 'show' : 'fadeIn', + inherit = verb === 'show' ? true : undefined; + point.graphic[verb](inherit); + if (point.dataLabel) { + point.dataLabel[verb](inherit); + } + if (point.connector) { + point.connector[verb](inherit); + } + }); + }, Math.max(this.chart.options.drilldown.animation.duration - 50, 0)); + + // Reset + this.animate = noop; + } + + }; + + ColumnSeries.prototype.animateDrilldown = function (init) { + var series = this, + drilldownLevels = this.chart.drilldownLevels, + animateFrom = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1].shapeArgs, + animationOptions = this.chart.options.drilldown.animation; + + if (!init) { + each(drilldownLevels, function (level) { + if (series.userOptions === level.lowerSeriesOptions) { + animateFrom = level.shapeArgs; + } + }); + + animateFrom.x += (this.xAxis.oldPos - this.xAxis.pos); + + each(this.points, function (point) { + if (point.graphic) { + point.graphic + .attr(animateFrom) + .animate(point.shapeArgs, animationOptions); + } + if (point.dataLabel) { + point.dataLabel.fadeIn(animationOptions); + } + }); + this.animate = null; + } + + }; + + /** + * When drilling up, pull out the individual point graphics from the lower series + * and animate them into the origin point in the upper series. + */ + ColumnSeries.prototype.animateDrillupFrom = function (level) { + var animationOptions = this.chart.options.drilldown.animation, + group = this.group, + series = this; + + // Cancel mouse events on the series group (#2787) + each(series.trackerGroups, function (key) { + if (series[key]) { // we don't always have dataLabelsGroup + series[key].on('mouseover'); + } + }); + + + delete this.group; + each(this.points, function (point) { + var graphic = point.graphic, + startColor = H.Color(point.color).rgba, + endColor = H.Color(level.color).rgba, + complete = function () { + graphic.destroy(); + if (group) { + group = group.destroy(); + } + }; + + if (graphic) { + + delete point.graphic; + + if (animationOptions) { + /*jslint unparam: true*/ + graphic.animate(level.shapeArgs, H.merge(animationOptions, { + step: function (val, fx) { + if (fx.prop === 'start' && startColor.length === 4 && endColor.length === 4) { + this.attr({ + fill: tweenColors(startColor, endColor, fx.pos) + }); + } + }, + complete: complete + })); + /*jslint unparam: false*/ + } else { + graphic.attr(level.shapeArgs); + complete(); + } + } + }); + }; + + if (PieSeries) { + extend(PieSeries.prototype, { + supportsDrilldown: true, + animateDrillupTo: ColumnSeries.prototype.animateDrillupTo, + animateDrillupFrom: ColumnSeries.prototype.animateDrillupFrom, + + animateDrilldown: function (init) { + var level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1], + animationOptions = this.chart.options.drilldown.animation, + animateFrom = level.shapeArgs, + start = animateFrom.start, + angle = animateFrom.end - start, + startAngle = angle / this.points.length, + startColor = H.Color(level.color).rgba; + + if (!init) { + each(this.points, function (point, i) { + var endColor = H.Color(point.color).rgba; + + /*jslint unparam: true*/ + point.graphic + .attr(H.merge(animateFrom, { + start: start + i * startAngle, + end: start + (i + 1) * startAngle + }))[animationOptions ? 'animate' : 'attr'](point.shapeArgs, H.merge(animationOptions, { + step: function (val, fx) { + if (fx.prop === 'start' && startColor.length === 4 && endColor.length === 4) { + this.attr({ + fill: tweenColors(startColor, endColor, fx.pos) + }); + } + } + })); + /*jslint unparam: false*/ + }); + this.animate = null; + } + } + }); + } + + H.Point.prototype.doDrilldown = function (_holdRedraw) { + var series = this.series, + chart = series.chart, + drilldown = chart.options.drilldown, + i = (drilldown.series || []).length, + seriesOptions; + + while (i-- && !seriesOptions) { + if (drilldown.series[i].id === this.drilldown && inArray(this.drilldown, dupes) === -1) { + seriesOptions = drilldown.series[i]; + dupes.push(this.drilldown); + } + } + + // Fire the event. If seriesOptions is undefined, the implementer can check for + // seriesOptions, and call addSeriesAsDrilldown async if necessary. + fireEvent(chart, 'drilldown', { + point: this, + seriesOptions: seriesOptions + }); + + if (seriesOptions) { + if (_holdRedraw) { + chart.addSingleSeriesAsDrilldown(this, seriesOptions); + } else { + chart.addSeriesAsDrilldown(this, seriesOptions); + } + } + + }; + + wrap(H.Point.prototype, 'init', function (proceed, series, options, x) { + var point = proceed.call(this, series, options, x), + chart = series.chart, + tick = series.xAxis && series.xAxis.ticks[x], + tickLabel = tick && tick.label; + + if (point.drilldown) { + + // Add the click event to the point + H.addEvent(point, 'click', function () { + point.doDrilldown(); + }); + /*wrap(point, 'importEvents', function (proceed) { // wrapping importEvents makes point.click event work + if (!this.hasImportedEvents) { + proceed.call(this); + H.addEvent(this, 'click', function () { + this.doDrilldown(); + }); + } + });*/ + + // Make axis labels clickable + if (tickLabel) { + if (!tickLabel.basicStyles) { + tickLabel.basicStyles = H.merge(tickLabel.styles); + } + tickLabel + .addClass('highcharts-drilldown-axis-label') + .css(chart.options.drilldown.activeAxisLabelStyle) + .on('click', function () { + each(tickLabel.ddPoints, function (point) { + if (point.doDrilldown) { + point.doDrilldown(true); + } + }); + chart.applyDrilldown(); + }); + if (!tickLabel.ddPoints) { + tickLabel.ddPoints = []; + } + tickLabel.ddPoints.push(point); + + } + } else if (tickLabel && tickLabel.basicStyles) { + tickLabel.styles = {}; // reset for full overwrite of styles + tickLabel.css(tickLabel.basicStyles); + } + + return point; + }); + + wrap(H.Series.prototype, 'drawDataLabels', function (proceed) { + var css = this.chart.options.drilldown.activeDataLabelStyle; + + proceed.call(this); + + each(this.points, function (point) { + if (point.drilldown && point.dataLabel) { + point.dataLabel + .attr({ + 'class': 'highcharts-drilldown-data-label' + }) + .css(css) + .on('click', function () { + point.doDrilldown(); + }); + } + }); + }); + + // Mark the trackers with a pointer + var type, + drawTrackerWrapper = function (proceed) { + proceed.call(this); + each(this.points, function (point) { + if (point.drilldown && point.graphic) { + point.graphic + .attr({ + 'class': 'highcharts-drilldown-point' + }) + .css({ cursor: 'pointer' }); + } + }); + }; + for (type in seriesTypes) { + if (seriesTypes[type].prototype.supportsDrilldown) { + wrap(seriesTypes[type].prototype, 'drawTracker', drawTrackerWrapper); + } + } + +}(Highcharts)); diff --git a/html/includes/js/modules/exporting.js b/html/includes/js/modules/exporting.js new file mode 100644 index 0000000..cf150ea --- /dev/null +++ b/html/includes/js/modules/exporting.js @@ -0,0 +1,23 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + Exporting module + + (c) 2010-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(f){var A=f.Chart,t=f.addEvent,B=f.removeEvent,l=f.createElement,o=f.discardElement,v=f.css,k=f.merge,r=f.each,p=f.extend,D=Math.max,j=document,C=window,E=f.isTouchDevice,F=f.Renderer.prototype.symbols,s=f.getOptions(),y;p(s.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"});s.navigation={menuStyle:{border:"1px solid #A0A0A0", +background:"#FFFFFF",padding:"5px 0"},menuItemStyle:{padding:"0 10px",background:"none",color:"#303030",fontSize:E?"14px":"11px"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{symbolFill:"#E0E0E0",symbolSize:14,symbolStroke:"#666",symbolStrokeWidth:3,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,theme:{fill:"white",stroke:"none"},verticalAlign:"top",width:24}};s.exporting={type:"image/png",url:"http://export.highcharts.com/",buttons:{contextButton:{menuClassName:"highcharts-contextmenu", +symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}};f.post=function(b,a,d){var c,b=l("form",k({method:"post", +action:b,enctype:"multipart/form-data"},d),{display:"none"},j.body);for(c in a)l("input",{type:"hidden",name:c,value:a[c]},null,b);b.submit();o(b)};p(A.prototype,{getSVG:function(b){var a=this,d,c,z,h,g=k(a.options,b);if(!j.createElementNS)j.createElementNS=function(a,b){return j.createElement(b)};b=l("div",null,{position:"absolute",top:"-9999em",width:a.chartWidth+"px",height:a.chartHeight+"px"},j.body);c=a.renderTo.style.width;h=a.renderTo.style.height;c=g.exporting.sourceWidth||g.chart.width|| +/px$/.test(c)&&parseInt(c,10)||600;h=g.exporting.sourceHeight||g.chart.height||/px$/.test(h)&&parseInt(h,10)||400;p(g.chart,{animation:!1,renderTo:b,forExport:!0,width:c,height:h});g.exporting.enabled=!1;g.series=[];r(a.series,function(a){z=k(a.options,{animation:!1,enableMouseTracking:!1,showCheckbox:!1,visible:a.visible});z.isInternal||g.series.push(z)});d=new f.Chart(g,a.callback);r(["xAxis","yAxis"],function(b){r(a[b],function(a,c){var g=d[b][c],f=a.getExtremes(),h=f.userMin,f=f.userMax;g&&(h!== +void 0||f!==void 0)&&g.setExtremes(h,f,!0,!1)})});c=d.container.innerHTML;g=null;d.destroy();o(b);c=c.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g," xlink:href=").replace(/\n/," ").replace(/<\/svg>.*?$/,"</svg>").replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g,'$1="rgb($2)" $1-opacity="$3"').replace(/ /g, +" ").replace(/­/g,"").replace(/<IMG /g,"<image ").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g,'width="$1"').replace(/hc-svg-href="([^"]+)">/g,'xlink:href="$1"/>').replace(/id=([^" >]+)/g,'id="$1"').replace(/class=([^" >]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:(path|rect)/g,"$1").replace(/style="([^"]+)"/g,function(a){return a.toLowerCase()});return c=c.replace(/(url\(#highcharts-[0-9]+)"/g,"$1").replace(/"/g,"'")},exportChart:function(b,a){var b= +b||{},d=this.options.exporting,d=this.getSVG(k({chart:{borderRadius:0}},d.chartOptions,a,{exporting:{sourceWidth:b.sourceWidth||d.sourceWidth,sourceHeight:b.sourceHeight||d.sourceHeight}})),b=k(this.options.exporting,b);f.post(b.url,{filename:b.filename||"chart",type:b.type,width:b.width||0,scale:b.scale||2,svg:d},b.formAttributes)},print:function(){var b=this,a=b.container,d=[],c=a.parentNode,f=j.body,h=f.childNodes;if(!b.isPrinting)b.isPrinting=!0,r(h,function(a,b){if(a.nodeType===1)d[b]=a.style.display, +a.style.display="none"}),f.appendChild(a),C.focus(),C.print(),setTimeout(function(){c.appendChild(a);r(h,function(a,b){if(a.nodeType===1)a.style.display=d[b]});b.isPrinting=!1},1E3)},contextMenu:function(b,a,d,c,f,h,g){var e=this,k=e.options.navigation,q=k.menuItemStyle,m=e.chartWidth,n=e.chartHeight,j="cache-"+b,i=e[j],u=D(f,h),w,x,o,s=function(a){e.pointer.inClass(a.target,b)||x()};if(!i)e[j]=i=l("div",{className:b},{position:"absolute",zIndex:1E3,padding:u+"px"},e.container),w=l("div",null,p({MozBoxShadow:"3px 3px 10px #888", +WebkitBoxShadow:"3px 3px 10px #888",boxShadow:"3px 3px 10px #888"},k.menuStyle),i),x=function(){v(i,{display:"none"});g&&g.setState(0);e.openMenu=!1},t(i,"mouseleave",function(){o=setTimeout(x,500)}),t(i,"mouseenter",function(){clearTimeout(o)}),t(document,"mouseup",s),t(e,"destroy",function(){B(document,"mouseup",s)}),r(a,function(a){if(a){var b=a.separator?l("hr",null,null,w):l("div",{onmouseover:function(){v(this,k.menuItemHoverStyle)},onmouseout:function(){v(this,q)},onclick:function(){x();a.onclick.apply(e, +arguments)},innerHTML:a.text||e.options.lang[a.textKey]},p({cursor:"pointer"},q),w);e.exportDivElements.push(b)}}),e.exportDivElements.push(w,i),e.exportMenuWidth=i.offsetWidth,e.exportMenuHeight=i.offsetHeight;a={display:"block"};d+e.exportMenuWidth>m?a.right=m-d-f-u+"px":a.left=d-u+"px";c+h+e.exportMenuHeight>n&&g.alignOptions.verticalAlign!=="top"?a.bottom=n-c-u+"px":a.top=c+h-u+"px";v(i,a);e.openMenu=!0},addButton:function(b){var a=this,d=a.renderer,c=k(a.options.navigation.buttonOptions,b),j= +c.onclick,h=c.menuItems,g,e,l={stroke:c.symbolStroke,fill:c.symbolFill},q=c.symbolSize||12;if(!a.btnCount)a.btnCount=0;if(!a.exportDivElements)a.exportDivElements=[],a.exportSVGElements=[];if(c.enabled!==!1){var m=c.theme,n=m.states,o=n&&n.hover,n=n&&n.select,i;delete m.states;j?i=function(){j.apply(a,arguments)}:h&&(i=function(){a.contextMenu(e.menuClassName,h,e.translateX,e.translateY,e.width,e.height,e);e.setState(2)});c.text&&c.symbol?m.paddingLeft=f.pick(m.paddingLeft,25):c.text||p(m,{width:c.width, +height:c.height,padding:0});e=d.button(c.text,0,0,i,m,o,n).attr({title:a.options.lang[c._titleKey],"stroke-linecap":"round"});e.menuClassName=b.menuClassName||"highcharts-menu-"+a.btnCount++;c.symbol&&(g=d.symbol(c.symbol,c.symbolX-q/2,c.symbolY-q/2,q,q).attr(p(l,{"stroke-width":c.symbolStrokeWidth||1,zIndex:1})).add(e));e.add().align(p(c,{width:e.width,x:f.pick(c.x,y)}),!0,"spacingBox");y+=(e.width+c.buttonSpacing)*(c.align==="right"?-1:1);a.exportSVGElements.push(e,g)}},destroyExport:function(b){var b= +b.target,a,d;for(a=0;a<b.exportSVGElements.length;a++)if(d=b.exportSVGElements[a])d.onclick=d.ontouchstart=null,b.exportSVGElements[a]=d.destroy();for(a=0;a<b.exportDivElements.length;a++)d=b.exportDivElements[a],B(d,"mouseleave"),b.exportDivElements[a]=d.onmouseout=d.onmouseover=d.ontouchstart=d.onclick=null,o(d)}});F.menu=function(b,a,d,c){return["M",b,a+2.5,"L",b+d,a+2.5,"M",b,a+c/2+0.5,"L",b+d,a+c/2+0.5,"M",b,a+c-1.5,"L",b+d,a+c-1.5]};A.prototype.callbacks.push(function(b){var a,d=b.options.exporting, +c=d.buttons;y=0;if(d.enabled!==!1){for(a in c)b.addButton(c[a]);t(b,"destroy",b.destroyExport)}})})(Highcharts); diff --git a/html/includes/js/modules/exporting.src.js b/html/includes/js/modules/exporting.src.js new file mode 100644 index 0000000..2111990 --- /dev/null +++ b/html/includes/js/modules/exporting.src.js @@ -0,0 +1,719 @@ +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * Exporting module + * + * (c) 2010-2014 Torstein Honsi + * + * License: www.highcharts.com/license + */ + +// JSLint options: +/*global Highcharts, document, window, Math, setTimeout */ + +(function (Highcharts) { // encapsulate + +// create shortcuts +var Chart = Highcharts.Chart, + addEvent = Highcharts.addEvent, + removeEvent = Highcharts.removeEvent, + createElement = Highcharts.createElement, + discardElement = Highcharts.discardElement, + css = Highcharts.css, + merge = Highcharts.merge, + each = Highcharts.each, + extend = Highcharts.extend, + math = Math, + mathMax = math.max, + doc = document, + win = window, + isTouchDevice = Highcharts.isTouchDevice, + M = 'M', + L = 'L', + DIV = 'div', + HIDDEN = 'hidden', + NONE = 'none', + PREFIX = 'highcharts-', + ABSOLUTE = 'absolute', + PX = 'px', + UNDEFINED, + symbols = Highcharts.Renderer.prototype.symbols, + defaultOptions = Highcharts.getOptions(), + buttonOffset; + + // Add language + extend(defaultOptions.lang, { + printChart: 'Print chart', + downloadPNG: 'Download PNG image', + downloadJPEG: 'Download JPEG image', + downloadPDF: 'Download PDF document', + downloadSVG: 'Download SVG vector image', + contextButtonTitle: 'Chart context menu' + }); + +// Buttons and menus are collected in a separate config option set called 'navigation'. +// This can be extended later to add control buttons like zoom and pan right click menus. +defaultOptions.navigation = { + menuStyle: { + border: '1px solid #A0A0A0', + background: '#FFFFFF', + padding: '5px 0' + }, + menuItemStyle: { + padding: '0 10px', + background: NONE, + color: '#303030', + fontSize: isTouchDevice ? '14px' : '11px' + }, + menuItemHoverStyle: { + background: '#4572A5', + color: '#FFFFFF' + }, + + buttonOptions: { + symbolFill: '#E0E0E0', + symbolSize: 14, + symbolStroke: '#666', + symbolStrokeWidth: 3, + symbolX: 12.5, + symbolY: 10.5, + align: 'right', + buttonSpacing: 3, + height: 22, + // text: null, + theme: { + fill: 'white', // capture hover + stroke: 'none' + }, + verticalAlign: 'top', + width: 24 + } +}; + + + +// Add the export related options +defaultOptions.exporting = { + //enabled: true, + //filename: 'chart', + type: 'image/png', + url: 'http://export.highcharts.com/', + //width: undefined, + //scale: 2 + buttons: { + contextButton: { + menuClassName: PREFIX + 'contextmenu', + //x: -10, + symbol: 'menu', + _titleKey: 'contextButtonTitle', + menuItems: [{ + textKey: 'printChart', + onclick: function () { + this.print(); + } + }, { + separator: true + }, { + textKey: 'downloadPNG', + onclick: function () { + this.exportChart(); + } + }, { + textKey: 'downloadJPEG', + onclick: function () { + this.exportChart({ + type: 'image/jpeg' + }); + } + }, { + textKey: 'downloadPDF', + onclick: function () { + this.exportChart({ + type: 'application/pdf' + }); + } + }, { + textKey: 'downloadSVG', + onclick: function () { + this.exportChart({ + type: 'image/svg+xml' + }); + } + } + // Enable this block to add "View SVG" to the dropdown menu + /* + ,{ + + text: 'View SVG', + onclick: function () { + var svg = this.getSVG() + .replace(/</g, '\n<') + .replace(/>/g, '>'); + + doc.body.innerHTML = '<pre>' + svg + '</pre>'; + } + } // */ + ] + } + } +}; + +// Add the Highcharts.post utility +Highcharts.post = function (url, data, formAttributes) { + var name, + form; + + // create the form + form = createElement('form', merge({ + method: 'post', + action: url, + enctype: 'multipart/form-data' + }, formAttributes), { + display: NONE + }, doc.body); + + // add the data + for (name in data) { + createElement('input', { + type: HIDDEN, + name: name, + value: data[name] + }, null, form); + } + + // submit + form.submit(); + + // clean up + discardElement(form); +}; + +extend(Chart.prototype, { + + /** + * Return an SVG representation of the chart + * + * @param additionalOptions {Object} Additional chart options for the generated SVG representation + */ + getSVG: function (additionalOptions) { + var chart = this, + chartCopy, + sandbox, + svg, + seriesOptions, + sourceWidth, + sourceHeight, + cssWidth, + cssHeight, + options = merge(chart.options, additionalOptions); // copy the options and add extra options + + // IE compatibility hack for generating SVG content that it doesn't really understand + if (!doc.createElementNS) { + /*jslint unparam: true*//* allow unused parameter ns in function below */ + doc.createElementNS = function (ns, tagName) { + return doc.createElement(tagName); + }; + /*jslint unparam: false*/ + } + + // create a sandbox where a new chart will be generated + sandbox = createElement(DIV, null, { + position: ABSOLUTE, + top: '-9999em', + width: chart.chartWidth + PX, + height: chart.chartHeight + PX + }, doc.body); + + // get the source size + cssWidth = chart.renderTo.style.width; + cssHeight = chart.renderTo.style.height; + sourceWidth = options.exporting.sourceWidth || + options.chart.width || + (/px$/.test(cssWidth) && parseInt(cssWidth, 10)) || + 600; + sourceHeight = options.exporting.sourceHeight || + options.chart.height || + (/px$/.test(cssHeight) && parseInt(cssHeight, 10)) || + 400; + + // override some options + extend(options.chart, { + animation: false, + renderTo: sandbox, + forExport: true, + width: sourceWidth, + height: sourceHeight + }); + options.exporting.enabled = false; // hide buttons in print + + // prepare for replicating the chart + options.series = []; + each(chart.series, function (serie) { + seriesOptions = merge(serie.options, { + animation: false, // turn off animation + enableMouseTracking: false, + showCheckbox: false, + visible: serie.visible + }); + + if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set + options.series.push(seriesOptions); + } + }); + + // generate the chart copy + chartCopy = new Highcharts.Chart(options, chart.callback); + + // reflect axis extremes in the export + each(['xAxis', 'yAxis'], function (axisType) { + each(chart[axisType], function (axis, i) { + var axisCopy = chartCopy[axisType][i], + extremes = axis.getExtremes(), + userMin = extremes.userMin, + userMax = extremes.userMax; + + if (axisCopy && (userMin !== UNDEFINED || userMax !== UNDEFINED)) { + axisCopy.setExtremes(userMin, userMax, true, false); + } + }); + }); + + // get the SVG from the container's innerHTML + svg = chartCopy.container.innerHTML; + + // free up memory + options = null; + chartCopy.destroy(); + discardElement(sandbox); + + // sanitize + svg = svg + .replace(/zIndex="[^"]+"/g, '') + .replace(/isShadow="[^"]+"/g, '') + .replace(/symbolName="[^"]+"/g, '') + .replace(/jQuery[0-9]+="[^"]+"/g, '') + .replace(/url\([^#]+#/g, 'url(#') + .replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ') + .replace(/ href=/g, ' xlink:href=') + .replace(/\n/, ' ') + // Any HTML added to the container after the SVG (#894) + .replace(/<\/svg>.*?$/, '</svg>') + // Batik doesn't support rgba fills and strokes (#3095) + .replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, '$1="rgb($2)" $1-opacity="$3"') + /* This fails in IE < 8 + .replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight + return s2 +'.'+ s3[0]; + })*/ + + // Replace HTML entities, issue #347 + .replace(/ /g, '\u00A0') // no-break space + .replace(/­/g, '\u00AD') // soft hyphen + + // IE specific + .replace(/<IMG /g, '<image ') + .replace(/height=([^" ]+)/g, 'height="$1"') + .replace(/width=([^" ]+)/g, 'width="$1"') + .replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>') + .replace(/id=([^" >]+)/g, 'id="$1"') + .replace(/class=([^" >]+)/g, 'class="$1"') + .replace(/ transform /g, ' ') + .replace(/:(path|rect)/g, '$1') + .replace(/style="([^"]+)"/g, function (s) { + return s.toLowerCase(); + }); + + // IE9 beta bugs with innerHTML. Test again with final IE9. + svg = svg.replace(/(url\(#highcharts-[0-9]+)"/g, '$1') + .replace(/"/g, "'"); + + return svg; + }, + + /** + * Submit the SVG representation of the chart to the server + * @param {Object} options Exporting options. Possible members are url, type, width and formAttributes. + * @param {Object} chartOptions Additional chart options for the SVG representation of the chart + */ + exportChart: function (options, chartOptions) { + options = options || {}; + + var chart = this, + chartExportingOptions = chart.options.exporting, + svg = chart.getSVG(merge( + { chart: { borderRadius: 0 } }, + chartExportingOptions.chartOptions, + chartOptions, + { + exporting: { + sourceWidth: options.sourceWidth || chartExportingOptions.sourceWidth, + sourceHeight: options.sourceHeight || chartExportingOptions.sourceHeight + } + } + )); + + // merge the options + options = merge(chart.options.exporting, options); + + // do the post + Highcharts.post(options.url, { + filename: options.filename || 'chart', + type: options.type, + width: options.width || 0, // IE8 fails to post undefined correctly, so use 0 + scale: options.scale || 2, + svg: svg + }, options.formAttributes); + + }, + + /** + * Print the chart + */ + print: function () { + + var chart = this, + container = chart.container, + origDisplay = [], + origParent = container.parentNode, + body = doc.body, + childNodes = body.childNodes; + + if (chart.isPrinting) { // block the button while in printing mode + return; + } + + chart.isPrinting = true; + + // hide all body content + each(childNodes, function (node, i) { + if (node.nodeType === 1) { + origDisplay[i] = node.style.display; + node.style.display = NONE; + } + }); + + // pull out the chart + body.appendChild(container); + + // print + win.focus(); // #1510 + win.print(); + + // allow the browser to prepare before reverting + setTimeout(function () { + + // put the chart back in + origParent.appendChild(container); + + // restore all body content + each(childNodes, function (node, i) { + if (node.nodeType === 1) { + node.style.display = origDisplay[i]; + } + }); + + chart.isPrinting = false; + + }, 1000); + + }, + + /** + * Display a popup menu for choosing the export type + * + * @param {String} className An identifier for the menu + * @param {Array} items A collection with text and onclicks for the items + * @param {Number} x The x position of the opener button + * @param {Number} y The y position of the opener button + * @param {Number} width The width of the opener button + * @param {Number} height The height of the opener button + */ + contextMenu: function (className, items, x, y, width, height, button) { + var chart = this, + navOptions = chart.options.navigation, + menuItemStyle = navOptions.menuItemStyle, + chartWidth = chart.chartWidth, + chartHeight = chart.chartHeight, + cacheName = 'cache-' + className, + menu = chart[cacheName], + menuPadding = mathMax(width, height), // for mouse leave detection + boxShadow = '3px 3px 10px #888', + innerMenu, + hide, + hideTimer, + menuStyle, + docMouseUpHandler = function (e) { + if (!chart.pointer.inClass(e.target, className)) { + hide(); + } + }; + + // create the menu only the first time + if (!menu) { + + // create a HTML element above the SVG + chart[cacheName] = menu = createElement(DIV, { + className: className + }, { + position: ABSOLUTE, + zIndex: 1000, + padding: menuPadding + PX + }, chart.container); + + innerMenu = createElement(DIV, null, + extend({ + MozBoxShadow: boxShadow, + WebkitBoxShadow: boxShadow, + boxShadow: boxShadow + }, navOptions.menuStyle), menu); + + // hide on mouse out + hide = function () { + css(menu, { display: NONE }); + if (button) { + button.setState(0); + } + chart.openMenu = false; + }; + + // Hide the menu some time after mouse leave (#1357) + addEvent(menu, 'mouseleave', function () { + hideTimer = setTimeout(hide, 500); + }); + addEvent(menu, 'mouseenter', function () { + clearTimeout(hideTimer); + }); + + + // Hide it on clicking or touching outside the menu (#2258, #2335, #2407) + addEvent(document, 'mouseup', docMouseUpHandler); + addEvent(chart, 'destroy', function () { + removeEvent(document, 'mouseup', docMouseUpHandler); + }); + + + // create the items + each(items, function (item) { + if (item) { + var element = item.separator ? + createElement('hr', null, null, innerMenu) : + createElement(DIV, { + onmouseover: function () { + css(this, navOptions.menuItemHoverStyle); + }, + onmouseout: function () { + css(this, menuItemStyle); + }, + onclick: function () { + hide(); + item.onclick.apply(chart, arguments); + }, + innerHTML: item.text || chart.options.lang[item.textKey] + }, extend({ + cursor: 'pointer' + }, menuItemStyle), innerMenu); + + + // Keep references to menu divs to be able to destroy them + chart.exportDivElements.push(element); + } + }); + + // Keep references to menu and innerMenu div to be able to destroy them + chart.exportDivElements.push(innerMenu, menu); + + chart.exportMenuWidth = menu.offsetWidth; + chart.exportMenuHeight = menu.offsetHeight; + } + + menuStyle = { display: 'block' }; + + // if outside right, right align it + if (x + chart.exportMenuWidth > chartWidth) { + menuStyle.right = (chartWidth - x - width - menuPadding) + PX; + } else { + menuStyle.left = (x - menuPadding) + PX; + } + // if outside bottom, bottom align it + if (y + height + chart.exportMenuHeight > chartHeight && button.alignOptions.verticalAlign !== 'top') { + menuStyle.bottom = (chartHeight - y - menuPadding) + PX; + } else { + menuStyle.top = (y + height - menuPadding) + PX; + } + + css(menu, menuStyle); + chart.openMenu = true; + }, + + /** + * Add the export button to the chart + */ + addButton: function (options) { + var chart = this, + renderer = chart.renderer, + btnOptions = merge(chart.options.navigation.buttonOptions, options), + onclick = btnOptions.onclick, + menuItems = btnOptions.menuItems, + symbol, + button, + symbolAttr = { + stroke: btnOptions.symbolStroke, + fill: btnOptions.symbolFill + }, + symbolSize = btnOptions.symbolSize || 12; + if (!chart.btnCount) { + chart.btnCount = 0; + } + + // Keeps references to the button elements + if (!chart.exportDivElements) { + chart.exportDivElements = []; + chart.exportSVGElements = []; + } + + if (btnOptions.enabled === false) { + return; + } + + + var attr = btnOptions.theme, + states = attr.states, + hover = states && states.hover, + select = states && states.select, + callback; + + delete attr.states; + + if (onclick) { + callback = function () { + onclick.apply(chart, arguments); + }; + + } else if (menuItems) { + callback = function () { + chart.contextMenu( + button.menuClassName, + menuItems, + button.translateX, + button.translateY, + button.width, + button.height, + button + ); + button.setState(2); + }; + } + + + if (btnOptions.text && btnOptions.symbol) { + attr.paddingLeft = Highcharts.pick(attr.paddingLeft, 25); + + } else if (!btnOptions.text) { + extend(attr, { + width: btnOptions.width, + height: btnOptions.height, + padding: 0 + }); + } + + button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select) + .attr({ + title: chart.options.lang[btnOptions._titleKey], + 'stroke-linecap': 'round' + }); + button.menuClassName = options.menuClassName || PREFIX + 'menu-' + chart.btnCount++; + + if (btnOptions.symbol) { + symbol = renderer.symbol( + btnOptions.symbol, + btnOptions.symbolX - (symbolSize / 2), + btnOptions.symbolY - (symbolSize / 2), + symbolSize, + symbolSize + ) + .attr(extend(symbolAttr, { + 'stroke-width': btnOptions.symbolStrokeWidth || 1, + zIndex: 1 + })).add(button); + } + + button.add() + .align(extend(btnOptions, { + width: button.width, + x: Highcharts.pick(btnOptions.x, buttonOffset) // #1654 + }), true, 'spacingBox'); + + buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1); + + chart.exportSVGElements.push(button, symbol); + + }, + + /** + * Destroy the buttons. + */ + destroyExport: function (e) { + var chart = e.target, + i, + elem; + + // Destroy the extra buttons added + for (i = 0; i < chart.exportSVGElements.length; i++) { + elem = chart.exportSVGElements[i]; + + // Destroy and null the svg/vml elements + if (elem) { // #1822 + elem.onclick = elem.ontouchstart = null; + chart.exportSVGElements[i] = elem.destroy(); + } + } + + // Destroy the divs for the menu + for (i = 0; i < chart.exportDivElements.length; i++) { + elem = chart.exportDivElements[i]; + + // Remove the event handler + removeEvent(elem, 'mouseleave'); + + // Remove inline events + chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null; + + // Destroy the div by moving to garbage bin + discardElement(elem); + } + } +}); + + +symbols.menu = function (x, y, width, height) { + var arr = [ + M, x, y + 2.5, + L, x + width, y + 2.5, + M, x, y + height / 2 + 0.5, + L, x + width, y + height / 2 + 0.5, + M, x, y + height - 1.5, + L, x + width, y + height - 1.5 + ]; + return arr; +}; + +// Add the buttons on chart load +Chart.prototype.callbacks.push(function (chart) { + var n, + exportingOptions = chart.options.exporting, + buttons = exportingOptions.buttons; + + buttonOffset = 0; + + if (exportingOptions.enabled !== false) { + + for (n in buttons) { + chart.addButton(buttons[n]); + } + + // Destroy the export elements at chart destroy + addEvent(chart, 'destroy', chart.destroyExport); + } + +}); + + +}(Highcharts)); diff --git a/html/includes/js/modules/funnel.js b/html/includes/js/modules/funnel.js new file mode 100644 index 0000000..efaf891 --- /dev/null +++ b/html/includes/js/modules/funnel.js @@ -0,0 +1,13 @@ +/* + + Highcharts funnel module + + (c) 2010-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(b){var d=b.getOptions(),v=d.plotOptions,q=b.seriesTypes,E=b.merge,D=function(){},A=b.each;v.funnel=E(v.pie,{animation:!1,center:["50%","50%"],width:"90%",neckWidth:"30%",height:"100%",neckHeight:"25%",reversed:!1,dataLabels:{connectorWidth:1,connectorColor:"#606060"},size:!0,states:{select:{color:"#C0C0C0",borderColor:"#000000",shadow:!1}}});q.funnel=b.extendClass(q.pie,{type:"funnel",animate:D,singularTooltips:!0,translate:function(){var a=function(j,a){return/%$/.test(j)?a*parseInt(j, +10)/100:parseInt(j,10)},B=0,f=this.chart,c=this.options,g=c.reversed,b=f.plotWidth,n=f.plotHeight,o=0,f=c.center,h=a(f[0],b),d=a(f[1],n),q=a(c.width,b),k,r,e=a(c.height,n),s=a(c.neckWidth,b),t=a(c.neckHeight,n),w=e-t,a=this.data,x,y,v=c.dataLabels.position==="left"?1:0,z,l,C,p,i,u,m;this.getWidthAt=r=function(j){return j>e-t||e===t?s:s+(q-s)*((e-t-j)/(e-t))};this.getX=function(j,a){return h+(a?-1:1)*(r(g?n-j:j)/2+c.dataLabels.distance)};this.center=[h,d,e];this.centerX=h;A(a,function(a){B+=a.y}); +A(a,function(a){m=null;y=B?a.y/B:0;l=d-e/2+o*e;i=l+y*e;k=r(l);z=h-k/2;C=z+k;k=r(i);p=h-k/2;u=p+k;l>w?(z=p=h-s/2,C=u=h+s/2):i>w&&(m=i,k=r(w),p=h-k/2,u=p+k,i=w);g&&(l=e-l,i=e-i,m=m?e-m:null);x=["M",z,l,"L",C,l,u,i];m&&x.push(u,m,p,m);x.push(p,i,"Z");a.shapeType="path";a.shapeArgs={d:x};a.percentage=y*100;a.plotX=h;a.plotY=(l+(m||i))/2;a.tooltipPos=[h,a.plotY];a.slice=D;a.half=v;o+=y})},drawPoints:function(){var a=this,b=a.options,f=a.chart.renderer;A(a.data,function(c){var g=c.graphic,d=c.shapeArgs; +g?g.animate(d):c.graphic=f.path(d).attr({fill:c.color,stroke:b.borderColor,"stroke-width":b.borderWidth}).add(a.group)})},sortByAngle:function(a){a.sort(function(a,b){return a.plotY-b.plotY})},drawDataLabels:function(){var a=this.data,b=this.options.dataLabels.distance,f,c,g,d=a.length,n,o;for(this.center[2]-=2*b;d--;)g=a[d],c=(f=g.half)?1:-1,o=g.plotY,n=this.getX(o,f),g.labelPos=[0,o,n+(b-5)*c,o,n+b*c,o,f?"right":"left",0];q.pie.prototype.drawDataLabels.call(this)}});d.plotOptions.pyramid=b.merge(d.plotOptions.funnel, +{neckWidth:"0%",neckHeight:"0%",reversed:!0});b.seriesTypes.pyramid=b.extendClass(b.seriesTypes.funnel,{type:"pyramid"})})(Highcharts); diff --git a/html/includes/js/modules/funnel.src.js b/html/includes/js/modules/funnel.src.js new file mode 100644 index 0000000..102d0ad --- /dev/null +++ b/html/includes/js/modules/funnel.src.js @@ -0,0 +1,310 @@ +/** + * @license + * Highcharts funnel module + * + * (c) 2010-2014 Torstein Honsi + * + * License: www.highcharts.com/license + */ + +/*global Highcharts */ +(function (Highcharts) { + +'use strict'; + +// create shortcuts +var defaultOptions = Highcharts.getOptions(), + defaultPlotOptions = defaultOptions.plotOptions, + seriesTypes = Highcharts.seriesTypes, + merge = Highcharts.merge, + noop = function () {}, + each = Highcharts.each; + +// set default options +defaultPlotOptions.funnel = merge(defaultPlotOptions.pie, { + animation: false, + center: ['50%', '50%'], + width: '90%', + neckWidth: '30%', + height: '100%', + neckHeight: '25%', + reversed: false, + dataLabels: { + //position: 'right', + connectorWidth: 1, + connectorColor: '#606060' + }, + size: true, // to avoid adapting to data label size in Pie.drawDataLabels + states: { + select: { + color: '#C0C0C0', + borderColor: '#000000', + shadow: false + } + } +}); + + +seriesTypes.funnel = Highcharts.extendClass(seriesTypes.pie, { + + type: 'funnel', + animate: noop, + singularTooltips: true, + + /** + * Overrides the pie translate method + */ + translate: function () { + + var + // Get positions - either an integer or a percentage string must be given + getLength = function (length, relativeTo) { + return (/%$/).test(length) ? + relativeTo * parseInt(length, 10) / 100 : + parseInt(length, 10); + }, + + sum = 0, + series = this, + chart = series.chart, + options = series.options, + reversed = options.reversed, + plotWidth = chart.plotWidth, + plotHeight = chart.plotHeight, + cumulative = 0, // start at top + center = options.center, + centerX = getLength(center[0], plotWidth), + centerY = getLength(center[1], plotHeight), + width = getLength(options.width, plotWidth), + tempWidth, + getWidthAt, + height = getLength(options.height, plotHeight), + neckWidth = getLength(options.neckWidth, plotWidth), + neckHeight = getLength(options.neckHeight, plotHeight), + neckY = height - neckHeight, + data = series.data, + path, + fraction, + half = options.dataLabels.position === 'left' ? 1 : 0, + + x1, + y1, + x2, + x3, + y3, + x4, + y5; + + // Return the width at a specific y coordinate + series.getWidthAt = getWidthAt = function (y) { + return y > height - neckHeight || height === neckHeight ? + neckWidth : + neckWidth + (width - neckWidth) * ((height - neckHeight - y) / (height - neckHeight)); + }; + series.getX = function (y, half) { + return centerX + (half ? -1 : 1) * ((getWidthAt(reversed ? plotHeight - y : y) / 2) + options.dataLabels.distance); + }; + + // Expose + series.center = [centerX, centerY, height]; + series.centerX = centerX; + + /* + * Individual point coordinate naming: + * + * x1,y1 _________________ x2,y1 + * \ / + * \ / + * \ / + * \ / + * \ / + * x3,y3 _________ x4,y3 + * + * Additional for the base of the neck: + * + * | | + * | | + * | | + * x3,y5 _________ x4,y5 + */ + + + + + // get the total sum + each(data, function (point) { + sum += point.y; + }); + + each(data, function (point) { + // set start and end positions + y5 = null; + fraction = sum ? point.y / sum : 0; + y1 = centerY - height / 2 + cumulative * height; + y3 = y1 + fraction * height; + //tempWidth = neckWidth + (width - neckWidth) * ((height - neckHeight - y1) / (height - neckHeight)); + tempWidth = getWidthAt(y1); + x1 = centerX - tempWidth / 2; + x2 = x1 + tempWidth; + tempWidth = getWidthAt(y3); + x3 = centerX - tempWidth / 2; + x4 = x3 + tempWidth; + + // the entire point is within the neck + if (y1 > neckY) { + x1 = x3 = centerX - neckWidth / 2; + x2 = x4 = centerX + neckWidth / 2; + + // the base of the neck + } else if (y3 > neckY) { + y5 = y3; + + tempWidth = getWidthAt(neckY); + x3 = centerX - tempWidth / 2; + x4 = x3 + tempWidth; + + y3 = neckY; + } + + if (reversed) { + y1 = height - y1; + y3 = height - y3; + y5 = (y5 ? height - y5 : null); + } + // save the path + path = [ + 'M', + x1, y1, + 'L', + x2, y1, + x4, y3 + ]; + if (y5) { + path.push(x4, y5, x3, y5); + } + path.push(x3, y3, 'Z'); + + // prepare for using shared dr + point.shapeType = 'path'; + point.shapeArgs = { d: path }; + + + // for tooltips and data labels + point.percentage = fraction * 100; + point.plotX = centerX; + point.plotY = (y1 + (y5 || y3)) / 2; + + // Placement of tooltips and data labels + point.tooltipPos = [ + centerX, + point.plotY + ]; + + // Slice is a noop on funnel points + point.slice = noop; + + // Mimicking pie data label placement logic + point.half = half; + + cumulative += fraction; + }); + }, + /** + * Draw a single point (wedge) + * @param {Object} point The point object + * @param {Object} color The color of the point + * @param {Number} brightness The brightness relative to the color + */ + drawPoints: function () { + var series = this, + options = series.options, + chart = series.chart, + renderer = chart.renderer; + + each(series.data, function (point) { + + var graphic = point.graphic, + shapeArgs = point.shapeArgs; + + if (!graphic) { // Create the shapes + point.graphic = renderer.path(shapeArgs). + attr({ + fill: point.color, + stroke: options.borderColor, + 'stroke-width': options.borderWidth + }). + add(series.group); + + } else { // Update the shapes + graphic.animate(shapeArgs); + } + }); + }, + + /** + * Funnel items don't have angles (#2289) + */ + sortByAngle: function (points) { + points.sort(function (a, b) { + return a.plotY - b.plotY; + }); + }, + + /** + * Extend the pie data label method + */ + drawDataLabels: function () { + var data = this.data, + labelDistance = this.options.dataLabels.distance, + leftSide, + sign, + point, + i = data.length, + x, + y; + + // In the original pie label anticollision logic, the slots are distributed + // from one labelDistance above to one labelDistance below the pie. In funnels + // we don't want this. + this.center[2] -= 2 * labelDistance; + + // Set the label position array for each point. + while (i--) { + point = data[i]; + leftSide = point.half; + sign = leftSide ? 1 : -1; + y = point.plotY; + x = this.getX(y, leftSide); + + // set the anchor point for data labels + point.labelPos = [ + 0, // first break of connector + y, // a/a + x + (labelDistance - 5) * sign, // second break, right outside point shape + y, // a/a + x + labelDistance * sign, // landing point for connector + y, // a/a + leftSide ? 'right' : 'left', // alignment + 0 // center angle + ]; + } + + seriesTypes.pie.prototype.drawDataLabels.call(this); + } + +}); + +/** + * Pyramid series type. + * A pyramid series is a special type of funnel, without neck and reversed by default. + */ +defaultOptions.plotOptions.pyramid = Highcharts.merge(defaultOptions.plotOptions.funnel, { + neckWidth: '0%', + neckHeight: '0%', + reversed: true +}); +Highcharts.seriesTypes.pyramid = Highcharts.extendClass(Highcharts.seriesTypes.funnel, { + type: 'pyramid' +}); + +}(Highcharts)); diff --git a/html/includes/js/modules/heatmap.js b/html/includes/js/modules/heatmap.js new file mode 100644 index 0000000..fc9b856 --- /dev/null +++ b/html/includes/js/modules/heatmap.js @@ -0,0 +1,23 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + + (c) 2011-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(h){var k=h.Axis,y=h.Chart,l=h.Color,z=h.Legend,t=h.LegendSymbolMixin,u=h.Series,v=h.SVGRenderer,w=h.getOptions(),i=h.each,r=h.extend,A=h.extendClass,m=h.merge,o=h.pick,x=h.numberFormat,p=h.seriesTypes,s=h.wrap,n=function(){},q=h.ColorAxis=function(){this.isColorAxis=!0;this.init.apply(this,arguments)};r(q.prototype,k.prototype);r(q.prototype,{defaultColorAxisOptions:{lineWidth:0,gridLineWidth:1,tickPixelInterval:72,startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},color:"gray", +width:0.01},labels:{overflow:"justify"},minColor:"#EFEFFF",maxColor:"#003875",tickLength:5},init:function(b,a){var c=b.options.legend.layout!=="vertical",d;d=m(this.defaultColorAxisOptions,{side:c?2:1,reversed:!c},a,{isX:c,opposite:!c,showEmpty:!1,title:null,isColor:!0});k.prototype.init.call(this,b,d);a.dataClasses&&this.initDataClasses(a);this.initStops(a);this.isXAxis=!0;this.horiz=c;this.zoomEnabled=!1},tweenColors:function(b,a,c){var d=a.rgba[3]!==1||b.rgba[3]!==1;return(d?"rgba(":"rgb(")+Math.round(a.rgba[0]+ +(b.rgba[0]-a.rgba[0])*(1-c))+","+Math.round(a.rgba[1]+(b.rgba[1]-a.rgba[1])*(1-c))+","+Math.round(a.rgba[2]+(b.rgba[2]-a.rgba[2])*(1-c))+(d?","+(a.rgba[3]+(b.rgba[3]-a.rgba[3])*(1-c)):"")+")"},initDataClasses:function(b){var a=this,c=this.chart,d,e=0,f=this.options,g=b.dataClasses.length;this.dataClasses=d=[];this.legendItems=[];i(b.dataClasses,function(b,h){var i,b=m(b);d.push(b);if(!b.color)f.dataClassColor==="category"?(i=c.options.colors,b.color=i[e++],e===i.length&&(e=0)):b.color=a.tweenColors(l(f.minColor), +l(f.maxColor),g<2?0.5:h/(g-1))})},initStops:function(b){this.stops=b.stops||[[0,this.options.minColor],[1,this.options.maxColor]];i(this.stops,function(a){a.color=l(a[1])})},setOptions:function(b){k.prototype.setOptions.call(this,b);this.options.crosshair=this.options.marker;this.coll="colorAxis"},setAxisSize:function(){var b=this.legendSymbol,a=this.chart,c,d,e;if(b)this.left=c=b.attr("x"),this.top=d=b.attr("y"),this.width=e=b.attr("width"),this.height=b=b.attr("height"),this.right=a.chartWidth- +c-e,this.bottom=a.chartHeight-d-b,this.len=this.horiz?e:b,this.pos=this.horiz?c:d},toColor:function(b,a){var c,d=this.stops,e,f=this.dataClasses,g,j;if(f)for(j=f.length;j--;){if(g=f[j],e=g.from,d=g.to,(e===void 0||b>=e)&&(d===void 0||b<=d)){c=g.color;if(a)a.dataClass=j;break}}else{this.isLog&&(b=this.val2lin(b));c=1-(this.max-b)/(this.max-this.min||1);for(j=d.length;j--;)if(c>d[j][0])break;e=d[j]||d[j+1];d=d[j+1]||e;c=1-(d[0]-c)/(d[0]-e[0]||1);c=this.tweenColors(e.color,d.color,c)}return c},getOffset:function(){var b= +this.legendGroup,a=this.chart.axisOffset[this.side];if(b){k.prototype.getOffset.call(this);if(!this.axisGroup.parentGroup)this.axisGroup.add(b),this.gridGroup.add(b),this.labelGroup.add(b),this.added=!0;this.chart.axisOffset[this.side]=a}},setLegendColor:function(){var b,a=this.options;b=this.horiz?[0,0,1,0]:[0,0,0,1];this.legendColor={linearGradient:{x1:b[0],y1:b[1],x2:b[2],y2:b[3]},stops:a.stops||[[0,a.minColor],[1,a.maxColor]]}},drawLegendSymbol:function(b,a){var c=b.padding,d=b.options,e=this.horiz, +f=o(d.symbolWidth,e?200:12),g=o(d.symbolHeight,e?12:200),j=o(d.labelPadding,e?16:30),d=o(d.itemDistance,10);this.setLegendColor();a.legendSymbol=this.chart.renderer.rect(0,b.baseline-11,f,g).attr({zIndex:1}).add(a.legendGroup);a.legendSymbol.getBBox();this.legendItemWidth=f+c+(e?d:j);this.legendItemHeight=g+c+(e?j:0)},setState:n,visible:!0,setVisible:n,getSeriesExtremes:function(){var b;if(this.series.length)b=this.series[0],this.dataMin=b.valueMin,this.dataMax=b.valueMax},drawCrosshair:function(b, +a){var c=!this.cross,d=a&&a.plotX,e=a&&a.plotY,f,g=this.pos,j=this.len;if(a)f=this.toPixels(a.value),f<g?f=g-2:f>g+j&&(f=g+j+2),a.plotX=f,a.plotY=this.len-f,k.prototype.drawCrosshair.call(this,b,a),a.plotX=d,a.plotY=e,!c&&this.cross&&this.cross.attr({fill:this.crosshair.color}).add(this.labelGroup)},getPlotLinePath:function(b,a,c,d,e){return e?this.horiz?["M",e-4,this.top-6,"L",e+4,this.top-6,e,this.top,"Z"]:["M",this.left,e,"L",this.left-6,e+6,this.left-6,e-6,"Z"]:k.prototype.getPlotLinePath.call(this, +b,a,c,d)},update:function(b,a){i(this.series,function(a){a.isDirtyData=!0});k.prototype.update.call(this,b,a);this.legendItem&&(this.setLegendColor(),this.chart.legend.colorizeItem(this,!0))},getDataClassLegendSymbols:function(){var b=this,a=this.chart,c=this.legendItems,d=a.options.legend,e=d.valueDecimals,f=d.valueSuffix||"",g;c.length||i(this.dataClasses,function(d,h){var k=!0,l=d.from,m=d.to;g="";l===void 0?g="< ":m===void 0&&(g="> ");l!==void 0&&(g+=x(l,e)+f);l!==void 0&&m!==void 0&&(g+=" - "); +m!==void 0&&(g+=x(m,e)+f);c.push(r({chart:a,name:g,options:{},drawLegendSymbol:t.drawRectangle,visible:!0,setState:n,setVisible:function(){k=this.visible=!k;i(b.series,function(a){i(a.points,function(a){a.dataClass===h&&a.setVisible(k)})});a.legend.colorizeItem(this,k)}},d))});return c},name:""});i(["fill","stroke"],function(b){HighchartsAdapter.addAnimSetter(b,function(a){a.elem.attr(b,q.prototype.tweenColors(l(a.start),l(a.end),a.pos))})});s(y.prototype,"getAxes",function(b){var a=this.options.colorAxis; +b.call(this);this.colorAxis=[];a&&new q(this,a)});s(z.prototype,"getAllItems",function(b){var a=[],c=this.chart.colorAxis[0];c&&(c.options.dataClasses?a=a.concat(c.getDataClassLegendSymbols()):a.push(c),i(c.series,function(a){a.options.showInLegend=!1}));return a.concat(b.call(this))});h={pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color",dashstyle:"dashStyle"},pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],optionalAxis:"colorAxis",trackerGroups:["group", +"markerGroup","dataLabelsGroup"],getSymbol:n,parallelArrays:["x","y","value"],colorKey:"value",translateColors:function(){var b=this,a=this.options.nullColor,c=this.colorAxis,d=this.colorKey;i(this.data,function(e){var f=e[d];if(f=f===null?a:c&&f!==void 0?c.toColor(f,e):e.color||b.color)e.color=f})}};s(v.prototype,"buildText",function(b,a){var c=a.styles&&a.styles.HcTextStroke;b.call(this,a);c&&a.applyTextStroke&&a.applyTextStroke(c)});v.prototype.Element.prototype.applyTextStroke=function(b){var a= +this.element,c,d,b=b.split(" ");c=a.getElementsByTagName("tspan");d=a.firstChild;this.ySetter=this.xSetter;i([].slice.call(c),function(c,f){var g;f===0&&(c.setAttribute("x",a.getAttribute("x")),(f=a.getAttribute("y"))!==null&&c.setAttribute("y",f));g=c.cloneNode(1);g.setAttribute("stroke",b[1]);g.setAttribute("stroke-width",b[0]);g.setAttribute("stroke-linejoin","round");a.insertBefore(g,d)})};w.plotOptions.heatmap=m(w.plotOptions.scatter,{animation:!1,borderWidth:0,nullColor:"#F8F8F8",dataLabels:{formatter:function(){return this.point.value}, +verticalAlign:"middle",crop:!1,overflow:!1,style:{color:"white",fontWeight:"bold",HcTextStroke:"1px rgba(0,0,0,0.5)"}},marker:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}<br/>"},states:{normal:{animation:!0},hover:{brightness:0.2}}});p.heatmap=A(p.scatter,m(h,{type:"heatmap",pointArrayMap:["y","value"],hasPointSpecificOptions:!0,supportsDrilldown:!0,getExtremesFromAll:!0,init:function(){p.scatter.prototype.init.apply(this,arguments);this.pointRange=this.options.colsize||1;this.yAxis.axisPointRange= +this.options.rowsize||1},translate:function(){var b=this.options,a=this.xAxis,c=this.yAxis;this.generatePoints();i(this.points,function(d){var e=(b.colsize||1)/2,f=(b.rowsize||1)/2,g=Math.round(a.len-a.translate(d.x-e,0,1,0,1)),e=Math.round(a.len-a.translate(d.x+e,0,1,0,1)),h=Math.round(c.translate(d.y-f,0,1,0,1)),f=Math.round(c.translate(d.y+f,0,1,0,1));d.plotX=(g+e)/2;d.plotY=(h+f)/2;d.shapeType="rect";d.shapeArgs={x:Math.min(g,e),y:Math.min(h,f),width:Math.abs(e-g),height:Math.abs(f-h)}});this.translateColors(); +this.chart.hasRendered&&i(this.points,function(a){a.shapeArgs.fill=a.options.color||a.color})},drawPoints:p.column.prototype.drawPoints,animate:n,getBox:n,drawLegendSymbol:t.drawRectangle,getExtremes:function(){u.prototype.getExtremes.call(this,this.valueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;u.prototype.getExtremes.call(this)}}))})(Highcharts); diff --git a/html/includes/js/modules/heatmap.src.js b/html/includes/js/modules/heatmap.src.js new file mode 100644 index 0000000..253ca2b --- /dev/null +++ b/html/includes/js/modules/heatmap.src.js @@ -0,0 +1,687 @@ +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * + * (c) 2011-2014 Torstein Honsi + * + * License: www.highcharts.com/license + */ + +/*global HighchartsAdapter*/ +(function (Highcharts) { + + +var UNDEFINED, + Axis = Highcharts.Axis, + Chart = Highcharts.Chart, + Color = Highcharts.Color, + Legend = Highcharts.Legend, + LegendSymbolMixin = Highcharts.LegendSymbolMixin, + Series = Highcharts.Series, + SVGRenderer = Highcharts.SVGRenderer, + + defaultOptions = Highcharts.getOptions(), + each = Highcharts.each, + extend = Highcharts.extend, + extendClass = Highcharts.extendClass, + merge = Highcharts.merge, + pick = Highcharts.pick, + numberFormat = Highcharts.numberFormat, + seriesTypes = Highcharts.seriesTypes, + wrap = Highcharts.wrap, + noop = function () {}; + + + + +/** + * The ColorAxis object for inclusion in gradient legends + */ +var ColorAxis = Highcharts.ColorAxis = function () { + this.isColorAxis = true; + this.init.apply(this, arguments); +}; +extend(ColorAxis.prototype, Axis.prototype); +extend(ColorAxis.prototype, { + defaultColorAxisOptions: { + lineWidth: 0, + gridLineWidth: 1, + tickPixelInterval: 72, + startOnTick: true, + endOnTick: true, + offset: 0, + marker: { + animation: { + duration: 50 + }, + color: 'gray', + width: 0.01 + }, + labels: { + overflow: 'justify' + }, + minColor: '#EFEFFF', + maxColor: '#003875', + tickLength: 5 + }, + init: function (chart, userOptions) { + var horiz = chart.options.legend.layout !== 'vertical', + options; + + // Build the options + options = merge(this.defaultColorAxisOptions, { + side: horiz ? 2 : 1, + reversed: !horiz + }, userOptions, { + isX: horiz, + opposite: !horiz, + showEmpty: false, + title: null, + isColor: true + }); + + Axis.prototype.init.call(this, chart, options); + + // Base init() pushes it to the xAxis array, now pop it again + //chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop(); + + // Prepare data classes + if (userOptions.dataClasses) { + this.initDataClasses(userOptions); + } + this.initStops(userOptions); + + // Override original axis properties + this.isXAxis = true; + this.horiz = horiz; + this.zoomEnabled = false; + }, + + /* + * Return an intermediate color between two colors, according to pos where 0 + * is the from color and 1 is the to color + */ + tweenColors: function (from, to, pos) { + // Check for has alpha, because rgba colors perform worse due to lack of + // support in WebKit. + var hasAlpha = (to.rgba[3] !== 1 || from.rgba[3] !== 1); + return (hasAlpha ? 'rgba(' : 'rgb(') + + Math.round(to.rgba[0] + (from.rgba[0] - to.rgba[0]) * (1 - pos)) + ',' + + Math.round(to.rgba[1] + (from.rgba[1] - to.rgba[1]) * (1 - pos)) + ',' + + Math.round(to.rgba[2] + (from.rgba[2] - to.rgba[2]) * (1 - pos)) + + (hasAlpha ? (',' + (to.rgba[3] + (from.rgba[3] - to.rgba[3]) * (1 - pos))) : '') + ')'; + }, + + initDataClasses: function (userOptions) { + var axis = this, + chart = this.chart, + dataClasses, + colorCounter = 0, + options = this.options, + len = userOptions.dataClasses.length; + this.dataClasses = dataClasses = []; + this.legendItems = []; + + each(userOptions.dataClasses, function (dataClass, i) { + var colors; + + dataClass = merge(dataClass); + dataClasses.push(dataClass); + if (!dataClass.color) { + if (options.dataClassColor === 'category') { + colors = chart.options.colors; + dataClass.color = colors[colorCounter++]; + // loop back to zero + if (colorCounter === colors.length) { + colorCounter = 0; + } + } else { + dataClass.color = axis.tweenColors( + Color(options.minColor), + Color(options.maxColor), + len < 2 ? 0.5 : i / (len - 1) // #3219 + ); + } + } + }); + }, + + initStops: function (userOptions) { + this.stops = userOptions.stops || [ + [0, this.options.minColor], + [1, this.options.maxColor] + ]; + each(this.stops, function (stop) { + stop.color = Color(stop[1]); + }); + }, + + /** + * Extend the setOptions method to process extreme colors and color + * stops. + */ + setOptions: function (userOptions) { + Axis.prototype.setOptions.call(this, userOptions); + + this.options.crosshair = this.options.marker; + this.coll = 'colorAxis'; + }, + + setAxisSize: function () { + var symbol = this.legendSymbol, + chart = this.chart, + x, + y, + width, + height; + + if (symbol) { + this.left = x = symbol.attr('x'); + this.top = y = symbol.attr('y'); + this.width = width = symbol.attr('width'); + this.height = height = symbol.attr('height'); + this.right = chart.chartWidth - x - width; + this.bottom = chart.chartHeight - y - height; + + this.len = this.horiz ? width : height; + this.pos = this.horiz ? x : y; + } + }, + + /** + * Translate from a value to a color + */ + toColor: function (value, point) { + var pos, + stops = this.stops, + from, + to, + color, + dataClasses = this.dataClasses, + dataClass, + i; + + if (dataClasses) { + i = dataClasses.length; + while (i--) { + dataClass = dataClasses[i]; + from = dataClass.from; + to = dataClass.to; + if ((from === UNDEFINED || value >= from) && (to === UNDEFINED || value <= to)) { + color = dataClass.color; + if (point) { + point.dataClass = i; + } + break; + } + } + + } else { + + if (this.isLog) { + value = this.val2lin(value); + } + pos = 1 - ((this.max - value) / ((this.max - this.min) || 1)); + i = stops.length; + while (i--) { + if (pos > stops[i][0]) { + break; + } + } + from = stops[i] || stops[i + 1]; + to = stops[i + 1] || from; + + // The position within the gradient + pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1); + + color = this.tweenColors( + from.color, + to.color, + pos + ); + } + return color; + }, + + getOffset: function () { + var group = this.legendGroup, + sideOffset = this.chart.axisOffset[this.side]; + + if (group) { + + Axis.prototype.getOffset.call(this); + + if (!this.axisGroup.parentGroup) { + + // Move the axis elements inside the legend group + this.axisGroup.add(group); + this.gridGroup.add(group); + this.labelGroup.add(group); + + this.added = true; + } + // Reset it to avoid color axis reserving space + this.chart.axisOffset[this.side] = sideOffset; + } + }, + + /** + * Create the color gradient + */ + setLegendColor: function () { + var grad, + horiz = this.horiz, + options = this.options; + + grad = horiz ? [0, 0, 1, 0] : [0, 0, 0, 1]; + this.legendColor = { + linearGradient: { x1: grad[0], y1: grad[1], x2: grad[2], y2: grad[3] }, + stops: options.stops || [ + [0, options.minColor], + [1, options.maxColor] + ] + }; + }, + + /** + * The color axis appears inside the legend and has its own legend symbol + */ + drawLegendSymbol: function (legend, item) { + var padding = legend.padding, + legendOptions = legend.options, + horiz = this.horiz, + box, + width = pick(legendOptions.symbolWidth, horiz ? 200 : 12), + height = pick(legendOptions.symbolHeight, horiz ? 12 : 200), + labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30), + itemDistance = pick(legendOptions.itemDistance, 10); + + this.setLegendColor(); + + // Create the gradient + item.legendSymbol = this.chart.renderer.rect( + 0, + legend.baseline - 11, + width, + height + ).attr({ + zIndex: 1 + }).add(item.legendGroup); + box = item.legendSymbol.getBBox(); + + // Set how much space this legend item takes up + this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding); + this.legendItemHeight = height + padding + (horiz ? labelPadding : 0); + }, + /** + * Fool the legend + */ + setState: noop, + visible: true, + setVisible: noop, + getSeriesExtremes: function () { + var series; + if (this.series.length) { + series = this.series[0]; + this.dataMin = series.valueMin; + this.dataMax = series.valueMax; + } + }, + drawCrosshair: function (e, point) { + var newCross = !this.cross, + plotX = point && point.plotX, + plotY = point && point.plotY, + crossPos, + axisPos = this.pos, + axisLen = this.len; + + if (point) { + crossPos = this.toPixels(point.value); + if (crossPos < axisPos) { + crossPos = axisPos - 2; + } else if (crossPos > axisPos + axisLen) { + crossPos = axisPos + axisLen + 2; + } + + point.plotX = crossPos; + point.plotY = this.len - crossPos; + Axis.prototype.drawCrosshair.call(this, e, point); + point.plotX = plotX; + point.plotY = plotY; + + if (!newCross && this.cross) { + this.cross + .attr({ + fill: this.crosshair.color + }) + .add(this.labelGroup); + } + } + }, + getPlotLinePath: function (a, b, c, d, pos) { + if (pos) { // crosshairs only + return this.horiz ? + ['M', pos - 4, this.top - 6, 'L', pos + 4, this.top - 6, pos, this.top, 'Z'] : + ['M', this.left, pos, 'L', this.left - 6, pos + 6, this.left - 6, pos - 6, 'Z']; + } else { + return Axis.prototype.getPlotLinePath.call(this, a, b, c, d); + } + }, + + update: function (newOptions, redraw) { + each(this.series, function (series) { + series.isDirtyData = true; // Needed for Axis.update when choropleth colors change + }); + Axis.prototype.update.call(this, newOptions, redraw); + if (this.legendItem) { + this.setLegendColor(); + this.chart.legend.colorizeItem(this, true); + } + }, + + /** + * Get the legend item symbols for data classes + */ + getDataClassLegendSymbols: function () { + var axis = this, + chart = this.chart, + legendItems = this.legendItems, + legendOptions = chart.options.legend, + valueDecimals = legendOptions.valueDecimals, + valueSuffix = legendOptions.valueSuffix || '', + name; + + if (!legendItems.length) { + each(this.dataClasses, function (dataClass, i) { + var vis = true, + from = dataClass.from, + to = dataClass.to; + + // Assemble the default name. This can be overridden by legend.options.labelFormatter + name = ''; + if (from === UNDEFINED) { + name = '< '; + } else if (to === UNDEFINED) { + name = '> '; + } + if (from !== UNDEFINED) { + name += numberFormat(from, valueDecimals) + valueSuffix; + } + if (from !== UNDEFINED && to !== UNDEFINED) { + name += ' - '; + } + if (to !== UNDEFINED) { + name += numberFormat(to, valueDecimals) + valueSuffix; + } + + // Add a mock object to the legend items + legendItems.push(extend({ + chart: chart, + name: name, + options: {}, + drawLegendSymbol: LegendSymbolMixin.drawRectangle, + visible: true, + setState: noop, + setVisible: function () { + vis = this.visible = !vis; + each(axis.series, function (series) { + each(series.points, function (point) { + if (point.dataClass === i) { + point.setVisible(vis); + } + }); + }); + + chart.legend.colorizeItem(this, vis); + } + }, dataClass)); + }); + } + return legendItems; + }, + name: '' // Prevents 'undefined' in legend in IE8 +}); + +/** + * Handle animation of the color attributes directly + */ +each(['fill', 'stroke'], function (prop) { + HighchartsAdapter.addAnimSetter(prop, function (fx) { + fx.elem.attr(prop, ColorAxis.prototype.tweenColors(Color(fx.start), Color(fx.end), fx.pos)); + }); +}); + +/** + * Extend the chart getAxes method to also get the color axis + */ +wrap(Chart.prototype, 'getAxes', function (proceed) { + + var options = this.options, + colorAxisOptions = options.colorAxis; + + proceed.call(this); + + this.colorAxis = []; + if (colorAxisOptions) { + proceed = new ColorAxis(this, colorAxisOptions); // Fake assignment for jsLint + } +}); + + +/** + * Wrap the legend getAllItems method to add the color axis. This also removes the + * axis' own series to prevent them from showing up individually. + */ +wrap(Legend.prototype, 'getAllItems', function (proceed) { + var allItems = [], + colorAxis = this.chart.colorAxis[0]; + + if (colorAxis) { + + // Data classes + if (colorAxis.options.dataClasses) { + allItems = allItems.concat(colorAxis.getDataClassLegendSymbols()); + // Gradient legend + } else { + // Add this axis on top + allItems.push(colorAxis); + } + + // Don't add the color axis' series + each(colorAxis.series, function (series) { + series.options.showInLegend = false; + }); + } + + return allItems.concat(proceed.call(this)); +});/** + * Mixin for maps and heatmaps + */ +var colorSeriesMixin = { + + pointAttrToOptions: { // mapping between SVG attributes and the corresponding options + stroke: 'borderColor', + 'stroke-width': 'borderWidth', + fill: 'color', + dashstyle: 'dashStyle' + }, + pointArrayMap: ['value'], + axisTypes: ['xAxis', 'yAxis', 'colorAxis'], + optionalAxis: 'colorAxis', + trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'], + getSymbol: noop, + parallelArrays: ['x', 'y', 'value'], + colorKey: 'value', + + /** + * In choropleth maps, the color is a result of the value, so this needs translation too + */ + translateColors: function () { + var series = this, + nullColor = this.options.nullColor, + colorAxis = this.colorAxis, + colorKey = this.colorKey; + + each(this.data, function (point) { + var value = point[colorKey], + color; + + color = value === null ? nullColor : (colorAxis && value !== undefined) ? colorAxis.toColor(value, point) : point.color || series.color; + + if (color) { + point.color = color; + } + }); + } +}; + + +/** + * Wrap the buildText method and add the hook for add text stroke + */ +wrap(SVGRenderer.prototype, 'buildText', function (proceed, wrapper) { + + var textStroke = wrapper.styles && wrapper.styles.HcTextStroke; + + proceed.call(this, wrapper); + + // Apply the text stroke + if (textStroke && wrapper.applyTextStroke) { + wrapper.applyTextStroke(textStroke); + } +}); + +/** + * Apply an outside text stroke to data labels, based on the custom CSS property, HcTextStroke. + * Consider moving this to Highcharts core, also makes sense on stacked columns etc. + */ +SVGRenderer.prototype.Element.prototype.applyTextStroke = function (textStroke) { + var elem = this.element, + tspans, + firstChild; + + textStroke = textStroke.split(' '); + tspans = elem.getElementsByTagName('tspan'); + firstChild = elem.firstChild; + + // In order to get the right y position of the clones, + // copy over the y setter + this.ySetter = this.xSetter; + + each([].slice.call(tspans), function (tspan, y) { + var clone; + if (y === 0) { + tspan.setAttribute('x', elem.getAttribute('x')); + if ((y = elem.getAttribute('y')) !== null) { + tspan.setAttribute('y', y); + } + } + clone = tspan.cloneNode(1); + clone.setAttribute('stroke', textStroke[1]); + clone.setAttribute('stroke-width', textStroke[0]); + clone.setAttribute('stroke-linejoin', 'round'); + elem.insertBefore(clone, firstChild); + }); +}; +/** + * Extend the default options with map options + */ +defaultOptions.plotOptions.heatmap = merge(defaultOptions.plotOptions.scatter, { + animation: false, + borderWidth: 0, + nullColor: '#F8F8F8', + dataLabels: { + formatter: function () { // #2945 + return this.point.value; + }, + verticalAlign: 'middle', + crop: false, + overflow: false, + style: { + color: 'white', + fontWeight: 'bold', + HcTextStroke: '1px rgba(0,0,0,0.5)' + } + }, + marker: null, + tooltip: { + pointFormat: '{point.x}, {point.y}: {point.value}<br/>' + }, + states: { + normal: { + animation: true + }, + hover: { + brightness: 0.2 + } + } +}); + +// The Heatmap series type +seriesTypes.heatmap = extendClass(seriesTypes.scatter, merge(colorSeriesMixin, { + type: 'heatmap', + pointArrayMap: ['y', 'value'], + hasPointSpecificOptions: true, + supportsDrilldown: true, + getExtremesFromAll: true, + init: function () { + seriesTypes.scatter.prototype.init.apply(this, arguments); + this.pointRange = this.options.colsize || 1; + this.yAxis.axisPointRange = this.options.rowsize || 1; // general point range + }, + translate: function () { + var series = this, + options = series.options, + xAxis = series.xAxis, + yAxis = series.yAxis; + + series.generatePoints(); + + each(series.points, function (point) { + var xPad = (options.colsize || 1) / 2, + yPad = (options.rowsize || 1) / 2, + x1 = Math.round(xAxis.len - xAxis.translate(point.x - xPad, 0, 1, 0, 1)), + x2 = Math.round(xAxis.len - xAxis.translate(point.x + xPad, 0, 1, 0, 1)), + y1 = Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), + y2 = Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)); + + // Set plotX and plotY for use in K-D-Tree and more + point.plotX = (x1 + x2) / 2; + point.plotY = (y1 + y2) / 2; + + point.shapeType = 'rect'; + point.shapeArgs = { + x: Math.min(x1, x2), + y: Math.min(y1, y2), + width: Math.abs(x2 - x1), + height: Math.abs(y2 - y1) + }; + }); + + series.translateColors(); + + // Make sure colors are updated on colorAxis update (#2893) + if (this.chart.hasRendered) { + each(series.points, function (point) { + point.shapeArgs.fill = point.options.color || point.color; // #3311 + }); + } + }, + drawPoints: seriesTypes.column.prototype.drawPoints, + animate: noop, + getBox: noop, + drawLegendSymbol: LegendSymbolMixin.drawRectangle, + + getExtremes: function () { + // Get the extremes from the value data + Series.prototype.getExtremes.call(this, this.valueData); + this.valueMin = this.dataMin; + this.valueMax = this.dataMax; + + // Get the extremes from the y data + Series.prototype.getExtremes.call(this); + } + +})); + + +}(Highcharts)); diff --git a/html/includes/js/modules/multicolor_series.js b/html/includes/js/modules/multicolor_series.js new file mode 100644 index 0000000..ca70ae6 --- /dev/null +++ b/html/includes/js/modules/multicolor_series.js @@ -0,0 +1,567 @@ +(function(H){ + var each = H.each, + seriesTypes = H.seriesTypes, + mathFloor = Math.floor, + mathMax = Math.max, + mathMin = Math.min, + mathAbs = Math.abs, + UNDEFINED, + NORMAL_STATE = '', + HOVER_STATE = 'hover', + SELECT_STATE = 'select', + VISIBLE = 'visible', + HIDDEN = 'hidden', + PREFIX = 'highcharts-', + NONE = 'none', + hasTouch = document.documentElement.ontouchstart !== UNDEFINED, + TRACKER_FILL = 'rgba(192,192,192,' + (H.hasSVG ? 0.0001 : 0.002) + ')', // invisible but clickable + M = 'M', + L = 'L'; + + // handle unsorted data, throw error anyway + function error(code, stop) { + var msg = 'Highcharts error #' + code + ': www.highcharts.com/errors/' + code; + if (stop) { + throw msg; + } else if (window.console) { + console.log(msg); + } + } + + /*** + If replacing L and M in trakcer will be necessary use that getPath(): + + function getPath(arr){ + var ret = []; + each(arr, function(el, ind) { + var len = el[0].length; + for(var i = 0; i < len; i++){ + var p = el[0][i]; + if(p == M && ind != 0 && i == 0) { + p = L; + } + ret.push(p); + } + }); + return ret; + } + ***/ + + + function getPath(arr){ + var ret = []; + each(arr, function(el) { + ret = ret.concat(el[0]); + }); + return ret; + } + + /*** + * + * ColoredLine series type + * + ***/ + + seriesTypes.coloredline = Highcharts.extendClass(seriesTypes.line); + H.seriesTypes.coloredline.prototype.processData = function(force) { + + var series = this, + processedXData = series.xData, // copied during slice operation below + processedYData = series.yData, + dataLength = processedXData.length, + croppedData, + cropStart = 0, + cropped, + distance, + closestPointRange, + xAxis = series.xAxis, + i, // loop variable + options = series.options, + cropThreshold = options.cropThreshold, + isCartesian = series.isCartesian; + + // If the series data or axes haven't changed, don't go through this. Return false to pass + // the message on to override methods like in data grouping. + if (isCartesian && !series.isDirty && !xAxis.isDirty && !series.yAxis.isDirty && !force) { + return false; + } + + // Find the closest distance between processed points + for (i = processedXData.length - 1; i >= 0; i--) { + distance = processedXData[i] - processedXData[i - 1]; + if (distance > 0 && (closestPointRange === UNDEFINED || distance < closestPointRange)) { + closestPointRange = distance; + + // Unsorted data is not supported by the line tooltip, as well as data grouping and + // navigation in Stock charts (#725) and width calculation of columns (#1900) + } else if (distance < 0 && series.requireSorting) { + error(15); + } + } + + // Record the properties + series.cropped = cropped; // undefined or true + series.cropStart = cropStart; + series.processedXData = processedXData; + series.processedYData = processedYData; + + if (options.pointRange === null) { // null means auto, as for columns, candlesticks and OHLC + series.pointRange = closestPointRange || 1; + } + series.closestPointRange = closestPointRange; + }; + + H.seriesTypes.coloredline.prototype.setTooltipPoints = function (renew) { + var series = this, + points = [], + pointsLength, + low, + high, + xAxis = series.xAxis, + xExtremes = xAxis && xAxis.getExtremes(), + axisLength = xAxis ? (xAxis.tooltipLen || xAxis.len) : series.chart.plotSizeX, // tooltipLen and tooltipPosName used in polar + point, + pointX, + nextPoint, + i, + tooltipPoints = []; // a lookup array for each pixel in the x dimension + + // don't waste resources if tracker is disabled + if (series.options.enableMouseTracking === false) { + return; + } + + // renew + if (renew) { + series.tooltipPoints = null; + } + // concat segments to overcome null values + each(series.points, function (segment) { + if(segment.y !== null){ + points = points.concat(segment); + } + }); + each(series.segments, function (segment) { + each(segment.points, function(point) { + if(point.y !== null){ + points = points.concat(point); + } + }); + }); + // Reverse the points in case the X axis is reversed + if (xAxis && xAxis.reversed) { + points = points.reverse(); + } + + // Polar needs additional shaping + if (series.orderTooltipPoints) { + series.orderTooltipPoints(points); + } + + // Assign each pixel position to the nearest point + pointsLength = points.length; + for (i = 0; i < pointsLength; i++) { + point = points[i]; + pointX = point.x; + if (pointX >= xExtremes.min && pointX <= xExtremes.max) { // #1149 + nextPoint = points[i + 1]; + + // Set this range's low to the last range's high plus one + low = high === UNDEFINED ? 0 : high + 1; + // Now find the new high + high = points[i + 1] ? + mathMin(mathMax(0, mathFloor( // #2070 + (point.clientX + (nextPoint ? (nextPoint.wrappedClientX || nextPoint.clientX) : axisLength)) / 2 )), axisLength) : + axisLength; + + while (low >= 0 && low <= high) { + tooltipPoints[low++] = point; + } + } + } + series.tooltipPoints = tooltipPoints; + }; + + H.seriesTypes.coloredline.prototype.drawTracker = function () { + var series = this, + options = series.options, + trackByArea = options.trackByArea, + trackerPath = [].concat(trackByArea ? series.areaPath : getPath(series.graphPath)), + trackerPathLength = trackerPath.length, + chart = series.chart, + pointer = chart.pointer, + renderer = chart.renderer, + snap = chart.options.tooltip.snap, + tracker = series.tracker, + cursor = options.cursor, + css = cursor && { cursor: cursor }, + singlePoints = series.singlePoints, + singlePoint, + i, + onMouseOver = function () { + if (chart.hoverSeries !== series) { + series.onMouseOver(); + } + }; + // Extend end points. A better way would be to use round linecaps, + // but those are not clickable in VML. + if (trackerPathLength && !trackByArea) { + i = trackerPathLength + 1; + while (i--) { + if (trackerPath[i] === M) { // extend left side + trackerPath.splice(i + 1, 0, trackerPath[i + 1] - snap, trackerPath[i + 2], L); + } + if ((i && trackerPath[i] === M) || i === trackerPathLength) { // extend right side + trackerPath.splice(i, 0, L, trackerPath[i - 2] + snap, trackerPath[i - 1]); + } + } + } + + // handle single points + for (i = 0; i < singlePoints.length; i++) { + singlePoint = singlePoints[i]; + if(singlePoint.plotX && singlePoint.plotY) { + trackerPath.push(M, singlePoint.plotX - snap, singlePoint.plotY, + L, singlePoint.plotX + snap, singlePoint.plotY); + } + } + + + + // draw the tracker + if (tracker) { + tracker.attr({ d: trackerPath }); + + } else { // create + + series.tracker = renderer.path(trackerPath) + .attr({ + 'stroke-linejoin': 'round', // #1225 + visibility: series.visible ? VISIBLE : HIDDEN, + stroke: TRACKER_FILL, + fill: trackByArea ? TRACKER_FILL : NONE, + 'stroke-width' : options.lineWidth + (trackByArea ? 0 : 2 * snap), + zIndex: 2 + }) + .add(series.group); + + // The tracker is added to the series group, which is clipped, but is covered + // by the marker group. So the marker group also needs to capture events. + each([series.tracker, series.markerGroup], function (tracker) { + tracker.addClass(PREFIX + 'tracker') + .on('mouseover', onMouseOver) + .on('mouseout', function (e) { pointer.onTrackerMouseOut(e); }) + .css(css); + + if (hasTouch) { + tracker.on('touchstart', onMouseOver); + } + }); + } + + }; + + H.seriesTypes.coloredline.prototype.setState = function (state) { + var series = this, + options = series.options, + graph = series.graph, + graphNeg = series.graphNeg, + stateOptions = options.states, + lineWidth = options.lineWidth, + attribs; + + state = state || NORMAL_STATE; + + if (series.state !== state) { + series.state = state; + + if (stateOptions[state] && stateOptions[state].enabled === false) { + return; + } + + if (state) { + lineWidth = stateOptions[state].lineWidth || lineWidth + 1; + } + + if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML + attribs = { + 'stroke-width': lineWidth + }; + // use attr because animate will cause any other animation on the graph to stop + each(graph, function(seg, i){ + seg.attr(attribs); + }); + } + } + }; + + /*** + * + * The main change to get multi color isFinite changes segments array. + * From array of points to object with color and array of points. + * + ***/ + H.seriesTypes.coloredline.prototype.getSegments = function(f){ + var series = this, + lastColor = 0, + segments = [], + i, + points = series.points, + pointsLength = points.length; + + if (pointsLength) { // no action required for [] + + // if connect nulls, just remove null points + if (series.options.connectNulls) { + each(points, function (point, i) { + if (points[i].y === null) { + points.splice(i, 1); + } + }); + each(points, function (point, i) { + if (i > 0 && points[i].segmentColor != points[i-1].segmentColor){ + segments.push({ + points: points.slice(lastColor, i + 1), + color: points[i - 1].segmentColor + }); + lastColor = i; + } + }); + + if (points.length && segments.length === 0) { + segments = [points]; + } + + // else, split on null points or different colors + } else { + var previousColor = null; + each(points, function (point, i) { + var colorChanged = i > 0 && point.segmentColor != points[i-1].segmentColor && points[i].segmentColor != previousColor, + colorExists = points[i-1] && points[i-1].segmentColor ? true : false; + + // handle first point + if(!previousColor && point.segmetColor){ + previousColor = point.segmentColor; + } + + if(colorChanged){ + var p = points.slice(lastColor, i + 1); + if(p.length > 0) { + segments.push({ + points: p, + color: colorExists ? points[i-1].segmentColor : previousColor + }); + lastColor = i; + } + } else if (i === pointsLength - 1){ + var next = i + 1; + if(point.y === null) { + next--; + } + var p = points.slice(lastColor, next); + if(p.length > 0) { + segments.push({ + points: p, + color: colorExists ? points[i-1].segmentColor : previousColor + }); + lastColor = i; + } + + } + + // store previous color + if(point){ + previousColor = point.segmentColor; + } + }); + } + } + // register it + series.segments = segments; + }; + + H.seriesTypes.coloredline.prototype.getGraphPath = function(f){ + + //var ret = f.apply(this, Array.prototype.slice.call(arguments, 1)); + var series = this, + graphPath = [], + segmentPath, + singlePoints = []; // used in drawTracker + // Divide into segments and build graph and area paths + each(series.segments, function (segment) { + segmentPath = series.getSegmentPath(segment.points); + // add the segment to the graph, or a single point for tracking + if (segment.points.length > 1) { + graphPath.push([segmentPath, segment.color]); + } else { + singlePoints.push(segment.points); + } + }); + + // Record it for use in drawGraph and drawTracker, and return graphPath + series.singlePoints = singlePoints; + series.graphPath = graphPath; + + return graphPath; + }; + + H.seriesTypes.coloredline.prototype.drawGraph = function(f){ + var series = this, + options = series.options, + props = [['graph', options.lineColor || series.color]], + lineWidth = options.lineWidth, + dashStyle = options.dashStyle, + roundCap = options.linecap !== 'square', + graphPath = series.getGraphPath(), + graphPathLength = graphPath.length, + graphSegmentsLength = 0, + negativeColor = options.negativeColor; + + // draw the graph + each(props, function (prop, i) { + var graphKey = prop[0], + graph = series[graphKey]; + + if (graph) {// cancel running animations, #459 + // do we have animation + each(graphPath, function(segment, j) { + // update color and path + + if(series[graphKey][j]){ + series[graphKey][j].attr({ d: segment[0], stroke: segment[1] }); + } else { + series[graphKey][j] = getSegment(segment, prop, i); + } + }); + + } else if (lineWidth && graphPath.length) { // #1487 + graph = []; + each(graphPath, function(segment, j) { + graph[j] = getSegment(segment, prop, i); + }); + series[graphKey] = graph; + //add destroying elements + series[graphKey].destroy = function(){ + for(g in series[graphKey]){ + var el = series[graphKey][g]; + if(el && el.destroy){ + el.destroy(); + } + } + }; + } + graphSegmentsLength = series.graph.length; + + for(var j = graphSegmentsLength; j >= graphPathLength; j --){ + if(series[graphKey][j]) { + series[graphKey][j].destroy(); + series[graphKey].splice(j, 1); + } + } + }); + + + function getSegment(segment, prop, i){ + var attribs = { + stroke: prop[1], + 'stroke-width': lineWidth, + zIndex: 1 // #1069 + }, + item; + if (dashStyle) { + attribs.dashstyle = dashStyle; + } else if (roundCap) { + attribs['stroke-linecap'] = attribs['stroke-linejoin'] = 'round'; + } + if(segment[1]){ + attribs.stroke = segment[1]; + } + + item = series.chart.renderer.path(segment[0]) + .attr(attribs) + .add(series.group) + .shadow(!i && options.shadow); + + return item; + } + + }; + + + /*** + * + * ColoredArea series type + * + ***/ + seriesTypes.coloredarea = Highcharts.extendClass(seriesTypes.coloredline); + + H.seriesTypes.coloredarea.prototype.init = function(chart, options) { + options.threshold = options.threshold || null; + H.Series.prototype.init.call(this, chart, options); + }; + + H.seriesTypes.coloredarea.prototype.closeSegment = H.seriesTypes.area.prototype.closeSegment; + + H.seriesTypes.coloredarea.prototype.drawGraph = function(f) { + H.seriesTypes.coloredline.prototype.drawGraph.call(this, f); + var series = this, + options = this.options, + props = [['graph', options.lineColor || series.color]]; + + each(props, function(prop, i) { + var graphKey = prop[0], + graph = series[graphKey]; + + if (graph) {// cancel running animations, #459 + // do we have animation + each(series.graphPath, function(segment, j) { + // update color and path + + if(series[graphKey][j]){ + series[graphKey][j].attr({ fill: segment[1] }); + } + }); + + } + }); + }; + + H.seriesTypes.coloredarea.prototype.getSegmentPath = function(segment){ + var path; + + seriesTypes.area.prototype.getSegmentPath.call(this, segment); + + path = [].concat(this.areaPath); + this.areaPath = []; + + return path; + }; + + H.seriesTypes.coloredarea.prototype.getGraphPath = function() { + var series = this, + graphPath = [], + segmentPath, + singlePoints = []; // used in drawTracker + // Divide into segments and build graph and area paths + + this.areaPath = []; + each(series.segments, function (segment) { + segmentPath = series.getSegmentPath(segment.points); + // add the segment to the graph, or a single point for tracking + if (segment.points.length > 1) { + graphPath.push([segmentPath, segment.color]); + } else { + singlePoints.push(segment.points); + } + }); + + // Record it for use in drawGraph and drawTracker, and return graphPath + series.singlePoints = singlePoints; + series.graphPath = graphPath; + return graphPath; + + }; + + H.seriesTypes.coloredarea.prototype.drawLegendSymbol = H.LegendSymbolMixin.drawRectangle; + +})(Highcharts); diff --git a/html/includes/js/modules/no-data-to-display.js b/html/includes/js/modules/no-data-to-display.js new file mode 100644 index 0000000..c96c4d1 --- /dev/null +++ b/html/includes/js/modules/no-data-to-display.js @@ -0,0 +1,12 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + Plugin for displaying a message when there is no data visible in chart. + + (c) 2010-2014 Highsoft AS + Author: Oystein Moseng + + License: www.highcharts.com/license +*/ +(function(c){function f(){return!!this.points.length}function g(){this.hasData()?this.hideNoData():this.showNoData()}var d=c.seriesTypes,e=c.Chart.prototype,h=c.getOptions(),i=c.extend;i(h.lang,{noData:"No data to display"});h.noData={position:{x:0,y:0,align:"center",verticalAlign:"middle"},attr:{},style:{fontWeight:"bold",fontSize:"12px",color:"#60606a"}};if(d.pie)d.pie.prototype.hasData=f;if(d.gauge)d.gauge.prototype.hasData=f;if(d.waterfall)d.waterfall.prototype.hasData=f;c.Series.prototype.hasData= +function(){return this.dataMax!==void 0&&this.dataMin!==void 0};e.showNoData=function(a){var b=this.options,a=a||b.lang.noData,b=b.noData;if(!this.noDataLabel)this.noDataLabel=this.renderer.label(a,0,0,null,null,null,null,null,"no-data").attr(b.attr).css(b.style).add(),this.noDataLabel.align(i(this.noDataLabel.getBBox(),b.position),!1,"plotBox")};e.hideNoData=function(){if(this.noDataLabel)this.noDataLabel=this.noDataLabel.destroy()};e.hasData=function(){for(var a=this.series,b=a.length;b--;)if(a[b].hasData()&& +!a[b].options.isInternal)return!0;return!1};e.callbacks.push(function(a){c.addEvent(a,"load",g);c.addEvent(a,"redraw",g)})})(Highcharts); diff --git a/html/includes/js/modules/no-data-to-display.src.js b/html/includes/js/modules/no-data-to-display.src.js new file mode 100644 index 0000000..9badd16 --- /dev/null +++ b/html/includes/js/modules/no-data-to-display.src.js @@ -0,0 +1,130 @@ +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * Plugin for displaying a message when there is no data visible in chart. + * + * (c) 2010-2014 Highsoft AS + * Author: Oystein Moseng + * + * License: www.highcharts.com/license + */ + +(function (H) { + + var seriesTypes = H.seriesTypes, + chartPrototype = H.Chart.prototype, + defaultOptions = H.getOptions(), + extend = H.extend; + + // Add language option + extend(defaultOptions.lang, { + noData: 'No data to display' + }); + + // Add default display options for message + defaultOptions.noData = { + position: { + x: 0, + y: 0, + align: 'center', + verticalAlign: 'middle' + }, + attr: { + }, + style: { + fontWeight: 'bold', + fontSize: '12px', + color: '#60606a' + } + }; + + /** + * Define hasData functions for series. These return true if there are data points on this series within the plot area + */ + function hasDataPie() { + return !!this.points.length; /* != 0 */ + } + + if (seriesTypes.pie) { + seriesTypes.pie.prototype.hasData = hasDataPie; + } + + if (seriesTypes.gauge) { + seriesTypes.gauge.prototype.hasData = hasDataPie; + } + + if (seriesTypes.waterfall) { + seriesTypes.waterfall.prototype.hasData = hasDataPie; + } + + H.Series.prototype.hasData = function () { + return this.dataMax !== undefined && this.dataMin !== undefined; + }; + + /** + * Display a no-data message. + * + * @param {String} str An optional message to show in place of the default one + */ + chartPrototype.showNoData = function (str) { + var chart = this, + options = chart.options, + text = str || options.lang.noData, + noDataOptions = options.noData; + + if (!chart.noDataLabel) { + chart.noDataLabel = chart.renderer.label(text, 0, 0, null, null, null, null, null, 'no-data') + .attr(noDataOptions.attr) + .css(noDataOptions.style) + .add(); + chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox'); + } + }; + + /** + * Hide no-data message + */ + chartPrototype.hideNoData = function () { + var chart = this; + if (chart.noDataLabel) { + chart.noDataLabel = chart.noDataLabel.destroy(); + } + }; + + /** + * Returns true if there are data points within the plot area now + */ + chartPrototype.hasData = function () { + var chart = this, + series = chart.series, + i = series.length; + + while (i--) { + if (series[i].hasData() && !series[i].options.isInternal) { + return true; + } + } + + return false; + }; + + /** + * Show no-data message if there is no data in sight. Otherwise, hide it. + */ + function handleNoData() { + var chart = this; + if (chart.hasData()) { + chart.hideNoData(); + } else { + chart.showNoData(); + } + } + + /** + * Add event listener to handle automatic display of no-data message + */ + chartPrototype.callbacks.push(function (chart) { + H.addEvent(chart, 'load', handleNoData); + H.addEvent(chart, 'redraw', handleNoData); + }); + +}(Highcharts)); diff --git a/html/includes/js/modules/solid-gauge.js b/html/includes/js/modules/solid-gauge.js new file mode 100644 index 0000000..85e8c85 --- /dev/null +++ b/html/includes/js/modules/solid-gauge.js @@ -0,0 +1,13 @@ +/* + Highcharts JS v4.0.4 (2014-09-02) + Solid angular gauge module + + (c) 2010-2014 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(a){var k=a.getOptions().plotOptions,q=a.pInt,r=a.pick,l=a.each,n;k.solidgauge=a.merge(k.gauge,{colorByPoint:!0});n={initDataClasses:function(b){var h=this,e=this.chart,c,m=0,f=this.options;this.dataClasses=c=[];l(b.dataClasses,function(g,d){var i,g=a.merge(g);c.push(g);if(!g.color)f.dataClassColor==="category"?(i=e.options.colors,g.color=i[m++],m===i.length&&(m=0)):g.color=h.tweenColors(a.Color(f.minColor),a.Color(f.maxColor),d/(b.dataClasses.length-1))})},initStops:function(b){this.stops= +b.stops||[[0,this.options.minColor],[1,this.options.maxColor]];l(this.stops,function(b){b.color=a.Color(b[1])})},toColor:function(b,h){var e,c=this.stops,a,f=this.dataClasses,g,d;if(f)for(d=f.length;d--;){if(g=f[d],a=g.from,c=g.to,(a===void 0||b>=a)&&(c===void 0||b<=c)){e=g.color;if(h)h.dataClass=d;break}}else{this.isLog&&(b=this.val2lin(b));e=1-(this.max-b)/(this.max-this.min);for(d=c.length;d--;)if(e>c[d][0])break;a=c[d]||c[d+1];c=c[d+1]||a;e=1-(c[0]-e)/(c[0]-a[0]||1);e=this.tweenColors(a.color, +c.color,e)}return e},tweenColors:function(b,a,e){var c=a.rgba[3]!==1||b.rgba[3]!==1;return b.rgba.length===0||a.rgba.length===0?"none":(c?"rgba(":"rgb(")+Math.round(a.rgba[0]+(b.rgba[0]-a.rgba[0])*(1-e))+","+Math.round(a.rgba[1]+(b.rgba[1]-a.rgba[1])*(1-e))+","+Math.round(a.rgba[2]+(b.rgba[2]-a.rgba[2])*(1-e))+(c?","+(a.rgba[3]+(b.rgba[3]-a.rgba[3])*(1-e)):"")+")"}};a.seriesTypes.solidgauge=a.extendClass(a.seriesTypes.gauge,{type:"solidgauge",bindAxes:function(){var b;a.seriesTypes.gauge.prototype.bindAxes.call(this); +b=this.yAxis;a.extend(b,n);b.options.dataClasses&&b.initDataClasses(b.options);b.initStops(b.options)},drawPoints:function(){var b=this,h=b.yAxis,e=h.center,c=b.options,m=b.chart.renderer;a.each(b.points,function(f){var g=f.graphic,d=h.startAngleRad+h.translate(f.y,null,null,null,!0),i=q(r(c.radius,100))*e[2]/200,o=q(r(c.innerRadius,60))*e[2]/200,p=h.toColor(f.y,f),k;if(p!=="none")k=f.color,f.color=p;c.wrap===!1&&(d=Math.max(h.startAngleRad,Math.min(h.endAngleRad,d)));var d=d*180/Math.PI,j=d/(180/ +Math.PI),l=h.startAngleRad,d=Math.min(j,l),j=Math.max(j,l);j-d>2*Math.PI&&(j=d+2*Math.PI);i={x:e[0],y:e[1],r:i,innerR:o,start:d,end:j};g?(o=i.d,g.attr({fill:f.color}).animate(i,{step:function(b,c){g.attr("fill",n.tweenColors(a.Color(k),a.Color(p),c.pos))}}),i.d=o):f.graphic=m.arc(i).attr({stroke:c.borderColor||"none","stroke-width":c.borderWidth||0,fill:f.color,"sweep-flag":0}).add(b.group)})},animate:null})})(Highcharts); diff --git a/html/includes/js/modules/solid-gauge.src.js b/html/includes/js/modules/solid-gauge.src.js new file mode 100644 index 0000000..6fd14c9 --- /dev/null +++ b/html/includes/js/modules/solid-gauge.src.js @@ -0,0 +1,234 @@ +/** + * @license Highcharts JS v4.0.4 (2014-09-02) + * Solid angular gauge module + * + * (c) 2010-2014 Torstein Honsi + * + * License: www.highcharts.com/license + */ + +/*global Highcharts*/ +(function (H) { + "use strict"; + + var defaultPlotOptions = H.getOptions().plotOptions, + pInt = H.pInt, + pick = H.pick, + each = H.each, + colorAxisMethods, + UNDEFINED; + + // The default options + defaultPlotOptions.solidgauge = H.merge(defaultPlotOptions.gauge, { + colorByPoint: true + }); + + + // These methods are defined in the ColorAxis object, and copied here. + // If we implement an AMD system we should make ColorAxis a dependency. + colorAxisMethods = { + + + initDataClasses: function (userOptions) { + var axis = this, + chart = this.chart, + dataClasses, + colorCounter = 0, + options = this.options; + this.dataClasses = dataClasses = []; + + each(userOptions.dataClasses, function (dataClass, i) { + var colors; + + dataClass = H.merge(dataClass); + dataClasses.push(dataClass); + if (!dataClass.color) { + if (options.dataClassColor === 'category') { + colors = chart.options.colors; + dataClass.color = colors[colorCounter++]; + // loop back to zero + if (colorCounter === colors.length) { + colorCounter = 0; + } + } else { + dataClass.color = axis.tweenColors(H.Color(options.minColor), H.Color(options.maxColor), i / (userOptions.dataClasses.length - 1)); + } + } + }); + }, + + initStops: function (userOptions) { + this.stops = userOptions.stops || [ + [0, this.options.minColor], + [1, this.options.maxColor] + ]; + each(this.stops, function (stop) { + stop.color = H.Color(stop[1]); + }); + }, + /** + * Translate from a value to a color + */ + toColor: function (value, point) { + var pos, + stops = this.stops, + from, + to, + color, + dataClasses = this.dataClasses, + dataClass, + i; + + if (dataClasses) { + i = dataClasses.length; + while (i--) { + dataClass = dataClasses[i]; + from = dataClass.from; + to = dataClass.to; + if ((from === UNDEFINED || value >= from) && (to === UNDEFINED || value <= to)) { + color = dataClass.color; + if (point) { + point.dataClass = i; + } + break; + } + } + + } else { + + if (this.isLog) { + value = this.val2lin(value); + } + pos = 1 - ((this.max - value) / (this.max - this.min)); + i = stops.length; + while (i--) { + if (pos > stops[i][0]) { + break; + } + } + from = stops[i] || stops[i + 1]; + to = stops[i + 1] || from; + + // The position within the gradient + pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1); + + color = this.tweenColors( + from.color, + to.color, + pos + ); + } + return color; + }, + tweenColors: function (from, to, pos) { + // Check for has alpha, because rgba colors perform worse due to lack of + // support in WebKit. + var hasAlpha = (to.rgba[3] !== 1 || from.rgba[3] !== 1); + + if (from.rgba.length === 0 || to.rgba.length === 0) { + return 'none'; + } + return (hasAlpha ? 'rgba(' : 'rgb(') + + Math.round(to.rgba[0] + (from.rgba[0] - to.rgba[0]) * (1 - pos)) + ',' + + Math.round(to.rgba[1] + (from.rgba[1] - to.rgba[1]) * (1 - pos)) + ',' + + Math.round(to.rgba[2] + (from.rgba[2] - to.rgba[2]) * (1 - pos)) + + (hasAlpha ? (',' + (to.rgba[3] + (from.rgba[3] - to.rgba[3]) * (1 - pos))) : '') + ')'; + } + }; + + // The series prototype + H.seriesTypes.solidgauge = H.extendClass(H.seriesTypes.gauge, { + type: 'solidgauge', + + bindAxes: function () { + var axis; + H.seriesTypes.gauge.prototype.bindAxes.call(this); + + axis = this.yAxis; + H.extend(axis, colorAxisMethods); + + // Prepare data classes + if (axis.options.dataClasses) { + axis.initDataClasses(axis.options); + } + axis.initStops(axis.options); + }, + + /** + * Draw the points where each point is one needle + */ + drawPoints: function () { + var series = this, + yAxis = series.yAxis, + center = yAxis.center, + options = series.options, + renderer = series.chart.renderer; + + H.each(series.points, function (point) { + var graphic = point.graphic, + rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true), + radius = (pInt(pick(options.radius, 100)) * center[2]) / 200, + innerRadius = (pInt(pick(options.innerRadius, 60)) * center[2]) / 200, + shapeArgs, + d, + toColor = yAxis.toColor(point.y, point), + fromColor; + + if (toColor !== 'none') { + fromColor = point.color; + point.color = toColor; + } + + // Handle the wrap option + if (options.wrap === false) { + rotation = Math.max(yAxis.startAngleRad, Math.min(yAxis.endAngleRad, rotation)); + } + rotation = rotation * 180 / Math.PI; + + var angle1 = rotation / (180 / Math.PI), + angle2 = yAxis.startAngleRad, + minAngle = Math.min(angle1, angle2), + maxAngle = Math.max(angle1, angle2); + + if (maxAngle - minAngle > 2 * Math.PI) { + maxAngle = minAngle + 2 * Math.PI; + } + + shapeArgs = { + x: center[0], + y: center[1], + r: radius, + innerR: innerRadius, + start: minAngle, + end: maxAngle + }; + + if (graphic) { + d = shapeArgs.d; + + /*jslint unparam: true*/ + graphic.attr({ + fill: point.color + }).animate(shapeArgs, { + step: function (value, fx) { + graphic.attr('fill', colorAxisMethods.tweenColors(H.Color(fromColor), H.Color(toColor), fx.pos)); + } + }); + /*jslint unparam: false*/ + shapeArgs.d = d; // animate alters it + } else { + point.graphic = renderer.arc(shapeArgs) + .attr({ + stroke: options.borderColor || 'none', + 'stroke-width': options.borderWidth || 0, + fill: point.color, + 'sweep-flag': 0 + }) + .add(series.group); + } + }); + }, + animate: null + }); + +}(Highcharts)); diff --git a/html/includes/js/themes/dark-blue.js b/html/includes/js/themes/dark-blue.js new file mode 100644 index 0000000..7cf7138 --- /dev/null +++ b/html/includes/js/themes/dark-blue.js @@ -0,0 +1,254 @@ +/** + * Dark blue theme for Highcharts JS + * @author Torstein Honsi + */ + +Highcharts.theme = { + colors: ["#DDDF0D", "#55BF3B", "#DF5353", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee", + "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"], + chart: { + backgroundColor: { + linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 }, + stops: [ + [0, 'rgb(48, 48, 96)'], + [1, 'rgb(0, 0, 0)'] + ] + }, + borderColor: '#000000', + borderWidth: 2, + className: 'dark-container', + plotBackgroundColor: 'rgba(255, 255, 255, .1)', + plotBorderColor: '#CCCCCC', + plotBorderWidth: 1 + }, + title: { + style: { + color: '#C0C0C0', + font: 'bold 16px "Trebuchet MS", Verdana, sans-serif' + } + }, + subtitle: { + style: { + color: '#666666', + font: 'bold 12px "Trebuchet MS", Verdana, sans-serif' + } + }, + xAxis: { + gridLineColor: '#333333', + gridLineWidth: 1, + labels: { + style: { + color: '#A0A0A0' + } + }, + lineColor: '#A0A0A0', + tickColor: '#A0A0A0', + title: { + style: { + color: '#CCC', + fontWeight: 'bold', + fontSize: '12px', + fontFamily: 'Trebuchet MS, Verdana, sans-serif' + + } + } + }, + yAxis: { + gridLineColor: '#333333', + labels: { + style: { + color: '#A0A0A0' + } + }, + lineColor: '#A0A0A0', + minorTickInterval: null, + tickColor: '#A0A0A0', + tickWidth: 1, + title: { + style: { + color: '#CCC', + fontWeight: 'bold', + fontSize: '12px', + fontFamily: 'Trebuchet MS, Verdana, sans-serif' + } + } + }, + tooltip: { + backgroundColor: 'rgba(0, 0, 0, 0.75)', + style: { + color: '#F0F0F0' + } + }, + toolbar: { + itemStyle: { + color: 'silver' + } + }, + plotOptions: { + line: { + dataLabels: { + color: '#CCC' + }, + marker: { + lineColor: '#333' + } + }, + spline: { + marker: { + lineColor: '#333' + } + }, + scatter: { + marker: { + lineColor: '#333' + } + }, + candlestick: { + lineColor: 'white' + } + }, + legend: { + itemStyle: { + font: '9pt Trebuchet MS, Verdana, sans-serif', + color: '#A0A0A0' + }, + itemHoverStyle: { + color: '#FFF' + }, + itemHiddenStyle: { + color: '#444' + } + }, + credits: { + style: { + color: '#666' + } + }, + labels: { + style: { + color: '#CCC' + } + }, + + navigation: { + buttonOptions: { + symbolStroke: '#DDDDDD', + hoverSymbolStroke: '#FFFFFF', + theme: { + fill: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0.4, '#606060'], + [0.6, '#333333'] + ] + }, + stroke: '#000000' + } + } + }, + + // scroll charts + rangeSelector: { + buttonTheme: { + fill: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0.4, '#888'], + [0.6, '#555'] + ] + }, + stroke: '#000000', + style: { + color: '#CCC', + fontWeight: 'bold' + }, + states: { + hover: { + fill: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0.4, '#BBB'], + [0.6, '#888'] + ] + }, + stroke: '#000000', + style: { + color: 'white' + } + }, + select: { + fill: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0.1, '#000'], + [0.3, '#333'] + ] + }, + stroke: '#000000', + style: { + color: 'yellow' + } + } + } + }, + inputStyle: { + backgroundColor: '#333', + color: 'silver' + }, + labelStyle: { + color: 'silver' + } + }, + + navigator: { + handles: { + backgroundColor: '#666', + borderColor: '#AAA' + }, + outlineColor: '#CCC', + maskFill: 'rgba(16, 16, 16, 0.5)', + series: { + color: '#7798BF', + lineColor: '#A6C7ED' + } + }, + + scrollbar: { + barBackgroundColor: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0.4, '#888'], + [0.6, '#555'] + ] + }, + barBorderColor: '#CCC', + buttonArrowColor: '#CCC', + buttonBackgroundColor: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0.4, '#888'], + [0.6, '#555'] + ] + }, + buttonBorderColor: '#CCC', + rifleColor: '#FFF', + trackBackgroundColor: { + linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, + stops: [ + [0, '#000'], + [1, '#333'] + ] + }, + trackBorderColor: '#666' + }, + + // special colors for some of the + legendBackgroundColor: 'rgba(0, 0, 0, 0.5)', + background2: 'rgb(35, 35, 70)', + dataLabelsColor: '#444', + textColor: '#C0C0C0', + maskColor: 'rgba(255,255,255,0.3)' +}; + +// Apply the theme +var highchartsOptions = Highcharts.setOptions(Highcharts.theme); diff --git a/html/includes/renderer-ctf.php b/html/includes/renderer-ctf.php new file mode 100644 index 0000000..9e0cef3 --- /dev/null +++ b/html/includes/renderer-ctf.php @@ -0,0 +1,264 @@ +<?php + +require_once 'renderer-general-import.php'; + +/** +Render graph with scores & grabs +*/ +function renderScoreGraph($uid) { + global $matchid; + global $time_gamestart; + global $time_gameend; + global $time_ratio_correction; + global $playernumberofteams; + global $playerteams; + + $uid = mysql_real_escape_string($uid); + + // Get all frags related events + start & end + $q_frags = mysql_query("SELECT * FROM `uts_temp_$uid` WHERE col0>=".mysql_real_escape_string($time_gamestart)." ORDER BY id ASC") or die(mysql_error()); + + // init caps/grabs array + $caps = array(); + $grabs = array(); + $lastCapTeam = array(); + $overTimeCap = false; + + $teamLabels = generateTeamLabels(); + $realTimeEnd = ($time_gameend-$time_gamestart)/$time_ratio_correction/60; + + // init vars & ensure datapoint at origin + for($i=0;$i<$playernumberofteams;$i++) { + $caps[$i][0] = array(0,0); + $prevcaps[$i] = 0; + $prevgrabs[$i] = 0; + + $flagmid[$i] = 0; + $flagbase[$i] = 0; + $flagclose[$i] = 0; + $flagnmybase[$i] = 0; + $flagcap[$i] = 0; + } + + $counter = 1; + while($data = mysql_fetch_array($q_frags)) { + + // Collect data from utstats own table + $r_id = $data[0]; + $r_time = round(($data[1]-$time_gamestart)/$time_ratio_correction/60,2); // Transform UT time to real time + $r_type = $data[2]; + $r_capper = $data[3]; + $r_team = $playerteams[$r_capper]; + + // Try to get team directly from data if possible, in case not found in playerteam db + if(!($r_team >=0 && strlen($r_team)>0)) { + if($data[4] == 0 || $data[4] == 20) + $r_team = 1; + if($data[4] == 1 || $data[4] == 14) + $r_team = 0; + } + + // Only collect team stats if team was found - sometimes this is bugged + if($r_team >=0 && strlen($r_team)>0) { + + // If flag is captured, save this datapoint + if($r_type == "flag_captured") { + $prevcaps[$r_team]++; + $flagcap[$r_team]++; + $flagnmybase[$r_team]--; + + // Analyse cap for tooltip data + $capdata = analyseCap($uid,$data[1],$r_capper,$r_team,$r_id); + + $caps[$r_team][] = array("x" => $r_time,"y" => $prevcaps[$r_team], "tooltipdata" => $capdata); + $lastCapTeam = array($r_time,$r_team); + + // If grab is done, simply save this event + } else if($r_type == "flag_taken") { + $prevgrabs[$r_team]++; + $flagnmybase[$r_team]++; + } else if($r_type == "flag_return_mid") { + $flagmid[$r_team]++; + $flagnmybase[$r_team]--; + } else if($r_type == "flag_return_enemybase") { + $flagbase[$r_team]++; + $flagnmybase[$r_team]--; + } else if($r_type == "flag_return_closesave") { + $flagclose[$r_team]++; + $flagnmybase[$r_team]--; + + } + + // If game_end event & game ended cause timelimit reached, round the time down to prevent UT gay timing to screw the graph + } if($r_type == "game_end") { + + // If it's a regular timelimit, floor the time to get it nicely rounded (ref gay UT timing)\ + $overTimeCap = (($r_time-$lastCapTeam[0])<=0.01); + + if($r_capper == "timelimit" && !$overTimeCap) + $r_time = round($r_time); + + // Repeat final CTF score at the end + for($i=0;$i<$playernumberofteams;$i++) { + if(!$overTimeCap || $i != $lastCapTeam[1]) + $caps[$i][] = array($r_time,$prevcaps[$i]); + } + } + + // Each minute, save amount of grabs. Don't do it for last minute if this one was less than half a minute + if(($r_time>=$counter && ($realTimeEnd-$r_time)>0.49) || $r_type == "game_end") { + + // Save grabs last min and reset + for($i=0;$i<$playernumberofteams;$i++) { + $grabs[$i][] = $prevgrabs[$i]; + $prevgrabs[$i] = 0; + } + + $counter++; + } + } + + // Ensure flagNmyBase is at least 0 + for($i=0;$i<$playernumberofteams;$i++) { + if($flagnmybase[$i]<0) + $flagnmybase[$i] = 0; + } + + // Save team score over team for teams + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_CTF_TEAMSCORE.", + '".mysql_real_escape_string(gzencode(serialize(array($grabs,$caps))))."', + '".mysql_real_escape_string(gzencode(serialize($teamLabels)))."')") or die(mysql_error()); + + $labelsBreakdown = array('caps','close','base','mid','enemy base'); + + // Save team score over team for teams + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_CTF_GRABBREAKDOWN.", + '".mysql_real_escape_string(gzencode(serialize(array($flagcap,$flagclose,$flagbase,$flagmid,$flagnmybase))))."', + '".mysql_real_escape_string(gzencode(serialize($labelsBreakdown)))."')") or die(mysql_error()); + +} + +/** +Analyse cap to show in tooltip +*/ +function analyseCap($uid, $capTime, $capPlayer,$capTeam, $capId) { + global $playernames; + global $playerteams; + global $time_ratio_correction; + + // Initialise variables + $tooltip = ''; + $cherrypick = ''; + $solocap = ''; + $standoff = ''; + $hero = ''; + $event = array(); + $cherrypickDone = false; + + $event[0]['flag_taken'] = array('id' => 0, 'time' => 0, 'player' => ''); + $event[0]['flag_returned'] = array('id' => 0, 'time' => 0, 'player' => ''); + $event[0]['flag_captured'] = array('id' => 0, 'time' => 0, 'player' => ''); + $event[1]['flag_taken'] = array('id' => 0, 'time' => 0, 'player' => ''); + $event[1]['flag_returned'] = array('id' => 0, 'time' => 0, 'player' => ''); + $event[1]['flag_captured'] = array('id' => 0, 'time' => 0, 'player' => ''); + + // Get grab time for both teams related to this cap. Query of the month award. + $q_grabs = mysql_query("SELECT f.id AS id, f.col0 AS gtime, f.col1 AS event, f.col2 AS player, f.col3 AS team + FROM ( + SELECT col3, col1, MAX( col0 ) AS xgtime FROM `uts_temp_$uid` WHERE (col1 = 'flag_taken' OR col1 = 'flag_returned' OR col1 = 'flag_captured') AND id<".mysql_real_escape_string($capId)." GROUP BY col3,col1 ORDER BY col3 DESC + ) AS x INNER JOIN `uts_temp_$uid` AS f + on f.col3 = x.col3 AND f.col1 = x.col1 AND f.col0 = x.xgtime") or die(mysql_error()); + + // Only continue if you have at least one event (should be at least flag_taken for this cap) + if(mysql_num_rows($q_grabs) >0) { + + while($r_grabs = mysql_fetch_array($q_grabs)) { + // Ugly code to fix bug where sometimes 20 or 14 is imported instead of 0 and 1 respectively + $fixedteam = ($r_grabs['team']==20)?0:$r_grabs['team']; + $fixedteam = ($fixedteam==14)?1:$fixedteam; + + // Swap team around since ut logs which flag has been taken, thus opposite team actually took it + $event[1-$fixedteam][$r_grabs['event']] = array('id' => $r_grabs['id'],'time' => $r_grabs['gtime'],'player' => $r_grabs['player']); + } + + // Determine how long flags were holded + $flagHolded[$capTeam] = $capTime - $event[$capTeam]['flag_taken']['time']; + $flagHolded[1-$capTeam] = $event[1-$capTeam]['flag_returned']['time'] - $event[1-$capTeam]['flag_taken']['time']; + + // Determine if this cap resulted from a cherrypick + // For this the flag shoudl be taken within 4 seconds after return + // Only register as cherry pick if previous run was at least 10 sec, otherwise it's not really a hcerry pick but just a subsequent grab + if($event[$capTeam]['flag_returned']['time']>0 && ($event[$capTeam]['flag_taken']['time']-$event[$capTeam]['flag_returned']['time'])<4) { + + $prevRunTime = small_query("SELECT MAX( col0 ) as gtime FROM `uts_temp_$uid` WHERE id<".mysql_real_escape_string($event[$capTeam]['flag_returned']['id'])." AND col1='flag_taken' AND col3='".(1-$capTeam)."'") or die(mysql_error()); + + if(($event[$capTeam]['flag_returned']['time'] - $prevRunTime[0]) > 10) + $cherrypickDone = true; + } + + if($event[$capTeam]['flag_captured']['time']>0 && ($event[$capTeam]['flag_taken']['time']-$event[$capTeam]['flag_captured']['time'])<4) + $cherrypickDone = true; + + if($cherrypickDone) + $cherrypick = "<br><span style=\"fontSize: '7px'; font-style: italic;\">Cherrypick by ".renderPlayernameForTooltip($event[$capTeam]['flag_taken']['player'])."</span>"; + + // Determine if solo cap + // First check if person who grabbed is same person as capper + if($event[$capTeam]['flag_taken']['player'] == $capPlayer) { + + // Second check is to see no pickups were done during this run + if(small_count("SELECT * FROM `uts_temp_$uid` WHERE col1 = 'flag_pickedup' AND col3 = '".(1-$capTeam)."' AND id<".mysql_real_escape_string($capId)." AND id>".mysql_real_escape_string($event[$capTeam]['flag_taken']['id'])) == 0) { + + $solocap = "<br>Solo cap"; + + } + + } + + // If taken for more than 30 seconds for both teams, this is a long standoff + // Add who did the return + if($flagHolded[$capTeam] > 30 && $flagHolded[1-$capTeam] > 30 && $event[1-$capTeam]['flag_returned']['player'] >= 0) + $standoff = "<br>Standoff return by ".renderPlayernameForTooltip($event[1-$capTeam]['flag_returned']['player']); + + $tooltip = "Capped by : ".renderPlayernameForTooltip($capPlayer)." (".renderTimeForTooltip($flagHolded[$capTeam]/$time_ratio_correction).")"; + $tooltip .= $cherrypick; + $tooltip .= $solocap; + $tooltip .= $standoff; + + } + + return $tooltip; +} + +/** +Prep temporary database for CTF parsing +*/ +function prepCTFdata($safe_uid) { + + // Replace time-out return by normal return + mysql_query("UPDATE `uts_temp_$safe_uid` SET col1='flag_returned', col2=(@temp:=col2),col2='-1',col3=@temp WHERE col1='flag_returned_timeout'") or die(mysql_error()); + +} + +function renderPlayernameForTooltip($pid) { + global $playernames; + + return substr($playernames[$pid],0,25); +} + +function renderTimeForTooltip($time) { + + $minutes = floor($time/60); + if($minutes > 0) { + $strtime = $minutes."min "; + $time = $time - $minutes*60; + } + + $seconds = round($time,0); + if($seconds >= 1) + $strtime .= $seconds."sec"; + + return $strtime; +} + +?>
\ No newline at end of file diff --git a/html/includes/renderer-dm.php b/html/includes/renderer-dm.php new file mode 100644 index 0000000..8e9f439 --- /dev/null +++ b/html/includes/renderer-dm.php @@ -0,0 +1,252 @@ +<?php + +require_once 'renderer-general-import.php'; + +/** +Render team DM graph for 2 teams scenario +*/ +function renderFragBarsTeams($datafragsteam,$derivfragsteam,$topTeams,$counter) { + global $matchid; + + $teamLabels = generateTeamLabels(); + + if($playernumberofteams == 2) { + // Net frags for first 2 teams + for($i=0;$i<($counter-1);$i++) { + $netfragsteam[0][$i] = $derivfragsteam[0][$i]-$derivfragsteam[1][$i]; + $netfragsteam[1][$i] = $derivfragsteam[1][$i]-$derivfragsteam[0][$i]; + + $netfragsteam[0][$i] = $netfragsteam[0][$i]>0 ? $netfragsteam[0][$i] : 0; + $netfragsteam[1][$i] = $netfragsteam[1][$i]>0 ? $netfragsteam[1][$i] : 0; + } + + // Save net frags in db for first 2 teams + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_TEAMDERIV.", + '".mysql_real_escape_string(gzencode(serialize(array($netfragsteam,$datafragsteam))))."', + '".mysql_real_escape_string(gzencode(serialize($teamLabels)))."')") or die(mysql_error()); + + } else { + + // Save team score over team for teams + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_TEAMSCORE.", + '".mysql_real_escape_string(gzencode(serialize($datafragsteam)))."', + '".mysql_real_escape_string(gzencode(serialize($teamLabels)))."')") or die(mysql_error()); + + } + + // Generate normalized data (vs #2) & store it + $normalfragsteam = normalizeDMdata($datafragsteam,$topTeams,$counter); + + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_TEAMNORMAL.", + '".mysql_real_escape_string(gzencode(serialize($normalfragsteam)))."', + '".mysql_real_escape_string(gzencode(serialize($teamLabels)))."')") or die(mysql_error()); + +} + + +/** +Basically generates all the different graphs wrt frags over time +*/ +function renderFragBars($datafrags, $derivfrags, $topFraggers,$counter) { + global $matchid; + + // base frags based on amount of players + $countPlayers = count($topFraggers); + + $topFraggersLabels = array_chunk(generateLabelsFraggers($topFraggers),4); + $datafragschunks = array_chunk(sortDMdata($datafrags,$topFraggers),4); + + // Only do something if there are frags & players + if($countPlayers > 1 && count($datafrags[$topFraggers[0]])>0 && count($derivfrags[$topFraggers[0]])>0) { + + // In duel, show bar chart like DOM + if($countPlayers == 2) { + + // Net frags for first 2 players + for($i=0;$i<($counter-1);$i++) { + $netfrags[0][$i] = $derivfrags[$topFraggers[0]][$i]-$derivfrags[$topFraggers[1]][$i]; + $netfrags[1][$i] = $derivfrags[$topFraggers[1]][$i]-$derivfrags[$topFraggers[0]][$i]; + + $netfrags[0][$i] = $netfrags[0][$i]>0 ? $netfrags[0][$i] : 0; + $netfrags[1][$i] = $netfrags[1][$i]>0 ? $netfrags[1][$i] : 0; + } + + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_PLAYERDERIV.", + '".mysql_real_escape_string(gzencode(serialize(array($netfrags,$datafragschunks[0]))))."', + '".mysql_real_escape_string(gzencode(serialize($topFraggersLabels[0])))."')") or die(mysql_error()); + + } else { + + // Generate graph for player 1 to 4 + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_PLAYERSCORE.", + '".mysql_real_escape_string(gzencode(serialize($datafragschunks[0])))."', + '".mysql_real_escape_string(gzencode(serialize($topFraggersLabels[0])))."')") or die(mysql_error()); + + } + + // Normalize frags + $normalfrags = normalizeDMdata($datafrags,$topFraggers,$counter); + $normalfragschunks = array_chunk(sortDMdata($normalfrags,$topFraggers),4); + + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_PLAYERNORMAL.", + '".mysql_real_escape_string(gzencode(serialize($normalfragschunks[0])))."', '".mysql_real_escape_string(gzencode(serialize($topFraggersLabels[0])))."')") or die(mysql_error()); + + // If at least 8 players, also great second graph for 5 to 8 + if($countPlayers >= 8) { + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_PLAYERSCORE5.", + '".mysql_real_escape_string(gzencode(serialize($datafragschunks[1])))."', + '".mysql_real_escape_string(gzencode(serialize($topFraggersLabels[1])))."')") or die(mysql_error()); + + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_FRAGS_PLAYERNORMAL5.", + '".mysql_real_escape_string(gzencode(serialize($normalfragschunks[1])))."', + '".mysql_real_escape_string(gzencode(serialize($topFraggersLabels[1])))."')") or die(mysql_error()); + } + + + } +} + + +/** +Sort data based on ranking of players +*/ +function sortDMdata($datafrags,$topFraggers) { + $sortedArray = array(); + + foreach($topFraggers as $fragger) { + $sortedArray[] = $datafrags[$fragger]; + } + + return $sortedArray; +} + +/** +Normalize data vs #2 in rank to show gap over time +*/ +function normalizeDMdata($datafrags, $topFraggers,$counter) { + // base frags based on amount of players + $countPlayers = count($topFraggers); + $player3hasData = (count($datafrags[$topFraggers[2]])>0); + $player4hasData = (count($datafrags[$topFraggers[3]])>0); + + // Generate normalized data for players + for($i=0;$i<$counter;$i++) { + + // Normalize data vs #2 for first 4 players + $normalfrags[$topFraggers[0]][$i] = $datafrags[$topFraggers[0]][$i] - $datafrags[$topFraggers[1]][$i]; + $normalfrags[$topFraggers[1]][$i] = 0; + + if($countPlayers >=3 && $player3hasData) + $normalfrags[$topFraggers[2]][$i] = $datafrags[$topFraggers[2]][$i] - $datafrags[$topFraggers[1]][$i]; + if($countPlayers >=4 && $player4hasData) + $normalfrags[$topFraggers[3]][$i] = $datafrags[$topFraggers[3]][$i] - $datafrags[$topFraggers[1]][$i]; + + // Also do this vs 6 for player 5 to 8 if we have at least 8 players + if($countPlayers >= 8) { + $normalfrags[$topFraggers[4]][$i] = $datafrags[$topFraggers[4]][$i] - $datafrags[$topFraggers[5]][$i]; + $normalfrags[$topFraggers[6]][$i] = $datafrags[$topFraggers[6]][$i] - $datafrags[$topFraggers[5]][$i]; + $normalfrags[$topFraggers[7]][$i] = $datafrags[$topFraggers[7]][$i] - $datafrags[$topFraggers[5]][$i]; + $normalfrags[$topFraggers[5]][$i] = 0; + } + + } + + return $normalfrags; +} + +/** +Get data wrt frags over time +*/ +function parseDMdata($uid) { + global $time_gamestart; + global $time_gameend; + global $time_ratio_correction; + global $playernumberofteams; + global $playerteams; + + $uid = mysql_real_escape_string($uid); + + // Get all frags related events + start & end + $q_frags = mysql_query("SELECT * FROM `uts_temp_$uid` WHERE col0>=".mysql_real_escape_string($time_gamestart)." ORDER BY id ASC") or die(mysql_error()); + + // Get all unique player id's + $q_ids = mysql_query("SELECT DISTINCT col2 FROM `uts_temp_$uid` WHERE col1='kill'"); + while($data = mysql_fetch_array($q_ids)) { + $ids[] = $data[0]; + } + + // Iterate over frags + $prevx = 0; + $prevfrags = array(); + $prevfragsteam = array(); + $counter = 1; + $firstrun = true; + $realTimeEnd = ($time_gameend-$time_gamestart)/$time_ratio_correction/60; + + while($data = mysql_fetch_array($q_frags)) { + + // Collect data from utstats own table + $r_time = ($data[1]-$time_gamestart)/$time_ratio_correction/60; // Transform UT time to real time + $r_type = $data[2]; + $r_killer = $data[3]; + + // If game_end event & game ended cause timelimit reached, round the time down to prevent UT gay timing to screw the graph + if($r_type == "game_end" && $r_capper == "timelimit") + $r_time = floor($r_time); + + // Add frag if kill event, deduct if suicide + if($r_type == "kill") { + $frags[$r_killer]++; + $fragsteam[$playerteams[$r_killer]]++; + } else if($r_type == "suicide" || $r_type == "teamkill") { + $frags[$r_killer]--; + $fragsteam[$playerteams[$r_killer]]--; + } + + // Only save the data each minute. Added game_start & game_end for first & last tick + // Add 0.05 sec to counter for gay UT timing rounding error + if($r_type == "game_start" || ($r_time>$counter && ($realTimeEnd-$r_time)>0.4) || $r_type == "game_end") { + + foreach($ids as $id) { + // On first run, everyone has score 0 + if($firstrun) + $frags[$id] = 0; + else + $derivfrags[$id][] = $frags[$id] - $prevfrags[$id]; + + $datafrags[$id][] = $frags[$id]; + } + + $prevfrags = $frags; + + for($i=0;$i<$playernumberofteams;$i++) { + // On first run, everyone has score 0 + if($firstrun) + $fragsteam[$i] = 0; + else + $derivfragsteam[$i][] = $fragsteam[$i] - $prevfragsteam[$i]; + + $datafragsteam[$i][] = $fragsteam[$i]; + + } + + $prevfragsteam = $fragsteam; + + if(!$firstrun) + $counter++; + else + $firstrun = false; + } + + } + + // Get top 8 - no time for the noobies + arsort($frags); + arsort($fragsteam); + $topFraggers = array_slice(array_keys($frags),0,8); + $topTeams = array_slice(array_keys($fragsteam),0,$playernumberofteams); + + return array($datafrags, $derivfrags, $topFraggers,$counter,$datafragsteam,$derivfragsteam,$topTeams); +} + +?>
\ No newline at end of file diff --git a/html/includes/renderer-dom.php b/html/includes/renderer-dom.php new file mode 100644 index 0000000..d481695 --- /dev/null +++ b/html/includes/renderer-dom.php @@ -0,0 +1,396 @@ +<?php + +require_once 'renderer-general-import.php'; + +/* +Helper function to create the temporary table used for dom stats +*/ +function createEmptyTempTable($table_name) { + + $sqlCreateTable = " + CREATE TEMPORARY TABLE `$table_name` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cp` varchar(254) NOT NULL, + `teamid` int(11) NOT NULL, + `playerid` int(11) NOT NULL, + `playername` varchar(254) NOT NULL, + `start` float NOT NULL, + `end` float NOT NULL, + `time` float NOT NULL, + `scoret0` float NOT NULL, + `scoret1` float NOT NULL, + `realTimeEnd` float NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM + "; + mysql_query($sqlCreateTable) or die(mysql_error()); +} + +/* +Create & populate the dom stats table +@return name of temporary table +*/ +function generateTempTable($uid) { + global $playernames; + global $playerteams; + global $time_gamestart; + global $time_gameend; + global $time_ratio_correction; + + $uid = mysql_real_escape_string($uid); + $tempTableName = "uts_tempidom_".$uid; + + createEmptyTempTable($tempTableName); + + // iterate over cp's. also capture game-end event as a quick hack to also do final iteration over final cp + $q_logdom = mysql_query("SELECT * FROM uts_temp_$uid WHERE (col1='controlpoint_capture' OR col1='game_end') AND col0>".mysql_real_escape_string($time_gamestart)." ORDER BY col1, col2, id ASC")or die(mysql_error()); + + $prev_time = 0; + + // dynamicly create insert query to populate the table in 1 go, instead of multiple database calls + $insertQuery = "INSERT INTO $tempTableName (cp, teamid, playerid, playername, start, end, time,scoret0,scoret1,realTimeEnd) VALUES"; + + // basically loop over all capture events per CP. Each time calculate how long the previous owner had the point and translate this to dom points + while($r_logdom = mysql_fetch_array($q_logdom)) { + $points[0] = 0; + $points[1] = 0; + $ticks[0] = 0; + $ticks[1] = 0; + + $start_time = $prev_time; + + $r_cp = mysql_real_escape_string($r_logdom['col2']); + $r_time = mysql_real_escape_string($r_logdom['col0']); + + // skip first capture event - no dom points given at start of map since no-one has cp + if($prev_time > 0) { + + // if switching to other cp + if($prev_cp != $r_cp) { + $end_time = $time_gameend; // take game end time to calculate time cp was taken, since it's the last time it's taken + extra tick for end time + + } else { + $end_time = $r_time; + } + + $time_diff = ($end_time - $start_time); + + // point has to be yours for at least a second before it starts to add points + if($time_diff >= 1) { + + // after this second, it will start to add points during each time the timer runs (= each second) + // thus, first run of timer is ceil of start time + // also, floor of end time since having the point after the timer ran, but not until the next tick = no points + // timing in log does not account for gamespeed, typically 1.1 ratio, which is corrected in these times + // test was done to save the actual tick times based upon the dom_points stats event (happens each 5 ticks), but this doesn't result in significant better results to be worth the effort + + // save amount of timer 'ticks' that generate a score of 0.2 + $ticks[$r_teamid] = (floor($end_time/$time_ratio_correction)-ceil($start_time/$time_ratio_correction)); + + } + + // if no tick happened, insert the event with 0 points + if($ticks[$r_teamid]==0) { + + $realTimeEnd=($start_time-$time_gamestart)/$time_ratio_correction/60; + $insertQuery .= " ('$prev_cp', '$r_teamid', '$r_pid', '$r_pname', '$start_time', '$end_time', '$time_diff', '".$points[0]."', '".$points[1]."', '$realTimeEnd'),"; + + // if ticks happened, insert each seperate tick as an event + } else { + + for($i=1;($ticks[$r_teamid]+1-$i) > 0;$i++) { + + $realTimeEnd=($start_time+$time_diff/$ticks[$r_teamid]*$i-$time_gamestart)/$time_ratio_correction/60; + $points[$r_teamid] = 0.2; + + $insertQuery .= " ('$prev_cp', '$r_teamid', '$r_pid', '$r_pname', '$start_time', '$end_time', '$time_diff', '".$points[0]."', '".$points[1]."', '$realTimeEnd'),"; + + } + } + + } + + // save data for current capture event + $prev_time = $r_time; + $prev_cp = $r_cp; + + $r_event = mysql_real_escape_string($r_logdom['col1']); + $r_pid = mysql_real_escape_string($r_logdom['col3']); + $r_teamid = mysql_real_escape_string($playerteams[$r_pid]); + $r_pname = mysql_real_escape_string($playernames[$r_pid]); + + } + + // populate table + $insertQuery = rtrim($insertQuery,","); + mysql_query($insertQuery) or die(mysql_error()); + + return $tempTableName; + +} + +/* +Generate times when amp was taken +@return $amps[$team][$start_time,$end_time, $pid] +*/ +function generateAmpTimes($uid) { + global $playernames; + global $playerteams; + global $time_gamestart; + global $time_gameend; + global $time_ratio_correction; + + $amps = array(); + $prev_time = array(); + + $uid = mysql_real_escape_string($uid); + + // Get activate & deactivate times & players + $q_amps = mysql_query("SELECT col0,col1,col3 FROM uts_temp_$uid WHERE col2='Damage Amplifier' AND (col1='item_activate' OR col1='item_deactivate') ORDER BY id ASC"); + while($r_amps = mysql_fetch_array($q_amps)) { + $time = ($r_amps[0]-$time_gamestart)/$time_ratio_correction/60; + $event = $r_amps[1]; + $pid = $r_amps[2]; + + // If amp is deactivated, calculate the time it was used + if($event == "item_deactivate") { + $amps[$playerteams[$pid]][] = array($prev_time[$pid], $time,$pid); + $prev_time[$pid] = 0; + + // If amp is activated & none yet acquired, save the time of the start of this amp run + } else if($prev_time[$pid] == 0) { + $prev_time[$pid] = $time; + } + } + + return $amps; +} + +/* +Function to render the chart with amp runs +*/ +function renderAmpBars($uid,$tempTableName) { + global $playernames; + global $ampTimes; + global $matchid; + global $renderer_color; + + $uid = mysql_real_escape_string($uid); + + // Iterate over amp runs + for($i=0;$i<2;$i++) { + foreach ($ampTimes[$i] as $ampTaken) { + $ampStart = mysql_real_escape_string($ampTaken[0]); + $ampEnd = mysql_real_escape_string($ampTaken[1]); + $pid = $ampTaken[2]; + + // Only save amp runs longer than 20seconds + if($ampEnd > ($ampStart+.33)) { + + // Get scores during amprun + $q_scoresDuringAmp = mysql_query("SELECT SUM(scoret0),SUM(scoret1) FROM $tempTableName WHERE realTimeEnd > $ampStart AND realTimeEnd < $ampEnd"); + $r_scoresDuringAmps = mysql_fetch_array($q_scoresDuringAmp); + + $netPoints = $r_scoresDuringAmps[$i] - $r_scoresDuringAmps[1-$i]; + + // Process time for readable label + $totalTime = $ampEnd-$ampStart; + $totalTimeMinutes = floor($totalTime); + $totalTimeSeconds = round(($totalTime-$totalTimeMinutes)*60,0); + + $timeLabel = ""; + if($totalTimeMinutes>0) { $timeLabel .= $totalTimeMinutes."m"; } + if($totalTimeSeconds>0) { $timeLabel .= $totalTimeSeconds."s"; } + + $playerName = $playernames[$pid]; + + $ampRun['start'] = $ampStart; + $ampRun['label'] = substr($playerName,0,18)." (".$timeLabel.")"; + $ampRun['points'] = round($netPoints,0); + $ampRun['team'] = $i; + + $ampRuns[] = $ampRun; + } + } + } + + if(count($ampRuns)>0) { + + // Sort ampruns not on teams, but on start time, to make sure they are plotted chronocologicstic + $ampRuns = array_sort($ampRuns,'start'); + + $data = array(); + $labels = array("Net Points"); + $categories = array(); + + // Process the ampruns to map it to bar plots + foreach ($ampRuns as $ampRun) { + $categories[] = $ampRun['label']; + $data[] = array("y" => $ampRun['points'], "color" => $renderer_color['team'][$ampRun['team']][0]); + } + + // Save team score over team for teams + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels,categories) VALUES (".$matchid.", ".RENDERER_CHART_ITEMS_AMPRUNS.", + '".mysql_real_escape_string(gzencode(serialize(array($data))))."', + '".mysql_real_escape_string(gzencode(serialize($labels)))."', + '".mysql_real_escape_string(gzencode(serialize($categories)))."')") or die(mysql_error()); + + } + + +} + +/* +Render dom points over time & net rate of change per minute over all cp's +*/ +function renderDataTotal($uid,$tempTableName) { + $query = "SELECT t.realTimeEnd,@t0sum := @t0sum + t.scoret0 AS cumulScoret0,@t1sum := @t1sum + t.scoret1 AS cumulScoret1 FROM $tempTableName t JOIN (SELECT @t0sum := 0) r JOIN (SELECT @t1sum := 0) s ORDER BY realTimeEnd ASC"; + $appex = "total"; + + renderData($uid,$tempTableName,$query,$appex,"Total score",""); +} + +/* +Render dom points over time & net rate of change per minute per cp +*/ +function renderDataCPs($uid,$tempTableName) { + $q_cps = mysql_query("SELECT DISTINCT(cp) FROM $tempTableName"); + + $i=0; + while($r_cps = mysql_fetch_array($q_cps)) { + $r_cp = mysql_real_escape_string($r_cps[0]); + $query = "SELECT t.realTimeEnd,@t0sum := @t0sum + t.scoret0 AS cumulScoret0,@t1sum := @t1sum + t.scoret1 AS cumulScoret1 FROM $tempTableName t JOIN (SELECT @t0sum := 0) r JOIN (SELECT @t1sum := 0) s WHERE t.CP = '$r_cp' ORDER BY realTimeEnd ASC"; + $appex = "cp".$i++; + renderData($uid,$tempTableName,$query,$appex,"Score CP ".$r_cps[0],$r_cps[0]); + + } +} + +/* +Render dom points over time & net rate of change per minute +*/ +function renderData($uid,$tempTableName,$query,$appex,$title,$cp) { + global $matchid; + + // Use helper function to parse the data into different datasets for charts + list($dompoints,$derivdompoints) = parseData($query); + $title = "Total"; + + if(count($dompoints) > 0 && count($dompoints[0]) > 0 && count($dompoints[1]) > 0) { + + + // If this is a cp plot, use player names as label. Otherwise simply teamname + if(strlen($cp) > 0) { + $labels = renderNamesCP($tempTableName,$cp); + $title = $cp; + } else { + $labels = generateTeamLabels(); + + } + + // Deriv Dom points over time per team + mysql_query("INSERT INTO uts_chartdata (mid,chartid,title,data,labels) VALUES (".$matchid.", ".RENDERER_CHART_DOM_SCOREDERIV.", + '".mysql_real_escape_string($title)."', + '".mysql_real_escape_string(gzencode(serialize(array($derivdompoints,$dompoints))))."', + '".mysql_real_escape_string(gzencode(serialize($labels)))."')") or die(mysql_error()); + + } +} + +/* +Helper function to parse the data for the main renderData +*/ +function parseData($query) { + $q_result = mysql_query($query) or die(mysql_error()); + + $smallcounter = 1/3; + $counter = 1; + $prevpoints = array(0,0); + $prevtime = 0; + + $run = 0; + $numRows = mysql_num_rows($q_result); + + while($data = mysql_fetch_array($q_result)) { + $r_time = round($data[0],2); + if($run==($numRows-1)) + $r_time = $prevtime; + + $points[0] = round($data[1],0); + $points[1] = round($data[2],0); + + // Prep data for dom points over time + // Only save the data each $smallcounter interval, to optimize rendering time + if($r_time >= $smallcounter || $run==($numRows-1)) { + + for($i=0;$i<2;$i++) { + $dompoints[$i][] = array($r_time,$points[$i]); + } + + $smallcounter+=1/3; + } + + // Prep data for net change over time + // Only save the data each integer interval, since we want the value per minute + if($r_time >= $counter || ($run==($numRows-1) && ($counter-$r_time)<(1/3))) { + + // Iterate over teams to get points last min + for($i=0;$i<2;$i++) { + $derivypre[$i] = $points[$i]-$prevpoints[$i]; + } + + // Iterate over teams again to determine net points + for($i=0;$i<2;$i++) { + $derivypost[$i] = $derivypre[$i]-$derivypre[1-$i]; + $derivdompoints[$i][] = $derivypost[$i]>0 ? $derivypost[$i] : 0; + } + + $prevpoints = $points; + + $counter++; + } + + $prevtime = $r_time; + $run++; + } + + + return array($dompoints,$derivdompoints); +} + +/* +Render the names of players that played the cp +*/ +function renderNamesCP($tempTableName,$cp) { + $labels = array(); + + $q_namesPerCP = mysql_query("SELECT playername, COUNT( playername ) AS cplayer, MAX( teamid ) AS tid, AVG( realTimeEnd ) AS ati FROM $tempTableName WHERE cp = '".mysql_real_escape_string($cp)."' GROUP BY playername ORDER BY tid,ati") or die(mysql_error()); + + while($r_namesPerCP = mysql_fetch_array($q_namesPerCP)) { + + $playerName = substr($r_namesPerCP[0],0,18); + $timesTouched = $r_namesPerCP[1]; + $teamid = $r_namesPerCP[2]; + $avgTime = $r_namesPerCP[3]; + + // Only plot the playername if he touched the cp at least 60 times + if(isset($playerName) && !empty($playerName) && strlen($playerName)>0 && $timesTouched > 75) { + if(strlen($labels[$teamid])>0) + $labels[$teamid] .= " + "; + + $labels[$teamid] .= $playerName; + } + + } + + // Default value if empty + if(!isset($labels[0]) || !strlen($labels[0])>1) + $labels[0] = 'Red Team'; + if(!isset($labels[1]) || !strlen($labels[1])>1) + $labels[1] = 'Blue Team'; + + return $labels; +} + + +?>
\ No newline at end of file diff --git a/html/includes/renderer-general-import.php b/html/includes/renderer-general-import.php new file mode 100644 index 0000000..fbe62fc --- /dev/null +++ b/html/includes/renderer-general-import.php @@ -0,0 +1,168 @@ +<?php + +/* +Retrieve player names & player teams +Pretty much utstats code re-used +@return $playernames, $playerteams (arrays based on pid) +*/ +function getPlayerTeam() { + global $matchid; + + $playernames = array(); + $playerteams = array(); + + $uid = mysql_real_escape_string($uid); + + // Get List of Player IDs and Process What They Have Done + $sql_player = "SELECT p.playerid,p.team,i.name FROM uts_player p JOIN uts_pinfo i ON p.pid = i.id WHERE p.matchid=$matchid"; + $q_player = mysql_query($sql_player) or die(mysql_error()); + + while ($r_player = mysql_fetch_array($q_player)) { + $playerid = $r_player['playerid']; + $playername = $r_player['name']; + $playerteam = $r_player['team']; + + $playernames[$playerid] = $playername; + $playerteams[$playerid] = $playerteam; + } + + $r_team = small_query("SELECT COUNT(DISTINCT team) FROM uts_player WHERE matchid=$matchid"); + $teams = $r_team[0]; + + return array($playernames,$playerteams,$teams); + +} + +/* +Get time game starts, game ends, and ratio compared to real time +@return $time_gamestart, $time_gameend, $time_ratio_correction (difference in ut time & real time, typically 110%) +*/ +function getGameStartEndRatio($uid) { + + // gather game start & end time + $q_logdom = mysql_query("SELECT col0 FROM uts_temp_$uid WHERE col1='game_start' OR col1='game_end' ORDER BY id ASC")or die(mysql_error()); + + $time_gamestart = mysql_result($q_logdom,0); + $time_gameend = mysql_result($q_logdom,1); + //$time_ratio_correction = ($time_gameend-$time_gamestart)/1200; + $time_ratio_correction = TIMERATIO; // based on hardcore mode + + return array($time_gamestart, $time_gameend, $time_ratio_correction); +} + +function generateTeamLabels() { + + return array('Red Team', 'Blue Team', 'Green Team', 'Gold Team'); +} + + +/* +Generate the chart with pickups +*/ +function renderDataPickups($uid,$team=true,$playerRedWins=true,$topFraggers) { + global $matchid; + global $renderer_color; + global $renderer_folder; + global $renderer_width; + global $renderer_heigth; + + $uid = mysql_real_escape_string($uid); + + $q_pickups = mysql_query("SELECT SUM(pu_belt), SUM(pu_keg), SUM(pu_pads), SUM(pu_armour), SUM(pu_amp) FROM uts_player as p WHERE matchid = ".mysql_real_escape_string($matchid)." GROUP BY team") or die(mysql_error()); + + while($r_pickups = mysql_fetch_row($q_pickups)) { + $preData[] = $r_pickups; + } + + $pickupitems = array('belt','keg','pads','armour','amp'); + $itemsPickedUp = array(); + + if($team || $playerRedWins) { + $teamOneId = 0; + $teamTwoId = 1; + } else { + $teamOneId = 1; + $teamTwoId = 0; + } + + // Process data to convert these to percentages + // Normal numbers don't plot nicely (fe. pads getting much higher pickups due to lower spawn time + for($i=0;$i<count($pickupitems);$i++) { + + if($preData[0][$i]>0) { + $percValue = round($preData[0][$i]/($preData[0][$i]+$preData[1][$i])*100,0); + + $data[$teamOneId][] = $percValue; + $data[$teamTwoId][] = 100-$percValue; + $itemsPickedUp[] = $pickupitems[$i]; + + } else if($preData[1][$i]>0) { + $data[$teamOneId][] = 0; + $data[$teamTwoId][] = 100; + $itemsPickedUp[] = $pickupitems[$i]; + } + + } + + if(count($itemsPickedUp)>2) { + if($team) + $labels = generateTeamLabels(); + else + $labels = generateLabelsFraggers($topFraggers); + + $charttype = $team?RENDERER_CHART_ITEMS_TEAMPICKUPS:RENDERER_CHART_ITEMS_PLAYERPICKUPS; + + // Save team score over team for teams + mysql_query("INSERT INTO uts_chartdata (mid,chartid,data,labels,categories) VALUES (".$matchid.", ".$charttype.", + '".mysql_real_escape_string(gzencode(serialize($data)))."', + '".mysql_real_escape_string(gzencode(serialize($labels)))."', + '".mysql_real_escape_string(gzencode(serialize($itemsPickedUp)))."')") or die(mysql_error()); + } +} + +/** +Generate labels for the fraggers +*/ +function generateLabelsFraggers($topFraggers) { + global $playernames; + + $labels = array(); + + foreach($topFraggers as $fragger) { + $labels[] = substr($playernames[$fragger],0,18); + } + + return $labels; +} + +/* +Helper function to sort array on key, based on solution from the interwebs +*/ +function array_sort($array, $on) { + $new_array = array(); + $sortable_array = array(); + + if (count($array) > 0) { + foreach ($array as $k => $v) { + if (is_array($v)) { + foreach ($v as $k2 => $v2) { + if ($k2 == $on) { + $sortable_array[$k] = $v2; + } + } + } else { + $sortable_array[$k] = $v; + } + } + + asort($sortable_array); + + foreach ($sortable_array as $k => $v) { + $new_array[$k] = $array[$k]; + } + } + + return $new_array; +} + +?> diff --git a/html/includes/renderer-general-output.php b/html/includes/renderer-general-output.php new file mode 100644 index 0000000..462e7bb --- /dev/null +++ b/html/includes/renderer-general-output.php @@ -0,0 +1,195 @@ +<?php +// Fix for UTF-8 required for local use +require_once('encoding.php'); +use \ForceUTF8\Encoding; + +function renderChart($target,$layout,$color,$title,$data,$labels,$categories,$width,$height,$charttype) { + + // Add categories if required + if(!empty($categories) && count($categories)>0) { + $categoriesString = "categories: ".json_encode($categories).", "; + $categoriesStringPos = strpos($layout,"{",strpos($layout,"xAxis"))+1; + if($categoriesStringPos !== false) + $layout = substr_replace($layout,$categoriesString,$categoriesStringPos,0); + } + + // Replace title if required + if(!empty($title) && strlen($title)>0) { + $titleStringPosStart = strpos($layout,":",strpos($layout,"text"))+1; + $titleStringPosEnd = strpos($layout,"}",strpos($layout,"text"))-1; + + if($categoriesStringPos !== false) + $layout = substr_replace($layout,json_encode($title),$titleStringPosStart,$titleStringPosEnd-$titleStringPosStart); + } + + $chart = " + <div id='$target' style='width: ".$width."px; height: ".$height."px; margin: 0em'></div> + <script type='text/javascript'> + + var chart = new Highcharts.Chart({ + chart: { + renderTo: '$target' "; + + if($charttype == RENDERER_CHARTTYPE_RADAR) + $chart .= ", polar: true, type: 'area'"; + + // Encoding::toUTF8() required for $data & $labels in offline use + $chart .= "}, ".Encoding::toUTF8($layout)." ,series: [ + ".jsonEncodeSeries(Encoding::toUTF8($data),Encoding::toUTF8($labels),$color,$charttype)." + ] + }); + </script>"; + + return $chart; +} + +function jsonEncodeMultiSeries($data,$labels,$color,$charttype) { + $countSeries = count($data); + + for($i=0;$i<$countSeries;$i++) { + + // Reset vars per serie + $layoutSerie = ''; + $colorTransparant = false; + $charttypeSingle = $charttype; + + // Check if this is the last one + if($i == ($countSeries-1)) { + + if($charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) + $charttypeSingle = RENDERER_CHARTTYPE_LINESTEP; + + } else { + + if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) { + $colorTransparant = true; + $charttypeSingle = RENDERER_CHARTTYPE_COLUMN; + + + $layoutSerie .= " + showInLegend: false, + yAxis: 1, + "; + } + + } + + $jsonData .= jsonEncodeSingleSerie($data[$i],$labels,$color,$charttypeSingle,$layoutSerie,$colorTransparant); + + if($i<($countSeries-1)) + $jsonData .= ","; + + } + + return $jsonData; +} + + + +function jsonEncodeSingleSerie($data,$labels,$color,$charttype,$layoutSerie,$colorTransparant=false) { + global $renderer_color; + global $renderer_color_transparancy; + + $countSeries = count($data); + $jsonData = ""; + + if($countSeries>0) { + for($i=0;$i<$countSeries;$i++) { + + $colorSerie = $renderer_color[$color][$i][0]; + if($colorTransparant) + $colorSerie = "rgba(".hex2rgb($colorSerie).",".$renderer_color_transparancy.")"; + + $jsonData .= " { "; + + if($charttype == RENDERER_CHARTTYPE_COLUMN) + $jsonData .= " type: 'column',"; + + if($charttype == RENDERER_CHARTTYPE_BAR) + $jsonData .= " type: 'bar',"; + + if($charttype == RENDERER_CHARTTYPE_LINESTEP) + $jsonData .= " step: 'left',"; + + $jsonData .= $layoutSerie; + + $jsonData .= " + color: '".$colorSerie."', + name: ".json_encode($labels[$i]).", + data: ".json_encode($data[$i])." }"; + + if($i<($countSeries-1)) + $jsonData .= ","; + + } + + } else if(countSeries==1) { + $jsonData .= "data: { ".$layoutSerie.json_encode($data[0])." }"; + } + + return $jsonData; +} + +function jsonEncodeRadarSerie($data,$labels,$color,$charttype) { + return jsonEncodeSingleSerie($data,$labels,$color,$charttype,'',true); +} + + +function jsonEncodeSeries($data,$labels,$color,$charttype) { + + if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) + return jsonEncodeMultiSeries($data,$labels,$color,$charttype); + + else + return jsonEncodeSingleSerie($data,$labels,$color,$charttype); +} + + +/** +Functions to render block in which the graphs are shown +*/ +function renderHeaderBlock($category) { + + return ' + <table class="box" border="0" cellpadding="0" cellspacing="0"> + <thead> + <tr> + <td class="heading" align="center" colspan="2" style="min-width: 300px"><a href="#_" onclick="toggle_visibility(\''.$category.'\');">'.$category.'</a></td> + </tr> + </thead> + <tbody id="'.$category.'"> + <tr> + <td> + '; +} + +function renderFootBlock() { + return ' + </td> + </tr> + </tbody> + </table><br> + '; +} + +/* +Helper function to get rgb value for hex color, based on solution from the interwebs +*/ +function hex2rgb($hex) { + $hex = str_replace("#", "", $hex); + + if(strlen($hex) == 3) { + $r = hexdec(substr($hex,0,1).substr($hex,0,1)); + $g = hexdec(substr($hex,1,1).substr($hex,1,1)); + $b = hexdec(substr($hex,2,1).substr($hex,2,1)); + } else { + $r = hexdec(substr($hex,0,2)); + $g = hexdec(substr($hex,2,2)); + $b = hexdec(substr($hex,4,2)); + } + $rgb = array($r, $g, $b); + return implode(",", $rgb); // returns the rgb values separated by commas + +} + +?>
\ No newline at end of file diff --git a/html/includes/teamstats.php b/html/includes/teamstats.php index 66e53ab..fd06ead 100755 --- a/html/includes/teamstats.php +++ b/html/includes/teamstats.php @@ -109,17 +109,17 @@ function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'ga } else {
echo '<td nowrap class="darkhuman" align="left"><span style="text-decoration: line-through;">'.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).'</span></td>';
}
- echo '<td class="'.$class.'" align="center">'.GetMinutes($r_players[gametime]).'</td>';
- echo '<td class="'.$class.'" align="center">'.$r_players[gamescore].'</td>';
+ echo '<td class="'.$class.'" align="center">'.GetMinutes($r_players['gametime']/TIMERATIO).'</td>';
+ echo '<td class="'.$class.'" align="center">'.$r_players['gamescore'].'</td>';
if ($extra) echo '<td class="'.$class.'" align="center">'.$r_players[$extra].'</td>';
- echo '<td class="'.$class.'" align="center">'.$r_players[frags].'</td>';
+ echo '<td class="'.$class.'" align="center">'.$r_players['frags'].'</td>';
echo '<td class="'.$class.'" align="center">'.$kills.'</td>';
- echo '<td class="'.$class.'" align="center">'.$r_players[deaths].'</td>';
- echo '<td class="'.$class.'" align="center">'.$r_players[suicides].'</td>';
+ echo '<td class="'.$class.'" align="center">'.$r_players['deaths'].'</td>';
+ echo '<td class="'.$class.'" align="center">'.$r_players['suicides'].'</td>';
- if ($teams) echo '<td class="'.$class.'" align="center">'.$r_players[teamkills].'</td>';
+ if ($teams) echo '<td class="'.$class.'" align="center">'.$r_players['teamkills'].'</td>';
echo '<td class="'.$class.'" align="center">'.$eff.'</td>';
echo '<td class="'.$class.'" align="center">'.$acc.'</td>';
diff --git a/html/jpgraph/.htaccess b/html/jpgraph/.htaccess new file mode 100644 index 0000000..438cccd --- /dev/null +++ b/html/jpgraph/.htaccess @@ -0,0 +1,10 @@ +#------------------------------------------------------------------------------
+# Server root folder www .htaccess
+# This file provides server security limiting access to the localhost only.
+# Comment next four lines to deactivate. (Allows external access)
+#------------------------------------------------------------------------------
+
+Order Deny,Allow
+Deny from all
+Allow from 127.0.0.1
+Allow from ::1
diff --git a/html/jpgraph/d2utmpFU7H53 b/html/jpgraph/d2utmpFU7H53 new file mode 100644 index 0000000..ee01669 --- /dev/null +++ b/html/jpgraph/d2utmpFU7H53 @@ -0,0 +1,1190 @@ +<?php +/*======================================================================= + // File: JPGRAPH_BAR.PHP + // Description: Bar plot extension for JpGraph + // Created: 2001-01-08 + // Ver: $Id: jpgraph_bar.php 1905 2009-10-06 18:00:21Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +require_once('jpgraph_plotband.php'); + +// Pattern for Bars +DEFINE('PATTERN_DIAG1',1); +DEFINE('PATTERN_DIAG2',2); +DEFINE('PATTERN_DIAG3',3); +DEFINE('PATTERN_DIAG4',4); +DEFINE('PATTERN_CROSS1',5); +DEFINE('PATTERN_CROSS2',6); +DEFINE('PATTERN_CROSS3',7); +DEFINE('PATTERN_CROSS4',8); +DEFINE('PATTERN_STRIPE1',9); +DEFINE('PATTERN_STRIPE2',10); + +//=================================================== +// CLASS BarPlot +// Description: Main code to produce a bar plot +//=================================================== +class BarPlot extends Plot { + public $fill=false,$fill_color="lightblue"; // Default is to fill with light blue + public $iPattern=-1,$iPatternDensity=80,$iPatternColor='black'; + public $valuepos='top'; + public $grad=false,$grad_style=1; + public $grad_fromcolor=array(50,50,200),$grad_tocolor=array(255,255,255); + public $ymin=0; + protected $width=0.4; // in percent of major ticks + protected $abswidth=-1; // Width in absolute pixels + protected $ybase=0; // Bars start at 0 + protected $align="center"; + protected $bar_shadow=false; + protected $bar_shadow_color="black"; + protected $bar_shadow_hsize=3,$bar_shadow_vsize=3; + protected $bar_3d=false; + protected $bar_3d_hsize=3,$bar_3d_vsize=3; + + //--------------- + // CONSTRUCTOR + function __construct($datay,$datax=false) { + parent::__construct($datay,$datax); + ++$this->numpoints; + } + + //--------------- + // PUBLIC METHODS + + // Set a drop shadow for the bar (or rather an "up-right" shadow) + function SetShadow($aColor="black",$aHSize=3,$aVSize=3,$aShow=true) { + $this->bar_shadow=$aShow; + $this->bar_shadow_color=$aColor; + $this->bar_shadow_vsize=$aVSize; + $this->bar_shadow_hsize=$aHSize; + + // Adjust the value margin to compensate for shadow + $this->value->margin += $aVSize; + } + + function Set3D($aHSize=3,$aVSize=3,$aShow=true) { + $this->bar_3d=$aShow; + $this->bar_3d_vsize=$aVSize; + $this->bar_3d_hsize=$aHSize; + + $this->value->margin += $aVSize; + } + + // DEPRECATED use SetYBase instead + function SetYMin($aYStartValue) { + //die("JpGraph Error: Deprecated function SetYMin. Use SetYBase() instead."); + $this->ybase=$aYStartValue; + } + + // Specify the base value for the bars + function SetYBase($aYStartValue) { + $this->ybase=$aYStartValue; + } + + // The method will take the specified pattern anre + // return a pattern index that corresponds to the original + // patterm being rotated 90 degreees. This is needed when plottin + // Horizontal bars + function RotatePattern($aPat,$aRotate=true) { + $rotate = array(1 => 2, 2 => 1, 3 => 3, 4 => 5, 5 => 4, 6 => 6, 7 => 7, 8 => 8); + if( $aRotate ) { + return $rotate[$aPat]; + } + else { + return $aPat; + } + } + + function Legend($graph) { + if( $this->grad && $this->legend!="" && !$this->fill ) { + $color=array($this->grad_fromcolor,$this->grad_tocolor); + // In order to differentiate between gradients and cooors specified as an RGB triple + $graph->legend->Add($this->legend,$color,"",-$this->grad_style, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + elseif( $this->legend!="" && ($this->iPattern > -1 || is_array($this->iPattern)) ) { + if( is_array($this->iPattern) ) { + $p1 = $this->RotatePattern( $this->iPattern[0], $graph->img->a == 90 ); + $p2 = $this->iPatternColor[0]; + $p3 = $this->iPatternDensity[0]; + } + else { + $p1 = $this->RotatePattern( $this->iPattern, $graph->img->a == 90 ); + $p2 = $this->iPatternColor; + $p3 = $this->iPatternDensity; + } + if( $p3 < 90 ) $p3 += 5; + $color = array($p1,$p2,$p3,$this->fill_color); + // A kludge: Too mark that we add a pattern we use a type value of < 100 + $graph->legend->Add($this->legend,$color,"",-101, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + elseif( $this->fill_color && $this->legend!="" ) { + if( is_array($this->fill_color) ) { + $graph->legend->Add($this->legend,$this->fill_color[0],"",0, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + else { + $graph->legend->Add($this->legend,$this->fill_color,"",0, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + } + } + + // Gets called before any axis are stroked + function PreStrokeAdjust($graph) { + parent::PreStrokeAdjust($graph); + + // If we are using a log Y-scale we want the base to be at the + // minimum Y-value unless the user have specifically set some other + // value than the default. + if( substr($graph->axtype,-3,3)=="log" && $this->ybase==0 ) + $this->ybase = $graph->yaxis->scale->GetMinVal(); + + // For a "text" X-axis scale we will adjust the + // display of the bars a little bit. + if( substr($graph->axtype,0,3)=="tex" ) { + // Position the ticks between the bars + $graph->xaxis->scale->ticks->SetXLabelOffset(0.5,0); + + // Center the bars + if( $this->abswidth > -1 ) { + $graph->SetTextScaleAbsCenterOff($this->abswidth); + } + else { + if( $this->align == "center" ) + $graph->SetTextScaleOff(0.5-$this->width/2); + elseif( $this->align == "right" ) + $graph->SetTextScaleOff(1-$this->width); + } + } + elseif( ($this instanceof AccBarPlot) || ($this instanceof GroupBarPlot) ) { + // We only set an absolute width for linear and int scale + // for text scale the width will be set to a fraction of + // the majstep width. + if( $this->abswidth == -1 ) { + // Not set + // set width to a visuable sensible default + $this->abswidth = $graph->img->plotwidth/(2*$this->numpoints); + } + } + } + + function Min() { + $m = parent::Min(); + if( $m[1] >= $this->ybase ) $m[1] = $this->ybase; + return $m; + } + + function Max() { + $m = parent::Max(); + if( $m[1] <= $this->ybase ) $m[1] = $this->ybase; + return $m; + } + + // Specify width as fractions of the major stepo size + function SetWidth($aWidth) { + if( $aWidth > 1 ) { + // Interpret this as absolute width + $this->abswidth=$aWidth; + } + else { + $this->width=$aWidth; + } + } + + // Specify width in absolute pixels. If specified this + // overrides SetWidth() + function SetAbsWidth($aWidth) { + $this->abswidth=$aWidth; + } + + function SetAlign($aAlign) { + $this->align=$aAlign; + } + + function SetNoFill() { + $this->grad = false; + $this->fill_color=false; + $this->fill=false; + } + + function SetFillColor($aColor) { + // Do an extra error check if the color is specified as an RGB array triple + // In that case convert it to a hex string since it will otherwise be + // interpretated as an array of colors for each individual bar. + + $aColor = RGB::tryHexConversion($aColor); + $this->fill = true ; + $this->fill_color=$aColor; + + } + + function SetFillGradient($aFromColor,$aToColor=null,$aStyle=null) { + $this->grad = true; + $this->grad_fromcolor = $aFromColor; + $this->grad_tocolor = $aToColor; + $this->grad_style = $aStyle; + } + + function SetValuePos($aPos) { + $this->valuepos = $aPos; + } + + function SetPattern($aPattern, $aColor='black'){ + if( is_array($aPattern) ) { + $n = count($aPattern); + $this->iPattern = array(); + $this->iPatternDensity = array(); + if( is_array($aColor) ) { + $this->iPatternColor = array(); + if( count($aColor) != $n ) { + JpGraphError::RaiseL(2001);//('NUmber of colors is not the same as the number of patterns in BarPlot::SetPattern()'); + } + } + else { + $this->iPatternColor = $aColor; + } + for( $i=0; $i < $n; ++$i ) { + $this->_SetPatternHelper($aPattern[$i], $this->iPattern[$i], $this->iPatternDensity[$i]); + if( is_array($aColor) ) { + $this->iPatternColor[$i] = $aColor[$i]; + } + } + } + else { + $this->_SetPatternHelper($aPattern, $this->iPattern, $this->iPatternDensity); + $this->iPatternColor = $aColor; + } + } + + function _SetPatternHelper($aPattern, &$aPatternValue, &$aDensity){ + switch( $aPattern ) { + case PATTERN_DIAG1: + $aPatternValue= 1; + $aDensity = 92; + break; + case PATTERN_DIAG2: + $aPatternValue= 1; + $aDensity = 78; + break; + case PATTERN_DIAG3: + $aPatternValue= 2; + $aDensity = 92; + break; + case PATTERN_DIAG4: + $aPatternValue= 2; + $aDensity = 78; + break; + case PATTERN_CROSS1: + $aPatternValue= 8; + $aDensity = 90; + break; + case PATTERN_CROSS2: + $aPatternValue= 8; + $aDensity = 78; + break; + case PATTERN_CROSS3: + $aPatternValue= 8; + $aDensity = 65; + break; + case PATTERN_CROSS4: + $aPatternValue= 7; + $aDensity = 90; + break; + case PATTERN_STRIPE1: + $aPatternValue= 5; + $aDensity = 94; + break; + case PATTERN_STRIPE2: + $aPatternValue= 5; + $aDensity = 85; + break; + default: + JpGraphError::RaiseL(2002); + //('Unknown pattern specified in call to BarPlot::SetPattern()'); + } + } + + function Stroke($img,$xscale,$yscale) { + + $numpoints = count($this->coords[0]); + if( isset($this->coords[1]) ) { + if( count($this->coords[1])!=$numpoints ) { + JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints); + //"Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])."Number of Y-points:$numpoints"); + } + else { + $exist_x = true; + } + } + else { + $exist_x = false; + } + + + $numbars=count($this->coords[0]); + + // Use GetMinVal() instead of scale[0] directly since in the case + // of log scale we get a correct value. Log scales will have negative + // values for values < 1 while still not representing negative numbers. + if( $yscale->GetMinVal() >= 0 ) + $zp=$yscale->scale_abs[0]; + else { + $zp=$yscale->Translate(0); + } + + if( $this->abswidth > -1 ) { + $abswidth=$this->abswidth; + } + else { + $abswidth=round($this->width*$xscale->scale_factor,0); + } + + // Count pontetial pattern array to avoid doing the count for each iteration + if( is_array($this->iPattern) ) { + $np = count($this->iPattern); + } + + $grad = null; + for($i=0; $i < $numbars; ++$i) { + + // If value is NULL, or 0 then don't draw a bar at all + if ($this->coords[0][$i] === null || $this->coords[0][$i] === '' ) + continue; + + if( $exist_x ) { + $x=$this->coords[1][$i]; + } + else { + $x=$i; + } + + $x=$xscale->Translate($x); + + // Comment Note: This confuses the positioning when using acc together with + // grouped bars. Workaround for fixing #191 + /* + if( !$xscale->textscale ) { + if($this->align=="center") + $x -= $abswidth/2; + elseif($this->align=="right") + $x -= $abswidth; + } + */ + // Stroke fill color and fill gradient + $pts=array( + $x,$zp, + $x,$yscale->Translate($this->coords[0][$i]), + $x+$abswidth,$yscale->Translate($this->coords[0][$i]), + $x+$abswidth,$zp); + if( $this->grad ) { + if( $grad === null ) { + $grad = new Gradient($img); + } + if( is_array($this->grad_fromcolor) ) { + // The first argument (grad_fromcolor) can be either an array or a single color. If it is an array + // then we have two choices. It can either a) be a single color specified as an RGB triple or it can be + // an array to specify both (from, to style) for each individual bar. The way to know the difference is + // to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB + // triple. + $ng = count($this->grad_fromcolor); + if( $ng === 3 ) { + if( is_numeric($this->grad_fromcolor[0]) && $this->grad_fromcolor[0] > 0 && $this->grad_fromcolor[0] < 256 ) { + // RGB Triple + $fromcolor = $this->grad_fromcolor; + $tocolor = $this->grad_tocolor; + $style = $this->grad_style; + } + else { + $fromcolor = $this->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->grad_fromcolor[$i % $ng][1]; + $style = $this->grad_fromcolor[$i % $ng][2]; + } + } + else { + $fromcolor = $this->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->grad_fromcolor[$i % $ng][1]; + $style = $this->grad_fromcolor[$i % $ng][2]; + } + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $fromcolor,$tocolor,$style); + } + else { + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $this->grad_fromcolor,$this->grad_tocolor,$this->grad_style); + } + } + elseif( !empty($this->fill_color) ) { + if(is_array($this->fill_color)) { + $img->PushColor($this->fill_color[$i % count($this->fill_color)]); + } else { + $img->PushColor($this->fill_color); + } + $img->FilledPolygon($pts); + $img->PopColor(); + } + +/////////////////////////kokorahen rectangle polygon////////////////////// + + // Remember value of this bar + $val=$this->coords[0][$i]; + + if( !empty($val) && !is_numeric($val) ) { + JpGraphError::RaiseL(2004,$i,$val); + //'All values for a barplot must be numeric. You have specified value['.$i.'] == \''.$val.'\''); + } + + // Determine the shadow + if( $this->bar_shadow && $val != 0) { + + $ssh = $this->bar_shadow_hsize; + $ssv = $this->bar_shadow_vsize; + // Create points to create a "upper-right" shadow + if( $val > 0 ) { + $sp[0]=$pts[6]; $sp[1]=$pts[7]; + $sp[2]=$pts[4]; $sp[3]=$pts[5]; + $sp[4]=$pts[2]; $sp[5]=$pts[3]; + $sp[6]=$pts[2]+$ssh; $sp[7]=$pts[3]-$ssv; + $sp[8]=$pts[4]+$ssh; $sp[9]=$pts[5]-$ssv; + $sp[10]=$pts[6]+$ssh; $sp[11]=$pts[7]-$ssv; + } + elseif( $val < 0 ) { + $sp[0]=$pts[4]; $sp[1]=$pts[5]; + $sp[2]=$pts[6]; $sp[3]=$pts[7]; + $sp[4]=$pts[0]; $sp[5]=$pts[1]; + $sp[6]=$pts[0]+$ssh; $sp[7]=$pts[1]-$ssv; + $sp[8]=$pts[6]+$ssh; $sp[9]=$pts[7]-$ssv; + $sp[10]=$pts[4]+$ssh; $sp[11]=$pts[5]-$ssv; + } + if( is_array($this->bar_shadow_color) ) { + $numcolors = count($this->bar_shadow_color); + if( $numcolors == 0 ) { + JpGraphError::RaiseL(2005);//('You have specified an empty array for shadow colors in the bar plot.'); + } + $img->PushColor($this->bar_shadow_color[$i % $numcolors]); + } + else { + $img->PushColor($this->bar_shadow_color); + } + $img->FilledPolygon($sp); + $img->PopColor(); + + } elseif( $this->bar_3d && $val != 0) { + // Determine the 3D + + $ssh = $this->bar_3d_hsize; + $ssv = $this->bar_3d_vsize; + + // Create points to create a "upper-right" shadow + if( $val > 0 ) { + $sp1[0]=$pts[6]; $sp1[1]=$pts[7]; + $sp1[2]=$pts[4]; $sp1[3]=$pts[5]; + $sp1[4]=$pts[4]+$ssh; $sp1[5]=$pts[5]-$ssv; + $sp1[6]=$pts[6]+$ssh; $sp1[7]=$pts[7]-$ssv; + + $sp2[0]=$pts[4]; $sp2[1]=$pts[5]; + $sp2[2]=$pts[2]; $sp2[3]=$pts[3]; + $sp2[4]=$pts[2]+$ssh; $sp2[5]=$pts[3]-$ssv; + $sp2[6]=$pts[4]+$ssh; $sp2[7]=$pts[5]-$ssv; + + } + elseif( $val < 0 ) { + $sp1[0]=$pts[4]; $sp1[1]=$pts[5]; + $sp1[2]=$pts[6]; $sp1[3]=$pts[7]; + $sp1[4]=$pts[6]+$ssh; $sp1[5]=$pts[7]-$ssv; + $sp1[6]=$pts[4]+$ssh; $sp1[7]=$pts[5]-$ssv; + + $sp2[0]=$pts[6]; $sp2[1]=$pts[7]; + $sp2[2]=$pts[0]; $sp2[3]=$pts[1]; + $sp2[4]=$pts[0]+$ssh; $sp2[5]=$pts[1]-$ssv; + $sp2[6]=$pts[6]+$ssh; $sp2[7]=$pts[7]-$ssv; + } + + $base_color = $this->fill_color; + + $img->PushColor($base_color . ':0.7'); + $img->FilledPolygon($sp1); + $img->PopColor(); + + $img->PushColor($base_color . ':1.1'); + $img->FilledPolygon($sp2); + $img->PopColor(); + } + + // Stroke the pattern + if( is_array($this->iPattern) ) { + $f = new RectPatternFactory(); + if( is_array($this->iPatternColor) ) { + $pcolor = $this->iPatternColor[$i % $np]; + } + else { + $pcolor = $this->iPatternColor; + } + $prect = $f->Create($this->iPattern[$i % $np],$pcolor,1); + $prect->SetDensity($this->iPatternDensity[$i % $np]); + + if( $val < 0 ) { + $rx = $pts[0]; + $ry = $pts[1]; + } + else { + $rx = $pts[2]; + $ry = $pts[3]; + } + $width = abs($pts[4]-$pts[0])+1; + $height = abs($pts[1]-$pts[3])+1; + $prect->SetPos(new Rectangle($rx,$ry,$width,$height)); + $prect->Stroke($img); + } + else { + if( $this->iPattern > -1 ) { + $f = new RectPatternFactory(); + $prect = $f->Create($this->iPattern,$this->iPatternColor,1); + $prect->SetDensity($this->iPatternDensity); + if( $val < 0 ) { + $rx = $pts[0]; + $ry = $pts[1]; + } + else { + $rx = $pts[2]; + $ry = $pts[3]; + } + $width = abs($pts[4]-$pts[0])+1; + $height = abs($pts[1]-$pts[3])+1; + $prect->SetPos(new Rectangle($rx,$ry,$width,$height)); + $prect->Stroke($img); + } + } + + // Stroke the outline of the bar + if( is_array($this->color) ) { + $img->SetColor($this->color[$i % count($this->color)]); + } + else { + $img->SetColor($this->color); + } + + $pts[] = $pts[0]; + $pts[] = $pts[1]; + + if( $this->weight > 0 ) { + $img->SetLineWeight($this->weight); + $img->Polygon($pts); + } + + // Determine how to best position the values of the individual bars + $x=$pts[2]+($pts[4]-$pts[2])/2; + $this->value->SetMargin(5); + + if( $this->valuepos=='top' ) { + $y=$pts[3]; + if( $img->a === 90 ) { + if( $val < 0 ) { + $this->value->SetAlign('right','center'); + } + else { + $this->value->SetAlign('left','center'); + } + + } + else { + if( $val < 0 ) { + $this->value->SetMargin(-5); + $y=$pts[1]; + $this->value->SetAlign('center','bottom'); + } + else { + $this->value->SetAlign('center','bottom'); + } + + } + $this->value->Stroke($img,$val,$x,$y); + } + elseif( $this->valuepos=='max' ) { + $y=$pts[3]; + if( $img->a === 90 ) { + if( $val < 0 ) + $this->value->SetAlign('left','center'); + else + $this->value->SetAlign('right','center'); + } + else { + if( $val < 0 ) { + $this->value->SetAlign('center','bottom'); + } + else { + $this->value->SetAlign('center','top'); + } + } + $this->value->SetMargin(-5); + $this->value->Stroke($img,$val,$x,$y); + } + elseif( $this->valuepos=='center' ) { + $y = ($pts[3] + $pts[1])/2; + $this->value->SetAlign('center','center'); + $this->value->SetMargin(0); + $this->value->Stroke($img,$val,$x,$y); + } + elseif( $this->valuepos=='bottom' || $this->valuepos=='min' ) { + $y=$pts[1]; + if( $img->a === 90 ) { + if( $val < 0 ) + $this->value->SetAlign('right','center'); + else + $this->value->SetAlign('left','center'); + } + $this->value->SetMargin(3); + $this->value->Stroke($img,$val,$x,$y); + } + else { + JpGraphError::RaiseL(2006,$this->valuepos); + //'Unknown position for values on bars :'.$this->valuepos); + } + // Create the client side image map + $rpts = $img->ArrRotate($pts); + $csimcoord=round($rpts[0]).", ".round($rpts[1]); + for( $j=1; $j < 4; ++$j){ + $csimcoord .= ", ".round($rpts[2*$j]).", ".round($rpts[2*$j+1]); + } + if( !empty($this->csimtargets[$i]) ) { + $this->csimareas .= '<area shape="poly" coords="'.$csimcoord.'" '; + $this->csimareas .= " href=\"".htmlentities($this->csimtargets[$i])."\""; + + if( !empty($this->csimwintargets[$i]) ) { + $this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" "; + } + + $sval=''; + if( !empty($this->csimalts[$i]) ) { + $sval=sprintf($this->csimalts[$i],$this->coords[0][$i]); + $this->csimareas .= " title=\"$sval\" alt=\"$sval\" "; + } + $this->csimareas .= " />\n"; + } + } + return true; + } +} // Class + +//=================================================== +// CLASS GroupBarPlot +// Description: Produce grouped bar plots +//=================================================== +class GroupBarPlot extends BarPlot { + public $plots; + private $nbrplots=0; + //--------------- + // CONSTRUCTOR + function GroupBarPlot($plots) { + $this->width=0.7; + $this->plots = $plots; + $this->nbrplots = count($plots); + if( $this->nbrplots < 1 ) { + JpGraphError::RaiseL(2007);//('Cannot create GroupBarPlot from empty plot array.'); + } + for($i=0; $i < $this->nbrplots; ++$i ) { + if( empty($this->plots[$i]) || !isset($this->plots[$i]) ) { + JpGraphError::RaiseL(2008,$i);//("Group bar plot element nbr $i is undefined or empty."); + } + } + $this->numpoints = $plots[0]->numpoints; + $this->width=0.7; + } + + //--------------- + // PUBLIC METHODS + function Legend($graph) { + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + $c = get_class($this->plots[$i]); + if( !($this->plots[$i] instanceof BarPlot) ) { + JpGraphError::RaiseL(2009,$c); + //('One of the objects submitted to GroupBar is not a BarPlot. Make sure that you create the Group Bar plot from an array of BarPlot or AccBarPlot objects. (Class = '.$c.')'); + } + $this->plots[$i]->DoLegend($graph); + } + } + + function Min() { + list($xmin,$ymin) = $this->plots[0]->Min(); + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + list($xm,$ym) = $this->plots[$i]->Min(); + $xmin = max($xmin,$xm); + $ymin = min($ymin,$ym); + } + return array($xmin,$ymin); + } + + function Max() { + list($xmax,$ymax) = $this->plots[0]->Max(); + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + list($xm,$ym) = $this->plots[$i]->Max(); + $xmax = max($xmax,$xm); + $ymax = max($ymax,$ym); + } + return array($xmax,$ymax); + } + + function GetCSIMareas() { + $n = count($this->plots); + $csimareas=''; + for($i=0; $i < $n; ++$i) { + $csimareas .= $this->plots[$i]->csimareas; + } + return $csimareas; + } + + // Stroke all the bars next to each other + function Stroke($img,$xscale,$yscale) { + $tmp=$xscale->off; + $n = count($this->plots); + $subwidth = $this->width/$this->nbrplots ; + + for( $i=0; $i < $n; ++$i ) { + $this->plots[$i]->ymin=$this->ybase; + $this->plots[$i]->SetWidth($subwidth); + + // If the client have used SetTextTickInterval() then + // major_step will be > 1 and the positioning will fail. + // If we assume it is always one the positioning will work + // fine with a text scale but this will not work with + // arbitrary linear scale + $xscale->off = $tmp+$i*round($xscale->scale_factor* $subwidth); + $this->plots[$i]->Stroke($img,$xscale,$yscale); + } + $xscale->off=$tmp; + } +} // Class + +//=================================================== +// CLASS AccBarPlot +// Description: Produce accumulated bar plots +//=================================================== +class AccBarPlot extends BarPlot { + public $plots=null; + private $nbrplots=0; + //--------------- + // CONSTRUCTOR + function __construct($plots) { + $this->plots = $plots; + $this->nbrplots = count($plots); + if( $this->nbrplots < 1 ) { + JpGraphError::RaiseL(2010);//('Cannot create AccBarPlot from empty plot array.'); + } + for($i=0; $i < $this->nbrplots; ++$i ) { + if( empty($this->plots[$i]) || !isset($this->plots[$i]) ) { + JpGraphError::RaiseL(2011,$i);//("Acc bar plot element nbr $i is undefined or empty."); + } + } + + // We can only allow individual plost which do not have specified X-positions + for($i=0; $i < $this->nbrplots; ++$i ) { + if( !empty($this->plots[$i]->coords[1]) ) { + JpGraphError::RaiseL(2015); + //'Individual bar plots in an AccBarPlot or GroupBarPlot can not have specified X-positions.'); + } + } + + // Use 0 weight by default which means that the individual bar + // weights will be used per part n the accumulated bar + $this->SetWeight(0); + + $this->numpoints = $plots[0]->numpoints; + $this->value = new DisplayValue(); + } + + //--------------- + // PUBLIC METHODS + function Legend($graph) { + $n = count($this->plots); + for( $i=$n-1; $i >= 0; --$i ) { + $c = get_class($this->plots[$i]); + if( !($this->plots[$i] instanceof BarPlot) ) { + JpGraphError::RaiseL(2012,$c); + //('One of the objects submitted to AccBar is not a BarPlot. Make sure that you create the AccBar plot from an array of BarPlot objects.(Class='.$c.')'); + } + $this->plots[$i]->DoLegend($graph); + } + } + + function Max() { + list($xmax) = $this->plots[0]->Max(); + $nmax=0; + for($i=0; $i < count($this->plots); ++$i) { + $n = count($this->plots[$i]->coords[0]); + $nmax = max($nmax,$n); + list($x) = $this->plots[$i]->Max(); + $xmax = max($xmax,$x); + } + for( $i = 0; $i < $nmax; $i++ ) { + // Get y-value for bar $i by adding the + // individual bars from all the plots added. + // It would be wrong to just add the + // individual plots max y-value since that + // would in most cases give to large y-value. + $y=0; + if( !isset($this->plots[0]->coords[0][$i]) ) { + JpGraphError::RaiseL(2014); + } + if( $this->plots[0]->coords[0][$i] > 0 ) + $y=$this->plots[0]->coords[0][$i]; + for( $j = 1; $j < $this->nbrplots; $j++ ) { + if( !isset($this->plots[$j]->coords[0][$i]) ) { + JpGraphError::RaiseL(2014); + } + if( $this->plots[$j]->coords[0][$i] > 0 ) + $y += $this->plots[$j]->coords[0][$i]; + } + $ymax[$i] = $y; + } + $ymax = max($ymax); + + // Bar always start at baseline + if( $ymax <= $this->ybase ) + $ymax = $this->ybase; + return array($xmax,$ymax); + } + + function Min() { + $nmax=0; + list($xmin,$ysetmin) = $this->plots[0]->Min(); + for($i=0; $i < count($this->plots); ++$i) { + $n = count($this->plots[$i]->coords[0]); + $nmax = max($nmax,$n); + list($x,$y) = $this->plots[$i]->Min(); + $xmin = Min($xmin,$x); + $ysetmin = Min($y,$ysetmin); + } + for( $i = 0; $i < $nmax; $i++ ) { + // Get y-value for bar $i by adding the + // individual bars from all the plots added. + // It would be wrong to just add the + // individual plots max y-value since that + // would in most cases give to large y-value. + $y=0; + if( $this->plots[0]->coords[0][$i] < 0 ) + $y=$this->plots[0]->coords[0][$i]; + for( $j = 1; $j < $this->nbrplots; $j++ ) { + if( $this->plots[$j]->coords[0][$i] < 0 ) + $y += $this->plots[ $j ]->coords[0][$i]; + } + $ymin[$i] = $y; + } + $ymin = Min($ysetmin,Min($ymin)); + // Bar always start at baseline + if( $ymin >= $this->ybase ) + $ymin = $this->ybase; + return array($xmin,$ymin); + } + + // Stroke acc bar plot + function Stroke($img,$xscale,$yscale) { + $pattern=NULL; + $img->SetLineWeight($this->weight); + $grad=null; + for($i=0; $i < $this->numpoints-1; $i++) { + $accy = 0; + $accy_neg = 0; + for($j=0; $j < $this->nbrplots; ++$j ) { + $img->SetColor($this->plots[$j]->color); + + if ( $this->plots[$j]->coords[0][$i] >= 0) { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy); + $accyt=$yscale->Translate($accy); + $accy+=$this->plots[$j]->coords[0][$i]; + } + else { + //if ( $this->plots[$j]->coords[0][$i] < 0 || $accy_neg < 0 ) { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy_neg); + $accyt=$yscale->Translate($accy_neg); + $accy_neg+=$this->plots[$j]->coords[0][$i]; + } + + $xt=$xscale->Translate($i); + + if( $this->abswidth > -1 ) { + $abswidth=$this->abswidth; + } + else { + $abswidth=round($this->width*$xscale->scale_factor,0); + } + + $pts=array($xt,$accyt,$xt,$yt,$xt+$abswidth,$yt,$xt+$abswidth,$accyt); + + if( $this->bar_shadow ) { + $ssh = $this->bar_shadow_hsize; + $ssv = $this->bar_shadow_vsize; + + // We must also differ if we are a positive or negative bar. + if( $j === 0 ) { + // This gets extra complicated since we have to + // see all plots to see if we are negative. It could + // for example be that all plots are 0 until the very + // last one. We therefore need to save the initial setup + // for both the negative and positive case + + // In case the final bar is positive + $sp[0]=$pts[6]+1; $sp[1]=$pts[7]; + $sp[2]=$pts[6]+$ssh; $sp[3]=$pts[7]-$ssv; + + // In case the final bar is negative + $nsp[0]=$pts[0]; $nsp[1]=$pts[1]; + $nsp[2]=$pts[0]+$ssh; $nsp[3]=$pts[1]-$ssv; + $nsp[4]=$pts[6]+$ssh; $nsp[5]=$pts[7]-$ssv; + $nsp[10]=$pts[6]+1; $nsp[11]=$pts[7]; + } + + if( $j === $this->nbrplots-1 ) { + // If this is the last plot of the bar and + // the total value is larger than 0 then we + // add the shadow. + if( is_array($this->bar_shadow_color) ) { + $numcolors = count($this->bar_shadow_color); + if( $numcolors == 0 ) { + JpGraphError::RaiseL(2013);//('You have specified an empty array for shadow colors in the bar plot.'); + } + $img->PushColor($this->bar_shadow_color[$i % $numcolors]); + } + else { + $img->PushColor($this->bar_shadow_color); + } + + if( $accy > 0 ) { + $sp[4]=$pts[4]+$ssh; $sp[5]=$pts[5]-$ssv; + $sp[6]=$pts[2]+$ssh; $sp[7]=$pts[3]-$ssv; + $sp[8]=$pts[2]; $sp[9]=$pts[3]-1; + $sp[10]=$pts[4]+1; $sp[11]=$pts[5]; + $img->FilledPolygon($sp,4); + } + elseif( $accy_neg < 0 ) { + $nsp[6]=$pts[4]+$ssh; $nsp[7]=$pts[5]-$ssv; + $nsp[8]=$pts[4]+1; $nsp[9]=$pts[5]; + $img->FilledPolygon($nsp,4); + } + $img->PopColor(); + } + } + + + // If value is NULL or 0, then don't draw a bar at all + if ($this->plots[$j]->coords[0][$i] == 0 ) continue; + + if( $this->plots[$j]->grad ) { + if( $grad === null ) { + $grad = new Gradient($img); + } + if( is_array($this->plots[$j]->grad_fromcolor) ) { + // The first argument (grad_fromcolor) can be either an array or a single color. If it is an array + // then we have two choices. It can either a) be a single color specified as an RGB triple or it can be + // an array to specify both (from, to style) for each individual bar. The way to know the difference is + // to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB + // triple. + $ng = count($this->plots[$j]->grad_fromcolor); + if( $ng === 3 ) { + if( is_numeric($this->plots[$j]->grad_fromcolor[0]) && $this->plots[$j]->grad_fromcolor[0] > 0 && + $this->plots[$j]->grad_fromcolor[0] < 256 ) { + // RGB Triple + $fromcolor = $this->plots[$j]->grad_fromcolor; + $tocolor = $this->plots[$j]->grad_tocolor; + $style = $this->plots[$j]->grad_style; + } + else { + $fromcolor = $this->plots[$j]->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->plots[$j]->grad_fromcolor[$i % $ng][1]; + $style = $this->plots[$j]->grad_fromcolor[$i % $ng][2]; + } + } + else { + $fromcolor = $this->plots[$j]->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->plots[$j]->grad_fromcolor[$i % $ng][1]; + $style = $this->plots[$j]->grad_fromcolor[$i % $ng][2]; + } + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $fromcolor,$tocolor,$style); + } + else { + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $this->plots[$j]->grad_fromcolor, + $this->plots[$j]->grad_tocolor, + $this->plots[$j]->grad_style); + } + } else { + if (is_array($this->plots[$j]->fill_color) ) { + $numcolors = count($this->plots[$j]->fill_color); + $fillcolor = $this->plots[$j]->fill_color[$i % $numcolors]; + // If the bar is specified to be non filled then the fill color is false + if( $fillcolor !== false ) { + $img->SetColor($this->plots[$j]->fill_color[$i % $numcolors]); + } + } + else { + $fillcolor = $this->plots[$j]->fill_color; + if( $fillcolor !== false ) { + $img->SetColor($this->plots[$j]->fill_color); + } + } + if( $fillcolor !== false ) { + $img->FilledPolygon($pts); + } + } + + $img->SetColor($this->plots[$j]->color); + + // Stroke the pattern + if( $this->plots[$j]->iPattern > -1 ) { + if( $pattern===NULL ) { + $pattern = new RectPatternFactory(); + } + + $prect = $pattern->Create($this->plots[$j]->iPattern,$this->plots[$j]->iPatternColor,1); + $prect->SetDensity($this->plots[$j]->iPatternDensity); + if( $this->plots[$j]->coords[0][$i] < 0 ) { + $rx = $pts[0]; + $ry = $pts[1]; + } + else { + $rx = $pts[2]; + $ry = $pts[3]; + } + $width = abs($pts[4]-$pts[0])+1; + $height = abs($pts[1]-$pts[3])+1; + $prect->SetPos(new Rectangle($rx,$ry,$width,$height)); + $prect->Stroke($img); + } + + + // CSIM array + + if( $i < count($this->plots[$j]->csimtargets) ) { + // Create the client side image map + $rpts = $img->ArrRotate($pts); + $csimcoord=round($rpts[0]).", ".round($rpts[1]); + for( $k=1; $k < 4; ++$k){ + $csimcoord .= ", ".round($rpts[2*$k]).", ".round($rpts[2*$k+1]); + } + if( ! empty($this->plots[$j]->csimtargets[$i]) ) { + $this->csimareas.= '<area shape="poly" coords="'.$csimcoord.'" '; + $this->csimareas.= " href=\"".$this->plots[$j]->csimtargets[$i]."\" "; + + if( ! empty($this->plots[$j]->csimwintargets[$i]) ) { + $this->csimareas.= " target=\"".$this->plots[$j]->csimwintargets[$i]."\" "; + } + + $sval=''; + if( !empty($this->plots[$j]->csimalts[$i]) ) { + $sval=sprintf($this->plots[$j]->csimalts[$i],$this->plots[$j]->coords[0][$i]); + $this->csimareas .= " title=\"$sval\" "; + } + $this->csimareas .= " alt=\"$sval\" />\n"; + } + } + + $pts[] = $pts[0]; + $pts[] = $pts[1]; + $img->SetLineWeight($this->plots[$j]->weight); + $img->Polygon($pts); + $img->SetLineWeight(1); + } + + // Daw potential bar around the entire accbar bar + if( $this->weight > 0 ) { + $y=$yscale->Translate(0); + $img->SetColor($this->color); + $img->SetLineWeight($this->weight); + $img->Rectangle($pts[0],$y,$pts[6],$pts[5]); + } + + // Draw labels for each acc.bar + + $x=$pts[2]+($pts[4]-$pts[2])/2; + if($this->bar_shadow) $x += $ssh; + + // First stroke the accumulated value for the entire bar + // This value is always placed at the top/bottom of the bars + if( $accy_neg < 0 ) { + $y=$yscale->Translate($accy_neg); + $this->value->Stroke($img,$accy_neg,$x,$y); + } + else { + $y=$yscale->Translate($accy); + $this->value->Stroke($img,$accy,$x,$y); + } + + $accy = 0; + $accy_neg = 0; + for($j=0; $j < $this->nbrplots; ++$j ) { + + // We don't print 0 values in an accumulated bar plot + if( $this->plots[$j]->coords[0][$i] == 0 ) continue; + + if ($this->plots[$j]->coords[0][$i] > 0) { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy); + $accyt=$yscale->Translate($accy); + if( $this->plots[$j]->valuepos=='center' ) { + $y = $accyt-($accyt-$yt)/2; + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $y = $accyt; + } + else { // top or max + $y = $accyt-($accyt-$yt); + } + $accy+=$this->plots[$j]->coords[0][$i]; + if( $this->plots[$j]->valuepos=='center' ) { + $this->plots[$j]->value->SetAlign("center","center"); + $this->plots[$j]->value->SetMargin(0); + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $this->plots[$j]->value->SetAlign('center','bottom'); + $this->plots[$j]->value->SetMargin(2); + } + else { + $this->plots[$j]->value->SetAlign('center','top'); + $this->plots[$j]->value->SetMargin(1); + } + } else { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy_neg); + $accyt=$yscale->Translate($accy_neg); + $accy_neg+=$this->plots[$j]->coords[0][$i]; + if( $this->plots[$j]->valuepos=='center' ) { + $y = $accyt-($accyt-$yt)/2; + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $y = $accyt; + } + else { + $y = $accyt-($accyt-$yt); + } + if( $this->plots[$j]->valuepos=='center' ) { + $this->plots[$j]->value->SetAlign("center","center"); + $this->plots[$j]->value->SetMargin(0); + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $this->plots[$j]->value->SetAlign('center',$j==0 ? 'bottom':'top'); + $this->plots[$j]->value->SetMargin(-2); + } + else { + $this->plots[$j]->value->SetAlign('center','bottom'); + $this->plots[$j]->value->SetMargin(-1); + } + } + $this->plots[$j]->value->Stroke($img,$this->plots[$j]->coords[0][$i],$x,$y); + } + + } + return true; + } +} // Class + +/* EOF */ +?> diff --git a/html/jpgraph/flag_mapping b/html/jpgraph/flag_mapping new file mode 100644 index 0000000..be22726 --- /dev/null +++ b/html/jpgraph/flag_mapping @@ -0,0 +1,237 @@ +class JpCountryFlags { + +iCountryFlags = array( + 'Afghanistan' => 'afgh.gif', + 'Republic of Angola' => 'agla.gif', + 'Republic of Albania' => 'alba.gif', + 'Alderney' => 'alde.gif', + 'Democratic and Popular Republic of Algeria' => 'alge.gif', + 'Territory of American Samoa' => 'amsa.gif', + 'Principality of Andorra' => 'andr.gif', + 'British Overseas Territory of Anguilla' => 'angu.gif', + 'Antarctica' => 'anta.gif', + 'Argentine Republic' => 'arge.gif', + 'League of Arab States' => 'arle.gif', + 'Republic of Armenia' => 'arme.gif', + 'Aruba' => 'arub.gif', + 'Commonwealth of Australia' => 'astl.gif', + 'Republic of Austria' => 'aust.gif', + 'Azerbaijani Republic' => 'azer.gif', + 'British Antarctic Territory' => 'bant.gif', + 'Kingdom of Belgium' => 'belg.gif', + 'British Overseas Territory of Bermuda' => 'berm.gif', + 'Commonwealth of the Bahamas' => 'bhms.gif', + 'Kingdom of Bahrain' => 'bhrn.gif', + 'Republic of Belarus' => 'blru.gif', + 'Republic of Bolivia' => 'blva.gif', + 'Belize' => 'blze.gif', + 'Republic of Benin' => 'bnin.gif', + 'Republic of Botswana' => 'bots.gif', + 'Federative Republic of Brazil' => 'braz.gif', + 'Barbados' => 'brbd.gif', + 'British Indian Ocean Territory' => 'brin.gif', + 'Brunei Darussalam' => 'brun.gif', + 'Republic of Burkina' => 'bufa.gif', + 'Republic of Bulgaria' => 'bulg.gif', + 'Republic of Burundi' => 'buru.gif', + 'Overseas Territory of the British Virgin Islands' => 'bvis.gif', + 'Central African Republic' => 'cafr.gif', + 'Kingdom of Cambodia' => 'camb.gif', + 'Republic of Cameroon' => 'came.gif', + 'Dominion of Canada' => 'cana.gif', + 'Caribbean Community' => 'cari.gif', + 'Republic of Cape Verde' => 'cave.gif', + 'Republic of Chad' => 'chad.gif', + 'Republic of Chile' => 'chil.gif', + 'Territory of Christmas Island' => 'chms.gif', + 'Commonwealth of Independent States' => 'cins.gif', + 'Cook Islands' => 'ckis.gif', + 'Republic of Colombia' => 'clmb.gif', + 'Territory of Cocos Islands' => 'cois.gif', + 'Commonwealth' => 'comn.gif', + 'Union of the Comoros' => 'como.gif', + 'Republic of the Congo' => 'cong.gif', + 'Republic of Costa Rica' => 'corc.gif', + 'Republic of Croatia' => 'croa.gif', + 'Republic of Cuba' => 'cuba.gif', + 'British Overseas Territory of the Cayman Islands' => 'cyis.gif', + 'Republic of Cyprus' => 'cypr.gif', + 'The Czech Republic' => 'czec.gif', + 'Kingdom of Denmark' => 'denm.gif', + 'Republic of Djibouti' => 'djib.gif', + 'Commonwealth of Dominica' => 'domn.gif', + 'Dominican Republic' => 'dore.gif', + 'Republic of Ecuador' => 'ecua.gif', + 'Arab Republic of Egypt' => 'egyp.gif', + 'Republic of El Salvador' => 'elsa.gif', + 'England' => 'engl.gif', + 'Republic of Equatorial Guinea' => 'eqgu.gif', + 'State of Eritrea' => 'erit.gif', + 'Republic of Estonia' => 'estn.gif', + 'Ethiopia' => 'ethp.gif', + 'European Union' => 'euun.gif', + 'British Overseas Territory of the Falkland Islands' => 'fais.gif', + 'International Federation of Vexillological Associations' => 'fiav.gif', + 'Republic of Fiji' => 'fiji.gif', + 'Republic of Finland' => 'finl.gif', + 'Territory of French Polynesia' => 'fpol.gif', + 'French Republic' => 'fran.gif', + 'Overseas Department of French Guiana' => 'frgu.gif', + 'Gabonese Republic' => 'gabn.gif', + 'Republic of the Gambia' => 'gamb.gif', + 'Republic of Georgia' => 'geor.gif', + 'Federal Republic of Germany' => 'germ.gif', + 'Republic of Ghana' => 'ghan.gif', + 'Gibraltar' => 'gibr.gif', + 'Hellenic Republic' => 'grec.gif', + 'State of Grenada' => 'gren.gif', + 'Overseas Department of Guadeloupe' => 'guad.gif', + 'Territory of Guam' => 'guam.gif', + 'Republic of Guatemala' => 'guat.gif', + 'The Bailiwick of Guernsey' => 'guer.gif', + 'Republic of Guinea' => 'guin.gif', + 'Republic of Haiti' => 'hait.gif', + 'Hong Kong Special Administrative Region' => 'hokn.gif', + 'Republic of Honduras' => 'hond.gif', + 'Republic of Hungary' => 'hung.gif', + 'Republic of Iceland' => 'icel.gif', + 'International Committee of the Red Cross' => 'icrc.gif', + 'Republic of India' => 'inda.gif', + 'Republic of Indonesia' => 'indn.gif', + 'Republic of Iraq' => 'iraq.gif', + 'Republic of Ireland' => 'irel.gif', + 'Organization of the Islamic Conference' => 'isco.gif', + 'Isle of Man' => 'isma.gif', + 'State of Israel' => 'isra.gif', + 'Italian Republic' => 'ital.gif', + 'Jamaica' => 'jama.gif', + 'Japan' => 'japa.gif', + 'The Bailiwick of Jersey' => 'jers.gif', + 'Hashemite Kingdom of Jordan' => 'jord.gif', + 'Republic of Kazakhstan' => 'kazk.gif', + 'Republic of Kenya' => 'keny.gif', + 'Republic of Kiribati' => 'kirb.gif', + 'State of Kuwait' => 'kuwa.gif', + 'Kyrgyz Republic' => 'kyrg.gif', + 'Republic of Latvia' => 'latv.gif', + 'Lebanese Republic' => 'leba.gif', + 'Kingdom of Lesotho' => 'lest.gif', + 'Republic of Liberia' => 'libe.gif', + 'Principality of Liechtenstein' => 'liec.gif', + 'Republic of Lithuania' => 'lith.gif', + 'Grand Duchy of Luxembourg' => 'luxe.gif', + 'Macao Special Administrative Region' => 'maca.gif', + 'Republic of Macedonia' => 'mace.gif', + 'Republic of Madagascar' => 'mada.gif', + 'Republic of the Marshall Islands' => 'mais.gif', + 'Republic of Maldives' => 'mald.gif', + 'Republic of Mali' => 'mali.gif', + 'Federation of Malaysia' => 'mals018.gif', + 'Republic of Malta' => 'malt.gif', + 'Republic of Malawi' => 'malw.gif', + 'Overseas Department of Martinique' => 'mart.gif', + 'Islamic Republic of Mauritania' => 'maur.gif', + 'Territorial Collectivity of Mayotte' => 'mayt.gif', + 'United Mexican States' => 'mexc.gif', + 'Federated States of Micronesia' => 'micr.gif', + 'Midway Islands' => 'miis.gif', + 'Republic of Moldova' => 'mold.gif', + 'Principality of Monaco' => 'mona.gif', + 'Republic of Mongolia' => 'mong.gif', + 'British Overseas Territory of Montserrat' => 'mont.gif', + 'Kingdom of Morocco' => 'morc.gif', + 'Republic of Mozambique' => 'moza.gif', + 'Republic of Mauritius' => 'mrts.gif', + 'Union of Myanmar' => 'myan.gif', + 'Republic of Namibia' => 'namb.gif', + 'North Atlantic Treaty Organization' => 'nato.gif', + 'Republic of Nauru' => 'naur.gif', + 'Turkish Republic of Northern Cyprus' => 'ncyp.gif', + 'Netherlands Antilles' => 'nean.gif', + 'Kingdom of Nepal' => 'nepa.gif', + 'Kingdom of the Netherlands' => 'neth.gif', + 'Territory of Norfolk Island' => 'nfis.gif', + 'Federal Republic of Nigeria' => 'ngra.gif', + 'Republic of Nicaragua' => 'nica.gif', + 'Republic of Niger' => 'nigr.gif', + 'Niue' => 'niue.gif', + 'Commonwealth of the Northern Mariana Islands' => 'nmar.gif', + 'Province of Northern Ireland' => 'noir.gif', + 'Nordic Council' => 'nord.gif', + 'Kingdom of Norway' => 'norw.gif', + 'Territory of New Caledonia and Dependencies' => 'nwca.gif', + 'New Zealand' => 'nwze.gif', + 'Organization of American States' => 'oast.gif', + 'Organization of African Unity' => 'oaun.gif', + 'International Olympic Committee' => 'olym.gif', + 'Sultanate of Oman' => 'oman.gif', + 'Organization of Petroleum Exporting Countries' => 'opec.gif', + 'Islamic Republic of Pakistan' => 'paks.gif', + 'Republic of Palau' => 'pala.gif', + 'Independent State of Papua New Guinea' => 'pang.gif', + 'Republic of Paraguay' => 'para.gif', + 'Republic of the Philippines' => 'phil.gif', + 'British Overseas Territory of the Pitcairn Islands' => 'piis.gif', + 'Republic of Poland' => 'pola.gif', + 'Republic of Portugal' => 'port.gif', + 'Commonwealth of Puerto Rico' => 'purc.gif', + 'State of Qatar' => 'qata.gif', + 'Russian Federation' => 'russ.gif', + 'Republic of Rwanda' => 'rwan.gif', + 'Kingdom of Saudi Arabia' => 'saar.gif', + 'Republic of San Marino' => 'sama.gif', + 'Nordic Sami Conference' => 'sami.gif', + 'Sark' => 'sark.gif', + 'Scotland' => 'scot.gif', + 'Principality of Seborga' => 'sebo.gif', + 'Republic of Sierra Leone' => 'sile.gif', + 'Republic of Singapore' => 'sing.gif', + 'Republic of Korea' => 'skor.gif', + 'Republic of Slovenia' => 'slva.gif', + 'Somali Republic' => 'smla.gif', + 'Republic of Somaliland' => 'smld.gif', + 'Republic of South Africa' => 'soaf.gif', + 'Solomon Islands' => 'sois.gif', + 'Kingdom of Spain' => 'span.gif', + 'Secretariat of the Pacific Community' => 'spco.gif', + 'Democratic Socialist Republic of Sri Lanka' => 'srla.gif', + 'Saint Lucia' => 'stlu.gif', + 'Republic of the Sudan' => 'suda.gif', + 'Republic of Suriname' => 'surn.gif', + 'Slovak Republic' => 'svka.gif', + 'Kingdom of Sweden' => 'swdn.gif', + 'Swiss Confederation' => 'swit.gif', + 'Syrian Arab Republic' => 'syra.gif', + 'Kingdom of Swaziland' => 'szld.gif', + 'Republic of China' => 'taiw.gif', + 'Republic of Tajikistan' => 'tajk.gif', + 'United Republic of Tanzania' => 'tanz.gif', + 'Kingdom of Thailand' => 'thal.gif', + 'Autonomous Region of Tibet' => 'tibe.gif', + 'Turkmenistan' => 'tkst.gif', + 'Togolese Republic' => 'togo.gif', + 'Tokelau' => 'toke.gif', + 'Kingdom of Tonga' => 'tong.gif', + 'Tristan da Cunha' => 'trdc.gif', + 'Tromelin' => 'tris.gif', + 'Republic of Tunisia' => 'tuns.gif', + 'Republic of Turkey' => 'turk.gif', + 'Tuvalu' => 'tuva.gif', + 'United Arab Emirates' => 'uaem.gif', + 'Republic of Uganda' => 'ugan.gif', + 'Ukraine' => 'ukrn.gif', + 'United Kingdom of Great Britain' => 'unkg.gif', + 'United Nations' => 'unna.gif', + 'United States of America' => 'unst.gif', + 'Oriental Republic of Uruguay' => 'urgy.gif', + 'Virgin Islands of the United States' => 'usvs.gif', + 'Republic of Uzbekistan' => 'uzbk.gif', + 'State of the Vatican City' => 'vacy.gif', + 'Republic of Vanuatu' => 'vant.gif', + 'Bolivarian Republic of Venezuela' => 'venz.gif', + 'Republic of Yemen' => 'yemn.gif', + 'Democratic Republic of Congo' => 'zare.gif', + 'Republic of Zimbabwe' => 'zbwe.gif' +) ; + + diff --git a/html/jpgraph/flags.dat b/html/jpgraph/flags.dat Binary files differnew file mode 100644 index 0000000..4dddaf7 --- /dev/null +++ b/html/jpgraph/flags.dat diff --git a/html/jpgraph/flags_thumb100x100.dat b/html/jpgraph/flags_thumb100x100.dat Binary files differnew file mode 100644 index 0000000..93566f4 --- /dev/null +++ b/html/jpgraph/flags_thumb100x100.dat diff --git a/html/jpgraph/flags_thumb35x35.dat b/html/jpgraph/flags_thumb35x35.dat Binary files differnew file mode 100644 index 0000000..83af33c --- /dev/null +++ b/html/jpgraph/flags_thumb35x35.dat diff --git a/html/jpgraph/flags_thumb60x60.dat b/html/jpgraph/flags_thumb60x60.dat Binary files differnew file mode 100644 index 0000000..8dd1272 --- /dev/null +++ b/html/jpgraph/flags_thumb60x60.dat diff --git a/html/jpgraph/fonts/DejaVuSans-Bold.ttf b/html/jpgraph/fonts/DejaVuSans-Bold.ttf Binary files differnew file mode 100644 index 0000000..692c53c --- /dev/null +++ b/html/jpgraph/fonts/DejaVuSans-Bold.ttf diff --git a/html/jpgraph/fonts/DejaVuSans-BoldOblique.ttf b/html/jpgraph/fonts/DejaVuSans-BoldOblique.ttf Binary files differnew file mode 100644 index 0000000..6c07c03 --- /dev/null +++ b/html/jpgraph/fonts/DejaVuSans-BoldOblique.ttf diff --git a/html/jpgraph/fonts/DejaVuSans-Oblique.ttf b/html/jpgraph/fonts/DejaVuSans-Oblique.ttf Binary files differnew file mode 100644 index 0000000..8ee3b53 --- /dev/null +++ b/html/jpgraph/fonts/DejaVuSans-Oblique.ttf diff --git a/html/jpgraph/fonts/DejaVuSans.ttf b/html/jpgraph/fonts/DejaVuSans.ttf Binary files differnew file mode 100644 index 0000000..72b55dc --- /dev/null +++ b/html/jpgraph/fonts/DejaVuSans.ttf diff --git a/html/jpgraph/fonts/FF_FONT0-Bold.gdf b/html/jpgraph/fonts/FF_FONT0-Bold.gdf Binary files differnew file mode 100644 index 0000000..3b371f8 --- /dev/null +++ b/html/jpgraph/fonts/FF_FONT0-Bold.gdf diff --git a/html/jpgraph/fonts/FF_FONT0.gdf b/html/jpgraph/fonts/FF_FONT0.gdf Binary files differnew file mode 100644 index 0000000..e231b71 --- /dev/null +++ b/html/jpgraph/fonts/FF_FONT0.gdf diff --git a/html/jpgraph/fonts/FF_FONT1-Bold.gdf b/html/jpgraph/fonts/FF_FONT1-Bold.gdf Binary files differnew file mode 100644 index 0000000..d62f0b3 --- /dev/null +++ b/html/jpgraph/fonts/FF_FONT1-Bold.gdf diff --git a/html/jpgraph/fonts/FF_FONT1.gdf b/html/jpgraph/fonts/FF_FONT1.gdf Binary files differnew file mode 100644 index 0000000..7b5b0f6 --- /dev/null +++ b/html/jpgraph/fonts/FF_FONT1.gdf diff --git a/html/jpgraph/fonts/FF_FONT2-Bold.gdf b/html/jpgraph/fonts/FF_FONT2-Bold.gdf Binary files differnew file mode 100644 index 0000000..6e40284 --- /dev/null +++ b/html/jpgraph/fonts/FF_FONT2-Bold.gdf diff --git a/html/jpgraph/fonts/FF_FONT2.gdf b/html/jpgraph/fonts/FF_FONT2.gdf Binary files differnew file mode 100644 index 0000000..50bca09 --- /dev/null +++ b/html/jpgraph/fonts/FF_FONT2.gdf diff --git a/html/jpgraph/gd_image.inc.php b/html/jpgraph/gd_image.inc.php new file mode 100644 index 0000000..fecc401 --- /dev/null +++ b/html/jpgraph/gd_image.inc.php @@ -0,0 +1,2304 @@ +<?php +//======================================================================= +// File: GD_IMAGE.INC.PHP +// Description: PHP Graph Plotting library. Low level image drawing routines +// Created: 2001-01-08, refactored 2008-03-29 +// Ver: $Id: gd_image.inc.php 1922 2010-01-11 11:42:50Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +require_once 'jpgraph_rgb.inc.php'; +require_once 'jpgraph_ttf.inc.php'; +require_once 'imageSmoothArc.php'; + +// Line styles +define('LINESTYLE_SOLID',1); +define('LINESTYLE_DOTTED',2); +define('LINESTYLE_DASHED',3); +define('LINESTYLE_LONGDASH',4); + +// The DEFAULT_GFORMAT sets the default graphic encoding format, i.e. +// PNG, JPG or GIF depending on what is installed on the target system +// in that order. +if( !DEFINED("DEFAULT_GFORMAT") ) { + define("DEFAULT_GFORMAT","auto"); +} + +//======================================================================== +// CLASS Image +// Description: The very coor image drawing class that encapsulates all +// calls to the GD library +// Note: The class used by the library is the decendant +// class RotImage which extends the Image class with transparent +// rotation. +//========================================================================= +class Image { + public $img=null; + public $rgb=null; + public $img_format; + public $ttf=null; + public $line_style=LINESTYLE_SOLID; + public $current_color,$current_color_name; + public $original_width=0, $original_height=0; + public $plotwidth=0,$plotheight=0; + + // for __get, __set + private $_left_margin=30,$_right_margin=30,$_top_margin=20,$_bottom_margin=30; + //private $_plotwidth=0,$_plotheight=0; + private $_width=0, $_height=0; + private $_line_weight=1; + + protected $expired=true; + protected $lastx=0, $lasty=0; + protected $obs_list=array(); + protected $font_size=12,$font_family=FF_DEFAULT, $font_style=FS_NORMAL; + protected $font_file=''; + protected $text_halign="left",$text_valign="bottom"; + protected $use_anti_aliasing=false; + protected $quality=null; + protected $colorstack=array(),$colorstackidx=0; + protected $canvascolor = 'white' ; + protected $langconv = null ; + protected $iInterlace=false; + protected $bbox_cache = array(); // STore the last found tetx bounding box + protected $ff_font0; + protected $ff_font0_bold; + protected $ff_font1; + protected $ff_font1_bold; + protected $ff_font2; + protected $ff_font2_bold; + + + //--------------- + // CONSTRUCTOR + function __construct($aWidth=0,$aHeight=0,$aFormat=DEFAULT_GFORMAT,$aSetAutoMargin=true) { + + $this->original_width = $aWidth; + $this->original_height = $aHeight; + $this->CreateImgCanvas($aWidth, $aHeight); + + if( $aSetAutoMargin ) { + $this->SetAutoMargin(); + } + + if( !$this->SetImgFormat($aFormat) ) { + JpGraphError::RaiseL(25081,$aFormat);//("JpGraph: Selected graphic format is either not supported or unknown [$aFormat]"); + } + $this->ttf = new TTF(); + $this->langconv = new LanguageConv(); + + $this->ff_font0 = imageloadfont(dirname(__FILE__) . "/fonts/FF_FONT0.gdf"); + $this->ff_font1 = imageloadfont(dirname(__FILE__) . "/fonts/FF_FONT1.gdf"); + $this->ff_font2 = imageloadfont(dirname(__FILE__) . "/fonts/FF_FONT2.gdf"); + $this->ff_font1_bold = imageloadfont(dirname(__FILE__) . "/fonts/FF_FONT1-Bold.gdf"); + $this->ff_font2_bold = imageloadfont(dirname(__FILE__) . "/fonts/FF_FONT2-Bold.gdf"); + } + + // Enable interlacing in images + function SetInterlace($aFlg=true) { + $this->iInterlace=$aFlg; + } + + // Should we use anti-aliasing. Note: This really slows down graphics! + function SetAntiAliasing($aFlg=true) { + $this->use_anti_aliasing = $aFlg; + if( function_exists('imageantialias') ) { + imageantialias($this->img,$aFlg); + } + else { + JpGraphError::RaiseL(25128);//('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.') + } + } + + function GetAntiAliasing() { + return $this->use_anti_aliasing ; + } + + function CreateRawCanvas($aWidth=0,$aHeight=0) { + + $aWidth *= SUPERSAMPLING_SCALE; + $aHeight *= SUPERSAMPLING_SCALE; + + if( $aWidth <= 1 || $aHeight <= 1 ) { + JpGraphError::RaiseL(25082,$aWidth,$aHeight);//("Illegal sizes specified for width or height when creating an image, (width=$aWidth, height=$aHeight)"); + } + + $this->img = @imagecreatetruecolor($aWidth, $aHeight); + if( $this->img < 1 ) { + JpGraphError::RaiseL(25126); + //die("Can't create truecolor image. Check that you really have GD2 library installed."); + } + $this->SetAlphaBlending(); + + if( $this->iInterlace ) { + imageinterlace($this->img,1); + } + if( $this->rgb != null ) { + $this->rgb->img = $this->img ; + } + else { + $this->rgb = new RGB($this->img); + } + } + + function CloneCanvasH() { + $oldimage = $this->img; + $this->CreateRawCanvas($this->width,$this->height); + imagecopy($this->img,$oldimage,0,0,0,0,$this->width,$this->height); + return $oldimage; + } + + function CreateImgCanvas($aWidth=0,$aHeight=0) { + + $old = array($this->img,$this->width,$this->height); + + $aWidth = round($aWidth); + $aHeight = round($aHeight); + + $this->width=$aWidth; + $this->height=$aHeight; + + + if( $aWidth==0 || $aHeight==0 ) { + // We will set the final size later. + // Note: The size must be specified before any other + // img routines that stroke anything are called. + $this->img = null; + $this->rgb = null; + return $old; + } + + $this->CreateRawCanvas($aWidth,$aHeight); + // Set canvas color (will also be the background color for a + // a pallett image + $this->SetColor($this->canvascolor); + $this->FilledRectangle(0,0,$this->width-1,$this->height-1); + + return $old ; + } + + function CopyCanvasH($aToHdl,$aFromHdl,$aToX,$aToY,$aFromX,$aFromY,$aWidth,$aHeight,$aw=-1,$ah=-1) { + if( $aw === -1 ) { + $aw = $aWidth; + $ah = $aHeight; + $f = 'imagecopyresized'; + } + else { + $f = 'imagecopyresampled'; + } + $f($aToHdl,$aFromHdl,$aToX,$aToY,$aFromX,$aFromY, $aWidth,$aHeight,$aw,$ah); + } + + function Copy($fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth=-1,$fromHeight=-1) { + $this->CopyCanvasH($this->img,$fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth,$fromHeight); + } + + function CopyMerge($fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth=-1,$fromHeight=-1,$aMix=100) { + if( $aMix == 100 ) { + $this->CopyCanvasH($this->img,$fromImg, + $toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth,$fromHeight); + } + else { + if( ($fromWidth != -1 && ($fromWidth != $toWidth)) || ($fromHeight != -1 && ($fromHeight != $fromHeight)) ) { + // Create a new canvas that will hold the re-scaled original from image + if( $toWidth <= 1 || $toHeight <= 1 ) { + JpGraphError::RaiseL(25083);//('Illegal image size when copying image. Size for copied to image is 1 pixel or less.'); + } + + $tmpimg = @imagecreatetruecolor($toWidth, $toHeight); + + if( $tmpimg < 1 ) { + JpGraphError::RaiseL(25084);//('Failed to create temporary GD canvas. Out of memory ?'); + } + $this->CopyCanvasH($tmpimg,$fromImg,0,0,0,0, + $toWidth,$toHeight,$fromWidth,$fromHeight); + $fromImg = $tmpimg; + } + imagecopymerge($this->img,$fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$aMix); + } + } + + static function GetWidth($aImg=null) { + if( $aImg === null ) { + $aImg = $this->img; + } + return imagesx($aImg); + } + + static function GetHeight($aImg=null) { + if( $aImg === null ) { + $aImg = $this->img; + } + return imagesy($aImg); + } + + static function CreateFromString($aStr) { + $img = imagecreatefromstring($aStr); + if( $img === false ) { + JpGraphError::RaiseL(25085); + //('An image can not be created from the supplied string. It is either in a format not supported or the string is representing an corrupt image.'); + } + return $img; + } + + function SetCanvasH($aHdl) { + $this->img = $aHdl; + $this->rgb->img = $aHdl; + } + + function SetCanvasColor($aColor) { + $this->canvascolor = $aColor ; + } + + function SetAlphaBlending($aFlg=true) { + ImageAlphaBlending($this->img,$aFlg); + } + + function SetAutoMargin() { + $min_bm=5; + $lm = min(40,$this->width/7); + $rm = min(20,$this->width/10); + $tm = max(5,$this->height/7); + $bm = max($min_bm,$this->height/6); + $this->SetMargin($lm,$rm,$tm,$bm); + } + + //--------------- + // PUBLIC METHODS + + function SetFont($family,$style=FS_NORMAL,$size=10) { + $this->font_family=$family; + $this->font_style=$style; + $this->font_size=$size*SUPERSAMPLING_SCALE; + $this->font_file=''; + if( ($this->font_family==FF_FONT1 || $this->font_family==FF_FONT2) && $this->font_style==FS_BOLD ){ + ++$this->font_family; + } + if( $this->font_family > FF_FONT2+1 ) { // A TTF font so get the font file + + // Check that this PHP has support for TTF fonts + if( !function_exists('imagettfbbox') ) { + // use internal font when php is configured without '--with-ttf' + $this->font_family = FF_FONT1; +// JpGraphError::RaiseL(25087);//('This PHP build has not been configured with TTF support. You need to recompile your PHP installation with FreeType support.'); + } else { + $this->font_file = $this->ttf->File($this->font_family,$this->font_style); + } + } + } + + // Get the specific height for a text string + function GetTextHeight($txt="",$angle=0) { + $tmp = preg_split('/\n/',$txt); + $n = count($tmp); + $m=0; + for($i=0; $i< $n; ++$i) { + $m = max($m,strlen($tmp[$i])); + } + + if( $this->font_family <= FF_FONT2+1 ) { + if( $angle==0 ) { + $h = imagefontheight($this->font_family); + if( $h === false ) { + JpGraphError::RaiseL(25088);//('You have a misconfigured GD font support. The call to imagefontwidth() fails.'); + } + + return $n*$h; + } + else { + $w = @imagefontwidth($this->font_family); + if( $w === false ) { + JpGraphError::RaiseL(25088);//('You have a misconfigured GD font support. The call to imagefontwidth() fails.'); + } + + return $m*$w; + } + } + else { + $bbox = $this->GetTTFBBox($txt,$angle); + return $bbox[1]-$bbox[5]+1; + } + } + + // Estimate font height + function GetFontHeight($angle=0) { + $txt = "XOMg"; + return $this->GetTextHeight($txt,$angle); + } + + // Approximate font width with width of letter "O" + function GetFontWidth($angle=0) { + $txt = 'O'; + return $this->GetTextWidth($txt,$angle); + } + + // Get actual width of text in absolute pixels. Note that the width is the + // texts projected with onto the x-axis. Call with angle=0 to get the true + // etxt width. + function GetTextWidth($txt,$angle=0) { + + $tmp = preg_split('/\n/',$txt); + $n = count($tmp); + if( $this->font_family <= FF_FONT2+1 ) { + + $m=0; + for($i=0; $i < $n; ++$i) { + $l=strlen($tmp[$i]); + if( $l > $m ) { + $m = $l; + } + } + + if( $angle==0 ) { + $w = @imagefontwidth($this->font_family); + if( $w === false ) { + JpGraphError::RaiseL(25088);//('You have a misconfigured GD font support. The call to imagefontwidth() fails.'); + } + return $m*$w; + } + else { + // 90 degrees internal so height becomes width + $h = @imagefontheight($this->font_family); + if( $h === false ) { + JpGraphError::RaiseL(25089);//('You have a misconfigured GD font support. The call to imagefontheight() fails.'); + } + return $n*$h; + } + } + else { + // For TTF fonts we must walk through a lines and find the + // widest one which we use as the width of the multi-line + // paragraph + $m=0; + for( $i=0; $i < $n; ++$i ) { + $bbox = $this->GetTTFBBox($tmp[$i],$angle); + $mm = $bbox[2] - $bbox[0]; + if( $mm > $m ) + $m = $mm; + } + return $m; + } + } + + + // Draw text with a box around it + function StrokeBoxedText($x,$y,$txt,$dir=0,$fcolor="white",$bcolor="black", + $shadowcolor=false,$paragraph_align="left", + $xmarg=6,$ymarg=4,$cornerradius=0,$dropwidth=3) { + + $oldx = $this->lastx; + $oldy = $this->lasty; + + if( !is_numeric($dir) ) { + if( $dir=="h" ) $dir=0; + elseif( $dir=="v" ) $dir=90; + else JpGraphError::RaiseL(25090,$dir);//(" Unknown direction specified in call to StrokeBoxedText() [$dir]"); + } + + if( $this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2+1) { + $width=$this->GetTextWidth($txt,$dir) ; + $height=$this->GetTextHeight($txt,$dir) ; + } + else { + $width=$this->GetBBoxWidth($txt,$dir) ; + $height=$this->GetBBoxHeight($txt,$dir) ; + } + + $height += 2*$ymarg; + $width += 2*$xmarg; + + if( $this->text_halign=="right" ) $x -= $width; + elseif( $this->text_halign=="center" ) $x -= $width/2; + + if( $this->text_valign=="bottom" ) $y -= $height; + elseif( $this->text_valign=="center" ) $y -= $height/2; + + $olda = $this->SetAngle(0); + + if( $shadowcolor ) { + $this->PushColor($shadowcolor); + $this->FilledRoundedRectangle($x-$xmarg+$dropwidth,$y-$ymarg+$dropwidth, + $x+$width+$dropwidth,$y+$height-$ymarg+$dropwidth, + $cornerradius); + $this->PopColor(); + $this->PushColor($fcolor); + $this->FilledRoundedRectangle($x-$xmarg,$y-$ymarg, + $x+$width,$y+$height-$ymarg, + $cornerradius); + $this->PopColor(); + $this->PushColor($bcolor); + $this->RoundedRectangle($x-$xmarg,$y-$ymarg, + $x+$width,$y+$height-$ymarg,$cornerradius); + $this->PopColor(); + } + else { + if( $fcolor ) { + $oc=$this->current_color; + $this->SetColor($fcolor); + $this->FilledRoundedRectangle($x-$xmarg,$y-$ymarg,$x+$width,$y+$height-$ymarg,$cornerradius); + $this->current_color=$oc; + } + if( $bcolor ) { + $oc=$this->current_color; + $this->SetColor($bcolor); + $this->RoundedRectangle($x-$xmarg,$y-$ymarg,$x+$width,$y+$height-$ymarg,$cornerradius); + $this->current_color=$oc; + } + } + + $h=$this->text_halign; + $v=$this->text_valign; + $this->SetTextAlign("left","top"); + + $debug=false; + $this->StrokeText($x, $y, $txt, $dir, $paragraph_align,$debug); + + $bb = array($x-$xmarg,$y+$height-$ymarg,$x+$width,$y+$height-$ymarg, + $x+$width,$y-$ymarg,$x-$xmarg,$y-$ymarg); + $this->SetTextAlign($h,$v); + + $this->SetAngle($olda); + $this->lastx = $oldx; + $this->lasty = $oldy; + + return $bb; + } + + // Draw text with a box around it. This time the box will be rotated + // with the text. The previous method will just make a larger enough non-rotated + // box to hold the text inside. + function StrokeBoxedText2($x,$y,$txt,$dir=0,$fcolor="white",$bcolor="black", + $shadowcolor=false,$paragraph_align="left", + $xmarg=6,$ymarg=4,$cornerradius=0,$dropwidth=3) { + + // This version of boxed text will stroke a rotated box round the text + // thta will follow the angle of the text. + // This has two implications: + // 1) This methos will only support TTF fonts + // 2) The only two alignment that makes sense are centered or baselined + + if( $this->font_family <= FF_FONT2+1 ) { + JpGraphError::RaiseL(25131);//StrokeBoxedText2() Only support TTF fonts and not built in bitmap fonts + } + + $oldx = $this->lastx; + $oldy = $this->lasty; + $dir = $this->NormAngle($dir); + + if( !is_numeric($dir) ) { + if( $dir=="h" ) $dir=0; + elseif( $dir=="v" ) $dir=90; + else JpGraphError::RaiseL(25090,$dir);//(" Unknown direction specified in call to StrokeBoxedText() [$dir]"); + } + + $width=$this->GetTextWidth($txt,0) + 2*$xmarg; + $height=$this->GetTextHeight($txt,0) + 2*$ymarg ; + $rect_width=$this->GetBBoxWidth($txt,$dir) ; + $rect_height=$this->GetBBoxHeight($txt,$dir) ; + + $baseline_offset = $this->bbox_cache[1]-1; + + if( $this->text_halign=="center" ) { + if( $dir >= 0 && $dir <= 90 ) { + + $x -= $rect_width/2; + $x += sin($dir*M_PI/180)*$height; + $y += $rect_height/2; + + } elseif( $dir >= 270 && $dir <= 360 ) { + + $x -= $rect_width/2; + $y -= $rect_height/2; + $y += cos($dir*M_PI/180)*$height; + + } elseif( $dir >= 90 && $dir <= 180 ) { + + $x += $rect_width/2; + $y += $rect_height/2; + $y += cos($dir*M_PI/180)*$height; + + } + else { + // $dir > 180 && $dir < 270 + $x += $rect_width/2; + $x += sin($dir*M_PI/180)*$height; + $y -= $rect_height/2; + } + } + + // Rotate the box around this point + $this->SetCenter($x,$y); + $olda = $this->SetAngle(-$dir); + + // We need to use adjusted coordinats for the box to be able + // to draw the box below the baseline. This cannot be done before since + // the rotating point must be the original x,y since that is arounbf the + // point where the text will rotate and we cannot change this since + // that is where the GD/GreeType will rotate the text + + + // For smaller <14pt font we need to do some additional + // adjustments to make it look good + if( $this->font_size < 14 ) { + $x -= 2; + $y += 2; + } + else { + // $y += $baseline_offset; + } + + if( $shadowcolor ) { + $this->PushColor($shadowcolor); + $this->FilledRectangle($x-$xmarg+$dropwidth,$y+$ymarg+$dropwidth-$height, + $x+$width+$dropwidth,$y+$ymarg+$dropwidth); + //$cornerradius); + $this->PopColor(); + $this->PushColor($fcolor); + $this->FilledRectangle($x-$xmarg, $y+$ymarg-$height, + $x+$width, $y+$ymarg); + //$cornerradius); + $this->PopColor(); + $this->PushColor($bcolor); + $this->Rectangle($x-$xmarg,$y+$ymarg-$height, + $x+$width,$y+$ymarg); + //$cornerradius); + $this->PopColor(); + } + else { + if( $fcolor ) { + $oc=$this->current_color; + $this->SetColor($fcolor); + $this->FilledRectangle($x-$xmarg,$y+$ymarg-$height,$x+$width,$y+$ymarg);//,$cornerradius); + $this->current_color=$oc; + } + if( $bcolor ) { + $oc=$this->current_color; + $this->SetColor($bcolor); + $this->Rectangle($x-$xmarg,$y+$ymarg-$height,$x+$width,$y+$ymarg);//,$cornerradius); + $this->current_color=$oc; + } + } + + if( $this->font_size < 14 ) { + $x += 2; + $y -= 2; + } + else { + + // Restore the original y before we stroke the text + // $y -= $baseline_offset; + + } + + $this->SetCenter(0,0); + $this->SetAngle($olda); + + $h=$this->text_halign; + $v=$this->text_valign; + if( $this->text_halign == 'center') { + $this->SetTextAlign('center','basepoint'); + } + else { + $this->SetTextAlign('basepoint','basepoint'); + } + + $debug=false; + $this->StrokeText($x, $y, $txt, $dir, $paragraph_align,$debug); + + $bb = array($x-$xmarg, $y+$height-$ymarg, + $x+$width, $y+$height-$ymarg, + $x+$width, $y-$ymarg, + $x-$xmarg, $y-$ymarg); + + $this->SetTextAlign($h,$v); + $this->SetAngle($olda); + + $this->lastx = $oldx; + $this->lasty = $oldy; + + return $bb; + } + + // Set text alignment + function SetTextAlign($halign,$valign="bottom") { + $this->text_halign=$halign; + $this->text_valign=$valign; + } + + function _StrokeBuiltinFont($x,$y,$txt,$dir,$paragraph_align,&$aBoundingBox,$aDebug=false) { + + if( is_numeric($dir) && $dir!=90 && $dir!=0) + JpGraphError::RaiseL(25091);//(" Internal font does not support drawing text at arbitrary angle. Use TTF fonts instead."); + + $h=$this->GetTextHeight($txt); + $fh=$this->GetFontHeight(); + $w=$this->GetTextWidth($txt); + + if( $this->text_halign=="right") { + $x -= $dir==0 ? $w : $h; + } + elseif( $this->text_halign=="center" ) { + // For center we subtract 1 pixel since this makes the middle + // be prefectly in the middle + $x -= $dir==0 ? $w/2-1 : $h/2; + } + if( $this->text_valign=="top" ) { + $y += $dir==0 ? $h : $w; + } + elseif( $this->text_valign=="center" ) { + $y += $dir==0 ? $h/2 : $w/2; + } + + $use_font = $this->font_family; + + if( $dir==90 ) { + imagestringup($this->img,$use_font,$x,$y,$txt,$this->current_color); + $aBoundingBox = array(round($x),round($y),round($x),round($y-$w),round($x+$h),round($y-$w),round($x+$h),round($y)); + if( $aDebug ) { + // Draw bounding box + $this->PushColor('green'); + $this->Polygon($aBoundingBox,true); + $this->PopColor(); + } + } + else { + if( preg_match('/\n/',$txt) ) { + $tmp = preg_split('/\n/',$txt); + for($i=0; $i < count($tmp); ++$i) { + $w1 = $this->GetTextWidth($tmp[$i]); + if( $paragraph_align=="left" ) { + imagestring($this->img,$use_font,$x,$y-$h+1+$i*$fh,$tmp[$i],$this->current_color); + } + elseif( $paragraph_align=="right" ) { + imagestring($this->img,$use_font,$x+($w-$w1),$y-$h+1+$i*$fh,$tmp[$i],$this->current_color); + } + else { + imagestring($this->img,$use_font,$x+$w/2-$w1/2,$y-$h+1+$i*$fh,$tmp[$i],$this->current_color); + } + } + } + else { + //Put the text + imagestring($this->img,$use_font,$x,$y-$h+1,$txt,$this->current_color); + } + if( $aDebug ) { + // Draw the bounding rectangle and the bounding box + $p1 = array(round($x),round($y),round($x),round($y-$h),round($x+$w),round($y-$h),round($x+$w),round($y)); + + // Draw bounding box + $this->PushColor('green'); + $this->Polygon($p1,true); + $this->PopColor(); + + } + $aBoundingBox=array(round($x),round($y),round($x),round($y-$h),round($x+$w),round($y-$h),round($x+$w),round($y)); + } + } + + function AddTxtCR($aTxt) { + // If the user has just specified a '\n' + // instead of '\n\t' we have to add '\r' since + // the width will be too muchy otherwise since when + // we print we stroke the individually lines by hand. + $e = explode("\n",$aTxt); + $n = count($e); + for($i=0; $i<$n; ++$i) { + $e[$i]=str_replace("\r","",$e[$i]); + } + return implode("\n\r",$e); + } + + function NormAngle($a) { + // Normalize angle in degrees + // Normalize angle to be between 0-360 + while( $a > 360 ) + $a -= 360; + while( $a < -360 ) + $a += 360; + if( $a < 0 ) + $a = 360 + $a; + return $a; + } + + function imagettfbbox_fixed($size, $angle, $fontfile, $text) { + + + if( ! USE_LIBRARY_IMAGETTFBBOX ) { + + $bbox = @imagettfbbox($size, $angle, $fontfile, $text); + if( $bbox === false ) { + JpGraphError::RaiseL(25092,$this->font_file); + //("There is either a configuration problem with TrueType or a problem reading font file (".$this->font_file."). Make sure file exists and is in a readable place for the HTTP process. (If 'basedir' restriction is enabled in PHP then the font file must be located in the document root.). It might also be a wrongly installed FreeType library. Try uppgrading to at least FreeType 2.1.13 and recompile GD with the correct setup so it can find the new FT library."); + } + $this->bbox_cache = $bbox; + return $bbox; + } + + // The built in imagettfbbox is buggy for angles != 0 so + // we calculate this manually by getting the bounding box at + // angle = 0 and then rotate the bounding box manually + $bbox = @imagettfbbox($size, 0, $fontfile, $text); + if( $bbox === false ) { + JpGraphError::RaiseL(25092,$this->font_file); + //("There is either a configuration problem with TrueType or a problem reading font file (".$this->font_file."). Make sure file exists and is in a readable place for the HTTP process. (If 'basedir' restriction is enabled in PHP then the font file must be located in the document root.). It might also be a wrongly installed FreeType library. Try uppgrading to at least FreeType 2.1.13 and recompile GD with the correct setup so it can find the new FT library."); + } + + $angle = $this->NormAngle($angle); + + $a = $angle*M_PI/180; + $ca = cos($a); + $sa = sin($a); + $ret = array(); + + // We always add 1 pixel to the left since the left edge of the bounding + // box is sometimes coinciding with the first pixel of the text + //$bbox[0] -= 1; + //$bbox[6] -= 1; + + // For roatated text we need to add extra width for rotated + // text since the kerning and stroking of the TTF is not the same as for + // text at a 0 degree angle + + if( $angle > 0.001 && abs($angle-360) > 0.001 ) { + $h = abs($bbox[7]-$bbox[1]); + $w = abs($bbox[2]-$bbox[0]); + + $bbox[0] -= 2; + $bbox[6] -= 2; + // The width is underestimated so compensate for that + $bbox[2] += round($w*0.06); + $bbox[4] += round($w*0.06); + + // and we also need to compensate with increased height + $bbox[5] -= round($h*0.1); + $bbox[7] -= round($h*0.1); + + if( $angle > 90 ) { + // For angles > 90 we also need to extend the height further down + // by the baseline since that is also one more problem + $bbox[1] += round($h*0.15); + $bbox[3] += round($h*0.15); + + // and also make it slighty less height + $bbox[7] += round($h*0.05); + $bbox[5] += round($h*0.05); + + // And we need to move the box slightly top the rright (from a tetx perspective) + $bbox[0] += round($w*0.02); + $bbox[6] += round($w*0.02); + + if( $angle > 180 ) { + // And we need to move the box slightly to the left (from a text perspective) + $bbox[0] -= round($w*0.02); + $bbox[6] -= round($w*0.02); + $bbox[2] -= round($w*0.02); + $bbox[4] -= round($w*0.02); + + } + + } + for($i = 0; $i < 7; $i += 2) { + $ret[$i] = round($bbox[$i] * $ca + $bbox[$i+1] * $sa); + $ret[$i+1] = round($bbox[$i+1] * $ca - $bbox[$i] * $sa); + } + $this->bbox_cache = $ret; + return $ret; + } + else { + $this->bbox_cache = $bbox; + return $bbox; + } + } + + // Deprecated + function GetTTFBBox($aTxt,$aAngle=0) { + $bbox = $this->imagettfbbox_fixed($this->font_size,$aAngle,$this->font_file,$aTxt); + return $bbox; + } + + function GetBBoxTTF($aTxt,$aAngle=0) { + // Normalize the bounding box to become a minimum + // enscribing rectangle + + $aTxt = $this->AddTxtCR($aTxt); + + if( !is_readable($this->font_file) ) { + JpGraphError::RaiseL(25093,$this->font_file); + //('Can not read font file ('.$this->font_file.') in call to Image::GetBBoxTTF. Please make sure that you have set a font before calling this method and that the font is installed in the TTF directory.'); + } + $bbox = $this->imagettfbbox_fixed($this->font_size,$aAngle,$this->font_file,$aTxt); + + if( $aAngle==0 ) return $bbox; + + if( $aAngle >= 0 ) { + if( $aAngle <= 90 ) { //<=0 + $bbox = array($bbox[6],$bbox[1],$bbox[2],$bbox[1], + $bbox[2],$bbox[5],$bbox[6],$bbox[5]); + } + elseif( $aAngle <= 180 ) { //<= 2 + $bbox = array($bbox[4],$bbox[7],$bbox[0],$bbox[7], + $bbox[0],$bbox[3],$bbox[4],$bbox[3]); + } + elseif( $aAngle <= 270 ) { //<= 3 + $bbox = array($bbox[2],$bbox[5],$bbox[6],$bbox[5], + $bbox[6],$bbox[1],$bbox[2],$bbox[1]); + } + else { + $bbox = array($bbox[0],$bbox[3],$bbox[4],$bbox[3], + $bbox[4],$bbox[7],$bbox[0],$bbox[7]); + } + } + elseif( $aAngle < 0 ) { + if( $aAngle <= -270 ) { // <= -3 + $bbox = array($bbox[6],$bbox[1],$bbox[2],$bbox[1], + $bbox[2],$bbox[5],$bbox[6],$bbox[5]); + } + elseif( $aAngle <= -180 ) { // <= -2 + $bbox = array($bbox[0],$bbox[3],$bbox[4],$bbox[3], + $bbox[4],$bbox[7],$bbox[0],$bbox[7]); + } + elseif( $aAngle <= -90 ) { // <= -1 + $bbox = array($bbox[2],$bbox[5],$bbox[6],$bbox[5], + $bbox[6],$bbox[1],$bbox[2],$bbox[1]); + } + else { + $bbox = array($bbox[0],$bbox[3],$bbox[4],$bbox[3], + $bbox[4],$bbox[7],$bbox[0],$bbox[7]); + } + } + return $bbox; + } + + function GetBBoxHeight($aTxt,$aAngle=0) { + $box = $this->GetBBoxTTF($aTxt,$aAngle); + return abs($box[7]-$box[1]); + } + + function GetBBoxWidth($aTxt,$aAngle=0) { + $box = $this->GetBBoxTTF($aTxt,$aAngle); + return $box[2]-$box[0]+1; + } + + + function _StrokeTTF($x,$y,$txt,$dir,$paragraph_align,&$aBoundingBox,$debug=false) { + + // Setup default inter line margin for paragraphs to be + // 3% of the font height. + $ConstLineSpacing = 0.03 ; + + // Remember the anchor point before adjustment + if( $debug ) { + $ox=$x; + $oy=$y; + } + + if( !preg_match('/\n/',$txt) || ($dir>0 && preg_match('/\n/',$txt)) ) { + // Format a single line + + $txt = $this->AddTxtCR($txt); + $bbox=$this->GetBBoxTTF($txt,$dir); + $width = $this->GetBBoxWidth($txt,$dir); + $height = $this->GetBBoxHeight($txt,$dir); + + // The special alignment "basepoint" is mostly used internally + // in the library. This will put the anchor position at the left + // basepoint of the tetx. This is the default anchor point for + // TTF text. + + if( $this->text_valign != 'basepoint' ) { + // Align x,y ot lower left corner of bbox + + + if( $this->text_halign=='right' ) { + $x -= $width; + $x -= $bbox[0]; + } + elseif( $this->text_halign=='center' ) { + $x -= $width/2; + $x -= $bbox[0]; + } + elseif( $this->text_halign=='baseline' ) { + // This is only support for text at 90 degree !! + // Do nothing the text is drawn at baseline by default + } + + if( $this->text_valign=='top' ) { + $y -= $bbox[1]; // Adjust to bottom of text + $y += $height; + } + elseif( $this->text_valign=='center' ) { + $y -= $bbox[1]; // Adjust to bottom of text + $y += $height/2; + } + elseif( $this->text_valign=='baseline' ) { + // This is only support for text at 0 degree !! + // Do nothing the text is drawn at baseline by default + } + } + ImageTTFText ($this->img, $this->font_size, $dir, $x, $y, + $this->current_color,$this->font_file,$txt); + + // Calculate and return the co-ordinates for the bounding box + $box = $this->imagettfbbox_fixed($this->font_size,$dir,$this->font_file,$txt); + $p1 = array(); + + for($i=0; $i < 4; ++$i) { + $p1[] = round($box[$i*2]+$x); + $p1[] = round($box[$i*2+1]+$y); + } + $aBoundingBox = $p1; + + // Debugging code to highlight the bonding box and bounding rectangle + // For text at 0 degrees the bounding box and bounding rectangle are the + // same + if( $debug ) { + // Draw the bounding rectangle and the bounding box + + $p = array(); + $p1 = array(); + + for($i=0; $i < 4; ++$i) { + $p[] = $bbox[$i*2]+$x ; + $p[] = $bbox[$i*2+1]+$y; + $p1[] = $box[$i*2]+$x ; + $p1[] = $box[$i*2+1]+$y ; + } + + // Draw bounding box + $this->PushColor('green'); + $this->Polygon($p1,true); + $this->PopColor(); + + // Draw bounding rectangle + $this->PushColor('darkgreen'); + $this->Polygon($p,true); + $this->PopColor(); + + // Draw a cross at the anchor point + $this->PushColor('red'); + $this->Line($ox-15,$oy,$ox+15,$oy); + $this->Line($ox,$oy-15,$ox,$oy+15); + $this->PopColor(); + } + } + else { + // Format a text paragraph + $fh=$this->GetFontHeight(); + + // Line margin is 25% of font height + $linemargin=round($fh*$ConstLineSpacing); + $fh += $linemargin; + $w=$this->GetTextWidth($txt); + + $y -= $linemargin/2; + $tmp = preg_split('/\n/',$txt); + $nl = count($tmp); + $h = $nl * $fh; + + if( $this->text_halign=='right') { + $x -= $dir==0 ? $w : $h; + } + elseif( $this->text_halign=='center' ) { + $x -= $dir==0 ? $w/2 : $h/2; + } + + if( $this->text_valign=='top' ) { + $y += $dir==0 ? $h : $w; + } + elseif( $this->text_valign=='center' ) { + $y += $dir==0 ? $h/2 : $w/2; + } + + // Here comes a tricky bit. + // Since we have to give the position for the string at the + // baseline this means thaht text will move slightly up + // and down depending on any of it's character descend below + // the baseline, for example a 'g'. To adjust the Y-position + // we therefore adjust the text with the baseline Y-offset + // as used for the current font and size. This will keep the + // baseline at a fixed positoned disregarding the actual + // characters in the string. + $standardbox = $this->GetTTFBBox('Gg',$dir); + $yadj = $standardbox[1]; + $xadj = $standardbox[0]; + $aBoundingBox = array(); + for($i=0; $i < $nl; ++$i) { + $wl = $this->GetTextWidth($tmp[$i]); + $bbox = $this->GetTTFBBox($tmp[$i],$dir); + if( $paragraph_align=='left' ) { + $xl = $x; + } + elseif( $paragraph_align=='right' ) { + $xl = $x + ($w-$wl); + } + else { + // Center + $xl = $x + $w/2 - $wl/2 ; + } + + // In theory we should adjust with full pre-lead to get the lines + // lined up but this doesn't look good so therfore we only adjust with + // half th pre-lead + $xl -= $bbox[0]/2; + $yl = $y - $yadj; + //$xl = $xl- $xadj; + ImageTTFText($this->img, $this->font_size, $dir, $xl, $yl-($h-$fh)+$fh*$i, + $this->current_color,$this->font_file,$tmp[$i]); + + // echo "xl=$xl,".$tmp[$i]." <br>"; + if( $debug ) { + // Draw the bounding rectangle around each line + $box=@ImageTTFBBox($this->font_size,$dir,$this->font_file,$tmp[$i]); + $p = array(); + for($j=0; $j < 4; ++$j) { + $p[] = $bbox[$j*2]+$xl; + $p[] = $bbox[$j*2+1]+$yl-($h-$fh)+$fh*$i; + } + + // Draw bounding rectangle + $this->PushColor('darkgreen'); + $this->Polygon($p,true); + $this->PopColor(); + } + } + + // Get the bounding box + $bbox = $this->GetBBoxTTF($txt,$dir); + for($j=0; $j < 4; ++$j) { + $bbox[$j*2]+= round($x); + $bbox[$j*2+1]+= round($y - ($h-$fh) - $yadj); + } + $aBoundingBox = $bbox; + + if( $debug ) { + // Draw a cross at the anchor point + $this->PushColor('red'); + $this->Line($ox-25,$oy,$ox+25,$oy); + $this->Line($ox,$oy-25,$ox,$oy+25); + $this->PopColor(); + } + + } + } + + function StrokeText($x,$y,$txt,$dir=0,$paragraph_align="left",$debug=false) { + + $x = round($x); + $y = round($y); + + // Do special language encoding + $txt = $this->langconv->Convert($txt,$this->font_family); + + if( !is_numeric($dir) ) { + JpGraphError::RaiseL(25094);//(" Direction for text most be given as an angle between 0 and 90."); + } + + if( $this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2+1) { + $this->_StrokeBuiltinFont($x,$y,$txt,$dir,$paragraph_align,$boundingbox,$debug); + } + elseif( $this->font_family >= _FIRST_FONT && $this->font_family <= _LAST_FONT) { + $this->_StrokeTTF($x,$y,$txt,$dir,$paragraph_align,$boundingbox,$debug); + } + else { + JpGraphError::RaiseL(25095);//(" Unknown font font family specification. "); + } + return $boundingbox; + } + + function SetMargin($lm,$rm,$tm,$bm) { + + $this->left_margin=$lm; + $this->right_margin=$rm; + $this->top_margin=$tm; + $this->bottom_margin=$bm; + + $this->plotwidth = $this->width - $this->left_margin - $this->right_margin; + $this->plotheight = $this->height - $this->top_margin - $this->bottom_margin; + + if( $this->width > 0 && $this->height > 0 ) { + if( $this->plotwidth < 0 || $this->plotheight < 0 ) { + JpGraphError::RaiseL(25130, $this->plotwidth, $this->plotheight); + //JpGraphError::raise("To small plot area. ($lm,$rm,$tm,$bm : $this->plotwidth x $this->plotheight). With the given image size and margins there is to little space left for the plot. Increase the plot size or reduce the margins."); + } + } + } + + function SetTransparent($color) { + imagecolortransparent ($this->img,$this->rgb->allocate($color)); + } + + function SetColor($color,$aAlpha=0) { + $this->current_color_name = $color; + $this->current_color=$this->rgb->allocate($color,$aAlpha); + if( $this->current_color == -1 ) { + $tc=imagecolorstotal($this->img); + JpGraphError::RaiseL(25096); + //("Can't allocate any more colors. Image has already allocated maximum of <b>$tc colors</b>. This might happen if you have anti-aliasing turned on together with a background image or perhaps gradient fill since this requires many, many colors. Try to turn off anti-aliasing. If there is still a problem try downgrading the quality of the background image to use a smaller pallete to leave some entries for your graphs. You should try to limit the number of colors in your background image to 64. If there is still problem set the constant DEFINE(\"USE_APPROX_COLORS\",true); in jpgraph.php This will use approximative colors when the palette is full. Unfortunately there is not much JpGraph can do about this since the palette size is a limitation of current graphic format and what the underlying GD library suppports."); + } + return $this->current_color; + } + + function PushColor($color) { + if( $color != "" ) { + $this->colorstack[$this->colorstackidx]=$this->current_color_name; + $this->colorstack[$this->colorstackidx+1]=$this->current_color; + $this->colorstackidx+=2; + $this->SetColor($color); + } + else { + JpGraphError::RaiseL(25097);//("Color specified as empty string in PushColor()."); + } + } + + function PopColor() { + if( $this->colorstackidx < 1 ) { + JpGraphError::RaiseL(25098);//(" Negative Color stack index. Unmatched call to PopColor()"); + } + $this->current_color=$this->colorstack[--$this->colorstackidx]; + $this->current_color_name=$this->colorstack[--$this->colorstackidx]; + } + + + function SetLineWeight($weight) { + $old = $this->line_weight; + imagesetthickness($this->img,$weight); + $this->line_weight = $weight; + return $old; + } + + function SetStartPoint($x,$y) { + $this->lastx=round($x); + $this->lasty=round($y); + } + + function Arc($cx,$cy,$w,$h,$s,$e) { + // GD Arc doesn't like negative angles + while( $s < 0) $s += 360; + while( $e < 0) $e += 360; + imagearc($this->img,round($cx),round($cy),round($w),round($h),$s,$e,$this->current_color); + } + + function FilledArc($xc,$yc,$w,$h,$s,$e,$style='') { + $s = round($s); + $e = round($e); + while( $s < 0 ) $s += 360; + while( $e < 0 ) $e += 360; + if( $style=='' ) + $style=IMG_ARC_PIE; + if( abs($s-$e) > 0 ) { + imagefilledarc($this->img,round($xc),round($yc),round($w),round($h),$s,$e,$this->current_color,$style); +// $this->DrawImageSmoothArc($this->img,round($xc),round($yc),round($w),round($h),$s,$e,$this->current_color,$style); + } + } + + function FilledCakeSlice($cx,$cy,$w,$h,$s,$e) { + $this->CakeSlice($cx,$cy,$w,$h,$s,$e,$this->current_color_name); + } + + function CakeSlice($xc,$yc,$w,$h,$s,$e,$fillcolor="",$arccolor="") { + $s = round($s); $e = round($e); + $w = round($w); $h = round($h); + $xc = round($xc); $yc = round($yc); + if( $s == $e ) { + // A full circle. We draw this a plain circle + $this->PushColor($fillcolor); + imagefilledellipse($this->img,$xc,$yc,2*$w,2*$h,$this->current_color); + + // If antialiasing is used then we often don't have any color no the surrounding + // arc. So, we need to check for this special case so we don't send an empty + // color to the push function. In this case we use the fill color for the arc as well + if( $arccolor != '' ) { + $this->PopColor(); + $this->PushColor($arccolor); + } + imageellipse($this->img,$xc,$yc,2*$w,2*$h,$this->current_color); + $this->Line($xc,$yc,cos($s*M_PI/180)*$w+$xc,$yc+sin($s*M_PI/180)*$h); + $this->PopColor(); + } + else { + $this->PushColor($fillcolor); + $this->FilledArc($xc,$yc,2*$w,2*$h,$s,$e); + $this->PopColor(); + if( $arccolor != "" ) { + $this->PushColor($arccolor); + // We add 2 pixels to make the Arc() better aligned with + // the filled arc. + imagefilledarc($this->img,$xc,$yc,2*$w,2*$h,$s,$e,$this->current_color,IMG_ARC_NOFILL | IMG_ARC_EDGED ) ; + $this->PopColor(); + } + } + } + + function Ellipse($xc,$yc,$w,$h) { + $this->Arc($xc,$yc,$w,$h,0,360); + } + + function Circle($xc,$yc,$r) { + imageellipse($this->img,round($xc),round($yc),$r*2,$r*2,$this->current_color); +// $this->DrawImageSmoothArc($this->img,round($xc),round($yc),$r*2+1,$r*2+1,0,360,$this->current_color); +// $this->imageSmoothCircle($this->img, round($xc),round($yc), $r*2+1, $this->current_color); + } + + function FilledCircle($xc,$yc,$r) { + imagefilledellipse($this->img,round($xc),round($yc),2*$r,2*$r,$this->current_color); +// $this->DrawImageSmoothArc($this->img, round($xc), round($yc), 2*$r, 2*$r, 0, 360, $this->current_color); + } + + // Linear Color InterPolation + function lip($f,$t,$p) { + $p = round($p,1); + $r = $f[0] + ($t[0]-$f[0])*$p; + $g = $f[1] + ($t[1]-$f[1])*$p; + $b = $f[2] + ($t[2]-$f[2])*$p; + return array($r,$g,$b); + } + + // Set line style dashed, dotted etc + function SetLineStyle($s) { + if( is_numeric($s) ) { + if( $s<1 || $s>4 ) { + JpGraphError::RaiseL(25101,$s);//(" Illegal numeric argument to SetLineStyle(): ($s)"); + } + } + elseif( is_string($s) ) { + if( $s == "solid" ) $s=1; + elseif( $s == "dotted" ) $s=2; + elseif( $s == "dashed" ) $s=3; + elseif( $s == "longdashed" ) $s=4; + else { + JpGraphError::RaiseL(25102,$s);//(" Illegal string argument to SetLineStyle(): $s"); + } + } + else { + JpGraphError::RaiseL(25103,$s);//(" Illegal argument to SetLineStyle $s"); + } + $old = $this->line_style; + $this->line_style=$s; + return $old; + } + + // Same as Line but take the line_style into account + function StyleLine($x1,$y1,$x2,$y2,$aStyle='', $from_grid_class = false) { + if( $this->line_weight <= 0 ) return; + + if( $aStyle === '' ) { + $aStyle = $this->line_style; + } + + $dashed_line_method = 'DashedLine'; + if ($from_grid_class) { + $dashed_line_method = 'DashedLineForGrid'; + } + + // Add error check since dashed line will only work if anti-alias is disabled + // this is a limitation in GD + + if( $aStyle == 1 ) { + // Solid style. We can handle anti-aliasing for this + $this->Line($x1,$y1,$x2,$y2); + } + else { + // Since the GD routines doesn't handle AA for styled line + // we have no option than to turn it off to get any lines at + // all if the weight > 1 + $oldaa = $this->GetAntiAliasing(); + if( $oldaa && $this->line_weight > 1 ) { + $this->SetAntiAliasing(false); + } + + switch( $aStyle ) { + case 2: // Dotted + $this->$dashed_line_method($x1,$y1,$x2,$y2,2,6); + break; + case 3: // Dashed + $this->$dashed_line_method($x1,$y1,$x2,$y2,5,9); + break; + case 4: // Longdashes + $this->$dashed_line_method($x1,$y1,$x2,$y2,9,13); + break; + default: + JpGraphError::RaiseL(25104,$this->line_style);//(" Unknown line style: $this->line_style "); + break; + } + if( $oldaa ) { + $this->SetAntiAliasing(true); + } + } + } + + function DashedLine($x1,$y1,$x2,$y2,$dash_length=1,$dash_space=4) { + + if( $this->line_weight <= 0 ) return; + + // Add error check to make sure anti-alias is not enabled. + // Dashed line does not work with anti-alias enabled. This + // is a limitation in GD. + if( $this->use_anti_aliasing ) { +// JpGraphError::RaiseL(25129); // Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines. + } + + $x1 = round($x1); + $x2 = round($x2); + $y1 = round($y1); + $y2 = round($y2); + + $dash_length *= SUPERSAMPLING_SCALE; + $dash_space *= SUPERSAMPLING_SCALE; + + $style = array_fill(0,$dash_length,$this->current_color); + $style = array_pad($style,$dash_space,IMG_COLOR_TRANSPARENT); + imagesetstyle($this->img, $style); + imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED); + + $this->lastx = $x2; + $this->lasty = $y2; + } + + function DashedLineForGrid($x1,$y1,$x2,$y2,$dash_length=1,$dash_space=4) { + + if( $this->line_weight <= 0 ) return; + + // Add error check to make sure anti-alias is not enabled. + // Dashed line does not work with anti-alias enabled. This + // is a limitation in GD. + if( $this->use_anti_aliasing ) { +// JpGraphError::RaiseL(25129); // Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines. + } + + $x1 = round($x1); + $x2 = round($x2); + $y1 = round($y1); + $y2 = round($y2); + + /* + $dash_length *= $this->scale; + $dash_space *= $this->scale; + */ + + $dash_length = 2; + $dash_length = 4; + imagesetthickness($this->img, 1); + $style = array_fill(0,$dash_length, $this->current_color); //hexdec('CCCCCC')); + $style = array_pad($style,$dash_space,IMG_COLOR_TRANSPARENT); + imagesetstyle($this->img, $style); + imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED); + + $this->lastx = $x2; + $this->lasty = $y2; + } + + function Line($x1,$y1,$x2,$y2) { + + if( $this->line_weight <= 0 ) return; + + $x1 = round($x1); + $x2 = round($x2); + $y1 = round($y1); + $y2 = round($y2); + + imageline($this->img,$x1,$y1,$x2,$y2,$this->current_color); +// $this->DrawLine($this->img, $x1, $y1, $x2, $y2, $this->line_weight, $this->current_color); + $this->lastx=$x2; + $this->lasty=$y2; + } + + function Polygon($p,$closed=FALSE,$fast=FALSE) { + + if( $this->line_weight <= 0 ) return; + + $n=count($p); + $oldx = $p[0]; + $oldy = $p[1]; + if( $fast ) { + for( $i=2; $i < $n; $i+=2 ) { + imageline($this->img,$oldx,$oldy,$p[$i],$p[$i+1],$this->current_color); + $oldx = $p[$i]; + $oldy = $p[$i+1]; + } + if( $closed ) { + imageline($this->img,$p[$n*2-2],$p[$n*2-1],$p[0],$p[1],$this->current_color); + } + } + else { + for( $i=2; $i < $n; $i+=2 ) { + $this->StyleLine($oldx,$oldy,$p[$i],$p[$i+1]); + $oldx = $p[$i]; + $oldy = $p[$i+1]; + } + if( $closed ) { + $this->StyleLine($oldx,$oldy,$p[0],$p[1]); + } + } + } + + function FilledPolygon($pts) { + $n=count($pts); + if( $n == 0 ) { + JpGraphError::RaiseL(25105);//('NULL data specified for a filled polygon. Check that your data is not NULL.'); + } + for($i=0; $i < $n; ++$i) { + $pts[$i] = round($pts[$i]); + } + $old = $this->line_weight; + imagesetthickness($this->img,1); + imagefilledpolygon($this->img,$pts,count($pts)/2,$this->current_color); + $this->line_weight = $old; + imagesetthickness($this->img,$old); + } + + function Rectangle($xl,$yu,$xr,$yl) { + $this->Polygon(array($xl,$yu,$xr,$yu,$xr,$yl,$xl,$yl,$xl,$yu)); + } + + function FilledRectangle($xl,$yu,$xr,$yl) { + $this->FilledPolygon(array($xl,$yu,$xr,$yu,$xr,$yl,$xl,$yl)); + } + + function FilledRectangle2($xl,$yu,$xr,$yl,$color1,$color2,$style=1) { + // Fill a rectangle with lines of two colors + if( $style===1 ) { + // Horizontal stripe + if( $yl < $yu ) { + $t = $yl; $yl=$yu; $yu=$t; + } + for( $y=$yu; $y <= $yl; ++$y) { + $this->SetColor($color1); + $this->Line($xl,$y,$xr,$y); + ++$y; + $this->SetColor($color2); + $this->Line($xl,$y,$xr,$y); + } + } + else { + if( $xl < $xl ) { + $t = $xl; $xl=$xr; $xr=$t; + } + for( $x=$xl; $x <= $xr; ++$x) { + $this->SetColor($color1); + $this->Line($x,$yu,$x,$yl); + ++$x; + $this->SetColor($color2); + $this->Line($x,$yu,$x,$yl); + } + } + } + + function ShadowRectangle($xl,$yu,$xr,$yl,$fcolor=false,$shadow_width=4,$shadow_color='darkgray',$useAlpha=true) { + // This is complicated by the fact that we must also handle the case where + // the reactangle has no fill color + $xl = floor($xl); + $yu = floor($yu); + $xr = floor($xr); + $yl = floor($yl); + $this->PushColor($shadow_color); + $shadowAlpha=0; + $this->SetLineWeight(1); + $this->SetLineStyle('solid'); + $basecolor = $this->rgb->Color($shadow_color); + $shadow_color = array($basecolor[0],$basecolor[1],$basecolor[2],); + for( $i=0; $i < $shadow_width; ++$i ) { + $this->SetColor($shadow_color,$shadowAlpha); + $this->Line($xr-$shadow_width+$i, $yu+$shadow_width, + $xr-$shadow_width+$i, $yl-$shadow_width-1+$i); + $this->Line($xl+$shadow_width, $yl-$shadow_width+$i, + $xr-$shadow_width+$i, $yl-$shadow_width+$i); + if( $useAlpha ) $shadowAlpha += 1.0/$shadow_width; + } + + $this->PopColor(); + if( $fcolor==false ) { + $this->Rectangle($xl,$yu,$xr-$shadow_width-1,$yl-$shadow_width-1); + } + else { + $this->PushColor($fcolor); + $this->FilledRectangle($xl,$yu,$xr-$shadow_width-1,$yl-$shadow_width-1); + $this->PopColor(); + $this->Rectangle($xl,$yu,$xr-$shadow_width-1,$yl-$shadow_width-1); + } + } + + function FilledRoundedRectangle($xt,$yt,$xr,$yl,$r=5) { + if( $r==0 ) { + $this->FilledRectangle($xt,$yt,$xr,$yl); + return; + } + + // To avoid overlapping fillings (which will look strange + // when alphablending is enabled) we have no choice but + // to fill the five distinct areas one by one. + + // Center square + $this->FilledRectangle($xt+$r,$yt+$r,$xr-$r,$yl-$r); + // Top band + $this->FilledRectangle($xt+$r,$yt,$xr-$r,$yt+$r); + // Bottom band + $this->FilledRectangle($xt+$r,$yl-$r,$xr-$r,$yl); + // Left band + $this->FilledRectangle($xt,$yt+$r,$xt+$r,$yl-$r); + // Right band + $this->FilledRectangle($xr-$r,$yt+$r,$xr,$yl-$r); + + // Topleft & Topright arc + $this->FilledArc($xt+$r,$yt+$r,$r*2,$r*2,180,270); + $this->FilledArc($xr-$r,$yt+$r,$r*2,$r*2,270,360); + + // Bottomleft & Bottom right arc + $this->FilledArc($xt+$r,$yl-$r,$r*2,$r*2,90,180); + $this->FilledArc($xr-$r,$yl-$r,$r*2,$r*2,0,90); + + } + + function RoundedRectangle($xt,$yt,$xr,$yl,$r=5) { + + if( $r==0 ) { + $this->Rectangle($xt,$yt,$xr,$yl); + return; + } + + // Top & Bottom line + $this->Line($xt+$r,$yt,$xr-$r,$yt); + $this->Line($xt+$r,$yl,$xr-$r,$yl); + + // Left & Right line + $this->Line($xt,$yt+$r,$xt,$yl-$r); + $this->Line($xr,$yt+$r,$xr,$yl-$r); + + // Topleft & Topright arc + $this->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270); + $this->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360); + + // Bottomleft & Bottomright arc + $this->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180); + $this->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90); + } + + function FilledBevel($x1,$y1,$x2,$y2,$depth=2,$color1='white@0.4',$color2='darkgray@0.4') { + $this->FilledRectangle($x1,$y1,$x2,$y2); + $this->Bevel($x1,$y1,$x2,$y2,$depth,$color1,$color2); + } + + function Bevel($x1,$y1,$x2,$y2,$depth=2,$color1='white@0.4',$color2='black@0.5') { + $this->PushColor($color1); + for( $i=0; $i < $depth; ++$i ) { + $this->Line($x1+$i,$y1+$i,$x1+$i,$y2-$i); + $this->Line($x1+$i,$y1+$i,$x2-$i,$y1+$i); + } + $this->PopColor(); + + $this->PushColor($color2); + for( $i=0; $i < $depth; ++$i ) { + $this->Line($x1+$i,$y2-$i,$x2-$i,$y2-$i); + $this->Line($x2-$i,$y1+$i,$x2-$i,$y2-$i-1); + } + $this->PopColor(); + } + + function StyleLineTo($x,$y) { + $this->StyleLine($this->lastx,$this->lasty,$x,$y); + $this->lastx=$x; + $this->lasty=$y; + } + + function LineTo($x,$y) { + $this->Line($this->lastx,$this->lasty,$x,$y); + $this->lastx=$x; + $this->lasty=$y; + } + + function Point($x,$y) { + imagesetpixel($this->img,round($x),round($y),$this->current_color); + } + + function Fill($x,$y) { + imagefill($this->img,round($x),round($y),$this->current_color); + } + + function FillToBorder($x,$y,$aBordColor) { + $bc = $this->rgb->allocate($aBordColor); + if( $bc == -1 ) { + JpGraphError::RaiseL(25106);//('Image::FillToBorder : Can not allocate more colors'); + } + imagefilltoborder($this->img,round($x),round($y),$bc,$this->current_color); + } + + function SetExpired($aFlg=true) { + $this->expired = $aFlg; + } + + // Generate image header + function Headers() { + + // In case we are running from the command line with the client version of + // PHP we can't send any headers. + $sapi = php_sapi_name(); + if( $sapi == 'cli' ) return; + + // These parameters are set by headers_sent() but they might cause + // an undefined variable error unless they are initilized + $file=''; + $lineno=''; + if( headers_sent($file,$lineno) ) { + $file=basename($file); + $t = new ErrMsgText(); + $msg = $t->Get(10,$file,$lineno); + die($msg); + } + + if ($this->expired) { + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); + header("Cache-Control: no-cache, must-revalidate"); + header("Pragma: no-cache"); + } + header("Content-type: image/$this->img_format"); + } + + // Adjust image quality for formats that allow this + function SetQuality($q) { + $this->quality = $q; + } + + // Stream image to browser or to file + function Stream($aFile="") { + $this->DoSupersampling(); + + $func="image".$this->img_format; + if( $this->img_format=="jpeg" && $this->quality != null ) { + $res = @$func($this->img,$aFile,$this->quality); + } + else { + if( $aFile != "" ) { + $res = @$func($this->img,$aFile); + if( !$res ) { + JpGraphError::RaiseL(25107,$aFile);//("Can't write to file '$aFile'. Check that the process running PHP has enough permission."); + } + } + else { + $res = @$func($this->img); + if( !$res ) { + JpGraphError::RaiseL(25108);//("Can't stream image. This is most likely due to a faulty PHP/GD setup. Try to recompile PHP and use the built-in GD library that comes with PHP."); + } + + } + } + } + + // Do SuperSampling using $scale + function DoSupersampling() { + if (SUPERSAMPLING_SCALE <= 1) { + return $this->img; + } + + $dst_img = @imagecreatetruecolor($this->original_width, $this->original_height); + imagecopyresampled($dst_img, $this->img, 0, 0, 0, 0, $this->original_width, $this->original_height, $this->width, $this->height); + $this->Destroy(); + return $this->img = $dst_img; + } + + // Clear resources used by image (this is normally not used since all resources are/should be + // returned when the script terminates + function Destroy() { + imagedestroy($this->img); + } + + // Specify image format. Note depending on your installation + // of PHP not all formats may be supported. + function SetImgFormat($aFormat,$aQuality=75) { + $this->quality = $aQuality; + $aFormat = strtolower($aFormat); + $tst = true; + $supported = imagetypes(); + if( $aFormat=="auto" ) { + if( $supported & IMG_PNG ) $this->img_format="png"; + elseif( $supported & IMG_JPG ) $this->img_format="jpeg"; + elseif( $supported & IMG_GIF ) $this->img_format="gif"; + elseif( $supported & IMG_WBMP ) $this->img_format="wbmp"; + elseif( $supported & IMG_XPM ) $this->img_format="xpm"; + else { + JpGraphError::RaiseL(25109);//("Your PHP (and GD-lib) installation does not appear to support any known graphic formats. You need to first make sure GD is compiled as a module to PHP. If you also want to use JPEG images you must get the JPEG library. Please see the PHP docs for details."); + } + return true; + } + else { + if( $aFormat=="jpeg" || $aFormat=="png" || $aFormat=="gif" ) { + if( $aFormat=="jpeg" && !($supported & IMG_JPG) ) $tst=false; + elseif( $aFormat=="png" && !($supported & IMG_PNG) ) $tst=false; + elseif( $aFormat=="gif" && !($supported & IMG_GIF) ) $tst=false; + elseif( $aFormat=="wbmp" && !($supported & IMG_WBMP) ) $tst=false; + elseif( $aFormat=="xpm" && !($supported & IMG_XPM) ) $tst=false; + else { + $this->img_format=$aFormat; + return true; + } + } + else { + $tst=false; + } + if( !$tst ) { + JpGraphError::RaiseL(25110,$aFormat);//(" Your PHP installation does not support the chosen graphic format: $aFormat"); + } + } + } + + /** + * Draw Line + */ + function DrawLine($im, $x1, $y1, $x2, $y2, $weight, $color) { + if ($weight == 1) { + return imageline($im,$x1,$y1,$x2,$y2,$color); + } + + $angle=(atan2(($y1 - $y2), ($x2 - $x1))); + + $dist_x = $weight * (sin($angle)) / 2; + $dist_y = $weight * (cos($angle)) / 2; + + $p1x=ceil(($x1 + $dist_x)); + $p1y=ceil(($y1 + $dist_y)); + $p2x=ceil(($x2 + $dist_x)); + $p2y=ceil(($y2 + $dist_y)); + $p3x=ceil(($x2 - $dist_x)); + $p3y=ceil(($y2 - $dist_y)); + $p4x=ceil(($x1 - $dist_x)); + $p4y=ceil(($y1 - $dist_y)); + + $array=array($p1x,$p1y,$p2x,$p2y,$p3x,$p3y,$p4x,$p4y); + imagefilledpolygon ( $im, $array, (count($array)/2), $color ); + + // for antialias + imageline($im, $p1x, $p1y, $p2x, $p2y, $color); + imageline($im, $p3x, $p3y, $p4x, $p4y, $color); + return; + + + + return imageline($this->img,$x1,$y1,$x2,$y2,$this->current_color); + $weight = 8; + if ($weight <= 1) { + return imageline($this->img,$x1,$y1,$x2,$y2,$this->current_color); + } + + $pts = array(); + + $weight /= 2; + + if ($y2 - $y1 == 0) { + // x line + $pts = array(); + $pts[] = $x1; $pts[] = $y1 - $weight; + $pts[] = $x1; $pts[] = $y1 + $weight; + $pts[] = $x2; $pts[] = $y2 + $weight; + $pts[] = $x2; $pts[] = $y2 - $weight; + + } elseif ($x2 - $x1 == 0) { + // y line + $pts = array(); + $pts[] = $x1 - $weight; $pts[] = $y1; + $pts[] = $x1 + $weight; $pts[] = $y1; + $pts[] = $x2 + $weight; $pts[] = $y2; + $pts[] = $x2 - $weight; $pts[] = $y2; + + } else { + + var_dump($x1, $x2, $y1, $y2); + $length = sqrt(pow($x2 - $x1, 2) + pow($y2 - $y1, 2)); + var_dump($length);exit; + exit; + +/* + $lean = ($y2 - $y1) / ($x2 - $x1); + $lean2 = -1 / $lean; + $sin = $lean / ($y2 - $y1); + $cos = $lean / ($x2 - $x1); + + $pts[] = $x1 + (-$weight * $sin); $pts[] = $y1 + (-$weight * $cos); + $pts[] = $x1 + (+$weight * $sin); $pts[] = $y1 + (+$weight * $cos); + $pts[] = $x2 + (+$weight * $sin); $pts[] = $y2 + (+$weight * $cos); + $pts[] = $x2 + (-$weight * $sin); $pts[] = $y2 + (-$weight * $cos); +*/ + } + +//print_r($pts);exit; + if (count($pts)/2 < 3) { + return; + } + + imagesetthickness($im, 1); + imagefilledpolygon($im, $pts,count($pts)/2, $color); + + + $weight *= 2; + +// $this->DrawImageSmoothArc($im, $x1, $y1, $weight, $weight, 0, 360, $color); +// $this->DrawImageSmoothArc($im, $x2, $y2, $weight, $weight, 0, 360, $color); + } + + + function DrawImageSmoothArc($im, $xc, $yc, $w, $h, $s, $e, $color, $style = null) { + $tmp = $s; + $s = (360 - $e) / 180 * M_PI; + $e = (360 - $tmp) / 180 * M_PI; + return imageSmoothArc($im, round($xc), round($yc), round($w), round($h), $this->CreateColorForImageSmoothArc($color), $s, $e); + } + + function CreateColorForImageSmoothArc($color) { + $alpha = $color >> 24 & 0xFF; + $red = $color >> 16 & 0xFF; + $green = $color >> 8 & 0xFF; + $blue = $color & 0xFF; + +//var_dump($alpha, $red, $green, $blue);exit; + + return array($red, $green, $blue, $alpha); + } + + function imageSmoothCircle( &$img, $cx, $cy, $cr, $color ) { + $ir = $cr; + $ix = 0; + $iy = $ir; + $ig = 2 * $ir - 3; + $idgr = -6; + $idgd = 4 * $ir - 10; + $fill = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 0 ); + imageLine( $img, $cx + $cr - 1, $cy, $cx, $cy, $fill ); + imageLine( $img, $cx - $cr + 1, $cy, $cx - 1, $cy, $fill ); + imageLine( $img, $cx, $cy + $cr - 1, $cx, $cy + 1, $fill ); + imageLine( $img, $cx, $cy - $cr + 1, $cx, $cy - 1, $fill ); + $draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 42 ); + imageSetPixel( $img, $cx + $cr, $cy, $draw ); + imageSetPixel( $img, $cx - $cr, $cy, $draw ); + imageSetPixel( $img, $cx, $cy + $cr, $draw ); + imageSetPixel( $img, $cx, $cy - $cr, $draw ); + while ( $ix <= $iy - 2 ) { + if ( $ig < 0 ) { + $ig += $idgd; + $idgd -= 8; + $iy--; + } else { + $ig += $idgr; + $idgd -= 4; + } + $idgr -= 4; + $ix++; + imageLine( $img, $cx + $ix, $cy + $iy - 1, $cx + $ix, $cy + $ix, $fill ); + imageLine( $img, $cx + $ix, $cy - $iy + 1, $cx + $ix, $cy - $ix, $fill ); + imageLine( $img, $cx - $ix, $cy + $iy - 1, $cx - $ix, $cy + $ix, $fill ); + imageLine( $img, $cx - $ix, $cy - $iy + 1, $cx - $ix, $cy - $ix, $fill ); + imageLine( $img, $cx + $iy - 1, $cy + $ix, $cx + $ix, $cy + $ix, $fill ); + imageLine( $img, $cx + $iy - 1, $cy - $ix, $cx + $ix, $cy - $ix, $fill ); + imageLine( $img, $cx - $iy + 1, $cy + $ix, $cx - $ix, $cy + $ix, $fill ); + imageLine( $img, $cx - $iy + 1, $cy - $ix, $cx - $ix, $cy - $ix, $fill ); + $filled = 0; + for ( $xx = $ix - 0.45; $xx < $ix + 0.5; $xx += 0.2 ) { + for ( $yy = $iy - 0.45; $yy < $iy + 0.5; $yy += 0.2 ) { + if ( sqrt( pow( $xx, 2 ) + pow( $yy, 2 ) ) < $cr ) $filled += 4; + } + } + $draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], ( 100 - $filled ) ); + imageSetPixel( $img, $cx + $ix, $cy + $iy, $draw ); + imageSetPixel( $img, $cx + $ix, $cy - $iy, $draw ); + imageSetPixel( $img, $cx - $ix, $cy + $iy, $draw ); + imageSetPixel( $img, $cx - $ix, $cy - $iy, $draw ); + imageSetPixel( $img, $cx + $iy, $cy + $ix, $draw ); + imageSetPixel( $img, $cx + $iy, $cy - $ix, $draw ); + imageSetPixel( $img, $cx - $iy, $cy + $ix, $draw ); + imageSetPixel( $img, $cx - $iy, $cy - $ix, $draw ); + } + } + + function __get($name) { + + if (strpos($name, 'raw_') !== false) { + // if $name == 'raw_left_margin' , return $this->_left_margin; + $variable_name = '_' . str_replace('raw_', '', $name); + return $this->$variable_name; + } + + $variable_name = '_' . $name; + + if (isset($this->$variable_name)) { + return $this->$variable_name * SUPERSAMPLING_SCALE; + } else { + JpGraphError::RaiseL('25132', $name); + } + } + + function __set($name, $value) { + $this->{'_'.$name} = $value; + } + +} // CLASS + +//=================================================== +// CLASS RotImage +// Description: Exactly as Image but draws the image at +// a specified angle around a specified rotation point. +//=================================================== +class RotImage extends Image { + public $a=0; + public $dx=0,$dy=0,$transx=0,$transy=0; + private $m=array(); + + function __construct($aWidth,$aHeight,$a=0,$aFormat=DEFAULT_GFORMAT,$aSetAutoMargin=true) { + parent::__construct($aWidth,$aHeight,$aFormat,$aSetAutoMargin); + $this->dx=$this->left_margin+$this->plotwidth/2; + $this->dy=$this->top_margin+$this->plotheight/2; + $this->SetAngle($a); + } + + function SetCenter($dx,$dy) { + $old_dx = $this->dx; + $old_dy = $this->dy; + $this->dx=$dx; + $this->dy=$dy; + $this->SetAngle($this->a); + return array($old_dx,$old_dy); + } + + function SetTranslation($dx,$dy) { + $old = array($this->transx,$this->transy); + $this->transx = $dx; + $this->transy = $dy; + return $old; + } + + function UpdateRotMatrice() { + $a = $this->a; + $a *= M_PI/180; + $sa=sin($a); $ca=cos($a); + // Create the rotation matrix + $this->m[0][0] = $ca; + $this->m[0][1] = -$sa; + $this->m[0][2] = $this->dx*(1-$ca) + $sa*$this->dy ; + $this->m[1][0] = $sa; + $this->m[1][1] = $ca; + $this->m[1][2] = $this->dy*(1-$ca) - $sa*$this->dx ; + } + + function SetAngle($a) { + $tmp = $this->a; + $this->a = $a; + $this->UpdateRotMatrice(); + return $tmp; + } + + function Circle($xc,$yc,$r) { + list($xc,$yc) = $this->Rotate($xc,$yc); + parent::Circle($xc,$yc,$r); + } + + function FilledCircle($xc,$yc,$r) { + list($xc,$yc) = $this->Rotate($xc,$yc); + parent::FilledCircle($xc,$yc,$r); + } + + + function Arc($xc,$yc,$w,$h,$s,$e) { + list($xc,$yc) = $this->Rotate($xc,$yc); + $s += $this->a; + $e += $this->a; + parent::Arc($xc,$yc,$w,$h,$s,$e); + } + + function FilledArc($xc,$yc,$w,$h,$s,$e,$style='') { + list($xc,$yc) = $this->Rotate($xc,$yc); + $s += $this->a; + $e += $this->a; + parent::FilledArc($xc,$yc,$w,$h,$s,$e); + } + + function SetMargin($lm,$rm,$tm,$bm) { + parent::SetMargin($lm,$rm,$tm,$bm); + $this->dx=$this->left_margin+$this->plotwidth/2; + $this->dy=$this->top_margin+$this->plotheight/2; + $this->UpdateRotMatrice(); + } + + function Rotate($x,$y) { + // Optimization. Ignore rotation if Angle==0 || Angle==360 + if( $this->a == 0 || $this->a == 360 ) { + return array($x + $this->transx, $y + $this->transy ); + } + else { + $x1=round($this->m[0][0]*$x + $this->m[0][1]*$y,1) + $this->m[0][2] + $this->transx; + $y1=round($this->m[1][0]*$x + $this->m[1][1]*$y,1) + $this->m[1][2] + $this->transy; + return array($x1,$y1); + } + } + + function CopyMerge($fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth=-1,$fromHeight=-1,$aMix=100) { + list($toX,$toY) = $this->Rotate($toX,$toY); + parent::CopyMerge($fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth,$fromHeight,$aMix); + + } + + function ArrRotate($pnts) { + $n = count($pnts)-1; + for($i=0; $i < $n; $i+=2) { + list ($x,$y) = $this->Rotate($pnts[$i],$pnts[$i+1]); + $pnts[$i] = $x; $pnts[$i+1] = $y; + } + return $pnts; + } + + function DashedLine($x1,$y1,$x2,$y2,$dash_length=1,$dash_space=4) { + list($x1,$y1) = $this->Rotate($x1,$y1); + list($x2,$y2) = $this->Rotate($x2,$y2); + parent::DashedLine($x1,$y1,$x2,$y2,$dash_length,$dash_space); + } + + function Line($x1,$y1,$x2,$y2) { + list($x1,$y1) = $this->Rotate($x1,$y1); + list($x2,$y2) = $this->Rotate($x2,$y2); + parent::Line($x1,$y1,$x2,$y2); + } + + function Rectangle($x1,$y1,$x2,$y2) { + // Rectangle uses Line() so it will be rotated through that call + parent::Rectangle($x1,$y1,$x2,$y2); + } + + function FilledRectangle($x1,$y1,$x2,$y2) { + if( $y1==$y2 || $x1==$x2 ) + $this->Line($x1,$y1,$x2,$y2); + else + $this->FilledPolygon(array($x1,$y1,$x2,$y1,$x2,$y2,$x1,$y2)); + } + + function Polygon($pnts,$closed=FALSE,$fast=FALSE) { + // Polygon uses Line() so it will be rotated through that call unless + // fast drawing routines are used in which case a rotate is needed + if( $fast ) { + parent::Polygon($this->ArrRotate($pnts)); + } + else { + parent::Polygon($pnts,$closed,$fast); + } + } + + function FilledPolygon($pnts) { + parent::FilledPolygon($this->ArrRotate($pnts)); + } + + function Point($x,$y) { + list($xp,$yp) = $this->Rotate($x,$y); + parent::Point($xp,$yp); + } + + function StrokeText($x,$y,$txt,$dir=0,$paragraph_align="left",$debug=false) { + list($xp,$yp) = $this->Rotate($x,$y); + return parent::StrokeText($xp,$yp,$txt,$dir,$paragraph_align,$debug); + } +} + +//======================================================================= +// CLASS ImgStreamCache +// Description: Handle caching of graphs to files. All image output goes +// through this class +//======================================================================= +class ImgStreamCache { + private $cache_dir, $timeout=0; // Infinite timeout + //--------------- + // CONSTRUCTOR + function __construct($aCacheDir=CACHE_DIR) { + $this->cache_dir = $aCacheDir; + } + + //--------------- + // PUBLIC METHODS + + // Specify a timeout (in minutes) for the file. If the file is older then the + // timeout value it will be overwritten with a newer version. + // If timeout is set to 0 this is the same as infinite large timeout and if + // timeout is set to -1 this is the same as infinite small timeout + function SetTimeout($aTimeout) { + $this->timeout=$aTimeout; + } + + // Output image to browser and also write it to the cache + function PutAndStream($aImage,$aCacheFileName,$aInline,$aStrokeFileName) { + + // Check if we should always stroke the image to a file + if( _FORCE_IMGTOFILE ) { + $aStrokeFileName = _FORCE_IMGDIR.GenImgName(); + } + + if( $aStrokeFileName != '' ) { + + if( $aStrokeFileName == 'auto' ) { + $aStrokeFileName = GenImgName(); + } + + if( file_exists($aStrokeFileName) ) { + + // Wait for lock (to make sure no readers are trying to access the image) + $fd = fopen($aStrokeFileName,'w'); + $lock = flock($fd, LOCK_EX); + + // Since the image write routines only accepts a filename which must not + // exist we need to delete the old file first + if( !@unlink($aStrokeFileName) ) { + $lock = flock($fd, LOCK_UN); + JpGraphError::RaiseL(25111,$aStrokeFileName); + //(" Can't delete cached image $aStrokeFileName. Permission problem?"); + } + $aImage->Stream($aStrokeFileName); + $lock = flock($fd, LOCK_UN); + fclose($fd); + + } + else { + $aImage->Stream($aStrokeFileName); + } + + return; + } + + if( $aCacheFileName != '' && USE_CACHE) { + + $aCacheFileName = $this->cache_dir . $aCacheFileName; + if( file_exists($aCacheFileName) ) { + if( !$aInline ) { + // If we are generating image off-line (just writing to the cache) + // and the file exists and is still valid (no timeout) + // then do nothing, just return. + $diff=time()-filemtime($aCacheFileName); + if( $diff < 0 ) { + JpGraphError::RaiseL(25112,$aCacheFileName); + //(" Cached imagefile ($aCacheFileName) has file date in the future!!"); + } + if( $this->timeout>0 && ($diff <= $this->timeout*60) ) return; + } + + // Wait for lock (to make sure no readers are trying to access the image) + $fd = fopen($aCacheFileName,'w'); + $lock = flock($fd, LOCK_EX); + + if( !@unlink($aCacheFileName) ) { + $lock = flock($fd, LOCK_UN); + JpGraphError::RaiseL(25113,$aStrokeFileName); + //(" Can't delete cached image $aStrokeFileName. Permission problem?"); + } + $aImage->Stream($aCacheFileName); + $lock = flock($fd, LOCK_UN); + fclose($fd); + + } + else { + $this->MakeDirs(dirname($aCacheFileName)); + if( !is_writeable(dirname($aCacheFileName)) ) { + JpGraphError::RaiseL(25114,$aCacheFileName); + //('PHP has not enough permissions to write to the cache file '.$aCacheFileName.'. Please make sure that the user running PHP has write permission for this file if you wan to use the cache system with JpGraph.'); + } + $aImage->Stream($aCacheFileName); + } + + $res=true; + // Set group to specified + if( CACHE_FILE_GROUP != '' ) { + $res = @chgrp($aCacheFileName,CACHE_FILE_GROUP); + } + if( CACHE_FILE_MOD != '' ) { + $res = @chmod($aCacheFileName,CACHE_FILE_MOD); + } + if( !$res ) { + JpGraphError::RaiseL(25115,$aStrokeFileName); + //(" Can't set permission for cached image $aStrokeFileName. Permission problem?"); + } + + $aImage->Destroy(); + if( $aInline ) { + if ($fh = @fopen($aCacheFileName, "rb") ) { + $aImage->Headers(); + fpassthru($fh); + return; + } + else { + JpGraphError::RaiseL(25116,$aFile);//(" Cant open file from cache [$aFile]"); + } + } + } + elseif( $aInline ) { + $aImage->Headers(); + $aImage->Stream(); + return; + } + } + + function IsValid($aCacheFileName) { + $aCacheFileName = $this->cache_dir.$aCacheFileName; + if ( USE_CACHE && file_exists($aCacheFileName) ) { + $diff=time()-filemtime($aCacheFileName); + if( $this->timeout>0 && ($diff > $this->timeout*60) ) { + return false; + } + else { + return true; + } + } + else { + return false; + } + } + + function StreamImgFile($aImage,$aCacheFileName) { + $aCacheFileName = $this->cache_dir.$aCacheFileName; + if ( $fh = @fopen($aCacheFileName, 'rb') ) { + $lock = flock($fh, LOCK_SH); + $aImage->Headers(); + fpassthru($fh); + $lock = flock($fh, LOCK_UN); + fclose($fh); + return true; + } + else { + JpGraphError::RaiseL(25117,$aCacheFileName);//(" Can't open cached image \"$aCacheFileName\" for reading."); + } + } + + // Check if a given image is in cache and in that case + // pass it directly on to web browser. Return false if the + // image file doesn't exist or exists but is to old + function GetAndStream($aImage,$aCacheFileName) { + if( $this->Isvalid($aCacheFileName) ) { + $this->StreamImgFile($aImage,$aCacheFileName); + } + else { + return false; + } + } + + //--------------- + // PRIVATE METHODS + // Create all necessary directories in a path + function MakeDirs($aFile) { + $dirs = array(); + // In order to better work when open_basedir is enabled + // we do not create directories in the root path + while ( $aFile != '/' && !(file_exists($aFile)) ) { + $dirs[] = $aFile.'/'; + $aFile = dirname($aFile); + } + for ($i = sizeof($dirs)-1; $i>=0; $i--) { + if(! @mkdir($dirs[$i],0777) ) { + JpGraphError::RaiseL(25118,$aFile);//(" Can't create directory $aFile. Make sure PHP has write permission to this directory."); + } + // We also specify mode here after we have changed group. + // This is necessary if Apache user doesn't belong the + // default group and hence can't specify group permission + // in the previous mkdir() call + if( CACHE_FILE_GROUP != "" ) { + $res=true; + $res =@chgrp($dirs[$i],CACHE_FILE_GROUP); + $res = @chmod($dirs[$i],0777); + if( !$res ) { + JpGraphError::RaiseL(25119,$aFile);//(" Can't set permissions for $aFile. Permission problems?"); + } + } + } + return true; + } +} // CLASS Cache + +?> diff --git a/html/jpgraph/imageSmoothArc.php b/html/jpgraph/imageSmoothArc.php new file mode 100644 index 0000000..a1d581f --- /dev/null +++ b/html/jpgraph/imageSmoothArc.php @@ -0,0 +1,344 @@ +<?php + +/* + + Copyright (c) 2006-2008 Ulrich Mierendorff + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + Changelog: + version 1.1 + - improved the rendering speed by ~20% + + - Thanks to Matthias Mächler for fixing some small errors: + * uninitialized variables + * deprecated passing of $img reference in imageSmoothArc () + + version 1.0 + Release of rewritten script + +*/ + +function imageSmoothArcDrawSegment (&$img, $cx, $cy, $a, $b, $aaAngleX, $aaAngleY, $color, $start, $stop, $seg) +{ + // Originally written from scratch by Ulrich Mierendorff, 06/2006 + // Rewritten and improved, 04/2007, 07/2007 + + // Please do not use THIS function directly. Scroll down to imageSmoothArc(...). + + $fillColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], $color[3] ); + + $xStart = abs($a * cos($start)); + $yStart = abs($b * sin($start)); + $xStop = abs($a * cos($stop)); + $yStop = abs($b * sin($stop)); + $dxStart = 0; + $dyStart = 0; + $dxStop = 0; + $dyStop = 0; + if ($xStart != 0) + $dyStart = $yStart/$xStart; + if ($xStop != 0) + $dyStop = $yStop/$xStop; + if ($yStart != 0) + $dxStart = $xStart/$yStart; + if ($yStop != 0) + $dxStop = $xStop/$yStop; + if (abs($xStart) >= abs($yStart)) { + $aaStartX = true; + } else { + $aaStartX = false; + } + if ($xStop >= $yStop) { + $aaStopX = true; + } else { + $aaStopX = false; + } + //$xp = +1; $yp = -1; $xa = +1; $ya = 0; + for ( $x = 0; $x < $a; $x += 1 ) { + /*$y = $b * sqrt( 1 - ($x*$x)/($a*$a) ); + + $error = $y - (int)($y); + $y = (int)($y); + + $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error );*/ + + $_y1 = $dyStop*$x; + $_y2 = $dyStart*$x; + if ($xStart > $xStop) + { + $error1 = $_y1 - (int)($_y1); + $error2 = 1 - $_y2 + (int)$_y2; + $_y1 = $_y1-$error1; + $_y2 = $_y2+$error2; + } + else + { + $error1 = 1 - $_y1 + (int)$_y1; + $error2 = $_y2 - (int)($_y2); + $_y1 = $_y1+$error1; + $_y2 = $_y2-$error2; + } + /* + if ($aaStopX) + $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 ); + if ($aaStartX) + $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 ); + */ + + if ($seg == 0 || $seg == 2) + { + $i = $seg; + if (!($start > $i*M_PI/2 && $x > $xStart)) { + if ($i == 0) { + $xp = +1; $yp = -1; $xa = +1; $ya = 0; + } else { + $xp = -1; $yp = +1; $xa = 0; $ya = +1; + } + if ( $stop < ($i+1)*(M_PI/2) && $x <= $xStop ) { + $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 ); + $y1 = $_y1; if ($aaStopX) imageSetPixel($img, $cx+$xp*($x)+$xa, $cy+$yp*($y1+1)+$ya, $diffColor1); + + } else { + $y = $b * sqrt( 1 - ($x*$x)/($a*$a) ); + $error = $y - (int)($y); + $y = (int)($y); + $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error ); + $y1 = $y; if ($x < $aaAngleX ) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y1+1)+$ya, $diffColor); + } + if ($start > $i*M_PI/2 && $x <= $xStart) { + $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 ); + $y2 = $_y2; if ($aaStartX) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y2-1)+$ya, $diffColor2); + } else { + $y2 = 0; + } + if ($y2 <= $y1) imageLine($img, $cx+$xp*$x+$xa, $cy+$yp*$y1+$ya , $cx+$xp*$x+$xa, $cy+$yp*$y2+$ya, $fillColor); + } + } + + if ($seg == 1 || $seg == 3) + { + $i = $seg; + if (!($stop < ($i+1)*M_PI/2 && $x > $xStop)) { + if ($i == 1) { + $xp = -1; $yp = -1; $xa = 0; $ya = 0; + } else { + $xp = +1; $yp = +1; $xa = 1; $ya = 1; + } + if ( $start > $i*M_PI/2 && $x < $xStart ) { + $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 ); + $y1 = $_y2; if ($aaStartX) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y1+1)+$ya, $diffColor2); + + } else { + $y = $b * sqrt( 1 - ($x*$x)/($a*$a) ); + $error = $y - (int)($y); + $y = (int) $y; + $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error ); + $y1 = $y; if ($x < $aaAngleX ) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y1+1)+$ya, $diffColor); + } + if ($stop < ($i+1)*M_PI/2 && $x <= $xStop) { + $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 ); + $y2 = $_y1; if ($aaStopX) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y2-1)+$ya, $diffColor1); + } else { + $y2 = 0; + } + if ($y2 <= $y1) imageLine($img, $cx+$xp*$x+$xa, $cy+$yp*$y1+$ya, $cx+$xp*$x+$xa, $cy+$yp*$y2+$ya, $fillColor); + } + } + } + + ///YYYYY + + for ( $y = 0; $y < $b; $y += 1 ) { + /*$x = $a * sqrt( 1 - ($y*$y)/($b*$b) ); + + $error = $x - (int)($x); + $x = (int)($x); + + $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error ); + */ + $_x1 = $dxStop*$y; + $_x2 = $dxStart*$y; + if ($yStart > $yStop) + { + $error1 = $_x1 - (int)($_x1); + $error2 = 1 - $_x2 + (int)$_x2; + $_x1 = $_x1-$error1; + $_x2 = $_x2+$error2; + } + else + { + $error1 = 1 - $_x1 + (int)$_x1; + $error2 = $_x2 - (int)($_x2); + $_x1 = $_x1+$error1; + $_x2 = $_x2-$error2; + } +/* + if (!$aaStopX) + $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 ); + if (!$aaStartX) + $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 ); +*/ + + if ($seg == 0 || $seg == 2) + { + $i = $seg; + if (!($start > $i*M_PI/2 && $y > $yStop)) { + if ($i == 0) { + $xp = +1; $yp = -1; $xa = 1; $ya = 0; + } else { + $xp = -1; $yp = +1; $xa = 0; $ya = 1; + } + if ( $stop < ($i+1)*(M_PI/2) && $y <= $yStop ) { + $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 ); + $x1 = $_x1; if (!$aaStopX) imageSetPixel($img, $cx+$xp*($x1-1)+$xa, $cy+$yp*($y)+$ya, $diffColor1); + } + if ($start > $i*M_PI/2 && $y < $yStart) { + $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 ); + $x2 = $_x2; if (!$aaStartX) imageSetPixel($img, $cx+$xp*($x2+1)+$xa, $cy+$yp*($y)+$ya, $diffColor2); + } else { + $x = $a * sqrt( 1 - ($y*$y)/($b*$b) ); + $error = $x - (int)($x); + $x = (int)($x); + $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error ); + $x1 = $x; if ($y < $aaAngleY && $y <= $yStop ) imageSetPixel($img, $cx+$xp*($x1+1)+$xa, $cy+$yp*$y+$ya, $diffColor); + } + } + } + + if ($seg == 1 || $seg == 3) + { + $i = $seg; + if (!($stop < ($i+1)*M_PI/2 && $y > $yStart)) { + if ($i == 1) { + $xp = -1; $yp = -1; $xa = 0; $ya = 0; + } else { + $xp = +1; $yp = +1; $xa = 1; $ya = 1; + } + if ( $start > $i*M_PI/2 && $y < $yStart ) { + $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 ); + $x1 = $_x2; if (!$aaStartX) imageSetPixel($img, $cx+$xp*($x1-1)+$xa, $cy+$yp*$y+$ya, $diffColor2); + } + if ($stop < ($i+1)*M_PI/2 && $y <= $yStop) { + $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 ); + $x2 = $_x1; if (!$aaStopX) imageSetPixel($img, $cx+$xp*($x2+1)+$xa, $cy+$yp*$y+$ya, $diffColor1); + } else { + $x = $a * sqrt( 1 - ($y*$y)/($b*$b) ); + $error = $x - (int)($x); + $x = (int)($x); + $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error ); + $x1 = $x; if ($y < $aaAngleY && $y < $yStart) imageSetPixel($img,$cx+$xp*($x1+1)+$xa, $cy+$yp*$y+$ya, $diffColor); + } + } + } + } +} + + +function imageSmoothArc ( &$img, $cx, $cy, $w, $h, $color, $start, $stop) +{ + // Originally written from scratch by Ulrich Mierendorff, 06/2006 + // Rewritten and improved, 04/2007, 07/2007 + // compared to old version: + // + Support for transparency added + // + Improved quality of edges & antialiasing + + // note: This function does not represent the fastest way to draw elliptical + // arcs. It was written without reading any papers on that subject. Better + // algorithms may be twice as fast or even more. + + // what it cannot do: It does not support outlined arcs, only filled + + // Parameters: + // $cx - Center of ellipse, X-coord + // $cy - Center of ellipse, Y-coord + // $w - Width of ellipse ($w >= 2) + // $h - Height of ellipse ($h >= 2 ) + // $color - Color of ellipse as a four component array with RGBA + // $start - Starting angle of the arc, no limited range! + // $stop - Stop angle of the arc, no limited range! + // $start _can_ be greater than $stop! + // If any value is not in the given range, results are undefined! + + // This script does not use any special algorithms, everything is completely + // written from scratch; see http://de.wikipedia.org/wiki/Ellipse for formulas. + + while ($start < 0) + $start += 2*M_PI; + while ($stop < 0) + $stop += 2*M_PI; + + while ($start > 2*M_PI) + $start -= 2*M_PI; + + while ($stop > 2*M_PI) + $stop -= 2*M_PI; + + + if ($start > $stop) + { + imageSmoothArc ( $img, $cx, $cy, $w, $h, $color, $start, 2*M_PI); + imageSmoothArc ( $img, $cx, $cy, $w, $h, $color, 0, $stop); + return; + } + + $a = 1.0*round ($w/2); + $b = 1.0*round ($h/2); + $cx = 1.0*round ($cx); + $cy = 1.0*round ($cy); + + $aaAngle = atan(($b*$b)/($a*$a)*tan(0.25*M_PI)); + $aaAngleX = $a*cos($aaAngle); + $aaAngleY = $b*sin($aaAngle); + + $a -= 0.5; // looks better... + $b -= 0.5; + + for ($i=0; $i<4;$i++) + { + if ($start < ($i+1)*M_PI/2) + { + if ($start > $i*M_PI/2) + { + if ($stop > ($i+1)*M_PI/2) + { + imageSmoothArcDrawSegment($img, $cx, $cy, $a, $b, $aaAngleX, $aaAngleY , $color, $start, ($i+1)*M_PI/2, $i); + } + else + { + imageSmoothArcDrawSegment($img, $cx, $cy, $a, $b, $aaAngleX, $aaAngleY, $color, $start, $stop, $i); + break; + } + } + else + { + if ($stop > ($i+1)*M_PI/2) + { + imageSmoothArcDrawSegment($img, $cx, $cy, $a, $b, $aaAngleX, $aaAngleY, $color, $i*M_PI/2, ($i+1)*M_PI/2, $i); + } + else + { + imageSmoothArcDrawSegment($img, $cx, $cy, $a, $b, $aaAngleX, $aaAngleY, $color, $i*M_PI/2, $stop, $i); + break; + } + } + } + } +} +?> diff --git a/html/jpgraph/imgdata_balls.inc.php b/html/jpgraph/imgdata_balls.inc.php new file mode 100644 index 0000000..ee5db49 --- /dev/null +++ b/html/jpgraph/imgdata_balls.inc.php @@ -0,0 +1,1061 @@ +<?php +//======================================================================= +// File: IMGDATA_ROUNDBALLS.INC +// Description: Base64 encoded images for small round markers +// Created: 2003-03-20 +// Ver: $Id: imgdata_balls.inc.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +class ImgData_Balls extends ImgData { + protected $name = 'Round Balls'; + protected $an = array(MARK_IMG_LBALL => 'imgdata_large', + MARK_IMG_MBALL => 'imgdata_small', + MARK_IMG_SBALL => 'imgdata_xsmall', + MARK_IMG_BALL => 'imgdata_xsmall'); + protected $colors,$index,$maxidx; + private $colors_1 = array('blue','lightblue','brown','darkgreen', + 'green','purple','red','gray','yellow','silver','gray'); + private $index_1 = array('blue'=>9,'lightblue'=>1,'brown'=>6,'darkgreen'=>7, + 'green'=>8,'purple'=>4,'red'=>0,'gray'=>5,'silver'=>3,'yellow'=>2); + private $maxidx_1 = 9 ; + + private $colors_2 = array('blue','bluegreen','brown','cyan', + 'darkgray','greengray','gray','green', + 'greenblue','lightblue','lightred', + 'purple','red','white','yellow'); + + + private $index_2 = array('blue'=>9,'bluegreen'=>13,'brown'=>8,'cyan'=>12, + 'darkgray'=>5,'greengray'=>6,'gray'=>2,'green'=>10, + 'greenblue'=>3,'lightblue'=>1,'lightred'=>14, + 'purple'=>7,'red'=>0,'white'=>11,'yellow'=>4); + + private $maxidx_2 = 14 ; + + + private $colors_3 = array('bluegreen','cyan','darkgray','greengray', + 'gray','graypurple','green','greenblue','lightblue', + 'lightred','navy','orange','purple','red','yellow'); + + private $index_3 = array('bluegreen'=>1,'cyan'=>11,'darkgray'=>14,'greengray'=>10, + 'gray'=>3,'graypurple'=>4,'green'=>9,'greenblue'=>7, + 'lightblue'=>13,'lightred'=>0,'navy'=>2,'orange'=>12, + 'purple'=>8,'red'=>5,'yellow'=>6); + private $maxidx_3 = 14 ; + + protected $imgdata_large, $imgdata_small, $imgdata_xsmall ; + + + function GetImg($aMark,$aIdx) { + switch( $aMark ) { + case MARK_IMG_SBALL: + case MARK_IMG_BALL: + $this->colors = $this->colors_3; + $this->index = $this->index_3 ; + $this->maxidx = $this->maxidx_3 ; + break; + case MARK_IMG_MBALL: + $this->colors = $this->colors_2; + $this->index = $this->index_2 ; + $this->maxidx = $this->maxidx_2 ; + break; + default: + $this->colors = $this->colors_1; + $this->index = $this->index_1 ; + $this->maxidx = $this->maxidx_1 ; + break; + } + return parent::GetImg($aMark,$aIdx); + } + + function __construct() { + + //========================================================== + // File: bl_red.png + //========================================================== + $this->imgdata_large[0][0]= 1072 ; + $this->imgdata_large[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAAByF'. + 'BMVEX/////////xsb/vb3/lIz/hIT/e3v/c3P/c2v/a2v/Y2P/'. + 'UlL/Skr/SkL/Qjn/MTH/MSn/KSn/ISH/IRj/GBj/GBD/EBD/EA'. + 'j/CAj/CAD/AAD3QkL3MTH3KSn3KSH3GBj3EBD3CAj3AAD1zMzv'. + 'QkLvISHvIRjvGBjvEBDvEAjvAADnUlLnSkrnMTnnKSnnIRjnGB'. + 'DnEBDnCAjnAADec3PeSkreISHeGBjeGBDeEAjWhITWa2vWUlLW'. + 'SkrWISnWGBjWEBDWEAjWCAjWAADOnp7Oa2vOGCHOGBjOGBDOEB'. + 'DOCAjOAADJrq7Gt7fGGBjGEBDGCAjGAADEpKS/v7+9QkK9GBC9'. + 'EBC9CAi9AAC1e3u1a2u1Skq1KSm1EBC1CAi1AACtEBCtCBCtCA'. + 'itAACngYGlCAilAACghIScOTmcCAicAACYgYGUGAiUCAiUAAiU'. + 'AACMKSmMEACMAACEa2uEGAiEAAB7GBh7CAB7AABzOTlzGBBzCA'. + 'BzAABrSkprOTlrGBhrAABjOTljAABaQkJaOTlaCABaAABSKSlS'. + 'GBhSAABKKSlKGBhKAABCGBhCCABCAAA5CAA5AAAxCAAxAAApCA'. + 'ApAAAhAAAYAACc9eRyAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgF'. + 'HUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkRFD'. + 'UHLytKAAAB4UlEQVR4nGNgIAK4mGjrmNq6BmFIWMmISUpKSmk5'. + 'B8ZEokj4qoiLiQCBgqald3xaBpKMj6y4sLCQkJCIvIaFV0RaUR'. + 'lCSk5cWEiAn19ASN7QwisuraihHiajKyEixM/NwckjoKrvEACU'. + 'qumpg7pAUlREiJdNmZmLT9/cMzwps7Smc3I2WEpGUkxYkJuFiY'. + 'lTxszePzY1v7Shc2oX2D+K4iLCgjzsrOw8embuYUmZeTVtPVOn'. + 'gqSslYAOF+Ln4ZHWtXMPTcjMrWno7J82rRgoZWOsqaCgrqaqqm'. + 'fn5peQmlsK1DR52vRaoFSIs5GRoYG5ub27n19CYm5pdVPnxKnT'. + 'pjWDpLydnZwcHTz8QxMSEnJLgDL9U6dNnQ6Sio4PDAgICA+PTU'. + 'zNzSkph8hADIxKS46Pj0tKTc3MLSksqWrtmQySAjuDIT8rKy0r'. + 'Kz+vtLSmur6jb9JUIJgGdjxDQUVRUVFpaUVNQ1NrZ9+kKVOmTZ'. + 'k6vR0sldJUAwQNTU2dnX0TgOJTQLrSIYFY2dPW1NbW2TNxwtQp'. + 'U6ZMmjJt2rRGWNB3TO7vnzh5MsgSoB6gy7sREdY7bRrQEDAGOb'. + 'wXOQW0TJsOEpwClmxBTTbZ7UDVIPkp7dkYaYqhuLa5trYYUxwL'. + 'AADzm6uekAAcXAAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bl_bluegreen.png + //========================================================== + $this->imgdata_large[1][0]= 1368 ; + $this->imgdata_large[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMMFi8hE9b2uAAABOVJREFUeNq9lk2sJFUVx3+3qv'. + 'tW95t57zFvhiFxmCFRUJRoNCQiJARMhiFx/Igxii5goTG6ZDAu'. + '/EhcSCIrTAgLEiKsJ8ywABNZEMJXEDYCukAmjgjzBkK/j35V1d'. + '333FtV97io97pfzwxfG86qcu/N+Z3zP+fcW/Apmfk4hx57+R/6'. + 'Rqmc9ykhsWjlsUngAA1fXIQ7b73pI/186IGHnn9dH/8frC8v4I'. + 'PiG53uaerR4GmKkv31mB8cyfjd946ZTwR66qVX9OTWIi8UKUv9'. + 'BOrZXpYZvFeiBvzI0fgSUSFKwbVG+Pl1V3HH0VvNR4KeeukV/f'. + 'PmMmdHhst76aXD64AbeVQ9bjNHaiGOC2o3wLrAb2/4LL/84ffn'. + 'fCdzkOdayKpLppBemrBsU5Y1Zdmm9LJdGU6E/t4M24Q26jRDRL'. + 'j3mdc49cSTekFsMzs5XuTsyLDUNSDQ25NwKOly9YIl22MYhJr/'. + 'uoDtBBoT0CxBRGYOAhibIaOCe//2MpfM6KHnX9cXipSlbkKWmS'. + 'nk9iv38J0jixw7vJfrTMYBOvhSoQHJBS09ANELloAGDxW8tfoW'. + 'J+5/UC8CPS0LU7r3SpYarr7M8rmFjMPLXT6/33L4si7Z2GCrQC'. + '+0ctlOaNs9DReV8vSLr85ndPLpZ/WNvHW+01kAVFBOGvJx0wYg'. + 'Sp47RIQ4Emwa8FGJXlDxSCFo5YlVgAo2hwPue/hRndboTV3EW2'. + 'Wp3k6wBp8q56QiWzecW6vwQfnPRkAWhFgILnq08jQ+R2nlUzzN'. + 'uES9Q7Vd+9fba7NmWJW61db2247qACmcjxXr45psYphsFGSLBu'. + 'kIajxqtjNwHkvAjQt0sg3crhPA2+fPz0CuyNFOghsGsr19mnFg'. + 'DGwrRm8UoAtNmQPQtRXDgdC4HImCFEKcCE0oieUWUYq2LtbiGp'. + 'mBQmppfIkjw45DK0QNNkvQ0jMBtPL0UnDRM1rN+cxKwzvOo2NP'. + 'tykR9a1kfpZNDLMG6QDYJqCTBvUe1+uxs+YKyPoGrTwY2HhvC4'. + 'CDWQd5d4xNApNQEEMgjgLdUCLBQ5cprL/trwNwKG2IUmDqDFd5'. + 'sr5BWrlxuSdLDFEFlqAzXGc4zFjupqh6uqYihpxJcEgp026l2w'. + '7wFUv7Z6AvrfRo/n0OYzPwIKE3HUKAJg2otMBiElnsF7wngis9'. + '3ZDjNnLi7huCWUZfueZKTu/M0V3HvmkOFDVxVKDG04ScejSgW5'. + 'V0q5JYFEghuDLHlTmToqDeGOCKIVtrW9hsdmXufEcNLPSXuPHa'. + 'a+bvuh9df5AH/v5PDFmbWQC3Mx+TVvfGVTRB2CodNgT2JBX003'. + 'aANZAYS/BxCv32TV/l2C03G7jgmfjGiT/qmeEmibEYm7XzAO2k'. + 'A+pbgHhBgydqu54YO5eRiLCy7yDvPP6Xqf+5Z+Lu277OYuOpiw'. + 'H15oBmlNOMcmK5RbP+PrEscGU+DSAxdg4CICIkxnLP8aNz63Og'. + 'H3/rdvOb795GVhuaYo0oBc3GGrEsUPVTwO6a7LYd+X51x3Hu/t'. + 'lP5tS65FN+6okn9U+n/sqb596dTvhOF+02myXTmkQNrOw7yD3H'. + 'j14E+UDQjp24/0E9/eKrbA4HH3aMK1b2ccvXvswjv//1J/s5ud'. + 'Due/hRPfP+OmfOrk7vrn7a48ihA3zh8CH+8Iuffiw/n4r9H1ZZ'. + '0zz7G56hAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bl_yellow.png + //========================================================== + $this->imgdata_large[2][0]= 1101 ; + $this->imgdata_large[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAAB2l'. + 'BMVEX//////////+///+f//9b//8b//73//7X//63//6X//5T/'. + '/4z//4T//3P//2v//1r//0r//0L//zH//yn//yH//xj//xD//w'. + 'j//wD/90L/9zn/9zH/9xj/9xD/9wj/9wD39yn37zn37zH37yH3'. + '7xD37wj37wDv70Lv50rv50Lv5znv5yHv5xjv5wjv5wDn51Ln5x'. + 'Dn3jHn3iHn3hjn3hDn3gje3oze3nPe3lLe1oze1nPe1lLe1ine'. + '1iHe1hje1hDe1gje1gDW1qXW1mvWzqXWzkLWzhjWzhDWzgjWzg'. + 'DOzrXOzq3OzpzOzgDOxkrOxinOxhjOxhDOxgjOxgDGxqXGxnvG'. + 'xmvGvRjGvRDGvQjGvQDFxbnAvr6/v7+9vaW9vZS9vQi9vQC9tR'. + 'C9tQi9tQC7u7W1tZS1tXu1tTG1tQi1rRC1rQi1rQCtrYytrSGt'. + 'rQitrQCtpYStpSGtpQitpQClpYSlpXulpQClnBClnAilnACcnG'. + 'ucnAicnACclAiclACUlFqUlCmUlAiUlACUjFKUjAiUjACMjFKM'. + 'jEqMjACMhACEhACEewB7ezF7exB7ewB7cwBzcylzcwBzaxBzaw'. + 'BraxhrawhrawBrYxBrYwBjYwBjWgBaWgBaUgCXBwRMAAAAAXRS'. + 'TlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAd'. + 'LdfvwAAAAHdElNRQfTAwkRFBKiJZ4hAAAB7ElEQVR4nI3S+1vS'. + 'UBgHcB67WJmIMWAVdDHEDLBC6Go0slj3Ft0m9RRBWQEmFZFDEM'. + 'Qgt0EMFBY7p/+198hj1kM/9N1+++x73rOd6XT/kStnTx4fPzd9'. + 'uwfOjFhomj7smAhwj/6Cm2O0xUwy6g7cCL99uCW3jtBmE7lsdr'. + 'fvejgpzP7uEDFRRoqy2k8xQPnypo2BUMP6waF9Vpf3ciiSzErL'. + 'XTkPc0zDe3bsHDAcc00yoVgqL3UWN2iENpspff+2vn6D0+NnZ9'. + '6lC5K6RuSqBTZn1O/a3rd7v/MSez+WyIpVFX8GuuCA9SjD4N6B'. + 'oRNTfo5PCAVR0fBXoIuOQzab1XjwwNHx00GOj8/nKtV1DdeArk'. + '24R+0ul9PjmbrHPYl+EipyU0OoQSjg8/m83kl/MMhx0fjCkqio'. + 'SMOE7t4JMAzDsizH81AqSdW2hroLPg4/CEF4PhKNx98vlevrbY'. + 'QQXgV6kXwVfjkTiSXmhYVcSa7DIE1DOENe7GM6lUym0l+EXKks'. + 'K20VAeH2M0JvVgrZfL5Qqkiy0lRVaMBd7H7EZUmsiJJcrTdVja'. + 'wGpdbTLj3/3qwrUOjAfGgg4LnNA5tdQx14Hm00QFBm65hfNzAm'. + '+yIFhFtzuj+z2MI/MQn6Uez5pz4Ua41G7VumB/6RX4zMr1TKBr'. + 'SXAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bl_silver.png + //========================================================== + $this->imgdata_large[3][0]= 1481 ; + $this->imgdata_large[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAADAF'. + 'BMVEUAAADOzs7Gxsa9vb21tbXOxsbOzsbGzsb3///O1ta1vb2c'. + 'paVSWlpKWlpSY2ve5+97hIze7/9aY2vO5/9zhJRaa3tSY3PGzt'. + 'aMlJxrc3tja3NKUlpCSlK1vcZze4RSWmPW5/+Upb3G3v9zhJxS'. + 'Y3t7jKVaa4TO3veltc6ElK1re5Rjc4ycpbV7hJRaY3M5QlLn7/'. + '/Gzt6lrb2EjJzO3v9ja3vG1ve9zu+1xueltdacrc6UpcaMnL1C'. + 'SlqElLV7jK1zhKVre5zW3u/O1ue1vc6ttcaMlKVze4xrc4RSWm'. + 'tKUmPG1v+9zve1xu+tveeltd6crdbe5/+9xt6cpb17hJxaY3s5'. + 'QlrW3vfO1u/Gzue1vdattc6lrcaUnLWMlK2EjKVze5Rrc4xja4'. + 'RSWnNKUmtCSmO9xuecpcZ7hKVaY4TW3v/O1vfGzu+1vd6ttdal'. + 'rc69xu+UnL2MlLWEjK1ze5xrc5R7hK1ja4zO1v+1veettd6lrd'. + 'aMlL3Gzv/39//W1t7Gxs61tb29vcatrbWlpa2cnKWUlJyEhIx7'. + 'e4TW1ufGxta1tcZSUlqcnK3W1u+UlKW9vda1tc57e4ytrcalpb'. + '1ra3vOzu9jY3OUlK29vd6MjKWEhJxaWmtSUmNzc4xKSlpjY3tK'. + 'SmNCQlqUjJzOxs7///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. + 'AAAAAAAAAAAAAAAAAAAAAAAAD///9fnkWVAAAAAnRSTlP/AOW3'. + 'MEoAAAABYktHRP+lB/LFAAAACXBIWXMAAABFAAAARQBP+QatAA'. + 'AB/klEQVR42mNgxAsYqCdd3+lcb4hLmj8wMMvEu8DCMqYbU9op'. + 'UEFB2MTb26eyysomFl06XEEhUCHLpAKo2z/fujikEUVaXUFBMB'. + 'BouLePuV+VVWGRciIXknSEsImCQd3//xwmPr65llaFcSFJHkjS'. + '3iYmWUDZ//8NfCr989NjNUMSUyTg0jneSiaCINn/gmlVQM12qg'. + 'lJnp5waTMTE5NAkCyHWZW/lXWNfUlikmdYK0zax7siS4EDKJtd'. + 'mQeU1XRwLBdLkRGASucWmGVnZ4dnhZvn5lmm29iVOWpnJqcuko'. + 'JKR1Wm5eTkRKYF5eblp9sU2ZeUJiV7zbfVg0pH56UFBQXNjIqK'. + 'jgkujItX1koKTVmYajsdKu2qETVhwgSXiUDZ2Bn9xqUeoZ5e0t'. + 'LzYYZ3B092ndjtOnmKTmycW1s7SHa+l5dtB8zlccE6RlN0dGbM'. + 'mDVbd5KupNBcL6+F82XgHouLj5vRP2PWLGNdd4+ppnxe8tJec6'. + 'XnNsKkm0uVQ5RDRHQTPTym68nPlZbvkfYCexsa5rpJ2qXa5Umm'. + 'ocmec3m8vHjmSs+fgxyhC5JDQ8WSPT2lvbzm8vDIe0nbtiBLN8'. + '8BigNdu1B6Lsje+fPbUFMLi5TMfGmvHi/puUAv23q2YCTFNqH5'. + 'MvPnSwPh3HasCbm3XUpv+nS5VtrkEkwAANSTpGHdye9PAAAASn'. + 'RFWHRzaWduYXR1cmUANGJkODkyYmE4MWZhNTk4MTIyNDJjNjUx'. + 'NzZhY2UxMDAzOGFhZjdhZWIyNzliNTM2ZGFmZDlkM2RiNDU3Zm'. + 'NlNT9CliMAAAAASUVORK5CYII=' ; + + //========================================================== + // File: bl_purple.png + //========================================================== + $this->imgdata_large[4][0]= 1149 ; + $this->imgdata_large[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAACAV'. + 'BMVEX/////////7///5///1v//xv//rf//pf//lP//jP//hP//'. + 'c///a///Wv//Wvf/Uv//Sv//Qv//Qvf/Off/Mf//Kf//If//If'. + 'f/GP//GPf/EP//EPf/CP//CPf/CO//AP//APf3Oe/3Kff3Ke/3'. + 'Ie/3GO/3EO/3AO/vSu/vSufvOefvMefvIefvGOfvEOfvCOfvAO'. + 'fnUufnSufnMd7nId7nGN7nGNbnEN7nCN7nAN7ejN7ejNbec97e'. + 'c9beUtbeQtbeIdbeGNbeENbeCNbeANbWpdbWa9bWQs7WGM7WEM'. + '7WCM7WAM7Otc7Orc7OnM7OSsbOIb3OGMbOEMbOCMbOAM7OAMbG'. + 'pcbGnMbGe8bGa8bGKbXGEL3GCL3GAL3FucXBu73AvsC/v7+9pb'. + '29Ka29GLW9ELW9CLW9AL29ALW5rrm1lLW1e7W1MbW1GKW1EK21'. + 'CLW1CK21AK2tjK2thKWtMaWtIaWtGJytCK2tCKWtAK2tAKWlhK'. + 'Wle6WlEJylCJylAKWlAJyca5ycGJScEJScCJScAJycAJSUWpSU'. + 'UoyUKZSUEIyUCIyUAJSUAIyMUoyMSoyMIYSMEISMCISMAIyMAI'. + 'SECHuEAISEAHt7MXt7EHt7CHt7AHt7AHNzKXNzEGtzAHNzAGtr'. + 'GGtrEGNrCGtrAGtrAGNjCFpjAGNjAFpaAFpaAFIpZn4bAAAAAX'. + 'RSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsS'. + 'AdLdfvwAAAAHdElNRQfTAwkRFB0ymoOwAAAB9UlEQVR4nGNgIA'. + 'K42hhqGtm5+WFIWClKycvLK6gbuARGoEj4aMjLSElISUir6Tt7'. + 'x+aEIWR8leQlwEBSTc/CK7awLguuR0lGQkJMVFRUTFJVzwko1d'. + 'oFk9OQl5IQE+Dh5hVR0TV3CkkvbJgyASJjDZIR5GBl5eRX0TH1'. + 'DEqrbJ2ypBEspSgvJSXKw8bMxMavbOLoGZNf1TZlybw4oIyfLN'. + 'BxotxsLEzsQiaOHkFpBQ2905esrAZK2SpIAaUEuDm5+LTNPAKj'. + 'C+pbps1evrIDKGWnLictKSkuLKyoZQyUya9o7Z2+YMXKGUApew'. + 'M9PTVdXR0TEwf3wOjUirruafOXL18xFyjl72Kpb25qaurg4REU'. + 'EFVe2zJ5zpLlK1aCpbydnZ2dnDwDA6NTopLLeiZNXbB8BcTAyP'. + 'TQ0JDg4KCY1NS83JKmiVOBepYvX9UPlAovzEiPSU/LLyior2vq'. + 'mjZr3vLlIF01IC+XVhUWFlZW1Lc290ycOGfxohVATSsXx4Oksn'. + 'vaWlsb2tq6J0+bM2/RohVA81asbIcEYueU3t7JU6ZNnwNyGkhm'. + '+cp5CRCppJnzZ8+ZM3/JUogECBbBIixr8Yqly8FCy8F6ltUgoj'. + 'lz7sqVK2ByK+cVMSCDxoUrwWDVysXt8WhJKqG4Y8bcuTP6qrGk'. + 'QwwAABiMu7T4HMi4AAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bl_gray.png + //========================================================== + $this->imgdata_large[5][0]= 905 ; + $this->imgdata_large[5][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAABO1'. + 'BMVEX////////3///39/fv7+/e5+fW3t7Wzs7WxsbG1tbGzsbG'. + 'xsbDxMS/v7++wMC+v7+9zsa9xsa9vb29tbW9ra29pa24uLi1xs'. + 'a1vb21tbWxtrattbWmpqalra2cra2cpaWcnJycjIyUpaWUnJyU'. + 'lJSUjIyMnJyMnJSMlJSMlIyMjJSMjIyElJSElIyEjIyEhIR7jI'. + 'x7hIR7hHt7e3t7e3N7e2tzhIRze3tze3Nzc3Nre3trc3Nrc2tr'. + 'a2tjc3Njc2tja3Nja2tjY2NjWlpaa2taY2taY2NaY1paWlpaUl'. + 'JSY2NSY1pSWlpSWlJSUlJSUkpKWlpKWlJKUlpKUlJKUkpKSkpK'. + 'SkJCUlJCUkJCSkpCSkJCQkI5Sko5QkI5Qjk5OUI5OTkxQkIxOT'. + 'kxMTkxMTEpMTEhMTEhKSkYISEpy7AFAAAAAXRSTlMAQObYZgAA'. + 'AAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdE'. + 'lNRQfTAwkRFQfW40uLAAABx0lEQVR4nI3SbXfSMBQA4NV3nce5'. + 'TecAHUywRMHSgFuBCFsQUqwBS1OsWQh0GTj//y8wZUzdwQ/efM'. + 'tzcm/uuXdj4z9ic/PR9k4qk1qDnf0X2/uZzKt8GaRvSubg4LVp'. + 'mkWzCGAT/i3Zsm2XNQHLsm2n2937LaaNnGoJFAEo27B50qN0ay'. + 'Wg26lXsw8fP8nmzcJb2CbsnF5JmmCE8ncN404KvLfsYwd7/MdV'. + 'Pdgl/VbKMIzbuwVgVZw2JlSKJTVJ3609vWUY957lgAUd1KNcqr'. + 'yWnOcOPn8q7d5/8PywAqsOOiVDrn42NFk+HQ7dVuXNYeFdBTpN'. + 'nY5JdZl8xI5Y+HXYaTVqEDp1hAnRohZM03EUjMdhn5wghOoNnD'. + 'wSK7KiiDPqEtz+iD4ctdyAifNYzUnScBSxwPd6GLfRURW7Ay5i'. + 'pS5bmrY8348C5vvUI+TLiIVSJrVA0heK/GDkJxYMRoyfCSmk4s'. + 'uWc3yic/oBo4yF374LGQs5Xw0GyQljI8bYmEsxVUoKxa6HMpAT'. + 'vgyhU2mR8uU1pXmsa8ezqb6U4mwWF/5MeY8uLtQ0nmmQ8UWYvb'. + 'EcJaYWar7QhztrO5Wr4Q4hDbAG/4hfTAF2iCiWrCEAAAAASUVO'. + 'RK5CYII=' ; + + //========================================================== + // File: bl_brown.png + //========================================================== + $this->imgdata_large[6][0]= 1053 ; + $this->imgdata_large[6][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAABoV'. + 'BMVEX////Gzs7GvbXGrZTGpXu9nHO1nHO1nIy9taXGxs7GtaXO'. + 'nHPGlFrGjEq9hEq1hEqte0Klczmcazmce1KtnIzGxsbGvb3OlF'. + 'LOlFq9hFKte0qcc0KUYzGEWimMc1K9ta3OnGvOnGPWnGO9jFq9'. + 'jFKlc0KUazmMYzl7UilzUjGtpZzGxr3GnGPWpWvepXO1hFJ7Wj'. + 'FrSiFjUjG1ra3GnHPvxpT/5733zpythFKUa0KEYzlzUilaOSF7'. + 'Wjm9jErvvYz/99b///f/78bnrYS1hFqle0p7UjFrSiljQiFCMR'. + 'iMhHO9lGvGjFLWnGv/3q3////erXuthEqlc0paQiFKMRhSQin/'. + '1qX/997//++cc0pjSilaQilKORhCKRiclIy9pYzGlGPntYT33q'. + '3vvZSEWjlSOSE5KRB7c2O1lHutczmthFqte1JrWkqtjGtCKRBa'. + 'SjmljGuca0KMYzGMaznOztaclISUYzmEWjFKOSF7a1qEYzFaSi'. + 'GUjISEa0pKOSm9vb2llIxaQhg5IQiEc2tzY0paORilnJy1raVS'. + 'OSljUkJjWkKTpvQWAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHU'. + 'gAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkREiei'. + 'zP2EAAAB9UlEQVR4nGWS/VfSUBjHL5QluhhBxtwyWcCus5Blpm'. + 'wDC4ONaWXCyBi7RMZmpQ2Bypm9W/byV3cHHo/W88s95/s5z/d5'. + 'uwCcCh/4L3zAf+bs0NC588On9QAYGSUuBINk6GI4cmnsBLk8Go'. + '1SFEGMkzRzZeLq5JE8FvDHouw1lqXiCZJOcnCKnx4AcP0GBqmZ'. + 'mRgRT9MMB4Wbs7cGSXNRik3dnp9fiMUzNCNKgpzN9bsaWaQo9s'. + '7dfH7pXiFTZCBU1JK27LmtBO8TDx7mV1eXHqXXyiIUFLWiVzHx'. + 'BxcJIvV4/cn6wkqmWOOwmVE3UQOAp6HxRKL5bGPj+VwhUhalFq'. + '8alm5vAt+LlySZTsebzcKrraIIW4JqZC3N3ga+1+EQTZKZta1M'. + 'pCZCSeDViqVrThsEdsLJZLJYLpZrHVGScrKBvTQNtQHY6XIM02'. + 'E6Ik7odRW1Dzy3N28n3kGuB3tQagm7UMBFXI/sATAs7L5vdbEs'. + '8Lycm923NB0j5wMe6KOsKIIyxcuqauxbrmlqyEWfPmPy5assY1'. + 'U1SvWKZWom9nK/HfQ3+v2HYZSMStayTNN0PYKqg11P1nWsWq7u'. + '4gJeY8g9PLrddNXRdW8Iryv86I3ja/9s26gvukhDdvUQnIjlKr'. + 'IdZCNH+3Xw779qbG63f//ZOzb6C4+ofdbzERrSAAAAAElFTkSu'. + 'QmCC' ; + + //========================================================== + // File: bl_darkgreen.png + //========================================================== + $this->imgdata_large[7][0]= 1113 ; + $this->imgdata_large[7][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAAB2l'. + 'BMVEX////////3///v///n/+/e99bW/+/W99bO786/v7++vr69'. + '/96999a7wb24vbu1/9a1zqW1u7itxrWosq6l772l1qWlxrWlxq'. + '2lva2cxpSU562U3q2UxqWUvaWUpZyM77WM57WMvYyMtZyMrZyM'. + 'pZSMnJSEvZyEtYyErZSElIx7zpR7xpx7xpR7vZR7jIRz1pRzxp'. + 'RzjIRrzpRrzoxrxoxrtYRrrYxrrXtrpYRrhHNjzoxjxoxjxoRj'. + 'vYRjtYRjrXtjpXtjlGNje2tazoxazoRaxoxaxoRavYRatYRatX'. + 'tarXtapXNanHNajFpae2tSzoRSxoRSvXtStXtSrXtSrXNSpXNS'. + 'nHNSnGtSlGtSlGNSjGtSjGNKvXtKtXNKrXNKpWtKnGtKlGNKjG'. + 'NKhGNKhFJKc1pKa1JCrWtCpWtCnGtClGNCjGNCjFpChFpCe1JC'. + 'a1JCY1I5pWs5nGM5lGM5jFo5hFo5e1o5c0o5WkoxjFoxhFoxhF'. + 'Ixe1Ixc1Ixc0oxa0ophFIpe0opc0opa0opa0IpY0IpWkIpWjkp'. + 'UkIpUjkhc0oha0IhY0IhWjkhWjEhUjkhUjEhSjEhSikhQjEhQi'. + 'kYWjkYSjEYSikYQjEYQikQSikQQikQQiEQOSExf8saAAAAAXRS'. + 'TlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAd'. + 'LdfvwAAAAHdElNRQfTAwkRFCaDkWqUAAAB+ElEQVR4nI3S+1vS'. + 'UBgHcGZlPV0ks/vFrmQWFimJjiwiYUJWjFBWFhClyZCy5hLrwA'. + 'x2EIwJC1w7zf2vnU0re+iHvs9++7x7zznvORbLf+TA6ct9fYMX'. + 'jrfAUYefpp+/iM1ykxf/lmuhUZ/PTwXC8dml5Wcd23o5H5Mk6b'. + '5NUU8icXbhS67rNzn9JDnguOEYGQtEEtwC+Crs3RJ76P5A/znr'. + 'vsNX7wQnEiwHCtK7TTkW8rvdZ9uJtvZTLkxpHhSrP66bNEj7/P'. + '3WNoLYeeSWQQCIpe9lQw7RNEU5rDsIYtcJ14Nocg7kRUlBNkxn'. + 'YmGKcp7cv3vPwR7XOJPmc0VYU3Sv0e9NOBAYG7Hbz/cMjTMveZ'. + 'CHkqxuTBv0PhYJB4N3XR6PJ5rMAPMnpGUxDX1IxSeMTEaZp1OZ'. + 'nGAIQiYtsalUIhFlmGTy3sO3AizJCKn6DKYryxzHsWyaneMzr6'. + 'cWxRVZVlFTe4SpE3zm+U/4+whyiwJcWVMQNr3XONirVWAklxcE'. + 'EdbqchPhjhVzGpeqhUKhWBQhLElr9fo3pDaQPrw5xOl1CGG1JE'. + 'k1uYEBIVkrb02+o6RItfq6rBhbw/tuINT96766KhuqYpY3UFPF'. + 'BbY/19yZ1XF1U0UNBa9T7rZsz80K0jWk6bpWGW55UzbvTHZ+3t'. + 'vbAv/IT+K1uCmhIrKJAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bl_green.png + //========================================================== + $this->imgdata_large[8][0]= 1484 ; + $this->imgdata_large[8][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMMFjM4kcoDJQAABVlJREFUeNq9ll2MJFUVx3/11V'. + 'Vd/TE9vU0v4zLDwJIF16jBqLAPhsRXEiDqg0QTJiQSjcSNvCzw'. + 'sBEDDxizhvAAxBgf1oR9QF9NiE9ESFZkQyZB5WtddmdnZ3qqqr'. + 'uqbt367Cofqu3ZZpWVaDzJfbkf53//55z/PVdZXV3l/2H6f7Lp'. + '5VdOV/4Nb+GmHpUeA7AdBNxc3kafNb73jRPK9Xwon8ToxVefqU'. + 'b91wibH5EkCQBCizFihTSviHUHR0hWws9xe3wvJ7/7nPKpgX5y'. + '9oFqt3eOgWniRBoAbUBGGqZUibSYaeoT2B5bnkdaSA6793Cv/S'. + 'QPPbihXBfo5VdOV+8dfgnvwAU62YH5fCZ12sDujFkwyegCqTrB'. + 'iUOKTOJKj8jr88jS8zy6cXwBTP048nuHX0I0nDlIp7RpTG7kM0'. + 'sdyAYsTVukUuWGhlWHMq0ITL92lnUp9R1Obz/GmTNnqn9bDD8/'. + '+0D1oX0O0zQZZDYCsK2j3Gl9jQqDfHiei8GfiKVLlsZkJaBAN1'. + '0i6PgwUbB0GxG5/PrtE/xLRr959Znqw9452oVNI+jiJhnr1pe4'. + 'k29zB1/nFr5Kj7tpt1YYhJ0FJ7nUYbcJQBgahN2MzeCP/OipR6'. + 'prgN6Qr6ELFQFUWoRpNVjlKwxZB8DCpE+PtfEKqV1cUzxpVudu'. + 'GTBHA5Y1g99e+dUio9O/P1Vpq+/WE5GGjDSMoAtAQjrf3C52IP'. + 'QxpY4WK2hpReka9Gfrhqgz0bACRoCWjDh56kQ1z9FeuUUQxVhK'. + 'B92sD1VahM+bAJgcoJhGjP/6Ln8rAgDiRCVRKiIzxMkkodBJ85'. + 'im1IlEHbE4k1xyNveL4YP8HarmGJIOpqyjeQmfNHmTvnqZTWBt'. + 'vIJXpPwlukJSuSTKGK3pEwtJmiX00ZlInTyNscImO6XBITvH1c'. + '8vVt2OucdKvIyeKRTNCivsEMgcpg6taYs30nfq0Gqg6hOSSFJ4'. + 'BSnJPht0IqEjWmOGocEI6F0J94F0qaL6BntTF0MtUfweKQKAPU'. + 'Wwp4OcVnQAmVb0p9DLOzjEhEKnGRmoRc7EzRGlwA6NujAKG4yP'. + '6Sjwc4aVznZ7DK0xXdkDoJf0kGmFBniFBOBGcZSCCSKd0IwN0k'. + 'IS+QZWCGVZex4BnUxya3+Zt9iugQbcRFpIAtuHvAZulPUdLhUJ'. + 'RqegI3WcqaSXddlT3idsWMSRRGkEtNwmyTifAwyBo7LP+11J0e'. + '7tM7pZOYblHkBLcqZ5LcYtw6Wbd4CM3SpE9foYZsIHoqDKCrbz'. + 'mLSQtPwmuhXgtBLs0GBdbXOhFGB7WBKO2F8GXt9/VO97Ya3atF'. + '7nUHnwGjGGQqcPxFEdFqURkEidiZszAERoYIsGju1hq21kWee3'. + 'bw15+8WpsvAy3K1+i3JkkhZyPpxxjjPOsfOYiZ+TFhLPzQnHOU'. + 'tpzGB2dgA4tscIkKIx19Cxg/fPL7vQJu47eXt1VvsDK8pwPueZ'. + 'PuZoQMOqhRoJHSs0kKLBWjvjYinmeQGw1TaX1RFdfZ3LMzYLjA'. + 'C++dkn6AaH2Nobk6cxEzdnuG0TdC8zvdJkN0hqkFkO/jwL0fxa'. + 'so8sBcuFzQ+/+MRC+BeAHnpwQzn++ee5KT9Eshuy46dcKAXm32'. + '0uzPQhS4GttkH2GQID2Wc0Y4LtAbDxhZ/x5A+e/uTG9+jGceXH'. + '9/ySnnIXnUzOxXe1038mW3ZynNmam4yYWkO+f9cv+Oljz16/lV'. + '9tDz/9nerc1hm8ZEScSRK7VvtYl1i1dklsOKyvc+zg/bzw1O8+'. + '/efkajt56kR1ydlEJBc5H46xzbrJ3dY9wrB7hGcff+6/+279L+'. + '0fHxyiE8XMLl4AAAAASUVORK5CYII=' ; + + //========================================================== + // File: bl_blue.png + //========================================================== + $this->imgdata_large[9][0]= 1169 ; + $this->imgdata_large[9][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAACEF'. + 'BMVEX/////////7//35//v1v/exv/Wvf/Wrf/Wpf/Orf+/v7+9'. + 'tc69jP+9hP+5ucW1tc6tlP+rq7Wlpdalpcalpb2cnM6cnMacc/'. + '+cWv+UlLWUjN6UjK2Uc/+Ma/+MUv+EhKWEa/+EQvd7e8Z7e7V7'. + 'e6V7c957Wv9za9Zza8ZzSv9ra5xrSv9rOf9rMe9jUudjQv9jOe'. + '9aWpRaUt5aUpRaSu9aSudSUoxSSs5SSoxSMf9KQtZKOfdKMedK'. + 'Kf9KKe9CKf9CKb1CKa1CIfdCIedCId45MXs5Kfc5If85Iec5Id'. + 'Y5GP8xMbUxMXsxKc4xKZQxIf8xGP8xGO8xGN4xGNYxGL0xGK0p'. + 'KXMpIYwpGP8pGO8pGOcpGNYpGM4pEP8pEPcpEOcpEN4pENYpEM'. + 'YpEL0hGKUhEP8hEPchEO8hEOchEN4hENYhEM4hEMYhELUhCP8h'. + 'CO8hCN4YGJwYGGsYEL0YEK0YEHMYCN4YCM4YCMYYCL0YCKUYAP'. + '8QEJQQEIwQEHsQEGsQCM4QCLUQCK0QCKUQCJwQCJQQCIwQCHMQ'. + 'CGsQAP8QAPcQAO8QAOcQAN4QANYQAM4QAMYQAL0QALUQAKUQAJ'. + 'QQAIQICGsICGMIAO8IANYIAL0IALUIAK0IAKUIAJwIAJQIAIwI'. + 'AIQIAHsIAHMIAGsIAGMAAN4AAMYAAK0AAJQAAIwAAIQAAHMAAG'. + 'sAAGMAAFrR1dDlAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkRFRPMOZ'. + '/2AAAB+klEQVR4nGNgIAIIqeqZmBqpi2JISNml5lVXV3d198Yo'. + 'oUjwm1SnxsbGRsSm5ZfNXO4tjCTjVh0ABhFx6QV9E1Y0S8JkuN'. + '3yAgLc7W3t/QPi4jPKJ8ye1yoIlTKpjvVy15eVUbN0i4zKLJ8w'. + 'ae6qcKgLqmMj3PUFWFl5NJ0CExLLJzbNW7BWCyxlXR0ba6/Axs'. + 'zELmfnkRBT0QiSKgXJCOflxUbYy3KyMHEoOrtEZ1c2TZ6/cMl6'. + 'eaCUamdsbIC7tjgPr4SBS3BMMVDTwkXr1hsDpYy6UmMj/O0tdX'. + 'QNbDxjknJLWqYsXLx0vStQynxGflpkZGCgs7Onp29SbtNkoMy6'. + 'pevCgFJWy3oyMuKjgoKCPWNCvEuqWhcsWrJ06XqQlPnMvrKyrM'. + 'TomJjkZAfHlNa2qdOWrlu63gcopbG8v7+hvLwip7g4JdSxsLZu'. + '8dKlS9ettwBKic2eNXHChIkTG5tKqgpr2uo6loLAehWQx0LnzJ'. + '49p6mpeXLLlNq6RUvqly6dvnR9Bx9ISnnlvLmT582bMr9t4aL2'. + '+vrp60GaDCGB6Ld6wfwFCxYCJZYsXQ+SmL6+FBryInVrFi1atH'. + 'jJkqVQsH6pNCzCJNvXrQW6CmQJREYFEc2CYevXrwMLAyXXl0oz'. + 'IAOt0vVQUGSIkabkDV3DwlzNVDAksAAAfUbNQRCwr88AAAAASU'. + 'VORK5CYII=' ; + + //========================================================== + // File: bs_red.png + //========================================================== + $this->imgdata_small[0][0]= 437 ; + $this->imgdata_small[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAk1'. + 'BMVEX////////GxsbGra3/xsbOhITWhIT/hIT/e3v/c3P/a2vG'. + 'UlK1SkrOUlL/Y2PWUlLGSkrnUlLeSkrnSkr/SkqEGBj/KSmlGB'. + 'jeGBjvGBj3GBj/EBD/CAj/AAD3AADvAADnAADeAADWAADOAADG'. + 'AAC9AAC1AACtAAClAACcAACUAACMAACEAAB7AABzAABrAABjAA'. + 'BuukXBAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZ'. + 'cwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkUGDNEMgOYAAAAm0'. + 'lEQVR4nI3Q3RKCIBAFYGZMy9RKzX7MVUAUlQTe/+kS0K49d3wD'. + '7JlFaG+CvIR3FvzPXgpLatxevVVS+Jzv0BDGk/UJwOkQ1ph2g/'. + 'Ct5ACX4wNT1o/zzUoJUFUGBiGfVnDTYGJgmrWy8iKEtp0Bpd2d'. + 'jLGu56MB7f4JOOfDJAwoNwslk/jOUi+Jts6RVNrC1hkhPy50Ef'. + 'u79/ADQMQSGQ8bBywAAAAASUVORK5CYII=' ; + + + //========================================================== + // File: bs_lightblue.png + //========================================================== + $this->imgdata_small[1][0]= 657 ; + $this->imgdata_small[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAABVl'. + 'BMVEX////////d///AwMC7wcS08P+y+P+xxdCwxM+uws2twMur'. + 'vsinzNynytylzuKhyN6e5v6d5P+d1fOcwNWcu8ub4f+at8iZ3v'. + '+ZvdGY2/yW2f+VscGU1vuT1fqTr72Sx+SSxeKR0fWRz/GPz/OP'. + 'rr+OyeqMy+6Myu2LyeyKxueJudSGw+SGorGDvt+Cvd6CvN2Aud'. + 'p+uNd+t9Z9tdV8tdR8tNN6sc94r813rct2q8h0qcZ0qMVzp8Rx'. + 'o8Bwor5tn7ptnrptnrlsnbhqmbRpmbNpi51ol7Flkqtkkqtkka'. + 'pjj6hijaRhjaZgi6NfiqJfiaFdh55bhJtag5pZgphYgJZYf5VX'. + 'cn9Ve5FSeI1RdopRdYlQdYlPc4dPcoZPcoVNcINLboBLbH9GZn'. + 'hGZXdFZHZEY3RDYnJCXW4/W2s/WWg+Wmo7VmU7VGM7U2E6VGM6'. + 'VGI5UV82T1wGxheQAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHU'. + 'gAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkUGTok'. + '9Yp9AAAAtElEQVR4nGNgIBaw8wkpKghzwvksPAKiUsraprYiLF'. + 'ARXkE2JiZ1PXMHXzGIAIekOFBE08TGLTCOCyzCLyvDxsZqZOnk'. + 'E56kAhaRV9NQUjW2tPcMjs9wBYsY6Oobmlk7egRGpxZmgkW0zC'. + '2s7Jy9giKT8gohaiQcnVzc/UNjkrMLCyHmcHr7BYREJKTlFxbm'. + 'QOxiEIuKTUzJKgQCaZibpdOzQfwCOZibGRi4dcJyw3S4iQ4HAL'. + 'qvIlIAMH7YAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bs_gray.png + //========================================================== + $this->imgdata_small[2][0]= 550 ; + $this->imgdata_small[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAAQCAMAAADH72RtAAABI1'. + 'BMVEX///8AAAD8EAD8IAD8NAD8RAD8VAAYGBi/v7+goKCCgoJk'. + 'ZGRGRkb8yAD83AD87AD8/AD4+ADo+ADY+ADI+AC0+ACk+ACU+A'. + 'CE+AB0/ABk/ABU/ABE/AAw/AAg/AAQ/AAA/AAA+AAA6BAA2CAA'. + 'yDQAtEQApFQAlGQAhHQAdIgAZJgAVKgARLgAMMgAINwAEOwAAP'. + 'wAAPgIAPAQAOgYAOAkANgsANA0AMg8AMBEALhMALBUAKhcAKBo'. + 'AJhwAJB4AIiAAID////4+Pjy8vLs7Ozm5ubg4ODa2trT09PNzc'. + '3Hx8fBwcG7u7u1tbWurq6oqKiioqKcnJyWlpaQkJCJiYmDg4N9'. + 'fX13d3dxcXFra2tkZGReXl5YWFhSUlJMTExGRkZAQEA1BLn4AA'. + 'AAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIA'. + 'AAsSAdLdfvwAAAAHdElNRQfTAwkUGiIctEHoAAAAfElEQVR4nI'. + '2N2xKDIAwF+bZ2kAa8cNFosBD//yvKWGh9dN+yk9kjxH28R7ze'. + 'wzBOYSX6CaNB927Z9qZ66KTSNmBM7UU9Hx2c5qjmJaWCaV5j4t'. + 'o1ANr40sn5a+x4biElrqHgrXMeac/c1nEpFHG0LSFoo/jO/BeF'. + 'lJnFbT58ayUf0BpA8wAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bs_greenblue.png + //========================================================== + $this->imgdata_small[3][0]= 503 ; + $this->imgdata_small[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAxl'. + 'BMVEX///////+/v79znJQhSkJ7raU5hHtjraVKnJRCjIRClIyU'. + '9++E595avbVaxr2/v7+ctbWcvb17nJxrjIx7paUxQkK9//+Mvb'. + '17ra2Evb17tbVCY2MQGBiU5+ec9/eM5+d71tZanJxjra1rvb1j'. + 'tbVSnJxara1rzs5jxsZKlJRChIQpUlIhQkJatbVSpaU5c3MxY2'. + 'MYMTEQISFavb1Sra1KnJxCjIw5e3sxa2spWlpClJQhSkoYOTkp'. + 'Y2MhUlIQKSkIGBgQMTH+e30mAAAAAXRSTlMAQObYZgAAAAFiS0'. + 'dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfT'. + 'AwkUGTIqLgJPAAAAqklEQVR4nI2QVxOCMBCEM6Mi2OiCvSslJB'. + 'CUoqjn//9TYgCfubf9Zu9uZxFqO+rscO7b6l/LljMZX29J2pNr'. + 'YjmX4ZaIEs2NeiWO19NNacl8rHAyD4LR6jjw6PMRdTjZE0JOiU'. + 'dDv2ALTlzRvSdCCfAHGCc7yRPSrAQRQOWxKc3C/IUjBlDdUcM8'. + '97vFGwBY9QsZGBc/A4DWZNbeXIPWZEZI0c2lqSute/gCO9MXGY'. + '4/IOkAAAAASUVORK5CYII=' ; + + //========================================================== + // File: bs_yellow.png + //========================================================== + $this->imgdata_small[4][0]= 507 ; + $this->imgdata_small[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAzF'. + 'BMVEX///////+/v79zYwCMewDOxoTWzoTezkr/5wj/5wDnzgDe'. + 'xgC1pQCtnACllACcjACUhABjWgDGvVK1rUrOxlLGvUqEexilnB'. + 'jv3hj35xj/7wj/7wD35wDv3gDn1gDezgDWxgDOvQDGtQC9rQCE'. + 'ewB7cwBzawBrYwDWzlLn3lLe1krn3kre1hi9tQC1rQCtpQClnA'. + 'CclACUjACMhAD/9wC/v7///8bOzoT//4T//3v//3P//2v//2Pn'. + '50r//0r//yn39xj//xD//wBjYwDO8noaAAAAAXRSTlMAQObYZg'. + 'AAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAH'. + 'dElNRQfTAwkUGSDZl3MHAAAAqElEQVR4nI3QWRNDMBAA4My09E'. + 'IF1SME0VT1okXvM/3//6kEfbZv+81eswA0DfHxRpOV+M+zkDGG'. + 'rL63zCoJ2ef2RLZDIqNqYexyvFrY9ePkxGWdpvfzC7tEGtIRly'. + 'nqzboFKMlizAXbNnZyiFUKAy4bZ+B6W0lRaQDLmg4h/k7eFwDL'. + 'OWIky8qhXUBQ7gKGmsxpC+ah1TdriwByqG8GQNDNr6kLjf/wAx'. + 'KgEq+FpPbfAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bs_darkgray.png + //========================================================== + $this->imgdata_small[5][0]= 611 ; + $this->imgdata_small[5][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAMAAAAMCGV4AAABJl'. + 'BMVEX////////o8v/f6O7W4OnR3PXL1OTL0evEyLvCzePAwMC/'. + 'v7a8wsq7t7C1xum1vtS1q6GzopmyxeKsrsOqvNWoq7anvN+nsb'. + 'qhrcGgqbGfpq6cp7+bqMuVmJKRm7yPlKKMnL6FkKWFipOEkLSE'. + 'j6qEhoqAiaB+jqd8haF7hZR4iJt4g5l3hZl2gIt2cod1hJVzeY'. + 'VzboJvhp9sfJJsb41peY1pd5xpdoVod4xndI5lcHxka4BjcYVg'. + 'Z3BfboFbb4lbZnZbYntaZ4laZYVZV3JYYWpXX3JWWm5VX4RVW2'. + 'NUYX9SXHxPWn5OVFxNWWtNVXVMVWFKV3xHUGZGU3dGTldFSlxE'. + 'Sk9ESXBCRlNBS3k/SGs/RU4+R1k9R2U6RFU2PUg0PEQxNU0ECL'. + 'QWAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAA'. + 'CxIAAAsSAdLdfvwAAAAHdElNRQfTAwkUGQmbJetrAAAAtklEQV'. + 'R4nGNgwAK4JZTNNOWlYDxhMT4ZDTOzQE1uMF9CiJWVU0LbxDlS'. + 'G8QVF+FnZ2KRNHAIiPUHaZGSlmZj5lH19A1KjLUA8lXU5MWllF'. + 'yjo30TYr2BfG19G11b37CEeN84H38gX1HbwTUkOjo+zjfG3hLI'. + 'l1exCvCNCwnxjfMz0gTyRdXNHXx9fUNCQu2MwU6SN3ZwD42LCH'. + 'W30IK4T8vUJSAkNMhDiwPqYiktXWN9JZj7UQAAjWEfhlG+kScA'. + 'AAAASUVORK5CYII=' ; + + + //========================================================== + // File: bs_darkgreen.png + //========================================================== + $this->imgdata_small[6][0]= 666 ; + $this->imgdata_small[6][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAABX1'. + 'BMVEX////////l/+nAwMC86r+8wb28wby8wLy78sCzw7SywrSx'. + 'wLKwvrGuvK+syK+ryq2rx62n36ym3aumxKmk2qij0Keh16ahva'. + 'Og1aSguKKe06KeuaCetZ+d0KGdtZ+bz6Cay56ZyZ2Zwp2Zr5qZ'. + 'rpqYwJuXyZuXrJmVw5mUxZiTxJeTw5eTq5WRwJWPtJKOvZKKuI'. + '6Kt42Kn4yJt42ItIuGsomFsYmEsIiEr4eDr4eBrIR/qoN+qIJ8'. + 'poB7pH56o356on14nnt2nXl0mndzmnZzmXZymHVwlXNvlHJukn'. + 'FtiHBqjm1qjW1oi2toiWpniWplh2hlhmdkhWdig2VggGNgf2Je'. + 'fmFdfGBde19bbl1aeFxXdFpWclhVclhVcVdUcFZTb1VSbVRQal'. + 'JPaVFKY0xKYkxJYUtIYEpHX0lEWkZCWERCV0NCVkM/U0A+U0A+'. + 'UUA+UEA9Uj89UT48Tj45TDvewfrHAAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'. + 'RQfTAwkUGRjxlcuZAAAAtElEQVR4nGNgIBZw8osqqIpzw/msfI'. + 'IiUmr6lo6SbFARASEOJiYtQ2uXADmIAJeEGFBE18LBMySBBywi'. + 'LC/LwcFiZuvmH5WiAxZR0tRW1DC3dfYJS8zyAouYGBibWtm7+o'. + 'TEpZfkgEX0rG3snNx9Q2NSCksgaqRd3Ty8gyLiU/NKSiDmcPsF'. + 'BodHJ2UUlZTkQ+xikIlNSE7LLgECZagL2VQyc0H8YnV2uD94jS'. + 'ILIo14iQ4HALarJBNwbJVNAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bs_purple.png + //========================================================== + $this->imgdata_small[7][0]= 447 ; + $this->imgdata_small[7][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAnF'. + 'BMVEX///////+/v7/Gvca9rb3Grcb/xv+1hLWte629hL21e7XG'. + 'hMbWhNbOe87We9b/hP//e/97OXv/c///a///Y/+cOZz/Sv/WOd'. + 'bnOefvOe//Kf9jCGNrCGv/EP//CP/nCOf/AP/3APfvAO/nAOfe'. + 'AN7WANbOAM7GAMa9AL21ALWtAK2lAKWcAJyUAJSMAIyEAIR7AH'. + 'tzAHNrAGtjAGPP1sZnAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgF'. + 'HUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkUGS'. + 'o5QpoZAAAAnElEQVR4nI3Q2xJDMBAG4MyQokWrZz3oSkJISJH3'. + 'f7dK0Gv/Xb7J7vyzCK0NjtPsHuH/2wlhTE7LnTNLCO/TFQjjIp'. + 'hHAA6bY06LSqppMAY47x+04HXTba2kAFlmQKr+YuVDCGUG2k6/'. + 'rNwYK8rKwKCnPxHnVS0aA3rag4UQslUGhrlk0Kpv1+sx3tLZ6w'. + 'dtYemMkOsnz8R3V9/hB87DEu2Wos5+AAAAAElFTkSuQmCC' ; + + + //========================================================== + // File: bs_brown.png + //========================================================== + $this->imgdata_small[8][0]= 677 ; + $this->imgdata_small[8][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAABaF'. + 'BMVEX//////////8X/3oD/3nj/1HX/0Gr/xGP/rkv/gBf+iS/2'. + 'bAL1agDxaQDuZwDrZwLpZQDmZQLlZADjcx7gZATeYQDdZgraXw'. + 'DZXwHYXgDXiEvXZAvUjlfUXwXTjVfTbR7ShUvRbR7RWwDMWQDL'. + 'WADKooLKWADJoYLJgkvHWATGoILFn4LFgEvFVgDEZx7EVQDDt6'. + '/DVQDCt6/CnoLChlfCVADAwMC+hFe+UgC8UgC6UQC4gVe4UAC3'. + 'gVe3UAC1gFe1eUu1TwC1TgCzTgCwTQKuTACrSgCqSgCpSgCpSQ'. + 'CodEulSACkRwCiRgCdRACcRACaQwCYQgCWQgKVQQCVQACUQACS'. + 'UR6RPwCOPgCNPQCLPACKPACJOwCEOQCBOAB+NwB9NgB8NgB7NQ'. + 'B6NwJ4NAB3RR52MwB0MgBuLwBtLwBsLwBqLgBpLQBkLQJiKgBh'. + 'KgBgKwRcKABbKQJbJwBaKQRaJwBYKAJVJQDZvdIYAAAAAXRSTl'. + 'MAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLd'. + 'fvwAAAAHdElNRQfTAwkUGho0tvl2AAAAtklEQVR4nGNgIBaoSg'. + 'mLKGpowfkGMty8AqJKpi4mRlAROR5ONg4JFUv3YHOIgDo/HwsT'. + 'q6yps29EsjZYREFIkJ2ZS9/OMzA20wEsIi8uKSZtaOPmH5WSFw'. + 'YW0VRW07Vw8vCLSMguLwCL6FlaObp6B0TGZxSXQ9TouHv6+IXG'. + 'JGYWlpdDzNEKCgmPjkvLKS0vL4LYxWAen5SelV8OBNZQFxrZ5h'. + 'aC+GX2MDczMBh7pZakehkTHQ4AA0Am/jsB5gkAAAAASUVORK5C'. + 'YII=' ; + + //========================================================== + // File: bs_blue.png + //========================================================== + $this->imgdata_small[9][0]= 436 ; + $this->imgdata_small[9][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAk1'. + 'BMVEX///////+/v7+trcbGxv+EhM6EhNaEhP97e/9zc/9ra/9S'. + 'UsZKSrVSUs5jY/9SUtZKSsZSUudKSt5KSudKSv8YGIQpKf8YGK'. + 'UYGN4YGO8YGPcQEP8ICP8AAP8AAPcAAO8AAOcAAN4AANYAAM4A'. + 'AMYAAL0AALUAAK0AAKUAAJwAAJQAAIwAAIQAAHsAAHMAAGsAAG'. + 'ONFkFbAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZ'. + 'cwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkUGhNNakHSAAAAmk'. + 'lEQVR4nI3P2xKCIBAGYGfM6SBWo1nauIqogaDA+z9dK9Lhrv47'. + 'vtl/2A2CfxNlJRRp9IETYGraJeEb7ocLNKznia8A7Db7umWDUG'. + 'sxAzhurxRHxok4KQGqCuEhlL45oU1D2w5BztY4KRhj/bCAsetM'. + '2uObjwvY8/oX50JItYDxSyZSTrO2mNhvGMbaWAevnbFIcpuTr7'. + 't+5AkyfBIKSJHdSQAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bs_green.png + //========================================================== + $this->imgdata_small[10][0]= 452 ; + $this->imgdata_small[10][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAn1'. + 'BMVEX///////+/v7+/v7/G/8aUxpSMvYyUzpSMzoyM1oxarVqE'. + '/4R7/3tavVpKnEpaxlpz/3Nr/2tKtUpj/2Na51pKzkpK1kpK50'. + 'pK/0oYcxgp/ykYlBgY3hgY7xgY9xgQ/xAI/wgA/wAA9wAA7wAA'. + '5wAA3gAA1gAAzgAAxgAAvQAAtQAArQAApQAAnAAAlAAAjAAAhA'. + 'AAewAAcwAAawAAYwA0tyxUAAAAAXRSTlMAQObYZgAAAAFiS0dE'. + 'AIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAw'. + 'kUGgW5vvSDAAAAnklEQVR4nI3QSxKCMAwA0M4gqCgoiiJ+kEAL'. + 'LQUq0PufzX7ENdnlJZNkgtDS2CYZvK6bf+7EoKLA9cH5SQzv6A'. + 'YloTywsAbYr44FrlgrXCMJwHl3xxVtuuFkJAPIcw2tGB9GcFli'. + 'oqEf5GTkSUhVMw2TtD0XSlnDOw3SznE5520vNEi7CwW9+Ayjyq'. + 'U/3+yPuq5gvhkhL0xlGnqL//AFf14UIh4mkEkAAAAASUVORK5C'. + 'YII=' ; + + + //========================================================== + // File: bs_white.png + //========================================================== + $this->imgdata_small[11][0]= 480 ; + $this->imgdata_small[11][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAAQCAYAAADwMZRfAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMLFTsY/ewvBQAAAW1JREFUeJytkz2u4jAUhT/jic'. + 'gfBUKiZhE0bIKeVbCWrIKenp6eDiGlCEEEBArIxvzGU4xeZjLk'. + 'jWb05lRXuvbx+exr4bouX1Xjyw7Atz81F4uFBYjjGIDhcCjq1o'. + 'k6nN1uZwFerxfP55Msy1itVmRZBsB4PK6YveHkeW5d18XzPIIg'. + 'wPd9Wq0WnU6HMAxJkoQoiuynOIfDwUopkVIihKAoCgAcx6Hdbm'. + 'OMIU1T5vN55eBKEikljUYDIX6kFUKU9e8aDAZlmjcca+1b7TgO'. + '1+uVy+VS9nzfr8e53++VzdZaiqIgz3OMMWitOZ/PaK0JgqDeRC'. + 'mF53lIKYGfr3O73TDGoJQiTVO01nS73XqT4/FIs9kkCAIej0eZ'. + 'brPZEMcxSZKgtQZgMpmIWpN+vy+m06n1PK9yTx8Gy+WS/X5Pr9'. + 'er9GuHLYoiG4YhSilOpxPr9Zrtdlti/JriU5MPjUYjq7UuEWaz'. + '2d+P/b/qv/zi75oetJcv7QQXAAAAAElFTkSuQmCC' ; + + + //========================================================== + // File: bs_cyan.png + //========================================================== + $this->imgdata_small[12][0]= 633 ; + $this->imgdata_small[12][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAABPl'. + 'BMVEX////////F///AwMCvxsaC1NSC0dGCz8+CzMyA//94//91'. + '//9q//9j//9X4uJX09NXz89Xx8dXxMRL//9L5uZL3d1L2NhLxs'. + 'ZLt7cv//8e9fUe8fEe7u4e398epqYehoYX//8L+PgK//8F9fUE'. + '/v4E5+cEb28EZ2cC//8C/v4C/f0CzMwCrq4Cjo4CdXUCaWkCZW'. + 'UB/PwA//8A/f0A+/sA8/MA7e0A7OwA6+sA5eUA5OQA4uIA4eEA'. + '3NwA2toA2NgA1dUA09MA0tIA0NAAysoAxsYAxcUAxMQAv78Avr'. + '4AvLwAtrYAtbUAs7MAsLAAra0Aq6sAqKgApaUApKQAoqIAoKAA'. + 'n58AmpoAlZUAk5MAkpIAkJAAj48AjIwAiYkAh4cAf38AfX0Ae3'. + 'sAenoAcnIAcHAAa2sAaWkAaGgAYmIUPEuTAAAAAXRSTlMAQObY'. + 'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'. + 'AHdElNRQfTAwkUGQDi+VPPAAAAtElEQVR4nGNgIBawikipyIiy'. + 'wfksfJpGRkamNtr8LFARPiMFHmFDcztXfwGoFi0jLiZuZRtnry'. + 'BddrCIiJEGL6eklYO7X3iCOFhE2thESdHawdUnJDZFDiyiamZh'. + 'aevk5h0UlZSpBhaRtbN3dPHwDY5MSM+EqBFzc/f0DgiLTkjLzI'. + 'SYw6bjHxgaEZeckZmpD7GLQSAqJj4xNRMIBGFuFtRLA/ENhGBu'. + 'ZmDgkJBXl5fgIDocAAKcINaFePT4AAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bs_bluegreen.png + //========================================================== + $this->imgdata_small[13][0]= 493 ; + $this->imgdata_small[13][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAvV'. + 'BMVEX///////+/v79j//855/8x3v851v9Spb1C1v8AOUqEtcZK'. + 'lK1StdYxzv8hxv8AY4QASmNSlK1KpcZKtd4YQlIYnM4YrecIvf'. + '8AtfcAre8AjL0AhLUAc5wAa5QAWnsAQloAKTkAGCFKhJxKrdYY'. + 'jL0Ypd4Atf8ArfcApecAnN4AlM4AjMYAe60Ac6UAY4wAUnNSnL'. + '0AlNYAWoQASmsAOVIAITGEtc4YWnsAUnsAMUqtvcaErcYAKUIA'. + 'GCkAECHUyVh/AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAA'. + 'AJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkUGxNUcXCT'. + 'AAAAqUlEQVR4nI2Q1xKCMBREM2NHLCCogAGCjd6SqLT8/2cZKT'. + '6zb3tm987OBWCsXoejp8rC35fi4+l6gXFZlD0Rz6fZ1tdDmKR9'. + 'RdOmkzmP7DDpilfX3SzvRgQ/Vr1uiZplfsCBiVf03RJd140wgj'. + 'kmNqMtuYXcxyYmNWJdRoYwzpM9qRvGujuCmSR7q7ARY00/MiWk'. + 'sCnjkobNEm1+HknDZgAqR0GKU43+wxdu2hYzbsHU6AAAAABJRU'. + '5ErkJggg==' ; + + //========================================================== + // File: bs_lightred.png + //========================================================== + $this->imgdata_small[14][0]= 532 ; + $this->imgdata_small[14][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAA3l'. + 'BMVEX///////+/v7/Gvb0hGBj/5///3v//zu//1u//xucpGCG9'. + 'nK21lKVSQkp7Wms5KTExISlaOUpjQlIhEBj/tdbOhKXnrcbGjK'. + 'Wla4TetcbGnK2EWmv/rc73pcZ7UmOcY3vOpbW1jJzenLW9e5Rz'. + 'Slq1c4xrQlJSOULGhJz/pcb3nL2chIzOnK33rcbelK3WjKWMWm'. + 'vGe5SEUmM5ISnOtb3GrbXerb3vpb2ca3v/rcaUY3POhJxCKTF7'. + 'SlrWnK21e4ytc4TvnLXnlK2la3taOUK1lJxrSlLGhJRjQkpSMT'. + 'lw+q2nAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZ'. + 'cwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAwkUGjoP2Nm+AAAAr0'. + 'lEQVR4nGNgIBaYiOk62imYwPnMkiIyso76yhJSzFARMxkRNk49'. + 'a3t5OW6oFk1LVkYOfWUHKxUXiEYzLS12DnN3VXkjIRtFsIiSk5'. + '6evqGqhYGKugAfWMRa1FpD2UHeQEXQRlgALCJur+rgbCUNFOAS'. + 'hqjRkZe3MpBTcwEKCEPMMTGSs3Xz8OQHCnBBHckt6OJpIyAMBD'. + 'wwN/MYc4H4LK4wNzMwmGrzcvFqmxIdDgDiHRT6VVQkrAAAAABJ'. + 'RU5ErkJggg==' ; + + //========================================================== + // File: bxs_lightred.png + //========================================================== + $this->imgdata_xsmall[0][0]= 432 ; + $this->imgdata_xsmall[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAA3l'. + 'BMVEX///////+/v7/Gvb0hGBj/5///3v//zu//1u//xucpGCG9'. + 'nK21lKVSQkp7Wms5KTExISlaOUpjQlIhEBj/tdbOhKXnrcbGjK'. + 'Wla4TetcbGnK2EWmv/rc73pcZ7UmOcY3vOpbW1jJzenLW9e5Rz'. + 'Slq1c4xrQlJSOULGhJz/pcb3nL2chIzOnK33rcbelK3WjKWMWm'. + 'vGe5SEUmM5ISnOtb3GrbXerb3vpb2ca3v/rcaUY3POhJxCKTF7'. + 'SlrWnK21e4ytc4TvnLXnlK2la3taOUK1lJxrSlLGhJRjQkpSMT'. + 'lw+q2nAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZ'. + 'cwAACxEAAAsRAX9kX5EAAAAHdElNRQfTAwkUKBOgGhWjAAAAS0'. + 'lEQVR4nGNgQAEmunYmEJaMCKe1vBxYzJKVQ9lKBSSupKdnaKGi'. + 'zgdkiqs6WKnYcIGYJnK2HvzCwmCNgi42wsLCECNMeXlNUY0HAL'. + 'DaB7Du8MiEAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bxs_bluegreen.png + //========================================================== + $this->imgdata_xsmall[1][0]= 397 ; + $this->imgdata_xsmall[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAvV'. + 'BMVEX///////+/v79j//855/8x3v851v9Spb1C1v8AOUqEtcZK'. + 'lK1StdYxzv8hxv8AY4QASmNSlK1KpcZKtd4YQlIYnM4YrecIvf'. + '8AtfcAre8AjL0AhLUAc5wAa5QAWnsAQloAKTkAGCFKhJxKrdYY'. + 'jL0Ypd4Atf8ArfcApecAnN4AlM4AjMYAe60Ac6UAY4wAUnNSnL'. + '0AlNYAWoQASmsAOVIAITGEtc4YWnsAUnsAMUqtvcaErcYAKUIA'. + 'GCkAECHUyVh/AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAA'. + 'AJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElNRQfTAwkUKDVyF5Be'. + 'AAAASUlEQVR4nGNgQAFmYqJcEJaEOJ+UrD5YTJKFTZrfGCQuaq'. + 'glLWvMaQ5kqujo6hnbKIKYXPr68gp2dmCNJiZAlh3ECGsREWtU'. + '4wF1kwdpAHfnSwAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bxs_navy.png + //========================================================== + $this->imgdata_xsmall[2][0]= 353 ; + $this->imgdata_xsmall[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAk1'. + 'BMVEX///////+/v7+trcbGxv+EhM6EhNaEhP97e/9zc/9ra/9S'. + 'UsZKSrVSUs5jY/9SUtZKSsZSUudKSt5KSudKSv8YGIQpKf8YGK'. + 'UYGN4YGO8YGPcQEP8ICP8AAP8AAPcAAO8AAOcAAN4AANYAAM4A'. + 'AMYAAL0AALUAAK0AAKUAAJwAAJQAAIwAAIQAAHsAAHMAAGsAAG'. + 'ONFkFbAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZ'. + 'cwAACxEAAAsRAX9kX5EAAAAHdElNRQfTAwkUJxXO4axZAAAAR0'. + 'lEQVR4nGNgQAGskhKsEJaslIi8ijpYTJaDU1FVAyQuKSujoKKh'. + 'LQ5kSigpqWro6oOYrOoaWroGBmCNWiCWAdQwUVFWVOMBOp4GCJ'. + 's5S60AAAAASUVORK5CYII=' ; + + //========================================================== + // File: bxs_gray.png + //========================================================== + $this->imgdata_xsmall[3][0]= 492 ; + $this->imgdata_xsmall[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAABI1'. + 'BMVEX///8AAAD8EAD8IAD8NAD8RAD8VAAYGBi/v7+goKCCgoJk'. + 'ZGRGRkb8yAD83AD87AD8/AD4+ADo+ADY+ADI+AC0+ACk+ACU+A'. + 'CE+AB0/ABk/ABU/ABE/AAw/AAg/AAQ/AAA/AAA+AAA6BAA2CAA'. + 'yDQAtEQApFQAlGQAhHQAdIgAZJgAVKgARLgAMMgAINwAEOwAAP'. + 'wAAPgIAPAQAOgYAOAkANgsANA0AMg8AMBEALhMALBUAKhcAKBo'. + 'AJhwAJB4AIiAAID////4+Pjy8vLs7Ozm5ubg4ODa2trT09PNzc'. + '3Hx8fBwcG7u7u1tbWurq6oqKiioqKcnJyWlpaQkJCJiYmDg4N9'. + 'fX13d3dxcXFra2tkZGReXl5YWFhSUlJMTExGRkZAQEA1BLn4AA'. + 'AAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxEA'. + 'AAsRAX9kX5EAAAAHdElNRQfTAwkUKC74clmyAAAAQklEQVR4nG'. + 'NgQAVBYVCGt5dXYEQ0mOnp5h4QFgVmeri6+4dHxYMVeHoFRUTH'. + 'gTUFBIZBWAwMkZEx8bFQM2Lj0UwHANc/DV6yq/BiAAAAAElFTk'. + 'SuQmCC' ; + + //========================================================== + // File: bxs_graypurple.png + //========================================================== + $this->imgdata_xsmall[4][0]= 542 ; + $this->imgdata_xsmall[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAABSl'. + 'BMVEX////////11P/MqdvKrNfAwMC+u7+9u7+4rr24lsi3rby3'. + 'lMe1rLq1o720q7i0oL20ksSzoryyqbaykMGxlb2wkL+vnbiujb'. + '2sjLuri7qpl7GoirWoibenmK2mla6mjLKmhrSllauki7CjhrCj'. + 'hLGihLChg6+ggq2fkqadkKOcfqqai6Gag6WYe6WXeqSWeaOTd6'. + 'CTd5+Rdp6RdZ6RdZ2Qg5eOc5qMcpiLcZeJb5WIbpOHbZKGbJGE'. + 'a4+CaY2AZ4t/Z4p/Zop/Zol+Zol7ZIZ6Y4V5YoR1ZH11X391Xn'. + '9zXX1yXXtxXHtvWnluWXhsV3VqVnNpVXJoVHFnU3BmUm9jUGth'. + 'VGdgTmheTGZcS2RcSmRaSWJYR19XRl5SQllRQlhQQVdPQFZOP1'. + 'VLPlFJO09IPE5IOk5FOEtEN0lDOEpDOElDNklCNkc/M0XhbrfD'. + 'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx'. + 'EAAAsRAX9kX5EAAAAHdElNRQfTAwkUKCgREfyHAAAATUlEQVR4'. + 'nGNgQAEcIko8EBY3M5Ougy+IxSXMwmTsFsAHZMqrSRvZB0W7A5'. + 'k6FlYugXEZICaPr394Um4uSAFDRFRCbm4uxAihsDAhVOMBHT0L'. + 'hkeRpo8AAAAASUVORK5CYII=' ; + + //========================================================== + // File: bxs_red.png + //========================================================== + $this->imgdata_xsmall[5][0]= 357 ; + $this->imgdata_xsmall[5][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAk1'. + 'BMVEX////////GxsbGra3/xsbOhITWhIT/hIT/e3v/c3P/a2vG'. + 'UlK1SkrOUlL/Y2PWUlLGSkrnUlLeSkrnSkr/SkqEGBj/KSmlGB'. + 'jeGBjvGBj3GBj/EBD/CAj/AAD3AADvAADnAADeAADWAADOAADG'. + 'AAC9AAC1AACtAAClAACcAACUAACMAACEAAB7AABzAABrAABjAA'. + 'BuukXBAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZ'. + 'cwAACxEAAAsRAX9kX5EAAAAHdElNRQfTAwkUIyjy5SVMAAAAS0'. + 'lEQVR4nGNgQAFsUpJsEJastIi8ijpYTJaDU0FVgxXIlJKVUVDR'. + '0BYHMiUUlVQ1dPVBTDZ1dS1dAwOQAgYtbSDLAGIEq6goK6rxAD'. + 'yXBg73lwGUAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: bxs_yellow.png + //========================================================== + $this->imgdata_xsmall[6][0]= 414 ; + $this->imgdata_xsmall[6][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAzF'. + 'BMVEX///////+/v79zYwCMewDOxoTWzoTezkr/5wj/5wDnzgDe'. + 'xgC1pQCtnACllACcjACUhABjWgDGvVK1rUrOxlLGvUqEexilnB'. + 'jv3hj35xj/7wj/7wD35wDv3gDn1gDezgDWxgDOvQDGtQC9rQCE'. + 'ewB7cwBzawBrYwDWzlLn3lLe1krn3kre1hi9tQC1rQCtpQClnA'. + 'CclACUjACMhAD/9wC/v7///8bOzoT//4T//3v//3P//2v//2Pn'. + '50r//0r//yn39xj//xD//wBjYwDO8noaAAAAAXRSTlMAQObYZg'. + 'AAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAH'. + 'dElNRQfTAwkUIzoBXFQEAAAAS0lEQVR4nGNgQAFsDhJsEJaTo5'. + '2skj5YzMnSSk7ZwBzIlOSUklPiMxYHMnW4FXT5VNVBTDZeXiNV'. + 'QUGQAgYBYyBLEGIEq5gYK6rxAH4kBmHBaMQQAAAAAElFTkSuQm'. + 'CC' ; + + //========================================================== + // File: bxs_greenblue.png + //========================================================== + $this->imgdata_xsmall[7][0]= 410 ; + $this->imgdata_xsmall[7][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAxl'. + 'BMVEX///////+/v79znJQhSkJ7raU5hHtjraVKnJRCjIRClIyU'. + '9++E595avbVaxr2/v7+ctbWcvb17nJxrjIx7paUxQkK9//+Mvb'. + '17ra2Evb17tbVCY2MQGBiU5+ec9/eM5+d71tZanJxjra1rvb1j'. + 'tbVSnJxara1rzs5jxsZKlJRChIQpUlIhQkJatbVSpaU5c3MxY2'. + 'MYMTEQISFavb1Sra1KnJxCjIw5e3sxa2spWlpClJQhSkoYOTkp'. + 'Y2MhUlIQKSkIGBgQMTH+e30mAAAAAXRSTlMAQObYZgAAAAFiS0'. + 'dEAIgFHUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElNRQfT'. + 'AwkUJy5/6kV9AAAATUlEQVR4nGNgQAGCyuyCEJaGugKHviVYzF'. + 'hO3sxCWwDIVNLTM9PXtpEGMhW12Cy0DR1ATEFLSxZ7BweQAgYd'. + 'HUMHBweIEQKiogKoxgMAo/4H5AfSehsAAAAASUVORK5CYII=' ; + + //========================================================== + // File: bxs_purple.png + //========================================================== + $this->imgdata_xsmall[8][0]= 364 ; + $this->imgdata_xsmall[8][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAnF'. + 'BMVEX///////+/v7/Gvca9rb3Grcb/xv+1hLWte629hL21e7XG'. + 'hMbWhNbOe87We9b/hP//e/97OXv/c///a///Y/+cOZz/Sv/WOd'. + 'bnOefvOe//Kf9jCGNrCGv/EP//CP/nCOf/AP/3APfvAO/nAOfe'. + 'AN7WANbOAM7GAMa9AL21ALWtAK2lAKWcAJyUAJSMAIyEAIR7AH'. + 'tzAHNrAGtjAGPP1sZnAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgF'. + 'HUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElNRQfTAwkUIj'. + 'mBTjT/AAAASUlEQVR4nGNgQAGskhKsEJaCrJiSuhZYTEFASFlD'. + 'GyQuqSCnrK6tJwpkiquoamgbGIGYrFpaugbGxmCNunpAljHECB'. + 'ZBQRZU4wFSMAZsXeM71AAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bxs_green.png + //========================================================== + $this->imgdata_xsmall[9][0]= 370 ; + $this->imgdata_xsmall[9][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAn1'. + 'BMVEX///////+/v7+/v7/G/8aUxpSMvYyUzpSMzoyM1oxarVqE'. + '/4R7/3tavVpKnEpaxlpz/3Nr/2tKtUpj/2Na51pKzkpK1kpK50'. + 'pK/0oYcxgp/ykYlBgY3hgY7xgY9xgQ/xAI/wgA/wAA9wAA7wAA'. + '5wAA3gAA1gAAzgAAxgAAvQAAtQAArQAApQAAnAAAlAAAjAAAhA'. + 'AAewAAcwAAawAAYwA0tyxUAAAAAXRSTlMAQObYZgAAAAFiS0dE'. + 'AIgFHUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElNRQfTAw'. + 'kUKBrZxq0HAAAATElEQVR4nGNgQAGccrIcEJaivISyhjaIxa7I'. + 'I6CiqcMKZMopKqho6OhLA5kyqmqaOobGICartraeoYkJSAGDnj'. + '6QZQIxgk1Skg3VeABlVgbItqEBUwAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bxs_darkgreen.png + //========================================================== + $this->imgdata_xsmall[10][0]= 563 ; + $this->imgdata_xsmall[10][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAABX1'. + 'BMVEX////////l/+nAwMC86r+8wb28wby8wLy78sCzw7SywrSx'. + 'wLKwvrGuvK+syK+ryq2rx62n36ym3aumxKmk2qij0Keh16ahva'. + 'Og1aSguKKe06KeuaCetZ+d0KGdtZ+bz6Cay56ZyZ2Zwp2Zr5qZ'. + 'rpqYwJuXyZuXrJmVw5mUxZiTxJeTw5eTq5WRwJWPtJKOvZKKuI'. + '6Kt42Kn4yJt42ItIuGsomFsYmEsIiEr4eDr4eBrIR/qoN+qIJ8'. + 'poB7pH56o356on14nnt2nXl0mndzmnZzmXZymHVwlXNvlHJukn'. + 'FtiHBqjm1qjW1oi2toiWpniWplh2hlhmdkhWdig2VggGNgf2Je'. + 'fmFdfGBde19bbl1aeFxXdFpWclhVclhVcVdUcFZTb1VSbVRQal'. + 'JPaVFKY0xKYkxJYUtIYEpHX0lEWkZCWERCV0NCVkM/U0A+U0A+'. + 'UUA+UEA9Uj89UT48Tj45TDvewfrHAAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElN'. + 'RQfTAwkUKCFozUQjAAAATUlEQVR4nGNgQAGcoqrcEJYQB5OhSw'. + 'CIxSXGwWThGcIDZCppK5o7hyV6AZl6NnbuoSmFICZ3YHB0RkkJ'. + 'SAFDbEJaSUkJxAjeyEheVOMBQj4MOEkWew4AAAAASUVORK5CYI'. + 'I=' ; + + //========================================================== + // File: bxs_cyan.png + //========================================================== + $this->imgdata_xsmall[11][0]= 530 ; + $this->imgdata_xsmall[11][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAABPl'. + 'BMVEX////////F///AwMCvxsaC1NSC0dGCz8+CzMyA//94//91'. + '//9q//9j//9X4uJX09NXz89Xx8dXxMRL//9L5uZL3d1L2NhLxs'. + 'ZLt7cv//8e9fUe8fEe7u4e398epqYehoYX//8L+PgK//8F9fUE'. + '/v4E5+cEb28EZ2cC//8C/v4C/f0CzMwCrq4Cjo4CdXUCaWkCZW'. + 'UB/PwA//8A/f0A+/sA8/MA7e0A7OwA6+sA5eUA5OQA4uIA4eEA'. + '3NwA2toA2NgA1dUA09MA0tIA0NAAysoAxsYAxcUAxMQAv78Avr'. + '4AvLwAtrYAtbUAs7MAsLAAra0Aq6sAqKgApaUApKQAoqIAoKAA'. + 'n58AmpoAlZUAk5MAkpIAkJAAj48AjIwAiYkAh4cAf38AfX0Ae3'. + 'sAenoAcnIAcHAAa2sAaWkAaGgAYmIUPEuTAAAAAXRSTlMAQObY'. + 'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAA'. + 'AHdElNRQfTAwkUKQFKuFWqAAAATUlEQVR4nGNgQAGsUjJsEJaR'. + 'grC5qz9YzIiL28YriB3IlDZRsnYNiZUDMmXtHT2CE9JBTDb/wI'. + 'jkzEyQAoaomMTMzEyIERzy8hyoxgMAN2MLVPW0f4gAAAAASUVO'. + 'RK5CYII=' ; + + //========================================================== + // File: bxs_orange.png + //========================================================== + $this->imgdata_xsmall[12][0]= 572 ; + $this->imgdata_xsmall[12][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAABaF'. + 'BMVEX//////////8X/3oD/3nj/1HX/0Gr/xGP/rkv/gBf+iS/2'. + 'bAL1agDxaQDuZwDrZwLpZQDmZQLlZADjcx7gZATeYQDdZgraXw'. + 'DZXwHYXgDXiEvXZAvUjlfUXwXTjVfTbR7ShUvRbR7RWwDMWQDL'. + 'WADKooLKWADJoYLJgkvHWATGoILFn4LFgEvFVgDEZx7EVQDDt6'. + '/DVQDCt6/CnoLChlfCVADAwMC+hFe+UgC8UgC6UQC4gVe4UAC3'. + 'gVe3UAC1gFe1eUu1TwC1TgCzTgCwTQKuTACrSgCqSgCpSgCpSQ'. + 'CodEulSACkRwCiRgCdRACcRACaQwCYQgCWQgKVQQCVQACUQACS'. + 'UR6RPwCOPgCNPQCLPACKPACJOwCEOQCBOAB+NwB9NgB8NgB7NQ'. + 'B6NwJ4NAB3RR52MwB0MgBuLwBtLwBsLwBqLgBpLQBkLQJiKgBh'. + 'KgBgKwRcKABbKQJbJwBaKQRaJwBYKAJVJQDZvdIYAAAAAXRSTl'. + 'MAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxEAAAsRAX9k'. + 'X5EAAAAHdElNRQfTAwkUJBSSy88MAAAATUlEQVR4nGNgQAGqwo'. + 'paEBYPJ4eKezCIpc7HwmrqG6ENZMpLihm6RaWEAZl6Vo7ekRnF'. + 'IKZWSHhcTnk5SAFDfFJWeXk5xAjj1FRjVOMBeFwNcWYSLjsAAA'. + 'AASUVORK5CYII=' ; + + //========================================================== + // File: bxs_lightblue.png + //========================================================== + $this->imgdata_xsmall[13][0]= 554 ; + $this->imgdata_xsmall[13][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAABVl'. + 'BMVEX////////d///AwMC7wcS08P+y+P+xxdCwxM+uws2twMur'. + 'vsinzNynytylzuKhyN6e5v6d5P+d1fOcwNWcu8ub4f+at8iZ3v'. + '+ZvdGY2/yW2f+VscGU1vuT1fqTr72Sx+SSxeKR0fWRz/GPz/OP'. + 'rr+OyeqMy+6Myu2LyeyKxueJudSGw+SGorGDvt+Cvd6CvN2Aud'. + 'p+uNd+t9Z9tdV8tdR8tNN6sc94r813rct2q8h0qcZ0qMVzp8Rx'. + 'o8Bwor5tn7ptnrptnrlsnbhqmbRpmbNpi51ol7Flkqtkkqtkka'. + 'pjj6hijaRhjaZgi6NfiqJfiaFdh55bhJtag5pZgphYgJZYf5VX'. + 'cn9Ve5FSeI1RdopRdYlQdYlPc4dPcoZPcoVNcINLboBLbH9GZn'. + 'hGZXdFZHZEY3RDYnJCXW4/W2s/WWg+Wmo7VmU7VGM7U2E6VGM6'. + 'VGI5UV82T1wGxheQAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHU'. + 'gAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElNRQfTAwkUJziL'. + 'PvAsAAAATUlEQVR4nGNgQAHsQgqcEJYgG5Oegy+IxSHOxmTiFs'. + 'gFZMprKBnbB8e7AplaFlbOQUl5ICanX0BEWmEhSAFDVGxKYWEh'. + 'xAjusDBuVOMBJO8LrFHRAykAAAAASUVORK5CYII=' ; + + //========================================================== + // File: bxs_darkgray.png + //========================================================== + $this->imgdata_xsmall[14][0]= 574 ; + $this->imgdata_xsmall[14][1]= + 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABm'. + 'JLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsRAAALEQF/ZF+RAAAB'. + 'iElEQVR42k3QPU8TYRwA8P//ebkXrgdIColXRAOEkJqbaExMut'. + 'DBhE1GNjYHPg+DG6ODiU6QOLjVxITBcFKBYCstlAC2Bz17fe76'. + 'vLD6+wg/1FpTRFR5lpaub/u1eGBGaAT4HneD4OlXx7avtDYUjT'. + 'HQabd2Ti8e3vVSKzxrtHS32wIpFVldno22Nqvvg2Bhl0gp/aNm'. + 'vJ3qqXAtLIva+ks1H0wqlSXi4+d6+OFTfRsAfHJx2d1od24rZP'. + 'xP2HzopINr1mkesX7ccojqif0v9crxWXODZTno3+dNGA7uWLsd'. + 'mUYU4fHJCViMG9umLBmM4L6fagZGg9QKfjZ+Qfy3C3G/B3mugF'. + 'IHHNcDf64E3KJALApk2p8CSolUUqLjFkyxOGMsTtFyJ+Wz57NQ'. + '8DghS4sLB0svioeZZo7nPhFoUKZDIVFbglkTTnl5/rC8snjAkJ'. + 'Bk/XV5LxHC/v7tR8jzTFPbg8LENK9WX0Vv31T2AEmCSmlKCCoh'. + 'ROnP1U1tPFYjJBRcbtzSf+GPsFTAQBq1n4AAAABKdEVYdHNpZ2'. + '5hdHVyZQBiYzYyMDIyNjgwYThjODMyMmUxNjk0NWUzZjljOGFh'. + 'N2VmZWFhMjA4OTE2ZjkwOTdhZWE1MzYyMjk0MWRkM2I5EqaPDA'. + 'AAAABJRU5ErkJggg==' ; + } +} + +?> diff --git a/html/jpgraph/imgdata_bevels.inc.php b/html/jpgraph/imgdata_bevels.inc.php new file mode 100644 index 0000000..c98fa57 --- /dev/null +++ b/html/jpgraph/imgdata_bevels.inc.php @@ -0,0 +1,104 @@ +<?php +//======================================================================= +// File: IMGDATA_BEVELS.INC +// Description: Base64 encoded images for round bevels +// Created: 2003-03-20 +// Ver: $Id: imgdata_bevels.inc.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +class ImgData_Bevels extends ImgData { + protected $name = 'Round Bevels'; + protected $an = array(MARK_IMG_BEVEL => 'imgdata'); + + protected $colors = array('green','purple','orange','red','yellow'); + protected $index = array('green'=>1,'purple'=>4,'orange'=>2,'red'=>0,'yellow'=>3); + protected $maxidx = 4 ; + + protected $imgdata ; + + function __construct() { + //========================================================== + // File: bullets_balls_red_013.png + //========================================================== + $this->imgdata[0][0]= 337 ; + $this->imgdata[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'. + 'BMVEX////////27t/f3+LFwcmNxMuxm62DmqKth1VpZmIWg6fv'. + 'HCa7K0BwMEytCjFnIyUlEBg9vhQvAAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'. + 'RQfTAxcBNhk+pYJVAAAAl0lEQVR4nE2Q2xLDIAgFHUWBKJf//9'. + 'oekmbafVDZARRbK/pYTKP9WNcNv64zzUdd9BjmrgnsVXRNSzO3'. + 'CJ5ahdhy0XKQkxld1kxb45j7dp0x2lBNOyVgQpMaoadX7Hs7zr'. + 'P1yKj47DKBnKaBKiSAkNss7O6PkMx6kIgYXISQJpcZCqdY6KR+'. + 'J1PkS5Xob/h7MNz8x6D3fz5DKQjpkZOBYAAAAABJRU5ErkJggg'. + '==' ; + + //========================================================== + // File: bullets_balls_green_013.png + //========================================================== + $this->imgdata[1][0]= 344 ; + $this->imgdata[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'. + 'BMVEX////////27t/e3+K3vriUub/Dm18j4xc3ob10k0ItqQlU'. + 'e5JBmwpxY1ENaKBgUh0iHgwsSre9AAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'. + 'RQfTAxcBNTfJXtxZAAAAnklEQVR4nE2QWY4EMQhDUVhSIRC4/2'. + 'kbaqLp9p+f2AxAayAzDfiK9znPORuvH0x8Ss9z6I9sHp6tcxE9'. + 'nLmWmebmt5F5p2AR0+C9AWpLBjXRaZsCAT3SqklVp0YkAWaGtd'. + 'c5Z41/STYpPzW7BjyiRrwkVmQto/Cw9tNEMvsgcekyCyFPboIu'. + 'IsuXiKffYB4NK4r/h6d4g9HPPwCR7i8+GscIiiaonUAAAAAASU'. + 'VORK5CYII=' ; + + //========================================================== + // File: bullets_balls_oy_035.png + //========================================================== + $this->imgdata[2][0]= 341 ; + $this->imgdata[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'. + 'BMVEX////////27t/f3+K5tbqNwcjnkjXjbxR2i5anfEoNkbis'. + 'PBxpU0sZbZejKgdqIRIlERIwYtkYAAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'. + 'RQfTAxcBNgK0wEu5AAAAm0lEQVR4nE3QVxIEIQgEUErAgTHA/U'. + '+7zbipf9RXgoGo0liMmX6RdSPLPtZM9F4LuuSIaZtZWffiU6Iz'. + 'Y8SOMF0NogBj30ioGRGLZgiPvce1TbIRz6oBQEbOFGK0rIoxrn'. + '5hDomMA1cfGRCaRVhjS3gkzheM+4HtnlkXcvdZhWG4qZawewe6'. + '9Jnz/TKLB/ML6HUepn//QczazuwFO/0Ivpolhi4AAAAASUVORK'. + '5CYII=' ; + + //========================================================== + // File: bullets_balls_oy_036.png + //========================================================== + $this->imgdata[3][0]= 340 ; + $this->imgdata[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'. + 'BMVEX////////27t/e3+LO3hfYzz65ubiNwci6uQ12ipadgVGa'. + 'fwsNkbhnVkcaZ5dwSA8lFg7CEepmAAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElN'. + 'RQfTAxcCBySi1nevAAAAjElEQVR4nFXPWw7EIAgFUNMoCMhj/6'. + 'staKczc/2RkwjS2glQ+w3YytgXCXCZpRo8gJdGxZadJws13CUP'. + '4SZI4MYiUxypeiGGw1XShVBTNN9kLXP2GRrZPFvKgd7z/sqGGV'. + '7C7r7r3l09alYN3iA8Yn+ImdVrNoEeSRqJPAaHfhZzLYwXstdZ'. + 'rP3n2bvdAI4INwtihiwAAAAASUVORK5CYII=' ; + + //========================================================== + // File: bullets_balls_pp_019.png + //========================================================== + $this->imgdata[4][0]= 334 ; + $this->imgdata[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'. + 'BMVEX////+/v7i4eO/w8eHxcvKroNVormtfkjrMN2BeXQrepPc'. + 'Esy4IL+OFaR7F25LHF8mFRh5XXtUAAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'. + 'RQfTAxcBNgkjEpIxAAAAlElEQVR4nE2QAQ7FIAhDDTAVndL7n3'. + 'ZV/7JfEwMvFIWUlkTMVNInbVv5ZeJqG7Smh2QTBwJBpsdizAZP'. + '5NyW0awhK8kYodnZxS6ECvPRp2sI+y7PBv1mN02KH7h77QCJ8D'. + '4VvY5NUgEmCwj6ZMzHtJRgRSXwC1gfcqJJH0GBnSnK1kUQ72DY'. + 'CPBv+MCS/e0jib77eQAJxwiEWm7hFwAAAABJRU5ErkJggg==' ; + + } +} + + +?> diff --git a/html/jpgraph/imgdata_diamonds.inc.php b/html/jpgraph/imgdata_diamonds.inc.php new file mode 100644 index 0000000..a0d6a42 --- /dev/null +++ b/html/jpgraph/imgdata_diamonds.inc.php @@ -0,0 +1,177 @@ +<?php +//======================================================================= +// File: IMGDATA_DIAMONDS.INC +// Description: Base64 encoded images for diamonds +// Created: 2003-03-20 +// Ver: $Id: imgdata_diamonds.inc.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +class ImgData_Diamonds extends ImgData { + protected $name = 'Diamonds'; + protected $an = array(MARK_IMG_DIAMOND =>'imgdata'); + protected $colors = array('lightblue','darkblue','gray', + 'blue','pink','purple','red','yellow'); + protected $index = array('lightblue' =>7,'darkblue'=>2,'gray'=>6, + 'blue'=>4,'pink'=>1,'purple'=>5,'red'=>0,'yellow'=>3); + + protected $maxidx = 7 ; + protected $imgdata ; + + function __construct() { + //========================================================== + // File: diam_red.png + //========================================================== + $this->imgdata[0][0]= 668 ; + $this->imgdata[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA/F'. + 'BMVEX///////+cAAD/AADOAABjAABrAADWGBjOCAj/CAj/GBj/'. + 'EBCcCAiMOTl7KSl7ISFzGBilGBjOEBBrCAjv5+eMQkK1QkKtMT'. + 'GtKSnWKSn/KSlzEBCcEBDexsb/tbXOe3ucWlqcUlKUSkr/e3vn'. + 'a2u9UlL/a2uEMTHeUlLeSkqtOTn/UlL/SkrWOTn/QkL/OTmlIS'. + 'H/MTH/ISH39/f/9/f35+fezs7/5+fvzs7WtbXOra3nvb3/zs7G'. + 'nJzvtbXGlJTepaW9jIy1hITWlJS1e3uta2ulY2P/lJTnhITne3'. + 'vGY2O9Wlr/c3PeY2O1Skr/Y2P/WlreQkLWISGlEBCglEUaAAAA'. + 'AXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAA'. + 'sSAdLdfvwAAAAHdElNRQfTAwsWEw5WI4qnAAABGUlEQVR4nHXQ'. + '1XLDMBAFUKUCM1NiO8zcpIxpp8z0//9SWY7b2LHv6EU6s1qtAN'. + 'iMBAojLPkigpJvogKC4pxDuQipjanlICXof1RQDkYEF21mKIfg'. + '/GGKtjAmOKt9oSyuCU7OhyiDCQnjowGfRnooCJIkiWJvv8NxnG'. + 'nyNAwFcekvZpPP3mu7Vrp8fOq8DYbTyjdnAvBj7Jbd7nP95urs'. + '+MC2D6unF+Cu0VJULQBAlsOQuueN3Hrp2nGUvqppemBZ0aU7Se'. + 'SXvYZFMKaLJn7MH3btJmZEMEmGSOreqy0SI/4ffo3uiUOYEACy'. + 'OFopmNWlP5uZd9uPWmUoxvK9ilO9NtBo6mS7KkZD0fOJYqgGBU'. + 'S/T7OKCAA9tfsFOicXcbxt29cAAAAASUVORK5CYII=' ; + + //========================================================== + // File: diam_pink.png + //========================================================== + $this->imgdata[1][0]= 262 ; + $this->imgdata[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'. + 'BMVEX///+AgID/M5n/Zpn/zMz/mZn1xELhAAAAAXRSTlMAQObY'. + 'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'. + 'AHdElNRQfTAwsWEi3tX8qUAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'. + 'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'. + '6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'. + 'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'. + '==' ; + + //========================================================== + // File: diam_blue.png + //========================================================== + $this->imgdata[2][0]= 662 ; + $this->imgdata[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA+V'. + 'BMVEX///+AgIAAAJwAAP8AAM4AAGMAAGsQEP8YGHMQEHMYGP8Q'. + 'EKUICJwICM5KSpQxMYQpKXsYGNYQEM4ICGsICP97e85aWpw5OY'. + 'xSUv85ObVCQt4xMa0pKa0hIaUpKf+9vd6EhLVra+dzc/9SUr1r'. + 'a/9aWt5SUt5CQrVaWv9KSv8hIXs5Of8xMf8pKdYhIdYYGKUhIf'. + '/Ozs739//v7/fn5+/v7//n5/fW1ufOzufOzu/W1v+trc69veel'. + 'pc6trd6UlMa9vf+MjL21tfe1tf+UlNZzc61ra6Wlpf+EhOeMjP'. + '9ra8ZSUpyEhP9CQoxKSrVCQv85Od4xMdYQENZnJhlWAAAAAXRS'. + 'TlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAd'. + 'LdfvwAAAAHdElNRQfTAwsWEx3Snct5AAABFklEQVR4nHXR5XbD'. + 'IBgGYM6AuHsaqbvOfeuknev9X8xISbplSd5/8JyXwwcA/I0AKm'. + 'PFchVBdvKNKggKQx2VIoRwMZihMiQE49YUlWBCcPL0hYq4ITh+'. + 'qKECUoLDZWqoQNA766F/mJHlHXblPJJNiyURhM5eU9cNw5BlmS'. + 'IrLOLxhzfotF7vwO2j3ez2ap/TmW4AIM7DoN9+tu+vLk6Pdg9O'. + '6ufXjfXLm6pxPACSJIpRFAa+/26DhuK6qjbiON40k0N3skjOvm'. + 'NijBmchF5mi+1jhQqDmWyIzPp1hUlrv8On5l+6mMm1tigFNyrt'. + '5R97g+FKKyGKkTNKesXPJTZXOFIrUoKiypcTQVHjK4g8H2dWEQ'. + 'B8bvUDLSQXSr41rmEAAAAASUVORK5CYII=' ; + + //========================================================== + // File: diam_yellow.png + //========================================================== + $this->imgdata[3][0]= 262 ; + $this->imgdata[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'. + 'BMVEX///+AgIBmMwCZZgD/zADMmQD/QLMZAAAAAXRSTlMAQObY'. + 'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'. + 'AHdElNRQfTAwsWEwcv/zIDAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'. + 'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'. + '6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'. + 'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'. + '==' ; + + //========================================================== + // File: diam_lightblue.png + //========================================================== + $this->imgdata[4][0]= 671 ; + $this->imgdata[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA/1'. + 'BMVEX///+AgIAAnP8A//8Azv8AY/8Aa/8I//8Y1v8Izv8Y//8Q'. + '//8InP8Qzv8Ypf85jP8he/8Yc/8Ia/8pe/8p//8p1v9Ctf8xrf'. + '8prf8QnP8Qc/9CjP+1//97//9r//9S//9K//9C//85//8x//8h'. + '//9r5/9K3v9S3v851v97zv9Svf85rf8hpf/G3v9SnP9anP9KlP'. + '8xhP/n7//v7+f3///n///O//+U//9z//9j//9a//975/9C3v8h'. + '1v+E5/+17/9j3v/O7//n9/+95/+l3v9jxv+U1v8Qpf9avf9Ktf'. + '+Uxv+11v97tf9rrf+cxv+Mvf9jpf+tzv+Etf/O3v/39/8Akkxr'. + 'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx'. + 'IAAAsSAdLdfvwAAAAHdElNRQfTAwsWEiHk6Ya/AAABGUlEQVR4'. + 'nHXQ13KDMBAF0J2o0E01GHDvJa7p3em95/+/JQJMYjDc0Yt0Zr'. + 'VaAaxHgtxwbSGPkGQpOIeQ2ORxJiJmNWYZyAhZR0WcgQGhViU0'. + 'nEGoedDHGxgRapRPcRpXhOr7XZzCmLjaXk9IIjvkOEmSRLG62+'. + 'F5XlEElhA5sW21GvXj6mGlDBfnJ51lr9svnvEKwH1hu2QPbwd3'. + 'N9eXVzuL7/Hn29frdKaamgcgy67L3HFG9gDefV+dm5qme4YRXL'. + 'oVR374mRqUELZYosf84XAxISFRQuMh4rrH8YxGSP6HX6H97NNQ'. + 'KEAaR08qCeuSnx2a8zIPWqUowtKHSRK91rAw0elmVYQFVc8mhq'. + '7p5RD7Ps3IIwA9sfsFxFUX6eZ4Zh4AAAAASUVORK5CYII=' ; + + //========================================================== + // File: diam_purple.png + //========================================================== + $this->imgdata[5][0]= 657 ; + $this->imgdata[5][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA/F'. + 'BMVEX///////8xAP/OAP+cAP9jAP9rAP+cCP85CP/OEP9SKf/O'. + 'CP9CEP9zGP9rCP+lGP/WOf/WIf9KIf9jOf+MQv+EMf97If9zEP'. + '+1Sv+lIf/ne//eUv/na//n5//Oxv/Wzv+chP9zUv97Wv9rQv9a'. + 'Mf9KGP/v5/+te/97Kf+9Y/+tOf+tKf+lEP/vtf/WMf/WKf/v7+'. + 'f39/+tnP+9rf9rSv9jQv9CGP+ljP+EY//Gtf+tlP+Ma/9zSv/e'. + 'zv+UUv+9lP+cWv+lY/+cUv+MOf+EKf+UQv/Opf/OhP/Ga/+1Qv'. + '/Oe/+9Uv/ntf/eWv/eSv/WGP/3zv/vlP/WEP//9/+pL4oHAAAA'. + 'AXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAA'. + 'sSAdLdfvwAAAAHdElNRQfTAwsWEjX+M1LCAAABDklEQVR4nHXQ'. + '1bLDIBAGYFqIEW+ksbr7cXd3ff93OUCamdOE/Mxw882yywLwPz'. + '+gNKotlRFUVnNUQlCxTMRFCKEdE+MgpJaEiIOU4DKaoSIygtb3'. + 'FBUQrm3xjPK4JvXjK0A5hFniYSBtIilQVYUm+X0KTVNiYah+2q'. + 'ulFb8nUbSovD2+TCavwXQWmnMA6ro+di+uR5cPzfPhVqPV3N1p'. + 'n3b3+rimAWAYhP3xnXd7P6oc9vadPsa1wYEs00dFQRAFehlX21'. + '25Sg9NOgwF5jeNTjVL9om0TjDc1lmeCKZ17nFPzhPtSRt6J06R'. + 'WKUoeG3MoXRa/wjLHGLodwZcotPqjsYngnWslRBZH91hWTbpD2'. + 'EdF1ECWW1SAAAAAElFTkSuQmCC' ; + + //========================================================== + // File: diam_gray.png + //========================================================== + $this->imgdata[6][0]= 262 ; + $this->imgdata[6][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'. + 'BMVEX//////wAzMzNmZmbMzMyZmZlq4Qo5AAAAAXRSTlMAQObY'. + 'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'. + 'AHdElNRQfTAwsWExZFTxLxAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'. + 'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'. + '6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'. + 'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'. + '==' ; + + //========================================================== + // File: diam_blgr.png + //========================================================== + $this->imgdata[7][0]= 262 ; + $this->imgdata[7][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'. + 'BMVEX///+AgIBmzP9m///M//+Z//8hMmBVAAAAAXRSTlMAQObY'. + 'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'. + 'AHdElNRQfTAwsWEwCxm6egAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'. + 'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'. + '6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'. + 'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'. + '==' ; + } +} + +?> diff --git a/html/jpgraph/imgdata_pushpins.inc.php b/html/jpgraph/imgdata_pushpins.inc.php new file mode 100644 index 0000000..e59b742 --- /dev/null +++ b/html/jpgraph/imgdata_pushpins.inc.php @@ -0,0 +1,517 @@ +<?php +//======================================================================= +// File: IMGDATA_PUSHPINS.INC +// Description: Base64 encoded images for pushpins +// Created: 2003-03-20 +// Ver: $Id: imgdata_pushpins.inc.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +class ImgData_PushPins extends ImgData { + protected $name = 'Push pins'; + protected $an = array(MARK_IMG_PUSHPIN => 'imgdata_small', + MARK_IMG_SPUSHPIN => 'imgdata_small', + MARK_IMG_LPUSHPIN => 'imgdata_large'); + + protected $colors = array('blue','green','orange','pink','red'); + protected $index = array('red' => 0, 'orange' => 1, 'pink' => 2, 'blue' => 3, 'green' => 4 ) ; + protected $maxidx = 4 ; + protected $imgdata_large, $imgdata_small ; + + function __construct() { + + // The anchor should be where the needle "hits" the paper + // (bottom left corner) + $this->anchor_x = 0; + $this->anchor_y = 1; + + //========================================================== + // File: ppl_red.png + //========================================================== + $this->imgdata_large[0][0]= 2490 ; + $this->imgdata_large[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMKBh4Ryh89CgAACUdJREFUeJy9mNtTFFcexz+/7p'. + '4Lw1wZJKDGCAwmDAqUySamcCq1ed6k9mn3UfMP7F+1T3nYqn2J'. + 'lZdoDEjpbq0KG8EBFBFBEJye6Zmenkv32Ydu5GYiUMmeqq6uqT'. + '6Xz3zP73aOcIKmAQkIFyD3N/jrBPwlKjLQEglVlJKyUjR3u7cc'. + 'WLoP3/4dvv03LNrQ8I6x1rFbDML9kOmHvh7IRHU9JKmUSG8vpF'. + 'IoXX/TV0AiEM5A5jT0noFMFMJHXUt/d5f9TUAbhtQ3cPFruDog'. + '8klHMnmO0dGYe/myOJGINEwTz3F2higFXgy8PpAkOC+h8hoaCt'. + '4ppHFcQAWSgOQlyI/p+lUjmRxWAwNJd3xca/f34yoFi4tgmjtD'. + 'NIFkJ4xcgBCgVqEBFJ9DqcZea/gNAAVEg7AOGYnHe9XoaJd3+X'. + 'LISSSwnz6lsbKCZ9sHh4UVdBkwdA6cPwNnIfJPmC3Ctgft3wwQ'. + 'QPkvTZJJnbExzfvsM2nMzVG7e5fG48d4lnXwTwEYCjJxuHQBog'. + 'BHUfKkgAIIhiGk06hTp/Dm5qS1uYlXLvtWd4gPgIiCrAEcVckT'. + 'Ab5p7TaYJrK1hQaEenrwSiVfQdc91P0kSp7Ii89D5ksY/kAkLy'. + 'IZXFdXkQjS1YUSEbdcRu168V6+HTUNIKJDRwdE+sBIQmP9Ld59'. + 'bEBA3of4F/D+uXb7rGaaCSmXI3pPj64PDaHCYfEqFVSjgWo2D2'. + '73XlJNQTgCyQykIuBWoNKEeh1aLXBPBCggGdBOgxZVSjoajVhH'. + 'o5HWlIpq4bCQSgm9vXhK4ZZKh5SUYygp4J1EQVUD9xlU18BJQD'. + 'bUbJ5T5XJStyxN9fSI099P3baxV1dRloW2h2ivx/yakg2ot6F1'. + 'EkCa4G1D+zVEq5ArKTWM42Q6HUczQV7U66w9e0ZpdRXlOIQ5vF'. + 'VHUXILKify4jiEzkOqC3peQMoBQymFlMt4Dx6wUSxSsm2UZXEK'. + 'P30QvOUt8/2Sd78CdWwFDTA+gsw3cOlPcPUD+CQB52oQ21RKXM'. + 'eRhGXhOg7VoKrx8KuS4ygZhVg3ZI8FGIfwR9BVgAtfwxdXdP3L'. + '86nUR91dXelNXTeWWy10paQHX602YAP1ADASAL7LJvFtMpOCc0'. + 'cG3FHuGlz6Gr4YEpnoTCbzsdHRbOzy5RCRiLRMk5rjyOtAimwA'. + 'U4U3SurBN/0wnAASBCVDIKpB4kiAB5Ub0/UvO9LpPAMDGfn005'. + 'AxPCzxep3Q6iqPLUseBoufCZRsAE6g5g5kKIDfKUj3wnpAG8QB'. + '/Z1OIqANQuI65AtwNScyYXR2XlAXL2YZHzcklRKWl5GVFXFtGx'. + 'MoAiV/EQaAGH6BUQNWgQpwFngv+Ca8KUAQEBcwgTJHyMV7679R'. + 'XS8YqdSI6u/PMD5ukMtJY3GR2uQkr5aXeWVZOEALmA8WsIAxfL'. + 'd0goVLAdCOd+/YpgqeVtBv4yiA++q/RKKXixe7GB8PSyoljcVF'. + 'yg8fyubyMpulEk2lyAIfAAvAC+B+oOQFoAt/+0rAejB/EzjNri'. + 'vvqNnCd64jxcE39V8spnP+vMbAgDSePKE2NcXm06dslMuUlcID'. + 'TuFvqwXMBU8N39bGgRR+ki0Dz4L5DSAe9NGD7zq+6kcN1L6H2b'. + 'ao5WWaQHllRTafPmWrVMJUimoAQrBYJFjQwre7B6A8YAi8LCgD'. + '5DVo6/hbb/iHK1KggvFeD3hHziQKEMuiNTNDbXGRTdtmw7Iwla'. + 'KGH0oqwbscLOoG46rAY6AOzRhY74PT6QuUKEN4PegXxd/yEDTT'. + 'YMWOk+oEaLkuFdNk0zTZwjfkavDUArXWgGXgFb4dEShXhfYqlI'. + 'ow3w9rg3B6ED60IOOA5oEYQBrcpG+mj9bg0VG8GMJhVDZLyzAo'. + 'VSq8rFYxXXefcjVgG9+uisDrXUCApoKSBcUHMBmHhfcgNwhtD3'. + 'q9IG6Lr15b4OUTmPwBJt8JqGuapp05o0mhoHnptLQfPsR+8IBK'. + 'uYyNH3yr+B77LHheA3tK1Ta+IrMeTL2C6Xl48TOsNWDDgAz7s5'. + '/r+krP/eddCsbj8fDQ4GBm9MqVvvRXX2VULBayRGRzaYn1SoWa'. + 'UjgB4PIB5QK4ZgBXBKaAHxQsrED1H7CRgCUPwgHZDqACmhWwXv'. + '2aDRqGYeRyufS169cvThQKV88PDuYbW1vJ5VRK+5euqxWlPMdX'. + 'SRqgreHbZGN3ijfKBXBTAeh2Fdwi2MofshP/dvKwCmKhp4m83Y'. + 'vj8Xg4l8tlCoXC0MTExMTFkZE/1m37wvLGRvKRacoD1209E7Fc'. + 'pZwYREOQqEJ4z3HskHLsz4AoXykPIBSN0t3dTTQafROoHdumXC'. + '4fjoMiog0ODiauX7+eLxQKV3O53ETdti88nJnJ3rl505ifmWm3'. + 'arWSodR8GNbycDoNHy5C5jFold1k8d+DyvELNwg93d18/vnn9P'. + 'X1oes6nufx/Plz7t+/fxhQKSWJRCI5NjaWHxkZKdj1+sjSwkJm'. + '+uZN/dZ337VqCwullGUVdZjsgIUC5LqhrUPvCugWuApeApPAzY'. + 'PKHWyaphGNRunt7WVwcBARwfM8Ojo6sCzrMKBhGLphGFEF2Wq1'. + '2jc7M5OZ/vHH0MPbt93awkJJmeZsC6ZaMK3DCwvWdNioQUb5B6'. + 'AdBR+9SzkAz/NwHIeXL18iIui6TjgcJplMMjY2th8wHo+Hh4aG'. + 'MsPDw6fddru7+Phxx51bt/RbN260qwsLpZhlFZsw9QJ+2Pbrga'. + 'oJG2FY2oKwuTtVEz9uV34NbqdtbW0xPT1NNBoF4MyZM1y5coWu'. + 'rq5dQBHRcrlc4tq1a/l8Pj9RMs38ndu3Ez//9JNXLRZNyuXZJk'. + 'xVYKoExQpsK/+IaAuYb7no8zjC/R+A4zisrq7u+53NZjl16tQ+'. + 'QIlEIslsNpuPRCJXZ2dnh2/duNFRW1oy07a96MKd575yxRqU1B'. + '5vPMpF5HHa1tYW9+7do7Ozc/eQpZTSQ6FQt1Lq8pMnT/5w7969'. + 'nuLcXE1rNufO9fRMhlKpOyvt9qPtVmvb25fFfvvWbrepVCqHwo'. + 'xaX19vff/996ZhGC8qlkW9Wt1Onz073fXxxz+6MB+9e9dUjuO+'. + '7ebq9wLdB9hoNCrr6+s/4wf3FCJW3fPmTZhXsNWCprjuW66Dfr'. + '928KAfBhJAEgiJSLuzs7OSTqctoFkqlZRt26j/I+L/AGjPTN4d'. + 'Nqn4AAAAAElFTkSuQmCC' ; + + //========================================================== + // File: ppl_orange.png + //========================================================== + $this->imgdata_large[1][0]= 2753 ; + $this->imgdata_large[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMLFQ0VCkHCzQAACk5JREFUeJytmGtzG0d2hp8zNw'. + 'AEcRdJ6EJK9FL0CqZUm9jWbkwq3vhDstl8dmLvz8rP2H8Q75ZT'. + 'pkRfpLgqsS6WIFEKGYkiSBCDO+banQ8DUpRWEkklXQUUqlCDfv'. + 'rp857pgfAOQ4AMOJdg4R/hX96Hf06bvDc5iT07i8yeg8ksiIAI'. + '4TBi/ds9/vivD/njapNHvRBfHXMu410AM+BUoVSF05NQsi1sO4'. + '8402AXwLQTuP31OAZO2aG0MEn14iSlnI1z3LnMk8IZYJyBwjIs'. + '/TWsVIWPJkvMFS4zMfMhUp5BsoCpAAEBLYKaMFGn00jBxnvu02'. + '35+JHmSJEnBpQEcPo38MmCxd/nS9Ry71Ga/g1W9a8gn0GsHkgA'. + '6DGjxkqb5CoO+YxF3A3p+jGjQUzoK+L/V0ADzFMwtSR8eLbAr8'. + 'uXOTf9NzhTc0geSLUQcYHgYEH786RMg0zWJHV2Aitv4x/HpHVS'. + 'QA2YBqTTGIUq5qkPMWaWkVwPnPtAA/BevmZcjxaaUtHh8pJJGu'. + 'DpCB9FvT7A7YT7S3p5vFMNzmWo/O0MSx/Ms3TqI8r59zFTfUQe'. + 'I7SBODE3tnfoIxYnNHligwik0zAzDdVpyKbA8sff5YAeMEwgkV'. + 'cufQeTJzZoCsaFLKXPTnNpoUTNsSgJmNoGsuNQjIDwYD2HlnZy'. + 'k++yxTKXZfKTU8zOpjhneeQYkorSmGERtIlICBKRbLX+y98YN3'. + 'ADcNIm+bJD4U3pPnmbEaRgYVRTGBkDSSsmxKfY7ZLuDJA4hdjl'. + 'JEgyBB2SJOvQ9RzTpNKoEwNq0CNFvOXR3/HxMgYVPObaz8kPmh'. + 'hkEWMatAfRONGGvLizyOE9P8KkpwhPDAgQKJQbELUD0oOIhbbH'. + 'JeVTmowxjAgZutB5AoOngA+2DdYrcTyOyYZP9+QpBvI29vwEhb'. + 'It042BVQgDy9KTMfkwQG1A9ACCLlgBBGUwxxoc52WDh2ATyEPp'. + '1hoaPvrEBh0Dq5an9OUsl/9hylk5b5c+mowLc4E2Jtw4Eoljyf'. + 'ogA/AGEAagNRjGyUxOmEycyVA5EWDBxrmUp3ytLIv/NJP69Goh'. + '+9mFydIvS5PZYkvH1oY/RFtKymlwBFQAgQd+kAA6qSQ8pvn2mp'. + 'SkJkuVFHPHBnQMrEt5Sl+e4/Lvp51PF1PF5Xy6WMvOWZXMom8z'. + 'OZTQ8+j5sbQiMEwopsCIwRtBGIJSCdzbTGo9NimkDcgdC7Bg49'. + 'TG5n4/nfr0Si77WdYp1YzyZEkWPdteaEnB7pPqBTxuIf/VgciE'. + 'SgasCPwh+GNIkaNNag1RiPge5pEhMQVjfoLcF+eoXSvbKxedwn'. + 'LKzC3KWbOi5/sW5a44/SHFUSgVA7SCzRG0AvA9mPOgFIETgu4n'. + 'Ww0wNQWFAqRSL6D2ZQYBdDrQ7R7jXiwgRcvIL02makuTmWtpM/'. + '+BlLMl5vuWzLVEuwH6oYnR1KS8kJINGXMM2YdfRlALoQoQQKeb'. + 'bDVwoMdxQMaLCwLo96HZTF5HbrEhmOftianfZisfzueKv7ZmrX'. + 'MsjhxKXZGBjzyeEHmSE3oWiggtyVGmE8DTIXTC5NxgAxOAGUM8'. + 'fun9mnSSLQ/CxNzOTgJ3LIMgoGwkKBiiMyaVviHVkdCO4FEKNv'. + 'LQzWBYHfITPa4UBVM0LR/WB7ARJsdDDTjA6deYFIFUOimJ3d0E'. + 'sNdLavYYgBpthqKcjiiJRO8K6CK0CsJTjfQAGaJtD9vQFAxNNQ'. + '1FB0yBAfA8gdMAIagLoCVAen0M00zMOTYShNDtoHs9CAIUoI4E'. + '1IBihCdNhsMhsj6NuV7BCC2IBpBqQaaFOENCCeiEsO1BO4RQgy'. + 'I5Hm4k4oIU9MrgZSAdBeTabZz+ODxKQRRBFBJo6IUc51anYRQo'. + 'dto+24FNxYCiaWKkQsj00KkO4gxRRkAngJ868M0u3OkkM+hxQA'. + 'cQ7YD7GO5XYSsPZybh/TCkFIYY+kWniTW4Q7jXgHvHMhiRpmuW'. + 'ca08GZkkZ/nY6TZMNhCnf2CuPoDVJvxpB+q9BHA8Ag1uH+oP4c'. + 'YEPCzDwmzSLquShHW/E0YRbG/BjZtw40hAy7aNzJlzRn75E6N0'. + 'qiwTzafI7kOU3gWrhzZC2iHcbsPqLlxvJnCt4KC1RYAL3I5hzY'. + 'Xv/huePYCtITQMKEnyB4KQvMURuJvw889HGSwUCs7CwkLpo6tX'. + 'Ty/+7nel6VLGDn/8N9m+eZuo1UP8iNhLau6b3RfmOsHBGTUYw9'. + 'WBNeDrGB4+h/4qNLKwTnLbHj9CJw/6GoIh9Jpvq0HHcayFhYXi'. + 'l3/4w9LK8vLKexfma3G/mb/3n1njTivS7tNQaaU1grQDjJ868D'. + 'Axx6vmxnBrY9C9IcSbSXbavNjb/S3eN6/0m1JcKBScixcvllZW'. + 'Vi6uLC8v12q1v/M8b/HxVjP//YYr32yE4dYWvShO0ogi14xwxq'. + 'F4rbnxZ3cMjtpvEEeMvwA0TdOYn5/PffHFF7Vr166tvPeLXyx7'. + 'nrd4+/btyg/frFo//Xgncnd67qCn78earQqcmYD3fSi1wPCTSV'. + '3gzqvm9uFOMl5nUAqFQn5paal26dKla57vf7D+6FHph9VV88af'. + 'vgq79bo70e3VT2l9A3hYg4UiRALVHTCHSZvYBm4A//6quf8zoG'. + '3bpuM4acMwKr1+//SDe/dK31+/bv90/Xrcq9fduNW6rbVeC+E7'. + 'gWdD2DKg4UEpBmPcm10RuScida31ntb62HAigoigDw6Gh0axWH'. + 'QWFhZKi4uLZ+I4PrVer2e+u37dXPvqq6hbr7tOp1NXWq89h6/b'. + '8FBB34WGBesdcPrj38lkMkGlUuml0+mu53nR3t4eo9HoSLhMJk'. + 'OlUiGdTuN5Hq7rvgA0TdO4cOFC7vPPP6/VarXldqdTu7m2lrv7'. + '7beq++BBO263b/tKrfWSXlbvwJ6CuAtDgTYiaBFMw6BSqfDxxx'. + '+rarWqGo0GN2/eZGtrC6XenAkRoVKpcPXqVWZmZmg0Gty6desF'. + 'oIhIOp3Ol8vlmmVZK3fv3Lm09uc/Zwbr653ccPgoNIzvnmn99Z'. + '7W9QG46lAaM5mM2l95GIYUi0VOnz7N7OwsWmsymQzyuse5Q8Mw'. + 'DNLpNDMzM5w/f/7A6AGgUkoajYa9urpayOXzUz/fvZutr68Pim'. + 'F4/2y1+n2o9Q/ru7uPesPhXnyo4A+vfHp6mmazybNnz9jZ2UFr'. + 'TbPZJAhe+8/aS0Mphed5NBoNABqNBqPR6MWBVWstvu/nnj9/Pv'. + 'vo0aPq5uZmPBgM/qcwPf39xV/9ajU1M3Nvq9PZaw8GoT50PjdN'. + 'k6mpKa5cucL58+eJ45j19XWePHnCzs4OnudhmiaWZRGGIVH05r'. + 'yEYYjrumxubrKxsfFyDQJ6NBp1Pc+7C4jWumBaVm+kVL2l1H2l'. + '1G6otS+H6V6z8u3tbVzXpdFooJRicXGRqakptre3uXXr1ltrcT'. + 'Qa8ezZszemWAE9rfUdYBOwtVLRbrPZ+48ff+wDvuu6Sr3MB4Dr'. + 'uty6desgfa1WC3iRyrNnz4pSSmezWUzTfGtYtNYcdvC/9sMlgP'. + 'n5N4cAAAAASUVORK5CYII=' ; + + //========================================================== + // File: ppl_pink.png + //========================================================== + $this->imgdata_large[2][0]= 2779 ; + $this->imgdata_large[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMLFQolY9lkpgAACmhJREFUeJy9mOtzFNl5h5+3b9'. + 'Mz0kzPBWmEVtIiWYhIiC0HCDhB8lb8ISk7nzdZ5+/zJ/8BTmpT'. + '660CZLwG1pVFgBkgGIHECEaa+/T9nHzQCCQuRpCNz6mp6g893U'. + '8/c37ve3qEjxiC4OA4n/Lp/EUu/tsMM/+aEWduVBx7WhdkShcY'. + 'xUH2zo0Dwod/5N6vf8V//PoGdx8M8EOFPtK9jI8BdHCcMuVSmf'. + 'LxHLmSZdm2U8xIbmKETDGDZZnIy4dBbCynyGhphurEDBOlHFnn'. + 'qPcyPxTOwDCOccw7w5nlBRZWylI+ny/mZ6rL1dzUZ5/IWGZU3D'. + 'ZIOMQDDaJcHDVGWUbJBi9odVr0QoVSPzigIEaZ8vgSS/8wZU3/'. + 'k1fylipz5dLM2WlrZqHKaGCKbEbontq3KAKWQyZfZKTgYqc9Bp'. + '2I2PcJ4ogk/UEBQcwipbFZmT13vDBx8fhnE1Ofnp9yJopFyT3X'. + 'yANfks0QHSQMDaL37pOxMLIu2UyVkjVKLjyKSeuD8dAYCFkso1'. + 'gYMaeWJ40T56cl8yAi/O4FSa2P6kYczIDsgVpAqcDImZPMuAB1'. + 'dkLQtcc8a/bwox8IUHAxZVxGZMouSLVYwKuMkD5IxN+JSdsRJB'. + 'pexuTVgYYM6EoGmxkmg3/hEhNUMr/hd7dqbOzExMn/GRDAxWZc'. + 'j3I8HiXfMjF2FQowKw7pjoN6E/Llw/GBJj8qxVOMlX4ipxc/lY'. + 'kl2zBLkmrTcEzMkoNoRLVidLi/9g+Z3I+1xRHX5EcAihxnbPRv'. + 'OTU9kZSmpKPy9FTGrLimPZ1H+UiyGaF67w6n7E1DwMngFDxGvc'. + 'w70v0xZUby5IxjlIyMssUJrJwVWkXBdbXvSvwEibcSdKCAFI16'. + '4/sc0SRo9cGAGq1DwvQFzV6DVuBiV4zYnlEts6A2TSPcSiXoxo'. + 'QqJCEEFMbQ2b69o5qMiOOPqIMQkagu/aSL7waE8101WFShLjk9'. + 'yxgEvjRUiyYd+gwAjY2J9VpXfZ/JEXLhDp3OR6U4T97+hEnPwx'. + 'tv4HsRjy2tTQSFzQgDUnwSLBQRI+x1ZgcH87Vcv4SF19Kt0ezS'. + '1h9s0Ma25pgr/YJfnLnEysok0+ezjM6EBLldGqKIJYuDRhOQEJ'. + 'Oih8X9Q0xmcXNjlCofBJgn78wxVz7L2YWf8tPPz1hnfjbjzfxN'. + 'qVwutq2etZXUQSXikcXGIgUiUkJSDIQMJgYGJsaB3c7b1qQ4GZ'. + 'xSkdGZIwMeNLfK6uezMnvJK3pLxeVixfvMsyVjSNSO6IV9adPG'. + 'AArkEEz8oUkFmBjYGO80qfd6pCWIayD59wIKcsjcKqufn7JO/S'. + 'xfyi+5c24pey5rZ09mJRNkiDdT/tzbkBr3SYkpMYpgEaIJSYhI'. + 'kSOY1GhilAQk5ntDIojxCZ/kf87Pl85xbuWEnLiUy+cW3NNuJX'. + 'MmY5meKf6mT7wZS+THdOjxlG06tIlIOMZxchSxcFFEGAwAGGME'. + 'jwyZYSnWL3cXWiIUbUI6hO/vxXuFOV84ycmlBWthNeflTjuzTi'. + 'lzJmM5s46Ej0J63/ZoPmoy6PYxtYVNhmfs0mbAND1mmKVMBY1L'. + 'mxA1LN7WgXQbCApNhKJHRIM+DQbv7yQGhjnJ5NgFuXBuxpu5mD'. + 'udm3LPuY7pmZLUE6L1SIJaIPFuDAqyw9lnwDYv6NFHkWJh4ZDB'. + 'wCBFD3uMxsTAwcBAiElpE/KcPg36dIiOvpsRxDCyhmlP2YY9ZU'. + 'v8NMb/1id+FGO0DTztkSXLOONUqeITsMkW2zwnJEIDFhYGx+A1'. + 'kwK4mASkvKDPc3p0iYhRRwYUhZLUTyV6Eu0t4s1Y4kcx6W6KaM'. + 'EZThcXH59RRhGEgIAddnBwNEBKqqpUtWBIF22YDIhJsbEkJqFN'. + 'qLtERHs7GnUkwISEQAf0uj30bY39PzbiC6qrDu2cExJ69Nhhhz'. + '59UlIUipCQOnVi4sjG7ubJBy6um0C+he/0iDHQKIQERYyKFLqr'. + 'SI/W6kJCnvOcrWSLSquC1/Jw9Ks3R0FQKHr0uMc9bnCDGjX69A'. + 'H0XlcJkibN5jOe/alCZStHbjJL9lSMLkXExvCXRiDV6GZEeGeX'. + '3TvvBVQoEjfBL/v0rT75Th7VU5C8gktI6NLlMY+5yU3WWGODDf'. + 'r098tHpNFNH7/2lKdXXdz7efLzVaqJIBOCmK8AJUlI6g0aV+9y'. + '9+p7AR3bMQpTBWPy7yeN6fy0jNwewfpvC9Xe+3kFoUuXe9zj5n'. + 'BusEGHjh6GIAGawC2FWuvSvbbF1maFylZAsC1ISZADBiVNSJrP'. + 'eX73MY//skHP85z5+fnSxQsXj//4n39cmnPn7LbZlsajBmEnBL'. + '1nuEGDG9x4aa5Ldz+h0RCuBqwBv1Wo+7vs9r7n++0MmYeAM+zB'. + '+61EK1QUEnbbtN+9Bh3Hsebn54u//PdfLq9eWl2ZnZ1dSnaSwu'. + 'Pin40b9g3doKE0WoNIl65xj3v75njd3BBubQi6ExKmDWkMRKSl'. + 'tSbVKQcMao1Go5Ugb0+x53nOyZMnSysrKydXLq1cWlxa/McgCB'. + 'Yev3hU+GPrD3I5/q94k3pXYQY58q6B5Bs0HB//neaGx00gyWaz'. + 'VCoV7bquCoKAnZ0dfN/f03egLGj0m3XQNE1jdnY2/+WXXy6trq'. + '6uzP3oR5eCIFi4detW5feXL1vr679Let37zVB3/mQytjXJwmSB'. + 'wikHp9ShY0RESqObwPrr5oBERKhUKly4cIFqtUq9XufmzZtsbW'. + '2hXvuDwTTNtxZq8TyvsLy8vLS4uLgahOHphw8elL69fNlc++qr'. + 'uFOrNXPddm1cczVL5f5P+Lv5MuOJgTGxwYbZpZsCdeAq8M1Bcw'. + 'CGYeC6LtVqlRMnTjAyMkKn0yGXyx0N0LZt03Ec1zCMSrfXO37v'. + 'zp3S769csb+/ciXt1mrNdHf3ltZ6Lca8ZpJsduhtCdb2gEFJoQ'. + 'xADYHuHDS3f32lFEEQUK/XGRkZoVAocP78eZaXl9FaI/Jq25Uk'. + 'yWHAYrHozM/PlxYWFibTND32sFbLXrtyxVz76qukXas1M61WTW'. + 'm99gx+20TdN9jqtfjP7QzOwwYNp037Zd0DukDnIByA1pqdnR2+'. + '++472u02Z8+eZWJiAsMwDsEBRNGBzYJpmsaJEyfyX3zxxdLS0t'. + 'KlVqu1dP3q1cLta9ekU6u1dat1J9b6Sk9kraV1rYXegW7apDYw'. + 'kFY6fPc4MNTw88bwfZ/NzU2UUnieRxAEiAiGcXiXfcigiIjruo'. + 'VyubxkWdbK7fX1xWvffFMInjzBM82uMT5+p++6V1UUrSe7u03t'. + '+8lezlKt3gHyl0aSJDQaDa5fv876+vo+w6FzDq1BpZRsb2/bly'. + '9f9vL5/Njdu3fzG0+eMJHNxsfn532vXN5NPG/7abPZal6/Hvfe'. + 'kroPHfsm98f7AHW9Xo+//vrrlmVZm71+37QNw3JnZ9PK4uJGpV'. + 'pt4Dh+vLGhsrmcfv1iHzu01m89HjIdCon2fb8TBMHtvYeRUn50'. + '1Oj4vqp3Ok1f5LYSadfr9dQfDN642P/XeF2DA+SBAuA4jkOhUK'. + 'BQKESO43S11p3BYBDt7u4y+CtB/i/q7jp1GMiw2AAAAABJRU5E'. + 'rkJggg==' ; + + //========================================================== + // File: ppl_blue.png + //========================================================== + $this->imgdata_large[3][0]= 2284 ; + $this->imgdata_large[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMLFRAiTZAL3gAACHlJREFUeJy9mGtv29YZgJ9zKF'. + 'F3y/Q9jh05tuQkarKgbYasde0UBdZgwNou/Vqga/sD9mP2B4a1'. + 'BbZ9atFPxb5sqOtmXbI19bqsluPYiR3HN90vFEWRZx/IJI5zqa'. + 'x0OwBBSgR5Hj7v+55zSEFXTUgIJyA9C6/9RsjMjAyFIxxJCDc7'. + 'iBqKgyZACGg3G2x9+xXf/fG33P3mC9qNKsp1O+1JdkEnQTdgIO'. + 'ttCSMUi8gj072MnugllAyB9G8rBGi6RsToJTF6iuRoFi1kHKZf'. + '7fB8Iggj0/Dy23D2dakNTR3JDsXPvzstxmZGRMER1EwHhQAEgE'. + 'CLhIkPD6InY9S3djGLJVBtQP1Qb4HDAyoJYQOOZkPx49nhTH9i'. + '7MUBGT7egxkJgd70wZS/CUkoZtA/fRoE1DZ2ACiv52ibReCp4e'. + '7CIEHomxDiuVdGTqUnf/ZeOjR8fpiVXZul5ZrY3bWwbdcLr/dA'. + 'AAIpAwQjUWIjQ+g9HZvswiCgBVF9/SI6OSLGzo0i+oLi6+Utbq'. + '+bKEftgwOE/0Ohocf66M+cBjo22U2RQLIHMhmYnvaOpR9S8bSU'. + 'UqCURGpRkuMZMm9cIvPGJZLj0yBjT2LprkiSkykx9cuXIhOnUs'. + 'm+QNC2XdG02ggBTcvFabsPWwTPpBAChSCgh4kYBpoeplWp47Qs'. + '7EYDt21xINzd5GCAxLExRl89Z+nHjpbKMmjbmkgfDzI0JEW53K'. + 'Jaa6NcAOEX8v52uJzsBlAS6u0hcnTIccPRqhWPCUcLD+s1EaUp'. + 'HCEhEMCyHNpt9SjgIU12A6iw6xb123vYhaaKjB9tlgMD5X+uBp'. + 'zdkpg6azA8EaNQtKlVba+Xez4eCntnJrsDdFsW5nYFpxlFN846'. + 'DXe8utkM4mhi+EgQmjYbS2WqexZKk6BpjwJ2YlK5VjeA3pNDiH'. + 'YjRWPzPE7tmBo8EWwGhkXx+z3uXL7D3rU97LIF8RBEAl6lK/Uo'. + '6JNM1rZ2aTcr3eUgIQOGTgbdwXMGyRejenLYTvQGbAdRuetSud'. + 'OivVuFZgtCEgICghICnZoMhmlVTPR49LCAEkQUhk/B7KXe0MWf'. + 'nxj8xVR/cDheK14WZmtVMJSBnlGoN6FmQq0FLfdwJgORKPHRo/'. + 'Snzx4G0F/FjJ4KiOdmjPCrrx8bffnMybMv9MQGNG3rzlVqtR1B'. + 'sh/CYXCD4Aag1oCW7ZnUOjSp6WFi/QNEB8Y7BfTNjZyCmUvJ0I'. + 'XXT47MTp98Ybon9VZCk8cVazfqlNargsY34G7ByAlIjkHd9CCr'. + 'LbBdiHViUgiECuDKYCdz8b2cywREdiYZOj8zNnLuzOTzx6ODp+'. + 'OaGaqwVzBFqz0Idhz2loE7YEwBLaAJLQcKbW8qjAcBF5Jh0AMP'. + 'IOHe6kxgtb3UMO2OxkF//ffK28nQqxfvm3szrtnDVa799Qb/+v'. + 'NtsbNSpm3tAv8B+w7Ub0FhAyoBcMPec9oK6raXk48ziQBXQcmC'. + 'pT3YqHa0mpEBkTR6wz/Jjo2cy04+fzwxdDquNfQKO7sFUbpu0c'. + 'wp3JoAYsA42Bbkl4GCryUNDEM7Avm6Z/CgSYBWG8pNuFuDu1Wo'. + 'tjoxKIJGeHIiM/jmK9NnX5ycuJQMtUcqXPvLDTa+qIie4hAJ1U'. + 'vdrmO2HaDfB931twJgAn1A4lGT96obPHPLBbhVgUoTHHWo9aAA'. + 'JVAKpyKEmQNzWRENAsL18ycKjAFN/9gCNvzLB/390MMmE7pnDi'. + 'Bvwt0K5Jv3O+0oB22nJ1Vvjb/UMhOpcKknqN1OiMB2DNHU2G5s'. + 'sVndpGJVcZXjX1IAlvw9PmhRQcOFPhsSDkiBrQR1G7brgs0a7D'. + 'ag3FK4rguqBXarI4Nt1SJv5gls7TEWtJDRBO2GwnIs8maevFnA'. + 'Gx6awLZvzeTBu4kFbLigijC47pscpx0xyDfkvtUEnlarCDtrUC'. + 't2HGIhvPHVdVwqjTIrxRU2a5uUrYoP0QZ2gMvACl7+3V/LuKDq'. + 'sJuDy597516+CEezIHXv7vcgXQu2l+Bvn8He9Y4AE4kgk5P9DE'. + 'R6aFdq5Et5Nit3yTf3m9sBcsAN3+D98c0Fit5JawE25r1zg1Fo'. + '5B8GFD7g+nVYnu8EUEop9XTa0N/9dUbqcphP/rDJzbUClVbpgR'. + 'y2fXM3fND95qj75J8AC6BWPINfVSBieK+x+6cS5UCzCLu3oFV9'. + 'GqCMx2NGOp2Znpv7aXZudsool3T5J/179sxVlHJ4kGPrP2COBX'. + '/7DmiApWCjxIMXpYNznYuXM+6TAKWUMppOZzLvv//ery5cuDCT'. + 'SqVS336bCwr1JfAPB9r+2KAFwJS+OcETzZHz/7v3etl6ipz77X'. + 'GAMh6PG+l0OjM3NzczOzs3k0pNnFlbW43+e/GKtMqrblSsF03V'. + 'WHcJA0PjIAzvg9JTze2H67g9DjAwOTmZ+uCDD96anZ2dnZiYmF'. + '5dW41++Lvfa1fnr7qllVK9103mXNTnJgPA+YugsvB3HTaEl+Qs'. + 'AZ/yeHPPDCiTyaRx5syZbGoilV1dW00szC9oV+avusuLy0Xd0X'. + 'MgFkDM+zkYBZEHV8f7wwKu84zmngQoNU0LaZoWUa4K31y5qX/8'. + '4cfyyvwVN5/L10NOKNeg8UmDxoKF5Vfj1xXAgD0JrgAcvBDfel'. + 'a4g4AykUgY6XR6emJiIru2ttZXq9S0K19eUcuLy8WQE8o5OAsN'. + 'Ggsmpl+NpoL1g9X4UBU+C9xDgEKIwNTUVOqdd955M9mbnJ3/cj'. + '6Vu5aTheXCQXNdVeMzAwJSCGEA2XKpnF1cXIzlFnOVhJPIKdR+'. + 'c88ctq4AlVKsrKzw0UcfKcC5uXqzXnNqSzb2pwLxOHP/l7Z/BN'. + 'eB01LKt4HTrusKvGr8jB+hGn8MQAkYQMrfw4Nq/MFPtf+rdvDb'. + 'k8QL+/5Z4Uepxm7bfwHuTAVUWpWaqAAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: ppl_green.png + //========================================================== + $this->imgdata_large[4][0]= 2854 ; + $this->imgdata_large[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMLFQ4hANhluwAACrNJREFUeJytmF1zE1eagJ+3u9'. + 'XdkvUty2AbmLEtEzDBgZ0UpDBOalNTUzU3czl7tct/2n+wt3M/'. + 'NVM12SSTQQSyW2TA+QAJQogtYYFtyfrqL3WfvWj5g8AEjzfvhS'. + 'SXjk8//Zz3Pf3qCMcJAWxMKlT4kH+jwu/FknnJSUItKFHzCrKA'. + 'BggBQx5ziz/wn/yBz3hED4/oaJfSjgVoYjJJgTLTZCjohp7IGT'. + 'k5aZ4kb+bRTR30Q7djj8f/kpPMUSCFedRL6W8e8qMQNE6S4xpv'. + 'c5HrTPFubiJ3ZnlyOXV59rJYU5Z00h1c3d0brxAiUkScRijisk'. + '6XLTyiN3s8HuAJpniXa/q8/pt8Or+0kF8oXJm5YiydWcIpOrJu'. + 'rjOQwd54AQwsMpTJYhPSoYuLQ58An/DnBQSdImXO8avsTPbqpc'. + 'lLp67OXDVzMznZLGxSs2qyIRu4at8gKHQEC50kE1icxqCAdxST'. + 'xjEA44tqaJlERl8uLWvvnX5PHuQfcCdxh5qq0aX76vj4WgWyXO'. + 'QiNgBP8IAaddr08X8+wHFmJSQhBbPAZGoSZSt5wQs6qoNC7UEd'. + '4AEoLIQSCaCCy78Dv8Tiv1hjjW1CRj8XIAgEKqDtt9keboMJZa'. + 'vMjuzQVd3Xr9prTJo+GF/jKZea95R25Lxs8jg5qFGiwDnOS0mW'. + 'NE0rjNRIt3WbklUCA9mV3Zdz8OBT/JfCQLB0SKYVVjGFYSfx/E'. + '26ow4e6uDujlPFQpE0FU6P8qNTHdXJdEdda0qf0itWBVM3pa/3'. + 'ccUlIECJet0cAJoeYk5EZCeS5IwEoerSxccJBwRqFFf38QCTaO'. + 'TRVFKJm3NTbtLNSyh2IkhIXsvLCesEGNCWdmwyruSD/z9kUlRc'. + '3bqNlSxhJNJ43p5JITrOEis8Qtr0cXEpU/JT/pmO18n2vb42pU'. + '3JnDnHMBqyPlpnoAaxhr2llv1ZUBqEGlqYwDQMsskMOcMgVL3Y'. + 'ZOQTHAcQQiIGjHCwCaiovjrv4hbcpKuJJjIcDHm685RGr4GLCx'. + 'YHkAcrLoAoDSLBiAQrMkjqybHJCbxgh+7xAC1MpsgzwRwD3qHL'. + 'WyTIBdlAa6u2rHfXaew06PV78ZZjAwleNnkolECoH5i090wOcY'. + '+TgwYzFHiPi1zkOkXexeAMASnVU+LiyiA1wFUuaqggACLizeWw'. + 'ycMzyssmVYKkbpGyC5T+OUALk2mKLHKWf+ED/az+YW42d66YL+'. + 'aNrmEEzQCFEnKw368EgEvcN1m80eTIQIt0TFOjMJHkzNEBBYPp'. + 'sblf8QHzrORO5JaWZ5ZLl6cuJyyxpNPv4PZdoT+GyIxBfI5uUg'. + 'eJMCwP2/bIHO1JEudcgUUWOceKNq99mCvnzs5PzRcuTV4y5mRO'. + 'SMIjo47z5S7a94oQCNKgJsZwO7D/IDNg3/LLhRNXt4JohBb4aG'. + '82GLdXcf93mQ+Y43r2RHZp+cRy6cqJK4l8MS+tdItaqiYtc0Mm'. + 'QpfJARh98HYh9IiXVcaAo58wGb+LBAjbSPgCOcoSa0wzxXtc08'. + '/pv8mfyL+9MLVQvDJ1JVHJV6SZbFI1qtTsB+KlehRtRTGE8Afo'. + 'P4DRcAxiEudhAHjjzz+ubgX4oHowakHQOlqzICQwyVPITGVOXi'. + 'xfLF6aumzmczl5lHzMff2+fCdPaGttEkXoLQAO9B7C6EugPYby'. + 'gVPjGXc5eIbNAJPjGwiAbaAJUQv8wVG7GROkJFpyOqn/ovgLba'. + '44L0+sDaraXb6jzq7aBQWjBOyUoHcaopOgmaA3IRyNDZnA1HjO'. + 'HSBkr7eEFDAEngHrQCf+/s2A8cSiSkqcKUeeTjwFy2Jd78t3+L'. + 'TR4itIiBLwLQhzkJyB5Cx4HXDaENVQCBAQcRqFIHTRaBIvuYXg'. + 'AdsouuNxEL0ZUBHnSQp66R73zYfUtQ6OytKT8RckQAJQoLtgO5'. + 'BJgj0D/WfgdyHaAHx8THoUcbGx8ciwhUl3bDEiToURPooeI7pH'. + 'MziK9Yd9nU5a6GgKjOH41vsgI4hAcyC5AZkapF+AoYNrjjsuhx'. + 'FbtPmeB5ykyQQzTPAWAQWC8S9oAI0QRRuPb9jkmyMZNAOTklvC'. + 'GGYZaFkGmkVAh8h4DtKFMIBunG+pB5B5AIkGBDsQ+qBiL20caj'. + 'zhJknq5KlgMkLjJHJos4kYEbFJi5vc5eYbATVN02bNWe19+32t'. + 'aJWlFm3wbf8Rz5NbDFJdlOFBF/g7cBf0JkrbBb+F6j1DOduEkU'. + '8bWCOiSofPWadBnSZDWmgUkEMGhZCINut8S/0NBtPptFlZrBSu'. + 'vnt1+ndnflfIp9OJ/279Ubbbd+lP7KBKPoEBsgnqLph/BRzwdS'. + 'LnBUFvHcfdpRsGPAGqwMco6jynz+e0SPKYCHMfLX5VKHwcenR+'. + 'Igd1XTcqlUr+xn/cePv91fevzy8sLO2OtrOpWkqL7gXKSAVRdh'. + 'ZFEmEXoYkwBNqovoc/3GHH3aUR+jwC1oD/AWrANi4hGwyBzqEG'. + 'Vvb77Dgi0eT1VZzJZMxKpVJYXV1dXF1dXVm6sPSvruue3Xzcyj'. + '6/syvDzwj0lNazK6Fj5LFCRZouZpBABj6jXouu3+Np6HNvDHaf'. + 'g91t74msbMuOJicnSSaTKKUQEUQEpRSO69But1/dB0VEm5uby9'. + 'y4cWNpdXX1+sLCworrume//PuXpeqnVeOban0U1PW2kcx+O9L7'. + 'Te9sUB4lWFR9SqNtNGcHx+/RDD2+Am4D94CnQA8OjjlEhMnyJC'. + 'srK8zOzu7BiYioMAzZ2Njg9u3brwIqpSSXy2WXl5eXLly4sOo4'. + 'zoV6vV6oflrVP/7Tx8Hmw1Zb6ydqmpWp7ha8h4O3gjOhzVANmF'. + 'XPMNQWvdDnCXCXuHR+APqH4fbCtm2mp6eZn59H13WJuYXRaKSU'. + 'UiSTyVcBdV3XDcOwRaTU7/en19bWCn/79G+JL/76RbhZ22y7u+'. + '6ahl71nPDz/nO17m7wAxlabFOihy4+DvAcqAMbPzZ3OFzX5dmz'. + 'Z2iahoiosUUVhiGNRgPHcV4GzGQy5uLiYuH8+fMzo9FoslarJW'. + '9+elP75E+fBJu1zY7qqpqBUW3T/niohnVvy+1zm5aVtp+WE2XT'. + 'nrHFzbjh1tYLz3XdPjD4R3BKKba2tqhWq4dzUO3noBPn4H5PKy'. + 'LaO++8U7hx48byhQsXVne7u6tf3/v64t3P7mbq9+odt+OuaWi3'. + 'PLxbW2ytubjbQCgiMnt6VlaurWgz0zM0m02q1WrUaDSUUuqI56'. + 'ivDxE5MCgiYllWtlwuL5mmufLV/a/O/uXPf9Ff1F+80Lv6Yx29'. + '2qHzyZBh3cdvc7gaTZuZkzPh/Py8ACqVSv1/uPZDKXUAGEWRtF'. + 'qtxEcffZTL5XLF+2v39fqjeivshA/TpP83JLwzYFBzcA4370Cc'. + 'S81nTRBUs9lkOByi1GuOPI4Rh3+26JZlnSkWi781DOPXvV4v3+'. + '/2G0R8kSBxB/jew+tERK+c49m2TblcxrZtXNfl+fPneJ6HZVmU'. + 'y2VJJpNyaJ9TSinlOA5bW1u4rntkQA0oAG8D54gb9W3ianxM3A'. + 'e/cn73U3Hq1Cm5du2aPjs7a+ztcSIShmE4ajQa6tatWzQajZ+0'. + 'fbiKI+It4SvijVUj7kL2qvGfgkskEqTTaZmcnDROnTplJhIJTU'. + 'QiwPd9P/Q8T6XTaQzDIAiCfzjP/wFVfszuFqdHXgAAAABJRU5E'. + 'rkJggg==' ; + + + //========================================================== + // File: pp_red.png + //========================================================== + $this->imgdata_small[0][0]= 384 ; + $this->imgdata_small[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'. + 'B3RJTUUH0wMJFhouFobZrQAAAQ1JREFUeJyV1dFtwyAQBuD/og'. + 'xQdYxa8gRY6hJ0jK6QdohMkTEuE5wUj5ERen05IoLvID7Jkn2G'. + 'j8MgTMyMXqRlUQBYq9ydmaL2h1cwqD7l30t+L1iwlbYFRegY7I'. + 'SHjkEifGg4ww3aBa/l4+9AhxWWr/dLhEunXUGHq6yGniw3QkOw'. + '3jJ7UBd82n/VVAlAtvsfp98lAj2sAJOhU4AeQ7DC1ubVBODWDJ'. + 'TtCsEWa6u5M1NeFs1NzgdtuhHGtj+9Q2IDppQUAL6Cyrlz0gDN'. + 'ohSMiJCt861672EiAhEhESG3woJ9V9OKTkwRKbdqz4cHmFLSFg'. + 's69+LvAZKdeZ/n89uLnd2g0S+gjd5g8zzjH5Y/eLLi+NPEAAAA'. + 'AElFTkSuQmCC' ; + + //========================================================== + // File: pp_orange.png + //========================================================== + $this->imgdata_small[1][0]= 403 ; + $this->imgdata_small[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'. + 'B3RJTUUH0wMJFhwAnApz5AAAASBJREFUeJyN1dFthDAMBuDf7S'. + '3BCm2VCRKpS4QxbhikW6IewzcBqm6Fm6JyH7iEEByCn5AJH38g'. + 'BBIRHNUzBAWAGNfe/SrUGv92CtNt309BrfFdMGPjvt9CD8Fyml'. + 'ZZaDchRgA/59FDMD18pvNoNyHxMnUmgLmPHoJ+CqqfMaNAH22C'. + 'fgqKRwR+GRpxGjXBEiuXDBWQhTK3plxijyWWvtKVS5KNG1xM8I'. + 'OBr7geV1WupDqpmTAPKjCqLhxk/z0PImQmjKrAuI6vMXlhFroD'. + 'vfdqITXWqg2YMSJEAFcReoag6UXU2DzPG8w5t09YYsAyLWvHrL'. + 'HUy6D3XmvMAAhAay8kAJpBosX4vt0G4+4Jam6s6Rz1fgFG0ncA'. + 'f3XfOQcA+Acv5IUSdQw9hgAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: pp_pink.png + //========================================================== + $this->imgdata_small[2][0]= 419 ; + $this->imgdata_small[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'. + 'B3RJTUUH0wMJFhsQzvz1RwAAATBJREFUeJyd1MFthDAQheF/oi'. + 'gF+JYWQKICkCJRA1vGtrDbxFbhGvY0HVjCLeS2BeTiHFgTB2wg'. + 'eRISstCnmcG2qCpbuXf3ADBQzWsPfZfS9y9HsEu4/Fo33Wf4Fx'. + 'gxL3a1XkI3wbTNXHLoboVeLFUYDqObYBy+Fw/Uh9DdCmtOwIjF'. + 'YvG76CZoOhNGRmpO8zz30CJoOhMAqlDxFzQLppgXj2XaNlP7FF'. + 'GLL7ccMYCBgZERgCvXLBrfi2DEclmiKZwFY4tp6sW26bVfnede'. + 'e5Hc5dC2bUgrXGKqWrwcXnNYDjmCrcCIiQgDcFYV05kQ8SXmnB'. + 'NgPiVN06wrTDGAhz5EWY/FOccTk+cTnHM/YNu2YYllgFxCWuUM'. + 'ikzGx+2Gc+4N+CoJW8n+5a2UKm2aBoBvGA6L7wfl8aoAAAAASU'. + 'VORK5CYII=' ; + + + //========================================================== + // File: pp_blue.png + //========================================================== + $this->imgdata_small[3][0]= 883 ; + $this->imgdata_small[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAACi1'. + 'BMVEX///8AAAAAADMAAGYAAJkAAMwAAP8zAAAzADMzAGYzAJkz'. + 'AMwzAP9mAABmADNmAGZmAJlmAMxmAP+ZAACZADOZAGaZAJmZAM'. + 'yZAP/MAADMADPMAGbMAJnMAMzMAP//AAD/ADP/AGb/AJn/AMz/'. + 'AP8AMwAAMzMAM2YAM5kAM8wAM/8zMwAzMzMzM2YzM5kzM8wzM/'. + '9mMwBmMzNmM2ZmM5lmM8xmM/+ZMwCZMzOZM2aZM5mZM8yZM//M'. + 'MwDMMzPMM2bMM5nMM8zMM///MwD/MzP/M2b/M5n/M8z/M/8AZg'. + 'AAZjMAZmYAZpkAZswAZv8zZgAzZjMzZmYzZpkzZswzZv9mZgBm'. + 'ZjNmZmZmZplmZsxmZv+ZZgCZZjOZZmaZZpmZZsyZZv/MZgDMZj'. + 'PMZmbMZpnMZszMZv//ZgD/ZjP/Zmb/Zpn/Zsz/Zv8AmQAAmTMA'. + 'mWYAmZkAmcwAmf8zmQAzmTMzmWYzmZkzmcwzmf9mmQBmmTNmmW'. + 'ZmmZlmmcxmmf+ZmQCZmTOZmWaZmZmZmcyZmf/MmQDMmTPMmWbM'. + 'mZnMmczMmf//mQD/mTP/mWb/mZn/mcz/mf8AzAAAzDMAzGYAzJ'. + 'kAzMwAzP8zzAAzzDMzzGYzzJkzzMwzzP9mzABmzDNmzGZmzJlm'. + 'zMxmzP+ZzACZzDOZzGaZzJmZzMyZzP/MzADMzDPMzGbMzJnMzM'. + 'zMzP//zAD/zDP/zGb/zJn/zMz/zP8A/wAA/zMA/2YA/5kA/8wA'. + '//8z/wAz/zMz/2Yz/5kz/8wz//9m/wBm/zNm/2Zm/5lm/8xm//'. + '+Z/wCZ/zOZ/2aZ/5mZ/8yZ///M/wDM/zPM/2bM/5nM/8zM////'. + '/wD//zP//2b//5n//8z///9jJVUgAAAAAXRSTlMAQObYZgAAAA'. + 'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'. + 'RQfTAwkWGTNerea3AAAAYUlEQVR4nHXNwQ3AIAxDUUfyoROxRZ'. + 'icARin0EBTIP3Hp1gBRqSqYo0seqjZpnngojlWBir5+b8o06lM'. + 'ha5uFKEpDZulV8l52axhVzqaCdxQp32qVSSwC1wN3fYiw7b76w'. + 'bN4SMue4/KbwAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: pp_green.png + //========================================================== + $this->imgdata_small[4][0]= 447 ; + $this->imgdata_small[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'. + 'B3RJTUUH0wMJFhkLdq9eKQAAAUxJREFUeJyN1LFVwzAQxvH/8f'. + 'IeDS0FLKABlN6eIwPYAzCHB0gWYI2jj+i1ABUTQN4TRSQ7iiWZ'. + 'qxLn9Mt9ydmiqrSq930AYFiu6YdKrf/hP1gYQn6960PxwBaYMG'. + 'E9UA3dBFtVQjdBOQmBakLennK0CapRwbZRZ3N0O/IeEsqp3HKL'. + 'Smtt5pUZgTPg4gdDud+6xoS97wM2rsxxmRSoTgoVcMZsXJkBho'. + 'SmKqCuOuEtls6nmGMFPTUmxBKx/MeyNfQGLoOOiC2ddsxb1Kzv'. + 'ZzUqu5IXbGDvBJf+hDisi77qFSuhq7Xpuu66TyJLRGbsXVUPxV'. + 'SxsgkzDMt0mKT3/RcjL8C5hHnvJToXY0xYRZ4xnVKsV/S+a8YA'. + 'AvCb3s9g13UhYj+TTo93B3fApRV1FVlEAD6H42DjN9/WvzDYuJ'. + 'dL5b1/ji+/IX8EGWP4AwRii8PdFHTqAAAAAElFTkSuQmCC' ; + } +} + +?> diff --git a/html/jpgraph/imgdata_squares.inc.php b/html/jpgraph/imgdata_squares.inc.php new file mode 100644 index 0000000..895dc93 --- /dev/null +++ b/html/jpgraph/imgdata_squares.inc.php @@ -0,0 +1,150 @@ +<?php +//======================================================================= +// File: IMGDATA_SQUARES.INC +// Description: Base64 encoded images for squares +// Created: 2003-03-20 +// Ver: $Id: imgdata_squares.inc.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +class ImgData_Squares extends ImgData { + protected $name = 'Squares'; + protected $an = array(MARK_IMG_SQUARE =>'imgdata'); + + protected $colors = array('bluegreen','blue','green', + 'lightblue','orange','purple','red','yellow'); + protected $index = array('bluegreen' =>2,'blue'=>5,'green'=>6, + 'lightblue'=>0,'orange'=>7,'purple'=>4,'red'=>3,'yellow'=>1); + protected $maxidx = 7 ; + protected $imgdata ; + + function ImgData_Squares () { + //========================================================== + //sq_lblue.png + //========================================================== + $this->imgdata[0][0]= 362 ; + $this->imgdata[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAIAAADZrBkAAAAABm'. + 'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'. + 'B3RJTUUH0wMLFgojiPx/ygAAAPdJREFUeNpj/P377+kzHx89/c'. + 'VAHNBQ5VBX52HavPWWjg6nnDQbkXoUFTnnL7zD9PPXrz17HxCj'. + 'E6Jn6fL7H7/+ZWJgYCBGJ7IeBgYGJogofp1oehDa8OjE1IOiDa'. + 'tOrHoYGBhY0NwD0enirMDAwMDFxYRVD7ptyDrNTAU0NXix6sGu'. + 'jYGBgZOT9e/f/0xMjFyczFgVsGAKCfBza2kKzpl3hIuT1c9Xb/'. + 'PW58/foKchJqx6tmy98vbjj8cvPm/afMnXW1JShA2fNmQ9EBFc'. + 'Opnw6MGjkwm/Hlw6mQjqwaqTiRg9mDoZv//4M2/+UYJ64EBWgj'. + 'cm2hwA8l24oNDl+DMAAAAASUVORK5CYII=' ; + + //========================================================== + //sq_yellow.png + //========================================================== + $this->imgdata[1][0]= 338 ; + $this->imgdata[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAWl'. + 'BMVEX////+/+H+/9/9/9v8/8P8/8H8/7v8/7n6/4P5/335/3n5'. + '/3X4/1f4/1P3/031/w30/wn0/wPt+ADp9ADm8ADk7gDc5gDa5A'. + 'DL1ADFzgCwuACqsgClrABzeAC9M0MzAAAAAWJLR0QAiAUdSAAA'. + 'AAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEDlOgDj'. + 'EAAAB+SURBVHjaVcpbCsQgDEDRGERGKopjDa2a/W9zfLWj9/Nw'. + 'Ac21ZRBOtZlRN9ApzSYFaDUj79KIorRDbJNO9bN/GUSh2ZRJFJ'. + 'S18iorURBiyksO8buT0zkfYaUqzI91ckfhWhoGXTLzsDjI68Sz'. + 'pGMjrzPzauA/iXk1AtykmvgBC8UcWUdc9HkAAAAASUVORK5CYI'. + 'I=' ; + + //========================================================== + //sq_blgr.png + //========================================================== + $this->imgdata[2][0]= 347 ; + $this->imgdata[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAZl'. + 'BMVEX////0+vv0+vrz+fry+frv+Png7e/d7e/a6+zY6+250tSz'. + '0tSyztCtztGM0NWIz9SDzdNfsLVcrrRZrbJOp61MpqtIr7dHn6'. + 'RErrZArLQ6q7M2g4kygYcsp68npa4ctr8QZ20JnqepKsl4AAAA'. + 'AWJLR0QAiAUdSAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU'. + '1FB9MDCxYEByp8tpUAAAB7SURBVHjaVcjRFoIgDADQWZpWJpjY'. + 'MsnG//9kzIFn3McLzfArDA3MndFjrhvgfDHFBEB9pt0CVzwrY3'. + 'n2yicjhY4vTSp0nbXtN+hCV53SHDWe61dZY+/9463r2XuifHAM'. + '0SoH+6xEcovUlCfefeFSIwfTTQ3fB+pi4lV/bTIgvmaA7a0AAA'. + 'AASUVORK5CYII=' ; + + //========================================================== + //sq_red.png + //========================================================== + $this->imgdata[3][0]= 324 ; + $this->imgdata[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAXV'. + 'BMVEX////++Pn99/j99ff99fb98/X98/T98PL55uj43+P24+bw'. + 'kKPvjaHviJ3teJHpxMnoL2Pjs73WW3rWNljVWXnUVnbUK1DTJk'. + '3SUHPOBz/KQmmxPVmuOFasNFOeIkWVka/fAAAAAWJLR0QAiAUd'. + 'SAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEHd'. + 'ceT+8AAABtSURBVHjaVchbAkMwEAXQq6i3VrQiQfa/zDYTw8z5'. + 'PCjGt9JVWFt1XWPh1fWNdfDy+tq6WPfRUPENNKnSnXNWPB4uv2'. + 'b54nSZ8jHrMtOxvWZZZtpD4KP6xLkO9/AhzhaCOMhJh68cOjzV'. + '/K/4Ac2cG+nBcaRuAAAAAElFTkSuQmCC' ; + + //========================================================== + //sq_pink.png + //========================================================== + $this->imgdata[4][0]= 445 ; + $this->imgdata[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAApV'. + 'BMVEX////6+Pz69/v49Pr38/r17/jr4+/l3Onj2efh1ua/L+i+'. + 'q8m+Lue9Lua8qsS8LuW8LeS7pca5LOG4LN+2Y9O2YNW1ZdO1Kt'. + 'y0atC0aNGzb82zbc6zKtuzKdqycsuwa8qtJtOISZ2GRpuFN6GE'. + 'NqCDQpmCMZ+BPpd/LJ1/K519S5B9Jpx9Jpt9JZt6RY11BJZ1BJ'. + 'V0BJV0BJRzBJNvNoRtIoJUEmdZ/XbrAAAAAWJLR0QAiAUdSAAA'. + 'AAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYDF3iKMD'. + 'YAAACeSURBVHjaVczbEoIgGARgCiMtrexoWpaa2FHUgvd/tH4Y'. + 'BnEvv9ldhNPradPnnGBUTtPDzMRPSIF46SaBoR25dYjz3I20Lb'. + 'ek6BgQz73Il7KKpSgCO0pTHU0886J1sCe0ZYbALjGhjFnEM2es'. + 'VhZVI4d+B1QtfnV47ywCEaKeP/p7JdLejSYt0j6NIiOq1wJZIs'. + 'QTDA0ELHwhPBCwyR/Cni9cOmzJtwAAAABJRU5ErkJggg==' ; + + //========================================================== + //sq_blue.png + //========================================================== + $this->imgdata[5][0]= 283 ; + $this->imgdata[5][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAQl'. + 'BMVEX////4+fz39/z19vvy8vru7/ni4+7g4fHW1ue8vteXmt6B'. + 'hdhiZ7FQVaZETcxCSJo1Oq4zNoMjKakhJHcKFaMEC2jRVYdWAA'. + 'AAAWJLR0QAiAUdSAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0'. + 'SU1FB9MDCxYDN0PkEP4AAABfSURBVHjaVchHAoAgDATAVcCCIF'. + 'j4/1elJEjmOFDHKVgDv4iz640gLs+LMF6ZUv/VqcXXplU7Gqpy'. + 'PFzBT5qml9NzlOX259riWHlS4kOffviHD8PQYZx2EFMPRkw+9Q'. + 'FSnRPeWEDzKAAAAABJRU5ErkJggg==' ; + + //========================================================== + //sq_green.png + //========================================================== + $this->imgdata[6][0]= 325 ; + $this->imgdata[6][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAXV'. + 'BMVEX////2+vX1+vX1+fT0+fPz+PPx9/Dv9u7u9e3h7uHe697a'. + '6dnO2s3I1sa10LOvza2ay5aEwYBWlE9TqE5Tkk1RkEpMrUJMg0'. + 'hKiUNGpEFBojw8oTcsbScaYBMWlwmMT0NtAAAAAWJLR0QAiAUd'. + 'SAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEFd'. + 'nFx90AAABuSURBVHjaVc9HAoAgDADB2HuJWLDx/2cKBITscW4L'. + '5byzMIWtZobNDZIZtrcCGZsRQ8GwvRSRNxIiMuysODKG3alikl'. + 'ueOPlpKTLBaRmOZxQxaXlfb5ZWI9om4WntrXiDSJzp7SBkwMQa'. + 'FEy0VR/NAB2kNuj7rgAAAABJRU5ErkJggg==' ; + + //========================================================== + //sq_orange.png + //========================================================== + $this->imgdata[7][0]= 321 ; + $this->imgdata[7][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAUV'. + 'BMVEX/////8+n/8uf/8OP/59H/5Mv/zqH/zJ3/ypv/yJf/vYH/'. + 'u33/uXn/n0n/nUX/m0H/lzn/ljf/lDP/kS3/kCv/iR//hxv/fg'. + 'n/fAX/eQDYZgDW6ia5AAAAAWJLR0QAiAUdSAAAAAlwSFlzAAAL'. + 'EgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEJIgbx+cAAAB2SURBVH'. + 'jaVczRCoQwDETRbLAWLZSGUA35/w/dVI0283i4DODew3YESmWW'. + 'kg5gWkoQAe6TleUQI/66Sy7i56+kLk7cht2N0+hcnJgQu0SqiC'. + '1SzSIbzWSi6gavqJ63wSduRi2f+kwyD5rEukwCdZ1kGAMGMfv9'. + 'AbWuGMOr5COSAAAAAElFTkSuQmCC' ; + } +} + +?> diff --git a/html/jpgraph/imgdata_stars.inc.php b/html/jpgraph/imgdata_stars.inc.php new file mode 100644 index 0000000..bc69690 --- /dev/null +++ b/html/jpgraph/imgdata_stars.inc.php @@ -0,0 +1,144 @@ +<?php +//======================================================================= +// File: IMGDATA_STARS.INC +// Description: Base64 encoded images for stars +// Created: 2003-03-20 +// Ver: $Id: imgdata_stars.inc.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +class ImgData_Stars extends ImgData { + protected $name = 'Stars'; + protected $an = array(MARK_IMG_STAR => 'imgdata'); + + protected $colors = array('bluegreen','lightblue','purple','blue','green','pink','red','yellow'); + protected $index = array('bluegreen'=>3,'lightblue'=>4,'purple'=>1, + 'blue'=>5,'green'=>0,'pink'=>7,'red'=>2,'yellow'=>6); + protected $maxidx = 7 ; + protected $imgdata ; + + function __construct() { + //========================================================== + // File: bstar_green_001.png + //========================================================== + $this->imgdata[0][0]= 329 ; + $this->imgdata[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAAUV'. + 'BMVEX///////+/v7+83rqcyY2Q/4R7/15y/1tp/05p/0lg/zdX'. + '/zdX/zVV/zdO/zFJ9TFJvDFD4yg+8Bw+3iU68hwurhYotxYosx'. + 'YokBoTfwANgQFUp7DWAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgF'. + 'HUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJj'. + 'CRyxgTAAAAcUlEQVR4nH3MSw6AIAwEUBL/IKBWwXL/g0pLojUS'. + 'ZzGLl8ko9Zumhr5iy66/GH0dp49llNPB5sTotDY5PVuLG6tnM9'. + 'CVKSIe1joSgPsAKSuANNaENFQvTAGzmheSkUpMBWeJZwqBT8wo'. + 'hmysD4bnnPsC/x8ItUdGPfAAAAAASUVORK5CYII=' ; + //========================================================== + // File: bstar_blred.png + //========================================================== + $this->imgdata[1][0]= 325 ; + $this->imgdata[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'. + 'BMVEX///+/v79uRJ6jWPOSUtKrb+ejWO+gWPaGTruJTr6rZvF2'. + 'RqC2ocqdVuCeV+egV/GsnLuIXL66rMSpcOyATbipY/OdWOp+VK'. + 'aTU9WhV+yJKBoLAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJwynv1'. + 'XVAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'. + 'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'. + 'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'. + 'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bstar_red_001.png + //========================================================== + $this->imgdata[2][0]= 325 ; + $this->imgdata[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'. + 'BMVEX///+/v7+eRFHzWG3SUmHnb37vWGr2WHG7Tlm+TljxZneg'. + 'Rk3KoaXgVmXnV2nxV227nJ++XGzErK3scIS4TVzzY3fqWG2mVF'. + 'zVU2PsV2rJFw9VAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJzCI0C'. + 'lSAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'. + 'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'. + 'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'. + 'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bstar_blgr_001.png + //========================================================== + $this->imgdata[3][0]= 325 ; + $this->imgdata[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'. + 'BMVEX///+/v79Ehp5Yx/NSq9Jvw+dYwu9YzfZOmbtOmb5myPFG'. + 'gqChvcpWteBXvedXxvGcsbtcpb6su8RwzOxNmrhjyvNYwupUjK'. + 'ZTr9VXwOyJhmWNAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJTC65k'. + 'vQAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'. + 'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'. + 'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'. + 'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bstar_blgr_002.png + //========================================================== + $this->imgdata[4][0]= 325 ; + $this->imgdata[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'. + 'BMVEX///+/v79EnpxY8/FS0dJv5+dY7+9Y9vBOubtOur5m8fFG'. + 'nKChycpW3uBX5+ZX8e2curtcvrqswsRw7OdNuLZj8/BY6udUpK'. + 'ZT1dRX7OtNkrW5AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJgXHeN'. + 'wwAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'. + 'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'. + 'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'. + 'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bstar_blue_001.png + //========================================================== + $this->imgdata[5][0]= 325 ; + $this->imgdata[5][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'. + 'BMVEX///+/v79EY55Yi/NSetJvledYiO9YkPZOb7tObr5mkvFG'. + 'X6ChrcpWgOBXhedXi/Gcpbtcf76sssRwnOxNcbhjk/NYiepUbK'. + 'ZTfdVXh+ynNEzzAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJhStyP'. + 'zCAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'. + 'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'. + 'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'. + 'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bstar_oy_007.png + //========================================================== + $this->imgdata[6][0]= 325 ; + $this->imgdata[6][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'. + 'BMVEX///+/v7+ejUTz11jSvVLn02/v1lj21li7q06+r07x2mag'. + 'lUbKxKHgy1bnz1fx1Ve7t5y+qlzEwqzs03C4pE3z2WPqz1imml'. + 'TVv1Ps01dGRjeyAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJjsGGc'. + 'GbAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'. + 'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'. + 'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'. + 'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ; + + //========================================================== + // File: bstar_lred.png + //========================================================== + $this->imgdata[7][0]= 325 ; + $this->imgdata[7][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'. + 'BMVEX///+/v7+eRJPzWN3SUr7nb9TvWNj2WOS7Tqi+TqnxZtyg'. + 'Ro/KocPgVsjnV9LxV927nLa+XLTErL7scN24TarzY9/qWNemVJ'. + 'jVU8LsV9VCwcc9AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'. + 'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJxi9ZY'. + 'GoAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'. + 'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'. + 'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'. + 'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ; + } +} + +?> diff --git a/html/jpgraph/jpg-config.inc.php b/html/jpgraph/jpg-config.inc.php new file mode 100644 index 0000000..ea16c1e --- /dev/null +++ b/html/jpgraph/jpg-config.inc.php @@ -0,0 +1,138 @@ +<?php +//======================================================================= +// File: JPG-CONFIG.INC +// Description: Configuration file for JpGraph library +// Created: 2004-03-27 +// Ver: $Id: jpg-config.inc.php 1871 2009-09-29 05:56:39Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +//------------------------------------------------------------------------ +// Directories for cache and font directory. +// +// CACHE_DIR: +// The full absolute name of the directory to be used to store the +// cached image files. This directory will not be used if the USE_CACHE +// define (further down) is false. If you enable the cache please note that +// this directory MUST be readable and writable for the process running PHP. +// Must end with '/' +// +// TTF_DIR: +// Directory where TTF fonts can be found. Must end with '/' +// +// The default values used if these defines are left commented out are: +// +// UNIX: +// CACHE_DIR /tmp/jpgraph_cache/ +// TTF_DIR /usr/share/fonts/truetype/ +// MBTTF_DIR /usr/share/fonts/truetype/ +// +// WINDOWS: +// CACHE_DIR $SERVER_TEMP/jpgraph_cache/ +// TTF_DIR $SERVER_SYSTEMROOT/fonts/ +// MBTTF_DIR $SERVER_SYSTEMROOT/fonts/ +// +//------------------------------------------------------------------------ +// define('CACHE_DIR','/tmp/jpgraph_cache/'); +// define('TTF_DIR','/usr/share/fonts/TrueType/'); +// define('MBTTF_DIR','/usr/share/fonts/TrueType/'); + +//------------------------------------------------------------------------- +// Cache directory specification for use with CSIM graphs that are +// using the cache. +// The directory must be the filesysystem name as seen by PHP +// and the 'http' version must be the same directory but as +// seen by the HTTP server relative to the 'htdocs' ddirectory. +// If a relative path is specified it is taken to be relative from where +// the image script is executed. +// Note: The default setting is to create a subdirectory in the +// directory from where the image script is executed and store all files +// there. As ususal this directory must be writeable by the PHP process. +define('CSIMCACHE_DIR','csimcache/'); +define('CSIMCACHE_HTTP_DIR','csimcache/'); + +//------------------------------------------------------------------------ +// Various JpGraph Settings. Adjust accordingly to your +// preferences. Note that cache functionality is turned off by +// default (Enable by setting USE_CACHE to true) +//------------------------------------------------------------------------ + +// Deafult locale for error messages. +// This defaults to English = 'en' +define('DEFAULT_ERR_LOCALE','en'); + +// Deafult graphic format set to 'auto' which will automatically +// choose the best available format in the order png,gif,jpeg +// (The supported format depends on what your PHP installation supports) +define('DEFAULT_GFORMAT','auto'); + +// Should the cache be used at all? By setting this to false no +// files will be generated in the cache directory. +// The difference from READ_CACHE being that setting READ_CACHE to +// false will still create the image in the cache directory +// just not use it. By setting USE_CACHE=false no files will even +// be generated in the cache directory. +define('USE_CACHE',false); + +// Should we try to find an image in the cache before generating it? +// Set this define to false to bypass the reading of the cache and always +// regenerate the image. Note that even if reading the cache is +// disabled the cached will still be updated with the newly generated +// image. Set also 'USE_CACHE' below. +define('READ_CACHE',true); + +// Determine if the error handler should be image based or purely +// text based. Image based makes it easier since the script will +// always return an image even in case of errors. +define('USE_IMAGE_ERROR_HANDLER',true); + +// Should the library examine the global php_errmsg string and convert +// any error in it to a graphical representation. This is handy for the +// occasions when, for example, header files cannot be found and this results +// in the graph not being created and just a 'red-cross' image would be seen. +// This should be turned off for a production site. +define('CATCH_PHPERRMSG',true); + +// Determine if the library should also setup the default PHP +// error handler to generate a graphic error mesage. This is useful +// during development to be able to see the error message as an image +// instead as a 'red-cross' in a page where an image is expected. +define('INSTALL_PHP_ERR_HANDLER',false); + +// Should usage of deprecated functions and parameters give a fatal error? +// (Useful to check if code is future proof.) +define('ERR_DEPRECATED',true); + +// The builtin GD function imagettfbbox() fuction which calculates the bounding box for +// text using TTF fonts is buggy. By setting this define to true the library +// uses its own compensation for this bug. However this will give a +// slightly different visual apparance than not using this compensation. +// Enabling this compensation will in general give text a bit more space to more +// truly reflect the actual bounding box which is a bit larger than what the +// GD function thinks. +define('USE_LIBRARY_IMAGETTFBBOX',true); + +//------------------------------------------------------------------------ +// The following constants should rarely have to be changed ! +//------------------------------------------------------------------------ + +// What group should the cached file belong to +// (Set to '' will give the default group for the 'PHP-user') +// Please note that the Apache user must be a member of the +// specified group since otherwise it is impossible for Apache +// to set the specified group. +define('CACHE_FILE_GROUP','www'); + +// What permissions should the cached file have +// (Set to '' will give the default persmissions for the 'PHP-user') +define('CACHE_FILE_MOD',0664); + +// Default theme class name +define('DEFAULT_THEME_CLASS', 'UniversalTheme'); + +define('SUPERSAMPLING', true); +define('SUPERSAMPLING_SCALE', 1); + +?> diff --git a/html/jpgraph/jpgraph.php b/html/jpgraph/jpgraph.php new file mode 100644 index 0000000..24f9001 --- /dev/null +++ b/html/jpgraph/jpgraph.php @@ -0,0 +1,5626 @@ +<?php +//======================================================================= +// File: JPGRAPH.PHP +// Description: PHP Graph Plotting library. Base module. +// Created: 2001-01-08 +// Ver: $Id: jpgraph.php 1924 2010-01-11 14:03:26Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +require_once('jpg-config.inc.php'); +require_once('jpgraph_gradient.php'); +require_once('jpgraph_errhandler.inc.php'); +require_once('jpgraph_ttf.inc.php'); +require_once('jpgraph_rgb.inc.php'); +require_once('jpgraph_text.inc.php'); +require_once('jpgraph_legend.inc.php'); +require_once('jpgraph_theme.inc.php'); +require_once('gd_image.inc.php'); + +// Version info +define('JPG_VERSION','3.5.0b1'); + +// Minimum required PHP version +define('MIN_PHPVERSION','5.1.0'); + +// Special file name to indicate that we only want to calc +// the image map in the call to Graph::Stroke() used +// internally from the GetHTMLCSIM() method. +define('_CSIM_SPECIALFILE','_csim_special_'); + +// HTTP GET argument that is used with image map +// to indicate to the script to just generate the image +// and not the full CSIM HTML page. +define('_CSIM_DISPLAY','_jpg_csimd'); + +// Special filename for Graph::Stroke(). If this filename is given +// then the image will NOT be streamed to browser of file. Instead the +// Stroke call will return the handler for the created GD image. +define('_IMG_HANDLER','__handle'); + +// Special filename for Graph::Stroke(). If this filename is given +// the image will be stroked to a file with a name based on the script name. +define('_IMG_AUTO','auto'); + +// Tick density +define("TICKD_DENSE",1); +define("TICKD_NORMAL",2); +define("TICKD_SPARSE",3); +define("TICKD_VERYSPARSE",4); + +// Side for ticks and labels. +define("SIDE_LEFT",-1); +define("SIDE_RIGHT",1); +define("SIDE_DOWN",-1); +define("SIDE_BOTTOM",-1); +define("SIDE_UP",1); +define("SIDE_TOP",1); + +// Legend type stacked vertical or horizontal +define("LEGEND_VERT",0); +define("LEGEND_HOR",1); + +// Mark types for plot marks +define("MARK_SQUARE",1); +define("MARK_UTRIANGLE",2); +define("MARK_DTRIANGLE",3); +define("MARK_DIAMOND",4); +define("MARK_CIRCLE",5); +define("MARK_FILLEDCIRCLE",6); +define("MARK_CROSS",7); +define("MARK_STAR",8); +define("MARK_X",9); +define("MARK_LEFTTRIANGLE",10); +define("MARK_RIGHTTRIANGLE",11); +define("MARK_FLASH",12); +define("MARK_IMG",13); +define("MARK_FLAG1",14); +define("MARK_FLAG2",15); +define("MARK_FLAG3",16); +define("MARK_FLAG4",17); + +// Builtin images +define("MARK_IMG_PUSHPIN",50); +define("MARK_IMG_SPUSHPIN",50); +define("MARK_IMG_LPUSHPIN",51); +define("MARK_IMG_DIAMOND",52); +define("MARK_IMG_SQUARE",53); +define("MARK_IMG_STAR",54); +define("MARK_IMG_BALL",55); +define("MARK_IMG_SBALL",55); +define("MARK_IMG_MBALL",56); +define("MARK_IMG_LBALL",57); +define("MARK_IMG_BEVEL",58); + +// Inline defines +define("INLINE_YES",1); +define("INLINE_NO",0); + +// Format for background images +define("BGIMG_FILLPLOT",1); +define("BGIMG_FILLFRAME",2); +define("BGIMG_COPY",3); +define("BGIMG_CENTER",4); +define("BGIMG_FREE",5); + +// Depth of objects +define("DEPTH_BACK",0); +define("DEPTH_FRONT",1); + +// Direction +define("VERTICAL",1); +define("HORIZONTAL",0); + +// Axis styles for scientific style axis +define('AXSTYLE_SIMPLE',1); +define('AXSTYLE_BOXIN',2); +define('AXSTYLE_BOXOUT',3); +define('AXSTYLE_YBOXIN',4); +define('AXSTYLE_YBOXOUT',5); + +// Style for title backgrounds +define('TITLEBKG_STYLE1',1); +define('TITLEBKG_STYLE2',2); +define('TITLEBKG_STYLE3',3); +define('TITLEBKG_FRAME_NONE',0); +define('TITLEBKG_FRAME_FULL',1); +define('TITLEBKG_FRAME_BOTTOM',2); +define('TITLEBKG_FRAME_BEVEL',3); +define('TITLEBKG_FILLSTYLE_HSTRIPED',1); +define('TITLEBKG_FILLSTYLE_VSTRIPED',2); +define('TITLEBKG_FILLSTYLE_SOLID',3); + +// Styles for axis labels background +define('LABELBKG_NONE',0); +define('LABELBKG_XAXIS',1); +define('LABELBKG_YAXIS',2); +define('LABELBKG_XAXISFULL',3); +define('LABELBKG_YAXISFULL',4); +define('LABELBKG_XYFULL',5); +define('LABELBKG_XY',6); + + +// Style for background gradient fills +define('BGRAD_FRAME',1); +define('BGRAD_MARGIN',2); +define('BGRAD_PLOT',3); + +// Width of tab titles +define('TABTITLE_WIDTHFIT',0); +define('TABTITLE_WIDTHFULL',-1); + +// Defines for 3D skew directions +define('SKEW3D_UP',0); +define('SKEW3D_DOWN',1); +define('SKEW3D_LEFT',2); +define('SKEW3D_RIGHT',3); + +// For internal use only +define("_JPG_DEBUG",false); +define("_FORCE_IMGTOFILE",false); +define("_FORCE_IMGDIR",'/tmp/jpgimg/'); + + +// +// Automatic settings of path for cache and font directory +// if they have not been previously specified +// +if(USE_CACHE) { + if (!defined('CACHE_DIR')) { + if ( strstr( PHP_OS, 'WIN') ) { + if( empty($_SERVER['TEMP']) ) { + $t = new ErrMsgText(); + $msg = $t->Get(11,$file,$lineno); + die($msg); + } + else { + define('CACHE_DIR', $_SERVER['TEMP'] . '/'); + } + } else { + define('CACHE_DIR','/tmp/jpgraph_cache/'); + } + } +} +elseif( !defined('CACHE_DIR') ) { + define('CACHE_DIR', ''); +} + +// +// Setup path for western/latin TTF fonts +// +if (!defined('TTF_DIR')) { + if (strstr( PHP_OS, 'WIN') ) { + $sroot = getenv('SystemRoot'); + if( empty($sroot) ) { + $t = new ErrMsgText(); + $msg = $t->Get(12,$file,$lineno); + die($msg); + } + else { + define('TTF_DIR', $sroot.'/fonts/'); + } + } else { + define('TTF_DIR','/usr/share/fonts/truetype/'); + } +} + +// +// Setup path for MultiByte TTF fonts (japanese, chinese etc.) +// +if (!defined('MBTTF_DIR')) { + if (strstr( PHP_OS, 'WIN') ) { + $sroot = getenv('SystemRoot'); + if( empty($sroot) ) { + $t = new ErrMsgText(); + $msg = $t->Get(12,$file,$lineno); + die($msg); + } + else { + define('MBTTF_DIR', $sroot.'/fonts/'); + } + } else { + define('MBTTF_DIR','/usr/share/fonts/truetype/'); + } +} + +// +// Check minimum PHP version +// +function CheckPHPVersion($aMinVersion) { + list($majorC, $minorC, $editC) = preg_split('/[\/.-]/', PHP_VERSION); + list($majorR, $minorR, $editR) = preg_split('/[\/.-]/', $aMinVersion); + + if ($majorC != $majorR) return false; + if ($majorC < $majorR) return false; + // same major - check minor + if ($minorC > $minorR) return true; + if ($minorC < $minorR) return false; + // and same minor + if ($editC >= $editR) return true; + return true; +} + +// +// Make sure PHP version is high enough +// +if( !CheckPHPVersion(MIN_PHPVERSION) ) { + JpGraphError::RaiseL(13,PHP_VERSION,MIN_PHPVERSION); + die(); +} + +// +// Make GD sanity check +// +if( !function_exists("imagetypes") || !function_exists('imagecreatefromstring') ) { + JpGraphError::RaiseL(25001); + //("This PHP installation is not configured with the GD library. Please recompile PHP with GD support to run JpGraph. (Neither function imagetypes() nor imagecreatefromstring() does exist)"); +} + +// +// Setup PHP error handler +// +function _phpErrorHandler($errno,$errmsg,$filename, $linenum, $vars) { + // Respect current error level + if( $errno & error_reporting() ) { + JpGraphError::RaiseL(25003,basename($filename),$linenum,$errmsg); + } +} + +if( INSTALL_PHP_ERR_HANDLER ) { + set_error_handler("_phpErrorHandler"); +} + +// +// Check if there were any warnings, perhaps some wrong includes by the user. In this +// case we raise it immediately since otherwise the image will not show and makes +// debugging difficult. This is controlled by the user setting CATCH_PHPERRMSG +// +if( isset($GLOBALS['php_errormsg']) && CATCH_PHPERRMSG && !preg_match('/|Deprecated|/i', $GLOBALS['php_errormsg']) ) { + JpGraphError::RaiseL(25004,$GLOBALS['php_errormsg']); +} + +// Useful mathematical function +function sign($a) {return $a >= 0 ? 1 : -1;} + +// +// Utility function to generate an image name based on the filename we +// are running from and assuming we use auto detection of graphic format +// (top level), i.e it is safe to call this function +// from a script that uses JpGraph +// +function GenImgName() { + // Determine what format we should use when we save the images + $supported = imagetypes(); + if( $supported & IMG_PNG ) $img_format="png"; + elseif( $supported & IMG_GIF ) $img_format="gif"; + elseif( $supported & IMG_JPG ) $img_format="jpeg"; + elseif( $supported & IMG_WBMP ) $img_format="wbmp"; + elseif( $supported & IMG_XPM ) $img_format="xpm"; + + + if( !isset($_SERVER['PHP_SELF']) ) { + JpGraphError::RaiseL(25005); + //(" Can't access PHP_SELF, PHP global variable. You can't run PHP from command line if you want to use the 'auto' naming of cache or image files."); + } + $fname = basename($_SERVER['PHP_SELF']); + if( !empty($_SERVER['QUERY_STRING']) ) { + $q = @$_SERVER['QUERY_STRING']; + $fname .= '_'.preg_replace("/\W/", "_", $q).'.'.$img_format; + } + else { + $fname = substr($fname,0,strlen($fname)-4).'.'.$img_format; + } + return $fname; +} + +//=================================================== +// CLASS JpgTimer +// Description: General timing utility class to handle +// time measurement of generating graphs. Multiple +// timers can be started. +//=================================================== +class JpgTimer { + private $start, $idx; + + function __construct() { + $this->idx=0; + } + + // Push a new timer start on stack + function Push() { + list($ms,$s)=explode(" ",microtime()); + $this->start[$this->idx++]=floor($ms*1000) + 1000*$s; + } + + // Pop the latest timer start and return the diff with the + // current time + function Pop() { + assert($this->idx>0); + list($ms,$s)=explode(" ",microtime()); + $etime=floor($ms*1000) + (1000*$s); + $this->idx--; + return $etime-$this->start[$this->idx]; + } +} // Class + +//=================================================== +// CLASS DateLocale +// Description: Hold localized text used in dates +//=================================================== +class DateLocale { + + public $iLocale = 'C'; // environmental locale be used by default + private $iDayAbb = null, $iShortDay = null, $iShortMonth = null, $iMonthName = null; + + function __construct() { + settype($this->iDayAbb, 'array'); + settype($this->iShortDay, 'array'); + settype($this->iShortMonth, 'array'); + settype($this->iMonthName, 'array'); + $this->Set('C'); + } + + function Set($aLocale) { + if ( in_array($aLocale, array_keys($this->iDayAbb)) ){ + $this->iLocale = $aLocale; + return TRUE; // already cached nothing else to do! + } + + $pLocale = setlocale(LC_TIME, 0); // get current locale for LC_TIME + + if (is_array($aLocale)) { + foreach ($aLocale as $loc) { + $res = @setlocale(LC_TIME, $loc); + if ( $res ) { + $aLocale = $loc; + break; + } + } + } + else { + $res = @setlocale(LC_TIME, $aLocale); + } + + if ( ! $res ) { + JpGraphError::RaiseL(25007,$aLocale); + //("You are trying to use the locale ($aLocale) which your PHP installation does not support. Hint: Use '' to indicate the default locale for this geographic region."); + return FALSE; + } + + $this->iLocale = $aLocale; + for( $i = 0, $ofs = 0 - strftime('%w'); $i < 7; $i++, $ofs++ ) { + $day = strftime('%a', strtotime("$ofs day")); + $day[0] = strtoupper($day[0]); + $this->iDayAbb[$aLocale][]= $day[0]; + $this->iShortDay[$aLocale][]= $day; + } + + for($i=1; $i<=12; ++$i) { + list($short ,$full) = explode('|', strftime("%b|%B",strtotime("2001-$i-01"))); + $this->iShortMonth[$aLocale][] = ucfirst($short); + $this->iMonthName [$aLocale][] = ucfirst($full); + } + + setlocale(LC_TIME, $pLocale); + + return TRUE; + } + + + function GetDayAbb() { + return $this->iDayAbb[$this->iLocale]; + } + + function GetShortDay() { + return $this->iShortDay[$this->iLocale]; + } + + function GetShortMonth() { + return $this->iShortMonth[$this->iLocale]; + } + + function GetShortMonthName($aNbr) { + return $this->iShortMonth[$this->iLocale][$aNbr]; + } + + function GetLongMonthName($aNbr) { + return $this->iMonthName[$this->iLocale][$aNbr]; + } + + function GetMonth() { + return $this->iMonthName[$this->iLocale]; + } +} + +// Global object handlers +gDateLocale = new DateLocale(); +gJpgDateLocale = new DateLocale(); + +//======================================================= +// CLASS Footer +// Description: Encapsulates the footer line in the Graph +//======================================================= +class Footer { + public $iLeftMargin = 3, $iRightMargin = 3, $iBottomMargin = 3 ; + public $left,$center,$right; + private $iTimer=null, $itimerpoststring=''; + + function __construct() { + $this->left = new Text(); + $this->left->ParagraphAlign('left'); + $this->center = new Text(); + $this->center->ParagraphAlign('center'); + $this->right = new Text(); + $this->right->ParagraphAlign('right'); + } + + function SetTimer($aTimer,$aTimerPostString='') { + $this->iTimer = $aTimer; + $this->itimerpoststring = $aTimerPostString; + } + + function SetMargin($aLeft=3,$aRight=3,$aBottom=3) { + $this->iLeftMargin = $aLeft; + $this->iRightMargin = $aRight; + $this->iBottomMargin = $aBottom; + } + + function Stroke($aImg) { + $y = $aImg->height - $this->iBottomMargin; + $x = $this->iLeftMargin; + $this->left->Align('left','bottom'); + $this->left->Stroke($aImg,$x,$y); + + $x = ($aImg->width - $this->iLeftMargin - $this->iRightMargin)/2; + $this->center->Align('center','bottom'); + $this->center->Stroke($aImg,$x,$y); + + $x = $aImg->width - $this->iRightMargin; + $this->right->Align('right','bottom'); + if( $this->iTimer != null ) { + $this->right->Set( $this->right->t . sprintf('%.3f',$this->iTimer->Pop()/1000.0) . $this->itimerpoststring ); + } + $this->right->Stroke($aImg,$x,$y); + } +} + + +//=================================================== +// CLASS Graph +// Description: Main class to handle graphs +//=================================================== +class Graph { + public $cache=null; // Cache object (singleton) + public $img=null; // Img object (singleton) + public $plots=array(); // Array of all plot object in the graph (for Y 1 axis) + public $y2plots=array(); // Array of all plot object in the graph (for Y 2 axis) + public $ynplots=array(); + public $xscale=null; // X Scale object (could be instance of LinearScale or LogScale + public $yscale=null,$y2scale=null, $ynscale=array(); + public $iIcons = array(); // Array of Icons to add to + public $cache_name; // File name to be used for the current graph in the cache directory + public $xgrid=null; // X Grid object (linear or logarithmic) + public $ygrid=null,$y2grid=null; //dito for Y + public $doframe,$frame_color, $frame_weight; // Frame around graph + public $boxed=false, $box_color='black', $box_weight=1; // Box around plot area + public $doshadow=false,$shadow_width=4,$shadow_color='gray@0.5'; // Shadow for graph + public $xaxis=null; // X-axis (instane of Axis class) + public $yaxis=null, $y2axis=null, $ynaxis=array(); // Y axis (instance of Axis class) + public $margin_color; // Margin color of graph + public $plotarea_color=array(255,255,255); // Plot area color + public $title,$subtitle,$subsubtitle; // Title and subtitle(s) text object + public $axtype="linlin"; // Type of axis + public $xtick_factor,$ytick_factor; // Factor to determine the maximum number of ticks depending on the plot width + public $texts=null, $y2texts=null; // Text object to ge shown in the graph + public $lines=null, $y2lines=null; + public $bands=null, $y2bands=null; + public $text_scale_off=0, $text_scale_abscenteroff=-1; // Text scale in fractions and for centering bars + public $background_image='',$background_image_type=-1,$background_image_format="png"; + public $background_image_bright=0,$background_image_contr=0,$background_image_sat=0; + public $background_image_xpos=0,$background_image_ypos=0; + public $image_bright=0, $image_contr=0, $image_sat=0; + public $inline; + public $showcsim=0,$csimcolor="red";//debug stuff, draw the csim boundaris on the image if <>0 + public $grid_depth=DEPTH_BACK; // Draw grid under all plots as default + public $iAxisStyle = AXSTYLE_SIMPLE; + public $iCSIMdisplay=false,$iHasStroked = false; + public $footer; + public $csimcachename = '', $csimcachetimeout = 0, $iCSIMImgAlt=''; + public $iDoClipping = false; + public $y2orderback=true; + public $tabtitle; + public $bkg_gradtype=-1,$bkg_gradstyle=BGRAD_MARGIN; + public $bkg_gradfrom='navy', $bkg_gradto='silver'; + public $plot_gradtype=-1,$plot_gradstyle=BGRAD_MARGIN; + public $plot_gradfrom='silver', $plot_gradto='navy'; + + public $titlebackground = false; + public $titlebackground_color = 'lightblue', + $titlebackground_style = 1, + $titlebackground_framecolor, + $titlebackground_framestyle, + $titlebackground_frameweight, + $titlebackground_bevelheight; + public $titlebkg_fillstyle=TITLEBKG_FILLSTYLE_SOLID; + public $titlebkg_scolor1='black',$titlebkg_scolor2='white'; + public $framebevel, $framebeveldepth; + public $framebevelborder, $framebevelbordercolor; + public $framebevelcolor1, $framebevelcolor2; + public $background_image_mix=100; + public $background_cflag = ''; + public $background_cflag_type = BGIMG_FILLPLOT; + public $background_cflag_mix = 100; + public $iImgTrans=false, + $iImgTransHorizon = 100,$iImgTransSkewDist=150, + $iImgTransDirection = 1, $iImgTransMinSize = true, + $iImgTransFillColor='white',$iImgTransHighQ=false, + $iImgTransBorder=false,$iImgTransHorizonPos=0.5; + public $legend; + public $graph_theme; + protected $iYAxisDeltaPos=50; + protected $iIconDepth=DEPTH_BACK; + protected $iAxisLblBgType = 0, + $iXAxisLblBgFillColor = 'lightgray', $iXAxisLblBgColor = 'black', + $iYAxisLblBgFillColor = 'lightgray', $iYAxisLblBgColor = 'black'; + protected $iTables=NULL; + + protected $isRunningClear = false; + protected $inputValues; + protected $isAfterSetScale = false; + + // aWIdth Width in pixels of image + // aHeight Height in pixels of image + // aCachedName Name for image file in cache directory + // aTimeOut Timeout in minutes for image in cache + // aInline If true the image is streamed back in the call to Stroke() + // If false the image is just created in the cache + function __construct($aWidth=300,$aHeight=200,$aCachedName='',$aTimeout=0,$aInline=true) { + + if( !is_numeric($aWidth) || !is_numeric($aHeight) ) { + JpGraphError::RaiseL(25008);//('Image width/height argument in Graph::Graph() must be numeric'); + } + + // Initialize frame and margin + $this->InitializeFrameAndMargin(); + + // Automatically generate the image file name based on the name of the script that + // generates the graph + if( $aCachedName == 'auto' ) { + $aCachedName=GenImgName(); + } + + // Should the image be streamed back to the browser or only to the cache? + $this->inline=$aInline; + + $this->img = new RotImage($aWidth,$aHeight); + $this->cache = new ImgStreamCache(); + + // Window doesn't like '?' in the file name so replace it with an '_' + $aCachedName = str_replace("?","_",$aCachedName); + $this->SetupCache($aCachedName, $aTimeout); + + $this->title = new Text(); + $this->title->ParagraphAlign('center'); + $this->title->SetFont(FF_DEFAULT,FS_NORMAL); //FF_FONT2, FS_BOLD + $this->title->SetMargin(5); + $this->title->SetAlign('center'); + + $this->subtitle = new Text(); + $this->subtitle->ParagraphAlign('center'); + $this->subtitle->SetMargin(3); + $this->subtitle->SetAlign('center'); + + $this->subsubtitle = new Text(); + $this->subsubtitle->ParagraphAlign('center'); + $this->subsubtitle->SetMargin(3); + $this->subsubtitle->SetAlign('center'); + + $this->legend = new Legend(); + $this->footer = new Footer(); + + // If the cached version exist just read it directly from the + // cache, stream it back to browser and exit + if( $aCachedName!='' && READ_CACHE && $aInline ) { + if( $this->cache->GetAndStream($this->img,$aCachedName) ) { + exit(); + } + } + + $this->SetTickDensity(); // Normal density + + $this->tabtitle = new GraphTabTitle(); + + if (!$this->isRunningClear) { + $this->inputValues = array(); + $this->inputValues['aWidth'] = $aWidth; + $this->inputValues['aHeight'] = $aHeight; + $this->inputValues['aCachedName'] = $aCachedName; + $this->inputValues['aTimeout'] = $aTimeout; + $this->inputValues['aInline'] = $aInline; + + $theme_class = DEFAULT_THEME_CLASS; + if (class_exists($theme_class)) { + $this->graph_theme = new $theme_class(); + } + } + } + + function InitializeFrameAndMargin() { + $this->doframe=true; + $this->frame_color='black'; + $this->frame_weight=1; + + $this->titlebackground_framecolor = 'blue'; + $this->titlebackground_framestyle = 2; + $this->titlebackground_frameweight = 1; + $this->titlebackground_bevelheight = 3; + $this->titlebkg_fillstyle=TITLEBKG_FILLSTYLE_SOLID; + $this->titlebkg_scolor1='black'; + $this->titlebkg_scolor2='white'; + $this->framebevel = false; + $this->framebeveldepth = 2; + $this->framebevelborder = false; + $this->framebevelbordercolor='black'; + $this->framebevelcolor1='white@0.4'; + $this->framebevelcolor2='black@0.4'; + + $this->margin_color = array(250,250,250); + } + + function SetupCache($aFilename,$aTimeout=60) { + $this->cache_name = $aFilename; + $this->cache->SetTimeOut($aTimeout); + } + + // Enable final image perspective transformation + function Set3DPerspective($aDir=1,$aHorizon=100,$aSkewDist=120,$aQuality=false,$aFillColor='#FFFFFF',$aBorder=false,$aMinSize=true,$aHorizonPos=0.5) { + $this->iImgTrans = true; + $this->iImgTransHorizon = $aHorizon; + $this->iImgTransSkewDist= $aSkewDist; + $this->iImgTransDirection = $aDir; + $this->iImgTransMinSize = $aMinSize; + $this->iImgTransFillColor=$aFillColor; + $this->iImgTransHighQ=$aQuality; + $this->iImgTransBorder=$aBorder; + $this->iImgTransHorizonPos=$aHorizonPos; + } + + function SetUserFont($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->img->ttf->SetUserFont($aNormal,$aBold,$aItalic,$aBoldIt); + } + + function SetUserFont1($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->img->ttf->SetUserFont1($aNormal,$aBold,$aItalic,$aBoldIt); + } + + function SetUserFont2($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->img->ttf->SetUserFont2($aNormal,$aBold,$aItalic,$aBoldIt); + } + + function SetUserFont3($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->img->ttf->SetUserFont3($aNormal,$aBold,$aItalic,$aBoldIt); + } + + // Set Image format and optional quality + function SetImgFormat($aFormat,$aQuality=75) { + $this->img->SetImgFormat($aFormat,$aQuality); + } + + // Should the grid be in front or back of the plot? + function SetGridDepth($aDepth) { + $this->grid_depth=$aDepth; + } + + function SetIconDepth($aDepth) { + $this->iIconDepth=$aDepth; + } + + // Specify graph angle 0-360 degrees. + function SetAngle($aAngle) { + $this->img->SetAngle($aAngle); + } + + function SetAlphaBlending($aFlg=true) { + $this->img->SetAlphaBlending($aFlg); + } + + // Shortcut to image margin + function SetMargin($lm,$rm,$tm,$bm) { + $this->img->SetMargin($lm,$rm,$tm,$bm); + } + + function SetY2OrderBack($aBack=true) { + $this->y2orderback = $aBack; + } + + // Rotate the graph 90 degrees and set the margin + // when we have done a 90 degree rotation + function Set90AndMargin($lm=0,$rm=0,$tm=0,$bm=0) { + $lm = $lm ==0 ? floor(0.2 * $this->img->width) : $lm ; + $rm = $rm ==0 ? floor(0.1 * $this->img->width) : $rm ; + $tm = $tm ==0 ? floor(0.2 * $this->img->height) : $tm ; + $bm = $bm ==0 ? floor(0.1 * $this->img->height) : $bm ; + + $adj = ($this->img->height - $this->img->width)/2; + $this->img->SetMargin($tm-$adj,$bm-$adj,$rm+$adj,$lm+$adj); + $this->img->SetCenter(floor($this->img->width/2),floor($this->img->height/2)); + $this->SetAngle(90); + if( empty($this->yaxis) || empty($this->xaxis) ) { + JpgraphError::RaiseL(25009);//('You must specify what scale to use with a call to Graph::SetScale()'); + } + $this->xaxis->SetLabelAlign('right','center'); + $this->yaxis->SetLabelAlign('center','bottom'); + } + + function SetClipping($aFlg=true) { + $this->iDoClipping = $aFlg ; + } + + // Add a plot object to the graph + function Add($aPlot) { + if( $aPlot == null ) { + JpGraphError::RaiseL(25010);//("Graph::Add() You tried to add a null plot to the graph."); + } + if( is_array($aPlot) && count($aPlot) > 0 ) { + $cl = $aPlot[0]; + } + else { + $cl = $aPlot; + } + + if( $cl instanceof Text ) $this->AddText($aPlot); + elseif( class_exists('PlotLine',false) && ($cl instanceof PlotLine) ) $this->AddLine($aPlot); + elseif( class_exists('PlotBand',false) && ($cl instanceof PlotBand) ) $this->AddBand($aPlot); + elseif( class_exists('IconPlot',false) && ($cl instanceof IconPlot) ) $this->AddIcon($aPlot); + elseif( class_exists('GTextTable',false) && ($cl instanceof GTextTable) ) $this->AddTable($aPlot); + else { + if( is_array($aPlot) ) { + $this->plots = array_merge($this->plots,$aPlot); + } + else { + $this->plots[] = $aPlot; + } + } + + if ($this->graph_theme) { + $this->graph_theme->SetupPlot($aPlot); + } + } + + function AddTable($aTable) { + if( is_array($aTable) ) { + for($i=0; $i < count($aTable); ++$i ) { + $this->iTables[]=$aTable[$i]; + } + } + else { + $this->iTables[] = $aTable ; + } + } + + function AddIcon($aIcon) { + if( is_array($aIcon) ) { + for($i=0; $i < count($aIcon); ++$i ) { + $this->iIcons[]=$aIcon[$i]; + } + } + else { + $this->iIcons[] = $aIcon ; + } + } + + // Add plot to second Y-scale + function AddY2($aPlot) { + if( $aPlot == null ) { + JpGraphError::RaiseL(25011);//("Graph::AddY2() You tried to add a null plot to the graph."); + } + + if( is_array($aPlot) && count($aPlot) > 0 ) { + $cl = $aPlot[0]; + } + else { + $cl = $aPlot; + } + + if( $cl instanceof Text ) { + $this->AddText($aPlot,true); + } + elseif( class_exists('PlotLine',false) && ($cl instanceof PlotLine) ) { + $this->AddLine($aPlot,true); + } + elseif( class_exists('PlotBand',false) && ($cl instanceof PlotBand) ) { + $this->AddBand($aPlot,true); + } + else { + $this->y2plots[] = $aPlot; + } + + if ($this->graph_theme) { + $this->graph_theme->SetupPlot($aPlot); + } + } + + // Add plot to the extra Y-axises + function AddY($aN,$aPlot) { + + if( $aPlot == null ) { + JpGraphError::RaiseL(25012);//("Graph::AddYN() You tried to add a null plot to the graph."); + } + + if( is_array($aPlot) && count($aPlot) > 0 ) { + $cl = $aPlot[0]; + } + else { + $cl = $aPlot; + } + + if( ($cl instanceof Text) || + (class_exists('PlotLine',false) && ($cl instanceof PlotLine)) || + (class_exists('PlotBand',false) && ($cl instanceof PlotBand)) ) { + JpGraph::RaiseL(25013);//('You can only add standard plots to multiple Y-axis'); + } + else { + $this->ynplots[$aN][] = $aPlot; + } + + if ($this->graph_theme) { + $this->graph_theme->SetupPlot($aPlot); + } + } + + // Add text object to the graph + function AddText($aTxt,$aToY2=false) { + if( $aTxt == null ) { + JpGraphError::RaiseL(25014);//("Graph::AddText() You tried to add a null text to the graph."); + } + if( $aToY2 ) { + if( is_array($aTxt) ) { + for($i=0; $i < count($aTxt); ++$i ) { + $this->y2texts[]=$aTxt[$i]; + } + } + else { + $this->y2texts[] = $aTxt; + } + } + else { + if( is_array($aTxt) ) { + for($i=0; $i < count($aTxt); ++$i ) { + $this->texts[]=$aTxt[$i]; + } + } + else { + $this->texts[] = $aTxt; + } + } + } + + // Add a line object (class PlotLine) to the graph + function AddLine($aLine,$aToY2=false) { + if( $aLine == null ) { + JpGraphError::RaiseL(25015);//("Graph::AddLine() You tried to add a null line to the graph."); + } + + if( $aToY2 ) { + if( is_array($aLine) ) { + for($i=0; $i < count($aLine); ++$i ) { + //$this->y2lines[]=$aLine[$i]; + $this->y2plots[]=$aLine[$i]; + } + } + else { + //$this->y2lines[] = $aLine; + $this->y2plots[]=$aLine; + } + } + else { + if( is_array($aLine) ) { + for($i=0; $i<count($aLine); ++$i ) { + //$this->lines[]=$aLine[$i]; + $this->plots[]=$aLine[$i]; + } + } + else { + //$this->lines[] = $aLine; + $this->plots[] = $aLine; + } + } + } + + // Add vertical or horizontal band + function AddBand($aBand,$aToY2=false) { + if( $aBand == null ) { + JpGraphError::RaiseL(25016);//(" Graph::AddBand() You tried to add a null band to the graph."); + } + + if( $aToY2 ) { + if( is_array($aBand) ) { + for($i=0; $i < count($aBand); ++$i ) { + $this->y2bands[] = $aBand[$i]; + } + } + else { + $this->y2bands[] = $aBand; + } + } + else { + if( is_array($aBand) ) { + for($i=0; $i < count($aBand); ++$i ) { + $this->bands[] = $aBand[$i]; + } + } + else { + $this->bands[] = $aBand; + } + } + } + + function SetPlotGradient($aFrom='navy',$aTo='silver',$aGradType=2) { + $this->plot_gradtype=$aGradType; + $this->plot_gradfrom = $aFrom; + $this->plot_gradto = $aTo; + } + + function SetBackgroundGradient($aFrom='navy',$aTo='silver',$aGradType=2,$aStyle=BGRAD_FRAME) { + $this->bkg_gradtype=$aGradType; + $this->bkg_gradstyle=$aStyle; + $this->bkg_gradfrom = $aFrom; + $this->bkg_gradto = $aTo; + } + + // Set a country flag in the background + function SetBackgroundCFlag($aName,$aBgType=BGIMG_FILLPLOT,$aMix=100) { + $this->background_cflag = $aName; + $this->background_cflag_type = $aBgType; + $this->background_cflag_mix = $aMix; + } + + // Alias for the above method + function SetBackgroundCountryFlag($aName,$aBgType=BGIMG_FILLPLOT,$aMix=100) { + $this->background_cflag = $aName; + $this->background_cflag_type = $aBgType; + $this->background_cflag_mix = $aMix; + } + + + // Specify a background image + function SetBackgroundImage($aFileName,$aBgType=BGIMG_FILLPLOT,$aImgFormat='auto') { + + // Get extension to determine image type + if( $aImgFormat == 'auto' ) { + $e = explode('.',$aFileName); + if( !$e ) { + JpGraphError::RaiseL(25018,$aFileName);//('Incorrect file name for Graph::SetBackgroundImage() : '.$aFileName.' Must have a valid image extension (jpg,gif,png) when using autodetection of image type'); + } + + $valid_formats = array('png', 'jpg', 'gif'); + $aImgFormat = strtolower($e[count($e)-1]); + if ($aImgFormat == 'jpeg') { + $aImgFormat = 'jpg'; + } + elseif (!in_array($aImgFormat, $valid_formats) ) { + JpGraphError::RaiseL(25019,$aImgFormat);//('Unknown file extension ($aImgFormat) in Graph::SetBackgroundImage() for filename: '.$aFileName); + } + } + + $this->background_image = $aFileName; + $this->background_image_type=$aBgType; + $this->background_image_format=$aImgFormat; + } + + function SetBackgroundImageMix($aMix) { + $this->background_image_mix = $aMix ; + } + + // Adjust background image position + function SetBackgroundImagePos($aXpos,$aYpos) { + $this->background_image_xpos = $aXpos ; + $this->background_image_ypos = $aYpos ; + } + + // Specify axis style (boxed or single) + function SetAxisStyle($aStyle) { + $this->iAxisStyle = $aStyle ; + } + + // Set a frame around the plot area + function SetBox($aDrawPlotFrame=true,$aPlotFrameColor=array(0,0,0),$aPlotFrameWeight=1) { + $this->boxed = $aDrawPlotFrame; + $this->box_weight = $aPlotFrameWeight; + $this->box_color = $aPlotFrameColor; + } + + // Specify color for the plotarea (not the margins) + function SetColor($aColor) { + $this->plotarea_color=$aColor; + } + + // Specify color for the margins (all areas outside the plotarea) + function SetMarginColor($aColor) { + $this->margin_color=$aColor; + } + + // Set a frame around the entire image + function SetFrame($aDrawImgFrame=true,$aImgFrameColor=array(0,0,0),$aImgFrameWeight=1) { + $this->doframe = $aDrawImgFrame; + $this->frame_color = $aImgFrameColor; + $this->frame_weight = $aImgFrameWeight; + } + + function SetFrameBevel($aDepth=3,$aBorder=false,$aBorderColor='black',$aColor1='white@0.4',$aColor2='darkgray@0.4',$aFlg=true) { + $this->framebevel = $aFlg ; + $this->framebeveldepth = $aDepth ; + $this->framebevelborder = $aBorder ; + $this->framebevelbordercolor = $aBorderColor ; + $this->framebevelcolor1 = $aColor1 ; + $this->framebevelcolor2 = $aColor2 ; + + $this->doshadow = false ; + } + + // Set the shadow around the whole image + function SetShadow($aShowShadow=true,$aShadowWidth=5,$aShadowColor='darkgray') { + $this->doshadow = $aShowShadow; + $this->shadow_color = $aShadowColor; + $this->shadow_width = $aShadowWidth; + $this->footer->iBottomMargin += $aShadowWidth; + $this->footer->iRightMargin += $aShadowWidth; + } + + // Specify x,y scale. Note that if you manually specify the scale + // you must also specify the tick distance with a call to Ticks::Set() + function SetScale($aAxisType,$aYMin=1,$aYMax=1,$aXMin=1,$aXMax=1) { + $this->axtype = $aAxisType; + + if( $aYMax < $aYMin || $aXMax < $aXMin ) { + JpGraphError::RaiseL(25020);//('Graph::SetScale(): Specified Max value must be larger than the specified Min value.'); + } + + $yt=substr($aAxisType,-3,3); + if( $yt == 'lin' ) { + $this->yscale = new LinearScale($aYMin,$aYMax); + } + elseif( $yt == 'int' ) { + $this->yscale = new LinearScale($aYMin,$aYMax); + $this->yscale->SetIntScale(); + } + elseif( $yt == 'log' ) { + $this->yscale = new LogScale($aYMin,$aYMax); + } + else { + JpGraphError::RaiseL(25021,$aAxisType);//("Unknown scale specification for Y-scale. ($aAxisType)"); + } + + $xt=substr($aAxisType,0,3); + if( $xt == 'lin' || $xt == 'tex' ) { + $this->xscale = new LinearScale($aXMin,$aXMax,'x'); + $this->xscale->textscale = ($xt == 'tex'); + } + elseif( $xt == 'int' ) { + $this->xscale = new LinearScale($aXMin,$aXMax,'x'); + $this->xscale->SetIntScale(); + } + elseif( $xt == 'dat' ) { + $this->xscale = new DateScale($aXMin,$aXMax,'x'); + } + elseif( $xt == 'log' ) { + $this->xscale = new LogScale($aXMin,$aXMax,'x'); + } + else { + JpGraphError::RaiseL(25022,$aAxisType);//(" Unknown scale specification for X-scale. ($aAxisType)"); + } + + $this->xaxis = new Axis($this->img,$this->xscale); + $this->yaxis = new Axis($this->img,$this->yscale); + $this->xgrid = new Grid($this->xaxis); + $this->ygrid = new Grid($this->yaxis); + $this->ygrid->Show(); + + + if (!$this->isRunningClear) { + $this->inputValues['aAxisType'] = $aAxisType; + $this->inputValues['aYMin'] = $aYMin; + $this->inputValues['aYMax'] = $aYMax; + $this->inputValues['aXMin'] = $aXMin; + $this->inputValues['aXMax'] = $aXMax; + + if ($this->graph_theme) { + $this->graph_theme->ApplyGraph($this); + } + } + + $this->isAfterSetScale = true; + } + + // Specify secondary Y scale + function SetY2Scale($aAxisType='lin',$aY2Min=1,$aY2Max=1) { + if( $aAxisType == 'lin' ) { + $this->y2scale = new LinearScale($aY2Min,$aY2Max); + } + elseif( $aAxisType == 'int' ) { + $this->y2scale = new LinearScale($aY2Min,$aY2Max); + $this->y2scale->SetIntScale(); + } + elseif( $aAxisType == 'log' ) { + $this->y2scale = new LogScale($aY2Min,$aY2Max); + } + else { + JpGraphError::RaiseL(25023,$aAxisType);//("JpGraph: Unsupported Y2 axis type: $aAxisType\nMust be one of (lin,log,int)"); + } + + $this->y2axis = new Axis($this->img,$this->y2scale); + $this->y2axis->scale->ticks->SetDirection(SIDE_LEFT); + $this->y2axis->SetLabelSide(SIDE_RIGHT); + $this->y2axis->SetPos('max'); + $this->y2axis->SetTitleSide(SIDE_RIGHT); + + // Deafult position is the max x-value + $this->y2grid = new Grid($this->y2axis); + + if ($this->graph_theme) { + $this->graph_theme->ApplyGraph($this); + } + } + + // Set the delta position (in pixels) between the multiple Y-axis + function SetYDeltaDist($aDist) { + $this->iYAxisDeltaPos = $aDist; + } + + // Specify secondary Y scale + function SetYScale($aN,$aAxisType="lin",$aYMin=1,$aYMax=1) { + + if( $aAxisType == 'lin' ) { + $this->ynscale[$aN] = new LinearScale($aYMin,$aYMax); + } + elseif( $aAxisType == 'int' ) { + $this->ynscale[$aN] = new LinearScale($aYMin,$aYMax); + $this->ynscale[$aN]->SetIntScale(); + } + elseif( $aAxisType == 'log' ) { + $this->ynscale[$aN] = new LogScale($aYMin,$aYMax); + } + else { + JpGraphError::RaiseL(25024,$aAxisType);//("JpGraph: Unsupported Y axis type: $aAxisType\nMust be one of (lin,log,int)"); + } + + $this->ynaxis[$aN] = new Axis($this->img,$this->ynscale[$aN]); + $this->ynaxis[$aN]->scale->ticks->SetDirection(SIDE_LEFT); + $this->ynaxis[$aN]->SetLabelSide(SIDE_RIGHT); + + if ($this->graph_theme) { + $this->graph_theme->ApplyGraph($this); + } + } + + // Specify density of ticks when autoscaling 'normal', 'dense', 'sparse', 'verysparse' + // The dividing factor have been determined heuristically according to my aesthetic + // sense (or lack off) y.m.m.v ! + function SetTickDensity($aYDensity=TICKD_NORMAL,$aXDensity=TICKD_NORMAL) { + $this->xtick_factor=30; + $this->ytick_factor=25; + switch( $aYDensity ) { + case TICKD_DENSE: + $this->ytick_factor=12; + break; + case TICKD_NORMAL: + $this->ytick_factor=25; + break; + case TICKD_SPARSE: + $this->ytick_factor=40; + break; + case TICKD_VERYSPARSE: + $this->ytick_factor=100; + break; + default: + JpGraphError::RaiseL(25025,$densy);//("JpGraph: Unsupported Tick density: $densy"); + } + switch( $aXDensity ) { + case TICKD_DENSE: + $this->xtick_factor=15; + break; + case TICKD_NORMAL: + $this->xtick_factor=30; + break; + case TICKD_SPARSE: + $this->xtick_factor=45; + break; + case TICKD_VERYSPARSE: + $this->xtick_factor=60; + break; + default: + JpGraphError::RaiseL(25025,$densx);//("JpGraph: Unsupported Tick density: $densx"); + } + } + + + // Get a string of all image map areas + function GetCSIMareas() { + if( !$this->iHasStroked ) { + $this->Stroke(_CSIM_SPECIALFILE); + } + + $csim = $this->title->GetCSIMAreas(); + $csim .= $this->subtitle->GetCSIMAreas(); + $csim .= $this->subsubtitle->GetCSIMAreas(); + $csim .= $this->legend->GetCSIMAreas(); + + if( $this->y2axis != NULL ) { + $csim .= $this->y2axis->title->GetCSIMAreas(); + } + + if( $this->texts != null ) { + $n = count($this->texts); + for($i=0; $i < $n; ++$i ) { + $csim .= $this->texts[$i]->GetCSIMAreas(); + } + } + + if( $this->y2texts != null && $this->y2scale != null ) { + $n = count($this->y2texts); + for($i=0; $i < $n; ++$i ) { + $csim .= $this->y2texts[$i]->GetCSIMAreas(); + } + } + + if( $this->yaxis != null && $this->xaxis != null ) { + $csim .= $this->yaxis->title->GetCSIMAreas(); + $csim .= $this->xaxis->title->GetCSIMAreas(); + } + + $n = count($this->plots); + for( $i=0; $i < $n; ++$i ) { + $csim .= $this->plots[$i]->GetCSIMareas(); + } + + $n = count($this->y2plots); + for( $i=0; $i < $n; ++$i ) { + $csim .= $this->y2plots[$i]->GetCSIMareas(); + } + + $n = count($this->ynaxis); + for( $i=0; $i < $n; ++$i ) { + $m = count($this->ynplots[$i]); + for($j=0; $j < $m; ++$j ) { + $csim .= $this->ynplots[$i][$j]->GetCSIMareas(); + } + } + + $n = count($this->iTables); + for( $i=0; $i < $n; ++$i ) { + $csim .= $this->iTables[$i]->GetCSIMareas(); + } + + return $csim; + } + + // Get a complete <MAP>..</MAP> tag for the final image map + function GetHTMLImageMap($aMapName) { + $im = "<map name=\"$aMapName\" id=\"$aMapName\" >\n"; + $im .= $this->GetCSIMareas(); + $im .= "</map>"; + return $im; + } + + function CheckCSIMCache($aCacheName,$aTimeOut=60) { + global $_SERVER; + + if( $aCacheName=='auto' ) { + $aCacheName=basename($_SERVER['PHP_SELF']); + } + + $urlarg = $this->GetURLArguments(); + $this->csimcachename = CSIMCACHE_DIR.$aCacheName.$urlarg; + $this->csimcachetimeout = $aTimeOut; + + // First determine if we need to check for a cached version + // This differs from the standard cache in the sense that the + // image and CSIM map HTML file is written relative to the directory + // the script executes in and not the specified cache directory. + // The reason for this is that the cache directory is not necessarily + // accessible from the HTTP server. + if( $this->csimcachename != '' ) { + $dir = dirname($this->csimcachename); + $base = basename($this->csimcachename); + $base = strtok($base,'.'); + $suffix = strtok('.'); + $basecsim = $dir.'/'.$base.'?'.$urlarg.'_csim_.html'; + $baseimg = $dir.'/'.$base.'?'.$urlarg.'.'.$this->img->img_format; + + $timedout=false; + // Does it exist at all ? + + if( file_exists($basecsim) && file_exists($baseimg) ) { + // Check that it hasn't timed out + $diff=time()-filemtime($basecsim); + if( $this->csimcachetimeout>0 && ($diff > $this->csimcachetimeout*60) ) { + $timedout=true; + @unlink($basecsim); + @unlink($baseimg); + } + else { + if ($fh = @fopen($basecsim, "r")) { + fpassthru($fh); + return true; + } + else { + JpGraphError::RaiseL(25027,$basecsim);//(" Can't open cached CSIM \"$basecsim\" for reading."); + } + } + } + } + return false; + } + + // Build the argument string to be used with the csim images + static function GetURLArguments($aAddRecursiveBlocker=false) { + + if( $aAddRecursiveBlocker ) { + // This is a JPGRAPH internal defined that prevents + // us from recursively coming here again + $urlarg = _CSIM_DISPLAY.'=1'; + } + + // Now reconstruct any user URL argument + reset($_GET); + while( list($key,$value) = each($_GET) ) { + if( is_array($value) ) { + foreach ( $value as $k => $v ) { + $urlarg .= '&'.$key.'%5B'.$k.'%5D='.urlencode($v); + } + } + else { + $urlarg .= '&'.$key.'='.urlencode($value); + } + } + + // It's not ideal to convert POST argument to GET arguments + // but there is little else we can do. One idea for the + // future might be recreate the POST header in case. + reset($_POST); + while( list($key,$value) = each($_POST) ) { + if( is_array($value) ) { + foreach ( $value as $k => $v ) { + $urlarg .= '&'.$key.'%5B'.$k.'%5D='.urlencode($v); + } + } + else { + $urlarg .= '&'.$key.'='.urlencode($value); + } + } + + return $urlarg; + } + + function SetCSIMImgAlt($aAlt) { + $this->iCSIMImgAlt = $aAlt; + } + + function StrokeCSIM($aScriptName='auto',$aCSIMName='',$aBorder=0) { + if( $aCSIMName=='' ) { + // create a random map name + srand ((double) microtime() * 1000000); + $r = rand(0,100000); + $aCSIMName='__mapname'.$r.'__'; + } + + if( $aScriptName=='auto' ) { + $aScriptName=basename($_SERVER['PHP_SELF']); + } + + $urlarg = $this->GetURLArguments(true); + + if( empty($_GET[_CSIM_DISPLAY]) ) { + // First determine if we need to check for a cached version + // This differs from the standard cache in the sense that the + // image and CSIM map HTML file is written relative to the directory + // the script executes in and not the specified cache directory. + // The reason for this is that the cache directory is not necessarily + // accessible from the HTTP server. + if( $this->csimcachename != '' ) { + $dir = dirname($this->csimcachename); + $base = basename($this->csimcachename); + $base = strtok($base,'.'); + $suffix = strtok('.'); + $basecsim = $dir.'/'.$base.'?'.$urlarg.'_csim_.html'; + $baseimg = $base.'?'.$urlarg.'.'.$this->img->img_format; + + // Check that apache can write to directory specified + + if( file_exists($dir) && !is_writeable($dir) ) { + JpgraphError::RaiseL(25028,$dir);//('Apache/PHP does not have permission to write to the CSIM cache directory ('.$dir.'). Check permissions.'); + } + + // Make sure directory exists + $this->cache->MakeDirs($dir); + + // Write the image file + $this->Stroke(CSIMCACHE_DIR.$baseimg); + + // Construct wrapper HTML and write to file and send it back to browser + + // In the src URL we must replace the '?' with its encoding to prevent the arguments + // to be converted to real arguments. + $tmp = str_replace('?','%3f',$baseimg); + $htmlwrap = $this->GetHTMLImageMap($aCSIMName)."\n". + '<img src="'.CSIMCACHE_HTTP_DIR.$tmp.'" ismap="ismap" usemap="#'.$aCSIMName.' width="'.$this->img->width.'" height="'.$this->img->height."\" alt=\"".$this->iCSIMImgAlt."\" />\n"; + + if($fh = @fopen($basecsim,'w') ) { + fwrite($fh,$htmlwrap); + fclose($fh); + echo $htmlwrap; + } + else { + JpGraphError::RaiseL(25029,$basecsim);//(" Can't write CSIM \"$basecsim\" for writing. Check free space and permissions."); + } + } + else { + + if( $aScriptName=='' ) { + JpGraphError::RaiseL(25030);//('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().'); + } + echo $this->GetHTMLImageMap($aCSIMName) . $this->GetCSIMImgHTML($aCSIMName, $aScriptName, $aBorder); + } + } + else { + $this->Stroke(); + } + } + + function StrokeCSIMImage() { + if( @$_GET[_CSIM_DISPLAY] == 1 ) { + $this->Stroke(); + } + } + + function GetCSIMImgHTML($aCSIMName, $aScriptName='auto', $aBorder=0 ) { + if( $aScriptName=='auto' ) { + $aScriptName=basename($_SERVER['PHP_SELF']); + } + $urlarg = $this->GetURLArguments(true); + return "<img src=\"".$aScriptName.'?'.$urlarg."\" ismap=\"ismap\" usemap=\"#".$aCSIMName.'" height="'.$this->img->height."\" alt=\"".$this->iCSIMImgAlt."\" />\n"; + } + + function GetTextsYMinMax($aY2=false) { + if( $aY2 ) { + $txts = $this->y2texts; + } + else { + $txts = $this->texts; + } + $n = count($txts); + $min=null; + $max=null; + for( $i=0; $i < $n; ++$i ) { + if( $txts[$i]->iScalePosY !== null && $txts[$i]->iScalePosX !== null ) { + if( $min === null ) { + $min = $max = $txts[$i]->iScalePosY ; + } + else { + $min = min($min,$txts[$i]->iScalePosY); + $max = max($max,$txts[$i]->iScalePosY); + } + } + } + if( $min !== null ) { + return array($min,$max); + } + else { + return null; + } + } + + function GetTextsXMinMax($aY2=false) { + if( $aY2 ) { + $txts = $this->y2texts; + } + else { + $txts = $this->texts; + } + $n = count($txts); + $min=null; + $max=null; + for( $i=0; $i < $n; ++$i ) { + if( $txts[$i]->iScalePosY !== null && $txts[$i]->iScalePosX !== null ) { + if( $min === null ) { + $min = $max = $txts[$i]->iScalePosX ; + } + else { + $min = min($min,$txts[$i]->iScalePosX); + $max = max($max,$txts[$i]->iScalePosX); + } + } + } + if( $min !== null ) { + return array($min,$max); + } + else { + return null; + } + } + + function GetXMinMax() { + + list($min,$ymin) = $this->plots[0]->Min(); + list($max,$ymax) = $this->plots[0]->Max(); + + $i=0; + // Some plots, e.g. PlotLine should not affect the scale + // and will return (null,null). We should ignore those + // values. + while( ($min===null || $max === null) && ($i < count($this->plots)-1) ) { + ++$i; + list($min,$ymin) = $this->plots[$i]->Min(); + list($max,$ymax) = $this->plots[$i]->Max(); + } + + foreach( $this->plots as $p ) { + list($xmin,$ymin) = $p->Min(); + list($xmax,$ymax) = $p->Max(); + + if( $xmin !== null && $xmax !== null ) { + $min = Min($xmin,$min); + $max = Max($xmax,$max); + } + } + + if( $this->y2axis != null ) { + foreach( $this->y2plots as $p ) { + list($xmin,$ymin) = $p->Min(); + list($xmax,$ymax) = $p->Max(); + $min = Min($xmin,$min); + $max = Max($xmax,$max); + } + } + + $n = count($this->ynaxis); + for( $i=0; $i < $n; ++$i ) { + if( $this->ynaxis[$i] != null) { + foreach( $this->ynplots[$i] as $p ) { + list($xmin,$ymin) = $p->Min(); + list($xmax,$ymax) = $p->Max(); + $min = Min($xmin,$min); + $max = Max($xmax,$max); + } + } + } + return array($min,$max); + } + + function AdjustMarginsForTitles() { + $totrequired = + ($this->title->t != '' + ? $this->title->GetTextHeight($this->img) + $this->title->margin + 5 * SUPERSAMPLING_SCALE + : 0 ) + + ($this->subtitle->t != '' + ? $this->subtitle->GetTextHeight($this->img) + $this->subtitle->margin + 5 * SUPERSAMPLING_SCALE + : 0 ) + + ($this->subsubtitle->t != '' + ? $this->subsubtitle->GetTextHeight($this->img) + $this->subsubtitle->margin + 5 * SUPERSAMPLING_SCALE + : 0 ) ; + + $btotrequired = 0; + if($this->xaxis != null && !$this->xaxis->hide && !$this->xaxis->hide_labels ) { + // Minimum bottom margin + if( $this->xaxis->title->t != '' ) { + if( $this->img->a == 90 ) { + $btotrequired = $this->yaxis->title->GetTextHeight($this->img) + 7 ; + } + else { + $btotrequired = $this->xaxis->title->GetTextHeight($this->img) + 7 ; + } + } + else { + $btotrequired = 0; + } + + if( $this->img->a == 90 ) { + $this->img->SetFont($this->yaxis->font_family,$this->yaxis->font_style, + $this->yaxis->font_size); + $lh = $this->img->GetTextHeight('Mg',$this->yaxis->label_angle); + } + else { + $this->img->SetFont($this->xaxis->font_family,$this->xaxis->font_style, + $this->xaxis->font_size); + $lh = $this->img->GetTextHeight('Mg',$this->xaxis->label_angle); + } + + $btotrequired += $lh + 6; + } + + if( $this->img->a == 90 ) { + // DO Nothing. It gets too messy to do this properly for 90 deg... + } + else{ + // need more top margin + if( $this->img->top_margin < $totrequired ) { + $this->SetMargin( + $this->img->raw_left_margin, + $this->img->raw_right_margin, + $totrequired / SUPERSAMPLING_SCALE, + $this->img->raw_bottom_margin + ); + } + + // need more bottom margin + if( $this->img->bottom_margin < $btotrequired ) { + $this->SetMargin( + $this->img->raw_left_margin, + $this->img->raw_right_margin, + $this->img->raw_top_margin, + $btotrequired / SUPERSAMPLING_SCALE + ); + } + } + } + + function StrokeStore($aStrokeFileName) { + // Get the handler to prevent the library from sending the + // image to the browser + $ih = $this->Stroke(_IMG_HANDLER); + + // Stroke it to a file + $this->img->Stream($aStrokeFileName); + + // Send it back to browser + $this->img->Headers(); + $this->img->Stream(); + } + + function doAutoscaleXAxis() { + //Check if we should autoscale x-axis + if( !$this->xscale->IsSpecified() ) { + if( substr($this->axtype,0,4) == "text" ) { + $max=0; + $n = count($this->plots); + for($i=0; $i < $n; ++$i ) { + $p = $this->plots[$i]; + // We need some unfortunate sub class knowledge here in order + // to increase number of data points in case it is a line plot + // which has the barcenter set. If not it could mean that the + // last point of the data is outside the scale since the barcenter + // settings means that we will shift the entire plot half a tick step + // to the right in oder to align with the center of the bars. + if( class_exists('BarPlot',false) ) { + $cl = strtolower(get_class($p)); + if( (class_exists('BarPlot',false) && ($p instanceof BarPlot)) || empty($p->barcenter) ) { + $max=max($max,$p->numpoints-1); + } + else { + $max=max($max,$p->numpoints); + } + } + else { + if( empty($p->barcenter) ) { + $max=max($max,$p->numpoints-1); + } + else { + $max=max($max,$p->numpoints); + } + } + } + $min=0; + if( $this->y2axis != null ) { + foreach( $this->y2plots as $p ) { + $max=max($max,$p->numpoints-1); + } + } + $n = count($this->ynaxis); + for( $i=0; $i < $n; ++$i ) { + if( $this->ynaxis[$i] != null) { + foreach( $this->ynplots[$i] as $p ) { + $max=max($max,$p->numpoints-1); + } + } + } + + $this->xscale->Update($this->img,$min,$max); + $this->xscale->ticks->Set($this->xaxis->tick_step,1); + $this->xscale->ticks->SupressMinorTickMarks(); + } + else { + list($min,$max) = $this->GetXMinMax(); + + $lres = $this->GetLinesXMinMax($this->lines); + if( $lres ) { + list($linmin,$linmax) = $lres ; + $min = min($min,$linmin); + $max = max($max,$linmax); + } + + $lres = $this->GetLinesXMinMax($this->y2lines); + if( $lres ) { + list($linmin,$linmax) = $lres ; + $min = min($min,$linmin); + $max = max($max,$linmax); + } + + $tres = $this->GetTextsXMinMax(); + if( $tres ) { + list($tmin,$tmax) = $tres ; + $min = min($min,$tmin); + $max = max($max,$tmax); + } + + $tres = $this->GetTextsXMinMax(true); + if( $tres ) { + list($tmin,$tmax) = $tres ; + $min = min($min,$tmin); + $max = max($max,$tmax); + } + + $this->xscale->AutoScale($this->img,$min,$max,round($this->img->plotwidth/$this->xtick_factor)); + } + + //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale + if( !is_numeric($this->yaxis->pos) && !is_string($this->yaxis->pos) ) { + $this->yaxis->SetPos($this->xscale->GetMinVal()); + } + } + elseif( $this->xscale->IsSpecified() && + ( $this->xscale->auto_ticks || !$this->xscale->ticks->IsSpecified()) ) { + // The tick calculation will use the user suplied min/max values to determine + // the ticks. If auto_ticks is false the exact user specifed min and max + // values will be used for the scale. + // If auto_ticks is true then the scale might be slightly adjusted + // so that the min and max values falls on an even major step. + $min = $this->xscale->scale[0]; + $max = $this->xscale->scale[1]; + $this->xscale->AutoScale($this->img,$min,$max,round($this->img->plotwidth/$this->xtick_factor),false); + + // Now make sure we show enough precision to accurate display the + // labels. If this is not done then the user might end up with + // a scale that might actually start with, say 13.5, butdue to rounding + // the scale label will ony show 14. + if( abs(floor($min)-$min) > 0 ) { + + // If the user has set a format then we bail out + if( $this->xscale->ticks->label_formatstr == '' && $this->xscale->ticks->label_dateformatstr == '' ) { + $this->xscale->ticks->precision = abs( floor(log10( abs(floor($min)-$min))) )+1; + } + } + } + + // Position the optional Y2 and Yn axis to the rightmost position of the x-axis + if( $this->y2axis != null ) { + if( !is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos) ) { + $this->y2axis->SetPos($this->xscale->GetMaxVal()); + } + $this->y2axis->SetTitleSide(SIDE_RIGHT); + } + + $n = count($this->ynaxis); + $nY2adj = $this->y2axis != null ? $this->iYAxisDeltaPos : 0; + for( $i=0; $i < $n; ++$i ) { + if( $this->ynaxis[$i] != null ) { + if( !is_numeric($this->ynaxis[$i]->pos) && !is_string($this->ynaxis[$i]->pos) ) { + $this->ynaxis[$i]->SetPos($this->xscale->GetMaxVal()); + $this->ynaxis[$i]->SetPosAbsDelta($i*$this->iYAxisDeltaPos + $nY2adj); + } + $this->ynaxis[$i]->SetTitleSide(SIDE_RIGHT); + } + } + } + + + function doAutoScaleYnAxis() { + + if( $this->y2scale != null) { + if( !$this->y2scale->IsSpecified() && count($this->y2plots)>0 ) { + list($min,$max) = $this->GetPlotsYMinMax($this->y2plots); + + $lres = $this->GetLinesYMinMax($this->y2lines); + if( is_array($lres) ) { + list($linmin,$linmax) = $lres ; + $min = min($min,$linmin); + $max = max($max,$linmax); + } + $tres = $this->GetTextsYMinMax(true); + if( is_array($tres) ) { + list($tmin,$tmax) = $tres ; + $min = min($min,$tmin); + $max = max($max,$tmax); + } + $this->y2scale->AutoScale($this->img,$min,$max,$this->img->plotheight/$this->ytick_factor); + } + elseif( $this->y2scale->IsSpecified() && ( $this->y2scale->auto_ticks || !$this->y2scale->ticks->IsSpecified()) ) { + // The tick calculation will use the user suplied min/max values to determine + // the ticks. If auto_ticks is false the exact user specifed min and max + // values will be used for the scale. + // If auto_ticks is true then the scale might be slightly adjusted + // so that the min and max values falls on an even major step. + $min = $this->y2scale->scale[0]; + $max = $this->y2scale->scale[1]; + $this->y2scale->AutoScale($this->img,$min,$max, + $this->img->plotheight/$this->ytick_factor, + $this->y2scale->auto_ticks); + + // Now make sure we show enough precision to accurate display the + // labels. If this is not done then the user might end up with + // a scale that might actually start with, say 13.5, butdue to rounding + // the scale label will ony show 14. + if( abs(floor($min)-$min) > 0 ) { + // If the user has set a format then we bail out + if( $this->y2scale->ticks->label_formatstr == '' && $this->y2scale->ticks->label_dateformatstr == '' ) { + $this->y2scale->ticks->precision = abs( floor(log10( abs(floor($min)-$min))) )+1; + } + } + + } + } + + + // + // Autoscale the extra Y-axises + // + $n = count($this->ynaxis); + for( $i=0; $i < $n; ++$i ) { + if( $this->ynscale[$i] != null) { + if( !$this->ynscale[$i]->IsSpecified() && count($this->ynplots[$i])>0 ) { + list($min,$max) = $this->GetPlotsYMinMax($this->ynplots[$i]); + $this->ynscale[$i]->AutoScale($this->img,$min,$max,$this->img->plotheight/$this->ytick_factor); + } + elseif( $this->ynscale[$i]->IsSpecified() && ( $this->ynscale[$i]->auto_ticks || !$this->ynscale[$i]->ticks->IsSpecified()) ) { + // The tick calculation will use the user suplied min/max values to determine + // the ticks. If auto_ticks is false the exact user specifed min and max + // values will be used for the scale. + // If auto_ticks is true then the scale might be slightly adjusted + // so that the min and max values falls on an even major step. + $min = $this->ynscale[$i]->scale[0]; + $max = $this->ynscale[$i]->scale[1]; + $this->ynscale[$i]->AutoScale($this->img,$min,$max, + $this->img->plotheight/$this->ytick_factor, + $this->ynscale[$i]->auto_ticks); + + // Now make sure we show enough precision to accurate display the + // labels. If this is not done then the user might end up with + // a scale that might actually start with, say 13.5, butdue to rounding + // the scale label will ony show 14. + if( abs(floor($min)-$min) > 0 ) { + // If the user has set a format then we bail out + if( $this->ynscale[$i]->ticks->label_formatstr == '' && $this->ynscale[$i]->ticks->label_dateformatstr == '' ) { + $this->ynscale[$i]->ticks->precision = abs( floor(log10( abs(floor($min)-$min))) )+1; + } + } + } + } + } + } + + function doAutoScaleYAxis() { + + //Check if we should autoscale y-axis + if( !$this->yscale->IsSpecified() && count($this->plots)>0 ) { + list($min,$max) = $this->GetPlotsYMinMax($this->plots); + $lres = $this->GetLinesYMinMax($this->lines); + if( is_array($lres) ) { + list($linmin,$linmax) = $lres ; + $min = min($min,$linmin); + $max = max($max,$linmax); + } + $tres = $this->GetTextsYMinMax(); + if( is_array($tres) ) { + list($tmin,$tmax) = $tres ; + $min = min($min,$tmin); + $max = max($max,$tmax); + } + $this->yscale->AutoScale($this->img,$min,$max, + $this->img->plotheight/$this->ytick_factor); + } + elseif( $this->yscale->IsSpecified() && ( $this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified()) ) { + // The tick calculation will use the user suplied min/max values to determine + // the ticks. If auto_ticks is false the exact user specifed min and max + // values will be used for the scale. + // If auto_ticks is true then the scale might be slightly adjusted + // so that the min and max values falls on an even major step. + $min = $this->yscale->scale[0]; + $max = $this->yscale->scale[1]; + $this->yscale->AutoScale($this->img,$min,$max, + $this->img->plotheight/$this->ytick_factor, + $this->yscale->auto_ticks); + + // Now make sure we show enough precision to accurate display the + // labels. If this is not done then the user might end up with + // a scale that might actually start with, say 13.5, butdue to rounding + // the scale label will ony show 14. + if( abs(floor($min)-$min) > 0 ) { + + // If the user has set a format then we bail out + if( $this->yscale->ticks->label_formatstr == '' && $this->yscale->ticks->label_dateformatstr == '' ) { + $this->yscale->ticks->precision = abs( floor(log10( abs(floor($min)-$min))) )+1; + } + } + } + + } + + function InitScaleConstants() { + // Setup scale constants + if( $this->yscale ) $this->yscale->InitConstants($this->img); + if( $this->xscale ) $this->xscale->InitConstants($this->img); + if( $this->y2scale ) $this->y2scale->InitConstants($this->img); + + $n=count($this->ynscale); + for($i=0; $i < $n; ++$i) { + if( $this->ynscale[$i] ) { + $this->ynscale[$i]->InitConstants($this->img); + } + } + } + + function doPrestrokeAdjustments() { + + // Do any pre-stroke adjustment that is needed by the different plot types + // (i.e bar plots want's to add an offset to the x-labels etc) + for($i=0; $i < count($this->plots) ; ++$i ) { + $this->plots[$i]->PreStrokeAdjust($this); + $this->plots[$i]->DoLegend($this); + } + + // Any plots on the second Y scale? + if( $this->y2scale != null ) { + for($i=0; $i<count($this->y2plots) ; ++$i ) { + $this->y2plots[$i]->PreStrokeAdjust($this); + $this->y2plots[$i]->DoLegend($this); + } + } + + // Any plots on the extra Y axises? + $n = count($this->ynaxis); + for($i=0; $i<$n ; ++$i ) { + if( $this->ynplots == null || $this->ynplots[$i] == null) { + JpGraphError::RaiseL(25032,$i);//("No plots for Y-axis nbr:$i"); + } + $m = count($this->ynplots[$i]); + for($j=0; $j < $m; ++$j ) { + $this->ynplots[$i][$j]->PreStrokeAdjust($this); + $this->ynplots[$i][$j]->DoLegend($this); + } + } + } + + function StrokeBands($aDepth,$aCSIM) { + // Stroke bands + if( $this->bands != null && !$aCSIM) { + for($i=0; $i < count($this->bands); ++$i) { + // Stroke all bands that asks to be in the background + if( $this->bands[$i]->depth == $aDepth ) { + $this->bands[$i]->Stroke($this->img,$this->xscale,$this->yscale); + } + } + } + + if( $this->y2bands != null && $this->y2scale != null && !$aCSIM ) { + for($i=0; $i < count($this->y2bands); ++$i) { + // Stroke all bands that asks to be in the foreground + if( $this->y2bands[$i]->depth == $aDepth ) { + $this->y2bands[$i]->Stroke($this->img,$this->xscale,$this->y2scale); + } + } + } + } + + + // Stroke the graph + // $aStrokeFileName If != "" the image will be written to this file and NOT + // streamed back to the browser + function Stroke($aStrokeFileName='') { + // Fist make a sanity check that user has specified a scale + if( empty($this->yscale) ) { + JpGraphError::RaiseL(25031);//('You must specify what scale to use with a call to Graph::SetScale().'); + } + + // Start by adjusting the margin so that potential titles will fit. + $this->AdjustMarginsForTitles(); + + // Give the plot a chance to do any scale adjuments the individual plots + // wants to do. Right now this is only used by the contour plot to set scale + // limits + for($i=0; $i < count($this->plots) ; ++$i ) { + $this->plots[$i]->PreScaleSetup($this); + } + + // Init scale constants that are used to calculate the transformation from + // world to pixel coordinates + $this->InitScaleConstants(); + + // If the filename is the predefined value = '_csim_special_' + // we assume that the call to stroke only needs to do enough + // to correctly generate the CSIM maps. + // We use this variable to skip things we don't strictly need + // to do to generate the image map to improve performance + // a best we can. Therefor you will see a lot of tests !$_csim in the + // code below. + $_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); + + // If we are called the second time (perhaps the user has called GetHTMLImageMap() + // himself then the legends have alsready been populated once in order to get the + // CSIM coordinats. Since we do not want the legends to be populated a second time + // we clear the legends + $this->legend->Clear(); + + // We need to know if we have stroked the plot in the + // GetCSIMareas. Otherwise the CSIM hasn't been generated + // and in the case of GetCSIM called before stroke to generate + // CSIM without storing an image to disk GetCSIM must call Stroke. + $this->iHasStroked = true; + + // Setup pre-stroked adjustments and Legends + $this->doPrestrokeAdjustments(); + + if ($this->graph_theme) { + $this->graph_theme->PreStrokeApply($this); + } + + // Bail out if any of the Y-axis not been specified and + // has no plots. (This means it is impossible to do autoscaling and + // no other scale was given so we can't possible draw anything). If you use manual + // scaling you also have to supply the tick steps as well. + if( (!$this->yscale->IsSpecified() && count($this->plots)==0) || + ($this->y2scale!=null && !$this->y2scale->IsSpecified() && count($this->y2plots)==0) ) { + //$e = "n=".count($this->y2plots)."\n"; + // $e = "Can't draw unspecified Y-scale.<br>\nYou have either:<br>\n"; + // $e .= "1. Specified an Y axis for autoscaling but have not supplied any plots<br>\n"; + // $e .= "2. Specified a scale manually but have forgot to specify the tick steps"; + JpGraphError::RaiseL(25026); + } + + // Bail out if no plots and no specified X-scale + if( (!$this->xscale->IsSpecified() && count($this->plots)==0 && count($this->y2plots)==0) ) { + JpGraphError::RaiseL(25034);//("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>"); + } + + // Autoscale the normal Y-axis + $this->doAutoScaleYAxis(); + + // Autoscale all additiopnal y-axis + $this->doAutoScaleYnAxis(); + + // Autoscale the regular x-axis and position the y-axis properly + $this->doAutoScaleXAxis(); + + // If we have a negative values and x-axis position is at 0 + // we need to supress the first and possible the last tick since + // they will be drawn on top of the y-axis (and possible y2 axis) + // The test below might seem strange the reasone being that if + // the user hasn't specified a value for position this will not + // be set until we do the stroke for the axis so as of now it + // is undefined. + // For X-text scale we ignore all this since the tick are usually + // much further in and not close to the Y-axis. Hence the test + // for 'text' + if( ($this->yaxis->pos==$this->xscale->GetMinVal() || (is_string($this->yaxis->pos) && $this->yaxis->pos=='min')) && + !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 && + substr($this->axtype,0,4) != 'text' && $this->xaxis->pos != 'min' ) { + + //$this->yscale->ticks->SupressZeroLabel(false); + $this->xscale->ticks->SupressFirst(); + if( $this->y2axis != null ) { + $this->xscale->ticks->SupressLast(); + } + } + elseif( !is_numeric($this->yaxis->pos) && $this->yaxis->pos=='max' ) { + $this->xscale->ticks->SupressLast(); + } + + if( !$_csim ) { + $this->StrokePlotArea(); + if( $this->iIconDepth == DEPTH_BACK ) { + $this->StrokeIcons(); + } + } + $this->StrokeAxis(false); + + // Stroke colored bands + $this->StrokeBands(DEPTH_BACK,$_csim); + + if( $this->grid_depth == DEPTH_BACK && !$_csim) { + $this->ygrid->Stroke(); + $this->xgrid->Stroke(); + } + + // Stroke Y2-axis + if( $this->y2axis != null && !$_csim) { + $this->y2axis->Stroke($this->xscale); + $this->y2grid->Stroke(); + } + + // Stroke yn-axis + $n = count($this->ynaxis); + for( $i=0; $i < $n; ++$i ) { + $this->ynaxis[$i]->Stroke($this->xscale); + } + + $oldoff=$this->xscale->off; + if( substr($this->axtype,0,4) == 'text' ) { + if( $this->text_scale_abscenteroff > -1 ) { + // For a text scale the scale factor is the number of pixel per step. + // Hence we can use the scale factor as a substitute for number of pixels + // per major scale step and use that in order to adjust the offset so that + // an object of width "abscenteroff" becomes centered. + $this->xscale->off += round($this->xscale->scale_factor/2)-round($this->text_scale_abscenteroff/2); + } + else { + $this->xscale->off += ceil($this->xscale->scale_factor*$this->text_scale_off*$this->xscale->ticks->minor_step); + } + } + + if( $this->iDoClipping ) { + $oldimage = $this->img->CloneCanvasH(); + } + + if( ! $this->y2orderback ) { + // Stroke all plots for Y1 axis + for($i=0; $i < count($this->plots); ++$i) { + $this->plots[$i]->Stroke($this->img,$this->xscale,$this->yscale); + $this->plots[$i]->StrokeMargin($this->img); + } + } + + // Stroke all plots for Y2 axis + if( $this->y2scale != null ) { + for($i=0; $i< count($this->y2plots); ++$i ) { + $this->y2plots[$i]->Stroke($this->img,$this->xscale,$this->y2scale); + } + } + + if( $this->y2orderback ) { + // Stroke all plots for Y1 axis + for($i=0; $i < count($this->plots); ++$i) { + $this->plots[$i]->Stroke($this->img,$this->xscale,$this->yscale); + $this->plots[$i]->StrokeMargin($this->img); + } + } + + $n = count($this->ynaxis); + for( $i=0; $i < $n; ++$i ) { + $m = count($this->ynplots[$i]); + for( $j=0; $j < $m; ++$j ) { + $this->ynplots[$i][$j]->Stroke($this->img,$this->xscale,$this->ynscale[$i]); + $this->ynplots[$i][$j]->StrokeMargin($this->img); + } + } + + if( $this->iIconDepth == DEPTH_FRONT) { + $this->StrokeIcons(); + } + + if( $this->iDoClipping ) { + // Clipping only supports graphs at 0 and 90 degrees + if( $this->img->a == 0 ) { + $this->img->CopyCanvasH($oldimage,$this->img->img, + $this->img->left_margin,$this->img->top_margin, + $this->img->left_margin,$this->img->top_margin, + $this->img->plotwidth+1,$this->img->plotheight); + } + elseif( $this->img->a == 90 ) { + $adj = ($this->img->height - $this->img->width)/2; + $this->img->CopyCanvasH($oldimage,$this->img->img, + $this->img->bottom_margin-$adj,$this->img->left_margin+$adj, + $this->img->bottom_margin-$adj,$this->img->left_margin+$adj, + $this->img->plotheight+1,$this->img->plotwidth); + } + else { + JpGraphError::RaiseL(25035,$this->img->a);//('You have enabled clipping. Cliping is only supported for graphs at 0 or 90 degrees rotation. Please adjust you current angle (='.$this->img->a.' degrees) or disable clipping.'); + } + $this->img->Destroy(); + $this->img->SetCanvasH($oldimage); + } + + $this->xscale->off=$oldoff; + + if( $this->grid_depth == DEPTH_FRONT && !$_csim ) { + $this->ygrid->Stroke(); + $this->xgrid->Stroke(); + } + + // Stroke colored bands + $this->StrokeBands(DEPTH_FRONT,$_csim); + + // Finally draw the axis again since some plots may have nagged + // the axis in the edges. + if( !$_csim ) { + $this->StrokeAxis(); + } + + if( $this->y2scale != null && !$_csim ) { + $this->y2axis->Stroke($this->xscale,false); + } + + if( !$_csim ) { + $this->StrokePlotBox(); + } + + // The titles and legends never gets rotated so make sure + // that the angle is 0 before stroking them + $aa = $this->img->SetAngle(0); + $this->StrokeTitles(); + $this->footer->Stroke($this->img); + $this->legend->Stroke($this->img); + $this->img->SetAngle($aa); + $this->StrokeTexts(); + $this->StrokeTables(); + + if( !$_csim ) { + + $this->img->SetAngle($aa); + + // Draw an outline around the image map + if(_JPG_DEBUG) { + $this->DisplayClientSideaImageMapAreas(); + } + + // Should we do any final image transformation + if( $this->iImgTrans ) { + if( !class_exists('ImgTrans',false) ) { + require_once('jpgraph_imgtrans.php'); + //JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.'); + } + + $tform = new ImgTrans($this->img->img); + $this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, + $this->iImgTransDirection,$this->iImgTransHighQ, + $this->iImgTransMinSize,$this->iImgTransFillColor, + $this->iImgTransBorder); + } + + // If the filename is given as the special "__handle" + // then the image handler is returned and the image is NOT + // streamed back + if( $aStrokeFileName == _IMG_HANDLER ) { + return $this->img->img; + } + else { + // Finally stream the generated picture + $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName); + } + } + } + + function SetAxisLabelBackground($aType,$aXFColor='lightgray',$aXColor='black',$aYFColor='lightgray',$aYColor='black') { + $this->iAxisLblBgType = $aType; + $this->iXAxisLblBgFillColor = $aXFColor; + $this->iXAxisLblBgColor = $aXColor; + $this->iYAxisLblBgFillColor = $aYFColor; + $this->iYAxisLblBgColor = $aYColor; + } + + function StrokeAxisLabelBackground() { + // Types + // 0 = No background + // 1 = Only X-labels, length of axis + // 2 = Only Y-labels, length of axis + // 3 = As 1 but extends to width of graph + // 4 = As 2 but extends to height of graph + // 5 = Combination of 3 & 4 + // 6 = Combination of 1 & 2 + + $t = $this->iAxisLblBgType ; + if( $t < 1 ) return; + + // Stroke optional X-axis label background color + if( $t == 1 || $t == 3 || $t == 5 || $t == 6 ) { + $this->img->PushColor($this->iXAxisLblBgFillColor); + if( $t == 1 || $t == 6 ) { + $xl = $this->img->left_margin; + $yu = $this->img->height - $this->img->bottom_margin + 1; + $xr = $this->img->width - $this->img->right_margin ; + $yl = $this->img->height-1-$this->frame_weight; + } + else { // t==3 || t==5 + $xl = $this->frame_weight; + $yu = $this->img->height - $this->img->bottom_margin + 1; + $xr = $this->img->width - 1 - $this->frame_weight; + $yl = $this->img->height-1-$this->frame_weight; + } + + $this->img->FilledRectangle($xl,$yu,$xr,$yl); + $this->img->PopColor(); + + // Check if we should add the vertical lines at left and right edge + if( $this->iXAxisLblBgColor !== '' ) { + // Hardcode to one pixel wide + $this->img->SetLineWeight(1); + $this->img->PushColor($this->iXAxisLblBgColor); + if( $t == 1 || $t == 6 ) { + $this->img->Line($xl,$yu,$xl,$yl); + $this->img->Line($xr,$yu,$xr,$yl); + } + else { + $xl = $this->img->width - $this->img->right_margin ; + $this->img->Line($xl,$yu-1,$xr,$yu-1); + } + $this->img->PopColor(); + } + } + + if( $t == 2 || $t == 4 || $t == 5 || $t == 6 ) { + $this->img->PushColor($this->iYAxisLblBgFillColor); + if( $t == 2 || $t == 6 ) { + $xl = $this->frame_weight; + $yu = $this->frame_weight+$this->img->top_margin; + $xr = $this->img->left_margin - 1; + $yl = $this->img->height - $this->img->bottom_margin + 1; + } + else { + $xl = $this->frame_weight; + $yu = $this->frame_weight; + $xr = $this->img->left_margin - 1; + $yl = $this->img->height-1-$this->frame_weight; + } + + $this->img->FilledRectangle($xl,$yu,$xr,$yl); + $this->img->PopColor(); + + // Check if we should add the vertical lines at left and right edge + if( $this->iXAxisLblBgColor !== '' ) { + $this->img->PushColor($this->iXAxisLblBgColor); + if( $t == 2 || $t == 6 ) { + $this->img->Line($xl,$yu-1,$xr,$yu-1); + $this->img->Line($xl,$yl-1,$xr,$yl-1); + } + else { + $this->img->Line($xr+1,$yu,$xr+1,$this->img->top_margin); + } + $this->img->PopColor(); + } + + } + } + + function StrokeAxis($aStrokeLabels=true) { + + if( $aStrokeLabels ) { + $this->StrokeAxisLabelBackground(); + } + + // Stroke axis + if( $this->iAxisStyle != AXSTYLE_SIMPLE ) { + switch( $this->iAxisStyle ) { + case AXSTYLE_BOXIN : + $toppos = SIDE_DOWN; + $bottompos = SIDE_UP; + $leftpos = SIDE_RIGHT; + $rightpos = SIDE_LEFT; + break; + case AXSTYLE_BOXOUT : + $toppos = SIDE_UP; + $bottompos = SIDE_DOWN; + $leftpos = SIDE_LEFT; + $rightpos = SIDE_RIGHT; + break; + case AXSTYLE_YBOXIN: + $toppos = FALSE; + $bottompos = SIDE_UP; + $leftpos = SIDE_RIGHT; + $rightpos = SIDE_LEFT; + break; + case AXSTYLE_YBOXOUT: + $toppos = FALSE; + $bottompos = SIDE_DOWN; + $leftpos = SIDE_LEFT; + $rightpos = SIDE_RIGHT; + break; + default: + JpGRaphError::RaiseL(25036,$this->iAxisStyle); //('Unknown AxisStyle() : '.$this->iAxisStyle); + break; + } + + // By default we hide the first label so it doesn't cross the + // Y-axis in case the positon hasn't been set by the user. + // However, if we use a box we always want the first value + // displayed so we make sure it will be displayed. + $this->xscale->ticks->SupressFirst(false); + + // Now draw the bottom X-axis + $this->xaxis->SetPos('min'); + $this->xaxis->SetLabelSide(SIDE_DOWN); + $this->xaxis->scale->ticks->SetSide($bottompos); + $this->xaxis->Stroke($this->yscale,$aStrokeLabels); + + if( $toppos !== FALSE ) { + // We also want a top X-axis + $this->xaxis = $this->xaxis; + $this->xaxis->SetPos('max'); + $this->xaxis->SetLabelSide(SIDE_UP); + // No title for the top X-axis + if( $aStrokeLabels ) { + $this->xaxis->title->Set(''); + } + $this->xaxis->scale->ticks->SetSide($toppos); + $this->xaxis->Stroke($this->yscale,$aStrokeLabels); + } + + // Stroke the left Y-axis + $this->yaxis->SetPos('min'); + $this->yaxis->SetLabelSide(SIDE_LEFT); + $this->yaxis->scale->ticks->SetSide($leftpos); + $this->yaxis->Stroke($this->xscale,$aStrokeLabels); + + // Stroke the right Y-axis + $this->yaxis->SetPos('max'); + // No title for the right side + if( $aStrokeLabels ) { + $this->yaxis->title->Set(''); + } + $this->yaxis->SetLabelSide(SIDE_RIGHT); + $this->yaxis->scale->ticks->SetSide($rightpos); + $this->yaxis->Stroke($this->xscale,$aStrokeLabels); + } + else { + $this->xaxis->Stroke($this->yscale,$aStrokeLabels); + $this->yaxis->Stroke($this->xscale,$aStrokeLabels); + } + } + + + // Private helper function for backgound image + static function LoadBkgImage($aImgFormat='',$aFile='',$aImgStr='') { + if( $aImgStr != '' ) { + return Image::CreateFromString($aImgStr); + } + + // Remove case sensitivity and setup appropriate function to create image + // Get file extension. This should be the LAST '.' separated part of the filename + $e = explode('.',$aFile); + $ext = strtolower($e[count($e)-1]); + if ($ext == "jpeg") { + $ext = "jpg"; + } + + if( trim($ext) == '' ) { + $ext = 'png'; // Assume PNG if no extension specified + } + + if( $aImgFormat == '' ) { + $imgtag = $ext; + } + else { + $imgtag = $aImgFormat; + } + + $supported = imagetypes(); + if( ( $ext == 'jpg' && !($supported & IMG_JPG) ) || + ( $ext == 'gif' && !($supported & IMG_GIF) ) || + ( $ext == 'png' && !($supported & IMG_PNG) ) || + ( $ext == 'bmp' && !($supported & IMG_WBMP) ) || + ( $ext == 'xpm' && !($supported & IMG_XPM) ) ) { + + JpGraphError::RaiseL(25037,$aFile);//('The image format of your background image ('.$aFile.') is not supported in your system configuration. '); + } + + + if( $imgtag == "jpg" || $imgtag == "jpeg") { + $f = "imagecreatefromjpeg"; + $imgtag = "jpg"; + } + else { + $f = "imagecreatefrom".$imgtag; + } + + // Compare specified image type and file extension + if( $imgtag != $ext ) { + //$t = "Background image seems to be of different type (has different file extension) than specified imagetype. Specified: '".$aImgFormat."'File: '".$aFile."'"; + JpGraphError::RaiseL(25038, $aImgFormat, $aFile); + } + + $img = @$f($aFile); + if( !$img ) { + JpGraphError::RaiseL(25039,$aFile);//(" Can't read background image: '".$aFile."'"); + } + return $img; + } + + function StrokePlotGrad() { + if( $this->plot_gradtype < 0 ) + return; + + $grad = new Gradient($this->img); + $xl = $this->img->left_margin; + $yt = $this->img->top_margin; + $xr = $xl + $this->img->plotwidth+1 ; + $yb = $yt + $this->img->plotheight ; + $grad->FilledRectangle($xl,$yt,$xr,$yb,$this->plot_gradfrom,$this->plot_gradto,$this->plot_gradtype); + + } + + function StrokeBackgroundGrad() { + if( $this->bkg_gradtype < 0 ) + return; + + $grad = new Gradient($this->img); + if( $this->bkg_gradstyle == BGRAD_PLOT ) { + $xl = $this->img->left_margin; + $yt = $this->img->top_margin; + $xr = $xl + $this->img->plotwidth+1 ; + $yb = $yt + $this->img->plotheight ; + $grad->FilledRectangle($xl,$yt,$xr,$yb,$this->bkg_gradfrom,$this->bkg_gradto,$this->bkg_gradtype); + } + else { + $xl = 0; + $yt = 0; + $xr = $xl + $this->img->width - 1; + $yb = $yt + $this->img->height - 1 ; + if( $this->doshadow ) { + $xr -= $this->shadow_width; + $yb -= $this->shadow_width; + } + if( $this->doframe ) { + $yt += $this->frame_weight; + $yb -= $this->frame_weight; + $xl += $this->frame_weight; + $xr -= $this->frame_weight; + } + $aa = $this->img->SetAngle(0); + $grad->FilledRectangle($xl,$yt,$xr,$yb,$this->bkg_gradfrom,$this->bkg_gradto,$this->bkg_gradtype); + $aa = $this->img->SetAngle($aa); + } + } + + function StrokeFrameBackground() { + if( $this->background_image != '' && $this->background_cflag != '' ) { + JpGraphError::RaiseL(25040);//('It is not possible to specify both a background image and a background country flag.'); + } + if( $this->background_image != '' ) { + $bkgimg = $this->LoadBkgImage($this->background_image_format,$this->background_image); + } + elseif( $this->background_cflag != '' ) { + if( ! class_exists('FlagImages',false) ) { + JpGraphError::RaiseL(25041);//('In order to use Country flags as backgrounds you must include the "jpgraph_flags.php" file.'); + } + $fobj = new FlagImages(FLAGSIZE4); + $dummy=''; + $bkgimg = $fobj->GetImgByName($this->background_cflag,$dummy); + $this->background_image_mix = $this->background_cflag_mix; + $this->background_image_type = $this->background_cflag_type; + } + else { + return ; + } + + $bw = ImageSX($bkgimg); + $bh = ImageSY($bkgimg); + + // No matter what the angle is we always stroke the image and frame + // assuming it is 0 degree + $aa = $this->img->SetAngle(0); + + switch( $this->background_image_type ) { + case BGIMG_FILLPLOT: // Resize to just fill the plotarea + $this->FillMarginArea(); + $this->StrokeFrame(); + // Special case to hande 90 degree rotated graph corectly + if( $aa == 90 ) { + $this->img->SetAngle(90); + $this->FillPlotArea(); + $aa = $this->img->SetAngle(0); + $adj = ($this->img->height - $this->img->width)/2; + $this->img->CopyMerge($bkgimg, + $this->img->bottom_margin-$adj,$this->img->left_margin+$adj, + 0,0, + $this->img->plotheight+1,$this->img->plotwidth, + $bw,$bh,$this->background_image_mix); + } + else { + $this->FillPlotArea(); + $this->img->CopyMerge($bkgimg, + $this->img->left_margin,$this->img->top_margin+1, + 0,0,$this->img->plotwidth+1,$this->img->plotheight, + $bw,$bh,$this->background_image_mix); + } + break; + case BGIMG_FILLFRAME: // Fill the whole area from upper left corner, resize to just fit + $hadj=0; $vadj=0; + if( $this->doshadow ) { + $hadj = $this->shadow_width; + $vadj = $this->shadow_width; + } + $this->FillMarginArea(); + $this->FillPlotArea(); + $this->img->CopyMerge($bkgimg,0,0,0,0,$this->img->width-$hadj,$this->img->height-$vadj, + $bw,$bh,$this->background_image_mix); + $this->StrokeFrame(); + break; + case BGIMG_COPY: // Just copy the image from left corner, no resizing + $this->FillMarginArea(); + $this->FillPlotArea(); + $this->img->CopyMerge($bkgimg,0,0,0,0,$bw,$bh, + $bw,$bh,$this->background_image_mix); + $this->StrokeFrame(); + break; + case BGIMG_CENTER: // Center original image in the plot area + $this->FillMarginArea(); + $this->FillPlotArea(); + $centerx = round($this->img->plotwidth/2+$this->img->left_margin-$bw/2); + $centery = round($this->img->plotheight/2+$this->img->top_margin-$bh/2); + $this->img->CopyMerge($bkgimg,$centerx,$centery,0,0,$bw,$bh, + $bw,$bh,$this->background_image_mix); + $this->StrokeFrame(); + break; + case BGIMG_FREE: // Just copy the image to the specified location + $this->img->CopyMerge($bkgimg, + $this->background_image_xpos,$this->background_image_ypos, + 0,0,$bw,$bh,$bw,$bh,$this->background_image_mix); + $this->StrokeFrame(); // New + break; + default: + JpGraphError::RaiseL(25042);//(" Unknown background image layout"); + } + $this->img->SetAngle($aa); + } + + // Private + // Draw a frame around the image + function StrokeFrame() { + if( !$this->doframe ) return; + + if( $this->background_image_type <= 1 && ($this->bkg_gradtype < 0 || ($this->bkg_gradtype > 0 && $this->bkg_gradstyle==BGRAD_PLOT)) ) { + $c = $this->margin_color; + } + else { + $c = false; + } + + if( $this->doshadow ) { + $this->img->SetColor($this->frame_color); + $this->img->ShadowRectangle(0,0,$this->img->width,$this->img->height, + $c,$this->shadow_width,$this->shadow_color); + } + elseif( $this->framebevel ) { + if( $c ) { + $this->img->SetColor($this->margin_color); + $this->img->FilledRectangle(0,0,$this->img->width-1,$this->img->height-1); + } + $this->img->Bevel(1,1,$this->img->width-2,$this->img->height-2, + $this->framebeveldepth, + $this->framebevelcolor1,$this->framebevelcolor2); + if( $this->framebevelborder ) { + $this->img->SetColor($this->framebevelbordercolor); + $this->img->Rectangle(0,0,$this->img->width-1,$this->img->height-1); + } + } + else { + $this->img->SetLineWeight($this->frame_weight); + if( $c ) { + $this->img->SetColor($this->margin_color); + $this->img->FilledRectangle(0,0,$this->img->width-1,$this->img->height-1); + } + $this->img->SetColor($this->frame_color); + $this->img->Rectangle(0,0,$this->img->width-1,$this->img->height-1); + } + } + + function FillMarginArea() { + $hadj=0; $vadj=0; + if( $this->doshadow ) { + $hadj = $this->shadow_width; + $vadj = $this->shadow_width; + } + + $this->img->SetColor($this->margin_color); + $this->img->FilledRectangle(0,0,$this->img->width-1-$hadj,$this->img->height-1-$vadj); + + $this->img->FilledRectangle(0,0,$this->img->width-1-$hadj,$this->img->top_margin); + $this->img->FilledRectangle(0,$this->img->top_margin,$this->img->left_margin,$this->img->height-1-$hadj); + $this->img->FilledRectangle($this->img->left_margin+1, + $this->img->height-$this->img->bottom_margin, + $this->img->width-1-$hadj, + $this->img->height-1-$hadj); + $this->img->FilledRectangle($this->img->width-$this->img->right_margin, + $this->img->top_margin+1, + $this->img->width-1-$hadj, + $this->img->height-$this->img->bottom_margin-1); + } + + function FillPlotArea() { + $this->img->PushColor($this->plotarea_color); + $this->img->FilledRectangle($this->img->left_margin, + $this->img->top_margin, + $this->img->width-$this->img->right_margin, + $this->img->height-$this->img->bottom_margin); + $this->img->PopColor(); + } + + // Stroke the plot area with either a solid color or a background image + function StrokePlotArea() { + // Note: To be consistent we really should take a possible shadow + // into account. However, that causes some problem for the LinearScale class + // since in the current design it does not have any links to class Graph which + // means it has no way of compensating for the adjusted plotarea in case of a + // shadow. So, until I redesign LinearScale we can't compensate for this. + // So just set the two adjustment parameters to zero for now. + $boxadj = 0; //$this->doframe ? $this->frame_weight : 0 ; + $adj = 0; //$this->doshadow ? $this->shadow_width : 0 ; + + if( $this->background_image != '' || $this->background_cflag != '' ) { + $this->StrokeFrameBackground(); + } + else { + $aa = $this->img->SetAngle(0); + $this->StrokeFrame(); + $aa = $this->img->SetAngle($aa); + $this->StrokeBackgroundGrad(); + if( $this->bkg_gradtype < 0 || ($this->bkg_gradtype > 0 && $this->bkg_gradstyle==BGRAD_MARGIN) ) { + $this->FillPlotArea(); + } + $this->StrokePlotGrad(); + } + } + + function StrokeIcons() { + $n = count($this->iIcons); + for( $i=0; $i < $n; ++$i ) { + $this->iIcons[$i]->StrokeWithScale($this->img,$this->xscale,$this->yscale); + } + } + + function StrokePlotBox() { + // Should we draw a box around the plot area? + if( $this->boxed ) { + $this->img->SetLineWeight(1); + $this->img->SetLineStyle('solid'); + $this->img->SetColor($this->box_color); + for($i=0; $i < $this->box_weight; ++$i ) { + $this->img->Rectangle( + $this->img->left_margin-$i,$this->img->top_margin-$i, + $this->img->width-$this->img->right_margin+$i, + $this->img->height-$this->img->bottom_margin+$i); + } + } + } + + function SetTitleBackgroundFillStyle($aStyle,$aColor1='black',$aColor2='white') { + $this->titlebkg_fillstyle = $aStyle; + $this->titlebkg_scolor1 = $aColor1; + $this->titlebkg_scolor2 = $aColor2; + } + + function SetTitleBackground($aBackColor='gray', $aStyle=TITLEBKG_STYLE1, $aFrameStyle=TITLEBKG_FRAME_NONE, $aFrameColor='black', $aFrameWeight=1, $aBevelHeight=3, $aEnable=true) { + $this->titlebackground = $aEnable; + $this->titlebackground_color = $aBackColor; + $this->titlebackground_style = $aStyle; + $this->titlebackground_framecolor = $aFrameColor; + $this->titlebackground_framestyle = $aFrameStyle; + $this->titlebackground_frameweight = $aFrameWeight; + $this->titlebackground_bevelheight = $aBevelHeight ; + } + + + function StrokeTitles() { + + $margin=3; + + if( $this->titlebackground ) { + // Find out height + $this->title->margin += 2 ; + $h = $this->title->GetTextHeight($this->img)+$this->title->margin+$margin; + if( $this->subtitle->t != '' && !$this->subtitle->hide ) { + $h += $this->subtitle->GetTextHeight($this->img)+$margin+ + $this->subtitle->margin; + $h += 2; + } + if( $this->subsubtitle->t != '' && !$this->subsubtitle->hide ) { + $h += $this->subsubtitle->GetTextHeight($this->img)+$margin+ + $this->subsubtitle->margin; + $h += 2; + } + $this->img->PushColor($this->titlebackground_color); + if( $this->titlebackground_style === TITLEBKG_STYLE1 ) { + // Inside the frame + if( $this->framebevel ) { + $x1 = $y1 = $this->framebeveldepth + 1 ; + $x2 = $this->img->width - $this->framebeveldepth - 2 ; + $this->title->margin += $this->framebeveldepth + 1 ; + $h += $y1 ; + $h += 2; + } + else { + $x1 = $y1 = $this->frame_weight; + $x2 = $this->img->width - $this->frame_weight-1; + } + } + elseif( $this->titlebackground_style === TITLEBKG_STYLE2 ) { + // Cover the frame as well + $x1 = $y1 = 0; + $x2 = $this->img->width - 1 ; + } + elseif( $this->titlebackground_style === TITLEBKG_STYLE3 ) { + // Cover the frame as well (the difference is that + // for style==3 a bevel frame border is on top + // of the title background) + $x1 = $y1 = 0; + $x2 = $this->img->width - 1 ; + $h += $this->framebeveldepth ; + $this->title->margin += $this->framebeveldepth ; + } + else { + JpGraphError::RaiseL(25043);//('Unknown title background style.'); + } + + if( $this->titlebackground_framestyle === 3 ) { + $h += $this->titlebackground_bevelheight*2 + 1 ; + $this->title->margin += $this->titlebackground_bevelheight ; + } + + if( $this->doshadow ) { + $x2 -= $this->shadow_width ; + } + + $indent=0; + if( $this->titlebackground_framestyle == TITLEBKG_FRAME_BEVEL ) { + $indent = $this->titlebackground_bevelheight; + } + + if( $this->titlebkg_fillstyle==TITLEBKG_FILLSTYLE_HSTRIPED ) { + $this->img->FilledRectangle2($x1+$indent,$y1+$indent,$x2-$indent,$h-$indent, + $this->titlebkg_scolor1, + $this->titlebkg_scolor2); + } + elseif( $this->titlebkg_fillstyle==TITLEBKG_FILLSTYLE_VSTRIPED ) { + $this->img->FilledRectangle2($x1+$indent,$y1+$indent,$x2-$indent,$h-$indent, + $this->titlebkg_scolor1, + $this->titlebkg_scolor2,2); + } + else { + // Solid fill + $this->img->FilledRectangle($x1,$y1,$x2,$h); + } + $this->img->PopColor(); + + $this->img->PushColor($this->titlebackground_framecolor); + $this->img->SetLineWeight($this->titlebackground_frameweight); + if( $this->titlebackground_framestyle == TITLEBKG_FRAME_FULL ) { + // Frame background + $this->img->Rectangle($x1,$y1,$x2,$h); + } + elseif( $this->titlebackground_framestyle == TITLEBKG_FRAME_BOTTOM ) { + // Bottom line only + $this->img->Line($x1,$h,$x2,$h); + } + elseif( $this->titlebackground_framestyle == TITLEBKG_FRAME_BEVEL ) { + $this->img->Bevel($x1,$y1,$x2,$h,$this->titlebackground_bevelheight); + } + $this->img->PopColor(); + + // This is clumsy. But we neeed to stroke the whole graph frame if it is + // set to bevel to get the bevel shading on top of the text background + if( $this->framebevel && $this->doframe && $this->titlebackground_style === 3 ) { + $this->img->Bevel(1,1,$this->img->width-2,$this->img->height-2, + $this->framebeveldepth, + $this->framebevelcolor1,$this->framebevelcolor2); + if( $this->framebevelborder ) { + $this->img->SetColor($this->framebevelbordercolor); + $this->img->Rectangle(0,0,$this->img->width-1,$this->img->height-1); + } + } + } + + // Stroke title + $y = $this->title->margin; + if( $this->title->halign == 'center' ) { + $this->title->Center(0,$this->img->width,$y); + } + elseif( $this->title->halign == 'left' ) { + $this->title->SetPos($this->title->margin+2,$y); + } + elseif( $this->title->halign == 'right' ) { + $indent = 0; + if( $this->doshadow ) { + $indent = $this->shadow_width+2; + } + $this->title->SetPos($this->img->width-$this->title->margin-$indent,$y,'right'); + } + $this->title->Stroke($this->img); + + // ... and subtitle + $y += $this->title->GetTextHeight($this->img) + $margin + $this->subtitle->margin; + if( $this->subtitle->halign == 'center' ) { + $this->subtitle->Center(0,$this->img->width,$y); + } + elseif( $this->subtitle->halign == 'left' ) { + $this->subtitle->SetPos($this->subtitle->margin+2,$y); + } + elseif( $this->subtitle->halign == 'right' ) { + $indent = 0; + if( $this->doshadow ) + $indent = $this->shadow_width+2; + $this->subtitle->SetPos($this->img->width-$this->subtitle->margin-$indent,$y,'right'); + } + $this->subtitle->Stroke($this->img); + + // ... and subsubtitle + $y += $this->subtitle->GetTextHeight($this->img) + $margin + $this->subsubtitle->margin; + if( $this->subsubtitle->halign == 'center' ) { + $this->subsubtitle->Center(0,$this->img->width,$y); + } + elseif( $this->subsubtitle->halign == 'left' ) { + $this->subsubtitle->SetPos($this->subsubtitle->margin+2,$y); + } + elseif( $this->subsubtitle->halign == 'right' ) { + $indent = 0; + if( $this->doshadow ) + $indent = $this->shadow_width+2; + $this->subsubtitle->SetPos($this->img->width-$this->subsubtitle->margin-$indent,$y,'right'); + } + $this->subsubtitle->Stroke($this->img); + + // ... and fancy title + $this->tabtitle->Stroke($this->img); + + } + + function StrokeTexts() { + // Stroke any user added text objects + if( $this->texts != null ) { + for($i=0; $i < count($this->texts); ++$i) { + $this->texts[$i]->StrokeWithScale($this->img,$this->xscale,$this->yscale); + } + } + + if( $this->y2texts != null && $this->y2scale != null ) { + for($i=0; $i < count($this->y2texts); ++$i) { + $this->y2texts[$i]->StrokeWithScale($this->img,$this->xscale,$this->y2scale); + } + } + + } + + function StrokeTables() { + if( $this->iTables != null ) { + $n = count($this->iTables); + for( $i=0; $i < $n; ++$i ) { + $this->iTables[$i]->StrokeWithScale($this->img,$this->xscale,$this->yscale); + } + } + } + + function DisplayClientSideaImageMapAreas() { + // Debug stuff - display the outline of the image map areas + $csim=''; + foreach ($this->plots as $p) { + $csim.= $p->GetCSIMareas(); + } + $csim .= $this->legend->GetCSIMareas(); + if (preg_match_all("/area shape=\"(\w+)\" coords=\"([0-9\, ]+)\"/", $csim, $coords)) { + $this->img->SetColor($this->csimcolor); + $n = count($coords[0]); + for ($i=0; $i < $n; $i++) { + if ( $coords[1][$i] == 'poly' ) { + preg_match_all('/\s*([0-9]+)\s*,\s*([0-9]+)\s*,*/',$coords[2][$i],$pts); + $this->img->SetStartPoint($pts[1][count($pts[0])-1],$pts[2][count($pts[0])-1]); + $m = count($pts[0]); + for ($j=0; $j < $m; $j++) { + $this->img->LineTo($pts[1][$j],$pts[2][$j]); + } + } elseif ( $coords[1][$i] == 'rect' ) { + $pts = preg_split('/,/', $coords[2][$i]); + $this->img->SetStartPoint($pts[0],$pts[1]); + $this->img->LineTo($pts[2],$pts[1]); + $this->img->LineTo($pts[2],$pts[3]); + $this->img->LineTo($pts[0],$pts[3]); + $this->img->LineTo($pts[0],$pts[1]); + } + } + } + } + + // Text scale offset in world coordinates + function SetTextScaleOff($aOff) { + $this->text_scale_off = $aOff; + $this->xscale->text_scale_off = $aOff; + } + + // Text width of bar to be centered in absolute pixels + function SetTextScaleAbsCenterOff($aOff) { + $this->text_scale_abscenteroff = $aOff; + } + + // Get Y min and max values for added lines + function GetLinesYMinMax( $aLines ) { + $n = count($aLines); + if( $n == 0 ) return false; + $min = $aLines[0]->scaleposition ; + $max = $min ; + $flg = false; + for( $i=0; $i < $n; ++$i ) { + if( $aLines[$i]->direction == HORIZONTAL ) { + $flg = true ; + $v = $aLines[$i]->scaleposition ; + if( $min > $v ) $min = $v ; + if( $max < $v ) $max = $v ; + } + } + return $flg ? array($min,$max) : false ; + } + + // Get X min and max values for added lines + function GetLinesXMinMax( $aLines ) { + $n = count($aLines); + if( $n == 0 ) return false ; + $min = $aLines[0]->scaleposition ; + $max = $min ; + $flg = false; + for( $i=0; $i < $n; ++$i ) { + if( $aLines[$i]->direction == VERTICAL ) { + $flg = true ; + $v = $aLines[$i]->scaleposition ; + if( $min > $v ) $min = $v ; + if( $max < $v ) $max = $v ; + } + } + return $flg ? array($min,$max) : false ; + } + + // Get min and max values for all included plots + function GetPlotsYMinMax($aPlots) { + $n = count($aPlots); + $i=0; + do { + list($xmax,$max) = $aPlots[$i]->Max(); + } while( ++$i < $n && !is_numeric($max) ); + + $i=0; + do { + list($xmin,$min) = $aPlots[$i]->Min(); + } while( ++$i < $n && !is_numeric($min) ); + + if( !is_numeric($min) || !is_numeric($max) ) { + JpGraphError::RaiseL(25044);//('Cannot use autoscaling since it is impossible to determine a valid min/max value of the Y-axis (only null values).'); + } + + for($i=0; $i < $n; ++$i ) { + list($xmax,$ymax)=$aPlots[$i]->Max(); + list($xmin,$ymin)=$aPlots[$i]->Min(); + if (is_numeric($ymax)) $max=max($max,$ymax); + if (is_numeric($ymin)) $min=min($min,$ymin); + } + if( $min == '' ) $min = 0; + if( $max == '' ) $max = 0; + if( $min == 0 && $max == 0 ) { + // Special case if all values are 0 + $min=0;$max=1; + } + return array($min,$max); + } + + function hasLinePlotAndBarPlot() { + $has_line = false; + $has_bar = false; + + foreach ($this->plots as $plot) { + if ($plot instanceof LinePlot) { + $has_line = true; + } + if ($plot instanceof BarPlot) { + $has_bar = true; + } + } + + if ($has_line && $has_bar) { + return true; + } + + return false; + } + + function SetTheme($graph_theme) { + + if (!($this instanceof PieGraph)) { + if (!$this->isAfterSetScale) { + JpGraphError::RaiseL(25133);//('Use Graph::SetTheme() after Graph::SetScale().'); + } + } + + if ($this->graph_theme) { + $this->ClearTheme(); + } + $this->graph_theme = $graph_theme; + $this->graph_theme->ApplyGraph($this); + } + + function ClearTheme() { + $this->graph_theme = null; + + $this->isRunningClear = true; + + $this->__construct( + $this->inputValues['aWidth'], + $this->inputValues['aHeight'], + $this->inputValues['aCachedName'], + $this->inputValues['aTimeout'], + $this->inputValues['aInline'] + ); + + if (!($this instanceof PieGraph)) { + if ($this->isAfterSetScale) { + $this->SetScale( + $this->inputValues['aAxisType'], + $this->inputValues['aYMin'], + $this->inputValues['aYMax'], + $this->inputValues['aXMin'], + $this->inputValues['aXMax'] + ); + } + } + + $this->isRunningClear = false; + } + + function SetSupersampling($do = false, $scale = 2) { + if ($do) { + define('SUPERSAMPLING_SCALE', $scale); + // $this->img->scale = $scale; + } else { + define('SUPERSAMPLING_SCALE', 1); + //$this->img->scale = 0; + } + } + +} // Class + +//=================================================== +// CLASS LineProperty +// Description: Holds properties for a line +//=================================================== +class LineProperty { + public $iWeight=1, $iColor='black', $iStyle='solid', $iShow=false; + + function __construct($aWeight=1,$aColor='black',$aStyle='solid') { + $this->iWeight = $aWeight; + $this->iColor = $aColor; + $this->iStyle = $aStyle; + } + + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function SetWeight($aWeight) { + $this->iWeight = $aWeight; + } + + function SetStyle($aStyle) { + $this->iStyle = $aStyle; + } + + function Show($aShow=true) { + $this->iShow=$aShow; + } + + function Stroke($aImg,$aX1,$aY1,$aX2,$aY2) { + if( $this->iShow ) { + $aImg->PushColor($this->iColor); + $oldls = $aImg->line_style; + $oldlw = $aImg->line_weight; + $aImg->SetLineWeight($this->iWeight); + $aImg->SetLineStyle($this->iStyle); + $aImg->StyleLine($aX1,$aY1,$aX2,$aY2); + $aImg->PopColor($this->iColor); + $aImg->line_style = $oldls; + $aImg->line_weight = $oldlw; + + } + } +} + +//=================================================== +// CLASS GraphTabTitle +// Description: Draw "tab" titles on top of graphs +//=================================================== +class GraphTabTitle extends Text{ + private $corner = 6 , $posx = 7, $posy = 4; + private $fillcolor='lightyellow',$bordercolor='black'; + private $align = 'left', $width=TABTITLE_WIDTHFIT; + function __construct() { + $this->t = ''; + $this->font_style = FS_BOLD; + $this->hide = true; + $this->color = 'darkred'; + } + + function SetColor($aTxtColor,$aFillColor='lightyellow',$aBorderColor='black') { + $this->color = $aTxtColor; + $this->fillcolor = $aFillColor; + $this->bordercolor = $aBorderColor; + } + + function SetFillColor($aFillColor) { + $this->fillcolor = $aFillColor; + } + + function SetTabAlign($aAlign) { + $this->align = $aAlign; + } + + function SetWidth($aWidth) { + $this->width = $aWidth ; + } + + function Set($t) { + $this->t = $t; + $this->hide = false; + } + + function SetCorner($aD) { + $this->corner = $aD ; + } + + function Stroke($aImg,$aDummy1=null,$aDummy2=null) { + if( $this->hide ) + return; + $this->boxed = false; + $w = $this->GetWidth($aImg) + 2*$this->posx; + $h = $this->GetTextHeight($aImg) + 2*$this->posy; + + $x = $aImg->left_margin; + $y = $aImg->top_margin; + + if( $this->width === TABTITLE_WIDTHFIT ) { + if( $this->align == 'left' ) { + $p = array($x, $y, + $x, $y-$h+$this->corner, + $x + $this->corner,$y-$h, + $x + $w - $this->corner, $y-$h, + $x + $w, $y-$h+$this->corner, + $x + $w, $y); + } + elseif( $this->align == 'center' ) { + $x += round($aImg->plotwidth/2) - round($w/2); + $p = array($x, $y, + $x, $y-$h+$this->corner, + $x + $this->corner, $y-$h, + $x + $w - $this->corner, $y-$h, + $x + $w, $y-$h+$this->corner, + $x + $w, $y); + } + else { + $x += $aImg->plotwidth -$w; + $p = array($x, $y, + $x, $y-$h+$this->corner, + $x + $this->corner,$y-$h, + $x + $w - $this->corner, $y-$h, + $x + $w, $y-$h+$this->corner, + $x + $w, $y); + } + } + else { + if( $this->width === TABTITLE_WIDTHFULL ) { + $w = $aImg->plotwidth ; + } + else { + $w = $this->width ; + } + + // Make the tab fit the width of the plot area + $p = array($x, $y, + $x, $y-$h+$this->corner, + $x + $this->corner,$y-$h, + $x + $w - $this->corner, $y-$h, + $x + $w, $y-$h+$this->corner, + $x + $w, $y); + + } + if( $this->halign == 'left' ) { + $aImg->SetTextAlign('left','bottom'); + $x += $this->posx; + $y -= $this->posy; + } + elseif( $this->halign == 'center' ) { + $aImg->SetTextAlign('center','bottom'); + $x += $w/2; + $y -= $this->posy; + } + else { + $aImg->SetTextAlign('right','bottom'); + $x += $w - $this->posx; + $y -= $this->posy; + } + + $aImg->SetColor($this->fillcolor); + $aImg->FilledPolygon($p); + + $aImg->SetColor($this->bordercolor); + $aImg->Polygon($p,true); + + $aImg->SetColor($this->color); + $aImg->SetFont($this->font_family,$this->font_style,$this->font_size); + $aImg->StrokeText($x,$y,$this->t,0,'center'); + } + +} + +//=================================================== +// CLASS SuperScriptText +// Description: Format a superscript text +//=================================================== +class SuperScriptText extends Text { + private $iSuper=''; + private $sfont_family='',$sfont_style='',$sfont_size=8; + private $iSuperMargin=2,$iVertOverlap=4,$iSuperScale=0.65; + private $iSDir=0; + private $iSimple=false; + + function __construct($aTxt='',$aSuper='',$aXAbsPos=0,$aYAbsPos=0) { + parent::__construct($aTxt,$aXAbsPos,$aYAbsPos); + $this->iSuper = $aSuper; + } + + function FromReal($aVal,$aPrecision=2) { + // Convert a floating point number to scientific notation + $neg=1.0; + if( $aVal < 0 ) { + $neg = -1.0; + $aVal = -$aVal; + } + + $l = floor(log10($aVal)); + $a = sprintf("%0.".$aPrecision."f",round($aVal / pow(10,$l),$aPrecision)); + $a *= $neg; + if( $this->iSimple && ($a == 1 || $a==-1) ) $a = ''; + + if( $a != '' ) { + $this->t = $a.' * 10'; + } + else { + if( $neg == 1 ) { + $this->t = '10'; + } + else { + $this->t = '-10'; + } + } + $this->iSuper = $l; + } + + function Set($aTxt,$aSuper='') { + $this->t = $aTxt; + $this->iSuper = $aSuper; + } + + function SetSuperFont($aFontFam,$aFontStyle=FS_NORMAL,$aFontSize=8) { + $this->sfont_family = $aFontFam; + $this->sfont_style = $aFontStyle; + $this->sfont_size = $aFontSize; + } + + // Total width of text + function GetWidth($aImg) { + $aImg->SetFont($this->font_family,$this->font_style,$this->font_size); + $w = $aImg->GetTextWidth($this->t); + $aImg->SetFont($this->sfont_family,$this->sfont_style,$this->sfont_size); + $w += $aImg->GetTextWidth($this->iSuper); + $w += $this->iSuperMargin; + return $w; + } + + // Hight of font (approximate the height of the text) + function GetFontHeight($aImg) { + $aImg->SetFont($this->font_family,$this->font_style,$this->font_size); + $h = $aImg->GetFontHeight(); + $aImg->SetFont($this->sfont_family,$this->sfont_style,$this->sfont_size); + $h += $aImg->GetFontHeight(); + return $h; + } + + // Hight of text + function GetTextHeight($aImg) { + $aImg->SetFont($this->font_family,$this->font_style,$this->font_size); + $h = $aImg->GetTextHeight($this->t); + $aImg->SetFont($this->sfont_family,$this->sfont_style,$this->sfont_size); + $h += $aImg->GetTextHeight($this->iSuper); + return $h; + } + + function Stroke($aImg,$ax=-1,$ay=-1) { + + // To position the super script correctly we need different + // cases to handle the alignmewnt specified since that will + // determine how we can interpret the x,y coordinates + + $w = parent::GetWidth($aImg); + $h = parent::GetTextHeight($aImg); + switch( $this->valign ) { + case 'top': + $sy = $this->y; + break; + case 'center': + $sy = $this->y - $h/2; + break; + case 'bottom': + $sy = $this->y - $h; + break; + default: + JpGraphError::RaiseL(25052);//('PANIC: Internal error in SuperScript::Stroke(). Unknown vertical alignment for text'); + break; + } + + switch( $this->halign ) { + case 'left': + $sx = $this->x + $w; + break; + case 'center': + $sx = $this->x + $w/2; + break; + case 'right': + $sx = $this->x; + break; + default: + JpGraphError::RaiseL(25053);//('PANIC: Internal error in SuperScript::Stroke(). Unknown horizontal alignment for text'); + break; + } + + $sx += $this->iSuperMargin; + $sy += $this->iVertOverlap; + + // Should we automatically determine the font or + // has the user specified it explicetly? + if( $this->sfont_family == '' ) { + if( $this->font_family <= FF_FONT2 ) { + if( $this->font_family == FF_FONT0 ) { + $sff = FF_FONT0; + } + elseif( $this->font_family == FF_FONT1 ) { + if( $this->font_style == FS_NORMAL ) { + $sff = FF_FONT0; + } + else { + $sff = FF_FONT1; + } + } + else { + $sff = FF_FONT1; + } + $sfs = $this->font_style; + $sfz = $this->font_size; + } + else { + // TTF fonts + $sff = $this->font_family; + $sfs = $this->font_style; + $sfz = floor($this->font_size*$this->iSuperScale); + if( $sfz < 8 ) $sfz = 8; + } + $this->sfont_family = $sff; + $this->sfont_style = $sfs; + $this->sfont_size = $sfz; + } + else { + $sff = $this->sfont_family; + $sfs = $this->sfont_style; + $sfz = $this->sfont_size; + } + + parent::Stroke($aImg,$ax,$ay); + + // For the builtin fonts we need to reduce the margins + // since the bounding bx reported for the builtin fonts + // are much larger than for the TTF fonts. + if( $sff <= FF_FONT2 ) { + $sx -= 2; + $sy += 3; + } + + $aImg->SetTextAlign('left','bottom'); + $aImg->SetFont($sff,$sfs,$sfz); + $aImg->PushColor($this->color); + $aImg->StrokeText($sx,$sy,$this->iSuper,$this->iSDir,'left'); + $aImg->PopColor(); + } +} + + +//=================================================== +// CLASS Grid +// Description: responsible for drawing grid lines in graph +//=================================================== +class Grid { + protected $img; + protected $scale; + protected $majorcolor='#CCCCCC',$minorcolor='#DDDDDD'; + protected $majortype='solid',$minortype='solid'; + protected $show=false, $showMinor=false,$majorweight=1,$minorweight=1; + protected $fill=false,$fillcolor=array('#EFEFEF','#BBCCFF'); + + function __construct($aAxis) { + $this->scale = $aAxis->scale; + $this->img = $aAxis->img; + } + + function SetColor($aMajColor,$aMinColor=false) { + $this->majorcolor=$aMajColor; + if( $aMinColor === false ) { + $aMinColor = $aMajColor ; + } + $this->minorcolor = $aMinColor; + } + + function SetWeight($aMajorWeight,$aMinorWeight=1) { + $this->majorweight=$aMajorWeight; + $this->minorweight=$aMinorWeight; + } + + // Specify if grid should be dashed, dotted or solid + function SetLineStyle($aMajorType,$aMinorType='solid') { + $this->majortype = $aMajorType; + $this->minortype = $aMinorType; + } + + function SetStyle($aMajorType,$aMinorType='solid') { + $this->SetLineStyle($aMajorType,$aMinorType); + } + + // Decide if both major and minor grid should be displayed + function Show($aShowMajor=true,$aShowMinor=false) { + $this->show=$aShowMajor; + $this->showMinor=$aShowMinor; + } + + function SetFill($aFlg=true,$aColor1='lightgray',$aColor2='lightblue') { + $this->fill = $aFlg; + $this->fillcolor = array( $aColor1, $aColor2 ); + } + + // Display the grid + function Stroke() { + if( $this->showMinor && !$this->scale->textscale ) { + $this->DoStroke($this->scale->ticks->ticks_pos,$this->minortype,$this->minorcolor,$this->minorweight); + $this->DoStroke($this->scale->ticks->maj_ticks_pos,$this->majortype,$this->majorcolor,$this->majorweight); + } + else { + $this->DoStroke($this->scale->ticks->maj_ticks_pos,$this->majortype,$this->majorcolor,$this->majorweight); + } + } + + //-------------- + // Private methods + // Draw the grid + function DoStroke($aTicksPos,$aType,$aColor,$aWeight) { + if( !$this->show ) return; + $nbrgrids = count($aTicksPos); + + if( $this->scale->type == 'y' ) { + $xl=$this->img->left_margin; + $xr=$this->img->width-$this->img->right_margin; + + if( $this->fill ) { + // Draw filled areas + $y2 = $aTicksPos[0]; + $i=1; + while( $i < $nbrgrids ) { + $y1 = $y2; + $y2 = $aTicksPos[$i++]; + $this->img->SetColor($this->fillcolor[$i & 1]); + $this->img->FilledRectangle($xl,$y1,$xr,$y2); + } + } + + $this->img->SetColor($aColor); + $this->img->SetLineWeight($aWeight); + + // Draw grid lines + switch( $aType ) { + case 'solid': $style = LINESTYLE_SOLID; break; + case 'dotted': $style = LINESTYLE_DOTTED; break; + case 'dashed': $style = LINESTYLE_DASHED; break; + case 'longdashed': $style = LINESTYLE_LONGDASH; break; + default: + $style = LINESTYLE_SOLID; break; + } + + for($i=0; $i < $nbrgrids; ++$i) { + $y=$aTicksPos[$i]; + $this->img->StyleLine($xl,$y,$xr,$y,$style,true); + } + } + elseif( $this->scale->type == 'x' ) { + $yu=$this->img->top_margin; + $yl=$this->img->height-$this->img->bottom_margin; + $limit=$this->img->width-$this->img->right_margin; + + if( $this->fill ) { + // Draw filled areas + $x2 = $aTicksPos[0]; + $i=1; + while( $i < $nbrgrids ) { + $x1 = $x2; + $x2 = min($aTicksPos[$i++],$limit) ; + $this->img->SetColor($this->fillcolor[$i & 1]); + $this->img->FilledRectangle($x1,$yu,$x2,$yl); + } + } + + $this->img->SetColor($aColor); + $this->img->SetLineWeight($aWeight); + + // We must also test for limit since we might have + // an offset and the number of ticks is calculated with + // assumption offset==0 so we might end up drawing one + // to many gridlines + $i=0; + $x=$aTicksPos[$i]; + while( $i<count($aTicksPos) && ($x=$aTicksPos[$i]) <= $limit ) { + if ( $aType == 'solid' ) $this->img->Line($x,$yl,$x,$yu); + elseif( $aType == 'dotted' ) $this->img->DashedLineForGrid($x,$yl,$x,$yu,1,6); + elseif( $aType == 'dashed' ) $this->img->DashedLineForGrid($x,$yl,$x,$yu,2,4); + elseif( $aType == 'longdashed' ) $this->img->DashedLineForGrid($x,$yl,$x,$yu,8,6); + ++$i; + } + } + else { + JpGraphError::RaiseL(25054,$this->scale->type);//('Internal error: Unknown grid axis ['.$this->scale->type.']'); + } + return true; + } +} // Class + +//=================================================== +// CLASS Axis +// Description: Defines X and Y axis. Notes that at the +// moment the code is not really good since the axis on +// several occasion must know wheter it's an X or Y axis. +// This was a design decision to make the code easier to +// follow. +//=================================================== +class AxisPrototype { + public $scale=null; + public $img=null; + public $hide=false,$hide_labels=false; + public $title=null; + public $font_family=FF_DEFAULT,$font_style=FS_NORMAL,$font_size=8,$label_angle=0; + public $tick_step=1; + public $pos = false; + public $ticks_label = array(); + + protected $weight=1; + protected $color=array(0,0,0),$label_color=array(0,0,0); + protected $ticks_label_colors=null; + protected $show_first_label=true,$show_last_label=true; + protected $label_step=1; // Used by a text axis to specify what multiple of major steps + // should be labeled. + protected $labelPos=0; // Which side of the axis should the labels be? + protected $title_adjust,$title_margin,$title_side=SIDE_LEFT; + protected $tick_label_margin=5; + protected $label_halign = '',$label_valign = '', $label_para_align='left'; + protected $hide_line=false; + protected $iDeltaAbsPos=0; + + function __construct($img,$aScale,$color = array(0,0,0)) { + $this->img = $img; + $this->scale = $aScale; + $this->color = $color; + $this->title=new Text(''); + + if( $aScale->type == 'y' ) { + $this->title_margin = 25; + $this->title_adjust = 'middle'; + $this->title->SetOrientation(90); + $this->tick_label_margin=7; + $this->labelPos=SIDE_LEFT; + } + else { + $this->title_margin = 5; + $this->title_adjust = 'high'; + $this->title->SetOrientation(0); + $this->tick_label_margin=5; + $this->labelPos=SIDE_DOWN; + $this->title_side=SIDE_DOWN; + } + } + + function SetLabelFormat($aFormStr) { + $this->scale->ticks->SetLabelFormat($aFormStr); + } + + function SetLabelFormatString($aFormStr,$aDate=false) { + $this->scale->ticks->SetLabelFormat($aFormStr,$aDate); + } + + function SetLabelFormatCallback($aFuncName) { + $this->scale->ticks->SetFormatCallback($aFuncName); + } + + function SetLabelAlign($aHAlign,$aVAlign='top',$aParagraphAlign='left') { + $this->label_halign = $aHAlign; + $this->label_valign = $aVAlign; + $this->label_para_align = $aParagraphAlign; + } + + // Don't display the first label + function HideFirstTickLabel($aShow=false) { + $this->show_first_label=$aShow; + } + + function HideLastTickLabel($aShow=false) { + $this->show_last_label=$aShow; + } + + // Manually specify the major and (optional) minor tick position and labels + function SetTickPositions($aMajPos,$aMinPos=NULL,$aLabels=NULL) { + $this->scale->ticks->SetTickPositions($aMajPos,$aMinPos,$aLabels); + } + + // Manually specify major tick positions and optional labels + function SetMajTickPositions($aMajPos,$aLabels=NULL) { + $this->scale->ticks->SetTickPositions($aMajPos,NULL,$aLabels); + } + + // Hide minor or major tick marks + function HideTicks($aHideMinor=true,$aHideMajor=true) { + $this->scale->ticks->SupressMinorTickMarks($aHideMinor); + $this->scale->ticks->SupressTickMarks($aHideMajor); + } + + // Hide zero label + function HideZeroLabel($aFlag=true) { + $this->scale->ticks->SupressZeroLabel(); + } + + function HideFirstLastLabel() { + // The two first calls to ticks method will supress + // automatically generated scale values. However, that + // will not affect manually specified value, e.g text-scales. + // therefor we also make a kludge here to supress manually + // specified scale labels. + $this->scale->ticks->SupressLast(); + $this->scale->ticks->SupressFirst(); + $this->show_first_label = false; + $this->show_last_label = false; + } + + // Hide the axis + function Hide($aHide=true) { + $this->hide=$aHide; + } + + // Hide the actual axis-line, but still print the labels + function HideLine($aHide=true) { + $this->hide_line = $aHide; + } + + function HideLabels($aHide=true) { + $this->hide_labels = $aHide; + } + + // Weight of axis + function SetWeight($aWeight) { + $this->weight = $aWeight; + } + + // Axis color + function SetColor($aColor,$aLabelColor=false) { + $this->color = $aColor; + if( !$aLabelColor ) $this->label_color = $aColor; + else $this->label_color = $aLabelColor; + } + + // Title on axis + function SetTitle($aTitle,$aAdjustAlign='high') { + $this->title->Set($aTitle); + $this->title_adjust=$aAdjustAlign; + } + + // Specify distance from the axis + function SetTitleMargin($aMargin) { + $this->title_margin=$aMargin; + } + + // Which side of the axis should the axis title be? + function SetTitleSide($aSideOfAxis) { + $this->title_side = $aSideOfAxis; + } + + function SetTickSide($aDir) { + $this->scale->ticks->SetSide($aDir); + } + + function SetTickSize($aMajSize,$aMinSize=3) { + $this->scale->ticks->SetSize($aMajSize,$aMinSize=3); + } + + // Specify text labels for the ticks. One label for each data point + function SetTickLabels($aLabelArray,$aLabelColorArray=null) { + $this->ticks_label = $aLabelArray; + $this->ticks_label_colors = $aLabelColorArray; + } + + function SetLabelMargin($aMargin) { + $this->tick_label_margin=$aMargin; + } + + // Specify that every $step of the ticks should be displayed starting + // at $start + function SetTextTickInterval($aStep,$aStart=0) { + $this->scale->ticks->SetTextLabelStart($aStart); + $this->tick_step=$aStep; + } + + // Specify that every $step tick mark should have a label + // should be displayed starting + function SetTextLabelInterval($aStep) { + if( $aStep < 1 ) { + JpGraphError::RaiseL(25058);//(" Text label interval must be specified >= 1."); + } + $this->label_step=$aStep; + } + + function SetLabelSide($aSidePos) { + $this->labelPos=$aSidePos; + } + + // Set the font + function SetFont($aFamily,$aStyle=FS_NORMAL,$aSize=10) { + $this->font_family = $aFamily; + $this->font_style = $aStyle; + $this->font_size = $aSize; + } + + // Position for axis line on the "other" scale + function SetPos($aPosOnOtherScale) { + $this->pos=$aPosOnOtherScale; + } + + // Set the position of the axis to be X-pixels delta to the right + // of the max X-position (used to position the multiple Y-axis) + function SetPosAbsDelta($aDelta) { + $this->iDeltaAbsPos=$aDelta; + } + + // Specify the angle for the tick labels + function SetLabelAngle($aAngle) { + $this->label_angle = $aAngle; + } + +} // Class + + +//=================================================== +// CLASS Axis +// Description: Defines X and Y axis. Notes that at the +// moment the code is not really good since the axis on +// several occasion must know wheter it's an X or Y axis. +// This was a design decision to make the code easier to +// follow. +//=================================================== +class Axis extends AxisPrototype { + + function __construct($img,$aScale,$color='black') { + parent::__construct($img,$aScale,$color); + } + + // Stroke the axis. + function Stroke($aOtherAxisScale,$aStrokeLabels=true) { + if( $this->hide ) + return; + if( is_numeric($this->pos) ) { + $pos=$aOtherAxisScale->Translate($this->pos); + } + else { // Default to minimum of other scale if pos not set + if( ($aOtherAxisScale->GetMinVal() >= 0 && $this->pos==false) || $this->pos == 'min' ) { + $pos = $aOtherAxisScale->scale_abs[0]; + } + elseif($this->pos == "max") { + $pos = $aOtherAxisScale->scale_abs[1]; + } + else { // If negative set x-axis at 0 + $this->pos=0; + $pos=$aOtherAxisScale->Translate(0); + } + } + + $pos += $this->iDeltaAbsPos; + $this->img->SetLineWeight($this->weight); + $this->img->SetColor($this->color); + $this->img->SetFont($this->font_family,$this->font_style,$this->font_size); + + if( $this->scale->type == "x" ) { + if( !$this->hide_line ) { + // Stroke X-axis + $this->img->FilledRectangle( + $this->img->left_margin, + $pos, + $this->img->width - $this->img->right_margin, + $pos + $this->weight-1 + ); + } + if( $this->title_side == SIDE_DOWN ) { + $y = $pos + $this->img->GetFontHeight() + $this->title_margin + $this->title->margin; + $yalign = 'top'; + } + else { + $y = $pos - $this->img->GetFontHeight() - $this->title_margin - $this->title->margin; + $yalign = 'bottom'; + } + + if( $this->title_adjust=='high' ) { + $this->title->SetPos($this->img->width-$this->img->right_margin,$y,'right',$yalign); + } + elseif( $this->title_adjust=='middle' || $this->title_adjust=='center' ) { + $this->title->SetPos(($this->img->width-$this->img->left_margin-$this->img->right_margin)/2+$this->img->left_margin,$y,'center',$yalign); + } + elseif($this->title_adjust=='low') { + $this->title->SetPos($this->img->left_margin,$y,'left',$yalign); + } + else { + JpGraphError::RaiseL(25060,$this->title_adjust);//('Unknown alignment specified for X-axis title. ('.$this->title_adjust.')'); + } + } + elseif( $this->scale->type == "y" ) { + // Add line weight to the height of the axis since + // the x-axis could have a width>1 and we want the axis to fit nicely together. + if( !$this->hide_line ) { + // Stroke Y-axis + $this->img->FilledRectangle( + $pos - $this->weight + 1, + $this->img->top_margin, + $pos, + $this->img->height - $this->img->bottom_margin + $this->weight - 1 + ); + } + + $x=$pos ; + if( $this->title_side == SIDE_LEFT ) { + $x -= $this->title_margin; + $x -= $this->title->margin; + $halign = 'right'; + } + else { + $x += $this->title_margin; + $x += $this->title->margin; + $halign = 'left'; + } + // If the user has manually specified an hor. align + // then we override the automatic settings with this + // specifed setting. Since default is 'left' we compare + // with that. (This means a manually set 'left' align + // will have no effect.) + if( $this->title->halign != 'left' ) { + $halign = $this->title->halign; + } + if( $this->title_adjust == 'high' ) { + $this->title->SetPos($x,$this->img->top_margin,$halign,'top'); + } + elseif($this->title_adjust=='middle' || $this->title_adjust=='center') { + $this->title->SetPos($x,($this->img->height-$this->img->top_margin-$this->img->bottom_margin)/2+$this->img->top_margin,$halign,"center"); + } + elseif($this->title_adjust=='low') { + $this->title->SetPos($x,$this->img->height-$this->img->bottom_margin,$halign,'bottom'); + } + else { + JpGraphError::RaiseL(25061,$this->title_adjust);//('Unknown alignment specified for Y-axis title. ('.$this->title_adjust.')'); + } + } + $this->scale->ticks->Stroke($this->img,$this->scale,$pos); + if( $aStrokeLabels ) { + if( !$this->hide_labels ) { + $this->StrokeLabels($pos); + } + $this->title->Stroke($this->img); + } + } + + //--------------- + // PRIVATE METHODS + // Draw all the tick labels on major tick marks + function StrokeLabels($aPos,$aMinor=false,$aAbsLabel=false) { + + if( is_array($this->label_color) && count($this->label_color) > 3 ) { + $this->ticks_label_colors = $this->label_color; + $this->img->SetColor($this->label_color[0]); + } + else { + $this->img->SetColor($this->label_color); + } + $this->img->SetFont($this->font_family,$this->font_style,$this->font_size); + $yoff=$this->img->GetFontHeight()/2; + + // Only draw labels at major tick marks + $nbr = count($this->scale->ticks->maj_ticks_label); + + // We have the option to not-display the very first mark + // (Usefull when the first label might interfere with another + // axis.) + $i = $this->show_first_label ? 0 : 1 ; + if( !$this->show_last_label ) { + --$nbr; + } + // Now run through all labels making sure we don't overshoot the end + // of the scale. + $ncolor=0; + if( isset($this->ticks_label_colors) ) { + $ncolor=count($this->ticks_label_colors); + } + while( $i < $nbr ) { + // $tpos holds the absolute text position for the label + $tpos=$this->scale->ticks->maj_ticklabels_pos[$i]; + + // Note. the $limit is only used for the x axis since we + // might otherwise overshoot if the scale has been centered + // This is due to us "loosing" the last tick mark if we center. + if( $this->scale->type == 'x' && $tpos > $this->img->width-$this->img->right_margin+1 ) { + return; + } + // we only draw every $label_step label + if( ($i % $this->label_step)==0 ) { + + // Set specific label color if specified + if( $ncolor > 0 ) { + $this->img->SetColor($this->ticks_label_colors[$i % $ncolor]); + } + + // If the label has been specified use that and in other case + // just label the mark with the actual scale value + $m=$this->scale->ticks->GetMajor(); + + // ticks_label has an entry for each data point and is the array + // that holds the labels set by the user. If the user hasn't + // specified any values we use whats in the automatically asigned + // labels in the maj_ticks_label + if( isset($this->ticks_label[$i*$m]) ) { + $label=$this->ticks_label[$i*$m]; + } + else { + if( $aAbsLabel ) { + $label=abs($this->scale->ticks->maj_ticks_label[$i]); + } + else { + $label=$this->scale->ticks->maj_ticks_label[$i]; + } + + // We number the scale from 1 and not from 0 so increase by one + if( $this->scale->textscale && + $this->scale->ticks->label_formfunc == '' && + ! $this->scale->ticks->HaveManualLabels() ) { + + ++$label; + + } + } + + if( $this->scale->type == "x" ) { + if( $this->labelPos == SIDE_DOWN ) { + if( $this->label_angle==0 || $this->label_angle==90 ) { + if( $this->label_halign=='' && $this->label_valign=='') { + $this->img->SetTextAlign('center','top'); + } + else { + $this->img->SetTextAlign($this->label_halign,$this->label_valign); + } + + } + else { + if( $this->label_halign=='' && $this->label_valign=='') { + $this->img->SetTextAlign("right","top"); + } + else { + $this->img->SetTextAlign($this->label_halign,$this->label_valign); + } + } + $this->img->StrokeText($tpos,$aPos+$this->tick_label_margin,$label, + $this->label_angle,$this->label_para_align); + } + else { + if( $this->label_angle==0 || $this->label_angle==90 ) { + if( $this->label_halign=='' && $this->label_valign=='') { + $this->img->SetTextAlign("center","bottom"); + } + else { + $this->img->SetTextAlign($this->label_halign,$this->label_valign); + } + } + else { + if( $this->label_halign=='' && $this->label_valign=='') { + $this->img->SetTextAlign("right","bottom"); + } + else { + $this->img->SetTextAlign($this->label_halign,$this->label_valign); + } + } + $this->img->StrokeText($tpos,$aPos-$this->tick_label_margin-1,$label, + $this->label_angle,$this->label_para_align); + } + } + else { + // scale->type == "y" + //if( $this->label_angle!=0 ) + //JpGraphError::Raise(" Labels at an angle are not supported on Y-axis"); + if( $this->labelPos == SIDE_LEFT ) { // To the left of y-axis + if( $this->label_halign=='' && $this->label_valign=='') { + $this->img->SetTextAlign("right","center"); + } + else { + $this->img->SetTextAlign($this->label_halign,$this->label_valign); + } + $this->img->StrokeText($aPos-$this->tick_label_margin,$tpos,$label,$this->label_angle,$this->label_para_align); + } + else { // To the right of the y-axis + if( $this->label_halign=='' && $this->label_valign=='') { + $this->img->SetTextAlign("left","center"); + } + else { + $this->img->SetTextAlign($this->label_halign,$this->label_valign); + } + $this->img->StrokeText($aPos+$this->tick_label_margin,$tpos,$label,$this->label_angle,$this->label_para_align); + } + } + } + ++$i; + } + } + +} + + +//=================================================== +// CLASS Ticks +// Description: Abstract base class for drawing linear and logarithmic +// tick marks on axis +//=================================================== +class Ticks { + public $label_formatstr=''; // C-style format string to use for labels + public $label_formfunc=''; + public $label_dateformatstr=''; + public $direction=1; // Should ticks be in(=1) the plot area or outside (=-1) + public $supress_last=false,$supress_tickmarks=false,$supress_minor_tickmarks=false; + public $maj_ticks_pos = array(), $maj_ticklabels_pos = array(), + $ticks_pos = array(), $maj_ticks_label = array(); + public $precision; + + protected $minor_abs_size=3, $major_abs_size=5; + protected $scale; + protected $is_set=false; + protected $supress_zerolabel=false,$supress_first=false; + protected $mincolor='',$majcolor=''; + protected $weight=1; + protected $label_usedateformat=FALSE; + + function __construct($aScale) { + $this->scale=$aScale; + $this->precision = -1; + } + + // Set format string for automatic labels + function SetLabelFormat($aFormatString,$aDate=FALSE) { + $this->label_formatstr=$aFormatString; + $this->label_usedateformat=$aDate; + } + + function SetLabelDateFormat($aFormatString) { + $this->label_dateformatstr=$aFormatString; + } + + function SetFormatCallback($aCallbackFuncName) { + $this->label_formfunc = $aCallbackFuncName; + } + + // Don't display the first zero label + function SupressZeroLabel($aFlag=true) { + $this->supress_zerolabel=$aFlag; + } + + // Don't display minor tick marks + function SupressMinorTickMarks($aHide=true) { + $this->supress_minor_tickmarks=$aHide; + } + + // Don't display major tick marks + function SupressTickMarks($aHide=true) { + $this->supress_tickmarks=$aHide; + } + + // Hide the first tick mark + function SupressFirst($aHide=true) { + $this->supress_first=$aHide; + } + + // Hide the last tick mark + function SupressLast($aHide=true) { + $this->supress_last=$aHide; + } + + // Size (in pixels) of minor tick marks + function GetMinTickAbsSize() { + return $this->minor_abs_size; + } + + // Size (in pixels) of major tick marks + function GetMajTickAbsSize() { + return $this->major_abs_size; + } + + function SetSize($aMajSize,$aMinSize=3) { + $this->major_abs_size = $aMajSize; + $this->minor_abs_size = $aMinSize; + } + + // Have the ticks been specified + function IsSpecified() { + return $this->is_set; + } + + function SetSide($aSide) { + $this->direction=$aSide; + } + + // Which side of the axis should the ticks be on + function SetDirection($aSide=SIDE_RIGHT) { + $this->direction=$aSide; + } + + // Set colors for major and minor tick marks + function SetMarkColor($aMajorColor,$aMinorColor='') { + $this->SetColor($aMajorColor,$aMinorColor); + } + + function SetColor($aMajorColor,$aMinorColor='') { + $this->majcolor=$aMajorColor; + + // If not specified use same as major + if( $aMinorColor == '' ) { + $this->mincolor=$aMajorColor; + } + else { + $this->mincolor=$aMinorColor; + } + } + + function SetWeight($aWeight) { + $this->weight=$aWeight; + } + +} // Class + +//=================================================== +// CLASS LinearTicks +// Description: Draw linear ticks on axis +//=================================================== +class LinearTicks extends Ticks { + public $minor_step=1, $major_step=2; + public $xlabel_offset=0,$xtick_offset=0; + private $label_offset=0; // What offset should the displayed label have + // i.e should we display 0,1,2 or 1,2,3,4 or 2,3,4 etc + private $text_label_start=0; + private $iManualTickPos = NULL, $iManualMinTickPos = NULL, $iManualTickLabels = NULL; + private $iAdjustForDST = false; // If a date falls within the DST period add one hour to the diaplyed time + + function __construct() { + $this->precision = -1; + } + + // Return major step size in world coordinates + function GetMajor() { + return $this->major_step; + } + + // Return minor step size in world coordinates + function GetMinor() { + return $this->minor_step; + } + + // Set Minor and Major ticks (in world coordinates) + function Set($aMajStep,$aMinStep=false) { + if( $aMinStep==false ) { + $aMinStep=$aMajStep; + } + + if( $aMajStep <= 0 || $aMinStep <= 0 ) { + JpGraphError::RaiseL(25064); + //(" Minor or major step size is 0. Check that you haven't got an accidental SetTextTicks(0) in your code. If this is not the case you might have stumbled upon a bug in JpGraph. Please report this and if possible include the data that caused the problem."); + } + + $this->major_step=$aMajStep; + $this->minor_step=$aMinStep; + $this->is_set = true; + } + + function SetMajTickPositions($aMajPos,$aLabels=NULL) { + $this->SetTickPositions($aMajPos,NULL,$aLabels); + } + + function SetTickPositions($aMajPos,$aMinPos=NULL,$aLabels=NULL) { + if( !is_array($aMajPos) || ($aMinPos!==NULL && !is_array($aMinPos)) ) { + JpGraphError::RaiseL(25065);//('Tick positions must be specifued as an array()'); + return; + } + $n=count($aMajPos); + if( is_array($aLabels) && (count($aLabels) != $n) ) { + JpGraphError::RaiseL(25066);//('When manually specifying tick positions and labels the number of labels must be the same as the number of specified ticks.'); + } + $this->iManualTickPos = $aMajPos; + $this->iManualMinTickPos = $aMinPos; + $this->iManualTickLabels = $aLabels; + } + + function HaveManualLabels() { + return count($this->iManualTickLabels) > 0; + } + + // Specify all the tick positions manually and possible also the exact labels + function _doManualTickPos($aScale) { + $n=count($this->iManualTickPos); + $m=count($this->iManualMinTickPos); + $doLbl=count($this->iManualTickLabels) > 0; + + $this->maj_ticks_pos = array(); + $this->maj_ticklabels_pos = array(); + $this->ticks_pos = array(); + + // Now loop through the supplied positions and translate them to screen coordinates + // and store them in the maj_label_positions + $minScale = $aScale->scale[0]; + $maxScale = $aScale->scale[1]; + $j=0; + for($i=0; $i < $n ; ++$i ) { + // First make sure that the first tick is not lower than the lower scale value + if( !isset($this->iManualTickPos[$i]) || $this->iManualTickPos[$i] < $minScale || $this->iManualTickPos[$i] > $maxScale) { + continue; + } + + $this->maj_ticks_pos[$j] = $aScale->Translate($this->iManualTickPos[$i]); + $this->maj_ticklabels_pos[$j] = $this->maj_ticks_pos[$j]; + + // Set the minor tick marks the same as major if not specified + if( $m <= 0 ) { + $this->ticks_pos[$j] = $this->maj_ticks_pos[$j]; + } + if( $doLbl ) { + $this->maj_ticks_label[$j] = $this->iManualTickLabels[$i]; + } + else { + $this->maj_ticks_label[$j]=$this->_doLabelFormat($this->iManualTickPos[$i],$i,$n); + } + ++$j; + } + + // Some sanity check + if( count($this->maj_ticks_pos) < 2 ) { + JpGraphError::RaiseL(25067);//('Your manually specified scale and ticks is not correct. The scale seems to be too small to hold any of the specified tickl marks.'); + } + + // Setup the minor tick marks + $j=0; + for($i=0; $i < $m; ++$i ) { + if( empty($this->iManualMinTickPos[$i]) || $this->iManualMinTickPos[$i] < $minScale || $this->iManualMinTickPos[$i] > $maxScale) { + continue; + } + $this->ticks_pos[$j] = $aScale->Translate($this->iManualMinTickPos[$i]); + ++$j; + } + } + + function _doAutoTickPos($aScale) { + $maj_step_abs = $aScale->scale_factor*$this->major_step; + $min_step_abs = $aScale->scale_factor*$this->minor_step; + + if( $min_step_abs==0 || $maj_step_abs==0 ) { + JpGraphError::RaiseL(25068);//("A plot has an illegal scale. This could for example be that you are trying to use text autoscaling to draw a line plot with only one point or that the plot area is too small. It could also be that no input data value is numeric (perhaps only '-' or 'x')"); + } + // We need to make this an int since comparing it below + // with the result from round() can give wrong result, such that + // (40 < 40) == TRUE !!! + $limit = (int)$aScale->scale_abs[1]; + + if( $aScale->textscale ) { + // This can only be true for a X-scale (horizontal) + // Define ticks for a text scale. This is slightly different from a + // normal linear type of scale since the position might be adjusted + // and the labels start at on + $label = (float)$aScale->GetMinVal()+$this->text_label_start+$this->label_offset; + $start_abs=$aScale->scale_factor*$this->text_label_start; + $nbrmajticks=round(($aScale->GetMaxVal()-$aScale->GetMinVal()-$this->text_label_start )/$this->major_step)+1; + + $x = $aScale->scale_abs[0]+$start_abs+$this->xlabel_offset*$min_step_abs; + for( $i=0; $label <= $aScale->GetMaxVal()+$this->label_offset; ++$i ) { + // Apply format to label + $this->maj_ticks_label[$i]=$this->_doLabelFormat($label,$i,$nbrmajticks); + $label+=$this->major_step; + + // The x-position of the tick marks can be different from the labels. + // Note that we record the tick position (not the label) so that the grid + // happen upon tick marks and not labels. + $xtick=$aScale->scale_abs[0]+$start_abs+$this->xtick_offset*$min_step_abs+$i*$maj_step_abs; + $this->maj_ticks_pos[$i]=$xtick; + $this->maj_ticklabels_pos[$i] = round($x); + $x += $maj_step_abs; + } + } + else { + $label = $aScale->GetMinVal(); + $abs_pos = $aScale->scale_abs[0]; + $j=0; $i=0; + $step = round($maj_step_abs/$min_step_abs); + if( $aScale->type == "x" ) { + // For a normal linear type of scale the major ticks will always be multiples + // of the minor ticks. In order to avoid any rounding issues the major ticks are + // defined as every "step" minor ticks and not calculated separately + $nbrmajticks=round(($aScale->GetMaxVal()-$aScale->GetMinVal()-$this->text_label_start )/$this->major_step)+1; + while( round($abs_pos) <= $limit ) { + $this->ticks_pos[] = round($abs_pos); + $this->ticks_label[] = $label; + if( $step== 0 || $i % $step == 0 && $j < $nbrmajticks ) { + $this->maj_ticks_pos[$j] = round($abs_pos); + $this->maj_ticklabels_pos[$j] = round($abs_pos); + $this->maj_ticks_label[$j]=$this->_doLabelFormat($label,$j,$nbrmajticks); + ++$j; + } + ++$i; + $abs_pos += $min_step_abs; + $label+=$this->minor_step; + } + } + elseif( $aScale->type == "y" ) { + //@todo s=2:20,12 s=1:50,6 $this->major_step:$nbr + // abs_point,limit s=1:270,80 s=2:540,160 + // $this->major_step = 50; + $nbrmajticks=round(($aScale->GetMaxVal()-$aScale->GetMinVal())/$this->major_step)+1; +// $step = 5; + while( round($abs_pos) >= $limit ) { + $this->ticks_pos[$i] = round($abs_pos); + $this->ticks_label[$i]=$label; + if( $step== 0 || $i % $step == 0 && $j < $nbrmajticks) { + $this->maj_ticks_pos[$j] = round($abs_pos); + $this->maj_ticklabels_pos[$j] = round($abs_pos); + $this->maj_ticks_label[$j]=$this->_doLabelFormat($label,$j,$nbrmajticks); + ++$j; + } + ++$i; + $abs_pos += $min_step_abs; + $label += $this->minor_step; + } + } + } + } + + function AdjustForDST($aFlg=true) { + $this->iAdjustForDST = $aFlg; + } + + + function _doLabelFormat($aVal,$aIdx,$aNbrTicks) { + + // If precision hasn't been specified set it to a sensible value + if( $this->precision==-1 ) { + $t = log10($this->minor_step); + if( $t > 0 ) { + $precision = 0; + } + else { + $precision = -floor($t); + } + } + else { + $precision = $this->precision; + } + + if( $this->label_formfunc != '' ) { + $f=$this->label_formfunc; + if( $this->label_formatstr == '' ) { + $l = call_user_func($f,$aVal); + } + else { + $l = sprintf($this->label_formatstr, call_user_func($f,$aVal)); + } + } + elseif( $this->label_formatstr != '' || $this->label_dateformatstr != '' ) { + if( $this->label_usedateformat ) { + // Adjust the value to take daylight savings into account + if (date("I",$aVal)==1 && $this->iAdjustForDST ) { + // DST + $aVal+=3600; + } + + $l = date($this->label_formatstr,$aVal); + if( $this->label_formatstr == 'W' ) { + // If we use week formatting then add a single 'w' in front of the + // week number to differentiate it from dates + $l = 'w'.$l; + } + } + else { + if( $this->label_dateformatstr !== '' ) { + // Adjust the value to take daylight savings into account + if (date("I",$aVal)==1 && $this->iAdjustForDST ) { + // DST + $aVal+=3600; + } + + $l = date($this->label_dateformatstr,$aVal); + if( $this->label_formatstr == 'W' ) { + // If we use week formatting then add a single 'w' in front of the + // week number to differentiate it from dates + $l = 'w'.$l; + } + } + else { + $l = sprintf($this->label_formatstr,$aVal); + } + } + } + else { + $l = sprintf('%01.'.$precision.'f',round($aVal,$precision)); + } + + if( ($this->supress_zerolabel && $l==0) || ($this->supress_first && $aIdx==0) || ($this->supress_last && $aIdx==$aNbrTicks-1) ) { + $l=''; + } + return $l; + } + + // Stroke ticks on either X or Y axis + function _StrokeTicks($aImg,$aScale,$aPos) { + $hor = $aScale->type == 'x'; + $aImg->SetLineWeight($this->weight); + + // We need to make this an int since comparing it below + // with the result from round() can give wrong result, such that + // (40 < 40) == TRUE !!! + $limit = (int)$aScale->scale_abs[1]; + + // A text scale doesn't have any minor ticks + if( !$aScale->textscale ) { + // Stroke minor ticks + $yu = $aPos - $this->direction*$this->GetMinTickAbsSize(); + $xr = $aPos + $this->direction*$this->GetMinTickAbsSize(); + $n = count($this->ticks_pos); + for($i=0; $i < $n; ++$i ) { + if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) { + if( $this->mincolor != '') { + $aImg->PushColor($this->mincolor); + } + if( $hor ) { + //if( $this->ticks_pos[$i] <= $limit ) + $aImg->Line($this->ticks_pos[$i],$aPos,$this->ticks_pos[$i],$yu); + } + else { + //if( $this->ticks_pos[$i] >= $limit ) + $aImg->Line($aPos,$this->ticks_pos[$i],$xr,$this->ticks_pos[$i]); + } + if( $this->mincolor != '' ) { + $aImg->PopColor(); + } + } + } + } + + // Stroke major ticks + $yu = $aPos - $this->direction*$this->GetMajTickAbsSize(); + $xr = $aPos + $this->direction*$this->GetMajTickAbsSize(); + $nbrmajticks=round(($aScale->GetMaxVal()-$aScale->GetMinVal()-$this->text_label_start )/$this->major_step)+1; + $n = count($this->maj_ticks_pos); + for($i=0; $i < $n ; ++$i ) { + if(!($this->xtick_offset > 0 && $i==$nbrmajticks-1) && !$this->supress_tickmarks) { + if( $this->majcolor != '') { + $aImg->PushColor($this->majcolor); + } + if( $hor ) { + //if( $this->maj_ticks_pos[$i] <= $limit ) + $aImg->Line($this->maj_ticks_pos[$i],$aPos,$this->maj_ticks_pos[$i],$yu); + } + else { + //if( $this->maj_ticks_pos[$i] >= $limit ) + $aImg->Line($aPos,$this->maj_ticks_pos[$i],$xr,$this->maj_ticks_pos[$i]); + } + if( $this->majcolor != '') { + $aImg->PopColor(); + } + } + } + + } + + // Draw linear ticks + function Stroke($aImg,$aScale,$aPos) { + if( $this->iManualTickPos != NULL ) { + $this->_doManualTickPos($aScale); + } + else { + $this->_doAutoTickPos($aScale); + } + $this->_StrokeTicks($aImg,$aScale,$aPos, $aScale->type == 'x' ); + } + + //--------------- + // PRIVATE METHODS + // Spoecify the offset of the displayed tick mark with the tick "space" + // Legal values for $o is [0,1] used to adjust where the tick marks and label + // should be positioned within the major tick-size + // $lo specifies the label offset and $to specifies the tick offset + // this comes in handy for example in bar graphs where we wont no offset for the + // tick but have the labels displayed halfway under the bars. + function SetXLabelOffset($aLabelOff,$aTickOff=-1) { + $this->xlabel_offset=$aLabelOff; + if( $aTickOff==-1 ) { + // Same as label offset + $this->xtick_offset=$aLabelOff; + } + else { + $this->xtick_offset=$aTickOff; + } + if( $aLabelOff>0 ) { + $this->SupressLast(); // The last tick wont fit + } + } + + // Which tick label should we start with? + function SetTextLabelStart($aTextLabelOff) { + $this->text_label_start=$aTextLabelOff; + } + +} // Class + +//=================================================== +// CLASS LinearScale +// Description: Handle linear scaling between screen and world +//=================================================== +class LinearScale { + public $textscale=false; // Just a flag to let the Plot class find out if + // we are a textscale or not. This is a cludge since + // this information is available in Graph::axtype but + // we don't have access to the graph object in the Plots + // stroke method. So we let graph store the status here + // when the linear scale is created. A real cludge... + public $type; // is this x or y scale ? + public $ticks=null; // Store ticks + public $text_scale_off = 0; + public $scale_abs=array(0,0); + public $scale_factor; // Scale factor between world and screen + public $off; // Offset between image edge and plot area + public $scale=array(0,0); + public $name = 'lin'; + public $auto_ticks=false; // When using manual scale should the ticks be automatically set? + public $world_abs_size; // Plot area size in pixels (Needed public in jpgraph_radar.php) + public $intscale=false; // Restrict autoscale to integers + protected $autoscale_min=false; // Forced minimum value, auto determine max + protected $autoscale_max=false; // Forced maximum value, auto determine min + private $gracetop=0,$gracebottom=0; + + private $_world_size; // Plot area size in world coordinates + + function __construct($aMin=0,$aMax=0,$aType='y') { + assert($aType=='x' || $aType=='y' ); + assert($aMin<=$aMax); + + $this->type=$aType; + $this->scale=array($aMin,$aMax); + $this->world_size=$aMax-$aMin; + $this->ticks = new LinearTicks(); + } + + // Check if scale is set or if we should autoscale + // We should do this is either scale or ticks has not been set + function IsSpecified() { + if( $this->GetMinVal()==$this->GetMaxVal() ) { // Scale not set + return false; + } + return true; + } + + // Set the minimum data value when the autoscaling is used. + // Usefull if you want a fix minimum (like 0) but have an + // automatic maximum + function SetAutoMin($aMin) { + $this->autoscale_min=$aMin; + } + + // Set the minimum data value when the autoscaling is used. + // Usefull if you want a fix minimum (like 0) but have an + // automatic maximum + function SetAutoMax($aMax) { + $this->autoscale_max=$aMax; + } + + // If the user manually specifies a scale should the ticks + // still be set automatically? + function SetAutoTicks($aFlag=true) { + $this->auto_ticks = $aFlag; + } + + // Specify scale "grace" value (top and bottom) + function SetGrace($aGraceTop,$aGraceBottom=0) { + if( $aGraceTop<0 || $aGraceBottom < 0 ) { + JpGraphError::RaiseL(25069);//(" Grace must be larger then 0"); + } + $this->gracetop=$aGraceTop; + $this->gracebottom=$aGraceBottom; + } + + // Get the minimum value in the scale + function GetMinVal() { + return $this->scale[0]; + } + + // get maximum value for scale + function GetMaxVal() { + return $this->scale[1]; + } + + // Specify a new min/max value for sclae + function Update($aImg,$aMin,$aMax) { + $this->scale=array($aMin,$aMax); + $this->world_size=$aMax-$aMin; + $this->InitConstants($aImg); + } + + // Translate between world and screen + function Translate($aCoord) { + if( !is_numeric($aCoord) ) { + if( $aCoord != '' && $aCoord != '-' && $aCoord != 'x' ) { + JpGraphError::RaiseL(25070);//('Your data contains non-numeric values.'); + } + return 0; + } + else { + return round($this->off+($aCoord - $this->scale[0]) * $this->scale_factor); + } + } + + // Relative translate (don't include offset) usefull when we just want + // to know the relative position (in pixels) on the axis + function RelTranslate($aCoord) { + if( !is_numeric($aCoord) ) { + if( $aCoord != '' && $aCoord != '-' && $aCoord != 'x' ) { + JpGraphError::RaiseL(25070);//('Your data contains non-numeric values.'); + } + return 0; + } + else { + return ($aCoord - $this->scale[0]) * $this->scale_factor; + } + } + + // Restrict autoscaling to only use integers + function SetIntScale($aIntScale=true) { + $this->intscale=$aIntScale; + } + + // Calculate an integer autoscale + function IntAutoScale($img,$min,$max,$maxsteps,$majend=true) { + // Make sure limits are integers + $min=floor($min); + $max=ceil($max); + if( abs($min-$max)==0 ) { + --$min; ++$max; + } + $maxsteps = floor($maxsteps); + + $gracetop=round(($this->gracetop/100.0)*abs($max-$min)); + $gracebottom=round(($this->gracebottom/100.0)*abs($max-$min)); + if( is_numeric($this->autoscale_min) ) { + $min = ceil($this->autoscale_min); + if( $min >= $max ) { + JpGraphError::RaiseL(25071);//('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.'); + } + } + + if( is_numeric($this->autoscale_max) ) { + $max = ceil($this->autoscale_max); + if( $min >= $max ) { + JpGraphError::RaiseL(25072);//('You have specified a max value with SetAutoMax() which is smaller than the miminum value used for the scale. This is not possible.'); + } + } + + if( abs($min-$max ) == 0 ) { + ++$max; + --$min; + } + + $min -= $gracebottom; + $max += $gracetop; + + // First get tickmarks as multiples of 1, 10, ... + if( $majend ) { + list($num1steps,$adj1min,$adj1max,$maj1step) = $this->IntCalcTicks($maxsteps,$min,$max,1); + } + else { + $adj1min = $min; + $adj1max = $max; + list($num1steps,$maj1step) = $this->IntCalcTicksFreeze($maxsteps,$min,$max,1); + } + + if( abs($min-$max) > 2 ) { + // Then get tick marks as 2:s 2, 20, ... + if( $majend ) { + list($num2steps,$adj2min,$adj2max,$maj2step) = $this->IntCalcTicks($maxsteps,$min,$max,5); + } + else { + $adj2min = $min; + $adj2max = $max; + list($num2steps,$maj2step) = $this->IntCalcTicksFreeze($maxsteps,$min,$max,5); + } + } + else { + $num2steps = 10000; // Dummy high value so we don't choose this + } + + if( abs($min-$max) > 5 ) { + // Then get tickmarks as 5:s 5, 50, 500, ... + if( $majend ) { + list($num5steps,$adj5min,$adj5max,$maj5step) = $this->IntCalcTicks($maxsteps,$min,$max,2); + } + else { + $adj5min = $min; + $adj5max = $max; + list($num5steps,$maj5step) = $this->IntCalcTicksFreeze($maxsteps,$min,$max,2); + } + } + else { + $num5steps = 10000; // Dummy high value so we don't choose this + } + + // Check to see whichof 1:s, 2:s or 5:s fit better with + // the requested number of major ticks + $match1=abs($num1steps-$maxsteps); + $match2=abs($num2steps-$maxsteps); + if( !empty($maj5step) && $maj5step > 1 ) { + $match5=abs($num5steps-$maxsteps); + } + else { + $match5=10000; // Dummy high value + } + + // Compare these three values and see which is the closest match + // We use a 0.6 weight to gravitate towards multiple of 5:s + if( $match1 < $match2 ) { + if( $match1 < $match5 ) $r=1; + else $r=3; + } + else { + if( $match2 < $match5 ) $r=2; + else $r=3; + } + // Minsteps are always the same as maxsteps for integer scale + switch( $r ) { + case 1: + $this->ticks->Set($maj1step,$maj1step); + $this->Update($img,$adj1min,$adj1max); + break; + case 2: + $this->ticks->Set($maj2step,$maj2step); + $this->Update($img,$adj2min,$adj2max); + break; + case 3: + $this->ticks->Set($maj5step,$maj5step); + $this->Update($img,$adj5min,$adj5max); + break; + default: + JpGraphError::RaiseL(25073,$r);//('Internal error. Integer scale algorithm comparison out of bound (r=$r)'); + } + } + + + // Calculate autoscale. Used if user hasn't given a scale and ticks + // $maxsteps is the maximum number of major tickmarks allowed. + function AutoScale($img,$min,$max,$maxsteps,$majend=true) { + + if( !is_numeric($min) || !is_numeric($max) ) { + JpGraphError::Raise(25044); + } + + if( $this->intscale ) { + $this->IntAutoScale($img,$min,$max,$maxsteps,$majend); + return; + } + if( abs($min-$max) < 0.00001 ) { + // We need some difference to be able to autoscale + // make it 5% above and 5% below value + if( $min==0 && $max==0 ) { // Special case + $min=-1; $max=1; + } + else { + $delta = (abs($max)+abs($min))*0.005; + $min -= $delta; + $max += $delta; + } + } + + $gracetop=($this->gracetop/100.0)*abs($max-$min); + $gracebottom=($this->gracebottom/100.0)*abs($max-$min); + if( is_numeric($this->autoscale_min) ) { + $min = $this->autoscale_min; + if( $min >= $max ) { + JpGraphError::RaiseL(25071);//('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.'); + } + if( abs($min-$max ) < 0.001 ) { + $max *= 1.2; + } + } + + if( is_numeric($this->autoscale_max) ) { + $max = $this->autoscale_max; + if( $min >= $max ) { + JpGraphError::RaiseL(25072);//('You have specified a max value with SetAutoMax() which is smaller than the miminum value used for the scale. This is not possible.'); + } + if( abs($min-$max ) < 0.001 ) { + $min *= 0.8; + } + } + + $min -= $gracebottom; + $max += $gracetop; + + // First get tickmarks as multiples of 0.1, 1, 10, ... + if( $majend ) { + list($num1steps,$adj1min,$adj1max,$min1step,$maj1step) = $this->CalcTicks($maxsteps,$min,$max,1,2); + } + else { + $adj1min=$min; + $adj1max=$max; + list($num1steps,$min1step,$maj1step) = $this->CalcTicksFreeze($maxsteps,$min,$max,1,2,false); + } + + // Then get tick marks as 2:s 0.2, 2, 20, ... + if( $majend ) { + list($num2steps,$adj2min,$adj2max,$min2step,$maj2step) = $this->CalcTicks($maxsteps,$min,$max,5,2); + } + else { + $adj2min=$min; + $adj2max=$max; + list($num2steps,$min2step,$maj2step) = $this->CalcTicksFreeze($maxsteps,$min,$max,5,2,false); + } + + // Then get tickmarks as 5:s 0.05, 0.5, 5, 50, ... + if( $majend ) { + list($num5steps,$adj5min,$adj5max,$min5step,$maj5step) = $this->CalcTicks($maxsteps,$min,$max,2,5); + } + else { + $adj5min=$min; + $adj5max=$max; + list($num5steps,$min5step,$maj5step) = $this->CalcTicksFreeze($maxsteps,$min,$max,2,5,false); + } + + // Check to see whichof 1:s, 2:s or 5:s fit better with + // the requested number of major ticks + $match1=abs($num1steps-$maxsteps); + $match2=abs($num2steps-$maxsteps); + $match5=abs($num5steps-$maxsteps); + + // Compare these three values and see which is the closest match + // We use a 0.8 weight to gravitate towards multiple of 5:s + $r=$this->MatchMin3($match1,$match2,$match5,0.8); + switch( $r ) { + case 1: + $this->Update($img,$adj1min,$adj1max); + $this->ticks->Set($maj1step,$min1step); + break; + case 2: + $this->Update($img,$adj2min,$adj2max); + $this->ticks->Set($maj2step,$min2step); + break; + case 3: + $this->Update($img,$adj5min,$adj5max); + $this->ticks->Set($maj5step,$min5step); + break; + } + } + + //--------------- + // PRIVATE METHODS + + // This method recalculates all constants that are depending on the + // margins in the image. If the margins in the image are changed + // this method should be called for every scale that is registred with + // that image. Should really be installed as an observer of that image. + function InitConstants($img) { + if( $this->type=='x' ) { + $this->world_abs_size=$img->width - $img->left_margin - $img->right_margin; + $this->off=$img->left_margin; + $this->scale_factor = 0; + if( $this->world_size > 0 ) { + $this->scale_factor=$this->world_abs_size/($this->world_size*1.0); + } + } + else { // y scale + $this->world_abs_size=$img->height - $img->top_margin - $img->bottom_margin; + $this->off=$img->top_margin+$this->world_abs_size; + $this->scale_factor = 0; + if( $this->world_size > 0 ) { + $this->scale_factor=-$this->world_abs_size/($this->world_size*1.0); + } + } + $size = $this->world_size * $this->scale_factor; + $this->scale_abs=array($this->off,$this->off + $size); + } + + // Initialize the conversion constants for this scale + // This tries to pre-calculate as much as possible to speed up the + // actual conversion (with Translate()) later on + // $start =scale start in absolute pixels (for x-scale this is an y-position + // and for an y-scale this is an x-position + // $len =absolute length in pixels of scale + function SetConstants($aStart,$aLen) { + $this->world_abs_size=$aLen; + $this->off=$aStart; + + if( $this->world_size<=0 ) { + // This should never ever happen !! + JpGraphError::RaiseL(25074); + //("You have unfortunately stumbled upon a bug in JpGraph. It seems like the scale range is ".$this->world_size." [for ".$this->type." scale] <br> Please report Bug #01 to info@jpgraph.net and include the script that gave this error. This problem could potentially be caused by trying to use \"illegal\" values in the input data arrays (like trying to send in strings or only NULL values) which causes the autoscaling to fail."); + } + + // scale_factor = number of pixels per world unit + $this->scale_factor=$this->world_abs_size/($this->world_size*1.0); + + // scale_abs = start and end points of scale in absolute pixels + $this->scale_abs=array($this->off,$this->off+$this->world_size*$this->scale_factor); + } + + + // Calculate number of ticks steps with a specific division + // $a is the divisor of 10**x to generate the first maj tick intervall + // $a=1, $b=2 give major ticks with multiple of 10, ...,0.1,1,10,... + // $a=5, $b=2 give major ticks with multiple of 2:s ...,0.2,2,20,... + // $a=2, $b=5 give major ticks with multiple of 5:s ...,0.5,5,50,... + // We return a vector of + // [$numsteps,$adjmin,$adjmax,$minstep,$majstep] + // If $majend==true then the first and last marks on the axis will be major + // labeled tick marks otherwise it will be adjusted to the closest min tick mark + function CalcTicks($maxsteps,$min,$max,$a,$b,$majend=true) { + $diff=$max-$min; + if( $diff==0 ) { + $ld=0; + } + else { + $ld=floor(log10($diff)); + } + + // Gravitate min towards zero if we are close + if( $min>0 && $min < pow(10,$ld) ) $min=0; + + //$majstep=pow(10,$ld-1)/$a; + $majstep=pow(10,$ld)/$a; + $minstep=$majstep/$b; + + $adjmax=ceil($max/$minstep)*$minstep; + $adjmin=floor($min/$minstep)*$minstep; + $adjdiff = $adjmax-$adjmin; + $numsteps=$adjdiff/$majstep; + + while( $numsteps>$maxsteps ) { + $majstep=pow(10,$ld)/$a; + $numsteps=$adjdiff/$majstep; + ++$ld; + } + + $minstep=$majstep/$b; + $adjmin=floor($min/$minstep)*$minstep; + $adjdiff = $adjmax-$adjmin; + if( $majend ) { + $adjmin = floor($min/$majstep)*$majstep; + $adjdiff = $adjmax-$adjmin; + $adjmax = ceil($adjdiff/$majstep)*$majstep+$adjmin; + } + else { + $adjmax=ceil($max/$minstep)*$minstep; + } + + return array($numsteps,$adjmin,$adjmax,$minstep,$majstep); + } + + function CalcTicksFreeze($maxsteps,$min,$max,$a,$b) { + // Same as CalcTicks but don't adjust min/max values + $diff=$max-$min; + if( $diff==0 ) { + $ld=0; + } + else { + $ld=floor(log10($diff)); + } + + //$majstep=pow(10,$ld-1)/$a; + $majstep=pow(10,$ld)/$a; + $minstep=$majstep/$b; + $numsteps=floor($diff/$majstep); + + while( $numsteps > $maxsteps ) { + $majstep=pow(10,$ld)/$a; + $numsteps=floor($diff/$majstep); + ++$ld; + } + $minstep=$majstep/$b; + return array($numsteps,$minstep,$majstep); + } + + + function IntCalcTicks($maxsteps,$min,$max,$a,$majend=true) { + $diff=$max-$min; + if( $diff==0 ) { + JpGraphError::RaiseL(25075);//('Can\'t automatically determine ticks since min==max.'); + } + else { + $ld=floor(log10($diff)); + } + + // Gravitate min towards zero if we are close + if( $min>0 && $min < pow(10,$ld) ) { + $min=0; + } + if( $ld == 0 ) { + $ld=1; + } + if( $a == 1 ) { + $majstep = 1; + } + else { + $majstep=pow(10,$ld)/$a; + } + $adjmax=ceil($max/$majstep)*$majstep; + + $adjmin=floor($min/$majstep)*$majstep; + $adjdiff = $adjmax-$adjmin; + $numsteps=$adjdiff/$majstep; + while( $numsteps>$maxsteps ) { + $majstep=pow(10,$ld)/$a; + $numsteps=$adjdiff/$majstep; + ++$ld; + } + + $adjmin=floor($min/$majstep)*$majstep; + $adjdiff = $adjmax-$adjmin; + if( $majend ) { + $adjmin = floor($min/$majstep)*$majstep; + $adjdiff = $adjmax-$adjmin; + $adjmax = ceil($adjdiff/$majstep)*$majstep+$adjmin; + } + else { + $adjmax=ceil($max/$majstep)*$majstep; + } + + return array($numsteps,$adjmin,$adjmax,$majstep); + } + + + function IntCalcTicksFreeze($maxsteps,$min,$max,$a) { + // Same as IntCalcTick but don't change min/max values + $diff=$max-$min; + if( $diff==0 ) { + JpGraphError::RaiseL(25075);//('Can\'t automatically determine ticks since min==max.'); + } + else { + $ld=floor(log10($diff)); + } + if( $ld == 0 ) { + $ld=1; + } + if( $a == 1 ) { + $majstep = 1; + } + else { + $majstep=pow(10,$ld)/$a; + } + + $numsteps=floor($diff/$majstep); + while( $numsteps > $maxsteps ) { + $majstep=pow(10,$ld)/$a; + $numsteps=floor($diff/$majstep); + ++$ld; + } + + return array($numsteps,$majstep); + } + + // Determine the minimum of three values witha weight for last value + function MatchMin3($a,$b,$c,$weight) { + if( $a < $b ) { + if( $a < ($c*$weight) ) { + return 1; // $a smallest + } + else { + return 3; // $c smallest + } + } + elseif( $b < ($c*$weight) ) { + return 2; // $b smallest + } + return 3; // $c smallest + } + + function __get($name) { + $variable_name = '_' . $name; + + if (isset($this->$variable_name)) { + return $this->$variable_name * SUPERSAMPLING_SCALE; + } else { + JpGraphError::RaiseL('25132', $name); + } + } + + function __set($name, $value) { + $this->{'_'.$name} = $value; + } +} // Class + + +//=================================================== +// CLASS DisplayValue +// Description: Used to print data values at data points +//=================================================== +class DisplayValue { + public $margin=5; + public $show=false; + public $valign='',$halign='center'; + public $format='%.1f',$negformat=''; + private $ff=FF_DEFAULT,$fs=FS_NORMAL,$fsize=8; + private $iFormCallback=''; + private $angle=0; + private $color='navy',$negcolor=''; + private $iHideZero=false; + public $txt=null; + + function __construct() { + $this->txt = new Text(); + } + + function Show($aFlag=true) { + $this->show=$aFlag; + } + + function SetColor($aColor,$aNegcolor='') { + $this->color = $aColor; + $this->negcolor = $aNegcolor; + } + + function SetFont($aFontFamily,$aFontStyle=FS_NORMAL,$aFontSize=8) { + $this->ff=$aFontFamily; + $this->fs=$aFontStyle; + $this->fsize=$aFontSize; + } + + function ApplyFont($aImg) { + $aImg->SetFont($this->ff,$this->fs,$this->fsize); + } + + function SetMargin($aMargin) { + $this->margin = $aMargin; + } + + function SetAngle($aAngle) { + $this->angle = $aAngle; + } + + function SetAlign($aHAlign,$aVAlign='') { + $this->halign = $aHAlign; + $this->valign = $aVAlign; + } + + function SetFormat($aFormat,$aNegFormat='') { + $this->format= $aFormat; + $this->negformat= $aNegFormat; + } + + function SetFormatCallback($aFunc) { + $this->iFormCallback = $aFunc; + } + + function HideZero($aFlag=true) { + $this->iHideZero=$aFlag; + } + + function Stroke($img,$aVal,$x,$y) { + + if( $this->show ) + { + if( $this->negformat=='' ) { + $this->negformat=$this->format; + } + if( $this->negcolor=='' ) { + $this->negcolor=$this->color; + } + + if( $aVal===NULL || (is_string($aVal) && ($aVal=='' || $aVal=='-' || $aVal=='x' ) ) ) { + return; + } + + if( is_numeric($aVal) && $aVal==0 && $this->iHideZero ) { + return; + } + + // Since the value is used in different cirumstances we need to check what + // kind of formatting we shall use. For example, to display values in a line + // graph we simply display the formatted value, but in the case where the user + // has already specified a text string we don't fo anything. + if( $this->iFormCallback != '' ) { + $f = $this->iFormCallback; + $sval = call_user_func($f,$aVal); + } + elseif( is_numeric($aVal) ) { + if( $aVal >= 0 ) { + $sval=sprintf($this->format,$aVal); + } + else { + $sval=sprintf($this->negformat,$aVal); + } + } + else { + $sval=$aVal; + } + + $y = $y-sign($aVal)*$this->margin; + + $this->txt->Set($sval); + $this->txt->SetPos($x,$y); + $this->txt->SetFont($this->ff,$this->fs,$this->fsize); + if( $this->valign == '' ) { + if( $aVal >= 0 ) { + $valign = "bottom"; + } + else { + $valign = "top"; + } + } + else { + $valign = $this->valign; + } + $this->txt->Align($this->halign,$valign); + + $this->txt->SetOrientation($this->angle); + if( $aVal > 0 ) { + $this->txt->SetColor($this->color); + } + else { + $this->txt->SetColor($this->negcolor); + } + $this->txt->Stroke($img); + } + } +} + +//=================================================== +// CLASS Plot +// Description: Abstract base class for all concrete plot classes +//=================================================== +class Plot { + public $numpoints=0; + public $value; + public $legend=''; + public $coords=array(); + public $color='black'; + public $hidelegend=false; + public $line_weight=1; + public $csimtargets=array(),$csimwintargets=array(); // Array of targets for CSIM + public $csimareas=''; // Resultant CSIM area tags + public $csimalts=null; // ALT:s for corresponding target + public $legendcsimtarget='',$legendcsimwintarget=''; + public $legendcsimalt=''; + protected $weight=1; + protected $center=false; + + protected $inputValues; + protected $isRunningClear = false; + + function __construct($aDatay,$aDatax=false) { + $this->numpoints = count($aDatay); + if( $this->numpoints==0 ) { + JpGraphError::RaiseL(25121);//("Empty input data array specified for plot. Must have at least one data point."); + } + + if (!$this->isRunningClear) { + $this->inputValues = array(); + $this->inputValues['aDatay'] = $aDatay; + $this->inputValues['aDatax'] = $aDatax; + } + + $this->coords[0]=$aDatay; + if( is_array($aDatax) ) { + $this->coords[1]=$aDatax; + $n = count($aDatax); + for( $i=0; $i < $n; ++$i ) { + if( !is_numeric($aDatax[$i]) ) { + JpGraphError::RaiseL(25070); + } + } + } + $this->value = new DisplayValue(); + } + + // Stroke the plot + // "virtual" function which must be implemented by + // the subclasses + function Stroke($aImg,$aXScale,$aYScale) { + JpGraphError::RaiseL(25122);//("JpGraph: Stroke() must be implemented by concrete subclass to class Plot"); + } + + function HideLegend($f=true) { + $this->hidelegend = $f; + } + + function DoLegend($graph) { + if( !$this->hidelegend ) + $this->Legend($graph); + } + + function StrokeDataValue($img,$aVal,$x,$y) { + $this->value->Stroke($img,$aVal,$x,$y); + } + + // Set href targets for CSIM + function SetCSIMTargets($aTargets,$aAlts='',$aWinTargets='') { + $this->csimtargets=$aTargets; + $this->csimwintargets=$aWinTargets; + $this->csimalts=$aAlts; + } + + // Get all created areas + function GetCSIMareas() { + return $this->csimareas; + } + + // "Virtual" function which gets called before any scale + // or axis are stroked used to do any plot specific adjustment + function PreStrokeAdjust($aGraph) { + if( substr($aGraph->axtype,0,4) == "text" && (isset($this->coords[1])) ) { + JpGraphError::RaiseL(25123);//("JpGraph: You can't use a text X-scale with specified X-coords. Use a \"int\" or \"lin\" scale instead."); + } + return true; + } + + // Virtual function to the the concrete plot class to make any changes to the graph + // and scale before the stroke process begins + function PreScaleSetup($aGraph) { + // Empty + } + + // Get minimum values in plot + function Min() { + if( isset($this->coords[1]) ) { + $x=$this->coords[1]; + } + else { + $x=''; + } + if( $x != '' && count($x) > 0 ) { + $xm=min($x); + } + else { + $xm=0; + } + $y=$this->coords[0]; + $cnt = count($y); + if( $cnt > 0 ) { + $i=0; + while( $i<$cnt && !is_numeric($ym=$y[$i]) ) { + $i++; + } + while( $i < $cnt) { + if( is_numeric($y[$i]) ) { + $ym=min($ym,$y[$i]); + } + ++$i; + } + } + else { + $ym=''; + } + return array($xm,$ym); + } + + // Get maximum value in plot + function Max() { + if( isset($this->coords[1]) ) { + $x=$this->coords[1]; + } + else { + $x=''; + } + + if( $x!='' && count($x) > 0 ) { + $xm=max($x); + } + else { + $xm = $this->numpoints-1; + } + $y=$this->coords[0]; + if( count($y) > 0 ) { + $cnt = count($y); + $i=0; + while( $i<$cnt && !is_numeric($ym=$y[$i]) ) { + $i++; + } + while( $i < $cnt ) { + if( is_numeric($y[$i]) ) { + $ym=max($ym,$y[$i]); + } + ++$i; + } + } + else { + $ym=''; + } + return array($xm,$ym); + } + + function SetColor($aColor) { + $this->color=$aColor; + } + + function SetLegend($aLegend,$aCSIM='',$aCSIMAlt='',$aCSIMWinTarget='') { + $this->legend = $aLegend; + $this->legendcsimtarget = $aCSIM; + $this->legendcsimwintarget = $aCSIMWinTarget; + $this->legendcsimalt = $aCSIMAlt; + } + + function SetWeight($aWeight) { + $this->weight=$aWeight; + } + + function SetLineWeight($aWeight=1) { + $this->line_weight=$aWeight; + } + + function SetCenter($aCenter=true) { + $this->center = $aCenter; + } + + // This method gets called by Graph class to plot anything that should go + // into the margin after the margin color has been set. + function StrokeMargin($aImg) { + return true; + } + + // Framework function the chance for each plot class to set a legend + function Legend($aGraph) { + if( $this->legend != '' ) { + $aGraph->legend->Add($this->legend,$this->color,'',0,$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + } + + function Clear() { + $this->isRunningClear = true; + $this->__construct($this->inputValues['aDatay'], $this->inputValues['aDatax']); + $this->isRunningClear = false; + } + +} // Class + + +// Provide a deterministic list of new colors whenever the getColor() method +// is called. Used to automatically set colors of plots. +class ColorFactory { + + static private $iIdx = 0; + static private $iColorList = array( + 'black', + 'blue', + 'orange', + 'darkgreen', + 'red', + 'AntiqueWhite3', + 'aquamarine3', + 'azure4', + 'brown', + 'cadetblue3', + 'chartreuse4', + 'chocolate', + 'darkblue', + 'darkgoldenrod3', + 'darkorchid3', + 'darksalmon', + 'darkseagreen4', + 'deepskyblue2', + 'dodgerblue4', + 'gold3', + 'hotpink', + 'lawngreen', + 'lightcoral', + 'lightpink3', + 'lightseagreen', + 'lightslateblue', + 'mediumpurple', + 'olivedrab', + 'orangered1', + 'peru', + 'slategray', + 'yellow4', + 'springgreen2'); + static private $iNum = 33; + + static function getColor() { + if( ColorFactory::$iIdx >= ColorFactory::$iNum ) + ColorFactory::$iIdx = 0; + return ColorFactory::$iColorList[ColorFactory::$iIdx++]; + } + +} + +// <EOF> +?> diff --git a/html/jpgraph/jpgraph_antispam-digits.php b/html/jpgraph/jpgraph_antispam-digits.php new file mode 100644 index 0000000..d9d350c --- /dev/null +++ b/html/jpgraph/jpgraph_antispam-digits.php @@ -0,0 +1,205 @@ +<?php +//======================================================================= +// File: JPGRAPH_ANTISPAM.PHP +// Description: Genarate anti-spam challenge +// Created: 2004-10-07 +// Ver: $Id: jpgraph_antispam-digits.php 1930 2010-01-22 20:19:27Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +class HandDigits { + public $digits = array(); + public $iHeight=30, $iWidth=30; + + function __construct() { + //========================================================== + // d6-small.jpg + //========================================================== + $this->digits['6'][0]= 645 ; + $this->digits['6'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAEBAAMBAAAAAAAAAAAAAAAABgMEBwX/xAAvEAABAwMC'. + 'BAQEBwAAAAAAAAABAgMEAAURBiESIjFRBxMUQRUWMmFTYnGRkrHC/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFhEBAQEAAAAA'. + 'AAAAAAAAAAAAAAER/9oADAMBAAIRAxEAPwDslwiR3oDku8ONttsAvDiVyMcO/ET7ke5/aoOz6k1Vr5htNjW7a7M1yO3NTQU9JUDu'. + 'GgrlSn8xyf6p4gXaHJvNps9/mKZtSkGdMjRwpfqAFBLLACRlZUrJONsI2717No1lbZ10kx7XGnRpKWQ/6GVGMfzEJ5VFIVtsOH6e'. + 'wyKVhYsia0y22pLThSkJK1uniVgdThOM0ol+StIUhpopIyCFq3H8aUVCwnG3PGe4Rp6fLXJtMdyM0ojcIWvIz3HFnAPfrWTXb6GN'. + 'WaLXDwZjVz8pKEfhuIUFg/bAz9sVJ61nt61mxJFslLtq7e5yPqiBT4UDklKw4MDpt+u+9bFiu9riXNu83R+fcr6tohuQ5HQhmK37'. + 'paaC8DruScmg6X8KkjZEhbaB9KEyFYSOw26Uqd+e7Qerl5z74DY/1SomP//Z' ; + + //========================================================== + // d2-small.jpg + //========================================================== + $this->digits['2'][0]= 606 ; + $this->digits['2'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEQMBIgACEQEDEQH/xAAYAAEBAQEBAAAAAAAAAAAAAAAFAAQHAv/EACsQAAEDBAEC'. + 'BAYDAAAAAAAAAAIBAwQABQYRIRIxQVFhcQcTFSJSU5GU0f/EABcBAAMBAAAAAAAAAAAAAAAAAAECAwT/xAAZEQACAwEAAAAAAAAA'. + 'AAAAAAAAARESUUH/2gAMAwEAAhEDEQA/AOqXm/Q8dxmOL4PPSnCSNFixx6nXnkXgRT3Te17JWbGsveueSyLZdbPItNxOKLzTLjou'. + 'gYCSoSoY8ISKSbFeUrzkdlnTL1YshskiErkQnFEZaF8kkdBBVdjyi6RNL5+9F486eS/ECVkcBtDt1vZcho5viS8ZCp9C9tAIAm/F'. + 'VoPRU+HRtJ5JVRP1kP0PfwP+1VKrHBMliXG4Nw8VgE4xGkuqk2S1wTUNEVdIvgpL9iL6KtNxY7WOwo9tt0RCitj0sR2uCbFPPzH1'. + '7+6rRuSRcljMBMsUy2tky045KOawZk5xtEFBJEROO3hx61kh2rPCIX3MhsyC4QmfTbC6lH8dq5212qwkiG5H6Y/9R2qm+ofxqqsL'. + 'DLZ6f//Z' ; + + //========================================================== + // d9-small.jpg + //========================================================== + $this->digits['9'][0]= 680 ; + $this->digits['9'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwP/xAArEAABAwMD'. + 'AgYBBQAAAAAAAAABAgMEBQYRABIhE1EUIjEzQUIHMlJhcdH/xAAWAQEBAQAAAAAAAAAAAAAAAAACAQD/xAAYEQEAAwEAAAAAAAAA'. + 'AAAAAAAAAREhQf/aAAwDAQACEQMRAD8AkK7brF6X7XpMeGoKhFMLEeT4ZUheEhanF4OcZ2pTgDykk92bZpdCsi7aezLjxkIPUZiV'. + 'RSCy8hah7EkZ27yM7V+iscal5bE22Lon1qNDmSKROd8Sl+Ix1lMOlIS4HGgQpbStoUCnlJz8HmsXtW3Lst2rmBAelLMRRekOwnYz'. + 'Edls9QKKnOVLyk7UgcbzzrdBthqEJJwZbAI4x1U/7o1TaFa9lG36aXaZTy54VrcXUgrzsGdx+T30aNydweqVw1GS87T6Lb86Q4ha'. + 'my/IAYjZBx+snKk99oOQMf1AViE65SY348hzFy6hPKnqtKz7DC1lbqyPrvJKUJ7H+M6Wrt3InP7o1brFNp4bCDGhxGAsqz69VSiQ'. + 'ORwBxrrQ7itm1ac7Hp0WoGTIc3PSn0pccdcP2WorycfA1RaRHjxosZqOyhtDTSAhCf2gDAGjVHTd9sKSCumynFEZK1tIJUe58/ro'. + '1V1//9k=' ; + + //========================================================== + // d5-small.jpg + //========================================================== + $this->digits['5'][0]= 632 ; + $this->digits['5'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgIFBwT/xAAoEAABAwME'. + 'AQQCAwAAAAAAAAABAgMEBQYRABIhIkEUMVFhBxNCgaH/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAv/EABcRAQEBAQAAAAAAAAAAAAAA'. + 'AAABEUH/2gAMAwEAAhEDEQA/ANGvW4YVOeiRX5b4mv5Sin05IdlupPKdo/j2SO3+6TbPNQvOsTVz33KRT4csR3YUF7Dsh5OSFvug'. + 'kqG4FPBxnjxpvvi4KZb1pTpU+QwxUi2Y7ZIAefUk5ATxnB9/gbtL/wCH1UpuhPUlZlMVaQ0mS8zJjqZOPfc2TwpIUonI9tw40R1r'. + 'WNGq/wBdJR1XT3lqHBUnGCfkfWjRWs1ve249erQqQYjOtN1FqPUpCXQ4WIzQSsJwT0UpRwQPG0nzqyuNHobjsl9kBuWqoOoXtT1/'. + 'WppZcA8lKRj64HxqU+3KpAr6plElRVKef3S4E0K9O8pLXVzKcqSsJAB9wSAca6bSoNXeuA1+5pEV+SGFNU1iKVFqI0Vdx2AJUeoz'. + '8DGlTDwG3CAf3q/pI0ah6MDhLz6U+EpXwPoaNMU//9k=' ; + + //========================================================== + // d1-small.jpg + //========================================================== + $this->digits['1'][0]= 646 ; + $this->digits['1'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEwMBIgACEQEDEQH/xAAZAAADAAMAAAAAAAAAAAAAAAAABQYCBAf/xAApEAACAQMD'. + 'AwQBBQAAAAAAAAABAgMEBREABiESMUEHEyJRkSNCYXGB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFxEBAQEBAAAAAAAAAAAA'. + 'AAAAAAEREv/aAAwDAQACEQMRAD8A6jdd4WLbstILnc4Uq0VoWpkJknb6IjXLHJUePOlez923fcW4r1SxWlqC2UbdKirQif3Xw3yA'. + 'OFAGT09/kO3OmV3a20MFRf6lIYPcpy7yRRAzgxjIy2M8YwcdiBzpX6d22VNvUlTXsFkuwkrKqNSfnK7F8OTzwrAY+l5zoxKskudN'. + 'EgQPUT9PBkWF3DH+1GPxo1mLnRoAqF2VRgGOFmX/AAgY/GjRUP6hVMFv2FuFqUvUGrpDFJMBnpdyF5bsAQew7Hxzp6LZNT0yQ1DI'. + 'wp0QCFBhD0jCsfLZHxbx5xxpTuvb1+v9PV7Ztk9roLPLCjmSSN3mX5ZwqjCgZX7PfWxDQb2in96pv9qq46aTE0bW4x9ceAWAYPwS'. + 'PsYzoixgmheBGjIVcYCnjp/jHjHbRpe1JLn9OnopE/a0ykvjwDx47aNMXqP/2Q==' ; + + //========================================================== + // d8-small.jpg + //========================================================== + $this->digits['8'][0]= 694 ; + $this->digits['8'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AFQMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABgcEBf/EACsQAAEDAwMD'. + 'AwMFAAAAAAAAAAECAwQFBhEAEiEUMVEHE0EVYYEiIzJCsf/EABYBAQEBAAAAAAAAAAAAAAAAAAIAAf/EABcRAQEBAQAAAAAAAAAA'. + 'AAAAAAABERL/2gAMAwEAAhEDEQA/AKL6gVVUa0i1T5QjvTprUJMlxW4R9zgQXe/AH+kaWrntqlWjaq7gpcmotXAw82ht9yY4tch8'. + 'uAFC0k7VBXPGMY51ruiaue+bThIj+7NbWqS+7HDxajFf6AlB/k44o8ZOABk4xkL0X0tZiojKrlRuGRJjugqldSlKGf6t7BuUQe3J'. + '44xxxrA1a4KVJipLidri8uLHgqOcfjOPxo0o2hdDvS1CmV2Yl6fS5ioipIQR1CAlKkLKR2UUqAI8g6NRSwuuyHab6s1ufLI/Zai7'. + 'UBJOxhTS0+6B32pWSFH4CidOdWU0ukLiN1BLr0zG5Sdm3GRvcPhIT858DvjXNrVsSLnm/VIdTXS6tTnFsxZTSN3jchaTwps+O/z9'. + 'tcBVq3hIX0tYqlIiQHdy5CqRHKHXEjAOMgBKjnvyRk4xrQa7OiGt1K5biYZL8SoVEpjOqkFsONtJCNwASeCQrn7aNUKnQYtLp7EC'. + 'EylmLHQltptPZKQOBo1FzH//2Q==' ; + + //========================================================== + // d4-small.jpg + //========================================================== + $this->digits['4'][0]= 643 ; + $this->digits['4'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABAYHAv/EAC0QAAIBAwQA'. + 'BAMJAAAAAAAAAAECAwQFEQAGEiETFDFBUmGBByIjUVNxobHR/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAIB/8QAGBEBAAMBAAAAAAAA'. + 'AAAAAAAAAAERIVH/2gAMAwEAAhEDEQA/ANjM00Nxmt1xiWW31CZp5uJwoAAaOQ/n7qfcZHqO5my3q5XX7R6ijiqnNut9u4NyJ4yv'. + 'JJyjYr8Xhrn5g599J7x3ulBNU7Zo7dXXXcLQ8kURYi4epYtkALjOePv1nUvbLvV7P3BZm3DR3eh88Kp7pVzBZI6iUhGWRRGWwE44'. + 'HX3V+uiL1uHgt+vL/H+aNJQ3CSeCOaFqSaJ1DJKs/TqRkMOvQjvRorHE4pRDLNWLGlRHGUeYIORXs9e5B7OP31E0fmdyb/t0DJ4Q'. + '27bfx3YZzPUIoAAz7IpOD6cuxq0uNumqLfVNDOqXBoZEjnZcqhIPXH4c46+WkdoWOltu3IDDLLLVVR83UVcuPEmmcZZ2/rHoAANG'. + 'GI7KIY1ijoLeEQBVCwIoAHpgY6Hy0aZe7mJ2jeHLKcEhusj6aNKgzr//2Q==' ; + + //========================================================== + // d7-small.jpg + //========================================================== + $this->digits['7'][0]= 658 ; + $this->digits['7'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgEFBwT/xAAuEAABAwIE'. + 'BAQGAwAAAAAAAAABAgMEBREABiExEhMiQSMyUXEHFBclVJFhk9L/xAAXAQADAQAAAAAAAAAAAAAAAAAAAQID/8QAGREBAQEAAwAA'. + 'AAAAAAAAAAAAAAEREiFR/9oADAMBAAIRAxEAPwDXq9mCjZeQ05VZ5ZST4bfEpa3VdglCbqUe+g9MZ5Uq7V8415WXoMSdQ6etgSps'. + '19wpkCMDZKUpv0FZvbi1NzpYasMDLDUbMVXrtQdbeeU23xLWkj5RlLYK0J7anW9gbAjCzkOtsVSUJUdtc6dVZK51UeaFm4LKbhpC'. + 'l7EhIFkDW974GbRI2XorUVls1OTdKAOqUpR0Hc3198GITQ6k+hLwrEpoODiDenRfW23bBicg78JXxPpD0mgVOW5PAivNNpahsPW5'. + '8xxQaSVkboQnhsnYm5OHqDGp1IpsalMKjMsMIC3+XZKbJFth62/QOEfMOZqZXp9JcKZTcGmTky3meSi7xQklI81vMR+sXIz/AEgp'. + 'Q0qPNu6ea8Q2jqtbp8+2w9h/OKORc/cpHjt1dDSHOtLZ4ekHW23bBjj+o9H/AB539aP94MG0+L//2Q==' ; + + //========================================================== + // d3-small.jpg + //========================================================== + $this->digits['3'][0]= 662 ; + $this->digits['3'][1]= + '/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. + 'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. + 'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwL/xAArEAABBAED'. + 'AwMDBQEAAAAAAAABAgMEBREABhIhMUEiMmETFZEHFkJDUdH/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/xAAYEQEBAQEBAAAAAAAA'. + 'AAAAAAAAEQExQf/aAAwDAQACEQMRAD8A0vclruBdk3VVLLUNssGRJsZSCtqOjlgJAHvcOD6c4HnOdIbcttw1W5P29cFEhuawqTXS'. + 'VsJjnCMBxKkJJx7goAde+ceJfdNxU0UNlyymyXHi6kxWUNl1S3EnkAEIHX2nv86qtTuZr9Q9+1VhRsOoYpYcgSVyAE/TdewkJxnK'. + 'sBCjkdPGpnOtFMd3PqsXgfOAgD8Y0aX+11H9rDDjn8lr9yj5J+dGqsqxaw6Cc9cQZU4Sp7zTJsIrKlcUEKwhSin1JABI45GUjqOu'. + 'lbOvjbc3Ts9ynjGCy445UuFLYRzbWgrT6fhSCQSMDke+pew2zYVly/d7YchNqkMJZnQpgV9J8IzwWFJyUrAJHYgjvpLbu37G5nR7'. + 'vck5C3YRKYEOEVJZj8kjKypXqWvirjk9h+dB9i4faa89TDZUfKlIyT8k+To10a6KTkpcJ/0vL/7o0TS//9k=' ; + } +} + +class AntiSpam { + + private $iNumber=''; + + function __construct($aNumber='') { + $this->iNumber = $aNumber; + } + + function Rand($aLen) { + $d=''; + for($i=0; $i < $aLen; ++$i) { + $d .= rand(1,9); + } + $this->iNumber = $d; + return $d; + } + + function Stroke() { + + $n=strlen($this->iNumber); + for($i=0; $i < $n; ++$i ) { + if( !is_numeric($this->iNumber[$i]) || $this->iNumber[$i]==0 ) { + return false; + } + } + + $dd = new HandDigits(); + $n = strlen($this->iNumber); + $img = @imagecreatetruecolor($n*$dd->iWidth, $dd->iHeight); + if( $img < 1 ) { + return false; + } + $start=0; + for($i=0; $i < $n; ++$i ) { + $size = $dd->digits[$this->iNumber[$i]][0]; + $dimg = imagecreatefromstring(base64_decode($dd->digits[$this->iNumber[$i]][1])); + imagecopy($img,$dimg,$start,0,0,0,imagesx($dimg), $dd->iHeight); + $start += imagesx($dimg); + } + $resimg = @imagecreatetruecolor($start+4, $dd->iHeight+4); + if( $resimg < 1 ) { + return false; + } + imagecopy($resimg,$img,2,2,0,0,$start, $dd->iHeight); + header("Content-type: image/jpeg"); + imagejpeg($resimg); + return true; + } +} + +?> diff --git a/html/jpgraph/jpgraph_antispam.php b/html/jpgraph/jpgraph_antispam.php new file mode 100644 index 0000000..7998df2 --- /dev/null +++ b/html/jpgraph/jpgraph_antispam.php @@ -0,0 +1,615 @@ +<?php +//======================================================================= +// File: JPGRAPH_ANTISPAM.PHP +// Description: Genarate anti-spam challenge +// Created: 2004-10-07 +// Ver: $Id: jpgraph_antispam.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +class HandDigits { + public $chars = array(); + public $iHeight=30, $iWidth=30; + + function __construct() { + + //========================================================== + // lj-small.jpg + //========================================================== + $this->chars['j'][0]= 658 ; + $this->chars['j'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAUGBAf/xAAsEAACAQMDAwMBCQAAAAAAAAAB'. +'AgMEBREAEjEGIUEUUXGBBxMVIiNSYWKC/8QAFgEBAQEAAAAAAAAAAAAAAAAAAwEC/8QAGhEAAwADAQAAAAAAAAAAAAAAAAECERIh'. +'Mv/aAAwDAQACEQMRAD8A6veK2st8zRWSyV1dUBfvHaGVI4hknsS7AFv4AyM57ayWbqeS+11xtT2etttwo4YqhEqnQs5bcAfyk4AZ'. +'SOeD441TKRTyingUBG4/ah8j684+dSFzh/BvtaslejMUu9DPQTDnLx4lQ/ONw1TGBm0jdRWqguEMghEisWilgDmNs4Ze+MEEEH40'. +'aUVFTa7JeLjRXu4GjhmnNbSfqFQVlA3rkckOjH/Q99Glmkl0C/Q06pvsvT9vttXHDF6T1KrWbs5gRgQJM+FDlQxPhjpF1XcVq+qe'. +'jEoKiOecXBqh2TDDYIXLKuP6549xk8auI6aJqV45oknWdNswkAIkGMYIxjGO2NR1F0LZY5qkWqkS1xrM0M8lMSJpY+TGrnJiQ577'. +'cEgeNHhi7D3qC3UN69M8tIakRhgrh9o748+eNGtcCiKjjpkQKlMTEg3ZwoxtHHtgfTRpYXArvp//2Q==' ; + + //========================================================== + // lf-small.jpg + //========================================================== + $this->chars['f'][0]= 633 ; + $this->chars['f'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQFBgcC/8QAKxAAAgEDAwMCBQUAAAAAAAAA'. +'AQIDBBEhAAUGEjFBEyIHFFFhoRUzYnGS/8QAFQEBAQAAAAAAAAAAAAAAAAAAAQP/xAAaEQACAwEBAAAAAAAAAAAAAAAAAQIRMRIh'. +'/9oADAMBAAIRAxEAPwDcnmLoIkiSYsouC3tA++O2lU9WkqVjJ+YdhZLsQI/4/YfQm50kZP0vbmaCSU0SRNIH6sghb9INs3t38dvp'. +'akUuz8x5DwdN5peS1jV1dSipSiVUigIcdQjQ26lIB/c6r3F86SZpE/zCFJaqsihQNhRgdj3Jyfxo0jDSbXHt9Oph9RAoV3qJGltY'. +'HDOxyb/nRpV0D3RXle21m48XraOk3IUSemUaV4g4Zc9ShcDtgff+tQfwvjq34Dtku7buamFqeJKemCCMxKFsEJU+/FrX8d76sEHG'. +'aNItzr4usVNdG3S0rmRYAVwEUmyjyQLZ11x7aF4zs9DQOyzml29I2cLa/pixIHi99DFCtU9dFuLIaijo9qiYPmR2mZmB9thgAHOD'. +'4+mjUrURyrUNMZFEkkIOFuFAbsP9d/OjVIQ6Vh4tP//Z' ; + + //========================================================== + // lb-small.jpg + //========================================================== + $this->chars['b'][0]= 645 ; + $this->chars['b'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAYCAwUH/8QAKxAAAQMDAwMDAwUAAAAAAAAA'. +'AQIDBAAFEQYSIRMxUSJBYQcVI2JxgqHw/8QAFQEBAQAAAAAAAAAAAAAAAAAAAQL/xAAYEQEBAQEBAAAAAAAAAAAAAAAAATERYf/a'. +'AAwDAQACEQMRAD8A6H95mxNYwLXcX+pCuilSLXJ6YSplaUELjqxwe4IJ5PIPamJ2V0bPcS7+NxCX1cHggAnIP+xSd9RyzHh2m7FQ'. +'Q1CvMNQWTjCt+HFD+PB/Y1fI1PL1HFFt0zaGblFdJQ9cJjpZiqPJUlBAKnPcEpGB5NNRKdrOl1NlgiQol4R2w4Sc5VtGf7opZteo'. +'LhdorjUSM5FnQnlR50NeHQysYxtVxlJHIPgjtRRD3xkaghs6juumdHz4+Y7RVPnt59K2mk7W+fcKWsZ7djTXMkW+xMP3GRJjwIEN'. +'HTG/CWx5wPY8AADx2NYk3SL9wukvUjGobnBkORksIbjdMANozgEqSo8qJPGO/wAVO36IsjUmBIfZfuM7epZk3F9UhSSk5O0K9Kcq'. +'8AcU3UzFuhUSBFud6nRXoz96mqmJZWg7m2dqUNhWBwdqQSP1UU5c/FFCn//Z' ; + + //========================================================== + // d6-small.jpg + //========================================================== + $this->chars['6'][0]= 645 ; + $this->chars['6'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAEBAAMBAAAAAAAAAAAAAAAABgMEBwX/xAAvEAABAwMC'. +'BAQEBwAAAAAAAAABAgMEAAURBiESIjFRBxMUQRUWMmFTYnGRkrHC/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFhEBAQEAAAAA'. +'AAAAAAAAAAAAAAER/9oADAMBAAIRAxEAPwDslwiR3oDku8ONttsAvDiVyMcO/ET7ke5/aoOz6k1Vr5htNjW7a7M1yO3NTQU9JUDu'. +'GgrlSn8xyf6p4gXaHJvNps9/mKZtSkGdMjRwpfqAFBLLACRlZUrJONsI2717No1lbZ10kx7XGnRpKWQ/6GVGMfzEJ5VFIVtsOH6e'. +'wyKVhYsia0y22pLThSkJK1uniVgdThOM0ol+StIUhpopIyCFq3H8aUVCwnG3PGe4Rp6fLXJtMdyM0ojcIWvIz3HFnAPfrWTXb6GN'. +'WaLXDwZjVz8pKEfhuIUFg/bAz9sVJ61nt61mxJFslLtq7e5yPqiBT4UDklKw4MDpt+u+9bFiu9riXNu83R+fcr6tohuQ5HQhmK37'. +'paaC8DruScmg6X8KkjZEhbaB9KEyFYSOw26Uqd+e7Qerl5z74DY/1SomP//Z' ; + + //========================================================== + // lx-small.jpg + //========================================================== + $this->chars['x'][0]= 650 ; + $this->chars['x'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABMDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAUHBgj/xAApEAABAwMDAwQCAwAAAAAAAAAB'. +'AgMEBQYRACFBBxIxFCJRgRNxkcHw/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/xAAWEQEBAQAAAAAAAAAAAAAAAAAAEQH/2gAMAwEA'. +'AhEDEQA/AH9t3pKvO14UykVARa/HfAlxlDKXR24V2p3z7RlPwdtMep91uWdRGHWELjuTFFtLvcC4SNznnH+21O7ttiodOq1BvC0E'. +'p9I0lSX2kgqCSklK+5PKCMAng6zV2XRO6u3lSIURtbDRShltlZHa0tW7q/0MeTwnjxq1Jiw2xc9xTLbhSVU5iaXUFfqFFILgJOCd'. +'9Gt3SXabR6REpkL8yo0RpLCFNx1qBCRjOQMHxo0pEr6o3um2LVYpMEpTVqg25lHn08dfcB9kEgfZ1LIFDuawqZRb7aQlLTzqglsg'. +'9wQdveOEqBIB425xqhQuk8qo9UKlPrlRblw2ZBeCSVKW6CcoSrI2AGOT41SKzT4dYtmdS5bIXDZhNoWgbZJ94x8AYT/GkM03oNUc'. +'uKgwqtTZDTMOU0FttqRkoHggnPkEEHRrkJ6t1SlSHYUOc6zHaWrsbQrATk5/vRqK/9k=' ; + + //========================================================== + // d2-small.jpg + //========================================================== + $this->chars['2'][0]= 606 ; + $this->chars['2'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEQMBIgACEQEDEQH/xAAYAAEBAQEBAAAAAAAAAAAAAAAFAAQHAv/EACsQAAEDBAEC'. +'BAYDAAAAAAAAAAIBAwQABQYRIRIxQVFhcQcTFSJSU5GU0f/EABcBAAMBAAAAAAAAAAAAAAAAAAECAwT/xAAZEQACAwEAAAAAAAAA'. +'AAAAAAAAARESUUH/2gAMAwEAAhEDEQA/AOqXm/Q8dxmOL4PPSnCSNFixx6nXnkXgRT3Te17JWbGsveueSyLZdbPItNxOKLzTLjou'. +'gYCSoSoY8ISKSbFeUrzkdlnTL1YshskiErkQnFEZaF8kkdBBVdjyi6RNL5+9F486eS/ECVkcBtDt1vZcho5viS8ZCp9C9tAIAm/F'. +'VoPRU+HRtJ5JVRP1kP0PfwP+1VKrHBMliXG4Nw8VgE4xGkuqk2S1wTUNEVdIvgpL9iL6KtNxY7WOwo9tt0RCitj0sR2uCbFPPzH1'. +'7+6rRuSRcljMBMsUy2tky045KOawZk5xtEFBJEROO3hx61kh2rPCIX3MhsyC4QmfTbC6lH8dq5212qwkiG5H6Y/9R2qm+ofxqqsL'. +'DLZ6f//Z' ; + + //========================================================== + // lm-small.jpg + //========================================================== + $this->chars['m'][0]= 649 ; + $this->chars['m'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAAcDBAUCBv/EAC0QAAICAQMCBAMJAAAAAAAA'. +'AAECAwQRAAUSBiETMVFhB2KhFSIyQVJxgZHB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAgED/8QAGREBAQEAAwAAAAAAAAAAAAAAAQAR'. +'EiEx/9oADAMBAAIRAxEAPwB0MI2lIdgI0Cly3kFXLEn2zx1FDdp7rbpbjUtRWKio3hyxOGQllJzkegX66rQ2qW87Zuk9S5FNVmru'. +'iywyBhjDKTkeXfSr+GRfYtq2KAO32b1BGxAZu0dyJ2DKPTxY1wPddVszycUq2Golq8jRWbcnJWwCVGMjz+VQP50atxMtm2ZUOY4l'. +'4qfUnBP0x/Z0amy4jJm10Tt2yddWasFmfaRfdrlG3UcgArnxKzJ+Fu4DqCMkcgNem2DoWav8PLfTm+FPEkuSNTnqueS5bnHIv6CG'. +'LNjJwM99bm67NB1Ht89KSxNXnr2hNDbiUc47K4KyD2GQMfmMjUnS+7vuIktTqPCaaWCqAMMojPFyw8hyYMQBnAwNJHYGXPTsW9VN'. +'jg2zf50W9zk524GAEihuz+xbIOD82jW5TkjtRPZkTkJ+4VgDhQfuj/f3OjUxl1f/2Q==' ; + + //========================================================== + // lt-small.jpg + //========================================================== + $this->chars['t'][0]= 648 ; + $this->chars['t'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQDBQYH/8QAJxAAAQMDAgYDAQEAAAAAAAAA'. +'AQIDBAUGEQASEyExQVFhIjJxFSP/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAP/xAAZEQADAQEBAAAAAAAAAAAAAAAAAREhMUH/2gAM'. +'AwEAAhEDEQA/AO4BLEiEy7uG4IGxxs5IOOx76wd2XYidSp1HoD70240gcNNPbDyI6wQQpaz8E9MczkdhqtbsKYLieDk6WLKmZmmL'. +'Hk7AHVkbkLI+RQc7uRxgkfr1tx2rGu6VbToLVKkhU+kbugGf9WfaknCk5ycaX0zmaa+3JkqvW/CmzojsB9xoF6OoFK0r6HOcEDI0'. +'aefTuKX5ScMdC14HYq8n12zo1DEUcKTGg1Z+hyBwoPBVIiA/VQyOIgedhUCB4WMfXSV3UufVLcTUIqVf26K6mXDbPVRRzKT54iMg'. +'+zjtq6mtsyJjclxpKlUhSXEbkgkqWnBx4+J5e/zU0pZemPvJJQzEPDfQOrwwFY9AZ5eeYPLV6FwhoFYZuigxpkJeIjqAeIoAk9wA'. +'D46EnuD+6Nc1smDNrTlRkxqtMo1vzKhIdYgU9YDqVpISrLhHxSSd21I0aYyqP//Z' ; + + //========================================================== + // li-small.jpg + //========================================================== + $this->chars['i'][0]= 639 ; + $this->chars['i'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABYDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAABwAGBP/EACcQAAEEAQMEAgIDAAAAAAAAAAEC'. +'AwQRBQAGEiExQVEHExSBFWFx/8QAFgEBAQEAAAAAAAAAAAAAAAAAAgMB/8QAGBEBAQEBAQAAAAAAAAAAAAAAAAECMRH/2gAMAwEA'. +'AhEDEQA/AE7c+5M9BeRG29t1WUfKFFYW+GvrI7WD3B9g140YD5T36rcErDjbUR6dCBdejsKUpxITXI2FUrooCh70yvxzHyIlMvuK'. +'eVSH7IKEpJoKqu/ahddLryR/aMiO187bsmrWShhp1AZS2XHHrWhNJrzdf7f7GiVcHk3sptmHkJcJ2DIftS2FrKlJPXudWuLGYeQp'. +'t2fmEIckqIZaaKuSGG0lQ4gduRoFRHQ9AOgs2lOJbk9aSUlpjGvAWeSVH2VKq/2dFPw3IjyJe8s281ct3I9UoHJXGiQkD2STrSZ7'. +'Yf8AOl7JTdw5eOCz0jw3+LbYCfA9nz71msb8KMxoTGTw+5srjsipAdDqFBQBIuiOl6KrdYyJMyTCshlw2G3Fr/HiNqNNAqJJUoGl'. +'KND+h47km1bZwsvCbYYjycxIyK1qDv2yEi0hQviK8atKDcy9j//Z' ; + + + //========================================================== + // lp-small.jpg + //========================================================== + $this->chars['p'][0]= 700 ; + $this->chars['p'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGgAAAQUBAAAAAAAAAAAAAAAAAAECBAUGB//EAC8QAAEDAwMCBAMJAAAAAAAA'. +'AAECAwQFESEABhIiMRMVUWEHFEEWIzIzcYGRocH/xAAWAQEBAQAAAAAAAAAAAAAAAAADAgH/xAAcEQACAgIDAAAAAAAAAAAAAAAA'. +'AQIxAxESIUH/2gAMAwEAAhEDEQA/AOh703xG21DMeOyqoVNDjSzERiwU6Ep5qtZNycA97HTF13d33KWtmlt9xwkLl1NkXVxIuQgK'. +'wLj+hqBvel0qmbR8GnR22nJNZiLeeKr8nDIT1OLJucX+uPbWom7iocRpafOac5MX1ALltp/Cbi+cJH++utdh+WVNL3PNdNYpdWgx'. +'Y0qmLZSrwJJcQoOJ5XKlJFu4HbJOjVbt+V5nu7eopNRivqcdhK+bFnWwA1Y2AOcgjvj9dGlxy0g5y0xd+hNXoG24C4obizq3HZUh'. +'YHqtRHD06bG/8a0MbbG1mqekxaBSGmgkrcdcitlLfrckZIz7DUatbeFak0tyRLUwzT5vmiGm0cufEkFBJItfkD+59tKmiO12atFa'. +'eQukO3ejUxgENqTcfnE5WbkHiOnJ76N2IqI1DibabptS+zkZhtp90F2Y0S026EkAFK/qL46cXv65NVZDfxHmVCK4DE2/RX/lRFbA'. +'C5LwAyq2EtpHZI7mxPYDRqoctdESimz/2Q==' ; + + //========================================================== + // le-small.jpg + //========================================================== + $this->chars['e'][0]= 700 ; + $this->chars['e'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABgDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAYEBQcB/8QAKhAAAQMCBAUEAwEAAAAAAAAA'. +'AgEDBAURAAYSIQciMTJBE0JRYRQVFoH/xAAXAQEBAQEAAAAAAAAAAAAAAAAAAgED/8QAGREAAwEBAQAAAAAAAAAAAAAAAAERAjFB'. +'/9oADAMBAAIRAxEAPwDTszvhEYCoS80BTm2bCjQRwdAzVe2yopkpJtpRUVfjEIc4V2oMerByg5Ji30oMyS3GeMunK0upfnu09MdJ'. +'p2scTmWnnGfx6HThktgLfKj7xEOqyr7QBbL41LhBzpxbcOru0LKDLdSnOHoaltNqSC4qWL0x9xbJYum69caczSaHmGmTmpDUYn4l'. +'UiqjkynzAVtwV23Ud+X4Ibpa2DCPkjhfUaRO/p8yzpb+YHhUmhbev6ZEll1lvqK3jt2XrbBgp6HVwsK3THpfEubGSoOUyFMpbJmL'. +'Deh6SgOGKti57EuY6l62JMWdJy7k3hg1LkOozEbVm7suQSkTiKtkEfP1pH664Za/QItccgI4bseTHdNxiXHLQ8yVl7V32XyioqL5'. +'TGc1ng6eYs0idczXUZscBBABWgEhEtfKNuUezwPnBhEuj8X2M21z9BR6NUX211Kk/UKKAjuhkPhL7XVf8vtgw7UPJlEyrDWFSYLb'. +'LBNF6qrzG6t0spEu6+fpL7YMXhUndp//2Q==' ; + + //========================================================== + // la-small.jpg + //========================================================== + $this->chars['a'][0]= 730 ; + $this->chars['a'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABoDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAABgMEBwX/xAAvEAABAwIFAQcCBwAAAAAAAAAB'. +'AgMEBREAEiExQQYHFBUiUXGBE2EyQkNSgpHh/8QAFwEBAQEBAAAAAAAAAAAAAAAAAAMBAv/EABkRAAMBAQEAAAAAAAAAAAAAAAAB'. +'IQIRMf/aAAwDAQACEQMRAD8AfdQ1pxjqZMSn0mRUZRYDaklJCE3OawO2ttTxY4hl07qFMVs1Ku02kpPnRGhsAqz8W9T9wDjozq6o'. +'Q1lDrcZLGVcmUoZg0obpufxK3Ftt9ccqB1GgBcmLSqtVEqOZcr6ARm/kbXHt7DEtc7WTJKTJqEWvRKfLqL9QplSjuPtGVYOJKBrm'. +'t+U+n94WGStZzNypmRWqckUKTbixy6jAfxPxHtCgKqFNlU5huK6pLMndSlegG4J45N8aKmTMKQRBsCNMzwB+RbHWHGEAZlPZX2hx'. +'qZIC34ygZoYUbB50JSkFXFhZR9BrpheR4fIbQ6gvurJ7q02bIQTuAOAN8x40HAxRr3TrNRpBmSHVt1KMlTyJTCsqkKAPlSf28W+c'. +'UGaD1c9HSR1HFUh9tJU45EBcAtcC9+P9wqbg8IAto9o81yputrVGpiUkgHKkqUTZI32+cKm1z1tIUgPBBAKQ4UBQH3uL3xmXSXep'. +'HVDtXStE5K5jlPU7PF3Q41+okJFkjgC+3OuNSYiSzHaLtRcW4UDMpLYSCbakDW3thhum5p//2Q==' ; + + //========================================================== + // d9-small.jpg + //========================================================== + $this->chars['9'][0]= 680 ; + $this->chars['9'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwP/xAArEAABAwMD'. +'AgYBBQAAAAAAAAABAgMEBQYRABIhE1EUIjEzQUIHMlJhcdH/xAAWAQEBAQAAAAAAAAAAAAAAAAACAQD/xAAYEQEAAwEAAAAAAAAA'. +'AAAAAAAAAREhQf/aAAwDAQACEQMRAD8AkK7brF6X7XpMeGoKhFMLEeT4ZUheEhanF4OcZ2pTgDykk92bZpdCsi7aezLjxkIPUZiV'. +'RSCy8hah7EkZ27yM7V+iscal5bE22Lon1qNDmSKROd8Sl+Ix1lMOlIS4HGgQpbStoUCnlJz8HmsXtW3Lst2rmBAelLMRRekOwnYz'. +'Edls9QKKnOVLyk7UgcbzzrdBthqEJJwZbAI4x1U/7o1TaFa9lG36aXaZTy54VrcXUgrzsGdx+T30aNydweqVw1GS87T6Lb86Q4ha'. +'my/IAYjZBx+snKk99oOQMf1AViE65SY348hzFy6hPKnqtKz7DC1lbqyPrvJKUJ7H+M6Wrt3InP7o1brFNp4bCDGhxGAsqz69VSiQ'. +'ORwBxrrQ7itm1ac7Hp0WoGTIc3PSn0pccdcP2WorycfA1RaRHjxosZqOyhtDTSAhCf2gDAGjVHTd9sKSCumynFEZK1tIJUe58/ro'. +'1V1//9k=' ; + + //========================================================== + // d5-small.jpg + //========================================================== + $this->chars['5'][0]= 632 ; + $this->chars['5'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgIFBwT/xAAoEAABAwME'. +'AQQCAwAAAAAAAAABAgMEBQYRABIhIkEUMVFhBxNCgaH/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAv/EABcRAQEBAQAAAAAAAAAAAAAA'. +'AAABEUH/2gAMAwEAAhEDEQA/ANGvW4YVOeiRX5b4mv5Sin05IdlupPKdo/j2SO3+6TbPNQvOsTVz33KRT4csR3YUF7Dsh5OSFvug'. +'kqG4FPBxnjxpvvi4KZb1pTpU+QwxUi2Y7ZIAefUk5ATxnB9/gbtL/wCH1UpuhPUlZlMVaQ0mS8zJjqZOPfc2TwpIUonI9tw40R1r'. +'WNGq/wBdJR1XT3lqHBUnGCfkfWjRWs1ve249erQqQYjOtN1FqPUpCXQ4WIzQSsJwT0UpRwQPG0nzqyuNHobjsl9kBuWqoOoXtT1/'. +'WppZcA8lKRj64HxqU+3KpAr6plElRVKef3S4E0K9O8pLXVzKcqSsJAB9wSAca6bSoNXeuA1+5pEV+SGFNU1iKVFqI0Vdx2AJUeoz'. +'8DGlTDwG3CAf3q/pI0ah6MDhLz6U+EpXwPoaNMU//9k=' ; + + //========================================================== + // d1-small.jpg + //========================================================== + $this->chars['1'][0]= 646 ; + $this->chars['1'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEwMBIgACEQEDEQH/xAAZAAADAAMAAAAAAAAAAAAAAAAABQYCBAf/xAApEAACAQMD'. +'AwQBBQAAAAAAAAABAgMEBREABiESMUEHEyJRkSNCYXGB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFxEBAQEBAAAAAAAAAAAA'. +'AAAAAAEREv/aAAwDAQACEQMRAD8A6jdd4WLbstILnc4Uq0VoWpkJknb6IjXLHJUePOlez923fcW4r1SxWlqC2UbdKirQif3Xw3yA'. +'OFAGT09/kO3OmV3a20MFRf6lIYPcpy7yRRAzgxjIy2M8YwcdiBzpX6d22VNvUlTXsFkuwkrKqNSfnK7F8OTzwrAY+l5zoxKskudN'. +'EgQPUT9PBkWF3DH+1GPxo1mLnRoAqF2VRgGOFmX/AAgY/GjRUP6hVMFv2FuFqUvUGrpDFJMBnpdyF5bsAQew7Hxzp6LZNT0yQ1DI'. +'wp0QCFBhD0jCsfLZHxbx5xxpTuvb1+v9PV7Ztk9roLPLCjmSSN3mX5ZwqjCgZX7PfWxDQb2in96pv9qq46aTE0bW4x9ceAWAYPwS'. +'PsYzoixgmheBGjIVcYCnjp/jHjHbRpe1JLn9OnopE/a0ykvjwDx47aNMXqP/2Q==' ; + + //========================================================== + // ll-small.jpg + //========================================================== + $this->chars['l'][0]= 626 ; + $this->chars['l'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAYEBQf/xAArEAACAQIFAwIGAwAAAAAAAAAB'. +'AgMEEQAFBhIhFEFREzEHFSIyYcFxgZH/xAAXAQEAAwAAAAAAAAAAAAAAAAACAAED/8QAGhEAAwEAAwAAAAAAAAAAAAAAAAECMREh'. +'Qf/aAAwDAQACEQMRAD8A15Zfm1VURj1Fp5AqLKv3OARcL4W5Nzx+MLWjdRz5hqXU6TSb6OCr6WghiQbrJ91gOTy1yT5xZ55myZFk'. +'Gb5ozX6Ondm28XYqpQDwu7jEH4c5S2UaDy4xxrLmlUDWzk8XaQ3O49hbj+RiB85HNg8Ee3aqwIqhDuux7G/HHbvzgxEqaWOvy09R'. +'O0o3hjdQoUji20g+fY3wYSM6pJ4Ylr7V+Zz5PSaezHTlTRNWzxySSxt6q1MSkH6AOT2Fu3Aw7RfF/T9DEkLUeawuF2mKSgdWQj2/'. +'q3+fnDZDlqRZzQGaOGcpTOaeR1u8R+ncN3gj94so2jNWHeMNNKzorEX2qp9v3imNPoRE1zpjUtZ09HJmYq5lury0benZeTww23t3'. +'Ivgw+T0yRRyyxIqNfkLcA8jt7YMKcBWn/9k=' ; + + + //========================================================== + // ls-small.jpg + //========================================================== + $this->chars['s'][0]= 701 ; + $this->chars['s'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAAMCBAUGB//EACwQAAEEAQIFAgUFAAAAAAAA'. +'AAECAwQFEQAGEhMUITEiYQcjQVFxFRZCUoH/xAAWAQEBAQAAAAAAAAAAAAAAAAADAgH/xAAZEQADAQEBAAAAAAAAAAAAAAAAAQIR'. +'EiH/2gAMAwEAAhEDEQA/APWZMhmFXSJU+SGmWFiQtAWMJQAnJUr8Z+w/OuQk71uZnMsqnbjy9s8st9UMCQ6kZJdZaIHEkZ/JHceN'. +'N3HtizuY1JLrG48yLBSC9UTFKQiY4nACir+wAOOMEe2rm2bTbzlqtE1MyBuZAPybpw85KSfDRJ4Cg+Pl/wC61hJeGjV31VuuKqwr'. +'LGU+whZZK+Rw+oYJAyj3GjS4dZFpZVkqPLktdfMXNcaU2kBC1BIITkdx6c599GlnvPAa3TL2vNvU76n0063acr3YSLCEjpUpUQtW'. +'Dhf14SMEnOc57aZ8Tegm7dbrEQGZt1PeTDgc1PEW3FeXAvyAkZVkeMDOm2G3f3O7Cl/qEuqkQg4lp6CRxraWfUlRUD24kZA741Ko'. +'2k1HvlT3ri2sLOCgtsyJz6XEtBwZPAgJAGQMHUNPWKqWItsqh0UCFVyLeKhyLHQ2TMdHNVj+RKlAnJyfto1FW2ahgjrq6LYTFjjf'. +'lymUOLdWfJyoHA+gA7AAAaNPE3ysJdLT/9k=' ; + + //========================================================== + // lh-small.jpg + //========================================================== + $this->chars['h'][0]= 677 ; + $this->chars['h'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGgAAAQUBAAAAAAAAAAAAAAAAAAIDBAUGB//EACwQAAIBAwMCBQIHAAAAAAAA'. +'AAECAwQFEQAGEiExExQiQVEVggcyU2GRocH/xAAXAQADAQAAAAAAAAAAAAAAAAAAAwQB/8QAGhEBAQEAAwEAAAAAAAAAAAAAAQAC'. +'AyEyMf/aAAwDAQACEQMRAD8A6DZb95q9bmpK6ieOCzNHJTxmE+NMhQ5fr1fLq3Ejvkak2e7ipiFsqb3R0m4qkPPJRiRXenU9VjKE'. +'5JVcA9R7nWc3/BUbfoKTdO3VRXhpjbZ2D8Rwk6RyZH6chB+46m7i2hDYtgA2ePlV2VkuKysoLzzRnlIScZJZeeevvjtrX7LK2rp7'. +'tTwwJ9WjhILDrTKnIdMEDl2+P80aVdJZb1QW+vgqENLPH4sBCDLIwUgnOf4GjVvDnLgUk79T81voqjb8NnuUx8pVRCiEaYUSuynl'. +'jHU9mOfnOoOx6hqz8PrbNdfEkMUXg1LSM3rKOUywJ7YAJ1ZTWmSpvdvlaVTDSUzJAhH5ZJBgv0x2RSAPlz21WXqoet3ba9nuW8n4'. +'Jr6qTPqnUNxSM/f6mPvxA9zqJnExTbR+h0nkhVu1uE8j0UBRQ9PGxBKFjnkAScdsDp10a0lc7z0tI7Y5YYN+5GAf7GjVXF4Icj3f'. +'/9k=' ; + + + //========================================================== + // ld-small.jpg + //========================================================== + $this->chars['d'][0]= 681 ; + $this->chars['d'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAQFBgH/xAAsEAABAwMEAAQFBQAAAAAAAAAB'. +'AgMEBQYRABIhMQcTI0EUMlFhkRgicaGx/8QAFgEBAQEAAAAAAAAAAAAAAAAAAgEA/8QAGBEBAQEBAQAAAAAAAAAAAAAAAAECETH/'. +'2gAMAwEAAhEDEQA/ALUhp6h3W/X63UlypbhCY0WMjLqGzwDtPCfv/WtealNpVInuVBBqCogcdbU36YUkAkJWVHG8YPXBxxzxqPcN'. +'YtWyWnIlUeW05VEOAvrCnnSkftK1H5lKJPHsMDoDUWq+KdrSbIqsalVsImiEtLUZ2MU71bcYJWkhZ/36ayLHhi/IXZVOmzKqp5uU'. +'688hTyjuGVEFJKvoQesD86NL2jGZp1EoLDSmk+ZAQ8d7oPzp3YGesFWMfxo1YGvSzLsT9QExVX8phTlMaFOExAJIBGQjJwCcL+/e'. +'rd+W7GuO0Kw05CQ6+ww69Gfdb2kFIKk7DgEkjgnr86rXRa9HuyP8LV4SH0sIBbWFFDiFEgDaocgdkjo8ccay0qw7ut5nyrcviQqC'. +'slsRKo0HwlODkBRzxj2AGoXTtpzIdQ8MbffUChz4NCPRaClAo9Mn6c7T3o13wytmo0K05VIqkiPJbizFiMWs4CTgnIIHOST796NL'. +'Ia1JX//Z' ; + + //========================================================== + // d8-small.jpg + //========================================================== + $this->chars['8'][0]= 694 ; + $this->chars['8'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AFQMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABgcEBf/EACsQAAEDAwMD'. +'AwMFAAAAAAAAAAECAwQFBhEAEiEUMVEHE0EVYYEiIzJCsf/EABYBAQEBAAAAAAAAAAAAAAAAAAIAAf/EABcRAQEBAQAAAAAAAAAA'. +'AAAAAAABERL/2gAMAwEAAhEDEQA/AKL6gVVUa0i1T5QjvTprUJMlxW4R9zgQXe/AH+kaWrntqlWjaq7gpcmotXAw82ht9yY4tch8'. +'uAFC0k7VBXPGMY51ruiaue+bThIj+7NbWqS+7HDxajFf6AlB/k44o8ZOABk4xkL0X0tZiojKrlRuGRJjugqldSlKGf6t7BuUQe3J'. +'44xxxrA1a4KVJipLidri8uLHgqOcfjOPxo0o2hdDvS1CmV2Yl6fS5ioipIQR1CAlKkLKR2UUqAI8g6NRSwuuyHab6s1ufLI/Zai7'. +'UBJOxhTS0+6B32pWSFH4CidOdWU0ukLiN1BLr0zG5Sdm3GRvcPhIT858DvjXNrVsSLnm/VIdTXS6tTnFsxZTSN3jchaTwps+O/z9'. +'tcBVq3hIX0tYqlIiQHdy5CqRHKHXEjAOMgBKjnvyRk4xrQa7OiGt1K5biYZL8SoVEpjOqkFsONtJCNwASeCQrn7aNUKnQYtLp7EC'. +'EylmLHQltptPZKQOBo1FzH//2Q==' ; + + //========================================================== + // lz-small.jpg + //========================================================== + $this->chars['z'][0]= 690 ; + $this->chars['z'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABYDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAABgAHA//EACsQAAEDAwQBAwIHAAAAAAAAAAEC'. +'AwQFESEABhIxBxMiQVFxCCM0UmGRof/EABYBAQEBAAAAAAAAAAAAAAAAAAECAP/EABgRAAMBAQAAAAAAAAAAAAAAAAABEVEC/9oA'. +'DAMBAAIRAxEAPwBTWfLu1KXXZDbM4uewNvLajlwhaCbBAwDe5uehYd3xm6t6bi3jvulwqc7KgxXZZeYQLNLeF73WRg4HEdgfzrSa'. +'P45pNEkznITDc9ypLShtyWhJDJyXC2qxJHZvjoZOjyVv1v8AESt6FFS4ijxvTLbawEApSccrYHJf0+OtJMQ2rNXk7GZMufJgJjTH'. +'Un9M4qzxT7hyCiThIyRnPXWrRvyLElVBUF6vlhl0lwRYCFKcQhAtyWpVhyWTx+w++rUvp4EWjOvbniUOnVatcS43BYDbJSPZyIBw'. +'ejclIx+3Wa+J63T6DQanuGszI0eZVJJV60p0Jum5GEi6le7l0PjvSjyRsaTvJqI1BqhhR46ksuMrQVJcUSEoUbHNr/7o7C8L7eiz'. +'4lLlyJk2cEqW+6V+m0AE9ISLnsj5+O9UhsFK92bZZqb9SRu9p2c4A0OCEqDbYAJSlJwAVZv3fBvbFrg/462btlhuS1RG5nL8pYkq'. +'KrnsKH06I/rVrQKkf//Z' ; + + //========================================================== + // d4-small.jpg + //========================================================== + $this->chars['4'][0]= 643 ; + $this->chars['4'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABAYHAv/EAC0QAAIBAwQA'. +'BAMJAAAAAAAAAAECAwQFEQAGEiETFDFBUmGBByIjUVNxobHR/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAIB/8QAGBEBAAMBAAAAAAAA'. +'AAAAAAAAAAERIVH/2gAMAwEAAhEDEQA/ANjM00Nxmt1xiWW31CZp5uJwoAAaOQ/n7qfcZHqO5my3q5XX7R6ijiqnNut9u4NyJ4yv'. +'JJyjYr8Xhrn5g599J7x3ulBNU7Zo7dXXXcLQ8kURYi4epYtkALjOePv1nUvbLvV7P3BZm3DR3eh88Kp7pVzBZI6iUhGWRRGWwE44'. +'HX3V+uiL1uHgt+vL/H+aNJQ3CSeCOaFqSaJ1DJKs/TqRkMOvQjvRorHE4pRDLNWLGlRHGUeYIORXs9e5B7OP31E0fmdyb/t0DJ4Q'. +'27bfx3YZzPUIoAAz7IpOD6cuxq0uNumqLfVNDOqXBoZEjnZcqhIPXH4c46+WkdoWOltu3IDDLLLVVR83UVcuPEmmcZZ2/rHoAANG'. +'GI7KIY1ijoLeEQBVCwIoAHpgY6Hy0aZe7mJ2jeHLKcEhusj6aNKgzr//2Q==' ; + + //========================================================== + // lv-small.jpg + //========================================================== + $this->chars['v'][0]= 648 ; + $this->chars['v'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQDBQYH/8QAKBAAAQQBAwMEAgMAAAAAAAAA'. +'AQIDBBEFAAYhEzFBEhQiYQdRFTKB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFxEBAQEBAAAAAAAAAAAAAAAAAAERIf/aAAwD'. +'AQACEQMRAD8A6Ngt1SZ4yrYgrecgTFsFJA9aGwAUrUaF2D2Avjzq6CIjiBPkB9bwQVIkIYIDae/wq+P9N+dY4SGMf+Txlev7KBmY'. +'PoadKRy4zxSgRxaTwO/x09u7KPYnasmHjlsyFZZXt4K23ezjvBpNGgLUrvXfVZyLLbWambiwEbKvvxYAkeotNlIJW2FEJWb7WBda'. +'NSQI0fHYyJjkrjKRDZQwnpQ1vgBIr+w8+a+9GocZr8iKkuY1eXhsKH8U8iZE9BHz6ZHUc48UfSPqzqH3kfeO9kTTDQYGGietpTaO'. +'shyW6AocpHNIrv8AvWzk9BUSdPdYS4BcRlomkhIV6KP0VE39V+tU2wdlRMHtZUB8NuTQ+51X27+Kr46ZPIAFV540D8zeLsJ5LMHa'. +'ubmMBCVJdjx0pRyLoWR4I8aNIQ8BvZMNtMTeUcsptKfc4tC1gAkCyFC+K0aJtf/Z' ; + + //========================================================== + // lk-small.jpg + //========================================================== + $this->chars['k'][0]= 680 ; + $this->chars['k'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGQAAAwEBAQAAAAAAAAAAAAAAAAUGBAMH/8QALhAAAQMDAwIEBAcAAAAAAAAA'. +'AQIDBAUREgAGITFBEyIyYQcVUYEUIzNicZHx/8QAFgEBAQEAAAAAAAAAAAAAAAAAAwEE/8QAGxEAAwACAwAAAAAAAAAAAAAAAAEC'. +'AxESMeH/2gAMAwEAAhEDEQA/APVK/V36dU6NSJDTT8esPLiqfK8S2cCoeTkKvZQ6jm2ldSqKqbu+OgMOvSX3m4UBrLnDlbqiefKl'. +'Nzz2x1m+IwNP27CkJQ7JkR6rCkMJbP5jp8S2CPfkgD6H+dJ6Ca0nerr+64rTNSqMYrg+C9mmOwhVpDfsuxSbi97DmybaoZeQ5jTl'. +'PEp18JTIfeW3kq3ly4H26aNZqvTWZsjFcZTsVtSg0G8Rio+vr2vb7g6NLPRnuXy8F+8kl+obUh4KXJdqSJJQnohlkZqJPYBXh3P+'. +'a4b5Hyp6k1bO7sOotPyXkj9NlwFl0ewstJA9ifrqkVSmET4csoS7UTHXFQ+6SQlskKUMb/tH9ddLVUmS7DqdBqD7U6OsqfS46jzl'. +'hQ5bXb1K9Scuybdxo2OTu92dwSZkWn0Sb8viQWyn8Qq5D6ifSLd0BIv7q0arTBRSKPToMZbi2GWylsvLK148Wue/XRrRjxOpT2R2'. +'k9aP/9k=' ; + + //========================================================== + // lr-small.jpg + //========================================================== + $this->chars['r'][0]= 681 ; + $this->chars['r'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABYDASIAAhEBAxEB/8QAGgAAAgIDAAAAAAAAAAAAAAAAAAYCBQMEB//EAC4QAAICAQIFAgMJAQAAAAAA'. +'AAECAwQRBQYAEiExQQdRFGFxEyIyM0JSYoGC8P/EABYBAQEBAAAAAAAAAAAAAAAAAAEAAv/EABcRAQEBAQAAAAAAAAAAAAAAAAAB'. +'EUH/2gAMAwEAAhEDEQA/AOs0ZdETU54Gt1INSmlPJEsyo7J+jlXPUYBPY9c+eE/dO9tY0a7ren6BVrW7VJTZtW5kZkjXkBSIKveQ'. +'gHp0AAJ4w+q2hVdT2Md0h46+saS4mr3EUK0gWTAB+vQj2PboeL/ZVOqmhaZVjkFmxdC6tctt3tM2G5/7bAx4C4+qxiWwd3prWzKe'. +'r3IBAth5OYxozKsgc8y4GTgnJB9uncdTi6tXq2140rRVM13JMEMAVAg7sMdBjJB/18uDgRO9R2Oo6FX2vShkFzURFUq1whIj+8DI'. +'7EdAFjXv7MeNb0kuStsFEmIaajZaos2fy2Q4VGH7SGxn+Rzw9yMLOm/FzRhZazmOTkP4grYyD3B8j2PTyeFfZ+z7G3BeSS8lmprl'. +'2K2qcnK0Z5S8gPjrgAY8cNEWmq7u23pEos6/Zji+Kd0rLLGWwseA3joeZj/w4OET1g0vlmrWV+ydFnkUxSgsvM4V+YYIwfHz6cHB'. +'ZeKZ1//Z' ; + + //========================================================== + // lg-small.jpg + //========================================================== + $this->chars['g'][0]= 655 ; + $this->chars['g'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQCBQYH/8QAJxAAAQQBAwQCAgMAAAAAAAAA'. +'AQIDBBEFAAYhBxIxQRNhcYEiQlH/xAAYAQACAwAAAAAAAAAAAAAAAAACAwABBP/EABkRAAMBAQEAAAAAAAAAAAAAAAABAhEhIv/a'. +'AAwDAQACEQMRAD8AayO4t6bq3hmMHtxyLi4OKeKH5jyASiiQCCQeTRNAeB61FrBb+jTGpLO+BMW24EFMhkhpQru8m7B/H70x09Yi'. +'q3nv/vLfwpnJ7UNkqSRbngf2ofWkpXV7brymC2malLfagurjW0aHk89xPJ9cX9aprURHWbYEaMHHEBfwpv8AnXPk+/8AdGqGJOxO'. +'4YbOSxK4y4boIStUWysgkEmxY54r60aOI8oTV9MHtjJwunPUbO46WWo0HLlD8KY4goboFVoquOVEVwLT963WdnxYfT6ZJyz0JvHm'. +'KvtaSkW4tYNVSqKiTwB+fw5n9sY/cuOXCzDDcluyW3Ckd7V+0n0eNZTH9DdouFalHIOJBUhtDki0pNV3UALo81ehG6IdKjPZ6d47'. +'4ywltanVJvuJI+RQs/sHRqy2r003JhsImEc/CUyhxRZBjKV2oJ8eRXNmufPnRo1WIz3DdNn/2Q==' ; + + //========================================================== + // lc-small.jpg + //========================================================== + $this->chars['c'][0]= 629 ; + $this->chars['c'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAwEBAQAAAAAAAAAAAAAAAAUGBwID/8QALRAAAgICAQIEBAYDAAAAAAAA'. +'AQIDBAURACExBhIiQRMVUWEHMkJScYFykaH/xAAWAQEBAQAAAAAAAAAAAAAAAAABAgP/xAAXEQEBAQEAAAAAAAAAAAAAAAAAATER'. +'/9oADAMBAAIRAxEAPwDcoGkmiT4Q8kWvzuPU38D2/v8A1zwrCFayq1qTaFk2H7aJHt05MeMvENzC4upDWkjW9kJXiricAJCigvJN'. +'IB1IVQT5frrv24twPgunk6a288crbklUSJNNdnSTZ2STHHqOP/Eb17njdZtAoqwEvrEiGVyG117/AG6HhyV8H1sljMldoxXTksGC'. +'zV7M0oaWGQOVeGQ92I6EMR22D11w4LmEPjaOL51iL8ssc9Z69zHtZkYCGGeQK0ez2UEoU39wCeX1S/LLiEt+mPSbMLxsGVv2kEjR'. +'305xkaEV/GTULMUT1LD/AAGh8gIZS2jv+vpybb8NMIb0dVLWYWgiiU0vmMphOj6V0TvQI3rfsON1E6dYjGtisa0F1mAWR2NhG0WZ'. +'3Ls3TqNs5Hc9h23w49NWL9K+Q/VD5T/zhwPH/9k=' ; + + //========================================================== + // d7-small.jpg + //========================================================== + $this->chars['7'][0]= 658 ; + $this->chars['7'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgEFBwT/xAAuEAABAwIE'. +'BAQGAwAAAAAAAAABAgMEBREABiExEhMiQSMyUXEHFBclVJFhk9L/xAAXAQADAQAAAAAAAAAAAAAAAAAAAQID/8QAGREBAQEAAwAA'. +'AAAAAAAAAAAAAAEREiFR/9oADAMBAAIRAxEAPwDXq9mCjZeQ05VZ5ZST4bfEpa3VdglCbqUe+g9MZ5Uq7V8415WXoMSdQ6etgSps'. +'19wpkCMDZKUpv0FZvbi1NzpYasMDLDUbMVXrtQdbeeU23xLWkj5RlLYK0J7anW9gbAjCzkOtsVSUJUdtc6dVZK51UeaFm4LKbhpC'. +'l7EhIFkDW974GbRI2XorUVls1OTdKAOqUpR0Hc3198GITQ6k+hLwrEpoODiDenRfW23bBicg78JXxPpD0mgVOW5PAivNNpahsPW5'. +'8xxQaSVkboQnhsnYm5OHqDGp1IpsalMKjMsMIC3+XZKbJFth62/QOEfMOZqZXp9JcKZTcGmTky3meSi7xQklI81vMR+sXIz/AEgp'. +'Q0qPNu6ea8Q2jqtbp8+2w9h/OKORc/cpHjt1dDSHOtLZ4ekHW23bBjj+o9H/AB539aP94MG0+L//2Q==' ; + + //========================================================== + // ly-small.jpg + //========================================================== + $this->chars['y'][0]= 672 ; + $this->chars['y'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAQGBQf/xAArEAABAwMEAQIFBQAAAAAAAAAB'. +'AgMEBREhAAYSEzEHIhQkQVGxQmFxgaH/xAAWAQEBAQAAAAAAAAAAAAAAAAADAQL/xAAeEQEAAgEEAwAAAAAAAAAAAAABABECAxIh'. +'MUGR8P/aAAwDAQACEQMRAD8Ar3tys07dVHohemz5dWQ7fk91MsA3IIRY8rkKFySceTqw3JVV0KhyKw+0C1CQp9aUOFSiAk4AIAvn'. +'76xtz0ioVvbcJ6msx2JtOfZmw1PKI5LQcJNh7UqBKcn6+NRfqPu6s1fYc6GxSJsRfWDUVSGA22ygEckJWSexRNgOP0udXzDKOJ0I'. +'yo62mHm25Sy80l1Z4lSgpQvZRGLgWwPGjTjbchyLH+Ejx22EtJSgO8kki3kADA/nOjWjGzv73CyQZjUWNVp7bNSrj7qJDqflqUlQ'. +'DMds24l3HvcNr3Pi9gME6T9WWVsemdYWswwC2lPta4m5WMA3OdUExCmozUJD6g84ntMjrHIFBTdQz5yLDx/WDNytpwW6nAkViqVe'. +'uvmXdlme6n4dCwlRBKEgA2tj99QG7Ilncp5QqpU31PMsJ6x7A32f6SPxo0hPVCD45oVyKf0MtgeT97/nRrO7UOCFla3tn//Z' ; + + //========================================================== + // d3-small.jpg + //========================================================== + $this->chars['3'][0]= 662 ; + $this->chars['3'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'. +'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwL/xAArEAABBAED'. +'AwMDBQEAAAAAAAABAgMEBREABhIhMUEiMmETFZEHFkJDUdH/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/xAAYEQEBAQEBAAAAAAAA'. +'AAAAAAAAEQExQf/aAAwDAQACEQMRAD8A0vclruBdk3VVLLUNssGRJsZSCtqOjlgJAHvcOD6c4HnOdIbcttw1W5P29cFEhuawqTXS'. +'VsJjnCMBxKkJJx7goAde+ceJfdNxU0UNlyymyXHi6kxWUNl1S3EnkAEIHX2nv86qtTuZr9Q9+1VhRsOoYpYcgSVyAE/TdewkJxnK'. +'sBCjkdPGpnOtFMd3PqsXgfOAgD8Y0aX+11H9rDDjn8lr9yj5J+dGqsqxaw6Cc9cQZU4Sp7zTJsIrKlcUEKwhSin1JABI45GUjqOu'. +'lbOvjbc3Ts9ynjGCy445UuFLYRzbWgrT6fhSCQSMDke+pew2zYVly/d7YchNqkMJZnQpgV9J8IzwWFJyUrAJHYgjvpLbu37G5nR7'. +'vck5C3YRKYEOEVJZj8kjKypXqWvirjk9h+dB9i4faa89TDZUfKlIyT8k+To10a6KTkpcJ/0vL/7o0TS//9k=' ; + + //========================================================== + // ln-small.jpg + //========================================================== + $this->chars['n'][0]= 643 ; + $this->chars['n'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGwAAAgEFAAAAAAAAAAAAAAAAAAYCAQMEBQf/xAAtEAACAQMCBAUCBwAAAAAA'. +'AAABAgMEBREAIQYSE0EHIjFRcWGRIzIzQoGCwf/EABYBAQEBAAAAAAAAAAAAAAAAAAMEAP/EABkRAQEBAQEBAAAAAAAAAAAAAAEA'. +'AhEhUf/aAAwDAQACEQMRAD8A6FR3p7v4oV9rlkMQsjL00RyOss0KkFxnDcrc2PbI1NOJKyTjW+W5OmKeA0UEJx5meRZS2/8AUfbS'. +'LVGS1+K16vCzfiR3GmoqqXGyxz06hWPsFlVMfOmq1iNvE69KjBYo3oJMZ3GKeYYPxg/fW+xzZX1FLQyxwSTcpWNceu4G3+aNSmpY'. +'qmQzzwh2k8yhv2r2H23/AJ0aoy+EWh7I1ntacR3PxDtEzhjWy0wkkIwYmanU5GO6sNh7rrU8AVdTceNbhDXxNHUQvS0tZ3DzwxVA'. +'fB7hj59/XJ08cPWaKj4gvlwSQiG7dCboqvLy9NOmQT9SM7ayJrBa6K5V91hjlWorp4JGUOAglRSiMMDb82/vgaBGTpVvtNUVtyJg'. +'5+WNAh5ZCu/r2+dGrgq0pi0DhmlRsSSAfqMd+b6ZyNu3po1Rk1yNBe3/2Q==' ; + + //========================================================== + // lu-small.jpg + //========================================================== + $this->chars['u'][0]= 671 ; + $this->chars['u'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAYDBAUH/8QAJRAAAQQBAwQDAQEAAAAAAAAA'. +'AQIDBBEFAAYhBxMxYRJBURSB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAQAD/8QAGhEBAQEAAwEAAAAAAAAAAAAAAQARITFBAv/aAAwD'. +'AQACEQMRAD8A6dLkQmJzu3WVtHIqjf0duKFNuBr5UTQ45F1R8/XI1PMmsYoJyjhS9iI7BKHeKjkXZVXqhyLHP+rrHeR1pZlx1W1M'. +'wTiW0ukkrS28nn5fV2SPPFfurHUKQhzYG7pLYKEfyBhaSOS7dG/YCki/uvWn3LPDOJrwa4kyEzOYeakqkpC3Hk0bNePQHgDRpchY'. +'leIZwzUWauKtuPctTSUlCAUmrBHIKuAPV/ujQsmHdm7hya43UbbD3ZVElOQJsdTS6IQaQUqBHCk8E2Pocgam6oYwObHy0Zm0oi45'. +'T1KBPdpV2f0pom/1Ws7cmPazu98Ltvcq3VzRHfehz8a4pirFEKRZo8eQT+eCdWYfS/b+WYnxpbuVcDRMdHcyTqg2fiAfiLoi+Rf+'. +'jT7Xc74HtOYnHyUOh8yWUvKeHhy0CiPVUAPoDRrm+OeznTva6lzsyMjCYbbaiNJjJSWElagD5tRpNUSALFeNGoOCH7Bv/9k=' ; + + //========================================================== + // lw-small.jpg + //========================================================== + $this->chars['w'][0]= 673 ; + $this->chars['w'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAYDBAX/xAAtEAACAQMDAgMHBQAAAAAAAAAB'. +'AgMEBREABhIhMRMUQRUiIzJRYZEWNIGx0f/EABYBAQEBAAAAAAAAAAAAAAAAAAABA//EABoRAAICAwAAAAAAAAAAAAAAAAABERIh'. +'MVH/2gAMAwEAAhEDEQA/AHXbV13ZLu6t2/uaa1JijWopVp4XUTKSAXRyc+6ehBGeoPbTSlwpql0K3GneqpZViqUhI5JzGMEZJGeh'. +'GlXfaFILDf7FQzXC426rDLTojs8sLqVkXBGcfKf40twWbdWzZY75R0s90ul3jPtKjVMJDNn4DDp8iEhW+wJ1WZG2KWt3Lv26U1tv'. +'92o7PaYkgYUbqVepYlmUBlIwqnB++O2jTDt/bBtth9jcpvEWNGqalZQryTlmeR8jPct6+mNGmRC4a1U13htzVFItB5nA/cyOUVfp'. +'7oz/ALqitJulYJKuqvFsppHALLFb3cp9FBaXr+O51bq0q6i38KK5PDVAAxSzU6SIpz3Kjjn8jUFoS7uFmut1gq17xLFQ+DxOccj8'. +'Rsn+tVpiyJnqv09YfOXu5AycgZZQEhBZjgDBOOgwO/po0sttWHdNzqLruioa4UwmdaC3kYp4IwSvJlBHKQ4OSe3po0qxM6P/2Q==' ; + + //========================================================== + // lq-small.jpg + //========================================================== + $this->chars['q'][0]= 671 ; + $this->chars['q'][1]= +'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'. +'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'. +'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAcDBAUG/8QAKRAAAQQBBAICAQQDAAAAAAAA'. +'AQIDBBEFAAYSIQcxIlETCBQVgSNBYf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAER/9oADAMB'. +'AAIRAxEAPwDT3H5Qz+O3LN2vtrF/y86NYLzzVlAABJITQPv2a/17vXMboz3lDEYWPuafNx7CFrS03+2jpK2bs0CUkUa7pRvrUu63'. +'sr438yv7pLEo4XIK5Kcji0uJUkckm+uQUOVH6GsnyJv7A5vaJwuFdkONLmolgONFH4vioKRXYqyCADXvRMh0yspmZ4jyIEtDTK47'. +'aiA0lQUopBJBI/7X9aNT7amRo228e3a31iO3yUzCcdSPiKAIFdCho0TIswZ7GQlO/hlRxBooih1YXzAoKUkX0LPEBX110dJ7zbuv'. +'AORpO04cIpmxH23FSEIRwKuNnsdk0o31702XhFMKbuRUZJWP8LTQ6HBCuIB+iVWSR2BXuqK93/hDlvGzEphmG3Ml5JpDi1I7TzNA'. +'BYFlPafY+/7LBiv1CYDH4iFDOGySlMR22lFP4wCUpANfL11o1r4bxXlWMNEaE/bqlIbCFl/ANPK5Do/M0VDr2Rf3o0TX/9k=' ; + + + + } +} + +class AntiSpam { + + private $iData=''; + private $iDD=null; + + function __construct($aData='') { + $this->iData = $aData; + $this->iDD = new HandDigits(); + } + + function Set($aData) { + $this->iData = $aData; + } + + function Rand($aLen) { + $d=''; + for($i=0; $i < $aLen; ++$i) { + if( rand(0,9) < 6 ) { + // Digits + $d .= chr( ord('1') + rand(0,8) ); + } + else { + // Letters + do { + $offset = rand(0,25); + } while ( $offset==14 ); + $d .= chr( ord('a') + $offset ); + } + } + $this->iData = $d; + return $d; + } + + function Stroke() { + + $n=strlen($this->iData); + if( $n==0 ) { + return false; + } + + for($i=0; $i < $n; ++$i ) { + if( $this->iData[$i]==='0' || strtolower($this->iData[$i])==='o') { + return false; + } + } + + $img = @imagecreatetruecolor($n*$this->iDD->iWidth, $this->iDD->iHeight); + if( $img < 1 ) { + return false; + } + + $start=0; + for($i=0; $i < $n; ++$i ) { + $dimg = imagecreatefromstring(base64_decode($this->iDD->chars[strtolower($this->iData[$i])][1])); + imagecopy($img,$dimg,$start,0,0,0,imagesx($dimg), $this->iDD->iHeight); + $start += imagesx($dimg); + } + $resimg = @imagecreatetruecolor($start+4, $this->iDD->iHeight+4); + if( $resimg < 1 ) { + return false; + } + + imagecopy($resimg,$img,2,2,0,0,$start, $this->iDD->iHeight); + header("Content-type: image/jpeg"); + imagejpeg($resimg); + return true; + } +} + +?> diff --git a/html/jpgraph/jpgraph_bar.php b/html/jpgraph/jpgraph_bar.php new file mode 100644 index 0000000..ee01669 --- /dev/null +++ b/html/jpgraph/jpgraph_bar.php @@ -0,0 +1,1190 @@ +<?php +/*======================================================================= + // File: JPGRAPH_BAR.PHP + // Description: Bar plot extension for JpGraph + // Created: 2001-01-08 + // Ver: $Id: jpgraph_bar.php 1905 2009-10-06 18:00:21Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +require_once('jpgraph_plotband.php'); + +// Pattern for Bars +DEFINE('PATTERN_DIAG1',1); +DEFINE('PATTERN_DIAG2',2); +DEFINE('PATTERN_DIAG3',3); +DEFINE('PATTERN_DIAG4',4); +DEFINE('PATTERN_CROSS1',5); +DEFINE('PATTERN_CROSS2',6); +DEFINE('PATTERN_CROSS3',7); +DEFINE('PATTERN_CROSS4',8); +DEFINE('PATTERN_STRIPE1',9); +DEFINE('PATTERN_STRIPE2',10); + +//=================================================== +// CLASS BarPlot +// Description: Main code to produce a bar plot +//=================================================== +class BarPlot extends Plot { + public $fill=false,$fill_color="lightblue"; // Default is to fill with light blue + public $iPattern=-1,$iPatternDensity=80,$iPatternColor='black'; + public $valuepos='top'; + public $grad=false,$grad_style=1; + public $grad_fromcolor=array(50,50,200),$grad_tocolor=array(255,255,255); + public $ymin=0; + protected $width=0.4; // in percent of major ticks + protected $abswidth=-1; // Width in absolute pixels + protected $ybase=0; // Bars start at 0 + protected $align="center"; + protected $bar_shadow=false; + protected $bar_shadow_color="black"; + protected $bar_shadow_hsize=3,$bar_shadow_vsize=3; + protected $bar_3d=false; + protected $bar_3d_hsize=3,$bar_3d_vsize=3; + + //--------------- + // CONSTRUCTOR + function __construct($datay,$datax=false) { + parent::__construct($datay,$datax); + ++$this->numpoints; + } + + //--------------- + // PUBLIC METHODS + + // Set a drop shadow for the bar (or rather an "up-right" shadow) + function SetShadow($aColor="black",$aHSize=3,$aVSize=3,$aShow=true) { + $this->bar_shadow=$aShow; + $this->bar_shadow_color=$aColor; + $this->bar_shadow_vsize=$aVSize; + $this->bar_shadow_hsize=$aHSize; + + // Adjust the value margin to compensate for shadow + $this->value->margin += $aVSize; + } + + function Set3D($aHSize=3,$aVSize=3,$aShow=true) { + $this->bar_3d=$aShow; + $this->bar_3d_vsize=$aVSize; + $this->bar_3d_hsize=$aHSize; + + $this->value->margin += $aVSize; + } + + // DEPRECATED use SetYBase instead + function SetYMin($aYStartValue) { + //die("JpGraph Error: Deprecated function SetYMin. Use SetYBase() instead."); + $this->ybase=$aYStartValue; + } + + // Specify the base value for the bars + function SetYBase($aYStartValue) { + $this->ybase=$aYStartValue; + } + + // The method will take the specified pattern anre + // return a pattern index that corresponds to the original + // patterm being rotated 90 degreees. This is needed when plottin + // Horizontal bars + function RotatePattern($aPat,$aRotate=true) { + $rotate = array(1 => 2, 2 => 1, 3 => 3, 4 => 5, 5 => 4, 6 => 6, 7 => 7, 8 => 8); + if( $aRotate ) { + return $rotate[$aPat]; + } + else { + return $aPat; + } + } + + function Legend($graph) { + if( $this->grad && $this->legend!="" && !$this->fill ) { + $color=array($this->grad_fromcolor,$this->grad_tocolor); + // In order to differentiate between gradients and cooors specified as an RGB triple + $graph->legend->Add($this->legend,$color,"",-$this->grad_style, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + elseif( $this->legend!="" && ($this->iPattern > -1 || is_array($this->iPattern)) ) { + if( is_array($this->iPattern) ) { + $p1 = $this->RotatePattern( $this->iPattern[0], $graph->img->a == 90 ); + $p2 = $this->iPatternColor[0]; + $p3 = $this->iPatternDensity[0]; + } + else { + $p1 = $this->RotatePattern( $this->iPattern, $graph->img->a == 90 ); + $p2 = $this->iPatternColor; + $p3 = $this->iPatternDensity; + } + if( $p3 < 90 ) $p3 += 5; + $color = array($p1,$p2,$p3,$this->fill_color); + // A kludge: Too mark that we add a pattern we use a type value of < 100 + $graph->legend->Add($this->legend,$color,"",-101, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + elseif( $this->fill_color && $this->legend!="" ) { + if( is_array($this->fill_color) ) { + $graph->legend->Add($this->legend,$this->fill_color[0],"",0, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + else { + $graph->legend->Add($this->legend,$this->fill_color,"",0, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + } + } + + // Gets called before any axis are stroked + function PreStrokeAdjust($graph) { + parent::PreStrokeAdjust($graph); + + // If we are using a log Y-scale we want the base to be at the + // minimum Y-value unless the user have specifically set some other + // value than the default. + if( substr($graph->axtype,-3,3)=="log" && $this->ybase==0 ) + $this->ybase = $graph->yaxis->scale->GetMinVal(); + + // For a "text" X-axis scale we will adjust the + // display of the bars a little bit. + if( substr($graph->axtype,0,3)=="tex" ) { + // Position the ticks between the bars + $graph->xaxis->scale->ticks->SetXLabelOffset(0.5,0); + + // Center the bars + if( $this->abswidth > -1 ) { + $graph->SetTextScaleAbsCenterOff($this->abswidth); + } + else { + if( $this->align == "center" ) + $graph->SetTextScaleOff(0.5-$this->width/2); + elseif( $this->align == "right" ) + $graph->SetTextScaleOff(1-$this->width); + } + } + elseif( ($this instanceof AccBarPlot) || ($this instanceof GroupBarPlot) ) { + // We only set an absolute width for linear and int scale + // for text scale the width will be set to a fraction of + // the majstep width. + if( $this->abswidth == -1 ) { + // Not set + // set width to a visuable sensible default + $this->abswidth = $graph->img->plotwidth/(2*$this->numpoints); + } + } + } + + function Min() { + $m = parent::Min(); + if( $m[1] >= $this->ybase ) $m[1] = $this->ybase; + return $m; + } + + function Max() { + $m = parent::Max(); + if( $m[1] <= $this->ybase ) $m[1] = $this->ybase; + return $m; + } + + // Specify width as fractions of the major stepo size + function SetWidth($aWidth) { + if( $aWidth > 1 ) { + // Interpret this as absolute width + $this->abswidth=$aWidth; + } + else { + $this->width=$aWidth; + } + } + + // Specify width in absolute pixels. If specified this + // overrides SetWidth() + function SetAbsWidth($aWidth) { + $this->abswidth=$aWidth; + } + + function SetAlign($aAlign) { + $this->align=$aAlign; + } + + function SetNoFill() { + $this->grad = false; + $this->fill_color=false; + $this->fill=false; + } + + function SetFillColor($aColor) { + // Do an extra error check if the color is specified as an RGB array triple + // In that case convert it to a hex string since it will otherwise be + // interpretated as an array of colors for each individual bar. + + $aColor = RGB::tryHexConversion($aColor); + $this->fill = true ; + $this->fill_color=$aColor; + + } + + function SetFillGradient($aFromColor,$aToColor=null,$aStyle=null) { + $this->grad = true; + $this->grad_fromcolor = $aFromColor; + $this->grad_tocolor = $aToColor; + $this->grad_style = $aStyle; + } + + function SetValuePos($aPos) { + $this->valuepos = $aPos; + } + + function SetPattern($aPattern, $aColor='black'){ + if( is_array($aPattern) ) { + $n = count($aPattern); + $this->iPattern = array(); + $this->iPatternDensity = array(); + if( is_array($aColor) ) { + $this->iPatternColor = array(); + if( count($aColor) != $n ) { + JpGraphError::RaiseL(2001);//('NUmber of colors is not the same as the number of patterns in BarPlot::SetPattern()'); + } + } + else { + $this->iPatternColor = $aColor; + } + for( $i=0; $i < $n; ++$i ) { + $this->_SetPatternHelper($aPattern[$i], $this->iPattern[$i], $this->iPatternDensity[$i]); + if( is_array($aColor) ) { + $this->iPatternColor[$i] = $aColor[$i]; + } + } + } + else { + $this->_SetPatternHelper($aPattern, $this->iPattern, $this->iPatternDensity); + $this->iPatternColor = $aColor; + } + } + + function _SetPatternHelper($aPattern, &$aPatternValue, &$aDensity){ + switch( $aPattern ) { + case PATTERN_DIAG1: + $aPatternValue= 1; + $aDensity = 92; + break; + case PATTERN_DIAG2: + $aPatternValue= 1; + $aDensity = 78; + break; + case PATTERN_DIAG3: + $aPatternValue= 2; + $aDensity = 92; + break; + case PATTERN_DIAG4: + $aPatternValue= 2; + $aDensity = 78; + break; + case PATTERN_CROSS1: + $aPatternValue= 8; + $aDensity = 90; + break; + case PATTERN_CROSS2: + $aPatternValue= 8; + $aDensity = 78; + break; + case PATTERN_CROSS3: + $aPatternValue= 8; + $aDensity = 65; + break; + case PATTERN_CROSS4: + $aPatternValue= 7; + $aDensity = 90; + break; + case PATTERN_STRIPE1: + $aPatternValue= 5; + $aDensity = 94; + break; + case PATTERN_STRIPE2: + $aPatternValue= 5; + $aDensity = 85; + break; + default: + JpGraphError::RaiseL(2002); + //('Unknown pattern specified in call to BarPlot::SetPattern()'); + } + } + + function Stroke($img,$xscale,$yscale) { + + $numpoints = count($this->coords[0]); + if( isset($this->coords[1]) ) { + if( count($this->coords[1])!=$numpoints ) { + JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints); + //"Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])."Number of Y-points:$numpoints"); + } + else { + $exist_x = true; + } + } + else { + $exist_x = false; + } + + + $numbars=count($this->coords[0]); + + // Use GetMinVal() instead of scale[0] directly since in the case + // of log scale we get a correct value. Log scales will have negative + // values for values < 1 while still not representing negative numbers. + if( $yscale->GetMinVal() >= 0 ) + $zp=$yscale->scale_abs[0]; + else { + $zp=$yscale->Translate(0); + } + + if( $this->abswidth > -1 ) { + $abswidth=$this->abswidth; + } + else { + $abswidth=round($this->width*$xscale->scale_factor,0); + } + + // Count pontetial pattern array to avoid doing the count for each iteration + if( is_array($this->iPattern) ) { + $np = count($this->iPattern); + } + + $grad = null; + for($i=0; $i < $numbars; ++$i) { + + // If value is NULL, or 0 then don't draw a bar at all + if ($this->coords[0][$i] === null || $this->coords[0][$i] === '' ) + continue; + + if( $exist_x ) { + $x=$this->coords[1][$i]; + } + else { + $x=$i; + } + + $x=$xscale->Translate($x); + + // Comment Note: This confuses the positioning when using acc together with + // grouped bars. Workaround for fixing #191 + /* + if( !$xscale->textscale ) { + if($this->align=="center") + $x -= $abswidth/2; + elseif($this->align=="right") + $x -= $abswidth; + } + */ + // Stroke fill color and fill gradient + $pts=array( + $x,$zp, + $x,$yscale->Translate($this->coords[0][$i]), + $x+$abswidth,$yscale->Translate($this->coords[0][$i]), + $x+$abswidth,$zp); + if( $this->grad ) { + if( $grad === null ) { + $grad = new Gradient($img); + } + if( is_array($this->grad_fromcolor) ) { + // The first argument (grad_fromcolor) can be either an array or a single color. If it is an array + // then we have two choices. It can either a) be a single color specified as an RGB triple or it can be + // an array to specify both (from, to style) for each individual bar. The way to know the difference is + // to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB + // triple. + $ng = count($this->grad_fromcolor); + if( $ng === 3 ) { + if( is_numeric($this->grad_fromcolor[0]) && $this->grad_fromcolor[0] > 0 && $this->grad_fromcolor[0] < 256 ) { + // RGB Triple + $fromcolor = $this->grad_fromcolor; + $tocolor = $this->grad_tocolor; + $style = $this->grad_style; + } + else { + $fromcolor = $this->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->grad_fromcolor[$i % $ng][1]; + $style = $this->grad_fromcolor[$i % $ng][2]; + } + } + else { + $fromcolor = $this->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->grad_fromcolor[$i % $ng][1]; + $style = $this->grad_fromcolor[$i % $ng][2]; + } + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $fromcolor,$tocolor,$style); + } + else { + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $this->grad_fromcolor,$this->grad_tocolor,$this->grad_style); + } + } + elseif( !empty($this->fill_color) ) { + if(is_array($this->fill_color)) { + $img->PushColor($this->fill_color[$i % count($this->fill_color)]); + } else { + $img->PushColor($this->fill_color); + } + $img->FilledPolygon($pts); + $img->PopColor(); + } + +/////////////////////////kokorahen rectangle polygon////////////////////// + + // Remember value of this bar + $val=$this->coords[0][$i]; + + if( !empty($val) && !is_numeric($val) ) { + JpGraphError::RaiseL(2004,$i,$val); + //'All values for a barplot must be numeric. You have specified value['.$i.'] == \''.$val.'\''); + } + + // Determine the shadow + if( $this->bar_shadow && $val != 0) { + + $ssh = $this->bar_shadow_hsize; + $ssv = $this->bar_shadow_vsize; + // Create points to create a "upper-right" shadow + if( $val > 0 ) { + $sp[0]=$pts[6]; $sp[1]=$pts[7]; + $sp[2]=$pts[4]; $sp[3]=$pts[5]; + $sp[4]=$pts[2]; $sp[5]=$pts[3]; + $sp[6]=$pts[2]+$ssh; $sp[7]=$pts[3]-$ssv; + $sp[8]=$pts[4]+$ssh; $sp[9]=$pts[5]-$ssv; + $sp[10]=$pts[6]+$ssh; $sp[11]=$pts[7]-$ssv; + } + elseif( $val < 0 ) { + $sp[0]=$pts[4]; $sp[1]=$pts[5]; + $sp[2]=$pts[6]; $sp[3]=$pts[7]; + $sp[4]=$pts[0]; $sp[5]=$pts[1]; + $sp[6]=$pts[0]+$ssh; $sp[7]=$pts[1]-$ssv; + $sp[8]=$pts[6]+$ssh; $sp[9]=$pts[7]-$ssv; + $sp[10]=$pts[4]+$ssh; $sp[11]=$pts[5]-$ssv; + } + if( is_array($this->bar_shadow_color) ) { + $numcolors = count($this->bar_shadow_color); + if( $numcolors == 0 ) { + JpGraphError::RaiseL(2005);//('You have specified an empty array for shadow colors in the bar plot.'); + } + $img->PushColor($this->bar_shadow_color[$i % $numcolors]); + } + else { + $img->PushColor($this->bar_shadow_color); + } + $img->FilledPolygon($sp); + $img->PopColor(); + + } elseif( $this->bar_3d && $val != 0) { + // Determine the 3D + + $ssh = $this->bar_3d_hsize; + $ssv = $this->bar_3d_vsize; + + // Create points to create a "upper-right" shadow + if( $val > 0 ) { + $sp1[0]=$pts[6]; $sp1[1]=$pts[7]; + $sp1[2]=$pts[4]; $sp1[3]=$pts[5]; + $sp1[4]=$pts[4]+$ssh; $sp1[5]=$pts[5]-$ssv; + $sp1[6]=$pts[6]+$ssh; $sp1[7]=$pts[7]-$ssv; + + $sp2[0]=$pts[4]; $sp2[1]=$pts[5]; + $sp2[2]=$pts[2]; $sp2[3]=$pts[3]; + $sp2[4]=$pts[2]+$ssh; $sp2[5]=$pts[3]-$ssv; + $sp2[6]=$pts[4]+$ssh; $sp2[7]=$pts[5]-$ssv; + + } + elseif( $val < 0 ) { + $sp1[0]=$pts[4]; $sp1[1]=$pts[5]; + $sp1[2]=$pts[6]; $sp1[3]=$pts[7]; + $sp1[4]=$pts[6]+$ssh; $sp1[5]=$pts[7]-$ssv; + $sp1[6]=$pts[4]+$ssh; $sp1[7]=$pts[5]-$ssv; + + $sp2[0]=$pts[6]; $sp2[1]=$pts[7]; + $sp2[2]=$pts[0]; $sp2[3]=$pts[1]; + $sp2[4]=$pts[0]+$ssh; $sp2[5]=$pts[1]-$ssv; + $sp2[6]=$pts[6]+$ssh; $sp2[7]=$pts[7]-$ssv; + } + + $base_color = $this->fill_color; + + $img->PushColor($base_color . ':0.7'); + $img->FilledPolygon($sp1); + $img->PopColor(); + + $img->PushColor($base_color . ':1.1'); + $img->FilledPolygon($sp2); + $img->PopColor(); + } + + // Stroke the pattern + if( is_array($this->iPattern) ) { + $f = new RectPatternFactory(); + if( is_array($this->iPatternColor) ) { + $pcolor = $this->iPatternColor[$i % $np]; + } + else { + $pcolor = $this->iPatternColor; + } + $prect = $f->Create($this->iPattern[$i % $np],$pcolor,1); + $prect->SetDensity($this->iPatternDensity[$i % $np]); + + if( $val < 0 ) { + $rx = $pts[0]; + $ry = $pts[1]; + } + else { + $rx = $pts[2]; + $ry = $pts[3]; + } + $width = abs($pts[4]-$pts[0])+1; + $height = abs($pts[1]-$pts[3])+1; + $prect->SetPos(new Rectangle($rx,$ry,$width,$height)); + $prect->Stroke($img); + } + else { + if( $this->iPattern > -1 ) { + $f = new RectPatternFactory(); + $prect = $f->Create($this->iPattern,$this->iPatternColor,1); + $prect->SetDensity($this->iPatternDensity); + if( $val < 0 ) { + $rx = $pts[0]; + $ry = $pts[1]; + } + else { + $rx = $pts[2]; + $ry = $pts[3]; + } + $width = abs($pts[4]-$pts[0])+1; + $height = abs($pts[1]-$pts[3])+1; + $prect->SetPos(new Rectangle($rx,$ry,$width,$height)); + $prect->Stroke($img); + } + } + + // Stroke the outline of the bar + if( is_array($this->color) ) { + $img->SetColor($this->color[$i % count($this->color)]); + } + else { + $img->SetColor($this->color); + } + + $pts[] = $pts[0]; + $pts[] = $pts[1]; + + if( $this->weight > 0 ) { + $img->SetLineWeight($this->weight); + $img->Polygon($pts); + } + + // Determine how to best position the values of the individual bars + $x=$pts[2]+($pts[4]-$pts[2])/2; + $this->value->SetMargin(5); + + if( $this->valuepos=='top' ) { + $y=$pts[3]; + if( $img->a === 90 ) { + if( $val < 0 ) { + $this->value->SetAlign('right','center'); + } + else { + $this->value->SetAlign('left','center'); + } + + } + else { + if( $val < 0 ) { + $this->value->SetMargin(-5); + $y=$pts[1]; + $this->value->SetAlign('center','bottom'); + } + else { + $this->value->SetAlign('center','bottom'); + } + + } + $this->value->Stroke($img,$val,$x,$y); + } + elseif( $this->valuepos=='max' ) { + $y=$pts[3]; + if( $img->a === 90 ) { + if( $val < 0 ) + $this->value->SetAlign('left','center'); + else + $this->value->SetAlign('right','center'); + } + else { + if( $val < 0 ) { + $this->value->SetAlign('center','bottom'); + } + else { + $this->value->SetAlign('center','top'); + } + } + $this->value->SetMargin(-5); + $this->value->Stroke($img,$val,$x,$y); + } + elseif( $this->valuepos=='center' ) { + $y = ($pts[3] + $pts[1])/2; + $this->value->SetAlign('center','center'); + $this->value->SetMargin(0); + $this->value->Stroke($img,$val,$x,$y); + } + elseif( $this->valuepos=='bottom' || $this->valuepos=='min' ) { + $y=$pts[1]; + if( $img->a === 90 ) { + if( $val < 0 ) + $this->value->SetAlign('right','center'); + else + $this->value->SetAlign('left','center'); + } + $this->value->SetMargin(3); + $this->value->Stroke($img,$val,$x,$y); + } + else { + JpGraphError::RaiseL(2006,$this->valuepos); + //'Unknown position for values on bars :'.$this->valuepos); + } + // Create the client side image map + $rpts = $img->ArrRotate($pts); + $csimcoord=round($rpts[0]).", ".round($rpts[1]); + for( $j=1; $j < 4; ++$j){ + $csimcoord .= ", ".round($rpts[2*$j]).", ".round($rpts[2*$j+1]); + } + if( !empty($this->csimtargets[$i]) ) { + $this->csimareas .= '<area shape="poly" coords="'.$csimcoord.'" '; + $this->csimareas .= " href=\"".htmlentities($this->csimtargets[$i])."\""; + + if( !empty($this->csimwintargets[$i]) ) { + $this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" "; + } + + $sval=''; + if( !empty($this->csimalts[$i]) ) { + $sval=sprintf($this->csimalts[$i],$this->coords[0][$i]); + $this->csimareas .= " title=\"$sval\" alt=\"$sval\" "; + } + $this->csimareas .= " />\n"; + } + } + return true; + } +} // Class + +//=================================================== +// CLASS GroupBarPlot +// Description: Produce grouped bar plots +//=================================================== +class GroupBarPlot extends BarPlot { + public $plots; + private $nbrplots=0; + //--------------- + // CONSTRUCTOR + function GroupBarPlot($plots) { + $this->width=0.7; + $this->plots = $plots; + $this->nbrplots = count($plots); + if( $this->nbrplots < 1 ) { + JpGraphError::RaiseL(2007);//('Cannot create GroupBarPlot from empty plot array.'); + } + for($i=0; $i < $this->nbrplots; ++$i ) { + if( empty($this->plots[$i]) || !isset($this->plots[$i]) ) { + JpGraphError::RaiseL(2008,$i);//("Group bar plot element nbr $i is undefined or empty."); + } + } + $this->numpoints = $plots[0]->numpoints; + $this->width=0.7; + } + + //--------------- + // PUBLIC METHODS + function Legend($graph) { + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + $c = get_class($this->plots[$i]); + if( !($this->plots[$i] instanceof BarPlot) ) { + JpGraphError::RaiseL(2009,$c); + //('One of the objects submitted to GroupBar is not a BarPlot. Make sure that you create the Group Bar plot from an array of BarPlot or AccBarPlot objects. (Class = '.$c.')'); + } + $this->plots[$i]->DoLegend($graph); + } + } + + function Min() { + list($xmin,$ymin) = $this->plots[0]->Min(); + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + list($xm,$ym) = $this->plots[$i]->Min(); + $xmin = max($xmin,$xm); + $ymin = min($ymin,$ym); + } + return array($xmin,$ymin); + } + + function Max() { + list($xmax,$ymax) = $this->plots[0]->Max(); + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + list($xm,$ym) = $this->plots[$i]->Max(); + $xmax = max($xmax,$xm); + $ymax = max($ymax,$ym); + } + return array($xmax,$ymax); + } + + function GetCSIMareas() { + $n = count($this->plots); + $csimareas=''; + for($i=0; $i < $n; ++$i) { + $csimareas .= $this->plots[$i]->csimareas; + } + return $csimareas; + } + + // Stroke all the bars next to each other + function Stroke($img,$xscale,$yscale) { + $tmp=$xscale->off; + $n = count($this->plots); + $subwidth = $this->width/$this->nbrplots ; + + for( $i=0; $i < $n; ++$i ) { + $this->plots[$i]->ymin=$this->ybase; + $this->plots[$i]->SetWidth($subwidth); + + // If the client have used SetTextTickInterval() then + // major_step will be > 1 and the positioning will fail. + // If we assume it is always one the positioning will work + // fine with a text scale but this will not work with + // arbitrary linear scale + $xscale->off = $tmp+$i*round($xscale->scale_factor* $subwidth); + $this->plots[$i]->Stroke($img,$xscale,$yscale); + } + $xscale->off=$tmp; + } +} // Class + +//=================================================== +// CLASS AccBarPlot +// Description: Produce accumulated bar plots +//=================================================== +class AccBarPlot extends BarPlot { + public $plots=null; + private $nbrplots=0; + //--------------- + // CONSTRUCTOR + function __construct($plots) { + $this->plots = $plots; + $this->nbrplots = count($plots); + if( $this->nbrplots < 1 ) { + JpGraphError::RaiseL(2010);//('Cannot create AccBarPlot from empty plot array.'); + } + for($i=0; $i < $this->nbrplots; ++$i ) { + if( empty($this->plots[$i]) || !isset($this->plots[$i]) ) { + JpGraphError::RaiseL(2011,$i);//("Acc bar plot element nbr $i is undefined or empty."); + } + } + + // We can only allow individual plost which do not have specified X-positions + for($i=0; $i < $this->nbrplots; ++$i ) { + if( !empty($this->plots[$i]->coords[1]) ) { + JpGraphError::RaiseL(2015); + //'Individual bar plots in an AccBarPlot or GroupBarPlot can not have specified X-positions.'); + } + } + + // Use 0 weight by default which means that the individual bar + // weights will be used per part n the accumulated bar + $this->SetWeight(0); + + $this->numpoints = $plots[0]->numpoints; + $this->value = new DisplayValue(); + } + + //--------------- + // PUBLIC METHODS + function Legend($graph) { + $n = count($this->plots); + for( $i=$n-1; $i >= 0; --$i ) { + $c = get_class($this->plots[$i]); + if( !($this->plots[$i] instanceof BarPlot) ) { + JpGraphError::RaiseL(2012,$c); + //('One of the objects submitted to AccBar is not a BarPlot. Make sure that you create the AccBar plot from an array of BarPlot objects.(Class='.$c.')'); + } + $this->plots[$i]->DoLegend($graph); + } + } + + function Max() { + list($xmax) = $this->plots[0]->Max(); + $nmax=0; + for($i=0; $i < count($this->plots); ++$i) { + $n = count($this->plots[$i]->coords[0]); + $nmax = max($nmax,$n); + list($x) = $this->plots[$i]->Max(); + $xmax = max($xmax,$x); + } + for( $i = 0; $i < $nmax; $i++ ) { + // Get y-value for bar $i by adding the + // individual bars from all the plots added. + // It would be wrong to just add the + // individual plots max y-value since that + // would in most cases give to large y-value. + $y=0; + if( !isset($this->plots[0]->coords[0][$i]) ) { + JpGraphError::RaiseL(2014); + } + if( $this->plots[0]->coords[0][$i] > 0 ) + $y=$this->plots[0]->coords[0][$i]; + for( $j = 1; $j < $this->nbrplots; $j++ ) { + if( !isset($this->plots[$j]->coords[0][$i]) ) { + JpGraphError::RaiseL(2014); + } + if( $this->plots[$j]->coords[0][$i] > 0 ) + $y += $this->plots[$j]->coords[0][$i]; + } + $ymax[$i] = $y; + } + $ymax = max($ymax); + + // Bar always start at baseline + if( $ymax <= $this->ybase ) + $ymax = $this->ybase; + return array($xmax,$ymax); + } + + function Min() { + $nmax=0; + list($xmin,$ysetmin) = $this->plots[0]->Min(); + for($i=0; $i < count($this->plots); ++$i) { + $n = count($this->plots[$i]->coords[0]); + $nmax = max($nmax,$n); + list($x,$y) = $this->plots[$i]->Min(); + $xmin = Min($xmin,$x); + $ysetmin = Min($y,$ysetmin); + } + for( $i = 0; $i < $nmax; $i++ ) { + // Get y-value for bar $i by adding the + // individual bars from all the plots added. + // It would be wrong to just add the + // individual plots max y-value since that + // would in most cases give to large y-value. + $y=0; + if( $this->plots[0]->coords[0][$i] < 0 ) + $y=$this->plots[0]->coords[0][$i]; + for( $j = 1; $j < $this->nbrplots; $j++ ) { + if( $this->plots[$j]->coords[0][$i] < 0 ) + $y += $this->plots[ $j ]->coords[0][$i]; + } + $ymin[$i] = $y; + } + $ymin = Min($ysetmin,Min($ymin)); + // Bar always start at baseline + if( $ymin >= $this->ybase ) + $ymin = $this->ybase; + return array($xmin,$ymin); + } + + // Stroke acc bar plot + function Stroke($img,$xscale,$yscale) { + $pattern=NULL; + $img->SetLineWeight($this->weight); + $grad=null; + for($i=0; $i < $this->numpoints-1; $i++) { + $accy = 0; + $accy_neg = 0; + for($j=0; $j < $this->nbrplots; ++$j ) { + $img->SetColor($this->plots[$j]->color); + + if ( $this->plots[$j]->coords[0][$i] >= 0) { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy); + $accyt=$yscale->Translate($accy); + $accy+=$this->plots[$j]->coords[0][$i]; + } + else { + //if ( $this->plots[$j]->coords[0][$i] < 0 || $accy_neg < 0 ) { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy_neg); + $accyt=$yscale->Translate($accy_neg); + $accy_neg+=$this->plots[$j]->coords[0][$i]; + } + + $xt=$xscale->Translate($i); + + if( $this->abswidth > -1 ) { + $abswidth=$this->abswidth; + } + else { + $abswidth=round($this->width*$xscale->scale_factor,0); + } + + $pts=array($xt,$accyt,$xt,$yt,$xt+$abswidth,$yt,$xt+$abswidth,$accyt); + + if( $this->bar_shadow ) { + $ssh = $this->bar_shadow_hsize; + $ssv = $this->bar_shadow_vsize; + + // We must also differ if we are a positive or negative bar. + if( $j === 0 ) { + // This gets extra complicated since we have to + // see all plots to see if we are negative. It could + // for example be that all plots are 0 until the very + // last one. We therefore need to save the initial setup + // for both the negative and positive case + + // In case the final bar is positive + $sp[0]=$pts[6]+1; $sp[1]=$pts[7]; + $sp[2]=$pts[6]+$ssh; $sp[3]=$pts[7]-$ssv; + + // In case the final bar is negative + $nsp[0]=$pts[0]; $nsp[1]=$pts[1]; + $nsp[2]=$pts[0]+$ssh; $nsp[3]=$pts[1]-$ssv; + $nsp[4]=$pts[6]+$ssh; $nsp[5]=$pts[7]-$ssv; + $nsp[10]=$pts[6]+1; $nsp[11]=$pts[7]; + } + + if( $j === $this->nbrplots-1 ) { + // If this is the last plot of the bar and + // the total value is larger than 0 then we + // add the shadow. + if( is_array($this->bar_shadow_color) ) { + $numcolors = count($this->bar_shadow_color); + if( $numcolors == 0 ) { + JpGraphError::RaiseL(2013);//('You have specified an empty array for shadow colors in the bar plot.'); + } + $img->PushColor($this->bar_shadow_color[$i % $numcolors]); + } + else { + $img->PushColor($this->bar_shadow_color); + } + + if( $accy > 0 ) { + $sp[4]=$pts[4]+$ssh; $sp[5]=$pts[5]-$ssv; + $sp[6]=$pts[2]+$ssh; $sp[7]=$pts[3]-$ssv; + $sp[8]=$pts[2]; $sp[9]=$pts[3]-1; + $sp[10]=$pts[4]+1; $sp[11]=$pts[5]; + $img->FilledPolygon($sp,4); + } + elseif( $accy_neg < 0 ) { + $nsp[6]=$pts[4]+$ssh; $nsp[7]=$pts[5]-$ssv; + $nsp[8]=$pts[4]+1; $nsp[9]=$pts[5]; + $img->FilledPolygon($nsp,4); + } + $img->PopColor(); + } + } + + + // If value is NULL or 0, then don't draw a bar at all + if ($this->plots[$j]->coords[0][$i] == 0 ) continue; + + if( $this->plots[$j]->grad ) { + if( $grad === null ) { + $grad = new Gradient($img); + } + if( is_array($this->plots[$j]->grad_fromcolor) ) { + // The first argument (grad_fromcolor) can be either an array or a single color. If it is an array + // then we have two choices. It can either a) be a single color specified as an RGB triple or it can be + // an array to specify both (from, to style) for each individual bar. The way to know the difference is + // to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB + // triple. + $ng = count($this->plots[$j]->grad_fromcolor); + if( $ng === 3 ) { + if( is_numeric($this->plots[$j]->grad_fromcolor[0]) && $this->plots[$j]->grad_fromcolor[0] > 0 && + $this->plots[$j]->grad_fromcolor[0] < 256 ) { + // RGB Triple + $fromcolor = $this->plots[$j]->grad_fromcolor; + $tocolor = $this->plots[$j]->grad_tocolor; + $style = $this->plots[$j]->grad_style; + } + else { + $fromcolor = $this->plots[$j]->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->plots[$j]->grad_fromcolor[$i % $ng][1]; + $style = $this->plots[$j]->grad_fromcolor[$i % $ng][2]; + } + } + else { + $fromcolor = $this->plots[$j]->grad_fromcolor[$i % $ng][0]; + $tocolor = $this->plots[$j]->grad_fromcolor[$i % $ng][1]; + $style = $this->plots[$j]->grad_fromcolor[$i % $ng][2]; + } + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $fromcolor,$tocolor,$style); + } + else { + $grad->FilledRectangle($pts[2],$pts[3], + $pts[6],$pts[7], + $this->plots[$j]->grad_fromcolor, + $this->plots[$j]->grad_tocolor, + $this->plots[$j]->grad_style); + } + } else { + if (is_array($this->plots[$j]->fill_color) ) { + $numcolors = count($this->plots[$j]->fill_color); + $fillcolor = $this->plots[$j]->fill_color[$i % $numcolors]; + // If the bar is specified to be non filled then the fill color is false + if( $fillcolor !== false ) { + $img->SetColor($this->plots[$j]->fill_color[$i % $numcolors]); + } + } + else { + $fillcolor = $this->plots[$j]->fill_color; + if( $fillcolor !== false ) { + $img->SetColor($this->plots[$j]->fill_color); + } + } + if( $fillcolor !== false ) { + $img->FilledPolygon($pts); + } + } + + $img->SetColor($this->plots[$j]->color); + + // Stroke the pattern + if( $this->plots[$j]->iPattern > -1 ) { + if( $pattern===NULL ) { + $pattern = new RectPatternFactory(); + } + + $prect = $pattern->Create($this->plots[$j]->iPattern,$this->plots[$j]->iPatternColor,1); + $prect->SetDensity($this->plots[$j]->iPatternDensity); + if( $this->plots[$j]->coords[0][$i] < 0 ) { + $rx = $pts[0]; + $ry = $pts[1]; + } + else { + $rx = $pts[2]; + $ry = $pts[3]; + } + $width = abs($pts[4]-$pts[0])+1; + $height = abs($pts[1]-$pts[3])+1; + $prect->SetPos(new Rectangle($rx,$ry,$width,$height)); + $prect->Stroke($img); + } + + + // CSIM array + + if( $i < count($this->plots[$j]->csimtargets) ) { + // Create the client side image map + $rpts = $img->ArrRotate($pts); + $csimcoord=round($rpts[0]).", ".round($rpts[1]); + for( $k=1; $k < 4; ++$k){ + $csimcoord .= ", ".round($rpts[2*$k]).", ".round($rpts[2*$k+1]); + } + if( ! empty($this->plots[$j]->csimtargets[$i]) ) { + $this->csimareas.= '<area shape="poly" coords="'.$csimcoord.'" '; + $this->csimareas.= " href=\"".$this->plots[$j]->csimtargets[$i]."\" "; + + if( ! empty($this->plots[$j]->csimwintargets[$i]) ) { + $this->csimareas.= " target=\"".$this->plots[$j]->csimwintargets[$i]."\" "; + } + + $sval=''; + if( !empty($this->plots[$j]->csimalts[$i]) ) { + $sval=sprintf($this->plots[$j]->csimalts[$i],$this->plots[$j]->coords[0][$i]); + $this->csimareas .= " title=\"$sval\" "; + } + $this->csimareas .= " alt=\"$sval\" />\n"; + } + } + + $pts[] = $pts[0]; + $pts[] = $pts[1]; + $img->SetLineWeight($this->plots[$j]->weight); + $img->Polygon($pts); + $img->SetLineWeight(1); + } + + // Daw potential bar around the entire accbar bar + if( $this->weight > 0 ) { + $y=$yscale->Translate(0); + $img->SetColor($this->color); + $img->SetLineWeight($this->weight); + $img->Rectangle($pts[0],$y,$pts[6],$pts[5]); + } + + // Draw labels for each acc.bar + + $x=$pts[2]+($pts[4]-$pts[2])/2; + if($this->bar_shadow) $x += $ssh; + + // First stroke the accumulated value for the entire bar + // This value is always placed at the top/bottom of the bars + if( $accy_neg < 0 ) { + $y=$yscale->Translate($accy_neg); + $this->value->Stroke($img,$accy_neg,$x,$y); + } + else { + $y=$yscale->Translate($accy); + $this->value->Stroke($img,$accy,$x,$y); + } + + $accy = 0; + $accy_neg = 0; + for($j=0; $j < $this->nbrplots; ++$j ) { + + // We don't print 0 values in an accumulated bar plot + if( $this->plots[$j]->coords[0][$i] == 0 ) continue; + + if ($this->plots[$j]->coords[0][$i] > 0) { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy); + $accyt=$yscale->Translate($accy); + if( $this->plots[$j]->valuepos=='center' ) { + $y = $accyt-($accyt-$yt)/2; + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $y = $accyt; + } + else { // top or max + $y = $accyt-($accyt-$yt); + } + $accy+=$this->plots[$j]->coords[0][$i]; + if( $this->plots[$j]->valuepos=='center' ) { + $this->plots[$j]->value->SetAlign("center","center"); + $this->plots[$j]->value->SetMargin(0); + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $this->plots[$j]->value->SetAlign('center','bottom'); + $this->plots[$j]->value->SetMargin(2); + } + else { + $this->plots[$j]->value->SetAlign('center','top'); + $this->plots[$j]->value->SetMargin(1); + } + } else { + $yt=$yscale->Translate($this->plots[$j]->coords[0][$i]+$accy_neg); + $accyt=$yscale->Translate($accy_neg); + $accy_neg+=$this->plots[$j]->coords[0][$i]; + if( $this->plots[$j]->valuepos=='center' ) { + $y = $accyt-($accyt-$yt)/2; + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $y = $accyt; + } + else { + $y = $accyt-($accyt-$yt); + } + if( $this->plots[$j]->valuepos=='center' ) { + $this->plots[$j]->value->SetAlign("center","center"); + $this->plots[$j]->value->SetMargin(0); + } + elseif( $this->plots[$j]->valuepos=='bottom' ) { + $this->plots[$j]->value->SetAlign('center',$j==0 ? 'bottom':'top'); + $this->plots[$j]->value->SetMargin(-2); + } + else { + $this->plots[$j]->value->SetAlign('center','bottom'); + $this->plots[$j]->value->SetMargin(-1); + } + } + $this->plots[$j]->value->Stroke($img,$this->plots[$j]->coords[0][$i],$x,$y); + } + + } + return true; + } +} // Class + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_canvas.php b/html/jpgraph/jpgraph_canvas.php new file mode 100644 index 0000000..f942951 --- /dev/null +++ b/html/jpgraph/jpgraph_canvas.php @@ -0,0 +1,95 @@ +<?php +/*======================================================================= + // File: JPGRAPH_CANVAS.PHP + // Description: Canvas drawing extension for JpGraph + // Created: 2001-01-08 + // Ver: $Id: jpgraph_canvas.php 1923 2010-01-11 13:48:49Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +//=================================================== +// CLASS CanvasGraph +// Description: Creates a simple canvas graph which +// might be used together with the basic Image drawing +// primitives. Useful to auickoly produce some arbitrary +// graphic which benefits from all the functionality in the +// graph liek caching for example. +//=================================================== +class CanvasGraph extends Graph { + //--------------- + // CONSTRUCTOR + function __construct($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) { + parent::__construct($aWidth,$aHeight,$aCachedName,$timeout,$inline); + } + + //--------------- + // PUBLIC METHODS + + function InitFrame() { + $this->StrokePlotArea(); + } + + // Method description + function Stroke($aStrokeFileName="") { + if( $this->texts != null ) { + for($i=0; $i < count($this->texts); ++$i) { + $this->texts[$i]->Stroke($this->img); + } + } + if( $this->iTables !== null ) { + for($i=0; $i < count($this->iTables); ++$i) { + $this->iTables[$i]->Stroke($this->img); + } + } + $this->StrokeTitles(); + + // If the filename is the predefined value = '_csim_special_' + // we assume that the call to stroke only needs to do enough + // to correctly generate the CSIM maps. + // We use this variable to skip things we don't strictly need + // to do to generate the image map to improve performance + // a best we can. Therefor you will see a lot of tests !$_csim in the + // code below. + $_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); + + // We need to know if we have stroked the plot in the + // GetCSIMareas. Otherwise the CSIM hasn't been generated + // and in the case of GetCSIM called before stroke to generate + // CSIM without storing an image to disk GetCSIM must call Stroke. + $this->iHasStroked = true; + + if( !$_csim ) { + + // Should we do any final image transformation + if( $this->iImgTrans ) { + if( !class_exists('ImgTrans',false) ) { + require_once('jpgraph_imgtrans.php'); + } + + $tform = new ImgTrans($this->img->img); + $this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, + $this->iImgTransDirection,$this->iImgTransHighQ, + $this->iImgTransMinSize,$this->iImgTransFillColor, + $this->iImgTransBorder); + } + + + // If the filename is given as the special _IMG_HANDLER + // then the image handler is returned and the image is NOT + // streamed back + if( $aStrokeFileName == _IMG_HANDLER ) { + return $this->img->img; + } + else { + // Finally stream the generated picture + $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName); + return true; + } + } + } +} // Class + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_canvtools.php b/html/jpgraph/jpgraph_canvtools.php new file mode 100644 index 0000000..2290a5b --- /dev/null +++ b/html/jpgraph/jpgraph_canvtools.php @@ -0,0 +1,523 @@ +<?php +/*======================================================================= + // File: JPGRAPH_CANVTOOLS.PHP + // Description: Some utilities for text and shape drawing on a canvas + // Created: 2002-08-23 + // Ver: $Id: jpgraph_canvtools.php 1857 2009-09-28 14:38:14Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +define('CORNER_TOPLEFT',0); +define('CORNER_TOPRIGHT',1); +define('CORNER_BOTTOMRIGHT',2); +define('CORNER_BOTTOMLEFT',3); + + +//=================================================== +// CLASS CanvasScale +// Description: Define a scale for canvas so we +// can abstract away with absolute pixels +//=================================================== + +class CanvasScale { + private $g; + private $w,$h; + private $ixmin=0,$ixmax=10,$iymin=0,$iymax=10; + + function __construct($graph,$xmin=0,$xmax=10,$ymin=0,$ymax=10) { + $this->g = $graph; + $this->w = $graph->img->width; + $this->h = $graph->img->height; + $this->ixmin = $xmin; + $this->ixmax = $xmax; + $this->iymin = $ymin; + $this->iymax = $ymax; + } + + function Set($xmin=0,$xmax=10,$ymin=0,$ymax=10) { + $this->ixmin = $xmin; + $this->ixmax = $xmax; + $this->iymin = $ymin; + $this->iymax = $ymax; + } + + function Get() { + return array($this->ixmin,$this->ixmax,$this->iymin,$this->iymax); + } + + function Translate($x,$y) { + $xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w); + $yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h); + return array($xp,$yp); + } + + function TranslateX($x) { + $xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w); + return $xp; + } + + function TranslateY($y) { + $yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h); + return $yp; + } + +} + + +//=================================================== +// CLASS Shape +// Description: Methods to draw shapes on canvas +//=================================================== +class Shape { + private $img,$scale; + + function __construct($aGraph,$scale) { + $this->img = $aGraph->img; + $this->img->SetColor('black'); + $this->scale = $scale; + } + + function SetColor($aColor) { + $this->img->SetColor($aColor); + } + + function Line($x1,$y1,$x2,$y2) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + list($x2,$y2) = $this->scale->Translate($x2,$y2); + $this->img->Line($x1,$y1,$x2,$y2); + } + + function SetLineWeight($aWeight) { + $this->img->SetLineWeight($aWeight); + } + + function Polygon($p,$aClosed=false) { + $n=count($p); + for($i=0; $i < $n; $i+=2 ) { + $p[$i] = $this->scale->TranslateX($p[$i]); + $p[$i+1] = $this->scale->TranslateY($p[$i+1]); + } + $this->img->Polygon($p,$aClosed); + } + + function FilledPolygon($p) { + $n=count($p); + for($i=0; $i < $n; $i+=2 ) { + $p[$i] = $this->scale->TranslateX($p[$i]); + $p[$i+1] = $this->scale->TranslateY($p[$i+1]); + } + $this->img->FilledPolygon($p); + } + + + // Draw a bezier curve with defining points in the $aPnts array + // using $aSteps steps. + // 0=x0, 1=y0 + // 2=x1, 3=y1 + // 4=x2, 5=y2 + // 6=x3, 7=y3 + function Bezier($p,$aSteps=40) { + $x0 = $p[0]; + $y0 = $p[1]; + // Calculate coefficients + $cx = 3*($p[2]-$p[0]); + $bx = 3*($p[4]-$p[2])-$cx; + $ax = $p[6]-$p[0]-$cx-$bx; + $cy = 3*($p[3]-$p[1]); + $by = 3*($p[5]-$p[3])-$cy; + $ay = $p[7]-$p[1]-$cy-$by; + + // Step size + $delta = 1.0/$aSteps; + + $x_old = $x0; + $y_old = $y0; + for($t=$delta; $t<=1.0; $t+=$delta) { + $tt = $t*$t; $ttt=$tt*$t; + $x = $ax*$ttt + $bx*$tt + $cx*$t + $x0; + $y = $ay*$ttt + $by*$tt + $cy*$t + $y0; + $this->Line($x_old,$y_old,$x,$y); + $x_old = $x; + $y_old = $y; + } + $this->Line($x_old,$y_old,$p[6],$p[7]); + } + + function Rectangle($x1,$y1,$x2,$y2) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + list($x2,$y2) = $this->scale->Translate($x2,$y2); + $this->img->Rectangle($x1,$y1,$x2,$y2); + } + + function FilledRectangle($x1,$y1,$x2,$y2) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + list($x2,$y2) = $this->scale->Translate($x2,$y2); + $this->img->FilledRectangle($x1,$y1,$x2,$y2); + } + + function Circle($x1,$y1,$r) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + if( $r >= 0 ) + $r = $this->scale->TranslateX($r); + else + $r = -$r; + $this->img->Circle($x1,$y1,$r); + } + + function FilledCircle($x1,$y1,$r) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + if( $r >= 0 ) + $r = $this->scale->TranslateX($r); + else + $r = -$r; + $this->img->FilledCircle($x1,$y1,$r); + } + + function RoundedRectangle($x1,$y1,$x2,$y2,$r=null) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + list($x2,$y2) = $this->scale->Translate($x2,$y2); + + if( $r == null ) + $r = 5; + elseif( $r >= 0 ) + $r = $this->scale->TranslateX($r); + else + $r = -$r; + $this->img->RoundedRectangle($x1,$y1,$x2,$y2,$r); + } + + function FilledRoundedRectangle($x1,$y1,$x2,$y2,$r=null) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + list($x2,$y2) = $this->scale->Translate($x2,$y2); + + if( $r == null ) + $r = 5; + elseif( $r > 0 ) + $r = $this->scale->TranslateX($r); + else + $r = -$r; + $this->img->FilledRoundedRectangle($x1,$y1,$x2,$y2,$r); + } + + function ShadowRectangle($x1,$y1,$x2,$y2,$fcolor=false,$shadow_width=null,$shadow_color=array(102,102,102)) { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + list($x2,$y2) = $this->scale->Translate($x2,$y2); + if( $shadow_width == null ) + $shadow_width=4; + else + $shadow_width=$this->scale->TranslateX($shadow_width); + $this->img->ShadowRectangle($x1,$y1,$x2,$y2,$fcolor,$shadow_width,$shadow_color); + } + + function SetTextAlign($halign,$valign="bottom") { + $this->img->SetTextAlign($halign,$valign="bottom"); + } + + function StrokeText($x1,$y1,$txt,$dir=0,$paragraph_align="left") { + list($x1,$y1) = $this->scale->Translate($x1,$y1); + $this->img->StrokeText($x1,$y1,$txt,$dir,$paragraph_align); + } + + // A rounded rectangle where one of the corner has been moved "into" the + // rectangle 'iw' width and 'ih' height. Corners: + // 0=Top left, 1=top right, 2=bottom right, 3=bottom left + function IndentedRectangle($xt,$yt,$w,$h,$iw=0,$ih=0,$aCorner=3,$aFillColor="",$r=4) { + + list($xt,$yt) = $this->scale->Translate($xt,$yt); + list($w,$h) = $this->scale->Translate($w,$h); + list($iw,$ih) = $this->scale->Translate($iw,$ih); + + $xr = $xt + $w - 0; + $yl = $yt + $h - 0; + + switch( $aCorner ) { + case 0: // Upper left + + // Bottom line, left & right arc + $this->img->Line($xt+$r,$yl,$xr-$r,$yl); + $this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180); + $this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90); + + // Right line, Top right arc + $this->img->Line($xr,$yt+$r,$xr,$yl-$r); + $this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360); + + // Top line, Top left arc + $this->img->Line($xt+$iw+$r,$yt,$xr-$r,$yt); + $this->img->Arc($xt+$iw+$r,$yt+$r,$r*2,$r*2,180,270); + + // Left line + $this->img->Line($xt,$yt+$ih+$r,$xt,$yl-$r); + + // Indent horizontal, Lower left arc + $this->img->Line($xt+$r,$yt+$ih,$xt+$iw-$r,$yt+$ih); + $this->img->Arc($xt+$r,$yt+$ih+$r,$r*2,$r*2,180,270); + + // Indent vertical, Indent arc + $this->img->Line($xt+$iw,$yt+$r,$xt+$iw,$yt+$ih-$r); + $this->img->Arc($xt+$iw-$r,$yt+$ih-$r,$r*2,$r*2,0,90); + + if( $aFillColor != '' ) { + $bc = $this->img->current_color_name; + $this->img->PushColor($aFillColor); + $this->img->FillToBorder($xr-$r,$yl-$r,$bc); + $this->img->PopColor(); + } + + break; + + case 1: // Upper right + + // Bottom line, left & right arc + $this->img->Line($xt+$r,$yl,$xr-$r,$yl); + $this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180); + $this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90); + + // Left line, Top left arc + $this->img->Line($xt,$yt+$r,$xt,$yl-$r); + $this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270); + + // Top line, Top right arc + $this->img->Line($xt+$r,$yt,$xr-$iw-$r,$yt); + $this->img->Arc($xr-$iw-$r,$yt+$r,$r*2,$r*2,270,360); + + // Right line + $this->img->Line($xr,$yt+$ih+$r,$xr,$yl-$r); + + // Indent horizontal, Lower right arc + $this->img->Line($xr-$iw+$r,$yt+$ih,$xr-$r,$yt+$ih); + $this->img->Arc($xr-$r,$yt+$ih+$r,$r*2,$r*2,270,360); + + // Indent vertical, Indent arc + $this->img->Line($xr-$iw,$yt+$r,$xr-$iw,$yt+$ih-$r); + $this->img->Arc($xr-$iw+$r,$yt+$ih-$r,$r*2,$r*2,90,180); + + if( $aFillColor != '' ) { + $bc = $this->img->current_color_name; + $this->img->PushColor($aFillColor); + $this->img->FillToBorder($xt+$r,$yl-$r,$bc); + $this->img->PopColor(); + } + + break; + + case 2: // Lower right + // Top line, Top left & Top right arc + $this->img->Line($xt+$r,$yt,$xr-$r,$yt); + $this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270); + $this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360); + + // Left line, Bottom left arc + $this->img->Line($xt,$yt+$r,$xt,$yl-$r); + $this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180); + + // Bottom line, Bottom right arc + $this->img->Line($xt+$r,$yl,$xr-$iw-$r,$yl); + $this->img->Arc($xr-$iw-$r,$yl-$r,$r*2,$r*2,0,90); + + // Right line + $this->img->Line($xr,$yt+$r,$xr,$yl-$ih-$r); + + // Indent horizontal, Lower right arc + $this->img->Line($xr-$r,$yl-$ih,$xr-$iw+$r,$yl-$ih); + $this->img->Arc($xr-$r,$yl-$ih-$r,$r*2,$r*2,0,90); + + // Indent vertical, Indent arc + $this->img->Line($xr-$iw,$yl-$r,$xr-$iw,$yl-$ih+$r); + $this->img->Arc($xr-$iw+$r,$yl-$ih+$r,$r*2,$r*2,180,270); + + if( $aFillColor != '' ) { + $bc = $this->img->current_color_name; + $this->img->PushColor($aFillColor); + $this->img->FillToBorder($xt+$r,$yt+$r,$bc); + $this->img->PopColor(); + } + + break; + + case 3: // Lower left + // Top line, Top left & Top right arc + $this->img->Line($xt+$r,$yt,$xr-$r,$yt); + $this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270); + $this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360); + + // Right line, Bottom right arc + $this->img->Line($xr,$yt+$r,$xr,$yl-$r); + $this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90); + + // Bottom line, Bottom left arc + $this->img->Line($xt+$iw+$r,$yl,$xr-$r,$yl); + $this->img->Arc($xt+$iw+$r,$yl-$r,$r*2,$r*2,90,180); + + // Left line + $this->img->Line($xt,$yt+$r,$xt,$yl-$ih-$r); + + // Indent horizontal, Lower left arc + $this->img->Line($xt+$r,$yl-$ih,$xt+$iw-$r,$yl-$ih); + $this->img->Arc($xt+$r,$yl-$ih-$r,$r*2,$r*2,90,180); + + // Indent vertical, Indent arc + $this->img->Line($xt+$iw,$yl-$ih+$r,$xt+$iw,$yl-$r); + $this->img->Arc($xt+$iw-$r,$yl-$ih+$r,$r*2,$r*2,270,360); + + if( $aFillColor != '' ) { + $bc = $this->img->current_color_name; + $this->img->PushColor($aFillColor); + $this->img->FillToBorder($xr-$r,$yt+$r,$bc); + $this->img->PopColor(); + } + + break; + } + } +} + + +//=================================================== +// CLASS RectangleText +// Description: Draws a text paragraph inside a +// rounded, possible filled, rectangle. +//=================================================== +class CanvasRectangleText { + private $ix,$iy,$iw,$ih,$ir=4; + private $iTxt,$iColor='black',$iFillColor='',$iFontColor='black'; + private $iParaAlign='center'; + private $iAutoBoxMargin=5; + private $iShadowWidth=3,$iShadowColor=''; + + function __construct($aTxt='',$xl=0,$yt=0,$w=0,$h=0) { + $this->iTxt = new Text($aTxt); + $this->ix = $xl; + $this->iy = $yt; + $this->iw = $w; + $this->ih = $h; + } + + function SetShadow($aColor='gray',$aWidth=3) { + $this->iShadowColor = $aColor; + $this->iShadowWidth = $aWidth; + } + + function SetFont($FontFam,$aFontStyle,$aFontSize=12) { + $this->iTxt->SetFont($FontFam,$aFontStyle,$aFontSize); + } + + function SetTxt($aTxt) { + $this->iTxt->Set($aTxt); + } + + function ParagraphAlign($aParaAlign) { + $this->iParaAlign = $aParaAlign; + } + + function SetFillColor($aFillColor) { + $this->iFillColor = $aFillColor; + } + + function SetAutoMargin($aMargin) { + $this->iAutoBoxMargin=$aMargin; + } + + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function SetFontColor($aColor) { + $this->iFontColor = $aColor; + } + + function SetPos($xl=0,$yt=0,$w=0,$h=0) { + $this->ix = $xl; + $this->iy = $yt; + $this->iw = $w; + $this->ih = $h; + } + + function Pos($xl=0,$yt=0,$w=0,$h=0) { + $this->ix = $xl; + $this->iy = $yt; + $this->iw = $w; + $this->ih = $h; + } + + function Set($aTxt,$xl,$yt,$w=0,$h=0) { + $this->iTxt->Set($aTxt); + $this->ix = $xl; + $this->iy = $yt; + $this->iw = $w; + $this->ih = $h; + } + + function SetCornerRadius($aRad=5) { + $this->ir = $aRad; + } + + function Stroke($aImg,$scale) { + + // If coordinates are specifed as negative this means we should + // treat them as abolsute (pixels) coordinates + if( $this->ix > 0 ) { + $this->ix = $scale->TranslateX($this->ix) ; + } + else { + $this->ix = -$this->ix; + } + + if( $this->iy > 0 ) { + $this->iy = $scale->TranslateY($this->iy) ; + } + else { + $this->iy = -$this->iy; + } + + list($this->iw,$this->ih) = $scale->Translate($this->iw,$this->ih) ; + + if( $this->iw == 0 ) + $this->iw = round($this->iTxt->GetWidth($aImg) + $this->iAutoBoxMargin); + if( $this->ih == 0 ) { + $this->ih = round($this->iTxt->GetTextHeight($aImg) + $this->iAutoBoxMargin); + } + + if( $this->iShadowColor != '' ) { + $aImg->PushColor($this->iShadowColor); + $aImg->FilledRoundedRectangle($this->ix+$this->iShadowWidth, + $this->iy+$this->iShadowWidth, + $this->ix+$this->iw-1+$this->iShadowWidth, + $this->iy+$this->ih-1+$this->iShadowWidth, + $this->ir); + $aImg->PopColor(); + } + + if( $this->iFillColor != '' ) { + $aImg->PushColor($this->iFillColor); + $aImg->FilledRoundedRectangle($this->ix,$this->iy, + $this->ix+$this->iw-1, + $this->iy+$this->ih-1, + $this->ir); + $aImg->PopColor(); + } + + if( $this->iColor != '' ) { + $aImg->PushColor($this->iColor); + $aImg->RoundedRectangle($this->ix,$this->iy, + $this->ix+$this->iw-1, + $this->iy+$this->ih-1, + $this->ir); + $aImg->PopColor(); + } + + $this->iTxt->Align('center','center'); + $this->iTxt->ParagraphAlign($this->iParaAlign); + $this->iTxt->SetColor($this->iFontColor); + $this->iTxt->Stroke($aImg, $this->ix+$this->iw/2, $this->iy+$this->ih/2); + + return array($this->iw, $this->ih); + + } + +} + + +?> diff --git a/html/jpgraph/jpgraph_contour.php b/html/jpgraph/jpgraph_contour.php new file mode 100644 index 0000000..760989e --- /dev/null +++ b/html/jpgraph/jpgraph_contour.php @@ -0,0 +1,587 @@ +<?php +/*======================================================================= +// File: JPGRAPH_CONTOUR.PHP +// Description: Contour plot +// Created: 2009-03-08 +// Ver: $Id: jpgraph_contour.php 1870 2009-09-29 04:24:18Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== +*/ +require_once('jpgraph_meshinterpolate.inc.php'); +define('HORIZ_EDGE',0); +define('VERT_EDGE',1); + +/** + * This class encapsulates the core contour plot algorithm. It will find the path + * of the specified isobars in the data matrix specified. It is assumed that the + * data matrix models an equspaced X-Y mesh of datavalues corresponding to the Z + * values. + * + */ +class Contour { + + private $dataPoints = array(); + private $nbrCols=0,$nbrRows=0; + private $horizEdges = array(), $vertEdges=array(); + private $isobarValues = array(); + private $stack = null; + private $isobarCoord = array(); + private $nbrIsobars = 10, $isobarColors = array(); + private $invert = true; + private $highcontrast = false, $highcontrastbw = false; + + /** + * Create a new contour level "algorithm machine". + * @param $aMatrix The values to find the contour from + * @param $aIsobars Mixed. If integer it determines the number of isobars to be used. The levels are determined + * automatically as equdistance between the min and max value of the matrice. + * If $aIsobars is an array then this is interpretated as an array of values to be used as isobars in the + * contour plot. + * @return an instance of the contour algorithm + */ + function __construct($aMatrix,$aIsobars=10, $aColors=null) { + + $this->nbrRows = count($aMatrix); + $this->nbrCols = count($aMatrix[0]); + $this->dataPoints = $aMatrix; + + if( is_array($aIsobars) ) { + // use the isobar values supplied + $this->nbrIsobars = count($aIsobars); + $this->isobarValues = $aIsobars; + } + else { + // Determine the isobar values automatically + $this->nbrIsobars = $aIsobars; + list($min,$max) = $this->getMinMaxVal(); + $stepSize = ($max-$min) / $aIsobars ; + $isobar = $min+$stepSize/2; + for ($i = 0; $i < $aIsobars; $i++) { + $this->isobarValues[$i] = $isobar; + $isobar += $stepSize; + } + } + + if( $aColors !== null && count($aColors) > 0 ) { + + if( !is_array($aColors) ) { + JpGraphError::RaiseL(28001); + //'Third argument to Contour must be an array of colors.' + } + + if( count($aColors) != count($this->isobarValues) ) { + JpGraphError::RaiseL(28002); + //'Number of colors must equal the number of isobar lines specified'; + } + + $this->isobarColors = $aColors; + } + } + + /** + * Flip the plot around the Y-coordinate. This has the same affect as flipping the input + * data matrice + * + * @param $aFlg If true the the vertice in input data matrice position (0,0) corresponds to the top left + * corner of teh plot otherwise it will correspond to the bottom left corner (a horizontal flip) + */ + function SetInvert($aFlg=true) { + $this->invert = $aFlg; + } + + /** + * Find the min and max values in the data matrice + * + * @return array(min_value,max_value) + */ + function getMinMaxVal() { + $min = $this->dataPoints[0][0]; + $max = $this->dataPoints[0][0]; + for ($i = 0; $i < $this->nbrRows; $i++) { + if( ($mi=min($this->dataPoints[$i])) < $min ) $min = $mi; + if( ($ma=max($this->dataPoints[$i])) > $max ) $max = $ma; + } + return array($min,$max); + } + + /** + * Reset the two matrices that keeps track on where the isobars crosses the + * horizontal and vertical edges + */ + function resetEdgeMatrices() { + for ($k = 0; $k < 2; $k++) { + for ($i = 0; $i <= $this->nbrRows; $i++) { + for ($j = 0; $j <= $this->nbrCols; $j++) { + $this->edges[$k][$i][$j] = false; + } + } + } + } + + /** + * Determine if the specified isobar crosses the horizontal edge specified by its row and column + * + * @param $aRow Row index of edge to be checked + * @param $aCol Col index of edge to be checked + * @param $aIsobar Isobar value + * @return true if the isobar is crossing this edge + */ + function isobarHCrossing($aRow,$aCol,$aIsobar) { + + if( $aCol >= $this->nbrCols-1 ) { + JpGraphError::RaiseL(28003,$aCol); + //'ContourPlot Internal Error: isobarHCrossing: Coloumn index too large (%d)' + } + if( $aRow >= $this->nbrRows ) { + JpGraphError::RaiseL(28004,$aRow); + //'ContourPlot Internal Error: isobarHCrossing: Row index too large (%d)' + } + + $v1 = $this->dataPoints[$aRow][$aCol]; + $v2 = $this->dataPoints[$aRow][$aCol+1]; + + return ($aIsobar-$v1)*($aIsobar-$v2) < 0 ; + + } + + /** + * Determine if the specified isobar crosses the vertical edge specified by its row and column + * + * @param $aRow Row index of edge to be checked + * @param $aCol Col index of edge to be checked + * @param $aIsobar Isobar value + * @return true if the isobar is crossing this edge + */ + function isobarVCrossing($aRow,$aCol,$aIsobar) { + + if( $aRow >= $this->nbrRows-1) { + JpGraphError::RaiseL(28005,$aRow); + //'isobarVCrossing: Row index too large + } + if( $aCol >= $this->nbrCols ) { + JpGraphError::RaiseL(28006,$aCol); + //'isobarVCrossing: Col index too large + } + + $v1 = $this->dataPoints[$aRow][$aCol]; + $v2 = $this->dataPoints[$aRow+1][$aCol]; + + return ($aIsobar-$v1)*($aIsobar-$v2) < 0 ; + + } + + /** + * Determine all edges, horizontal and vertical that the specified isobar crosses. The crossings + * are recorded in the two edge matrices. + * + * @param $aIsobar The value of the isobar to be checked + */ + function determineIsobarEdgeCrossings($aIsobar) { + + $ib = $this->isobarValues[$aIsobar]; + + for ($i = 0; $i < $this->nbrRows-1; $i++) { + for ($j = 0; $j < $this->nbrCols-1; $j++) { + $this->edges[HORIZ_EDGE][$i][$j] = $this->isobarHCrossing($i,$j,$ib); + $this->edges[VERT_EDGE][$i][$j] = $this->isobarVCrossing($i,$j,$ib); + } + } + + // We now have the bottom and rightmost edges unsearched + for ($i = 0; $i < $this->nbrRows-1; $i++) { + $this->edges[VERT_EDGE][$i][$j] = $this->isobarVCrossing($i,$this->nbrCols-1,$ib); + } + for ($j = 0; $j < $this->nbrCols-1; $j++) { + $this->edges[HORIZ_EDGE][$i][$j] = $this->isobarHCrossing($this->nbrRows-1,$j,$ib); + } + + } + + /** + * Return the normalized coordinates for the crossing of the specified edge with the specified + * isobar- The crossing is simpy detrmined with a linear interpolation between the two vertices + * on each side of the edge and the value of the isobar + * + * @param $aRow Row of edge + * @param $aCol Column of edge + * @param $aEdgeDir Determine if this is a horizontal or vertical edge + * @param $ib The isobar value + * @return unknown_type + */ + function getCrossingCoord($aRow,$aCol,$aEdgeDir,$aIsobarVal) { + + // In order to avoid numerical problem when two vertices are very close + // we have to check and avoid dividing by close to zero denumerator. + if( $aEdgeDir == HORIZ_EDGE ) { + $d = abs($this->dataPoints[$aRow][$aCol] - $this->dataPoints[$aRow][$aCol+1]); + if( $d > 0.001 ) { + $xcoord = $aCol + abs($aIsobarVal - $this->dataPoints[$aRow][$aCol]) / $d; + } + else { + $xcoord = $aCol; + } + $ycoord = $aRow; + } + else { + $d = abs($this->dataPoints[$aRow][$aCol] - $this->dataPoints[$aRow+1][$aCol]); + if( $d > 0.001 ) { + $ycoord = $aRow + abs($aIsobarVal - $this->dataPoints[$aRow][$aCol]) / $d; + } + else { + $ycoord = $aRow; + } + $xcoord = $aCol; + } + if( $this->invert ) { + $ycoord = $this->nbrRows-1 - $ycoord; + } + return array($xcoord,$ycoord); + + } + + /** + * In order to avoid all kinds of unpleasent extra checks and complex boundary + * controls for the degenerated case where the contour levels exactly crosses + * one of the vertices we add a very small delta (0.1%) to the data point value. + * This has no visible affect but it makes the code sooooo much cleaner. + * + */ + function adjustDataPointValues() { + + $ni = count($this->isobarValues); + for ($k = 0; $k < $ni; $k++) { + $ib = $this->isobarValues[$k]; + for ($row = 0 ; $row < $this->nbrRows-1; ++$row) { + for ($col = 0 ; $col < $this->nbrCols-1; ++$col ) { + if( abs($this->dataPoints[$row][$col] - $ib) < 0.0001 ) { + $this->dataPoints[$row][$col] += $this->dataPoints[$row][$col]*0.001; + } + } + } + } + + } + + /** + * @param $aFlg + * @param $aBW + * @return unknown_type + */ + function UseHighContrastColor($aFlg=true,$aBW=false) { + $this->highcontrast = $aFlg; + $this->highcontrastbw = $aBW; + } + + /** + * Calculate suitable colors for each defined isobar + * + */ + function CalculateColors() { + if ( $this->highcontrast ) { + if ( $this->highcontrastbw ) { + for ($ib = 0; $ib < $this->nbrIsobars; $ib++) { + $this->isobarColors[$ib] = 'black'; + } + } + else { + // Use only blue/red scale + $step = round(255/($this->nbrIsobars-1)); + for ($ib = 0; $ib < $this->nbrIsobars; $ib++) { + $this->isobarColors[$ib] = array($ib*$step, 50, 255-$ib*$step); + } + } + } + else { + $n = $this->nbrIsobars; + $v = 0; $step = 1 / ($this->nbrIsobars-1); + for ($ib = 0; $ib < $this->nbrIsobars; $ib++) { + $this->isobarColors[$ib] = RGB::GetSpectrum($v); + $v += $step; + } + } + } + + /** + * This is where the main work is done. For each isobar the crossing of the edges are determined + * and then each cell is analyzed to find the 0, 2 or 4 crossings. Then the normalized coordinate + * for the crossings are determined and pushed on to the isobar stack. When the method is finished + * the $isobarCoord will hold one arrayfor each isobar where all the line segments that makes + * up the contour plot are stored. + * + * @return array( $isobarCoord, $isobarValues, $isobarColors ) + */ + function getIsobars() { + + $this->adjustDataPointValues(); + + for ($isobar = 0; $isobar < $this->nbrIsobars; $isobar++) { + + $ib = $this->isobarValues[$isobar]; + $this->resetEdgeMatrices(); + $this->determineIsobarEdgeCrossings($isobar); + $this->isobarCoord[$isobar] = array(); + + $ncoord = 0; + + for ($row = 0 ; $row < $this->nbrRows-1; ++$row) { + for ($col = 0 ; $col < $this->nbrCols-1; ++$col ) { + + // Find out how many crossings around the edges + $n = 0; + if ( $this->edges[HORIZ_EDGE][$row][$col] ) $neigh[$n++] = array($row, $col, HORIZ_EDGE); + if ( $this->edges[HORIZ_EDGE][$row+1][$col] ) $neigh[$n++] = array($row+1,$col, HORIZ_EDGE); + if ( $this->edges[VERT_EDGE][$row][$col] ) $neigh[$n++] = array($row, $col, VERT_EDGE); + if ( $this->edges[VERT_EDGE][$row][$col+1] ) $neigh[$n++] = array($row, $col+1,VERT_EDGE); + + if ( $n == 2 ) { + $n1=0; $n2=1; + $this->isobarCoord[$isobar][$ncoord++] = array( + $this->getCrossingCoord($neigh[$n1][0],$neigh[$n1][1],$neigh[$n1][2],$ib), + $this->getCrossingCoord($neigh[$n2][0],$neigh[$n2][1],$neigh[$n2][2],$ib) ); + } + elseif ( $n == 4 ) { + // We must determine how to connect the edges either northwest->southeast or + // northeast->southwest. We do that by calculating the imaginary middle value of + // the cell by averaging the for corners. This will compared with the value of the + // top left corner will help determine the orientation of the ridge/creek + $midval = ($this->dataPoints[$row][$col]+$this->dataPoints[$row][$col+1]+$this->dataPoints[$row+1][$col]+$this->dataPoints[$row+1][$col+1])/4; + $v = $this->dataPoints[$row][$col]; + if( $midval == $ib ) { + // Orientation "+" + $n1=0; $n2=1; $n3=2; $n4=3; + } elseif ( ($midval > $ib && $v > $ib) || ($midval < $ib && $v < $ib) ) { + // Orientation of ridge/valley = "\" + $n1=0; $n2=3; $n3=2; $n4=1; + } elseif ( ($midval > $ib && $v < $ib) || ($midval < $ib && $v > $ib) ) { + // Orientation of ridge/valley = "/" + $n1=0; $n2=2; $n3=3; $n4=1; + } + + $this->isobarCoord[$isobar][$ncoord++] = array( + $this->getCrossingCoord($neigh[$n1][0],$neigh[$n1][1],$neigh[$n1][2],$ib), + $this->getCrossingCoord($neigh[$n2][0],$neigh[$n2][1],$neigh[$n2][2],$ib) ); + + $this->isobarCoord[$isobar][$ncoord++] = array( + $this->getCrossingCoord($neigh[$n3][0],$neigh[$n3][1],$neigh[$n3][2],$ib), + $this->getCrossingCoord($neigh[$n4][0],$neigh[$n4][1],$neigh[$n4][2],$ib) ); + + } + } + } + } + + if( count($this->isobarColors) == 0 ) { + // No manually specified colors. Calculate them automatically. + $this->CalculateColors(); + } + return array( $this->isobarCoord, $this->isobarValues, $this->isobarColors ); + } +} + + +/** + * This class represent a plotting of a contour outline of data given as a X-Y matrice + * + */ +class ContourPlot extends Plot { + + private $contour, $contourCoord, $contourVal, $contourColor; + private $nbrCountours = 0 ; + private $dataMatrix = array(); + private $invertLegend = false; + private $interpFactor = 1; + private $flipData = false; + private $isobar = 10; + private $showLegend = false; + private $highcontrast = false, $highcontrastbw = false; + private $manualIsobarColors = array(); + + /** + * Construct a contour plotting algorithm. The end result of the algorithm is a sequence of + * line segments for each isobar given as two vertices. + * + * @param $aDataMatrix The Z-data to be used + * @param $aIsobar A mixed variable, if it is an integer then this specified the number of isobars to use. + * The values of the isobars are automatically detrmined to be equ-spaced between the min/max value of the + * data. If it is an array then it explicetely gives the isobar values + * @param $aInvert By default the matrice with row index 0 corresponds to Y-value 0, i.e. in the bottom of + * the plot. If this argument is true then the row with the highest index in the matrice corresponds to + * Y-value 0. In affect flipping the matrice around an imaginary horizontal axis. + * @param $aHighContrast Use high contrast colors (blue/red:ish) + * @param $aHighContrastBW Use only black colors for contours + * @return an instance of the contour plot algorithm + */ + function __construct($aDataMatrix, $aIsobar=10, $aFactor=1, $aInvert=false, $aIsobarColors=array()) { + + $this->dataMatrix = $aDataMatrix; + $this->flipData = $aInvert; + $this->isobar = $aIsobar; + $this->interpFactor = $aFactor; + + if ( $this->interpFactor > 1 ) { + + if( $this->interpFactor > 5 ) { + JpGraphError::RaiseL(28007);// ContourPlot interpolation factor is too large (>5) + } + + $ip = new MeshInterpolate(); + $this->dataMatrix = $ip->Linear($this->dataMatrix, $this->interpFactor); + } + + $this->contour = new Contour($this->dataMatrix,$this->isobar,$aIsobarColors); + + if( is_array($aIsobar) ) + $this->nbrContours = count($aIsobar); + else + $this->nbrContours = $aIsobar; + } + + + /** + * Flipe the data around the center + * + * @param $aFlg + * + */ + function SetInvert($aFlg=true) { + $this->flipData = $aFlg; + } + + /** + * Set the colors for the isobar lines + * + * @param $aColorArray + * + */ + function SetIsobarColors($aColorArray) { + $this->manualIsobarColors = $aColorArray; + } + + /** + * Show the legend + * + * @param $aFlg true if the legend should be shown + * + */ + function ShowLegend($aFlg=true) { + $this->showLegend = $aFlg; + } + + + /** + * @param $aFlg true if the legend should start with the lowest isobar on top + * @return unknown_type + */ + function Invertlegend($aFlg=true) { + $this->invertLegend = $aFlg; + } + + /* Internal method. Give the min value to be used for the scaling + * + */ + function Min() { + return array(0,0); + } + + /* Internal method. Give the max value to be used for the scaling + * + */ + function Max() { + return array(count($this->dataMatrix[0])-1,count($this->dataMatrix)-1); + } + + /** + * Internal ramewrok method to setup the legend to be used for this plot. + * @param $aGraph The parent graph class + */ + function Legend($aGraph) { + + if( ! $this->showLegend ) + return; + + if( $this->invertLegend ) { + for ($i = 0; $i < $this->nbrContours; $i++) { + $aGraph->legend->Add(sprintf('%.1f',$this->contourVal[$i]), $this->contourColor[$i]); + } + } + else { + for ($i = $this->nbrContours-1; $i >= 0 ; $i--) { + $aGraph->legend->Add(sprintf('%.1f',$this->contourVal[$i]), $this->contourColor[$i]); + } + } + } + + + /** + * Framework function which gets called before the Stroke() method is called + * + * @see Plot#PreScaleSetup($aGraph) + * + */ + function PreScaleSetup($aGraph) { + $xn = count($this->dataMatrix[0])-1; + $yn = count($this->dataMatrix)-1; + + $aGraph->xaxis->scale->Update($aGraph->img,0,$xn); + $aGraph->yaxis->scale->Update($aGraph->img,0,$yn); + + $this->contour->SetInvert($this->flipData); + list($this->contourCoord,$this->contourVal,$this->contourColor) = $this->contour->getIsobars(); + } + + /** + * Use high contrast color schema + * + * @param $aFlg True, to use high contrast color + * @param $aBW True, Use only black and white color schema + */ + function UseHighContrastColor($aFlg=true,$aBW=false) { + $this->highcontrast = $aFlg; + $this->highcontrastbw = $aBW; + $this->contour->UseHighContrastColor($this->highcontrast,$this->highcontrastbw); + } + + /** + * Internal method. Stroke the contour plot to the graph + * + * @param $img Image handler + * @param $xscale Instance of the xscale to use + * @param $yscale Instance of the yscale to use + */ + function Stroke($img,$xscale,$yscale) { + + if( count($this->manualIsobarColors) > 0 ) { + $this->contourColor = $this->manualIsobarColors; + if( count($this->manualIsobarColors) != $this->nbrContours ) { + JpGraphError::RaiseL(28002); + } + } + + $img->SetLineWeight($this->line_weight); + + for ($c = 0; $c < $this->nbrContours; $c++) { + + $img->SetColor( $this->contourColor[$c] ); + + $n = count($this->contourCoord[$c]); + $i = 0; + while ( $i < $n ) { + list($x1,$y1) = $this->contourCoord[$c][$i][0]; + $x1t = $xscale->Translate($x1); + $y1t = $yscale->Translate($y1); + + list($x2,$y2) = $this->contourCoord[$c][$i++][1]; + $x2t = $xscale->Translate($x2); + $y2t = $yscale->Translate($y2); + + $img->Line($x1t,$y1t,$x2t,$y2t); + } + + } + } + +} + +// EOF +?> diff --git a/html/jpgraph/jpgraph_date.php b/html/jpgraph/jpgraph_date.php new file mode 100644 index 0000000..db4c441 --- /dev/null +++ b/html/jpgraph/jpgraph_date.php @@ -0,0 +1,499 @@ +<?php +/*======================================================================= + // File: JPGRAPH_DATE.PHP + // Description: Classes to handle Date scaling + // Created: 2005-05-02 + // Ver: $Id: jpgraph_date.php 1106 2009-02-22 20:16:35Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +define('HOURADJ_1',0+30); +define('HOURADJ_2',1+30); +define('HOURADJ_3',2+30); +define('HOURADJ_4',3+30); +define('HOURADJ_6',4+30); +define('HOURADJ_12',5+30); + +define('MINADJ_1',0+20); +define('MINADJ_5',1+20); +define('MINADJ_10',2+20); +define('MINADJ_15',3+20); +define('MINADJ_30',4+20); + +define('SECADJ_1',0); +define('SECADJ_5',1); +define('SECADJ_10',2); +define('SECADJ_15',3); +define('SECADJ_30',4); + + +define('YEARADJ_1',0+30); +define('YEARADJ_2',1+30); +define('YEARADJ_5',2+30); + +define('MONTHADJ_1',0+20); +define('MONTHADJ_6',1+20); + +define('DAYADJ_1',0); +define('DAYADJ_WEEK',1); +define('DAYADJ_7',1); + +define('SECPERYEAR',31536000); +define('SECPERDAY',86400); +define('SECPERHOUR',3600); +define('SECPERMIN',60); + + +class DateScale extends LinearScale { + private $date_format = ''; + private $iStartAlign = false, $iEndAlign = false; + private $iStartTimeAlign = false, $iEndTimeAlign = false; + + //--------------- + // CONSTRUCTOR + function __construct($aMin=0,$aMax=0,$aType='x') { + assert($aType=="x"); + assert($aMin<=$aMax); + + $this->type=$aType; + $this->scale=array($aMin,$aMax); + $this->world_size=$aMax-$aMin; + $this->ticks = new LinearTicks(); + $this->intscale=true; + } + + + //------------------------------------------------------------------------------------------ + // Utility Function AdjDate() + // Description: Will round a given time stamp to an even year, month or day + // argument. + //------------------------------------------------------------------------------------------ + + function AdjDate($aTime,$aRound=0,$aYearType=false,$aMonthType=false,$aDayType=false) { + $y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime); + $h=0;$i=0;$s=0; + if( $aYearType !== false ) { + $yearAdj = array(0=>1, 1=>2, 2=>5); + if( $aRound == 0 ) { + $y = floor($y/$yearAdj[$aYearType])*$yearAdj[$aYearType]; + } + else { + ++$y; + $y = ceil($y/$yearAdj[$aYearType])*$yearAdj[$aYearType]; + } + $m=1;$d=1; + } + elseif( $aMonthType !== false ) { + $monthAdj = array(0=>1, 1=>6); + if( $aRound == 0 ) { + $m = floor($m/$monthAdj[$aMonthType])*$monthAdj[$aMonthType]; + $d=1; + } + else { + ++$m; + $m = ceil($m/$monthAdj[$aMonthType])*$monthAdj[$aMonthType]; + $d=1; + } + } + elseif( $aDayType !== false ) { + if( $aDayType == 0 ) { + if( $aRound == 1 ) { + //++$d; + $h=23;$i=59;$s=59; + } + } + else { + // Adjust to an even week boundary. + $w = (int)date('w',$aTime); // Day of week 0=Sun, 6=Sat + if( true ) { // Adjust to start on Mon + if( $w==0 ) $w=6; + else --$w; + } + if( $aRound == 0 ) { + $d -= $w; + } + else { + $d += (7-$w); + $h=23;$i=59;$s=59; + } + } + } + return mktime($h,$i,$s,$m,$d,$y); + + } + + //------------------------------------------------------------------------------------------ + // Wrapper for AdjDate that will round a timestamp to an even date rounding + // it downwards. + //------------------------------------------------------------------------------------------ + function AdjStartDate($aTime,$aYearType=false,$aMonthType=false,$aDayType=false) { + return $this->AdjDate($aTime,0,$aYearType,$aMonthType,$aDayType); + } + + //------------------------------------------------------------------------------------------ + // Wrapper for AdjDate that will round a timestamp to an even date rounding + // it upwards + //------------------------------------------------------------------------------------------ + function AdjEndDate($aTime,$aYearType=false,$aMonthType=false,$aDayType=false) { + return $this->AdjDate($aTime,1,$aYearType,$aMonthType,$aDayType); + } + + //------------------------------------------------------------------------------------------ + // Utility Function AdjTime() + // Description: Will round a given time stamp to an even time according to + // argument. + //------------------------------------------------------------------------------------------ + + function AdjTime($aTime,$aRound=0,$aHourType=false,$aMinType=false,$aSecType=false) { + $y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime); + $h = (int)date('H',$aTime); $i = (int)date('i',$aTime); $s = (int)date('s',$aTime); + if( $aHourType !== false ) { + $aHourType %= 6; + $hourAdj = array(0=>1, 1=>2, 2=>3, 3=>4, 4=>6, 5=>12); + if( $aRound == 0 ) + $h = floor($h/$hourAdj[$aHourType])*$hourAdj[$aHourType]; + else { + if( ($h % $hourAdj[$aHourType]==0) && ($i > 0 || $s > 0) ) { + $h++; + } + $h = ceil($h/$hourAdj[$aHourType])*$hourAdj[$aHourType]; + if( $h >= 24 ) { + $aTime += 86400; + $y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime); + $h -= 24; + } + } + $i=0;$s=0; + } + elseif( $aMinType !== false ) { + $aMinType %= 5; + $minAdj = array(0=>1, 1=>5, 2=>10, 3=>15, 4=>30); + if( $aRound == 0 ) { + $i = floor($i/$minAdj[$aMinType])*$minAdj[$aMinType]; + } + else { + if( ($i % $minAdj[$aMinType]==0) && $s > 0 ) { + $i++; + } + $i = ceil($i/$minAdj[$aMinType])*$minAdj[$aMinType]; + if( $i >= 60) { + $aTime += 3600; + $y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime); + $h = (int)date('H',$aTime); $i = 0; + } + } + $s=0; + } + elseif( $aSecType !== false ) { + $aSecType %= 5; + $secAdj = array(0=>1, 1=>5, 2=>10, 3=>15, 4=>30); + if( $aRound == 0 ) { + $s = floor($s/$secAdj[$aSecType])*$secAdj[$aSecType]; + } + else { + $s = ceil($s/$secAdj[$aSecType]*1.0)*$secAdj[$aSecType]; + if( $s >= 60) { + $s=0; + $aTime += 60; + $y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime); + $h = (int)date('H',$aTime); $i = (int)date('i',$aTime); + } + } + } + return mktime($h,$i,$s,$m,$d,$y); + } + + //------------------------------------------------------------------------------------------ + // Wrapper for AdjTime that will round a timestamp to an even time rounding + // it downwards. + // Example: AdjStartTime(mktime(18,27,13,2,22,2005),false,2) => 18:20 + //------------------------------------------------------------------------------------------ + function AdjStartTime($aTime,$aHourType=false,$aMinType=false,$aSecType=false) { + return $this->AdjTime($aTime,0,$aHourType,$aMinType,$aSecType); + } + + //------------------------------------------------------------------------------------------ + // Wrapper for AdjTime that will round a timestamp to an even time rounding + // it upwards + // Example: AdjEndTime(mktime(18,27,13,2,22,2005),false,2) => 18:30 + //------------------------------------------------------------------------------------------ + function AdjEndTime($aTime,$aHourType=false,$aMinType=false,$aSecType=false) { + return $this->AdjTime($aTime,1,$aHourType,$aMinType,$aSecType); + } + + //------------------------------------------------------------------------------------------ + // DateAutoScale + // Autoscale a date axis given start and end time + // Returns an array ($start,$end,$major,$minor,$format) + //------------------------------------------------------------------------------------------ + function DoDateAutoScale($aStartTime,$aEndTime,$aDensity=0,$aAdjust=true) { + // Format of array + // array ( Decision point, array( array( Major-scale-step-array ), + // array( Minor-scale-step-array ), + // array( 0=date-adjust, 1=time-adjust, adjustment-alignment) ) + // + $scalePoints = + array( + /* Intervall larger than 10 years */ + SECPERYEAR*10,array(array(SECPERYEAR*5,SECPERYEAR*2), + array(SECPERYEAR), + array(0,YEARADJ_1, 0,YEARADJ_1) ), + + /* Intervall larger than 2 years */ + SECPERYEAR*2,array(array(SECPERYEAR),array(SECPERYEAR), + array(0,YEARADJ_1) ), + + /* Intervall larger than 90 days (approx 3 month) */ + SECPERDAY*90,array(array(SECPERDAY*30,SECPERDAY*14,SECPERDAY*7,SECPERDAY), + array(SECPERDAY*5,SECPERDAY*7,SECPERDAY,SECPERDAY), + array(0,MONTHADJ_1, 0,DAYADJ_WEEK, 0,DAYADJ_1, 0,DAYADJ_1)), + + /* Intervall larger than 30 days (approx 1 month) */ + SECPERDAY*30,array(array(SECPERDAY*14,SECPERDAY*7,SECPERDAY*2, SECPERDAY), + array(SECPERDAY,SECPERDAY,SECPERDAY,SECPERDAY), + array(0,DAYADJ_WEEK, 0,DAYADJ_1, 0,DAYADJ_1, 0,DAYADJ_1)), + + /* Intervall larger than 7 days */ + SECPERDAY*7,array(array(SECPERDAY,SECPERHOUR*12,SECPERHOUR*6,SECPERHOUR*2), + array(SECPERHOUR*6,SECPERHOUR*3,SECPERHOUR,SECPERHOUR), + array(0,DAYADJ_1, 1,HOURADJ_12, 1,HOURADJ_6, 1,HOURADJ_1)), + + /* Intervall larger than 1 day */ + SECPERDAY,array(array(SECPERDAY,SECPERHOUR*12,SECPERHOUR*6,SECPERHOUR*2,SECPERHOUR), + array(SECPERHOUR*6,SECPERHOUR*2,SECPERHOUR,SECPERHOUR,SECPERHOUR), + array(1,HOURADJ_12, 1,HOURADJ_6, 1,HOURADJ_1, 1,HOURADJ_1)), + + /* Intervall larger than 12 hours */ + SECPERHOUR*12,array(array(SECPERHOUR*2,SECPERHOUR,SECPERMIN*30,900,600), + array(1800,1800,900,300,300), + array(1,HOURADJ_1, 1,MINADJ_30, 1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5) ), + + /* Intervall larger than 2 hours */ + SECPERHOUR*2,array(array(SECPERHOUR,SECPERMIN*30,900,600,300), + array(1800,900,300,120,60), + array(1,HOURADJ_1, 1,MINADJ_30, 1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5) ), + + /* Intervall larger than 1 hours */ + SECPERHOUR,array(array(SECPERMIN*30,900,600,300),array(900,300,120,60), + array(1,MINADJ_30, 1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5) ), + + /* Intervall larger than 30 min */ + SECPERMIN*30,array(array(SECPERMIN*15,SECPERMIN*10,SECPERMIN*5,SECPERMIN), + array(300,300,60,10), + array(1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5, 1,MINADJ_1)), + + /* Intervall larger than 1 min */ + SECPERMIN,array(array(SECPERMIN,15,10,5), + array(15,5,2,1), + array(1,MINADJ_1, 1,SECADJ_15, 1,SECADJ_10, 1,SECADJ_5)), + + /* Intervall larger than 10 sec */ + 10,array(array(5,2), + array(1,1), + array(1,SECADJ_5, 1,SECADJ_1)), + + /* Intervall larger than 1 sec */ + 1,array(array(1), + array(1), + array(1,SECADJ_1)), + ); + + $ns = count($scalePoints); + // Establish major and minor scale units for the date scale + $diff = $aEndTime - $aStartTime; + if( $diff < 1 ) return false; + $done=false; + $i=0; + while( ! $done ) { + if( $diff > $scalePoints[2*$i] ) { + // Get major and minor scale for this intervall + $scaleSteps = $scalePoints[2*$i+1]; + $major = $scaleSteps[0][min($aDensity,count($scaleSteps[0])-1)]; + // Try to find out which minor step looks best + $minor = $scaleSteps[1][min($aDensity,count($scaleSteps[1])-1)]; + if( $aAdjust ) { + // Find out how we should align the start and end timestamps + $idx = 2*min($aDensity,floor(count($scaleSteps[2])/2)-1); + if( $scaleSteps[2][$idx] === 0 ) { + // Use date adjustment + $adj = $scaleSteps[2][$idx+1]; + if( $adj >= 30 ) { + $start = $this->AdjStartDate($aStartTime,$adj-30); + $end = $this->AdjEndDate($aEndTime,$adj-30); + } + elseif( $adj >= 20 ) { + $start = $this->AdjStartDate($aStartTime,false,$adj-20); + $end = $this->AdjEndDate($aEndTime,false,$adj-20); + } + else { + $start = $this->AdjStartDate($aStartTime,false,false,$adj); + $end = $this->AdjEndDate($aEndTime,false,false,$adj); + // We add 1 second for date adjustment to make sure we end on 00:00 the following day + // This makes the final major tick be srawn when we step day-by-day instead of ending + // on xx:59:59 which would not draw the final major tick + $end++; + } + } + else { + // Use time adjustment + $adj = $scaleSteps[2][$idx+1]; + if( $adj >= 30 ) { + $start = $this->AdjStartTime($aStartTime,$adj-30); + $end = $this->AdjEndTime($aEndTime,$adj-30); + } + elseif( $adj >= 20 ) { + $start = $this->AdjStartTime($aStartTime,false,$adj-20); + $end = $this->AdjEndTime($aEndTime,false,$adj-20); + } + else { + $start = $this->AdjStartTime($aStartTime,false,false,$adj); + $end = $this->AdjEndTime($aEndTime,false,false,$adj); + } + } + } + // If the overall date span is larger than 1 day ten we show date + $format = ''; + if( ($end-$start) > SECPERDAY ) { + $format = 'Y-m-d '; + } + // If the major step is less than 1 day we need to whow hours + min + if( $major < SECPERDAY ) { + $format .= 'H:i'; + } + // If the major step is less than 1 min we need to show sec + if( $major < 60 ) { + $format .= ':s'; + } + $done=true; + } + ++$i; + } + return array($start,$end,$major,$minor,$format); + } + + // Overrides the automatic determined date format. Must be a valid date() format string + function SetDateFormat($aFormat) { + $this->date_format = $aFormat; + $this->ticks->SetLabelDateFormat($this->date_format); + } + + function AdjustForDST($aFlg=true) { + $this->ticks->AdjustForDST($aFlg); + } + + + function SetDateAlign($aStartAlign,$aEndAlign=false) { + if( $aEndAlign === false ) { + $aEndAlign=$aStartAlign; + } + $this->iStartAlign = $aStartAlign; + $this->iEndAlign = $aEndAlign; + } + + function SetTimeAlign($aStartAlign,$aEndAlign=false) { + if( $aEndAlign === false ) { + $aEndAlign=$aStartAlign; + } + $this->iStartTimeAlign = $aStartAlign; + $this->iEndTimeAlign = $aEndAlign; + } + + + function AutoScale($img,$aStartTime,$aEndTime,$aNumSteps,$_adummy=false) { + // We need to have one dummy argument to make the signature of AutoScale() + // identical to LinearScale::AutoScale + if( $aStartTime == $aEndTime ) { + // Special case when we only have one data point. + // Create a small artifical intervall to do the autoscaling + $aStartTime -= 10; + $aEndTime += 10; + } + $done=false; + $i=0; + while( ! $done && $i < 5) { + list($adjstart,$adjend,$maj,$min,$format) = $this->DoDateAutoScale($aStartTime,$aEndTime,$i); + $n = floor(($adjend-$adjstart)/$maj); + if( $n * 1.7 > $aNumSteps ) { + $done=true; + } + $i++; + } + + /* + if( 0 ) { // DEBUG + echo " Start =".date("Y-m-d H:i:s",$aStartTime)."<br>"; + echo " End =".date("Y-m-d H:i:s",$aEndTime)."<br>"; + echo "Adj Start =".date("Y-m-d H:i:s",$adjstart)."<br>"; + echo "Adj End =".date("Y-m-d H:i:s",$adjend)."<p>"; + echo "Major = $maj s, ".floor($maj/60)."min, ".floor($maj/3600)."h, ".floor($maj/86400)."day<br>"; + echo "Min = $min s, ".floor($min/60)."min, ".floor($min/3600)."h, ".floor($min/86400)."day<br>"; + echo "Format=$format<p>"; + } + */ + + if( $this->iStartTimeAlign !== false && $this->iStartAlign !== false ) { + JpGraphError::RaiseL(3001); + //('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both'); + } + + if( $this->iStartTimeAlign !== false ) { + if( $this->iStartTimeAlign >= 30 ) { + $adjstart = $this->AdjStartTime($aStartTime,$this->iStartTimeAlign-30); + } + elseif( $this->iStartTimeAlign >= 20 ) { + $adjstart = $this->AdjStartTime($aStartTime,false,$this->iStartTimeAlign-20); + } + else { + $adjstart = $this->AdjStartTime($aStartTime,false,false,$this->iStartTimeAlign); + } + } + if( $this->iEndTimeAlign !== false ) { + if( $this->iEndTimeAlign >= 30 ) { + $adjend = $this->AdjEndTime($aEndTime,$this->iEndTimeAlign-30); + } + elseif( $this->iEndTimeAlign >= 20 ) { + $adjend = $this->AdjEndTime($aEndTime,false,$this->iEndTimeAlign-20); + } + else { + $adjend = $this->AdjEndTime($aEndTime,false,false,$this->iEndTimeAlign); + } + } + + + + if( $this->iStartAlign !== false ) { + if( $this->iStartAlign >= 30 ) { + $adjstart = $this->AdjStartDate($aStartTime,$this->iStartAlign-30); + } + elseif( $this->iStartAlign >= 20 ) { + $adjstart = $this->AdjStartDate($aStartTime,false,$this->iStartAlign-20); + } + else { + $adjstart = $this->AdjStartDate($aStartTime,false,false,$this->iStartAlign); + } + } + if( $this->iEndAlign !== false ) { + if( $this->iEndAlign >= 30 ) { + $adjend = $this->AdjEndDate($aEndTime,$this->iEndAlign-30); + } + elseif( $this->iEndAlign >= 20 ) { + $adjend = $this->AdjEndDate($aEndTime,false,$this->iEndAlign-20); + } + else { + $adjend = $this->AdjEndDate($aEndTime,false,false,$this->iEndAlign); + } + } + $this->Update($img,$adjstart,$adjend); + if( ! $this->ticks->IsSpecified() ) + $this->ticks->Set($maj,$min); + if( $this->date_format == '' ) + $this->ticks->SetLabelDateFormat($format); + else + $this->ticks->SetLabelDateFormat($this->date_format); + } +} + + +?> diff --git a/html/jpgraph/jpgraph_errhandler.inc.php b/html/jpgraph/jpgraph_errhandler.inc.php new file mode 100644 index 0000000..06be8eb --- /dev/null +++ b/html/jpgraph/jpgraph_errhandler.inc.php @@ -0,0 +1,369 @@ +<?php +//======================================================================= +// File: JPGRAPH_ERRHANDLER.PHP +// Description: Error handler class together with handling of localized +// error messages. All localized error messages are stored +// in a separate file under the "lang/" subdirectory. +// Created: 2006-09-24 +// Ver: $Id: jpgraph_errhandler.inc.php 1920 2009-12-08 10:02:26Z ljp $ +// +// Copyright 2006 (c) Aditus Consulting. All rights reserved. +//======================================================================== + +if( !defined('DEFAULT_ERR_LOCALE') ) { + define('DEFAULT_ERR_LOCALE','en'); +} + +if( !defined('USE_IMAGE_ERROR_HANDLER') ) { + define('USE_IMAGE_ERROR_HANDLER',true); +} + +GLOBAL $__jpg_err_locale ; +__jpg_err_locale = DEFAULT_ERR_LOCALE; + +class ErrMsgText { + private $lt=NULL; + function __construct() { + GLOBAL $__jpg_err_locale; + $file = 'lang/'.$__jpg_err_locale.'.inc.php'; + + // If the chosen locale doesn't exist try english + if( !file_exists(dirname(__FILE__).'/'.$file) ) { + $__jpg_err_locale = 'en'; + } + + $file = 'lang/'.$__jpg_err_locale.'.inc.php'; + if( !file_exists(dirname(__FILE__).'/'.$file) ) { + die('Chosen locale file ("'.$file.'") for error messages does not exist or is not readable for the PHP process. Please make sure that the file exists and that the file permissions are such that the PHP process is allowed to read this file.'); + } + require($file); + $this->lt = $_jpg_messages; + } + + function Get($errnbr,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) { + GLOBAL $__jpg_err_locale; + if( !isset($this->lt[$errnbr]) ) { + return 'Internal error: The specified error message ('.$errnbr.') does not exist in the chosen locale ('.$__jpg_err_locale.')'; + } + $ea = $this->lt[$errnbr]; + $j=0; + if( $a1 !== null ) { + $argv[$j++] = $a1; + if( $a2 !== null ) { + $argv[$j++] = $a2; + if( $a3 !== null ) { + $argv[$j++] = $a3; + if( $a4 !== null ) { + $argv[$j++] = $a4; + if( $a5 !== null ) { + $argv[$j++] = $a5; + } + } + } + } + } + $numargs = $j; + if( $ea[1] != $numargs ) { + // Error message argument count do not match. + // Just return the error message without arguments. + return $ea[0]; + } + switch( $numargs ) { + case 1: + $msg = sprintf($ea[0],$argv[0]); + break; + case 2: + $msg = sprintf($ea[0],$argv[0],$argv[1]); + break; + case 3: + $msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2]); + break; + case 4: + $msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2],$argv[3]); + break; + case 5: + $msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2],$argv[3],$argv[4]); + break; + case 0: + default: + $msg = sprintf($ea[0]); + break; + } + return $msg; + } +} + +// +// A wrapper class that is used to access the specified error object +// (to hide the global error parameter and avoid having a GLOBAL directive +// in all methods. +// +class JpGraphError { + private static $__iImgFlg = true; + private static $__iLogFile = ''; + private static $__iTitle = 'JpGraph Error: '; + public static function Raise($aMsg,$aHalt=true){ + throw new JpGraphException($aMsg); + } + public static function SetErrLocale($aLoc) { + GLOBAL $__jpg_err_locale ; + $__jpg_err_locale = $aLoc; + } + public static function RaiseL($errnbr,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) { + throw new JpGraphExceptionL($errnbr,$a1,$a2,$a3,$a4,$a5); + } + public static function SetImageFlag($aFlg=true) { + self::$__iImgFlg = $aFlg; + } + public static function GetImageFlag() { + return self::$__iImgFlg; + } + public static function SetLogFile($aFile) { + self::$__iLogFile = $aFile; + } + public static function GetLogFile() { + return self::$__iLogFile; + } + public static function SetTitle($aTitle) { + self::$__iTitle = $aTitle; + } + public static function GetTitle() { + return self::$__iTitle; + } +} + +class JpGraphException extends Exception { + // Redefine the exception so message isn't optional + public function __construct($message, $code = 0) { + // make sure everything is assigned properly + parent::__construct($message, $code); + } + // custom string representation of object + public function _toString() { + return __CLASS__ . ": [{$this->code}]: {$this->message} at " . basename($this->getFile()) . ":" . $this->getLine() . "\n" . $this->getTraceAsString() . "\n"; + } + // custom representation of error as an image + public function Stroke() { + if( JpGraphError::GetImageFlag() ) { + $errobj = new JpGraphErrObjectImg(); + $errobj->SetTitle(JpGraphError::GetTitle()); + } + else { + $errobj = new JpGraphErrObject(); + $errobj->SetTitle(JpGraphError::GetTitle()); + $errobj->SetStrokeDest(JpGraphError::GetLogFile()); + } + $errobj->Raise($this->getMessage()); + } + static public function defaultHandler(Exception $exception) { + global $__jpg_OldHandler; + if( $exception instanceof JpGraphException ) { + $exception->Stroke(); + } + else { + // Restore old handler + if( $__jpg_OldHandler !== NULL ) { + set_exception_handler($__jpg_OldHandler); + } + throw $exception; + } + } +} + +class JpGraphExceptionL extends JpGraphException { + // Redefine the exception so message isn't optional + public function __construct($errcode,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) { + // make sure everything is assigned properly + $errtxt = new ErrMsgText(); + JpGraphError::SetTitle('JpGraph Error: '.$errcode); + parent::__construct($errtxt->Get($errcode,$a1,$a2,$a3,$a4,$a5), 0); + } +} + +// Setup the default handler +global $__jpg_OldHandler; +__jpg_OldHandler = set_exception_handler(array('JpGraphException','defaultHandler')); + +// +// First of all set up a default error handler +// + +//============================================================= +// The default trivial text error handler. +//============================================================= +class JpGraphErrObject { + + protected $iTitle = "JpGraph error: "; + protected $iDest = false; + + + function __construct() { + // Empty. Reserved for future use + } + + function SetTitle($aTitle) { + $this->iTitle = $aTitle; + } + + function SetStrokeDest($aDest) { + $this->iDest = $aDest; + } + + // If aHalt is true then execution can't continue. Typical used for fatal errors + function Raise($aMsg,$aHalt=false) { + if( $this->iDest != '' ) { + if( $this->iDest == 'syslog' ) { + error_log($this->iTitle.$aMsg); + } + else { + $str = '['.date('r').'] '.$this->iTitle.$aMsg."\n"; + $f = @fopen($this->iDest,'a'); + if( $f ) { + @fwrite($f,$str); + @fclose($f); + } + } + } + else { + $aMsg = $this->iTitle.$aMsg; + // Check SAPI and if we are called from the command line + // send the error to STDERR instead + if( PHP_SAPI == 'cli' ) { + fwrite(STDERR,$aMsg); + } + else { + echo $aMsg; + } + } + if( $aHalt ) + exit(1); + } +} + +//============================================================== +// An image based error handler +//============================================================== +class JpGraphErrObjectImg extends JpGraphErrObject { + + function __construct() { + parent::__construct(); + // Empty. Reserved for future use + } + + function Raise($aMsg,$aHalt=true) { + $img_iconerror = + 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaV'. + 'BMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/'. + 'f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpY'. + 'iYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjea'. + 'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx'. + 'IAAAsSAdLdfvwAAAAHdElNRQfTBgISOCqusfs5AAABLUlEQVR4'. + '2tWV3XKCMBBGWfkranCIVClKLd/7P2Q3QsgCxjDTq+6FE2cPH+'. + 'xJ0Ogn2lQbsT+Wrs+buAZAV4W5T6Bs0YXBBwpKgEuIu+JERAX6'. + 'wM2rHjmDdEITmsQEEmWADgZm6rAjhXsoMGY9B/NZBwJzBvn+e3'. + 'wHntCAJdGu9SviwIwoZVDxPB9+Rc0TSEbQr0j3SA1gwdSn6Db0'. + '6Tm1KfV6yzWGQO7zdpvyKLKBDmRFjzeB3LYgK7r6A/noDAfjtS'. + 'IXaIzbJSv6WgUebTMV4EoRB8a2mQiQjgtF91HdKDKZ1gtFtQjk'. + 'YcWaR5OKOhkYt+ZsTFdJRfPAApOpQYJTNHvCRSJR6SJngQadfc'. + 'vd69OLMddVOPCGVnmrFD8bVYd3JXfxXPtLR/+mtv59/ALWiiMx'. + 'qL72fwAAAABJRU5ErkJggg==' ; + + + if( function_exists("imagetypes") ) { + $supported = imagetypes(); + } else { + $supported = 0; + } + + if( !function_exists('imagecreatefromstring') ) { + $supported = 0; + } + + if( ob_get_length() || headers_sent() || !($supported & IMG_PNG) ) { + // Special case for headers already sent or that the installation doesn't support + // the PNG format (which the error icon is encoded in). + // Dont return an image since it can't be displayed + die($this->iTitle.' '.$aMsg); + } + + $aMsg = wordwrap($aMsg,55); + $lines = substr_count($aMsg,"\n"); + + // Create the error icon GD + $erricon = Image::CreateFromString(base64_decode($img_iconerror)); + + // Create an image that contains the error text. + $w=400; + $h=100 + 15*max(0,$lines-3); + + $img = new Image($w,$h); + + + // Drop shadow + $img->SetColor("gray"); + $img->FilledRectangle(5,5,$w-1,$h-1,10); + $img->SetColor("gray:0.7"); + $img->FilledRectangle(5,5,$w-3,$h-3,10); + + // Window background + $img->SetColor("lightblue"); + $img->FilledRectangle(1,1,$w-5,$h-5); + $img->CopyCanvasH($img->img,$erricon,5,30,0,0,40,40); + + // Window border + $img->SetColor("black"); + $img->Rectangle(1,1,$w-5,$h-5); + $img->Rectangle(0,0,$w-4,$h-4); + + // Window top row + $img->SetColor("darkred"); + for($y=3; $y < 18; $y += 2 ) + $img->Line(1,$y,$w-6,$y); + + // "White shadow" + $img->SetColor("white"); + + // Left window edge + $img->Line(2,2,2,$h-5); + $img->Line(2,2,$w-6,2); + + // "Gray button shadow" + $img->SetColor("darkgray"); + + // Gray window shadow + $img->Line(2,$h-6,$w-5,$h-6); + $img->Line(3,$h-7,$w-5,$h-7); + + // Window title + $m = floor($w/2-5); + $l = 110; + $img->SetColor("lightgray:1.3"); + $img->FilledRectangle($m-$l,2,$m+$l,16); + + // Stroke text + $img->SetColor("darkred"); + $img->SetFont(FF_FONT2,FS_BOLD); + $img->StrokeText($m-90,15,$this->iTitle); + $img->SetColor("black"); + $img->SetFont(FF_FONT1,FS_NORMAL); + $txt = new Text($aMsg,52,25); + $txt->SetFont(FF_FONT1); + $txt->Align("left","top"); + $txt->Stroke($img); + if ($this->iDest) { + $img->Stream($this->iDest); + } else { + $img->Headers(); + $img->Stream(); + } + if( $aHalt ) + die(); + } +} + + + +if( ! USE_IMAGE_ERROR_HANDLER ) { + JpGraphError::SetImageFlag(false); +} +?> diff --git a/html/jpgraph/jpgraph_error.php b/html/jpgraph/jpgraph_error.php new file mode 100644 index 0000000..3ef3ca5 --- /dev/null +++ b/html/jpgraph/jpgraph_error.php @@ -0,0 +1,157 @@ +<?php +/*======================================================================= + // File: JPGRAPH_ERROR.PHP + // Description: Error plot extension for JpGraph + // Created: 2001-01-08 + // Ver: $Id: jpgraph_error.php 1106 2009-02-22 20:16:35Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +//=================================================== +// CLASS ErrorPlot +// Description: Error plot with min/max value for +// each datapoint +//=================================================== +class ErrorPlot extends Plot { + private $errwidth=2; + + //--------------- + // CONSTRUCTOR + function __construct($datay,$datax=false) { + parent::__construct($datay,$datax); + $this->numpoints /= 2; + } + //--------------- + // PUBLIC METHODS + + // Gets called before any axis are stroked + function PreStrokeAdjust($graph) { + if( $this->center ) { + $a=0.5; $b=0.5; + ++$this->numpoints; + } else { + $a=0; $b=0; + } + $graph->xaxis->scale->ticks->SetXLabelOffset($a); + $graph->SetTextScaleOff($b); + //$graph->xaxis->scale->ticks->SupressMinorTickMarks(); + } + + // Method description + function Stroke($img,$xscale,$yscale) { + $numpoints=count($this->coords[0])/2; + $img->SetColor($this->color); + $img->SetLineWeight($this->weight); + + if( isset($this->coords[1]) ) { + if( count($this->coords[1])!=$numpoints ) + JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints); + //("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints"); + else + $exist_x = true; + } + else + $exist_x = false; + + for( $i=0; $i<$numpoints; ++$i) { + if( $exist_x ) + $x=$this->coords[1][$i]; + else + $x=$i; + + if( !is_numeric($x) || + !is_numeric($this->coords[0][$i*2]) || !is_numeric($this->coords[0][$i*2+1]) ) { + continue; + } + + $xt = $xscale->Translate($x); + $yt1 = $yscale->Translate($this->coords[0][$i*2]); + $yt2 = $yscale->Translate($this->coords[0][$i*2+1]); + $img->Line($xt,$yt1,$xt,$yt2); + $img->Line($xt-$this->errwidth,$yt1,$xt+$this->errwidth,$yt1); + $img->Line($xt-$this->errwidth,$yt2,$xt+$this->errwidth,$yt2); + } + return true; + } +} // Class + + +//=================================================== +// CLASS ErrorLinePlot +// Description: Combine a line and error plot +// THIS IS A DEPRECATED PLOT TYPE JUST KEPT FOR +// BACKWARD COMPATIBILITY +//=================================================== +class ErrorLinePlot extends ErrorPlot { + public $line=null; + //--------------- + // CONSTRUCTOR + function __construct($datay,$datax=false) { + parent::__construct($datay,$datax); + // Calculate line coordinates as the average of the error limits + $n = count($datay); + for($i=0; $i < $n; $i+=2 ) { + $ly[]=($datay[$i]+$datay[$i+1])/2; + } + $this->line=new LinePlot($ly,$datax); + } + + //--------------- + // PUBLIC METHODS + function Legend($graph) { + if( $this->legend != "" ) + $graph->legend->Add($this->legend,$this->color); + $this->line->Legend($graph); + } + + function Stroke($img,$xscale,$yscale) { + parent::Stroke($img,$xscale,$yscale); + $this->line->Stroke($img,$xscale,$yscale); + } +} // Class + + +//=================================================== +// CLASS LineErrorPlot +// Description: Combine a line and error plot +//=================================================== +class LineErrorPlot extends ErrorPlot { + public $line=null; + //--------------- + // CONSTRUCTOR + // Data is (val, errdeltamin, errdeltamax) + function __construct($datay,$datax=false) { + $ly=array(); $ey=array(); + $n = count($datay); + if( $n % 3 != 0 ) { + JpGraphError::RaiseL(4002); + //('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3'); + } + for($i=0; $i < $n; $i+=3 ) { + $ly[]=$datay[$i]; + $ey[]=$datay[$i]+$datay[$i+1]; + $ey[]=$datay[$i]+$datay[$i+2]; + } + parent::__construct($ey,$datax); + $this->line=new LinePlot($ly,$datax); + } + + //--------------- + // PUBLIC METHODS + function Legend($graph) { + if( $this->legend != "" ) + $graph->legend->Add($this->legend,$this->color); + $this->line->Legend($graph); + } + + function Stroke($img,$xscale,$yscale) { + parent::Stroke($img,$xscale,$yscale); + $this->line->Stroke($img,$xscale,$yscale); + } +} // Class + + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_flags.php b/html/jpgraph/jpgraph_flags.php new file mode 100644 index 0000000..a7e2187 --- /dev/null +++ b/html/jpgraph/jpgraph_flags.php @@ -0,0 +1,376 @@ +<?php +//======================================================================= +// File: JPGRAPH_FLAGS.PHP +// Description: Class Jpfile. Handles plotmarks +// Created: 2003-06-28 +// Ver: $Id: jpgraph_flags.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +//------------------------------------------------------------ +// Defines for the different basic sizes of flags +//------------------------------------------------------------ +DEFINE('FLAGSIZE1',1); +DEFINE('FLAGSIZE2',2); +DEFINE('FLAGSIZE3',3); +DEFINE('FLAGSIZE4',4); + +class FlagImages { + + public $iCountryNameMap = array( + 'Afghanistan' => 'afgh', + 'Republic of Angola' => 'agla', + 'Republic of Albania' => 'alba', + 'Alderney' => 'alde', + 'Democratic and Popular Republic of Algeria' => 'alge', + 'Territory of American Samoa' => 'amsa', + 'Principality of Andorra' => 'andr', + 'British Overseas Territory of Anguilla' => 'angu', + 'Antarctica' => 'anta', + 'Argentine Republic' => 'arge', + 'League of Arab States' => 'arle', + 'Republic of Armenia' => 'arme', + 'Aruba' => 'arub', + 'Commonwealth of Australia' => 'astl', + 'Republic of Austria' => 'aust', + 'Azerbaijani Republic' => 'azer', + 'Bangladesh' => 'bngl', + 'British Antarctic Territory' => 'bant', + 'Kingdom of Belgium' => 'belg', + 'British Overseas Territory of Bermuda' => 'berm', + 'Commonwealth of the Bahamas' => 'bhms', + 'Kingdom of Bahrain' => 'bhrn', + 'Republic of Belarus' => 'blru', + 'Republic of Bolivia' => 'blva', + 'Belize' => 'blze', + 'Republic of Benin' => 'bnin', + 'Republic of Botswana' => 'bots', + 'Federative Republic of Brazil' => 'braz', + 'Barbados' => 'brbd', + 'British Indian Ocean Territory' => 'brin', + 'Brunei Darussalam' => 'brun', + 'Republic of Burkina' => 'bufa', + 'Republic of Bulgaria' => 'bulg', + 'Republic of Burundi' => 'buru', + 'Overseas Territory of the British Virgin Islands' => 'bvis', + 'Central African Republic' => 'cafr', + 'Kingdom of Cambodia' => 'camb', + 'Republic of Cameroon' => 'came', + 'Dominion of Canada' => 'cana', + 'Caribbean Community' => 'cari', + 'Republic of Cape Verde' => 'cave', + 'Republic of Chad' => 'chad', + 'Republic of Chile' => 'chil', + 'Peoples Republic of China' => 'chin', + 'Territory of Christmas Island' => 'chms', + 'Commonwealth of Independent States' => 'cins', + 'Cook Islands' => 'ckis', + 'Republic of Colombia' => 'clmb', + 'Territory of Cocos Islands' => 'cois', + 'Commonwealth' => 'comn', + 'Union of the Comoros' => 'como', + 'Republic of the Congo' => 'cong', + 'Republic of Costa Rica' => 'corc', + 'Republic of Croatia' => 'croa', + 'Republic of Cuba' => 'cuba', + 'British Overseas Territory of the Cayman Islands' => 'cyis', + 'Republic of Cyprus' => 'cypr', + 'The Czech Republic' => 'czec', + 'Kingdom of Denmark' => 'denm', + 'Republic of Djibouti' => 'djib', + 'Commonwealth of Dominica' => 'domn', + 'Dominican Republic' => 'dore', + 'Republic of Ecuador' => 'ecua', + 'Arab Republic of Egypt' => 'egyp', + 'Republic of El Salvador' => 'elsa', + 'England' => 'engl', + 'Republic of Equatorial Guinea' => 'eqgu', + 'State of Eritrea' => 'erit', + 'Republic of Estonia' => 'estn', + 'Ethiopia' => 'ethp', + 'European Union' => 'euun', + 'British Overseas Territory of the Falkland Islands' => 'fais', + 'International Federation of Vexillological Associations' => 'fiav', + 'Republic of Fiji' => 'fiji', + 'Republic of Finland' => 'finl', + 'Territory of French Polynesia' => 'fpol', + 'French Republic' => 'fran', + 'Overseas Department of French Guiana' => 'frgu', + 'Gabonese Republic' => 'gabn', + 'Republic of the Gambia' => 'gamb', + 'Republic of Georgia' => 'geor', + 'Federal Republic of Germany' => 'germ', + 'Republic of Ghana' => 'ghan', + 'Gibraltar' => 'gibr', + 'Hellenic Republic' => 'grec', + 'State of Grenada' => 'gren', + 'Overseas Department of Guadeloupe' => 'guad', + 'Territory of Guam' => 'guam', + 'Republic of Guatemala' => 'guat', + 'The Bailiwick of Guernsey' => 'guer', + 'Republic of Guinea' => 'guin', + 'Republic of Haiti' => 'hait', + 'Hong Kong Special Administrative Region' => 'hokn', + 'Republic of Honduras' => 'hond', + 'Republic of Hungary' => 'hung', + 'Republic of Iceland' => 'icel', + 'International Committee of the Red Cross' => 'icrc', + 'Republic of India' => 'inda', + 'Republic of Indonesia' => 'indn', + 'Republic of Iraq' => 'iraq', + 'Republic of Ireland' => 'irel', + 'Organization of the Islamic Conference' => 'isco', + 'Isle of Man' => 'isma', + 'State of Israel' => 'isra', + 'Italian Republic' => 'ital', + 'Jamaica' => 'jama', + 'Japan' => 'japa', + 'The Bailiwick of Jersey' => 'jers', + 'Hashemite Kingdom of Jordan' => 'jord', + 'Republic of Kazakhstan' => 'kazk', + 'Republic of Kenya' => 'keny', + 'Republic of Kiribati' => 'kirb', + 'State of Kuwait' => 'kuwa', + 'Kyrgyz Republic' => 'kyrg', + 'Republic of Latvia' => 'latv', + 'Lebanese Republic' => 'leba', + 'Kingdom of Lesotho' => 'lest', + 'Republic of Liberia' => 'libe', + 'Principality of Liechtenstein' => 'liec', + 'Republic of Lithuania' => 'lith', + 'Grand Duchy of Luxembourg' => 'luxe', + 'Macao Special Administrative Region' => 'maca', + 'Republic of Macedonia' => 'mace', + 'Republic of Madagascar' => 'mada', + 'Republic of the Marshall Islands' => 'mais', + 'Republic of Mali' => 'mali', + 'Federation of Malaysia' => 'mals', + 'Republic of Malta' => 'malt', + 'Republic of Malawi' => 'malw', + 'Overseas Department of Martinique' => 'mart', + 'Islamic Republic of Mauritania' => 'maur', + 'Territorial Collectivity of Mayotte' => 'mayt', + 'United Mexican States' => 'mexc', + 'Federated States of Micronesia' => 'micr', + 'Midway Islands' => 'miis', + 'Republic of Moldova' => 'mold', + 'Principality of Monaco' => 'mona', + 'Republic of Mongolia' => 'mong', + 'British Overseas Territory of Montserrat' => 'mont', + 'Kingdom of Morocco' => 'morc', + 'Republic of Mozambique' => 'moza', + 'Republic of Mauritius' => 'mrts', + 'Union of Myanmar' => 'myan', + 'Republic of Namibia' => 'namb', + 'North Atlantic Treaty Organization' => 'nato', + 'Republic of Nauru' => 'naur', + 'Turkish Republic of Northern Cyprus' => 'ncyp', + 'Netherlands Antilles' => 'nean', + 'Kingdom of Nepal' => 'nepa', + 'Kingdom of the Netherlands' => 'neth', + 'Territory of Norfolk Island' => 'nfis', + 'Federal Republic of Nigeria' => 'ngra', + 'Republic of Nicaragua' => 'nica', + 'Republic of Niger' => 'nigr', + 'Niue' => 'niue', + 'Commonwealth of the Northern Mariana Islands' => 'nmar', + 'Province of Northern Ireland' => 'noir', + 'Nordic Council' => 'nord', + 'Kingdom of Norway' => 'norw', + 'Territory of New Caledonia and Dependencies' => 'nwca', + 'New Zealand' => 'nwze', + 'Organization of American States' => 'oast', + 'Organization of African Unity' => 'oaun', + 'International Olympic Committee' => 'olym', + 'Sultanate of Oman' => 'oman', + 'Islamic Republic of Pakistan' => 'paks', + 'Republic of Palau' => 'pala', + 'Independent State of Papua New Guinea' => 'pang', + 'Republic of Paraguay' => 'para', + 'Republic of Peru' => 'peru', + 'Republic of the Philippines' => 'phil', + 'British Overseas Territory of the Pitcairn Islands' => 'piis', + 'Republic of Poland' => 'pola', + 'Republic of Portugal' => 'port', + 'Commonwealth of Puerto Rico' => 'purc', + 'State of Qatar' => 'qata', + 'Russian Federation' => 'russ', + 'Romania' => 'rmna', + 'Republic of Rwanda' => 'rwan', + 'Kingdom of Saudi Arabia' => 'saar', + 'Republic of San Marino' => 'sama', + 'Nordic Sami Conference' => 'sami', + 'Sark' => 'sark', + 'Scotland' => 'scot', + 'Principality of Seborga' => 'sebo', + 'Republic of Serbia' => 'serb', + 'Republic of Sierra Leone' => 'sile', + 'Republic of Singapore' => 'sing', + 'Republic of Korea' => 'skor', + 'Republic of Slovenia' => 'slva', + 'Somali Republic' => 'smla', + 'Republic of Somaliland' => 'smld', + 'Republic of South Africa' => 'soaf', + 'Solomon Islands' => 'sois', + 'Kingdom of Spain' => 'span', + 'Secretariat of the Pacific Community' => 'spco', + 'Democratic Socialist Republic of Sri Lanka' => 'srla', + 'Saint Lucia' => 'stlu', + 'Republic of the Sudan' => 'suda', + 'Republic of Suriname' => 'surn', + 'Slovak Republic' => 'svka', + 'Kingdom of Sweden' => 'swdn', + 'Swiss Confederation' => 'swit', + 'Syrian Arab Republic' => 'syra', + 'Kingdom of Swaziland' => 'szld', + 'Republic of China' => 'taiw', + 'Taiwan' => 'taiw', + 'Republic of Tajikistan' => 'tajk', + 'United Republic of Tanzania' => 'tanz', + 'Kingdom of Thailand' => 'thal', + 'Autonomous Region of Tibet' => 'tibe', + 'Turkmenistan' => 'tkst', + 'Togolese Republic' => 'togo', + 'Tokelau' => 'toke', + 'Kingdom of Tonga' => 'tong', + 'Tristan da Cunha' => 'trdc', + 'Tromelin' => 'tris', + 'Republic of Tunisia' => 'tuns', + 'Republic of Turkey' => 'turk', + 'Tuvalu' => 'tuva', + 'United Arab Emirates' => 'uaem', + 'Republic of Uganda' => 'ugan', + 'Ukraine' => 'ukrn', + 'United Kingdom of Great Britain' => 'unkg', + 'United Nations' => 'unna', + 'United States of America' => 'unst', + 'Oriental Republic of Uruguay' => 'urgy', + 'Virgin Islands of the United States' => 'usvs', + 'Republic of Uzbekistan' => 'uzbk', + 'State of the Vatican City' => 'vacy', + 'Republic of Vanuatu' => 'vant', + 'Bolivarian Republic of Venezuela' => 'venz', + 'Republic of Yemen' => 'yemn', + 'Democratic Republic of Congo' => 'zare', + 'Republic of Zimbabwe' => 'zbwe' ) ; + + + private $iFlagCount = -1; + private $iFlagSetMap = array( + FLAGSIZE1 => 'flags_thumb35x35', + FLAGSIZE2 => 'flags_thumb60x60', + FLAGSIZE3 => 'flags_thumb100x100', + FLAGSIZE4 => 'flags' + ); + + private $iFlagData ; + private $iOrdIdx=array(); + + function FlagImages($aSize=FLAGSIZE1) { + switch($aSize) { + case FLAGSIZE1 : + case FLAGSIZE2 : + case FLAGSIZE3 : + case FLAGSIZE4 : + $file = dirname(__FILE__).'/'.$this->iFlagSetMap[$aSize].'.dat'; + $fp = fopen($file,'rb'); + $rawdata = fread($fp,filesize($file)); + $this->iFlagData = unserialize($rawdata); + break; + default: + JpGraphError::RaiseL(5001,$aSize); + //('Unknown flag size. ('.$aSize.')'); + } + $this->iFlagCount = count($this->iCountryNameMap); + } + + function GetNum() { + return $this->iFlagCount; + } + + function GetImgByName($aName,&$outFullName) { + $idx = $this->GetIdxByName($aName,$outFullName); + return $this->GetImgByIdx($idx); + } + + function GetImgByIdx($aIdx) { + if( array_key_exists($aIdx,$this->iFlagData) ) { + $d = $this->iFlagData[$aIdx][1]; + return Image::CreateFromString($d); + } + else { + JpGraphError::RaiseL(5002,$aIdx); + //("Flag index \"�$aIdx\" does not exist."); + } + } + + function GetIdxByOrdinal($aOrd,&$outFullName) { + $aOrd--; + $n = count($this->iOrdIdx); + if( $n == 0 ) { + reset($this->iCountryNameMap); + $this->iOrdIdx=array(); + $i=0; + while( list($key,$val) = each($this->iCountryNameMap) ) { + $this->iOrdIdx[$i++] = array($val,$key); + } + $tmp=$this->iOrdIdx[$aOrd]; + $outFullName = $tmp[1]; + return $tmp[0]; + + } + elseif( $aOrd >= 0 && $aOrd < $n ) { + $tmp=$this->iOrdIdx[$aOrd]; + $outFullName = $tmp[1]; + return $tmp[0]; + } + else { + JpGraphError::RaiseL(5003,$aOrd); + //('Invalid ordinal number specified for flag index.'); + } + } + + function GetIdxByName($aName,&$outFullName) { + + if( is_integer($aName) ) { + $idx = $this->GetIdxByOrdinal($aName,$outFullName); + return $idx; + } + + $found=false; + $aName = strtolower($aName); + $nlen = strlen($aName); + reset($this->iCountryNameMap); + // Start by trying to match exact index name + while( list($key,$val) = each($this->iCountryNameMap) ) { + if( $nlen == strlen($val) && $val == $aName ) { + $found=true; + break; + } + } + if( !$found ) { + reset($this->iCountryNameMap); + // If the exact index doesn't work try a (partial) full name + while( list($key,$val) = each($this->iCountryNameMap) ) { + if( strpos(strtolower($key), $aName) !== false ) { + $found=true; + break; + } + } + } + if( $found ) { + $outFullName = $key; + return $val; + } + else { + JpGraphError::RaiseL(5004,$aName); + //("The (partial) country name \"$aName\" does not have a cooresponding flag image. The flag may still exist but under another name, e.g. insted of \"usa\" try \"united states\"."); + } + } +} + + + + +?> diff --git a/html/jpgraph/jpgraph_gantt.php b/html/jpgraph/jpgraph_gantt.php new file mode 100644 index 0000000..02d79bb --- /dev/null +++ b/html/jpgraph/jpgraph_gantt.php @@ -0,0 +1,3955 @@ +<?php +/*======================================================================= + // File: JPGRAPH_GANTT.PHP + // Description: JpGraph Gantt plot extension + // Created: 2001-11-12 + // Ver: $Id: jpgraph_gantt.php 1809 2009-09-09 13:07:33Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +require_once('jpgraph_plotband.php'); +require_once('jpgraph_iconplot.php'); +require_once('jpgraph_plotmark.inc.php'); + +// Maximum size for Automatic Gantt chart +define('MAX_GANTTIMG_SIZE_W',8000); +define('MAX_GANTTIMG_SIZE_H',5000); + +// Scale Header types +define("GANTT_HDAY",1); +define("GANTT_HWEEK",2); +define("GANTT_HMONTH",4); +define("GANTT_HYEAR",8); +define("GANTT_HHOUR",16); +define("GANTT_HMIN",32); + +// Bar patterns +define("GANTT_RDIAG",BAND_RDIAG); // Right diagonal lines +define("GANTT_LDIAG",BAND_LDIAG); // Left diagonal lines +define("GANTT_SOLID",BAND_SOLID); // Solid one color +define("GANTT_VLINE",BAND_VLINE); // Vertical lines +define("GANTT_HLINE",BAND_HLINE); // Horizontal lines +define("GANTT_3DPLANE",BAND_3DPLANE); // "3D" Plane +define("GANTT_HVCROSS",BAND_HVCROSS); // Vertical/Hor crosses +define("GANTT_DIAGCROSS",BAND_DIAGCROSS); // Diagonal crosses + +// Conversion constant +define("SECPERDAY",3600*24); + +// Locales. ONLY KEPT FOR BACKWARDS COMPATIBILITY +// You should use the proper locale strings directly +// from now on. +define("LOCALE_EN","en_UK"); +define("LOCALE_SV","sv_SE"); + +// Layout of bars +define("GANTT_EVEN",1); +define("GANTT_FROMTOP",2); + +// Style for minute header +define("MINUTESTYLE_MM",0); // 15 +define("MINUTESTYLE_CUSTOM",2); // Custom format + + +// Style for hour header +define("HOURSTYLE_HM24",0); // 13:10 +define("HOURSTYLE_HMAMPM",1); // 1:10pm +define("HOURSTYLE_H24",2); // 13 +define("HOURSTYLE_HAMPM",3); // 1pm +define("HOURSTYLE_CUSTOM",4); // User defined + +// Style for day header +define("DAYSTYLE_ONELETTER",0); // "M" +define("DAYSTYLE_LONG",1); // "Monday" +define("DAYSTYLE_LONGDAYDATE1",2); // "Monday 23 Jun" +define("DAYSTYLE_LONGDAYDATE2",3); // "Monday 23 Jun 2003" +define("DAYSTYLE_SHORT",4); // "Mon" +define("DAYSTYLE_SHORTDAYDATE1",5); // "Mon 23/6" +define("DAYSTYLE_SHORTDAYDATE2",6); // "Mon 23 Jun" +define("DAYSTYLE_SHORTDAYDATE3",7); // "Mon 23" +define("DAYSTYLE_SHORTDATE1",8); // "23/6" +define("DAYSTYLE_SHORTDATE2",9); // "23 Jun" +define("DAYSTYLE_SHORTDATE3",10); // "Mon 23" +define("DAYSTYLE_SHORTDATE4",11); // "23" +define("DAYSTYLE_CUSTOM",12); // "M" + +// Styles for week header +define("WEEKSTYLE_WNBR",0); +define("WEEKSTYLE_FIRSTDAY",1); +define("WEEKSTYLE_FIRSTDAY2",2); +define("WEEKSTYLE_FIRSTDAYWNBR",3); +define("WEEKSTYLE_FIRSTDAY2WNBR",4); + +// Styles for month header +define("MONTHSTYLE_SHORTNAME",0); +define("MONTHSTYLE_LONGNAME",1); +define("MONTHSTYLE_LONGNAMEYEAR2",2); +define("MONTHSTYLE_SHORTNAMEYEAR2",3); +define("MONTHSTYLE_LONGNAMEYEAR4",4); +define("MONTHSTYLE_SHORTNAMEYEAR4",5); +define("MONTHSTYLE_FIRSTLETTER",6); + + +// Types of constrain links +define('CONSTRAIN_STARTSTART',0); +define('CONSTRAIN_STARTEND',1); +define('CONSTRAIN_ENDSTART',2); +define('CONSTRAIN_ENDEND',3); + +// Arrow direction for constrain links +define('ARROW_DOWN',0); +define('ARROW_UP',1); +define('ARROW_LEFT',2); +define('ARROW_RIGHT',3); + +// Arrow type for constrain type +define('ARROWT_SOLID',0); +define('ARROWT_OPEN',1); + +// Arrow size for constrain lines +define('ARROW_S1',0); +define('ARROW_S2',1); +define('ARROW_S3',2); +define('ARROW_S4',3); +define('ARROW_S5',4); + +// Activity types for use with utility method CreateSimple() +define('ACTYPE_NORMAL',0); +define('ACTYPE_GROUP',1); +define('ACTYPE_MILESTONE',2); + +define('ACTINFO_3D',1); +define('ACTINFO_2D',0); + + +// Check if array_fill() exists +if (!function_exists('array_fill')) { + function array_fill($iStart, $iLen, $vValue) { + $aResult = array(); + for ($iCount = $iStart; $iCount < $iLen + $iStart; $iCount++) { + $aResult[$iCount] = $vValue; + } + return $aResult; + } +} + +//=================================================== +// CLASS GanttActivityInfo +// Description: +//=================================================== +class GanttActivityInfo { + public $iShow=true; + public $iLeftColMargin=4,$iRightColMargin=1,$iTopColMargin=1,$iBottomColMargin=3; + public $vgrid = null; + private $iColor='black'; + private $iBackgroundColor='lightgray'; + private $iFFamily=FF_FONT1,$iFStyle=FS_NORMAL,$iFSize=10,$iFontColor='black'; + private $iTitles=array(); + private $iWidth=array(),$iHeight=-1; + private $iTopHeaderMargin = 4; + private $iStyle=1; + private $iHeaderAlign='center'; + + function __construct() { + $this->vgrid = new LineProperty(); + } + + function Hide($aF=true) { + $this->iShow=!$aF; + } + + function Show($aF=true) { + $this->iShow=$aF; + } + + // Specify font + function SetFont($aFFamily,$aFStyle=FS_NORMAL,$aFSize=10) { + $this->iFFamily = $aFFamily; + $this->iFStyle = $aFStyle; + $this->iFSize = $aFSize; + } + + function SetStyle($aStyle) { + $this->iStyle = $aStyle; + } + + function SetColumnMargin($aLeft,$aRight) { + $this->iLeftColMargin = $aLeft; + $this->iRightColMargin = $aRight; + } + + function SetFontColor($aFontColor) { + $this->iFontColor = $aFontColor; + } + + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function SetBackgroundColor($aColor) { + $this->iBackgroundColor = $aColor; + } + + function SetColTitles($aTitles,$aWidth=null) { + $this->iTitles = $aTitles; + $this->iWidth = $aWidth; + } + + function SetMinColWidth($aWidths) { + $n = min(count($this->iTitles),count($aWidths)); + for($i=0; $i < $n; ++$i ) { + if( !empty($aWidths[$i]) ) { + if( empty($this->iWidth[$i]) ) { + $this->iWidth[$i] = $aWidths[$i]; + } + else { + $this->iWidth[$i] = max($this->iWidth[$i],$aWidths[$i]); + } + } + } + } + + function GetWidth($aImg) { + $txt = new TextProperty(); + $txt->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + $n = count($this->iTitles) ; + $rm=$this->iRightColMargin; + $w = 0; + for($h=0, $i=0; $i < $n; ++$i ) { + $w += $this->iLeftColMargin; + $txt->Set($this->iTitles[$i]); + if( !empty($this->iWidth[$i]) ) { + $w1 = max($txt->GetWidth($aImg)+$rm,$this->iWidth[$i]); + } + else { + $w1 = $txt->GetWidth($aImg)+$rm; + } + $this->iWidth[$i] = $w1; + $w += $w1; + $h = max($h,$txt->GetHeight($aImg)); + } + $this->iHeight = $h+$this->iTopHeaderMargin; + $txt=''; + return $w; + } + + function GetColStart($aImg,&$aStart,$aAddLeftMargin=false) { + $n = count($this->iTitles) ; + $adj = $aAddLeftMargin ? $this->iLeftColMargin : 0; + $aStart=array($aImg->left_margin+$adj); + for( $i=1; $i < $n; ++$i ) { + $aStart[$i] = $aStart[$i-1]+$this->iLeftColMargin+$this->iWidth[$i-1]; + } + } + + // Adjust headers left, right or centered + function SetHeaderAlign($aAlign) { + $this->iHeaderAlign=$aAlign; + } + + function Stroke($aImg,$aXLeft,$aYTop,$aXRight,$aYBottom,$aUseTextHeight=false) { + + if( !$this->iShow ) return; + + $txt = new TextProperty(); + $txt->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + $txt->SetColor($this->iFontColor); + $txt->SetAlign($this->iHeaderAlign,'top'); + $n=count($this->iTitles); + + if( $n == 0 ) + return; + + $x = $aXLeft; + $h = $this->iHeight; + $yTop = $aUseTextHeight ? $aYBottom-$h-$this->iTopColMargin-$this->iBottomColMargin : $aYTop ; + + if( $h < 0 ) { + JpGraphError::RaiseL(6001); + //('Internal error. Height for ActivityTitles is < 0'); + } + + $aImg->SetLineWeight(1); + // Set background color + $aImg->SetColor($this->iBackgroundColor); + $aImg->FilledRectangle($aXLeft,$yTop,$aXRight,$aYBottom-1); + + if( $this->iStyle == 1 ) { + // Make a 3D effect + $aImg->SetColor('white'); + $aImg->Line($aXLeft,$yTop+1,$aXRight,$yTop+1); + } + + for($i=0; $i < $n; ++$i ) { + if( $this->iStyle == 1 ) { + // Make a 3D effect + $aImg->SetColor('white'); + $aImg->Line($x+1,$yTop,$x+1,$aYBottom); + } + $x += $this->iLeftColMargin; + $txt->Set($this->iTitles[$i]); + + // Adjust the text anchor position according to the choosen alignment + $xp = $x; + if( $this->iHeaderAlign == 'center' ) { + $xp = (($x-$this->iLeftColMargin)+($x+$this->iWidth[$i]))/2; + } + elseif( $this->iHeaderAlign == 'right' ) { + $xp = $x +$this->iWidth[$i]-$this->iRightColMargin; + } + + $txt->Stroke($aImg,$xp,$yTop+$this->iTopHeaderMargin); + $x += $this->iWidth[$i]; + if( $i < $n-1 ) { + $aImg->SetColor($this->iColor); + $aImg->Line($x,$yTop,$x,$aYBottom); + } + } + + $aImg->SetColor($this->iColor); + $aImg->Line($aXLeft,$yTop, $aXRight,$yTop); + + // Stroke vertical column dividers + $cols=array(); + $this->GetColStart($aImg,$cols); + $n=count($cols); + for( $i=1; $i < $n; ++$i ) { + $this->vgrid->Stroke($aImg,$cols[$i],$aYBottom,$cols[$i], + $aImg->height - $aImg->bottom_margin); + } + } +} + + +//=================================================== +// CLASS GanttGraph +// Description: Main class to handle gantt graphs +//=================================================== +class GanttGraph extends Graph { + public $scale; // Public accessible + public $hgrid=null; + private $iObj=array(); // Gantt objects + private $iLabelHMarginFactor=0.2; // 10% margin on each side of the labels + private $iLabelVMarginFactor=0.4; // 40% margin on top and bottom of label + private $iLayout=GANTT_FROMTOP; // Could also be GANTT_EVEN + private $iSimpleFont = FF_FONT1,$iSimpleFontSize=11; + private $iSimpleStyle=GANTT_RDIAG,$iSimpleColor='yellow',$iSimpleBkgColor='red'; + private $iSimpleProgressBkgColor='gray',$iSimpleProgressColor='darkgreen'; + private $iSimpleProgressStyle=GANTT_SOLID; + private $iZoomFactor = 1.0; + //--------------- + // CONSTRUCTOR + // Create a new gantt graph + function __construct($aWidth=0,$aHeight=0,$aCachedName="",$aTimeOut=0,$aInline=true) { + + // Backward compatibility + if( $aWidth == -1 ) $aWidth=0; + if( $aHeight == -1 ) $aHeight=0; + + if( $aWidth< 0 || $aHeight < 0 ) { + JpgraphError::RaiseL(6002); + //("You can't specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension."); + } + parent::__construct($aWidth,$aHeight,$aCachedName,$aTimeOut,$aInline); + $this->scale = new GanttScale($this->img); + + // Default margins + $this->img->SetMargin(15,17,25,15); + + $this->hgrid = new HorizontalGridLine(); + + $this->scale->ShowHeaders(GANTT_HWEEK|GANTT_HDAY); + $this->SetBox(); + } + + //--------------- + // PUBLIC METHODS + + // + + function SetSimpleFont($aFont,$aSize) { + $this->iSimpleFont = $aFont; + $this->iSimpleFontSize = $aSize; + } + + function SetSimpleStyle($aBand,$aColor,$aBkgColor) { + $this->iSimpleStyle = $aBand; + $this->iSimpleColor = $aColor; + $this->iSimpleBkgColor = $aBkgColor; + } + + // A utility function to help create basic Gantt charts + function CreateSimple($data,$constrains=array(),$progress=array()) { + $num = count($data); + for( $i=0; $i < $num; ++$i) { + switch( $data[$i][1] ) { + case ACTYPE_GROUP: + // Create a slightly smaller height bar since the + // "wings" at the end will make it look taller + $a = new GanttBar($data[$i][0],$data[$i][2],$data[$i][3],$data[$i][4],'',8); + $a->title->SetFont($this->iSimpleFont,FS_BOLD,$this->iSimpleFontSize); + $a->rightMark->Show(); + $a->rightMark->SetType(MARK_RIGHTTRIANGLE); + $a->rightMark->SetWidth(8); + $a->rightMark->SetColor('black'); + $a->rightMark->SetFillColor('black'); + + $a->leftMark->Show(); + $a->leftMark->SetType(MARK_LEFTTRIANGLE); + $a->leftMark->SetWidth(8); + $a->leftMark->SetColor('black'); + $a->leftMark->SetFillColor('black'); + + $a->SetPattern(BAND_SOLID,'black'); + $csimpos = 6; + break; + + case ACTYPE_NORMAL: + $a = new GanttBar($data[$i][0],$data[$i][2],$data[$i][3],$data[$i][4],'',10); + $a->title->SetFont($this->iSimpleFont,FS_NORMAL,$this->iSimpleFontSize); + $a->SetPattern($this->iSimpleStyle,$this->iSimpleColor); + $a->SetFillColor($this->iSimpleBkgColor); + // Check if this activity should have a constrain line + $n = count($constrains); + for( $j=0; $j < $n; ++$j ) { + if( empty($constrains[$j]) || (count($constrains[$j]) != 3) ) { + JpGraphError::RaiseL(6003,$j); + //("Invalid format for Constrain parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)"); + } + if( $constrains[$j][0]==$data[$i][0] ) { + $a->SetConstrain($constrains[$j][1],$constrains[$j][2],'black',ARROW_S2,ARROWT_SOLID); + } + } + + // Check if this activity have a progress bar + $n = count($progress); + for( $j=0; $j < $n; ++$j ) { + + if( empty($progress[$j]) || (count($progress[$j]) != 2) ) { + JpGraphError::RaiseL(6004,$j); + //("Invalid format for Progress parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)"); + } + if( $progress[$j][0]==$data[$i][0] ) { + $a->progress->Set($progress[$j][1]); + $a->progress->SetPattern($this->iSimpleProgressStyle, + $this->iSimpleProgressColor); + $a->progress->SetFillColor($this->iSimpleProgressBkgColor); + //$a->progress->SetPattern($progress[$j][2],$progress[$j][3]); + break; + } + } + $csimpos = 6; + break; + + case ACTYPE_MILESTONE: + $a = new MileStone($data[$i][0],$data[$i][2],$data[$i][3]); + $a->title->SetFont($this->iSimpleFont,FS_NORMAL,$this->iSimpleFontSize); + $a->caption->SetFont($this->iSimpleFont,FS_NORMAL,$this->iSimpleFontSize); + $csimpos = 5; + break; + default: + die('Unknown activity type'); + break; + } + + // Setup caption + $a->caption->Set($data[$i][$csimpos-1]); + + // Check if this activity should have a CSIM target�? + if( !empty($data[$i][$csimpos]) ) { + $a->SetCSIMTarget($data[$i][$csimpos]); + $a->SetCSIMAlt($data[$i][$csimpos+1]); + } + if( !empty($data[$i][$csimpos+2]) ) { + $a->title->SetCSIMTarget($data[$i][$csimpos+2]); + $a->title->SetCSIMAlt($data[$i][$csimpos+3]); + } + + $this->Add($a); + } + } + + // Set user specified scale zoom factor when auto sizing is used + function SetZoomFactor($aZoom) { + $this->iZoomFactor = $aZoom; + } + + + // Set what headers should be shown + function ShowHeaders($aFlg) { + $this->scale->ShowHeaders($aFlg); + } + + // Specify the fraction of the font height that should be added + // as vertical margin + function SetLabelVMarginFactor($aVal) { + $this->iLabelVMarginFactor = $aVal; + } + + // Synonym to the method above + function SetVMarginFactor($aVal) { + $this->iLabelVMarginFactor = $aVal; + } + + + // Add a new Gantt object + function Add($aObject) { + if( is_array($aObject) && count($aObject) > 0 ) { + $cl = $aObject[0]; + if( class_exists('IconPlot',false) && ($cl instanceof IconPlot) ) { + $this->AddIcon($aObject); + } + elseif( class_exists('Text',false) && ($cl instanceof Text) ) { + $this->AddText($aObject); + } + else { + $n = count($aObject); + for($i=0; $i < $n; ++$i) + $this->iObj[] = $aObject[$i]; + } + } + else { + if( class_exists('IconPlot',false) && ($aObject instanceof IconPlot) ) { + $this->AddIcon($aObject); + } + elseif( class_exists('Text',false) && ($aObject instanceof Text) ) { + $this->AddText($aObject); + } + else { + $this->iObj[] = $aObject; + } + } + } + + function StrokeTexts() { + // Stroke any user added text objects + if( $this->texts != null ) { + $n = count($this->texts); + for($i=0; $i < $n; ++$i) { + if( $this->texts[$i]->iScalePosX !== null && $this->texts[$i]->iScalePosY !== null ) { + $x = $this->scale->TranslateDate($this->texts[$i]->iScalePosX); + $y = $this->scale->TranslateVertPos($this->texts[$i]->iScalePosY); + $y -= $this->scale->GetVertSpacing()/2; + } + else { + $x = $y = null; + } + $this->texts[$i]->Stroke($this->img,$x,$y); + } + } + } + + // Override inherit method from Graph and give a warning message + function SetScale($aAxisType,$aYMin=1,$aYMax=1,$aXMin=1,$aXMax=1) { + JpGraphError::RaiseL(6005); + //("SetScale() is not meaningfull with Gantt charts."); + } + + // Specify the date range for Gantt graphs (if this is not set it will be + // automtically determined from the input data) + function SetDateRange($aStart,$aEnd) { + // Adjust the start and end so that the indicate the + // begining and end of respective start and end days + if( strpos($aStart,':') === false ) + $aStart = date('Y-m-d 00:00',strtotime($aStart)); + if( strpos($aEnd,':') === false ) + $aEnd = date('Y-m-d 23:59',strtotime($aEnd)); + $this->scale->SetRange($aStart,$aEnd); + } + + // Get the maximum width of the activity titles columns for the bars + // The name is lightly misleading since we from now on can have + // multiple columns in the label section. When this was first written + // it only supported a single label, hence the name. + function GetMaxLabelWidth() { + $m=10; + if( $this->iObj != null ) { + $marg = $this->scale->actinfo->iLeftColMargin+$this->scale->actinfo->iRightColMargin; + $n = count($this->iObj); + for($i=0; $i < $n; ++$i) { + if( !empty($this->iObj[$i]->title) ) { + if( $this->iObj[$i]->title->HasTabs() ) { + list($tot,$w) = $this->iObj[$i]->title->GetWidth($this->img,true); + $m=max($m,$tot); + } + else + $m=max($m,$this->iObj[$i]->title->GetWidth($this->img)); + } + } + } + return $m; + } + + // Get the maximum height of the titles for the bars + function GetMaxLabelHeight() { + $m=10; + if( $this->iObj != null ) { + $n = count($this->iObj); + // We can not include the title of GnttVLine since that title is stroked at the bottom + // of the Gantt bar and not in the activity title columns + for($i=0; $i < $n; ++$i) { + if( !empty($this->iObj[$i]->title) && !($this->iObj[$i] instanceof GanttVLine) ) { + $m=max($m,$this->iObj[$i]->title->GetHeight($this->img)); + } + } + } + return $m; + } + + function GetMaxBarAbsHeight() { + $m=0; + if( $this->iObj != null ) { + $m = $this->iObj[0]->GetAbsHeight($this->img); + $n = count($this->iObj); + for($i=1; $i < $n; ++$i) { + $m=max($m,$this->iObj[$i]->GetAbsHeight($this->img)); + } + } + return $m; + } + + // Get the maximum used line number (vertical position) for bars + function GetBarMaxLineNumber() { + $m=1; + if( $this->iObj != null ) { + $m = $this->iObj[0]->GetLineNbr(); + $n = count($this->iObj); + for($i=1; $i < $n; ++$i) { + $m=max($m,$this->iObj[$i]->GetLineNbr()); + } + } + return $m; + } + + // Get the minumum and maximum used dates for all bars + function GetBarMinMax() { + $start = 0 ; + $n = count($this->iObj); + while( $start < $n && $this->iObj[$start]->GetMaxDate() === false ) + ++$start; + if( $start >= $n ) { + JpgraphError::RaiseL(6006); + //('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]'); + } + + $max=$this->scale->NormalizeDate($this->iObj[$start]->GetMaxDate()); + $min=$this->scale->NormalizeDate($this->iObj[$start]->GetMinDate()); + + for($i=$start+1; $i < $n; ++$i) { + $rmax = $this->scale->NormalizeDate($this->iObj[$i]->GetMaxDate()); + if( $rmax != false ) + $max=Max($max,$rmax); + $rmin = $this->scale->NormalizeDate($this->iObj[$i]->GetMinDate()); + if( $rmin != false ) + $min=Min($min,$rmin); + } + $minDate = date("Y-m-d",$min); + $min = strtotime($minDate); + $maxDate = date("Y-m-d 23:59",$max); + $max = strtotime($maxDate); + return array($min,$max); + } + + // Create a new auto sized canvas if the user hasn't specified a size + // The size is determined by what scale the user has choosen and hence + // the minimum width needed to display the headers. Some margins are + // also added to make it better looking. + function AutoSize() { + + if( $this->img->img == null ) { + // The predefined left, right, top, bottom margins. + // Note that the top margin might incease depending on + // the title. + $hadj = $vadj = 0; + if( $this->doshadow ) { + $hadj = $this->shadow_width; + $vadj = $this->shadow_width+5; + } + + $lm = $this->img->left_margin; + $rm = $this->img->right_margin +$hadj; + $rm += 2 ; + $tm = $this->img->top_margin; + $bm = $this->img->bottom_margin + $vadj; + $bm += 2; + + // If there are any added GanttVLine we must make sure that the + // bottom margin is wide enough to hold a title. + $n = count($this->iObj); + for($i=0; $i < $n; ++$i) { + if( $this->iObj[$i] instanceof GanttVLine ) { + $bm = max($bm,$this->iObj[$i]->title->GetHeight($this->img)+10); + } + } + + // First find out the height + $n=$this->GetBarMaxLineNumber()+1; + $m=max($this->GetMaxLabelHeight(),$this->GetMaxBarAbsHeight()); + $height=$n*((1+$this->iLabelVMarginFactor)*$m); + + // Add the height of the scale titles + $h=$this->scale->GetHeaderHeight(); + $height += $h; + + // Calculate the top margin needed for title and subtitle + if( $this->title->t != "" ) { + $tm += $this->title->GetFontHeight($this->img); + } + if( $this->subtitle->t != "" ) { + $tm += $this->subtitle->GetFontHeight($this->img); + } + + // ...and then take the bottom and top plot margins into account + $height += $tm + $bm + $this->scale->iTopPlotMargin + $this->scale->iBottomPlotMargin; + // Now find the minimum width for the chart required + + // If day scale or smaller is shown then we use the day font width + // as the base size unit. + // If only weeks or above is displayed we use a modified unit to + // get a smaller image. + if( $this->scale->IsDisplayHour() || $this->scale->IsDisplayMinute() ) { + // Add 2 pixel margin on each side + $fw=$this->scale->day->GetFontWidth($this->img)+4; + } + elseif( $this->scale->IsDisplayWeek() ) { + $fw = 8; + } + elseif( $this->scale->IsDisplayMonth() ) { + $fw = 4; + } + else { + $fw = 2; + } + + $nd=$this->scale->GetNumberOfDays(); + + if( $this->scale->IsDisplayDay() ) { + // If the days are displayed we also need to figure out + // how much space each day's title will require. + switch( $this->scale->day->iStyle ) { + case DAYSTYLE_LONG : + $txt = "Monday"; + break; + case DAYSTYLE_LONGDAYDATE1 : + $txt = "Monday 23 Jun"; + break; + case DAYSTYLE_LONGDAYDATE2 : + $txt = "Monday 23 Jun 2003"; + break; + case DAYSTYLE_SHORT : + $txt = "Mon"; + break; + case DAYSTYLE_SHORTDAYDATE1 : + $txt = "Mon 23/6"; + break; + case DAYSTYLE_SHORTDAYDATE2 : + $txt = "Mon 23 Jun"; + break; + case DAYSTYLE_SHORTDAYDATE3 : + $txt = "Mon 23"; + break; + case DAYSTYLE_SHORTDATE1 : + $txt = "23/6"; + break; + case DAYSTYLE_SHORTDATE2 : + $txt = "23 Jun"; + break; + case DAYSTYLE_SHORTDATE3 : + $txt = "Mon 23"; + break; + case DAYSTYLE_SHORTDATE4 : + $txt = "88"; + break; + case DAYSTYLE_CUSTOM : + $txt = date($this->scale->day->iLabelFormStr,strtotime('2003-12-20 18:00')); + break; + case DAYSTYLE_ONELETTER : + default: + $txt = "M"; + break; + } + $fw = $this->scale->day->GetStrWidth($this->img,$txt)+6; + } + + // If we have hours enabled we must make sure that each day has enough + // space to fit the number of hours to be displayed. + if( $this->scale->IsDisplayHour() ) { + // Depending on what format the user has choose we need different amount + // of space. We therefore create a typical string for the choosen format + // and determine the length of that string. + switch( $this->scale->hour->iStyle ) { + case HOURSTYLE_HMAMPM: + $txt = '12:00pm'; + break; + case HOURSTYLE_H24: + // 13 + $txt = '24'; + break; + case HOURSTYLE_HAMPM: + $txt = '12pm'; + break; + case HOURSTYLE_CUSTOM: + $txt = date($this->scale->hour->iLabelFormStr,strtotime('2003-12-20 18:00')); + break; + case HOURSTYLE_HM24: + default: + $txt = '24:00'; + break; + } + + $hfw = $this->scale->hour->GetStrWidth($this->img,$txt)+6; + $mw = $hfw; + if( $this->scale->IsDisplayMinute() ) { + // Depending on what format the user has choose we need different amount + // of space. We therefore create a typical string for the choosen format + // and determine the length of that string. + switch( $this->scale->minute->iStyle ) { + case HOURSTYLE_CUSTOM: + $txt2 = date($this->scale->minute->iLabelFormStr,strtotime('2005-05-15 18:55')); + break; + case MINUTESTYLE_MM: + default: + $txt2 = '15'; + break; + } + + $mfw = $this->scale->minute->GetStrWidth($this->img,$txt2)+6; + $n2 = ceil(60 / $this->scale->minute->GetIntervall() ); + $mw = $n2 * $mfw; + } + $hfw = $hfw < $mw ? $mw : $hfw ; + $n = ceil(24*60 / $this->scale->TimeToMinutes($this->scale->hour->GetIntervall()) ); + $hw = $n * $hfw; + $fw = $fw < $hw ? $hw : $fw ; + } + + // We need to repeat this code block here as well. + // THIS iS NOT A MISTAKE ! + // We really need it since we need to adjust for minutes both in the case + // where hour scale is shown and when it is not shown. + + if( $this->scale->IsDisplayMinute() ) { + // Depending on what format the user has choose we need different amount + // of space. We therefore create a typical string for the choosen format + // and determine the length of that string. + switch( $this->scale->minute->iStyle ) { + case HOURSTYLE_CUSTOM: + $txt = date($this->scale->minute->iLabelFormStr,strtotime('2005-05-15 18:55')); + break; + case MINUTESTYLE_MM: + default: + $txt = '15'; + break; + } + + $mfw = $this->scale->minute->GetStrWidth($this->img,$txt)+6; + $n = ceil(60 / $this->scale->TimeToMinutes($this->scale->minute->GetIntervall()) ); + $mw = $n * $mfw; + $fw = $fw < $mw ? $mw : $fw ; + } + + // If we display week we must make sure that 7*$fw is enough + // to fit up to 10 characters of the week font (if the week is enabled) + if( $this->scale->IsDisplayWeek() ) { + // Depending on what format the user has choose we need different amount + // of space + $fsw = strlen($this->scale->week->iLabelFormStr); + if( $this->scale->week->iStyle==WEEKSTYLE_FIRSTDAY2WNBR ) { + $fsw += 8; + } + elseif( $this->scale->week->iStyle==WEEKSTYLE_FIRSTDAYWNBR ) { + $fsw += 7; + } + else { + $fsw += 4; + } + + $ww = $fsw*$this->scale->week->GetFontWidth($this->img); + if( 7*$fw < $ww ) { + $fw = ceil($ww/7); + } + } + + if( !$this->scale->IsDisplayDay() && !$this->scale->IsDisplayHour() && + !( ($this->scale->week->iStyle==WEEKSTYLE_FIRSTDAYWNBR || + $this->scale->week->iStyle==WEEKSTYLE_FIRSTDAY2WNBR) && $this->scale->IsDisplayWeek() ) ) { + // If we don't display the individual days we can shrink the + // scale a little bit. This is a little bit pragmatic at the + // moment and should be re-written to take into account + // a) What scales exactly are shown and + // b) what format do they use so we know how wide we need to + // make each scale text space at minimum. + $fw /= 2; + if( !$this->scale->IsDisplayWeek() ) { + $fw /= 1.8; + } + } + + $cw = $this->GetMaxActInfoColWidth() ; + $this->scale->actinfo->SetMinColWidth($cw); + if( $this->img->width <= 0 ) { + // Now determine the width for the activity titles column + + // Firdst find out the maximum width of each object column + $titlewidth = max(max($this->GetMaxLabelWidth(), + $this->scale->tableTitle->GetWidth($this->img)), + $this->scale->actinfo->GetWidth($this->img)); + + // Add the width of the vertivcal divider line + $titlewidth += $this->scale->divider->iWeight*2; + + // Adjust the width by the user specified zoom factor + $fw *= $this->iZoomFactor; + + // Now get the total width taking + // titlewidth, left and rigt margin, dayfont size + // into account + $width = $titlewidth + $nd*$fw + $lm+$rm; + } + else { + $width = $this->img->width; + } + + $width = round($width); + $height = round($height); + // Make a sanity check on image size + if( $width > MAX_GANTTIMG_SIZE_W || $height > MAX_GANTTIMG_SIZE_H ) { + JpgraphError::RaiseL(6007,$width,$height); + //("Sanity check for automatic Gantt chart size failed. Either the width (=$width) or height (=$height) is larger than MAX_GANTTIMG_SIZE. This could potentially be caused by a wrong date in one of the activities."); + } + $this->img->CreateImgCanvas($width,$height); + $this->img->SetMargin($lm,$rm,$tm,$bm); + } + } + + // Return an array width the maximum width for each activity + // column. This is used when we autosize the columns where we need + // to find out the maximum width of each column. In order to do that we + // must walk through all the objects, sigh... + function GetMaxActInfoColWidth() { + $n = count($this->iObj); + if( $n == 0 ) return; + $w = array(); + $m = $this->scale->actinfo->iLeftColMargin + $this->scale->actinfo->iRightColMargin; + + for( $i=0; $i < $n; ++$i ) { + $tmp = $this->iObj[$i]->title->GetColWidth($this->img,$m); + $nn = count($tmp); + for( $j=0; $j < $nn; ++$j ) { + if( empty($w[$j]) ) + $w[$j] = $tmp[$j]; + else + $w[$j] = max($w[$j],$tmp[$j]); + } + } + return $w; + } + + // Stroke the gantt chart + function Stroke($aStrokeFileName="") { + + // If the filename is the predefined value = '_csim_special_' + // we assume that the call to stroke only needs to do enough + // to correctly generate the CSIM maps. + // We use this variable to skip things we don't strictly need + // to do to generate the image map to improve performance + // a best we can. Therefor you will see a lot of tests !$_csim in the + // code below. + $_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); + + // Should we autoscale dates? + + if( !$this->scale->IsRangeSet() ) { + list($min,$max) = $this->GetBarMinMax(); + $this->scale->SetRange($min,$max); + } + + $this->scale->AdjustStartEndDay(); + + // Check if we should autoscale the image + $this->AutoSize(); + + // Should we start from the top or just spread the bars out even over the + // available height + $this->scale->SetVertLayout($this->iLayout); + if( $this->iLayout == GANTT_FROMTOP ) { + $maxheight=max($this->GetMaxLabelHeight(),$this->GetMaxBarAbsHeight()); + $this->scale->SetVertSpacing($maxheight*(1+$this->iLabelVMarginFactor)); + } + // If it hasn't been set find out the maximum line number + if( $this->scale->iVertLines == -1 ) + $this->scale->iVertLines = $this->GetBarMaxLineNumber()+1; + + $maxwidth=max($this->scale->actinfo->GetWidth($this->img), + max($this->GetMaxLabelWidth(), + $this->scale->tableTitle->GetWidth($this->img))); + + $this->scale->SetLabelWidth($maxwidth+$this->scale->divider->iWeight);//*(1+$this->iLabelHMarginFactor)); + + if( !$_csim ) { + $this->StrokePlotArea(); + if( $this->iIconDepth == DEPTH_BACK ) { + $this->StrokeIcons(); + } + } + + $this->scale->Stroke(); + + if( !$_csim ) { + // Due to a minor off by 1 bug we need to temporarily adjust the margin + $this->img->right_margin--; + $this->StrokePlotBox(); + $this->img->right_margin++; + } + + // Stroke Grid line + $this->hgrid->Stroke($this->img,$this->scale); + + $n = count($this->iObj); + for($i=0; $i < $n; ++$i) { + //$this->iObj[$i]->SetLabelLeftMargin(round($maxwidth*$this->iLabelHMarginFactor/2)); + $this->iObj[$i]->Stroke($this->img,$this->scale); + } + + $this->StrokeTitles(); + + if( !$_csim ) { + $this->StrokeConstrains(); + $this->footer->Stroke($this->img); + + + if( $this->iIconDepth == DEPTH_FRONT) { + $this->StrokeIcons(); + } + + // Stroke all added user texts + $this->StrokeTexts(); + + // Should we do any final image transformation + if( $this->iImgTrans ) { + if( !class_exists('ImgTrans',false) ) { + require_once('jpgraph_imgtrans.php'); + } + + $tform = new ImgTrans($this->img->img); + $this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, + $this->iImgTransDirection,$this->iImgTransHighQ, + $this->iImgTransMinSize,$this->iImgTransFillColor, + $this->iImgTransBorder); + } + + + // If the filename is given as the special "__handle" + // then the image handler is returned and the image is NOT + // streamed back + if( $aStrokeFileName == _IMG_HANDLER ) { + return $this->img->img; + } + else { + // Finally stream the generated picture + $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline, + $aStrokeFileName); + } + } + } + + function StrokeConstrains() { + $n = count($this->iObj); + + // Stroke all constrains + for($i=0; $i < $n; ++$i) { + + // Some gantt objects may not have constraints associated with them + // for example we can add IconPlots which doesn't have this property. + if( empty($this->iObj[$i]->constraints) ) continue; + + $numConstrains = count($this->iObj[$i]->constraints); + + for( $k = 0; $k < $numConstrains; $k++ ) { + $vpos = $this->iObj[$i]->constraints[$k]->iConstrainRow; + if( $vpos >= 0 ) { + $c1 = $this->iObj[$i]->iConstrainPos; + + // Find out which object is on the target row + $targetobj = -1; + for( $j=0; $j < $n && $targetobj == -1; ++$j ) { + if( $this->iObj[$j]->iVPos == $vpos ) { + $targetobj = $j; + } + } + if( $targetobj == -1 ) { + JpGraphError::RaiseL(6008,$this->iObj[$i]->iVPos,$vpos); + //('You have specifed a constrain from row='.$this->iObj[$i]->iVPos.' to row='.$vpos.' which does not have any activity.'); + } + $c2 = $this->iObj[$targetobj]->iConstrainPos; + if( count($c1) == 4 && count($c2 ) == 4) { + switch( $this->iObj[$i]->constraints[$k]->iConstrainType ) { + case CONSTRAIN_ENDSTART: + if( $c1[1] < $c2[1] ) { + $link = new GanttLink($c1[2],$c1[3],$c2[0],$c2[1]); + } + else { + $link = new GanttLink($c1[2],$c1[1],$c2[0],$c2[3]); + } + $link->SetPath(3); + break; + case CONSTRAIN_STARTEND: + if( $c1[1] < $c2[1] ) { + $link = new GanttLink($c1[0],$c1[3],$c2[2],$c2[1]); + } + else { + $link = new GanttLink($c1[0],$c1[1],$c2[2],$c2[3]); + } + $link->SetPath(0); + break; + case CONSTRAIN_ENDEND: + if( $c1[1] < $c2[1] ) { + $link = new GanttLink($c1[2],$c1[3],$c2[2],$c2[1]); + } + else { + $link = new GanttLink($c1[2],$c1[1],$c2[2],$c2[3]); + } + $link->SetPath(1); + break; + case CONSTRAIN_STARTSTART: + if( $c1[1] < $c2[1] ) { + $link = new GanttLink($c1[0],$c1[3],$c2[0],$c2[1]); + } + else { + $link = new GanttLink($c1[0],$c1[1],$c2[0],$c2[3]); + } + $link->SetPath(3); + break; + default: + JpGraphError::RaiseL(6009,$this->iObj[$i]->iVPos,$vpos); + //('Unknown constrain type specified from row='.$this->iObj[$i]->iVPos.' to row='.$vpos); + break; + } + + $link->SetColor($this->iObj[$i]->constraints[$k]->iConstrainColor); + $link->SetArrow($this->iObj[$i]->constraints[$k]->iConstrainArrowSize, + $this->iObj[$i]->constraints[$k]->iConstrainArrowType); + + $link->Stroke($this->img); + } + } + } + } + } + + function GetCSIMAreas() { + if( !$this->iHasStroked ) + $this->Stroke(_CSIM_SPECIALFILE); + + $csim = $this->title->GetCSIMAreas(); + $csim .= $this->subtitle->GetCSIMAreas(); + $csim .= $this->subsubtitle->GetCSIMAreas(); + + $n = count($this->iObj); + for( $i=$n-1; $i >= 0; --$i ) + $csim .= $this->iObj[$i]->GetCSIMArea(); + return $csim; + } +} + +//=================================================== +// CLASS PredefIcons +// Description: Predefined icons for use with Gantt charts +//=================================================== +define('GICON_WARNINGRED',0); +define('GICON_TEXT',1); +define('GICON_ENDCONS',2); +define('GICON_MAIL',3); +define('GICON_STARTCONS',4); +define('GICON_CALC',5); +define('GICON_MAGNIFIER',6); +define('GICON_LOCK',7); +define('GICON_STOP',8); +define('GICON_WARNINGYELLOW',9); +define('GICON_FOLDEROPEN',10); +define('GICON_FOLDER',11); +define('GICON_TEXTIMPORTANT',12); + +class PredefIcons { + private $iBuiltinIcon = null, $iLen = -1 ; + + function GetLen() { + return $this->iLen ; + } + + function GetImg($aIdx) { + if( $aIdx < 0 || $aIdx >= $this->iLen ) { + JpGraphError::RaiseL(6010,$aIdx); + //('Illegal icon index for Gantt builtin icon ['.$aIdx.']'); + } + return Image::CreateFromString(base64_decode($this->iBuiltinIcon[$aIdx][1])); + } + + function __construct() { + //========================================================== + // warning.png + //========================================================== + $this->iBuiltinIcon[0][0]= 1043 ; + $this->iBuiltinIcon[0][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'. + 'B3RJTUUH0wgKFSgilWPhUQAAA6BJREFUeNrtl91rHFUYh5/3zMx+Z5JNUoOamCZNaqTZ6IWIkqRiQWmi1IDetHfeiCiltgXBP8AL'. + '0SIUxf/AvfRSBS9EKILFFqyIH9CEmFZtPqrBJLs7c+b1YneT3WTTbNsUFPLCcAbmzPt73o9zzgzs2Z793231UOdv3w9k9Z2uzOdA'. + '5+2+79yNeL7Hl7hw7oeixRMZ6PJM26W18DNAm/Vh7lR8fqh97NmMF11es1iFpMATqdirwMNA/J4DpIzkr5YsAF1PO6gIMYHRdPwl'. + 'oO2elmB+qH3sm7XozbkgYvy8SzYnZPtcblyM6I+5z3jQ+0vJfgpEu56BfI9vUkbyi2HZd1QJoeWRiAjBd4SDCW8SSAOy6wBHMzF7'. + 'YdV2A+ROuvRPLfHoiSU0EMY/cDAIhxJeGngKaN1VgHyPL7NBxI1K9P4QxBzw3K1zJ/zkG8B9uwaQ7/HNsRZv9kohBGD0o7JqMYS/'. + '/ynPidQw/LrBiPBcS/yFCT95DvB2BWAy4575PaQbQKW+tPd3GCItu2odKI++YxiKu0d26oWmAD7paZU/rLz37VqIijD2YbnzNBBE'. + 'IBHf8K8qjL7vYhCGErEU8CTg3xXAeMp96GrJEqkyXkm9Bhui1xfsunjdGhcYLq+IzjsGmBt5YH/cmJkFq6gIqlon3u4LxdKGuCIo'. + 'Qu41g0E41po+2R33Xt5uz9kRIB2UTle7PnfKrROP1HD4sRjZlq0lzhwoZ6rDNeTi3nEg1si/7FT7kYQbXS6E5E65tA5uRF9tutq0'. + 'K/VwAF+/FbIYWt6+tjQM/AqUms7A4Wy6d7YSfSNxgMmzi0ycWWworio4QJvj4LpuL5BqugTnXzzqJsJwurrlNhJXFaavW67NRw3F'. + 'q+aJcCQVe9fzvJGmAY7/dPH0gi0f64OveGxa+usCuQMeZ0+kt8BVrX+qPO9Bzx0MgqBvs+a2PfDdYIf+WAjXU1ub4tqNaPPzRs8A'. + 'blrli+WVn79cXn0cWKl+tGx7HLc7pu3CSmnfitL+l1UihAhwjFkPQev4K/fSABjBM8JCaFuurJU+rgW41SroA8aNMVNAFtgHJCsn'. + 'XGy/58QVxAC9MccJtZ5kIzNlW440WrJ2ea4YPA9cAooA7i0A/gS+iqLoOpB1HOegqrYB3UBmJrAtQAJwpwPr1Ry92wVlgZsiYlW1'. + 'uX1gU36dymgqYxJIJJNJT1W9QqHgNwFQBGYqo94OwHZQUuPD7ACglSvc+5n5T9m/wfJJX4U9qzEAAAAASUVORK5CYII=' ; + + //========================================================== + // edit.png + //========================================================== + $this->iBuiltinIcon[1][0]= 959 ; + $this->iBuiltinIcon[1][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAFgAWABY9j+ZuwAAAAlwSFlz'. + 'AAALEAAACxABrSO9dQAAAAd0SU1FB9AKDAwbIEXOA6AAAAM8SURBVHicpdRPaBxlHMbx76ZvsmOTmm1dsEqQSIIsEmGVBAQjivEQ'. + 'PAUJngpWsAWlBw8egpQepKwplN4ULEG9CjkEyUFKlSJrWTG0IU51pCsdYW2ncUPjdtp9Z+f3vuNhu8nKbmhaf5cZeGc+PO8zf1Lc'. + 'm0KhkACICCKCMeaBjiLC0tLSnjNvPmuOHRpH0TZTU1M8zBi9wakzn7OFTs5sw8YYACYmJrre7HkeuVyu69qPF77hlT1XmZ0eQ03O'. + 'wOLJTvhBx1rLz18VmJ0eY+jVd2FxDkKXnvYLHgb97OgLzE4ON9Hzc1B1QaQzsed5O0Lta3Ec89OnR5h5McfQ+Mw2qgQUnfBOPbZ3'. + 'bK3l+xOvMT0+3ERLp5FNF6UEjcL32+DdVmGt5WLhDYYPZrbRqreFumXwql0S3w9tnDvLWD5PZigPpdOwuYpSCo3C8wU3UHxQdHbf'. + 'cZIkNM6dxcnlUM4k1eUFMlUPpUADbpkttFarHe6oYqeOr6yt4RzMQHYUcUsQVtGicHDwKprViuLDkkOtVnsHCHZVRVy/zcj1i5Af'. + 'h8AjdIts+hUcGcYPK3iBtKM3gD/uAzf/AdY2mmmVgy6X8YNNKmGIvyloPcB8SUin07RQ4EZHFdsdG0wkJEnEaHAJxvKEpSLeaokV'. + 'r4zWmhUZYLlY4b1D03y5eIEWCtS7vsciAgiIxkQRabWOrlQor66y4pUphoJb1jiO4uO5o0S3q6RSqVbiOmC7VCEgAhLSaDQ48dH7'. + 'vD46REY0iysegSjKQciRt99ib7qXwX0O+pG4teM6YKHLB9JMq4mTmF9/+AKA4wvLZByH7OgYL7+UY2qvw/7Bfg5kHiXjJFyv3CGO'. + 'Y1rof+BW4t/XLiPG0DCGr79d4XzRxRnIMn98huXSTYyJ6et1UNYQhRvcinpJq86H3wGPPPM0iBDd+QffD1g4eZjLvuG7S1Wef26E'. + 'J7L7eSx7gAHVg7V3MSbi6m/r93baBd6qQjerAJg/9Ql/XrvG0ON1+vv7GH3qSfY5fahUnSTpwZgIEQesaVXRPbHRG/xyJSAxMYlp'. + 'EOm71HUINiY7mGb95l/8jZCyQmJjMDGJjUmsdCROtZ0n/P/Z8v4Fs2MTUUf7vYoAAAAASUVORK5CYII=' ; + + //========================================================== + // endconstrain.png + //========================================================== + $this->iBuiltinIcon[2][0]= 666 ; + $this->iBuiltinIcon[2][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlz'. + 'AAALDwAACw8BkvkDpQAAAAd0SU1FB9ALEREILkh0+eQAAAIXSURBVHictZU9aFNRFMd/N81HX77aptJUWmp1LHRpIcWhg5sIDlUQ'. + 'LAXB4t7RRUpwEhy7iQ46CCIoSHcl0CFaoVARU2MFMYktadLXJNok7x2HtCExvuYFmnO4w/3gx+Gc/z1HKRTdMEdXqHbB/sgc/sic'. + 'nDoYAI8XwDa8o1RMLT+2hAsigtTvbIGVqhX46szUifBGswUeCPgAGB7QeLk0X4Ork+HOxo1VgSqGASjMqkn8W4r4vVtEgI/RRQEL'. + 'vaoGD85cl5V3nySR/S1mxWxab7f35PnntNyMJeRr9kCMqiHTy09EoeToLwggx6ymiMOD/VwcD7Oa/MHkcIiQx026WGYto5P/U+ZZ'. + '7gD0QwDuT5z9N3LrVPi0Xs543eQPKkRzaS54eviJIp4tMFQFMllAWN2qcRZHBnixNM8NYD162xq8u7ePSQ+GX2Pjwxc2dB2cLtB8'. + '7GgamCb0anBYBeChMtl8855CarclxU1gvViiUK4w2OMkNDnGeJ8bt9fH90yOnOkCwLFTwhzykhvtYzOWoBBbY//R3dbaNTYhf2RO'. + 'QpeuUMzv188MlwuHy0H13HnE48UzMcL0WAtUHX8OxZHoG1URiFw7rnLLCswuSPD1ulze/iWjT2PSf+dBXRFtVVGIvzqph0pQL7VE'. + 'avXYaXXxPwsnt0imdttCocMmZBdK7YU9D8wuNOW0nXc6QWzPsSa5naZ1beb9BbGB6dxGtMnXAAAAAElFTkSuQmCC' ; + + //========================================================== + // mail.png + //========================================================== + $this->iBuiltinIcon[3][0]= 1122 ; + $this->iBuiltinIcon[3][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlz'. + 'AAALEAAACxABrSO9dQAAAAd0SU1FB9AJHAMfFvL9OU8AAAPfSURBVHictZRdaBRXFMd/987H7tbNx8aYtGCrEexDsOBDaKHFxirb'. + 'h0qhsiY0ykppKq1osI99C4H2WSiFFMHWUhXBrjRi0uCmtSEUGgP1QWqhWjGkoW7M1kTX3WRn5p4+TJJNGolQ6IXDnDtz+N0z/3PP'. + 'UWBIpdpYa23b9g09PZ2kUrOrvmUyGVKp1Ao/mUyi56YnVgWfO/P1CihAd/dJMpmaNROIRq8BkM1m0bH6TasC3j6QXgFdXI+DR6PR'. + 'JX/Pno8B+KLnMKqlpUU8z8MYs2RBEDzWf9J+0RcRbMdxGBsbw/fmCXwPMUEYID4iAVp8wIRmDIHMo4yHSIBSASKC+CWE0C/PF9jU'. + '3B6Cp+4M07C5FUtKGNvGwQJctPgIsgD2wRhEIqAMGB+UQYkHJgYYZD7P1HwVlmWhHcfhyk83KeRGUW4t6CgoG5SNUS4KBWgQDUov'. + '7AGlwYASBVqH0Bk49dXpCviVV3dw/tI1Bvr7kMIIlh0NYUpjlF0BAYvcxSXmEVLKceHSCJm+PnbueBHbtkNwTXUNBzo6aGpq4sSZ'. + 'GwT5H7BsF6Wdf1GWHQAoM0upeI9PT1yioS7B7tdaSdSuw7KsUGMAy7HYsmUztTW1nMwM0txssX1rlHjjS5jy/Uq2YkK/eJuLl6/z'. + 'x+1xkslW6mrixGIODx8EFSlEBC0+tmXT0NhA2763iEUjnLv4C8XpUbSbAB1mKkGJ3J83Od77HW5EszvZSqK2iljMIeJaRGNuJePF'. + '6mspY7BJ1DXwQnCd2fxGRq5OUCz8xt72dyhMZcn++Cu3xu9SKhdp2b4ZHWnAtTSxmIWlhcIjlksR3lNBYzlxZsb7+f7ne+xtSzOd'. + 'u83szH1OnThOPp/n+a0beeP1l4mvq+PU2Qyd+5PY1RuwlAqLYFaBfbTbyPSdfgaH77A//QF4f1O/vpr6RJyq+C5Kc/M8FbFxXItY'. + 'xOHDrvfo/fxLDnbsJBp5BowBReVWYAzabeTh5ABDw7cWoNNL3YYYNtSv57lnn6Z+Qx01VeuIuBa2DV1HD3H63BAPZu4u1WGpeLHq'. + 'Rh7+NcjA0O+0p4+CNwXigwnbWlQQdpuEpli+n+PIkcOc//YKuckJJFh2K2anrjFw+QZt6S6kPImIF/b+cqAJD1LihWAxC61twBTo'. + 'fPcQF/oGsVW5ovHQlavs2/8+uYnRVSOUgHAmmAClBIOBwKC0gPjhIRgEIX2wg7NnwpZW3d3d4vs+vu8TBMGK51rvPM9b8hdteZxd'. + 'LBbVR8feJDs0Rlv6GFKeXJ21rNRXESxMPR+CBUl0nN7PjtO+dye7Up/8v1I88bf/ixT/AO1/hZsqW+C6AAAAAElFTkSuQmCC' ; + + //========================================================== + // startconstrain.png + //========================================================== + $this->iBuiltinIcon[4][0]= 725 ; + $this->iBuiltinIcon[4][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlz'. + 'AAALDgAACw4BQL7hQQAAAAd0SU1FB9ALEREICJp5fBkAAAJSSURBVHic3dS9a1NRGMfx77kxtS+xqS9FG6p1ER3qVJpBQUUc3CRU'. + 'BwURVLB1EAuKIP0THJQiiNRJBK3iJl18AyeltRZa0bbaJMbUNmlNSm5e7s25j0NqpSSmyag/OMM9POdzDuflwn8djz8gClVRrVEV'. + 'ur4Bl1FTNSzLrSS6vbml0jUUwSXj8Qfk3PkLtLW2AeBIybmrgz3+gFzpucjlE4f4btuFTuWuCF5XDr3a3UPf6cM8GQvxzbsRAJdh'. + 'ScfxSywml5j7mVypN0eGEJ0tebIre+zxB6Tv7jPReS2hREpOvpmUXU+H5eC913JnNCSRVE60pUVbWoZjprR39Yq70bdqj4pW7PEH'. + '5FpvL9e79jOTTHM7ssDL6CJZ08LbvAGnrpZg2mI2Z/MlZfN8IkxuSwu4V9+WIrj7zFlOHfXzKrLIi2SGh5ECKjnNVNxkQEc55vOw'. + 'rb6O8JLFdHyJ+ayFElUeHvjwkfteL/V7fKTSkFvIQE4DoLI2Mz/muTkTApcBKIwaN8pwIUrKw+ajWwDknAO0d/r4zFaMuRS63sWm'. + 'RoOdm+vRIriUYjKexrQV+t1o0YEVwfZSVJmD/dIABJuO0LG3lRFx0GOfiAELE9OgCrfU0XnIp5FwGLEy5WEAOxlR5uN+ARhP7GN3'. + '5w7Gv4bQI2+xpt4jjv2nWBmIlcExE2vDAHYioszBZXw6CPE4ADoWVHmd/tuwlZR9eXYyoszBfpiNQqaAOU5+TXRN+DeeenADPT9b'. + 'EVgKVsutKPl0TGWGhwofoquaoKK4apsq/tH/e/kFwBMXLgAEKK4AAAAASUVORK5CYII=' ; + + //========================================================== + // calc.png + //========================================================== + $this->iBuiltinIcon[5][0]= 589 ; + $this->iBuiltinIcon[5][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAA4AIwBbgMF12wAAAAlwSFlz'. + 'AAALEQAACxEBf2RfkQAAAAd0SU1FB9AHBxQeFsqn0wQAAAHKSURBVHicnZWff+RAGIef3U/gcOEgUAgUCgcLhYXCwsHBQeGgUDgs'. + 'FgMHB4VA/4Bg4XChWFgIFIqBwkJhsRAYeOGF+TQHmWSTTbKd9pU37/x45jvfTDITXEynAbdWKVQB0NazcVm0alcL4rJaRVzm+w/e'. + '3iwAkzbYRcnnYgI04GCvsxxSPabYaEdt2Ra6D0atcvvvDmyrMWBX1zPq2ircP/Tk98DiJtjV/fim6ziOCL6dDHZNhxQ3arIMsox4'. + 'vejleL2Ay9+jaw6A+4OSICG2cacGKhsGxg+CxeqAQS0Y7BYJvowq7iGMOhXHEfzpvpQkA9bLKgOgWKt+4Lo1mM9hs9m17QNsJ70P'. + 'Fjc/O52joogoX8MZKiBiAFxd9Z1vcj9wfSpUlDRNMcYQxzFpmnJ0FPH8nDe1MQaWSz9woQpWSZKEojDkeaWoKAyr1tlu+s48wfVx'. + 'u7n5i7jthmGIiEGcT+36PP+gFeJrxWLhb0UA/lb4ggGs1T0rZs0zwM/ZjNfilcIY5tutPxgOW3F6dUX464LrKILLiw+A7WErrl+2'. + 'rABG1EL/BilZP8DjU2uR4U+2E49P1Z8QJmNXUzl24A9GBT0IruCfi86d9x+D12RGzt+pNAAAAABJRU5ErkJggg==' ; + + //========================================================== + // mag.png + //========================================================== + $this->iBuiltinIcon[6][0]= 1415 ; + $this->iBuiltinIcon[6][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlz'. + 'AAALDAAACwwBP0AiyAAAAAd0SU1FB9ALDxEWDY6Ul+UAAAUESURBVHicdZVrbFRFGIafsyyF0nalV1R6WiggaAptlzsr1OgEogmC'. + '0IgoBAsBgkIrBAPEhBj/AP6xRTCUFEwRI4jcgsitXMrFCJptJWvBNpXYbbXtbtttt6e7e86ec/yxadlCfZPJZDIz73zzzjfvR2VL'. + 'F7U+hf0HD2JduIzTFy6SlJRkPtkcDgdCCE65OxFC8NPV6wghyM7OptankJ2dzbSC5QghEEIgCSHog9PpNAF27dlN6miZuPgElB4/'. + 'nmY3O7ZtByA1NVUCkGWZweD1eklJScESTbqxuIjrd+/x6uIl5M19hSy7nfGOeUxf+g7VjU1sKi7C4/GYsiyz7tAJAD4/cRaA1tZW'. + 'AHIPnECUVGD1+/3U19ebG4uLeHf1akamjsIwoVnVCOvQEdLoVILYYmMo3PIxSBJflpSaDX5FAmju1QAYv/8k/s8+wLVxOU0jR2LZ'. + '8sMFAApWrCApbRRDrRZirBYSLBKaoRPQw3SFernf2sav7T0Ubt4KwL4FMwF4Vu8FoHBCKgCzDhwHwLIhZ7y5a89u4m2JhA0wTdDC'. + 'OrphEjJMNElCHxKDEjaobmvlfo/Krj27CQQCJsCGJW8C0KXqAMxMiosQA8hZWcTFx9OsaniDKh1qmG7VoFsL0x0K06kbeAMhWpRe'. + '/KpG+gwHAKUnz7Dz3BUMw6DK18nuw99wt0Nh6VdHI8RJicmETQgFg7SFwjSrGv+oKp6ghldV6dZ0ugJBlF6FmCESQ2w2AIqXLsan'. + 'BrFYLJTnTCBrdBqveeopWZiPFaBHUegJhegMqGgxEkHDwB/UaQ9rdIV06v0+TD2EEQjQFtAY0dsNgNvt5sialQAIIXh7wQKuVf6J'. + 'gTsSccPDWlQstClBGjr9eHpVWvUQncEwdYEedF8noQ4vmYmpZMTH0nTvDn25vLbrNmu7bvfnsYEbAMnhcPDgwQPzUo2LJusw/mhp'. + 'QwlHNO0KBAnoIfxtrcQMT2De1Mm891wyUzNlUlJSpIyMDBobGzlzr5rFM/Koq6vrP8ASGxsLwPmKcvIShjPGZiPOakE3VFB8hHwd'. + 'vJAxhrk5L7Ly+RQuH/sWgPdXrwFg/6HDFBUsIj09nehfbAWwPWOT9n5RYhqGwarNWxkRM5TRCfF4U1PQsDDJFk9uYhwXvzvKjm3b'. + 'KSsro3DJInNW5RXp7u2bAKSlpeH1esnPz6eqqgqLpmmcr3Fht9ulfaV7mZk1Bs+lM6T1djM9fhg5egDPpTNMy5TZsW07kydPYdWM'. + 'aXx96ixOp9O8cfUa80srmDpjOgAulytiQqZpMnvObLbt/JTtHxXj9/tRVdU0DGOAufRpevPDTeac0hJyc3NxOOawfv161lVWS6eX'. + 'z+9/UOCxu1VWVvaTRGv16NFfjB2bNeAQp9NpTpmSM4DcbrdL0WsGDKLRR+52uwe1yP8jb2lpYfikyY9t80n03UCWZeaXVjw1f+zs'. + 'Oen+/d+pqanhzp2fKSsrw+l0mi6XiyPl5ZGITdN8fAVJwjRNJEmi1qfw1kw7siyTnJxMe3s71dXV3GpoZO64DG41NPJylvxU5D/e'. + 'qJKsfWQD9IkaZ2RmUvr9aV4aGYcQgjfO3aWoYBF5eXm4ewIsu/CbdPz1aWb0/p1bNoOrQxlUiuiaFo3c3FyEEOx9+C9CCD6paaTW'. + 'p/TXyYkTJ0Xe59jf7QOyAKDWp/QXxcFQ61P4pT3ShBBcvnUHIQTjxmX19/8BCeVg+/GPpskAAAAASUVORK5CYII=' ; + + //========================================================== + // lock.png + //========================================================== + $this->iBuiltinIcon[7][0]= 963 ; + $this->iBuiltinIcon[7][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlz'. + 'AAALCwAACwsBbQSEtwAAAAd0SU1FB9AKAw0XDmwMOwIAAANASURBVHic7ZXfS1t3GMY/3+PprI7aisvo2YU6h6ATA8JW4rrlsF4U'. + 'qiAsF9mhl0N2cYTRy9G/wptAYWPD9iJtRy5asDe7cYFmyjaXOLaMImOrmkRrjL9yTmIS3120JybWQgfb3R74wuc8Lzw858vLOUpE'. + 'OK6pqSm2trbY39+nu7tbPHYch7m5OcLhMIA67kWj0aMQEWk6tm17rNm2LSIie3t7ksvlJJ1OSyqVkls3Z8SyLMnlcqTTaVKpFLdu'. + 'zmBZVj1HeY2VUti2TSQSQSml2bZdi0QirK2tMT09zerqKtlslqGhISYnJ4nHv2N+foFsNquOe9FotLlxOBwmk8lgWRbhcFgymYxY'. + 'liUi0mqaJoAuIi2macrdO7fFsizx3to0Te7euV1vrXtXEgqFmJmZYWVlhXK5LB4/U9kwDL784kYV0A3DYHd3m4sXRymXywKoRi8U'. + 'Ch01DgQCJBIJLMsiEAhIIpHw2uLz+eqtYrEYIqKZpimxWEyCwaCMjY01zYPBIJpXqVQqsby8TLVabWKA/v5+RkZGMAyDrq4ulFKH'. + 'HsfjcWZnZ+ns7KTRqwcnk0mKxSKFQqGJlVKtruuSTCYB6O3trW9UI/v9/iZPB/j8s2HOnX0FgHfeXpeffnzK+fWf+fijvhLs0PtG'. + 'D/n1OJ9+MsrlSwb3733DwMCAt1EyPj6uACYmJp56168NU6nUqFSE9nZdPE7+WqC/r4NKTagcCJVqDaUUB5VDAA4Pa9x7sMLlSwan'. + 'WjRmv13D7/erpaWlo604qOp88OF7LC48rPNosMq5Th+Dgxd4/XyA1rbzADi7j8jnf2P++wdcvSr8MJ/i8eomAKlUqn41OsDAQDeD'. + 'g++yuPCwzm/2vU8+n2a7sMFfj79mp7BBuVzioFSiXHJx3SKuW2Rzy0Up9dxnQVvODALQerqNRn4ZKe0Mvtc6TpzpmqbxalcY9Ato'. + '2v06t515C73YQftZB9GLnDrt4LoujuPgOA4Ui+C6yOpXJwZrJ7r/gv4P/u+D9W7fLxTz+1ScQxrZ3atRLaVxdjbY2d184R6/sLHe'. + 'opHP7/Do90Ua+WWUyezzZHObP/7cfX54/dowE1d66s8TV3oE+Mfn+L/zb4XmHPjRG9YjAAAAAElFTkSuQmCC' ; + + //========================================================== + // stop.png + //========================================================== + $this->iBuiltinIcon[8][0]= 889 ; + $this->iBuiltinIcon[8][1]= + 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlz'. + 'AAALDwAACw8BkvkDpQAAAAd0SU1FB9AJDwEvNyD6M/0AAAL2SURBVHic1ZTLaxVnGIefb2bO5OScHJN4oWrFNqcUJYoUEgU3/Qf6'. + 'F7gwCkIrvdBLUtqqiLhSg9bgBduFSHZdiG5ctkJ3xRDbUFwUmghNzBDanPGMkzOX79LFJGPMOSd204U/+Bbzvd/78F4H/ieJdoad'. + 'pZKxRFszAI/DcP0HazXY22v+HB01kee1PA/v3zfnjx4xgGnHcNZe7OvuNj+cOEF1ZATv5nUA4jhBSgmADCVWo8Ge2Of9wb18P/G7'. + 'oUXmYi30zqlTVEdGWLh1g2D6MYlKkXGE0Vl8aa2GEB149+4xXSzyoOIw/mimiZV/DPb25pFOj13A9gOMEChhUEqhVYqWKUk9QAUp'. + 'sT/P4s8PmKlUmNhQaIJbkDVqBbpw6wZ2zUc4Nm+ePku5p4eOrgpueQOFUoVCVxcD4+N07dpF9+5tVJeWGPBjhvr7WF1zC8ASgtcP'. + 'H8a7eZ1odh4sh50nzwCw9ZNh3M4Stutiu0X2nB/LyjZ6lcIbVTpdQU/jWVPzLADM8+ZGBRdtC7wrF/O7bR99iu26VL86iU4SAH4b'. + 'Po5d6AQhstMSvGyI4wS5FJBKSRwnzF8byx/u+PjzzMF1mfryQ1K/jnCahqp1xEopjFLoNEFJSRJHzF799gWHqa+/QKcSUXBI609f'. + 'Al5W4teQSiHDOipNUKnMI13RvnOXAIEKQixvGWya98SC560MFwPiqEG86JM8q79Q06lvhnOndy5/B6GPCUOMUu3BQgg8z0M3GmBZ'. + 'iGJn3v2VmsqnfzNx7FDueODuj8ROCFpjtG5TCmOYv32bJ09msP0ISydMfnAUgF8/O45RAA6WTPjlvXcB+Gn7FuRf/zAnNX6x3ARe'. + 'PSdmqL+P/YHkwMGDOGWDZTlQcNBRhPEComgB/YeHfq2InF1kLlXUOkpMbio1bd7aATRD/X0M1lPeSlM2vt2X1XBZjZnpLG2tmZO6'. + 'LbQVOIcP+HG2UauH3xgwBqOz9Cc3l1tC24Fz+MvUDroeGNb5if9H/1dM/wLPCYMw9fryKgAAAABJRU5ErkJggg==' ; + + //========================================================== + // error.png + //========================================================== + $this->iBuiltinIcon[9][0]= 541 ; + $this->iBuiltinIcon[9][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaVBMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/'. + 'f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpYiYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjea'. + 'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTCAkUMSj9wWSOAAABLUlEQVR4'. + '2s2U3ZKCMAxGjfzJanFAXFkUle/9H9JUKA1gKTN7Yy6YMjl+kNPK5rlZVSuxf1ZRnlZxFYAm93NnIKvR+MEHUgqBXx93wZGIUrSe'. + 'h+ctEgbpiMo3iQ4kioHCGxir/ZYUbr7AgPXs9bX0BCYM8vN/cPe8oQYzom3tVsSBMVHEoOJ5dm5F1RsIe9CtqGgRacCAkUvRtevT'. + 'e2pd6vOWF+gCuc/brcuhyARakBU9FgK5bUBWdHEH8tHpDsZnRTZQGzdLVvQ3CzyYZiTAmSIODEwzFCAdJopuvbpeZDisJ4pKEcjD'. + 'ijWPJhU1MjCo9dkYfiUVjQNTDKY6CVbR6A0niUSZjRwFanR0l9i/TyvGnFdqwStq5axMfDbyBksld/FUumvxS/Bd9VyJvQDWiiMx'. + 'iOsCHgAAAABJRU5ErkJggg==' ; + + //========================================================== + // openfolder.png + //========================================================== + $this->iBuiltinIcon[10][0]= 2040 ; + $this->iBuiltinIcon[10][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEANAAtwClFht71AAAAAlwSFlz'. + 'AAALEAAACxABrSO9dQAAAAd0SU1FB9AKDQ4RIXMeaLcAAAd1SURBVHicxZd7jBXVHcc/58zcvTNzH8vusqw8FsTsKiCUUh5WBZXG'. + 'GkOptmqwNWsWLKXFGlEpzZI0AWNKSy0WhDS22gJKtWlTsSRqzYIuLGB2WVvDIwQMZQMsy2OFfdzde+/OnHP6x907vJaFpjb9JZM5'. + 'c85Mfp/f9/s7Jxn4P4e41gtSyp78WGvtfdEAcqDFYUOH9HS0NhGk9tPb/ilSyp789UUB2AMuqhQy3Uzm7HGkE6W3dTNZMRI3EcWO'. + 'jf9ClLmWBT3dzW8jUsevWHCG3UpWl+IkHSxnbDh/Mcz12NevBcuWXTmf6TjnXvJ88gDmVB3pw3+nt3UzHa1NqMzBS2zqPLGFjtMN'. + 'ZNr3XdW+qyqwZcFk76HX/tHWfuQvyO4W7qhaHwL8efkMRlRUpPv7rqD0RrJ+FgAjLy1a20OIxZJEEuNCRfIApj+om4bGM3u2/sYU'. + '9J41d8973f3Dhg1pISTV1dXXBRNJxPGFCzhou+DCQrScZOkktNaeDZjamgeZ9MgiYmVDccvHhjAzJw0NTh8/alyZMaVJicp0iTHj'. + 'JpgNv38tjWUhhGROdbUL9W5/MH5XCkjlcibi+KIop5LVHLKEu8A/f4r286doa9pGrGwYAAsfqbbH3b8MgO/Nqgy6WvdbbXHMkEFJ'. + '4xUOMVEvaTZu3BgmvF4Yk4hz9rO/Ulr5cE9owae/rcGxohSOuiWkC2IjcIqKyPZm+OmCH7GhoZEF077EEzVVweAbJ+riEeO0Ey8y'. + 'UubqOHn0AOgMwvf59txnBrSp9dgxKmf/+kIP1NY8SFk0jh5ajmNHAWg5b2E5EexojGHjbiVRMoRMNs0LC+Yz46vTuH3enN7BI8fr'. + 'qFdo0BoVZNC9aVSQ4fNjBzEmQJiARxb+/AqYPMAVB5FsPU5v37g9OxgLhe14ZM5/ju052E6MNZvf5pmHHuLmmWOkEysxUtpGAtme'. + 'dtHTflJkezqQto3jFRnLssyf1jydxiiM7zNnye/c3ZsqLu2BN5fcMfzrv/hby1tPzmRUoihcTJ87CwQI2yLtDcIqsIjYUf51qBlf'. + 'OnScOSrdQUOMURkiXsLUzJnvbGhoBGDHH5cGyZLhOpYoNl5hqYnYEXOu5fDl9eYAHntx98n8hFHZcPHUuTSxSASAeK/CGIOxJJ0f'. + 'bOGNPU280dgkq6Y2yu8vfjCIlwwzr+/ZQ/PHO0gOLuO5qsftDQ2NbN+4OCgqG6WTxWVaq6zpF+DiSHWnicdylp3r6aZTWthIOrNp'. + 'ktHcvBu0sHX1Sm6ozB3B42d90zZA9bQp7PvgPSzXZfnqX/HS4DKKK2+x69Y/HURs26iBAN5ccsfw7774UcumF37C6f07KSt2OHji'. + 'DEUJD0tISjyPrrSPlAKvN0JP/U4O1NfjuhG2rvklN1SOpfXwftpbTqAyKRrff5fb7rs9V1R7m4wlz2ihA3HpmXflUWyOH2umpLiY'. + 'ui3v8M+6bWzfsRNbSgqkxaCkiy0simMuEWEhpcRzIhQWOIAh6tiAwS4owInFiTou5dOnMnl2NR++ujBwXEc9terD6M43nrj6LgAB'. + 'QnDPA9/irtkP8JRS7Hr/3T6YekDQ1pEiEXOwpUVJzCVlZZFS4mZtkpEo9ChAkDp/jtLMBACy6S4RiQghLyv5cgBRPnKUOX6smUGF'. + 'hSil0MYw9d77mPy1e5mnFE3batm3czvb6nYgEJztSFGU9LCRlMRdUjIH0+lnEMIwPNXD3NumoVJnrMCJaiciMUZfvQnz4QcBSvV1'. + 'vjE5GK358t0zmXDnDB79saLpo20c+aSRD+t25JTp7GZQwsEWFiVxl6hlUf/WO9z32CxmL1rOe6u/I2KuwGhzLQCB7/sYY9Bah3el'. + 'FKbvrrVm4vS7GH/7ncx+chEHGz7myCeNbPtoO0JI2jq78WIRLGkzsqs7V5SfFV5EovXACoiqqsfNpk2vo5VCWtYFBfoU0VoTBAFa'. + 'a7TRaK2p+MoURk+cxMzq+Rzbv49DDbuo27UTW9h0dedssPxuK+kIfN8XxhgDYPVXf2Fh4XKtFIl4AiklAlBKAYRKKK36wHIweTCt'. + 'NfHiEkaOn8j0+7/BmDFjaT30GbHywSxcuZkpFfFg+m1jjZ/NmnVvNfRvwd69e8WBA/uNFAIh4JVXXmHsmDHE4vEQQgjQ2lxQIm9N'. + 'nz35q3BEOZOHzaG2thaA4mRU+L29It+IV21CpbRQfeMFC35gRB/M2rVrubnyZmLxWJhECBEmz/eHyo/7lMlH3LFFujsthNFCCGOu'. + '+WNyeUgpjSVzMKtWraKyshLPdcPEeYWCIEBdpIxSivr6eta8vI7d6+cGnhdV06pe1QP+F/QXWmuRL+jZZ58LlVmxYgUVFRV4rhtu'. + '4TzMxXAA6XRaRAtsYUkx8I/JtSJQOlSwpmZpCLN8+fPcdNNoHMfB9/0QJgRoP295TlR7UVv8xxZcHMuWIZ9/Hn35vG3JEGZpzVJG'. + 'jx5N1IlitKahsZE1L69j69qHgx+urFX/lQL9JYdLlfnZihUhzOLFi8N3Ml1dthOxVH/f/8/CtqSJ2JaJ2JZ59J7RPsC/AViJsQS/'. + 'dBntAAAAAElFTkSuQmCC' ; + + //========================================================== + // folder.png + //========================================================== + $this->iBuiltinIcon[11][0]= 1824 ; + $this->iBuiltinIcon[11][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlz'. + 'AAALEAAACxABrSO9dQAAAAd0SU1FB9ECAQgFFyd9cRUAAAadSURBVHiczdhvbBP3Hcfx9/2xfefEOA5JoCNNnIT8AdtZmYBETJsI'. + '6+jQOlQihT1AYgytqzZpD1atfyYqlT1h0lRpT7aRJ4NQpRvZGELVuo5Ua9jEJDIETQsNQyPBsUJMWGPnj//e+e72wNg4xElMR6ed'. + 'ZNln3933dZ/f93f6yfB/sgmrHdDV1WXlPg8NDZUDScD8LFFFEZZlWYZhWMFg0Orq6sq/gDJAfFy1iiZy9OjrVnj4JzQ1rMWqfxm/'. + '309jYyNtbW0kEgnu3bvH4cOH88c/jqSKQl4/XGkd+eVtAN46up1LH92ktqYS++ZX8Pv9NDQ0sGnTJlKpFOFwmO7u7vy5IyMjeVRd'. + 'XV1+WEOh0IrY4pDnq6wXX/sTiCJaMkFZdRNqxefoe7VtCSqXVDqdZnZ2ltraWkzTpKqqijt3JpFlG7dvj7NzZ1f++qFQyA3EClHL'. + 'Ql743nFkhxPDtJAd5eTaYSVUfX09lZWVlJWVIUnSg7sVQMBCUcu4ceMGe/bsIRQK1QAzOcyykIM9P0KyudAyCWyqG8nhwqa4SkLt'. + '3r0bVVVxu924XC40TUOWZUQxe97CwgIdHR2LMHIxSCaVInVvFElxE0vMY1Pd2NUKJMWNTXHlUfF//4vETJCelwbpFm3MjP2dt37x'. + 'AlN+PzU1NViWRSwW4+7du3g8HjweD4qi5EFAJzAExIpCANbooxhplfB0FJvTg6xWIqsVRVF6MopkU3FXPcnkJxGU0VEAdF2noqKC'. + 'W3/8DpnqLjzep2lubsblcjE8PExHR8fboVDID9xYFpLBDpJF0jDQIncQpWlkm31FlFLtp9PfyuW/vYQj1kPSuRW/38+lj27S2Q7v'. + '/aWXUBVUffVNtm3blivVCEwsC5Eyc5iiApEpDEAXMqQdldhSiWVQHjJagud+8Fuexck/zv+K82dfoSbSCsDe75/km+4GVPd6+l5t'. + '4zJHcqVUYN2yEEtZQDCSJCueRAYsPY49HsFIZVG6p25JUumFafT4DKJN4amtT7Nz38sk5+5A70HMtEYyMkFiZhxzjQ/poXrLQrRU'. + 'DFGEeFpAlkQkm4pRiCpIKodKzk0T/2QMh+piPjxKZPwiSkUtu/b9mNnJEWS7E8nhAmvpM60oJDkXJxqNozxRRUxPIesispBBlsXV'. + 'UaKEFo8gzoaJhz8s2lOmrpUG+WBhJ9/60g+Z+fDXTAXfxllRjl1VkO0OFATsYhYliiK21ZKKhhHnFveUqSdKgwAEOp7F2v51vvw8'. + 'XH7/N1wd/BlTweuUV65BdtgfoLTSkipsdD3tRi0VYpommUwGwzDwdT5HYEc3giAwcvH3jLz3BlPB67jWeZBEKYsSBWwpHZtNKo4q'. + 'aHTDsJeeiGEYWJaFZVmYpommaRiGQdPnv0bb1m8gSRL/vPIOV979aR4lmAJ2p4qCgCxksNuKJ6VNpx4NYhgGpmkuQhmGQTqdxjAM'. + 'qr2d7HtxEEEQuH1tkKvvvkF44tqDnrIcKJKAPf1g+LAUElq8dIiu60sApmnm93Pfzc7OYhgGrie+wFe++ztcLhcT1wf54PzPCU9c'. + 'w7XWjWS3IdsdOAUBWZAxrRJnTQ6SG5bce2FCpmkughmGQSqVYm5uDtnj44sH38TtdhP6+Dwf//V4ttHXrkGURZJaic8RgHQ6jWma'. + 'SJKUL5RLKNfIOczDKF3XSSaTRCIRhLJWntp3nGfWrSMxc5OLf3iNP4+68T9Ub9nF76lTpxgfHycajZJKpdA0LZ9GbjYV7hcDWZaF'. + 'pmnMz88Ti8UYunSLmu1HFi2aVkxkaGjINTY2ttDb24vX6+XQoUNs3ryZ8vJyIDu1BUFYkkxhgxeiWlpaOHPmDE1NTdTX1xe98eWG'. + 'JnF/9dQZCoXUYDA4AOD1ejlw4ACtra2Ul5fniwmCkEcUJiUIAoFAgL6+Pnw+H21tbfT39z8SxCS7hHsfWH9/8dL4MKqnp4eWlhac'. + 'TmcekEvMNE2am5s5ceIEgUCA9vZ2Tp48ic/nY3j4UsmQHCYOjJHtpeBKqL1799Lc3IzT6UTXdRobGxkYGKC9vZ3W1tZ8Ko86NJ8a'. + 'tXHjRo4dO8bp06fZsmULGzZsoL+/n0AggNfr5ezZs/8VpGTU5OSkc//+/acBfD4f1dXV7Nq1i4aGBs6dO4fP5+Pq1SuPBbIiyjTN'. + 'RUnV1dUNXLhwAa/Xy44dO4jFYgBEo9FFF1r134BPuYlk16LrAYXsAlmtq6sbKDwoFAp9m+ykuP5ZQVZF3f8tCdwCov8LyHIoAANI'. + 'AXf/A1TI0XCDh7OWAAAAAElFTkSuQmCC' ; + + //========================================================== + // file_important.png + //========================================================== + $this->iBuiltinIcon[12][0]= 1785 ; + $this->iBuiltinIcon[12][1]= + 'iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlz'. + 'AAALDwAACw8BkvkDpQAAAAd0SU1FB9ECDAcjDeD3lKsAAAZ2SURBVHicrZhPaFzHHcc/897s7lutJCsr2VHsOHWMk0MPbsBUrcnF'. + 'OFRdSo6FNhdB6SGHlpDmYtJCDyoxyKe6EBxKQkt7KKL0T6ABo0NbciqigtC6PhWKI2NFqqxdSd7V2/dmftPDvPd212t55dCBYfbN'. + 'zpvfZ77z+/1mdhUjytWrV93Hf/24eD5z9gwiMlDjOKbb7dLtdhER2u02u7u73Lp1CxEZBw4AeZwdNQqkMd9wbziFGINJUt6rRbz5'. + '1ptUq1XK5TJBEAAUMHt7e+zu7gKwvLzMysoKwAng/uNg9CgQgFKlgg1DUJ67Vqtx6tQpZmdniaIIpRTOOZRSdDoddnZ2aLfbLC8v'. + 's7S0xJUrV7ZGwQSj1PhhfRodVdDlMrpc5vup5Z2fvMPdu3fZ29vDWjvwztjYGPV6nVqtRqVS4dKlSywtLQFsAdOH2XwsCEApg3jl'. + 'w98Rak2gvYjNZpNms0mSJDjnHgkDMDc3dySYQ0Ea8w139YUX0OUKulzyg7UmCEO+l1huvHuDra0t9vf3h1TJYSqVypFhHquIrlQI'. + 'S5qv/uIDAC7/4bcEQYAKvK+0Wq1DVQGIoog7d+4cCeaRII35hrt+8SsEOkRlUaEyR0UpFIrXHxyMVKVUKnHv3r0jwRwaNelBjBjL'. + 'Sz/7KYuLiwAsLi7y4z/9kY9e+TpkCuSqjI+Po7XuAWeKXLt2DWNMUZMkwRjDhQsXWFtbK6JpCCT3jfQgxomPtPX19YHWicM5x3c2'. + '73Pj3Ru8/aO3mZqaolKpoHVvyuvXr/Ppnf/Q7uzz380NPtu4y/qnG+ztd1hfX2dtbQ3gIvDnRyqSxl1UoPjyz98D4PTp0wPtq39Z'. + '4fdzLxegrVaLVqvF5OQkYRgWqpRKJZ77wvNsbW1RG5tgfKLOTH2G7Z1twqBQrgrMDvhInjfSOCY5iIv+hYWFgRZArEWsZWF941Bf'. + 'SdMUgMnJCWpjVU4cn+HUyePM1Gc4+fRUPkzBI5w1jbukcczLv/5l0XfmzJmBFuCba38r/CRXpT+CrDUoZ0jjB4RYonJAOYRobJKT'. + 'z5zgqfqxAbsFSH6mpHFM2qdGXh4VnoViD6mSJF2cTQeqDqBaKVHWmonJCWpZjhkC6anR5WsffTgwaHV1FaUUq6urA/2v3f5k4LnV'. + 'arG9tUn3oI2YBCcWHYAxMVYs1qZEZY2SFB2aYZDGfMN9d7uJiWPSeFiNo5Rclc3NTXZbO6RpF7EJVixYA9agwwDnUiqlEPdQ3imi'. + 'Jo27BGHIt/7x9yEjc3Nzh27Na7c/4TdffKl4bja3ae5MUIu0T/HOEIaOpJt4gwoSsVTK4SBIY77hFtY3ABBjBiZ90rKwvsH77/+K'. + 't37wOhO1iPpTk4SBw1mLsz6CnKQ4l3qV+kE+t9XHlNZOk+bUJLVIE1VCcIJWQmJ6qjj30NbcXLkZMt8YPig+Z3n1G5fZ39/j/vY2'. + '9ckqZT2Ochbn0p4qNkU/dDfUADdXbh4HXgRO4zNdEU0XL1784PLly5w9e7Z4SazFOfGrEotDcOKrcoJPmrYIXf/Zop3QNd1skuGt'. + 'cUAb2MgAxvHZTgFUq1Wmp6eZnZ0F8JlTjDduDThBnDeECEoJtbGIp6enqEblzCcEZ1PECU4yVRiOGgd0gc+AB0CZvkv1sWPHOHfu'. + 'HOfPn8da41cpkkltEBEPJhYnBkTQJcdYVKGkgRxCfBsq5xXNgAa2Bn+hjTOgHEKBP8pzRUxykIH4ifLJRTJAl+UMBJzPHQ6bfe/f'. + 'cWIzPxlUpD+zugzIZtVk1d8znBAqRxgoQuVQgSJQ3h9C5QhDRYgjUILCAzlnEdsHYTKfMTEBcP7F54YUGVmc2GLlIn6ve6v0ahSt'. + '8X25TzjJ+rIx1grKpQPWR4LkGVVsMgghvS0qjPdvm5OeceOTWA5Evo2mFzkjQfL7hZPUy5yvvF/uPFQL3+nbDmsLCEmT3sTmCTNr'. + 'rogT6yFsOix3ftw7OwQhkvSU6CuinhCk0+kAkFoBazEEICHaHHiPVmU0gnUp4EAc1mYrF0EBVpwPi34VrBkwPxKk3W5ju/e5/c+d'. + 'bGUHIAIuydTIE5zfc5Wr4lJcahHnHTP3CVGm78DrgY38N+DEibp7dmYKdAQmBh1hjEFjis+9CTWYGK21H6PxPyOI0DobYwzZF/z7'. + '7jadTvJtYG0kCD7lfwl49ijgT1gc0AH+dZSJA/xB+Mz/GSIvFoj/B7H1mAd8CO/zAAAAAElFTkSuQmCC' ; + + $this->iLen = count($this->iBuiltinIcon); + } +} + +//=================================================== +// Global cache for builtin images +//=================================================== +_gPredefIcons = new PredefIcons(); + +//=================================================== +// CLASS IconImage +// Description: Holds properties for an icon image +//=================================================== +class IconImage { + private $iGDImage=null; + private $iWidth,$iHeight; + private $ixalign='left',$iyalign='center'; + private $iScale=1.0; + + function __construct($aIcon,$aScale=1) { + GLOBAL $_gPredefIcons ; + if( is_string($aIcon) ) { + $this->iGDImage = Graph::LoadBkgImage('',$aIcon); + } + elseif( is_integer($aIcon) ) { + // Builtin image + $this->iGDImage = $_gPredefIcons->GetImg($aIcon); + } + else { + JpGraphError::RaiseL(6011); + //('Argument to IconImage must be string or integer'); + } + $this->iScale = $aScale; + $this->iWidth = Image::GetWidth($this->iGDImage); + $this->iHeight = Image::GetHeight($this->iGDImage); + } + + function GetWidth() { + return round($this->iScale*$this->iWidth); + } + + function GetHeight() { + return round($this->iScale*$this->iHeight); + } + + function SetAlign($aX='left',$aY='center') { + $this->ixalign = $aX; + $this->iyalign = $aY; + } + + function Stroke($aImg,$x,$y) { + + if( $this->ixalign == 'right' ) { + $x -= $this->iWidth; + } + elseif( $this->ixalign == 'center' ) { + $x -= round($this->iWidth/2*$this->iScale); + } + + if( $this->iyalign == 'bottom' ) { + $y -= $this->iHeight; + } + elseif( $this->iyalign == 'center' ) { + $y -= round($this->iHeight/2*$this->iScale); + } + + $aImg->Copy($this->iGDImage, + $x,$y,0,0, + round($this->iWidth*$this->iScale),round($this->iHeight*$this->iScale), + $this->iWidth,$this->iHeight); + } +} + + +//=================================================== +// CLASS TextProperty +// Description: Holds properties for a text +//=================================================== +class TextProperty { + public $iShow=true; + public $csimtarget='',$csimwintarget='',$csimalt=''; + private $iFFamily=FF_FONT1,$iFStyle=FS_NORMAL,$iFSize=10; + private $iFontArray=array(); + private $iColor="black"; + private $iText=""; + private $iHAlign="left",$iVAlign="bottom"; + + //--------------- + // CONSTRUCTOR + function __construct($aTxt='') { + $this->iText = $aTxt; + } + + //--------------- + // PUBLIC METHODS + function Set($aTxt) { + $this->iText = $aTxt; + } + + function SetCSIMTarget($aTarget,$aAltText='',$aWinTarget='') { + if( is_string($aTarget) ) + $aTarget = array($aTarget); + $this->csimtarget=$aTarget; + + if( is_string($aWinTarget) ) + $aWinTarget = array($aWinTarget); + $this->csimwintarget=$aWinTarget; + + if( is_string($aAltText) ) + $aAltText = array($aAltText); + $this->csimalt=$aAltText; + + } + + function SetCSIMAlt($aAltText) { + if( is_string($aAltText) ) + $aAltText = array($aAltText); + $this->csimalt=$aAltText; + } + + // Set text color + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function HasTabs() { + if( is_string($this->iText) ) { + return substr_count($this->iText,"\t") > 0; + } + elseif( is_array($this->iText) ) { + return false; + } + } + + // Get number of tabs in string + function GetNbrTabs() { + if( is_string($this->iText) ) { + return substr_count($this->iText,"\t") ; + } + else{ + return 0; + } + } + + // Set alignment + function Align($aHAlign,$aVAlign="bottom") { + $this->iHAlign=$aHAlign; + $this->iVAlign=$aVAlign; + } + + // Synonym + function SetAlign($aHAlign,$aVAlign="bottom") { + $this->iHAlign=$aHAlign; + $this->iVAlign=$aVAlign; + } + + // Specify font + function SetFont($aFFamily,$aFStyle=FS_NORMAL,$aFSize=10) { + $this->iFFamily = $aFFamily; + $this->iFStyle = $aFStyle; + $this->iFSize = $aFSize; + } + + function SetColumnFonts($aFontArray) { + if( !is_array($aFontArray) || count($aFontArray[0]) != 3 ) { + JpGraphError::RaiseL(6033); + // 'Array of fonts must contain arrays with 3 elements, i.e. (Family, Style, Size)' + } + $this->iFontArray = $aFontArray; + } + + + function IsColumns() { + return is_array($this->iText) ; + } + + // Get width of text. If text contains several columns separated by + // tabs then return both the total width as well as an array with a + // width for each column. + function GetWidth($aImg,$aUseTabs=false,$aTabExtraMargin=1.1) { + $extra_margin=4; + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + if( is_string($this->iText) ) { + if( strlen($this->iText) == 0 ) return 0; + $tmp = preg_split('/\t/',$this->iText); + if( count($tmp) <= 1 || !$aUseTabs ) { + $w = $aImg->GetTextWidth($this->iText); + return $w + 2*$extra_margin; + } + else { + $tot=0; + $n = count($tmp); + for($i=0; $i < $n; ++$i) { + $res[$i] = $aImg->GetTextWidth($tmp[$i]); + $tot += $res[$i]*$aTabExtraMargin; + } + return array(round($tot),$res); + } + } + elseif( is_object($this->iText) ) { + // A single icon + return $this->iText->GetWidth()+2*$extra_margin; + } + elseif( is_array($this->iText) ) { + // Must be an array of texts. In this case we return the sum of the + // length + a fixed margin of 4 pixels on each text string + $n = count($this->iText); + $nf = count($this->iFontArray); + for( $i=0, $w=0; $i < $n; ++$i ) { + if( $i < $nf ) { + $aImg->SetFont($this->iFontArray[$i][0],$this->iFontArray[$i][1],$this->iFontArray[$i][2]); + } + else { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + } + $tmp = $this->iText[$i]; + if( is_string($tmp) ) { + $w += $aImg->GetTextWidth($tmp)+$extra_margin; + } + else { + if( is_object($tmp) === false ) { + JpGraphError::RaiseL(6012); + } + $w += $tmp->GetWidth()+$extra_margin; + } + } + return $w; + } + else { + JpGraphError::RaiseL(6012); + } + } + + // for the case where we have multiple columns this function returns the width of each + // column individually. If there is no columns just return the width of the single + // column as an array of one + function GetColWidth($aImg,$aMargin=0) { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + if( is_array($this->iText) ) { + $n = count($this->iText); + $nf = count($this->iFontArray); + for( $i=0, $w=array(); $i < $n; ++$i ) { + $tmp = $this->iText[$i]; + if( is_string($tmp) ) { + if( $i < $nf ) { + $aImg->SetFont($this->iFontArray[$i][0],$this->iFontArray[$i][1],$this->iFontArray[$i][2]); + } + else { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + } + $w[$i] = $aImg->GetTextWidth($tmp)+$aMargin; + } + else { + if( is_object($tmp) === false ) { + JpGraphError::RaiseL(6012); + } + $w[$i] = $tmp->GetWidth()+$aMargin; + } + } + return $w; + } + else { + return array($this->GetWidth($aImg)); + } + } + + // Get total height of text + function GetHeight($aImg) { + $nf = count($this->iFontArray); + $maxheight = -1; + + if( $nf > 0 ) { + // We have to find out the largest font and take that one as the + // height of the row + for($i=0; $i < $nf; ++$i ) { + $aImg->SetFont($this->iFontArray[$i][0],$this->iFontArray[$i][1],$this->iFontArray[$i][2]); + $height = $aImg->GetFontHeight(); + $maxheight = max($height,$maxheight); + } + } + + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + $height = $aImg->GetFontHeight(); + $maxheight = max($height,$maxheight); + return $maxheight; + } + + // Unhide/hide the text + function Show($aShow=true) { + $this->iShow=$aShow; + } + + // Stroke text at (x,y) coordinates. If the text contains tabs then the + // x parameter should be an array of positions to be used for each successive + // tab mark. If no array is supplied then the tabs will be ignored. + function Stroke($aImg,$aX,$aY) { + if( $this->iShow ) { + $aImg->SetColor($this->iColor); + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + $aImg->SetTextAlign($this->iHAlign,$this->iVAlign); + if( $this->GetNbrTabs() < 1 ) { + if( is_string($this->iText) ) { + if( is_array($aX) ) $aX=$aX[0]; + if( is_array($aY) ) $aY=$aY[0]; + $aImg->StrokeText($aX,$aY,$this->iText); + } + elseif( is_array($this->iText) && ($n = count($this->iText)) > 0 ) { + $ax = is_array($aX) ; + $ay = is_array($aY) ; + if( $ax && $ay ) { + // Nothing; both are already arrays + } + elseif( $ax ) { + $aY = array_fill(0,$n,$aY); + } + elseif( $ay ) { + $aX = array_fill(0,$n,$aX); + } + else { + $aX = array_fill(0,$n,$aX); + $aY = array_fill(0,$n,$aY); + } + $n = min($n, count($aX) ) ; + $n = min($n, count($aY) ) ; + for($i=0; $i < $n; ++$i ) { + $tmp = $this->iText[$i]; + if( is_object($tmp) ) { + $tmp->Stroke($aImg,$aX[$i],$aY[$i]); + } + else { + if( $i < count($this->iFontArray) ) { + $font = $this->iFontArray[$i]; + $aImg->SetFont($font[0],$font[1],$font[2]); + } + else { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + } + $aImg->StrokeText($aX[$i],$aY[$i],str_replace("\t"," ",$tmp)); + } + } + } + } + else { + $tmp = preg_split('/\t/',$this->iText); + $n = min(count($tmp),count($aX)); + for($i=0; $i < $n; ++$i) { + if( $i < count($this->iFontArray) ) { + $font = $this->iFontArray[$i]; + $aImg->SetFont($font[0],$font[1],$font[2]); + } + else { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + } + $aImg->StrokeText($aX[$i],$aY,$tmp[$i]); + } + } + } + } +} + +//=================================================== +// CLASS HeaderProperty +// Description: Data encapsulating class to hold property +// for each type of the scale headers +//=================================================== +class HeaderProperty { + public $grid; + public $iShowLabels=true,$iShowGrid=true; + public $iTitleVertMargin=3,$iFFamily=FF_FONT0,$iFStyle=FS_NORMAL,$iFSize=8; + public $iStyle=0; + public $iFrameColor="black",$iFrameWeight=1; + public $iBackgroundColor="white"; + public $iWeekendBackgroundColor="lightgray",$iSundayTextColor="red"; // these are only used with day scale + public $iTextColor="black"; + public $iLabelFormStr="%d"; + public $iIntervall = 1; + + //--------------- + // CONSTRUCTOR + function __construct() { + $this->grid = new LineProperty(); + } + + //--------------- + // PUBLIC METHODS + function Show($aShow=true) { + $this->iShowLabels = $aShow; + } + + function SetIntervall($aInt) { + $this->iIntervall = $aInt; + } + + function SetInterval($aInt) { + $this->iIntervall = $aInt; + } + + function GetIntervall() { + return $this->iIntervall ; + } + + function SetFont($aFFamily,$aFStyle=FS_NORMAL,$aFSize=10) { + $this->iFFamily = $aFFamily; + $this->iFStyle = $aFStyle; + $this->iFSize = $aFSize; + } + + function SetFontColor($aColor) { + $this->iTextColor = $aColor; + } + + function GetFontHeight($aImg) { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + return $aImg->GetFontHeight(); + } + + function GetFontWidth($aImg) { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + return $aImg->GetFontWidth(); + } + + function GetStrWidth($aImg,$aStr) { + $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize); + return $aImg->GetTextWidth($aStr); + } + + function SetStyle($aStyle) { + $this->iStyle = $aStyle; + } + + function SetBackgroundColor($aColor) { + $this->iBackgroundColor=$aColor; + } + + function SetFrameWeight($aWeight) { + $this->iFrameWeight=$aWeight; + } + + function SetFrameColor($aColor) { + $this->iFrameColor=$aColor; + } + + // Only used by day scale + function SetWeekendColor($aColor) { + $this->iWeekendBackgroundColor=$aColor; + } + + // Only used by day scale + function SetSundayFontColor($aColor) { + $this->iSundayTextColor=$aColor; + } + + function SetTitleVertMargin($aMargin) { + $this->iTitleVertMargin=$aMargin; + } + + function SetLabelFormatString($aStr) { + $this->iLabelFormStr=$aStr; + } + + function SetFormatString($aStr) { + $this->SetLabelFormatString($aStr); + } + + +} + +//=================================================== +// CLASS GanttScale +// Description: Responsible for calculating and showing +// the scale in a gantt chart. This includes providing methods for +// converting dates to position in the chart as well as stroking the +// date headers (days, week, etc). +//=================================================== +class GanttScale { + public $minute,$hour,$day,$week,$month,$year; + public $divider,$dividerh,$tableTitle; + public $iStartDate=-1,$iEndDate=-1; + // Number of gantt bar position (n.b not necessariliy the same as the number of bars) + // we could have on bar in position 1, and one bar in position 5 then there are two + // bars but the number of bar positions is 5 + public $actinfo; + public $iTopPlotMargin=10,$iBottomPlotMargin=15; + public $iVertLines=-1; + public $iVertHeaderSize=-1; + // The width of the labels (defaults to the widest of all labels) + private $iLabelWidth; + // Out image to stroke the scale to + private $iImg; + private $iTableHeaderBackgroundColor="white",$iTableHeaderFrameColor="black"; + private $iTableHeaderFrameWeight=1; + private $iAvailableHeight=-1,$iVertSpacing=-1; + private $iDateLocale; + private $iVertLayout=GANTT_EVEN; + private $iUsePlotWeekendBackground=true; + private $iWeekStart = 1; // Default to have weekends start on Monday + + //--------------- + // CONSTRUCTOR + function __construct($aImg) { + $this->iImg = $aImg; + $this->iDateLocale = new DateLocale(); + + $this->minute = new HeaderProperty(); + $this->minute->SetIntervall(15); + $this->minute->SetLabelFormatString('i'); + $this->minute->SetFont(FF_FONT0); + $this->minute->grid->SetColor("gray"); + + $this->hour = new HeaderProperty(); + $this->hour->SetFont(FF_FONT0); + $this->hour->SetIntervall(6); + $this->hour->SetStyle(HOURSTYLE_HM24); + $this->hour->SetLabelFormatString('H:i'); + $this->hour->grid->SetColor("gray"); + + $this->day = new HeaderProperty(); + $this->day->grid->SetColor("gray"); + $this->day->SetLabelFormatString('l'); + + $this->week = new HeaderProperty(); + $this->week->SetLabelFormatString("w%d"); + $this->week->SetFont(FF_FONT1); + + $this->month = new HeaderProperty(); + $this->month->SetFont(FF_FONT1,FS_BOLD); + + $this->year = new HeaderProperty(); + $this->year->SetFont(FF_FONT1,FS_BOLD); + + $this->divider=new LineProperty(); + $this->dividerh=new LineProperty(); + $this->dividerh->SetWeight(2); + $this->divider->SetWeight(6); + $this->divider->SetColor('gray'); + $this->divider->SetStyle('fancy'); + + $this->tableTitle=new TextProperty(); + $this->tableTitle->Show(false); + $this->actinfo = new GanttActivityInfo(); + } + + //--------------- + // PUBLIC METHODS + // Specify what headers should be visible + function ShowHeaders($aFlg) { + $this->day->Show($aFlg & GANTT_HDAY); + $this->week->Show($aFlg & GANTT_HWEEK); + $this->month->Show($aFlg & GANTT_HMONTH); + $this->year->Show($aFlg & GANTT_HYEAR); + $this->hour->Show($aFlg & GANTT_HHOUR); + $this->minute->Show($aFlg & GANTT_HMIN); + + // Make some default settings of gridlines whihc makes sense + if( $aFlg & GANTT_HWEEK ) { + $this->month->grid->Show(false); + $this->year->grid->Show(false); + } + if( $aFlg & GANTT_HHOUR ) { + $this->day->grid->SetColor("black"); + } + } + + // Should the weekend background stretch all the way down in the plotarea + function UseWeekendBackground($aShow) { + $this->iUsePlotWeekendBackground = $aShow; + } + + // Have a range been specified? + function IsRangeSet() { + return $this->iStartDate!=-1 && $this->iEndDate!=-1; + } + + // Should the layout be from top or even? + function SetVertLayout($aLayout) { + $this->iVertLayout = $aLayout; + } + + // Which locale should be used? + function SetDateLocale($aLocale) { + $this->iDateLocale->Set($aLocale); + } + + // Number of days we are showing + function GetNumberOfDays() { + return round(($this->iEndDate-$this->iStartDate)/SECPERDAY); + } + + // The width of the actual plot area + function GetPlotWidth() { + $img=$this->iImg; + return $img->width - $img->left_margin - $img->right_margin; + } + + // Specify the width of the titles(labels) for the activities + // (This is by default set to the minimum width enought for the + // widest title) + function SetLabelWidth($aLabelWidth) { + $this->iLabelWidth=$aLabelWidth; + } + + // Which day should the week start? + // 0==Sun, 1==Monday, 2==Tuesday etc + function SetWeekStart($aStartDay) { + $this->iWeekStart = $aStartDay % 7; + + //Recalculate the startday since this will change the week start + $this->SetRange($this->iStartDate,$this->iEndDate); + } + + // Do we show min scale? + function IsDisplayMinute() { + return $this->minute->iShowLabels; + } + + // Do we show day scale? + function IsDisplayHour() { + return $this->hour->iShowLabels; + } + + + // Do we show day scale? + function IsDisplayDay() { + return $this->day->iShowLabels; + } + + // Do we show week scale? + function IsDisplayWeek() { + return $this->week->iShowLabels; + } + + // Do we show month scale? + function IsDisplayMonth() { + return $this->month->iShowLabels; + } + + // Do we show year scale? + function IsDisplayYear() { + return $this->year->iShowLabels; + } + + // Specify spacing (in percent of bar height) between activity bars + function SetVertSpacing($aSpacing) { + $this->iVertSpacing = $aSpacing; + } + + // Specify scale min and max date either as timestamp or as date strings + // Always round to the nearest week boundary + function SetRange($aMin,$aMax) { + $this->iStartDate = $this->NormalizeDate($aMin); + $this->iEndDate = $this->NormalizeDate($aMax); + } + + + // Adjust the start and end date so they fit to beginning/ending + // of the week taking the specified week start day into account. + function AdjustStartEndDay() { + + if( !($this->IsDisplayYear() ||$this->IsDisplayMonth() || $this->IsDisplayWeek()) ) { + // Don't adjust + return; + } + + // Get day in week for start and ending date (Sun==0) + $ds=strftime("%w",$this->iStartDate); + $de=strftime("%w",$this->iEndDate); + + // We want to start on iWeekStart day. But first we subtract a week + // if the startdate is "behind" the day the week start at. + // This way we ensure that the given start date is always included + // in the range. If we don't do this the nearest correct weekday in the week + // to start at might be later than the start date. + if( $ds < $this->iWeekStart ) + $d = strtotime('-7 day',$this->iStartDate); + else + $d = $this->iStartDate; + $adjdate = strtotime(($this->iWeekStart-$ds).' day',$d /*$this->iStartDate*/ ); + $this->iStartDate = $adjdate; + + // We want to end on the last day of the week + $preferredEndDay = ($this->iWeekStart+6)%7; + if( $preferredEndDay != $de ) { + // Solve equivalence eq: $de + x ~ $preferredDay (mod 7) + $adj = (7+($preferredEndDay - $de)) % 7; + $adjdate = strtotime("+$adj day",$this->iEndDate); + $this->iEndDate = $adjdate; + } + } + + // Specify background for the table title area (upper left corner of the table) + function SetTableTitleBackground($aColor) { + $this->iTableHeaderBackgroundColor = $aColor; + } + + /////////////////////////////////////// + // PRIVATE Methods + + // Determine the height of all the scale headers combined + function GetHeaderHeight() { + $img=$this->iImg; + $height=1; + if( $this->minute->iShowLabels ) { + $height += $this->minute->GetFontHeight($img); + $height += $this->minute->iTitleVertMargin; + } + if( $this->hour->iShowLabels ) { + $height += $this->hour->GetFontHeight($img); + $height += $this->hour->iTitleVertMargin; + } + if( $this->day->iShowLabels ) { + $height += $this->day->GetFontHeight($img); + $height += $this->day->iTitleVertMargin; + } + if( $this->week->iShowLabels ) { + $height += $this->week->GetFontHeight($img); + $height += $this->week->iTitleVertMargin; + } + if( $this->month->iShowLabels ) { + $height += $this->month->GetFontHeight($img); + $height += $this->month->iTitleVertMargin; + } + if( $this->year->iShowLabels ) { + $height += $this->year->GetFontHeight($img); + $height += $this->year->iTitleVertMargin; + } + return $height; + } + + // Get width (in pixels) for a single day + function GetDayWidth() { + return ($this->GetPlotWidth()-$this->iLabelWidth+1)/$this->GetNumberOfDays(); + } + + // Get width (in pixels) for a single hour + function GetHourWidth() { + return $this->GetDayWidth() / 24 ; + } + + function GetMinuteWidth() { + return $this->GetHourWidth() / 60 ; + } + + // Nuber of days in a year + function GetNumDaysInYear($aYear) { + if( $this->IsLeap($aYear) ) + return 366; + else + return 365; + } + + // Get week number + function GetWeekNbr($aDate,$aSunStart=true) { + // We can't use the internal strftime() since it gets the weeknumber + // wrong since it doesn't follow ISO on all systems since this is + // system linrary dependent. + // Even worse is that this works differently if we are on a Windows + // or UNIX box (it even differs between UNIX boxes how strftime() + // is natively implemented) + // + // Credit to Nicolas Hoizey <nhoizey@phpheaven.net> for this elegant + // version of Week Nbr calculation. + + $day = $this->NormalizeDate($aDate); + if( $aSunStart ) + $day += 60*60*24; + + /*------------------------------------------------------------------------- + According to ISO-8601 : + "Week 01 of a year is per definition the first week that has the Thursday in this year, + which is equivalent to the week that contains the fourth day of January. + In other words, the first week of a new year is the week that has the majority of its + days in the new year." + + Be carefull, with PHP, -3 % 7 = -3, instead of 4 !!! + + day of year = date("z", $day) + 1 + offset to thursday = 3 - (date("w", $day) + 6) % 7 + first thursday of year = 1 + (11 - date("w", mktime(0, 0, 0, 1, 1, date("Y", $day)))) % 7 + week number = (thursday's day of year - first thursday's day of year) / 7 + 1 + ---------------------------------------------------------------------------*/ + + $thursday = $day + 60 * 60 * 24 * (3 - (date("w", $day) + 6) % 7); // take week's thursday + $week = 1 + (date("z", $thursday) - (11 - date("w", mktime(0, 0, 0, 1, 1, date("Y", $thursday)))) % 7) / 7; + + return $week; + } + + // Is year a leap year? + function IsLeap($aYear) { + // Is the year a leap year? + //$year = 0+date("Y",$aDate); + if( $aYear % 4 == 0) + if( !($aYear % 100 == 0) || ($aYear % 400 == 0) ) + return true; + return false; + } + + // Get current year + function GetYear($aDate) { + return 0+Date("Y",$aDate); + } + + // Return number of days in a year + function GetNumDaysInMonth($aMonth,$aYear) { + $days=array(31,28,31,30,31,30,31,31,30,31,30,31); + $daysl=array(31,29,31,30,31,30,31,31,30,31,30,31); + if( $this->IsLeap($aYear)) + return $daysl[$aMonth]; + else + return $days[$aMonth]; + } + + // Get day in month + function GetMonthDayNbr($aDate) { + return 0+strftime("%d",$aDate); + } + + // Get day in year + function GetYearDayNbr($aDate) { + return 0+strftime("%j",$aDate); + } + + // Get month number + function GetMonthNbr($aDate) { + return 0+strftime("%m",$aDate); + } + + // Translate a date to screen coordinates (horizontal scale) + function TranslateDate($aDate) { + // + // In order to handle the problem with Daylight savings time + // the scale written with equal number of seconds per day beginning + // with the start date. This means that we "cement" the state of + // DST as it is in the start date. If later the scale includes the + // switchover date (depends on the locale) we need to adjust back + // if the date we try to translate has a different DST status since + // we would otherwise be off by one hour. + $aDate = $this->NormalizeDate($aDate); + $tmp = localtime($aDate); + $cloc = $tmp[8]; + $tmp = localtime($this->iStartDate); + $sloc = $tmp[8]; + $offset = 0; + if( $sloc != $cloc) { + if( $sloc ) + $offset = 3600; + else + $offset = -3600; + } + $img=$this->iImg; + return ($aDate-$this->iStartDate-$offset)/SECPERDAY*$this->GetDayWidth()+$img->left_margin+$this->iLabelWidth;; + } + + // Get screen coordinatesz for the vertical position for a bar + function TranslateVertPos($aPos,$atTop=false) { + $img=$this->iImg; + if( $aPos > $this->iVertLines ) + JpGraphError::RaiseL(6015,$aPos); + // 'Illegal vertical position %d' + if( $this->iVertLayout == GANTT_EVEN ) { + // Position the top bar at 1 vert spacing from the scale + $pos = round($img->top_margin + $this->iVertHeaderSize + ($aPos+1)*$this->iVertSpacing); + } + else { + // position the top bar at 1/2 a vert spacing from the scale + $pos = round($img->top_margin + $this->iVertHeaderSize + $this->iTopPlotMargin + ($aPos+1)*$this->iVertSpacing); + } + + if( $atTop ) + $pos -= $this->iVertSpacing; + + return $pos; + } + + // What is the vertical spacing? + function GetVertSpacing() { + return $this->iVertSpacing; + } + + // Convert a date to timestamp + function NormalizeDate($aDate) { + if( $aDate === false ) return false; + if( is_string($aDate) ) { + $t = strtotime($aDate); + if( $t === FALSE || $t === -1 ) { + JpGraphError::RaiseL(6016,$aDate); + //("Date string ($aDate) specified for Gantt activity can not be interpretated. Please make sure it is a valid time string, e.g. 2005-04-23 13:30"); + } + return $t; + } + elseif( is_int($aDate) || is_float($aDate) ) + return $aDate; + else + JpGraphError::RaiseL(6017,$aDate); + //Unknown date format in GanttScale ($aDate)."); + } + + + // Convert a time string to minutes + + function TimeToMinutes($aTimeString) { + // Split in hours and minutes + $pos=strpos($aTimeString,':'); + $minint=60; + if( $pos === false ) { + $hourint = $aTimeString; + $minint = 0; + } + else { + $hourint = floor(substr($aTimeString,0,$pos)); + $minint = floor(substr($aTimeString,$pos+1)); + } + $minint += 60 * $hourint; + return $minint; + } + + // Stroke the day scale (including gridlines) + function StrokeMinutes($aYCoord,$getHeight=false) { + $img=$this->iImg; + $xt=$img->left_margin+$this->iLabelWidth; + $yt=$aYCoord+$img->top_margin; + if( $this->minute->iShowLabels ) { + $img->SetFont($this->minute->iFFamily,$this->minute->iFStyle,$this->minute->iFSize); + $yb = $yt + $img->GetFontHeight() + + $this->minute->iTitleVertMargin + $this->minute->iFrameWeight; + if( $getHeight ) { + return $yb - $img->top_margin; + } + $xb = $img->width-$img->right_margin+1; + $img->SetColor($this->minute->iBackgroundColor); + $img->FilledRectangle($xt,$yt,$xb,$yb); + + $x = $xt; + $img->SetTextAlign("center"); + $day = date('w',$this->iStartDate); + $minint = $this->minute->GetIntervall() ; + + if( 60 % $minint !== 0 ) { + JpGraphError::RaiseL(6018,$minint); + //'Intervall for minutes must divide the hour evenly, e.g. 1,5,10,12,15,20,30 etc You have specified an intervall of '.$minint.' minutes.'); + } + + + $n = 60 / $minint; + $datestamp = $this->iStartDate; + $width = $this->GetHourWidth() / $n ; + if( $width < 8 ) { + // TO small width to draw minute scale + JpGraphError::RaiseL(6019,$width); + //('The available width ('.$width.') for minutes are to small for this scale to be displayed. Please use auto-sizing or increase the width of the graph.'); + } + + $nh = ceil(24*60 / $this->TimeToMinutes($this->hour->GetIntervall()) ); + $nd = $this->GetNumberOfDays(); + // Convert to intervall to seconds + $minint *= 60; + for($j=0; $j < $nd; ++$j, $day += 1, $day %= 7) { + for( $k=0; $k < $nh; ++$k ) { + for($i=0; $i < $n ;++$i, $x+=$width, $datestamp += $minint ) { + if( $day==6 || $day==0 ) { + + $img->PushColor($this->day->iWeekendBackgroundColor); + if( $this->iUsePlotWeekendBackground ) + $img->FilledRectangle($x,$yt+$this->day->iFrameWeight,$x+$width,$img->height-$img->bottom_margin); + else + $img->FilledRectangle($x,$yt+$this->day->iFrameWeight,$x+$width,$yb-$this->day->iFrameWeight); + $img->PopColor(); + + } + + if( $day==0 ) + $img->SetColor($this->day->iSundayTextColor); + else + $img->SetColor($this->day->iTextColor); + + switch( $this->minute->iStyle ) { + case MINUTESTYLE_CUSTOM: + $txt = date($this->minute->iLabelFormStr,$datestamp); + break; + case MINUTESTYLE_MM: + default: + // 15 + $txt = date('i',$datestamp); + break; + } + $img->StrokeText(round($x+$width/2),round($yb-$this->minute->iTitleVertMargin),$txt); + + // Fix a rounding problem the wrong way .. + // If we also have hour scale then don't draw the firsta or last + // gridline since that will be overwritten by the hour scale gridline if such exists. + // However, due to the propagation of rounding of the 'x+=width' term in the loop + // this might sometimes be one pixel of so we fix this by not drawing it. + // The proper way to fix it would be to re-calculate the scale for each step and + // not using the additive term. + if( !(($i == $n || $i==0) && $this->hour->iShowLabels && $this->hour->grid->iShow) ) { + $img->SetColor($this->minute->grid->iColor); + $img->SetLineWeight($this->minute->grid->iWeight); + $img->Line($x,$yt,$x,$yb); + $this->minute->grid->Stroke($img,$x,$yb,$x,$img->height-$img->bottom_margin); + } + } + } + } + $img->SetColor($this->minute->iFrameColor); + $img->SetLineWeight($this->minute->iFrameWeight); + $img->Rectangle($xt,$yt,$xb,$yb); + return $yb - $img->top_margin; + } + return $aYCoord; + } + + // Stroke the day scale (including gridlines) + function StrokeHours($aYCoord,$getHeight=false) { + $img=$this->iImg; + $xt=$img->left_margin+$this->iLabelWidth; + $yt=$aYCoord+$img->top_margin; + if( $this->hour->iShowLabels ) { + $img->SetFont($this->hour->iFFamily,$this->hour->iFStyle,$this->hour->iFSize); + $yb = $yt + $img->GetFontHeight() + + $this->hour->iTitleVertMargin + $this->hour->iFrameWeight; + if( $getHeight ) { + return $yb - $img->top_margin; + } + $xb = $img->width-$img->right_margin+1; + $img->SetColor($this->hour->iBackgroundColor); + $img->FilledRectangle($xt,$yt,$xb,$yb); + + $x = $xt; + $img->SetTextAlign("center"); + $tmp = $this->hour->GetIntervall() ; + $minint = $this->TimeToMinutes($tmp); + if( 1440 % $minint !== 0 ) { + JpGraphError::RaiseL(6020,$tmp); + //('Intervall for hours must divide the day evenly, e.g. 0:30, 1:00, 1:30, 4:00 etc. You have specified an intervall of '.$tmp); + } + + $n = ceil(24*60 / $minint ); + $datestamp = $this->iStartDate; + $day = date('w',$this->iStartDate); + $doback = !$this->minute->iShowLabels; + $width = $this->GetDayWidth() / $n ; + for($j=0; $j < $this->GetNumberOfDays(); ++$j, $day += 1,$day %= 7) { + for($i=0; $i < $n ;++$i, $x+=$width) { + if( $day==6 || $day==0 ) { + + $img->PushColor($this->day->iWeekendBackgroundColor); + if( $this->iUsePlotWeekendBackground && $doback ) + $img->FilledRectangle($x,$yt+$this->day->iFrameWeight,$x+$width,$img->height-$img->bottom_margin); + else + $img->FilledRectangle($x,$yt+$this->day->iFrameWeight,$x+$width,$yb-$this->day->iFrameWeight); + $img->PopColor(); + + } + + if( $day==0 ) + $img->SetColor($this->day->iSundayTextColor); + else + $img->SetColor($this->day->iTextColor); + + switch( $this->hour->iStyle ) { + case HOURSTYLE_HMAMPM: + // 1:35pm + $txt = date('g:ia',$datestamp); + break; + case HOURSTYLE_H24: + // 13 + $txt = date('H',$datestamp); + break; + case HOURSTYLE_HAMPM: + $txt = date('ga',$datestamp); + break; + case HOURSTYLE_CUSTOM: + $txt = date($this->hour->iLabelFormStr,$datestamp); + break; + case HOURSTYLE_HM24: + default: + $txt = date('H:i',$datestamp); + break; + } + $img->StrokeText(round($x+$width/2),round($yb-$this->hour->iTitleVertMargin),$txt); + $img->SetColor($this->hour->grid->iColor); + $img->SetLineWeight($this->hour->grid->iWeight); + $img->Line($x,$yt,$x,$yb); + $this->hour->grid->Stroke($img,$x,$yb,$x,$img->height-$img->bottom_margin); + //$datestamp += $minint*60 + $datestamp = mktime(date('H',$datestamp),date('i',$datestamp)+$minint,0, + date("m",$datestamp),date("d",$datestamp)+1,date("Y",$datestamp)); + + } + } + $img->SetColor($this->hour->iFrameColor); + $img->SetLineWeight($this->hour->iFrameWeight); + $img->Rectangle($xt,$yt,$xb,$yb); + return $yb - $img->top_margin; + } + return $aYCoord; + } + + + // Stroke the day scale (including gridlines) + function StrokeDays($aYCoord,$getHeight=false) { + $img=$this->iImg; + $daywidth=$this->GetDayWidth(); + $xt=$img->left_margin+$this->iLabelWidth; + $yt=$aYCoord+$img->top_margin; + if( $this->day->iShowLabels ) { + $img->SetFont($this->day->iFFamily,$this->day->iFStyle,$this->day->iFSize); + $yb=$yt + $img->GetFontHeight() + $this->day->iTitleVertMargin + $this->day->iFrameWeight; + if( $getHeight ) { + return $yb - $img->top_margin; + } + $xb=$img->width-$img->right_margin+1; + $img->SetColor($this->day->iBackgroundColor); + $img->FilledRectangle($xt,$yt,$xb,$yb); + + $x = $xt; + $img->SetTextAlign("center"); + $day = date('w',$this->iStartDate); + $datestamp = $this->iStartDate; + + $doback = !($this->hour->iShowLabels || $this->minute->iShowLabels); + + setlocale(LC_TIME,$this->iDateLocale->iLocale); + + for($i=0; $i < $this->GetNumberOfDays(); ++$i, $x+=$daywidth, $day += 1,$day %= 7) { + if( $day==6 || $day==0 ) { + $img->SetColor($this->day->iWeekendBackgroundColor); + if( $this->iUsePlotWeekendBackground && $doback) + $img->FilledRectangle($x,$yt+$this->day->iFrameWeight, + $x+$daywidth,$img->height-$img->bottom_margin); + else + $img->FilledRectangle($x,$yt+$this->day->iFrameWeight, + $x+$daywidth,$yb-$this->day->iFrameWeight); + } + + $mn = strftime('%m',$datestamp); + if( $mn[0]=='0' ) + $mn = $mn[1]; + + switch( $this->day->iStyle ) { + case DAYSTYLE_LONG: + // "Monday" + $txt = strftime('%A',$datestamp); + break; + case DAYSTYLE_SHORT: + // "Mon" + $txt = strftime('%a',$datestamp); + break; + case DAYSTYLE_SHORTDAYDATE1: + // "Mon 23/6" + $txt = strftime('%a %d/'.$mn,$datestamp); + break; + case DAYSTYLE_SHORTDAYDATE2: + // "Mon 23 Jun" + $txt = strftime('%a %d %b',$datestamp); + break; + case DAYSTYLE_SHORTDAYDATE3: + // "Mon 23 Jun 2003" + $txt = strftime('%a %d %b %Y',$datestamp); + break; + case DAYSTYLE_LONGDAYDATE1: + // "Monday 23 Jun" + $txt = strftime('%A %d %b',$datestamp); + break; + case DAYSTYLE_LONGDAYDATE2: + // "Monday 23 Jun 2003" + $txt = strftime('%A %d %b %Y',$datestamp); + break; + case DAYSTYLE_SHORTDATE1: + // "23/6" + $txt = strftime('%d/'.$mn,$datestamp); + break; + case DAYSTYLE_SHORTDATE2: + // "23 Jun" + $txt = strftime('%d %b',$datestamp); + break; + case DAYSTYLE_SHORTDATE3: + // "Mon 23" + $txt = strftime('%a %d',$datestamp); + break; + case DAYSTYLE_SHORTDATE4: + // "23" + $txt = strftime('%d',$datestamp); + break; + case DAYSTYLE_CUSTOM: + // Custom format + $txt = strftime($this->day->iLabelFormStr,$datestamp); + break; + case DAYSTYLE_ONELETTER: + default: + // "M" + $txt = strftime('%A',$datestamp); + $txt = strtoupper($txt[0]); + break; + } + + if( $day==0 ) + $img->SetColor($this->day->iSundayTextColor); + else + $img->SetColor($this->day->iTextColor); + $img->StrokeText(round($x+$daywidth/2+1), + round($yb-$this->day->iTitleVertMargin),$txt); + $img->SetColor($this->day->grid->iColor); + $img->SetLineWeight($this->day->grid->iWeight); + $img->Line($x,$yt,$x,$yb); + $this->day->grid->Stroke($img,$x,$yb,$x,$img->height-$img->bottom_margin); + $datestamp = mktime(0,0,0,date("m",$datestamp),date("d",$datestamp)+1,date("Y",$datestamp)); + //$datestamp += SECPERDAY; + + } + $img->SetColor($this->day->iFrameColor); + $img->SetLineWeight($this->day->iFrameWeight); + $img->Rectangle($xt,$yt,$xb,$yb); + return $yb - $img->top_margin; + } + return $aYCoord; + } + + // Stroke week header and grid + function StrokeWeeks($aYCoord,$getHeight=false) { + if( $this->week->iShowLabels ) { + $img=$this->iImg; + $yt=$aYCoord+$img->top_margin; + $img->SetFont($this->week->iFFamily,$this->week->iFStyle,$this->week->iFSize); + $yb=$yt + $img->GetFontHeight() + $this->week->iTitleVertMargin + $this->week->iFrameWeight; + + if( $getHeight ) { + return $yb - $img->top_margin; + } + + $xt=$img->left_margin+$this->iLabelWidth; + $weekwidth=$this->GetDayWidth()*7; + $wdays=$this->iDateLocale->GetDayAbb(); + $xb=$img->width-$img->right_margin+1; + $week = $this->iStartDate; + $weeknbr=$this->GetWeekNbr($week); + $img->SetColor($this->week->iBackgroundColor); + $img->FilledRectangle($xt,$yt,$xb,$yb); + $img->SetColor($this->week->grid->iColor); + $x = $xt; + if( $this->week->iStyle==WEEKSTYLE_WNBR ) { + $img->SetTextAlign("center"); + $txtOffset = $weekwidth/2+1; + } + elseif( $this->week->iStyle==WEEKSTYLE_FIRSTDAY || + $this->week->iStyle==WEEKSTYLE_FIRSTDAY2 || + $this->week->iStyle==WEEKSTYLE_FIRSTDAYWNBR || + $this->week->iStyle==WEEKSTYLE_FIRSTDAY2WNBR ) { + $img->SetTextAlign("left"); + $txtOffset = 3; + } + else { + JpGraphError::RaiseL(6021); + //("Unknown formatting style for week."); + } + + for($i=0; $i<$this->GetNumberOfDays()/7; ++$i, $x+=$weekwidth) { + $img->PushColor($this->week->iTextColor); + + if( $this->week->iStyle==WEEKSTYLE_WNBR ) + $txt = sprintf($this->week->iLabelFormStr,$weeknbr); + elseif( $this->week->iStyle==WEEKSTYLE_FIRSTDAY || + $this->week->iStyle==WEEKSTYLE_FIRSTDAYWNBR ) + $txt = date("j/n",$week); + elseif( $this->week->iStyle==WEEKSTYLE_FIRSTDAY2 || + $this->week->iStyle==WEEKSTYLE_FIRSTDAY2WNBR ) { + $monthnbr = date("n",$week)-1; + $shortmonth = $this->iDateLocale->GetShortMonthName($monthnbr); + $txt = Date("j",$week)." ".$shortmonth; + } + + if( $this->week->iStyle==WEEKSTYLE_FIRSTDAYWNBR || + $this->week->iStyle==WEEKSTYLE_FIRSTDAY2WNBR ) { + $w = sprintf($this->week->iLabelFormStr,$weeknbr); + $txt .= ' '.$w; + } + + $img->StrokeText(round($x+$txtOffset), + round($yb-$this->week->iTitleVertMargin),$txt); + + $week = strtotime('+7 day',$week); + $weeknbr = $this->GetWeekNbr($week); + $img->PopColor(); + $img->SetLineWeight($this->week->grid->iWeight); + $img->Line($x,$yt,$x,$yb); + $this->week->grid->Stroke($img,$x,$yb,$x,$img->height-$img->bottom_margin); + } + $img->SetColor($this->week->iFrameColor); + $img->SetLineWeight($this->week->iFrameWeight); + $img->Rectangle($xt,$yt,$xb,$yb); + return $yb-$img->top_margin; + } + return $aYCoord; + } + + // Format the mont scale header string + function GetMonthLabel($aMonthNbr,$year) { + $sn = $this->iDateLocale->GetShortMonthName($aMonthNbr); + $ln = $this->iDateLocale->GetLongMonthName($aMonthNbr); + switch($this->month->iStyle) { + case MONTHSTYLE_SHORTNAME: + $m=$sn; + break; + case MONTHSTYLE_LONGNAME: + $m=$ln; + break; + case MONTHSTYLE_SHORTNAMEYEAR2: + $m=$sn." '".substr("".$year,2); + break; + case MONTHSTYLE_SHORTNAMEYEAR4: + $m=$sn." ".$year; + break; + case MONTHSTYLE_LONGNAMEYEAR2: + $m=$ln." '".substr("".$year,2); + break; + case MONTHSTYLE_LONGNAMEYEAR4: + $m=$ln." ".$year; + break; + case MONTHSTYLE_FIRSTLETTER: + $m=$sn[0]; + break; + } + return $m; + } + + // Stroke month scale and gridlines + function StrokeMonths($aYCoord,$getHeight=false) { + if( $this->month->iShowLabels ) { + $img=$this->iImg; + $img->SetFont($this->month->iFFamily,$this->month->iFStyle,$this->month->iFSize); + $yt=$aYCoord+$img->top_margin; + $yb=$yt + $img->GetFontHeight() + $this->month->iTitleVertMargin + $this->month->iFrameWeight; + if( $getHeight ) { + return $yb - $img->top_margin; + } + $monthnbr = $this->GetMonthNbr($this->iStartDate)-1; + $xt=$img->left_margin+$this->iLabelWidth; + $xb=$img->width-$img->right_margin+1; + + $img->SetColor($this->month->iBackgroundColor); + $img->FilledRectangle($xt,$yt,$xb,$yb); + + $img->SetLineWeight($this->month->grid->iWeight); + $img->SetColor($this->month->iTextColor); + $year = 0+strftime("%Y",$this->iStartDate); + $img->SetTextAlign("center"); + if( $this->GetMonthNbr($this->iStartDate) == $this->GetMonthNbr($this->iEndDate) + && $this->GetYear($this->iStartDate)==$this->GetYear($this->iEndDate) ) { + $monthwidth=$this->GetDayWidth()*($this->GetMonthDayNbr($this->iEndDate) - $this->GetMonthDayNbr($this->iStartDate) + 1); + } + else { + $monthwidth=$this->GetDayWidth()*($this->GetNumDaysInMonth($monthnbr,$year)-$this->GetMonthDayNbr($this->iStartDate)+1); + } + // Is it enough space to stroke the first month? + $monthName = $this->GetMonthLabel($monthnbr,$year); + if( $monthwidth >= 1.2*$img->GetTextWidth($monthName) ) { + $img->SetColor($this->month->iTextColor); + $img->StrokeText(round($xt+$monthwidth/2+1), + round($yb-$this->month->iTitleVertMargin), + $monthName); + } + $x = $xt + $monthwidth; + while( $x < $xb ) { + $img->SetColor($this->month->grid->iColor); + $img->Line($x,$yt,$x,$yb); + $this->month->grid->Stroke($img,$x,$yb,$x,$img->height-$img->bottom_margin); + $monthnbr++; + if( $monthnbr==12 ) { + $monthnbr=0; + $year++; + } + $monthName = $this->GetMonthLabel($monthnbr,$year); + $monthwidth=$this->GetDayWidth()*$this->GetNumDaysInMonth($monthnbr,$year); + if( $x + $monthwidth < $xb ) + $w = $monthwidth; + else + $w = $xb-$x; + if( $w >= 1.2*$img->GetTextWidth($monthName) ) { + $img->SetColor($this->month->iTextColor); + $img->StrokeText(round($x+$w/2+1), + round($yb-$this->month->iTitleVertMargin),$monthName); + } + $x += $monthwidth; + } + $img->SetColor($this->month->iFrameColor); + $img->SetLineWeight($this->month->iFrameWeight); + $img->Rectangle($xt,$yt,$xb,$yb); + return $yb-$img->top_margin; + } + return $aYCoord; + } + + // Stroke year scale and gridlines + function StrokeYears($aYCoord,$getHeight=false) { + if( $this->year->iShowLabels ) { + $img=$this->iImg; + $yt=$aYCoord+$img->top_margin; + $img->SetFont($this->year->iFFamily,$this->year->iFStyle,$this->year->iFSize); + $yb=$yt + $img->GetFontHeight() + $this->year->iTitleVertMargin + $this->year->iFrameWeight; + + if( $getHeight ) { + return $yb - $img->top_margin; + } + + $xb=$img->width-$img->right_margin+1; + $xt=$img->left_margin+$this->iLabelWidth; + $year = $this->GetYear($this->iStartDate); + $img->SetColor($this->year->iBackgroundColor); + $img->FilledRectangle($xt,$yt,$xb,$yb); + $img->SetLineWeight($this->year->grid->iWeight); + $img->SetTextAlign("center"); + if( $year == $this->GetYear($this->iEndDate) ) + $yearwidth=$this->GetDayWidth()*($this->GetYearDayNbr($this->iEndDate)-$this->GetYearDayNbr($this->iStartDate)+1); + else + $yearwidth=$this->GetDayWidth()*($this->GetNumDaysInYear($year)-$this->GetYearDayNbr($this->iStartDate)+1); + + // The space for a year must be at least 20% bigger than the actual text + // so we allow 10% margin on each side + if( $yearwidth >= 1.20*$img->GetTextWidth("".$year) ) { + $img->SetColor($this->year->iTextColor); + $img->StrokeText(round($xt+$yearwidth/2+1), + round($yb-$this->year->iTitleVertMargin), + $year); + } + $x = $xt + $yearwidth; + while( $x < $xb ) { + $img->SetColor($this->year->grid->iColor); + $img->Line($x,$yt,$x,$yb); + $this->year->grid->Stroke($img,$x,$yb,$x,$img->height-$img->bottom_margin); + $year += 1; + $yearwidth=$this->GetDayWidth()*$this->GetNumDaysInYear($year); + if( $x + $yearwidth < $xb ) + $w = $yearwidth; + else + $w = $xb-$x; + if( $w >= 1.2*$img->GetTextWidth("".$year) ) { + $img->SetColor($this->year->iTextColor); + $img->StrokeText(round($x+$w/2+1), + round($yb-$this->year->iTitleVertMargin), + $year); + } + $x += $yearwidth; + } + $img->SetColor($this->year->iFrameColor); + $img->SetLineWeight($this->year->iFrameWeight); + $img->Rectangle($xt,$yt,$xb,$yb); + return $yb-$img->top_margin; + } + return $aYCoord; + } + + // Stroke table title (upper left corner) + function StrokeTableHeaders($aYBottom) { + $img=$this->iImg; + $xt=$img->left_margin; + $yt=$img->top_margin; + $xb=$xt+$this->iLabelWidth; + $yb=$aYBottom+$img->top_margin; + + if( $this->tableTitle->iShow ) { + $img->SetColor($this->iTableHeaderBackgroundColor); + $img->FilledRectangle($xt,$yt,$xb,$yb); + $this->tableTitle->Align("center","top"); + $this->tableTitle->Stroke($img,$xt+($xb-$xt)/2+1,$yt+2); + $img->SetColor($this->iTableHeaderFrameColor); + $img->SetLineWeight($this->iTableHeaderFrameWeight); + $img->Rectangle($xt,$yt,$xb,$yb); + } + + $this->actinfo->Stroke($img,$xt,$yt,$xb,$yb,$this->tableTitle->iShow); + + + // Draw the horizontal dividing line + $this->dividerh->Stroke($img,$xt,$yb,$img->width-$img->right_margin,$yb); + + // Draw the vertical dividing line + // We do the width "manually" since we want the line only to grow + // to the left + $fancy = $this->divider->iStyle == 'fancy' ; + if( $fancy ) { + $this->divider->iStyle = 'solid'; + } + + $tmp = $this->divider->iWeight; + $this->divider->iWeight=1; + $y = $img->height-$img->bottom_margin; + for($i=0; $i < $tmp; ++$i ) { + $this->divider->Stroke($img,$xb-$i,$yt,$xb-$i,$y); + } + + // Should we draw "fancy" divider + if( $fancy ) { + $img->SetLineWeight(1); + $img->SetColor($this->iTableHeaderFrameColor); + $img->Line($xb,$yt,$xb,$y); + $img->Line($xb-$tmp+1,$yt,$xb-$tmp+1,$y); + $img->SetColor('white'); + $img->Line($xb-$tmp+2,$yt,$xb-$tmp+2,$y); + } + } + + // Main entry point to stroke scale + function Stroke() { + if( !$this->IsRangeSet() ) { + JpGraphError::RaiseL(6022); + //("Gantt scale has not been specified."); + } + $img=$this->iImg; + + // If minutes are displayed then hour interval must be 1 + if( $this->IsDisplayMinute() && $this->hour->GetIntervall() > 1 ) { + JpGraphError::RaiseL(6023); + //('If you display both hour and minutes the hour intervall must be 1 (Otherwise it doesn\' make sense to display minutes).'); + } + + // Stroke all headers. As argument we supply the offset from the + // top which depends on any previous headers + + // First find out the height of each header + $offy=$this->StrokeYears(0,true); + $offm=$this->StrokeMonths($offy,true); + $offw=$this->StrokeWeeks($offm,true); + $offd=$this->StrokeDays($offw,true); + $offh=$this->StrokeHours($offd,true); + $offmin=$this->StrokeMinutes($offh,true); + + + // ... then we can stroke them in the "backwards order to ensure that + // the larger scale gridlines is stroked over the smaller scale gridline + $this->StrokeMinutes($offh); + $this->StrokeHours($offd); + $this->StrokeDays($offw); + $this->StrokeWeeks($offm); + $this->StrokeMonths($offy); + $this->StrokeYears(0); + + // Now when we now the oaverall size of the scale headers + // we can stroke the overall table headers + $this->StrokeTableHeaders($offmin); + + // Now we can calculate the correct scaling factor for each vertical position + $this->iAvailableHeight = $img->height - $img->top_margin - $img->bottom_margin - $offd; + + $this->iVertHeaderSize = $offmin; + if( $this->iVertSpacing == -1 ) + $this->iVertSpacing = $this->iAvailableHeight / $this->iVertLines; + } +} + + +//=================================================== +// CLASS GanttConstraint +// Just a structure to store all the values for a constraint +//=================================================== +class GanttConstraint { + public $iConstrainRow; + public $iConstrainType; + public $iConstrainColor; + public $iConstrainArrowSize; + public $iConstrainArrowType; + + //--------------- + // CONSTRUCTOR + function __construct($aRow,$aType,$aColor,$aArrowSize,$aArrowType){ + $this->iConstrainType = $aType; + $this->iConstrainRow = $aRow; + $this->iConstrainColor=$aColor; + $this->iConstrainArrowSize=$aArrowSize; + $this->iConstrainArrowType=$aArrowType; + } +} + + +//=================================================== +// CLASS GanttPlotObject +// The common signature for a Gantt object +//=================================================== +class GanttPlotObject { + public $title,$caption; + public $csimarea='',$csimtarget='',$csimwintarget='',$csimalt=''; + public $constraints = array(); + public $iCaptionMargin=5; + public $iConstrainPos=array(); + protected $iStart=""; // Start date + public $iVPos=0; // Vertical position + protected $iLabelLeftMargin=2; // Title margin + + function __construct() { + $this->title = new TextProperty(); + $this->title->Align('left','center'); + $this->caption = new TextProperty(); + } + + function GetCSIMArea() { + return $this->csimarea; + } + + function SetCSIMTarget($aTarget,$aAlt='',$aWinTarget='') { + if( !is_string($aTarget) ) { + $tv = substr(var_export($aTarget,true),0,40); + JpGraphError::RaiseL(6024,$tv); + //('CSIM Target must be specified as a string.'."\nStart of target is:\n$tv"); + } + if( !is_string($aAlt) ) { + $tv = substr(var_export($aAlt,true),0,40); + JpGraphError::RaiseL(6025,$tv); + //('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv"); + } + + $this->csimtarget=$aTarget; + $this->csimwintarget=$aWinTarget; + $this->csimalt=$aAlt; + } + + function SetCSIMAlt($aAlt) { + if( !is_string($aAlt) ) { + $tv = substr(var_export($aAlt,true),0,40); + JpGraphError::RaiseL(6025,$tv); + //('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv"); + } + $this->csimalt=$aAlt; + } + + function SetConstrain($aRow,$aType,$aColor='black',$aArrowSize=ARROW_S2,$aArrowType=ARROWT_SOLID) { + $this->constraints[] = new GanttConstraint($aRow, $aType, $aColor, $aArrowSize, $aArrowType); + } + + function SetConstrainPos($xt,$yt,$xb,$yb) { + $this->iConstrainPos = array($xt,$yt,$xb,$yb); + } + + function GetMinDate() { + return $this->iStart; + } + + function GetMaxDate() { + return $this->iStart; + } + + function SetCaptionMargin($aMarg) { + $this->iCaptionMargin=$aMarg; + } + + function GetAbsHeight($aImg) { + return 0; + } + + function GetLineNbr() { + return $this->iVPos; + } + + function SetLabelLeftMargin($aOff) { + $this->iLabelLeftMargin=$aOff; + } + + function StrokeActInfo($aImg,$aScale,$aYPos) { + $cols=array(); + $aScale->actinfo->GetColStart($aImg,$cols,true); + $this->title->Stroke($aImg,$cols,$aYPos); + } +} + +//=================================================== +// CLASS Progress +// Holds parameters for the progress indicator +// displyed within a bar +//=================================================== +class Progress { + public $iProgress=-1; + public $iPattern=GANTT_SOLID; + public $iColor="black", $iFillColor='black'; + public $iDensity=98, $iHeight=0.65; + + function Set($aProg) { + if( $aProg < 0.0 || $aProg > 1.0 ) { + JpGraphError::RaiseL(6027); + //("Progress value must in range [0, 1]"); + } + $this->iProgress = $aProg; + } + + function SetPattern($aPattern,$aColor="blue",$aDensity=98) { + $this->iPattern = $aPattern; + $this->iColor = $aColor; + $this->iDensity = $aDensity; + } + + function SetFillColor($aColor) { + $this->iFillColor = $aColor; + } + + function SetHeight($aHeight) { + $this->iHeight = $aHeight; + } +} + +define('GANTT_HGRID1',0); +define('GANTT_HGRID2',1); + +//=================================================== +// CLASS HorizontalGridLine +// Responsible for drawinf horizontal gridlines and filled alternatibg rows +//=================================================== +class HorizontalGridLine { + private $iGraph=NULL; + private $iRowColor1 = '', $iRowColor2 = ''; + private $iShow=false; + private $line=null; + private $iStart=0; // 0=from left margin, 1=just along header + + function __construct() { + $this->line = new LineProperty(); + $this->line->SetColor('gray@0.4'); + $this->line->SetStyle('dashed'); + } + + function Show($aShow=true) { + $this->iShow = $aShow; + } + + function SetRowFillColor($aColor1,$aColor2='') { + $this->iRowColor1 = $aColor1; + $this->iRowColor2 = $aColor2; + } + + function SetStart($aStart) { + $this->iStart = $aStart; + } + + function Stroke($aImg,$aScale) { + + if( ! $this->iShow ) return; + + // Get horizontal width of line + /* + $limst = $aScale->iStartDate; + $limen = $aScale->iEndDate; + $xt = round($aScale->TranslateDate($aScale->iStartDate)); + $xb = round($aScale->TranslateDate($limen)); + */ + + if( $this->iStart === 0 ) { + $xt = $aImg->left_margin-1; + } + else { + $xt = round($aScale->TranslateDate($aScale->iStartDate))+1; + } + + $xb = $aImg->width-$aImg->right_margin; + + $yt = round($aScale->TranslateVertPos(0)); + $yb = round($aScale->TranslateVertPos(1)); + $height = $yb - $yt; + + // Loop around for all lines in the chart + for($i=0; $i < $aScale->iVertLines; ++$i ) { + $yb = $yt - $height; + $this->line->Stroke($aImg,$xt,$yb,$xb,$yb); + if( $this->iRowColor1 !== '' ) { + if( $i % 2 == 0 ) { + $aImg->PushColor($this->iRowColor1); + $aImg->FilledRectangle($xt,$yt,$xb,$yb); + $aImg->PopColor(); + } + elseif( $this->iRowColor2 !== '' ) { + $aImg->PushColor($this->iRowColor2); + $aImg->FilledRectangle($xt,$yt,$xb,$yb); + $aImg->PopColor(); + } + } + $yt = round($aScale->TranslateVertPos($i+1)); + } + $yb = $yt - $height; + $this->line->Stroke($aImg,$xt,$yb,$xb,$yb); + } +} + + +//=================================================== +// CLASS GanttBar +// Responsible for formatting individual gantt bars +//=================================================== +class GanttBar extends GanttPlotObject { + public $progress; + public $leftMark,$rightMark; + private $iEnd; + private $iHeightFactor=0.5; + private $iFillColor="white",$iFrameColor="black"; + private $iShadow=false,$iShadowColor="darkgray",$iShadowWidth=1,$iShadowFrame="black"; + private $iPattern=GANTT_RDIAG,$iPatternColor="blue",$iPatternDensity=95; + private $iBreakStyle=false, $iBreakLineStyle='dotted',$iBreakLineWeight=1; + //--------------- + // CONSTRUCTOR + function __construct($aPos,$aLabel,$aStart,$aEnd,$aCaption="",$aHeightFactor=0.6) { + parent::__construct(); + $this->iStart = $aStart; + // Is the end date given as a date or as number of days added to start date? + if( is_string($aEnd) ) { + // If end date has been specified without a time we will asssume + // end date is at the end of that date + if( strpos($aEnd,':') === false ) { + $this->iEnd = strtotime($aEnd)+SECPERDAY-1; + } + else { + $this->iEnd = $aEnd; + } + } + elseif(is_int($aEnd) || is_float($aEnd) ) { + $this->iEnd = strtotime($aStart)+round($aEnd*SECPERDAY); + } + $this->iVPos = $aPos; + $this->iHeightFactor = $aHeightFactor; + $this->title->Set($aLabel); + $this->caption = new TextProperty($aCaption); + $this->caption->Align("left","center"); + $this->leftMark =new PlotMark(); + $this->leftMark->Hide(); + $this->rightMark=new PlotMark(); + $this->rightMark->Hide(); + $this->progress = new Progress(); + } + + //--------------- + // PUBLIC METHODS + function SetShadow($aShadow=true,$aColor="gray") { + $this->iShadow=$aShadow; + $this->iShadowColor=$aColor; + } + + function SetBreakStyle($aFlg=true,$aLineStyle='dotted',$aLineWeight=1) { + $this->iBreakStyle = $aFlg; + $this->iBreakLineStyle = $aLineStyle; + $this->iBreakLineWeight = $aLineWeight; + } + + function GetMaxDate() { + return $this->iEnd; + } + + function SetHeight($aHeight) { + $this->iHeightFactor = $aHeight; + } + + function SetColor($aColor) { + $this->iFrameColor = $aColor; + } + + function SetFillColor($aColor) { + $this->iFillColor = $aColor; + } + + function GetAbsHeight($aImg) { + if( is_int($this->iHeightFactor) || $this->leftMark->show || $this->rightMark->show ) { + $m=-1; + if( is_int($this->iHeightFactor) ) + $m = $this->iHeightFactor; + if( $this->leftMark->show ) + $m = max($m,$this->leftMark->width*2); + if( $this->rightMark->show ) + $m = max($m,$this->rightMark->width*2); + return $m; + } + else + return -1; + } + + function SetPattern($aPattern,$aColor="blue",$aDensity=95) { + $this->iPattern = $aPattern; + $this->iPatternColor = $aColor; + $this->iPatternDensity = $aDensity; + } + + function Stroke($aImg,$aScale) { + $factory = new RectPatternFactory(); + $prect = $factory->Create($this->iPattern,$this->iPatternColor); + $prect->SetDensity($this->iPatternDensity); + + // If height factor is specified as a float between 0,1 then we take it as meaning + // percetage of the scale width between horizontal line. + // If it is an integer > 1 we take it to mean the absolute height in pixels + if( $this->iHeightFactor > -0.0 && $this->iHeightFactor <= 1.1) + $vs = $aScale->GetVertSpacing()*$this->iHeightFactor; + elseif(is_int($this->iHeightFactor) && $this->iHeightFactor>2 && $this->iHeightFactor < 200 ) + $vs = $this->iHeightFactor; + else { + JpGraphError::RaiseL(6028,$this->iHeightFactor); + // ("Specified height (".$this->iHeightFactor.") for gantt bar is out of range."); + } + + // Clip date to min max dates to show + $st = $aScale->NormalizeDate($this->iStart); + $en = $aScale->NormalizeDate($this->iEnd); + + $limst = max($st,$aScale->iStartDate); + $limen = min($en,$aScale->iEndDate); + + $xt = round($aScale->TranslateDate($limst)); + $xb = round($aScale->TranslateDate($limen)); + $yt = round($aScale->TranslateVertPos($this->iVPos)-$vs-($aScale->GetVertSpacing()/2-$vs/2)); + $yb = round($aScale->TranslateVertPos($this->iVPos)-($aScale->GetVertSpacing()/2-$vs/2)); + $middle = round($yt+($yb-$yt)/2); + $this->StrokeActInfo($aImg,$aScale,$middle); + + // CSIM for title + if( ! empty($this->title->csimtarget) ) { + $colwidth = $this->title->GetColWidth($aImg); + $colstarts=array(); + $aScale->actinfo->GetColStart($aImg,$colstarts,true); + $n = min(count($colwidth),count($this->title->csimtarget)); + for( $i=0; $i < $n; ++$i ) { + $title_xt = $colstarts[$i]; + $title_xb = $title_xt + $colwidth[$i]; + $coords = "$title_xt,$yt,$title_xb,$yt,$title_xb,$yb,$title_xt,$yb"; + + if( ! empty($this->title->csimtarget[$i]) ) { + $this->csimarea .= "<area shape=\"poly\" coords=\"$coords\" href=\"".$this->title->csimtarget[$i]."\""; + + if( ! empty($this->title->csimwintarget[$i]) ) { + $this->csimarea .= "target=\"".$this->title->csimwintarget[$i]."\" "; + } + + if( ! empty($this->title->csimalt[$i]) ) { + $tmp = $this->title->csimalt[$i]; + $this->csimarea .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimarea .= " />\n"; + } + } + } + + // Check if the bar is totally outside the current scale range + if( $en < $aScale->iStartDate || $st > $aScale->iEndDate ) + return; + + + // Remember the positions for the bar + $this->SetConstrainPos($xt,$yt,$xb,$yb); + + + + $prect->ShowFrame(false); + $prect->SetBackground($this->iFillColor); + if( $this->iBreakStyle ) { + $aImg->SetColor($this->iFrameColor); + $olds = $aImg->SetLineStyle($this->iBreakLineStyle); + $oldw = $aImg->SetLineWeight($this->iBreakLineWeight); + $aImg->StyleLine($xt,$yt,$xb,$yt); + $aImg->StyleLine($xt,$yb,$xb,$yb); + $aImg->SetLineStyle($olds); + $aImg->SetLineWeight($oldw); + } + else { + if( $this->iShadow ) { + $aImg->SetColor($this->iFrameColor); + $aImg->ShadowRectangle($xt,$yt,$xb,$yb,$this->iFillColor,$this->iShadowWidth,$this->iShadowColor); + $prect->SetPos(new Rectangle($xt+1,$yt+1,$xb-$xt-$this->iShadowWidth-2,$yb-$yt-$this->iShadowWidth-2)); + $prect->Stroke($aImg); + } + else { + $prect->SetPos(new Rectangle($xt,$yt,$xb-$xt+1,$yb-$yt+1)); + $prect->Stroke($aImg); + $aImg->SetColor($this->iFrameColor); + $aImg->Rectangle($xt,$yt,$xb,$yb); + } + } + // CSIM for bar + if( ! empty($this->csimtarget) ) { + + $coords = "$xt,$yt,$xb,$yt,$xb,$yb,$xt,$yb"; + $this->csimarea .= "<area shape=\"poly\" coords=\"$coords\" href=\"".$this->csimtarget."\""; + + if( !empty($this->csimwintarget) ) { + $this->csimarea .= " target=\"".$this->csimwintarget."\" "; + } + + if( $this->csimalt != '' ) { + $tmp = $this->csimalt; + $this->csimarea .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimarea .= " />\n"; + } + + // Draw progress bar inside activity bar + if( $this->progress->iProgress > 0 ) { + + $xtp = $aScale->TranslateDate($st); + $xbp = $aScale->TranslateDate($en); + $len = ($xbp-$xtp)*$this->progress->iProgress; + + $endpos = $xtp+$len; + if( $endpos > $xt ) { + + // Take away the length of the progress that is not visible (before the start date) + $len -= ($xt-$xtp); + + // Is the the progress bar visible after the start date? + if( $xtp < $xt ) + $xtp = $xt; + + // Make sure that the progess bar doesn't extend over the end date + if( $xtp+$len-1 > $xb ) + $len = $xb - $xtp ; + + $prog = $factory->Create($this->progress->iPattern,$this->progress->iColor); + $prog->SetDensity($this->progress->iDensity); + $prog->SetBackground($this->progress->iFillColor); + $barheight = ($yb-$yt+1); + if( $this->iShadow ) + $barheight -= $this->iShadowWidth; + $progressheight = floor($barheight*$this->progress->iHeight); + $marg = ceil(($barheight-$progressheight)/2); + $pos = new Rectangle($xtp,$yt + $marg, $len,$barheight-2*$marg); + $prog->SetPos($pos); + $prog->Stroke($aImg); + } + } + + // We don't plot the end mark if the bar has been capped + if( $limst == $st ) { + $y = $middle; + // We treat the RIGHT and LEFT triangle mark a little bi + // special so that these marks are placed right under the + // bar. + if( $this->leftMark->GetType() == MARK_LEFTTRIANGLE ) { + $y = $yb ; + } + $this->leftMark->Stroke($aImg,$xt,$y); + } + if( $limen == $en ) { + $y = $middle; + // We treat the RIGHT and LEFT triangle mark a little bi + // special so that these marks are placed right under the + // bar. + if( $this->rightMark->GetType() == MARK_RIGHTTRIANGLE ) { + $y = $yb ; + } + $this->rightMark->Stroke($aImg,$xb,$y); + + $margin = $this->iCaptionMargin; + if( $this->rightMark->show ) + $margin += $this->rightMark->GetWidth(); + $this->caption->Stroke($aImg,$xb+$margin,$middle); + } + } +} + +//=================================================== +// CLASS MileStone +// Responsible for formatting individual milestones +//=================================================== +class MileStone extends GanttPlotObject { + public $mark; + + //--------------- + // CONSTRUCTOR + function __construct($aVPos,$aLabel,$aDate,$aCaption="") { + GanttPlotObject::__construct(); + $this->caption->Set($aCaption); + $this->caption->Align("left","center"); + $this->caption->SetFont(FF_FONT1,FS_BOLD); + $this->title->Set($aLabel); + $this->title->SetColor("darkred"); + $this->mark = new PlotMark(); + $this->mark->SetWidth(10); + $this->mark->SetType(MARK_DIAMOND); + $this->mark->SetColor("darkred"); + $this->mark->SetFillColor("darkred"); + $this->iVPos = $aVPos; + $this->iStart = $aDate; + } + + //--------------- + // PUBLIC METHODS + + function GetAbsHeight($aImg) { + return max($this->title->GetHeight($aImg),$this->mark->GetWidth()); + } + + function Stroke($aImg,$aScale) { + // Put the mark in the middle at the middle of the day + $d = $aScale->NormalizeDate($this->iStart)+SECPERDAY/2; + $x = $aScale->TranslateDate($d); + $y = $aScale->TranslateVertPos($this->iVPos)-($aScale->GetVertSpacing()/2); + + $this->StrokeActInfo($aImg,$aScale,$y); + + // CSIM for title + if( ! empty($this->title->csimtarget) ) { + + $yt = round($y - $this->title->GetHeight($aImg)/2); + $yb = round($y + $this->title->GetHeight($aImg)/2); + + $colwidth = $this->title->GetColWidth($aImg); + $colstarts=array(); + $aScale->actinfo->GetColStart($aImg,$colstarts,true); + $n = min(count($colwidth),count($this->title->csimtarget)); + for( $i=0; $i < $n; ++$i ) { + $title_xt = $colstarts[$i]; + $title_xb = $title_xt + $colwidth[$i]; + $coords = "$title_xt,$yt,$title_xb,$yt,$title_xb,$yb,$title_xt,$yb"; + + if( !empty($this->title->csimtarget[$i]) ) { + + $this->csimarea .= "<area shape=\"poly\" coords=\"$coords\" href=\"".$this->title->csimtarget[$i]."\""; + + if( !empty($this->title->csimwintarget[$i]) ) { + $this->csimarea .= "target=\"".$this->title->csimwintarget[$i]."\""; + } + + if( ! empty($this->title->csimalt[$i]) ) { + $tmp = $this->title->csimalt[$i]; + $this->csimarea .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimarea .= " />\n"; + } + } + } + + if( $d < $aScale->iStartDate || $d > $aScale->iEndDate ) + return; + + // Remember the coordinates for any constrains linking to + // this milestone + $w = $this->mark->GetWidth()/2; + $this->SetConstrainPos($x,round($y-$w),$x,round($y+$w)); + + // Setup CSIM + if( $this->csimtarget != '' ) { + $this->mark->SetCSIMTarget( $this->csimtarget ); + $this->mark->SetCSIMAlt( $this->csimalt ); + } + + $this->mark->Stroke($aImg,$x,$y); + $this->caption->Stroke($aImg,$x+$this->mark->width/2+$this->iCaptionMargin,$y); + + $this->csimarea .= $this->mark->GetCSIMAreas(); + } +} + + +//=================================================== +// CLASS GanttVLine +// Responsible for formatting individual milestones +//=================================================== + +class TextPropertyBelow extends TextProperty { + function __construct($aTxt='') { + parent::__construct($aTxt); + } + + function GetColWidth($aImg,$aMargin=0) { + // Since we are not stroking the title in the columns + // but rather under the graph we want this to return 0. + return array(0); + } +} + +class GanttVLine extends GanttPlotObject { + + private $iLine,$title_margin=3, $iDayOffset=0.5; + private $iStartRow = -1, $iEndRow = -1; + + //--------------- + // CONSTRUCTOR + function __construct($aDate,$aTitle="",$aColor="darkred",$aWeight=2,$aStyle="solid") { + GanttPlotObject::__construct(); + $this->iLine = new LineProperty(); + $this->iLine->SetColor($aColor); + $this->iLine->SetWeight($aWeight); + $this->iLine->SetStyle($aStyle); + $this->iStart = $aDate; + $this->title = new TextPropertyBelow(); + $this->title->Set($aTitle); + } + + //--------------- + // PUBLIC METHODS + + // Set start and end rows for the VLine. By default the entire heigh of the + // Gantt chart is used + function SetRowSpan($aStart, $aEnd=-1) { + $this->iStartRow = $aStart; + $this->iEndRow = $aEnd; + } + + function SetDayOffset($aOff=0.5) { + if( $aOff < 0.0 || $aOff > 1.0 ) { + JpGraphError::RaiseL(6029); + //("Offset for vertical line must be in range [0,1]"); + } + $this->iDayOffset = $aOff; + } + + function SetTitleMargin($aMarg) { + $this->title_margin = $aMarg; + } + + function SetWeight($aWeight) { + $this->iLine->SetWeight($aWeight); + } + + function Stroke($aImg,$aScale) { + $d = $aScale->NormalizeDate($this->iStart); + if( $d < $aScale->iStartDate || $d > $aScale->iEndDate ) + return; + if($this->iDayOffset != 0.0) + $d += 24*60*60*$this->iDayOffset; + $x = $aScale->TranslateDate($d);//d=1006858800, + + if( $this->iStartRow > -1 ) { + $y1 = $aScale->TranslateVertPos($this->iStartRow,true) ; + } + else { + $y1 = $aScale->iVertHeaderSize+$aImg->top_margin; + } + + if( $this->iEndRow > -1 ) { + $y2 = $aScale->TranslateVertPos($this->iEndRow); + } + else { + $y2 = $aImg->height - $aImg->bottom_margin; + } + + $this->iLine->Stroke($aImg,$x,$y1,$x,$y2); + $this->title->Align("center","top"); + $this->title->Stroke($aImg,$x,$y2+$this->title_margin); + } +} + +//=================================================== +// CLASS LinkArrow +// Handles the drawing of a an arrow +//=================================================== +class LinkArrow { + private $ix,$iy; + private $isizespec = array( + array(2,3),array(3,5),array(3,8),array(6,15),array(8,22)); + private $iDirection=ARROW_DOWN,$iType=ARROWT_SOLID,$iSize=ARROW_S2; + private $iColor='black'; + + function __construct($x,$y,$aDirection,$aType=ARROWT_SOLID,$aSize=ARROW_S2) { + $this->iDirection = $aDirection; + $this->iType = $aType; + $this->iSize = $aSize; + $this->ix = $x; + $this->iy = $y; + } + + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function SetSize($aSize) { + $this->iSize = $aSize; + } + + function SetType($aType) { + $this->iType = $aType; + } + + function Stroke($aImg) { + list($dx,$dy) = $this->isizespec[$this->iSize]; + $x = $this->ix; + $y = $this->iy; + switch ( $this->iDirection ) { + case ARROW_DOWN: + $c = array($x,$y,$x-$dx,$y-$dy,$x+$dx,$y-$dy,$x,$y); + break; + case ARROW_UP: + $c = array($x,$y,$x-$dx,$y+$dy,$x+$dx,$y+$dy,$x,$y); + break; + case ARROW_LEFT: + $c = array($x,$y,$x+$dy,$y-$dx,$x+$dy,$y+$dx,$x,$y); + break; + case ARROW_RIGHT: + $c = array($x,$y,$x-$dy,$y-$dx,$x-$dy,$y+$dx,$x,$y); + break; + default: + JpGraphError::RaiseL(6030); + //('Unknown arrow direction for link.'); + die(); + break; + } + $aImg->SetColor($this->iColor); + switch( $this->iType ) { + case ARROWT_SOLID: + $aImg->FilledPolygon($c); + break; + case ARROWT_OPEN: + $aImg->Polygon($c); + break; + default: + JpGraphError::RaiseL(6031); + //('Unknown arrow type for link.'); + die(); + break; + } + } +} + +//=================================================== +// CLASS GanttLink +// Handles the drawing of a link line between 2 points +//=================================================== + +class GanttLink { + private $ix1,$ix2,$iy1,$iy2; + private $iPathType=2,$iPathExtend=15; + private $iColor='black',$iWeight=1; + private $iArrowSize=ARROW_S2,$iArrowType=ARROWT_SOLID; + + function __construct($x1=0,$y1=0,$x2=0,$y2=0) { + $this->ix1 = $x1; + $this->ix2 = $x2; + $this->iy1 = $y1; + $this->iy2 = $y2; + } + + function SetPos($x1,$y1,$x2,$y2) { + $this->ix1 = $x1; + $this->ix2 = $x2; + $this->iy1 = $y1; + $this->iy2 = $y2; + } + + function SetPath($aPath) { + $this->iPathType = $aPath; + } + + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function SetArrow($aSize,$aType=ARROWT_SOLID) { + $this->iArrowSize = $aSize; + $this->iArrowType = $aType; + } + + function SetWeight($aWeight) { + $this->iWeight = $aWeight; + } + + function Stroke($aImg) { + // The way the path for the arrow is constructed is partly based + // on some heuristics. This is not an exact science but draws the + // path in a way that, for me, makes esthetic sence. For example + // if the start and end activities are very close we make a small + // detour to endter the target horixontally. If there are more + // space between axctivities then no suh detour is made and the + // target is "hit" directly vertical. I have tried to keep this + // simple. no doubt this could become almost infinitive complex + // and have some real AI. Feel free to modify this. + // This will no-doubt be tweaked as times go by. One design aim + // is to avoid having the user choose what types of arrow + // he wants. + + // The arrow is drawn between (x1,y1) to (x2,y2) + $x1 = $this->ix1 ; + $x2 = $this->ix2 ; + $y1 = $this->iy1 ; + $y2 = $this->iy2 ; + + // Depending on if the target is below or above we have to + // handle thi different. + if( $y2 > $y1 ) { + $arrowtype = ARROW_DOWN; + $midy = round(($y2-$y1)/2+$y1); + if( $x2 > $x1 ) { + switch ( $this->iPathType ) { + case 0: + $c = array($x1,$y1,$x1,$midy,$x2,$midy,$x2,$y2); + break; + case 1: + case 2: + case 3: + $c = array($x1,$y1,$x2,$y1,$x2,$y2); + break; + default: + JpGraphError::RaiseL(6032,$this->iPathType); + //('Internal error: Unknown path type (='.$this->iPathType .') specified for link.'); + exit(1); + break; + } + } + else { + switch ( $this->iPathType ) { + case 0: + case 1: + $c = array($x1,$y1,$x1,$midy,$x2,$midy,$x2,$y2); + break; + case 2: + // Always extend out horizontally a bit from the first point + // If we draw a link back in time (end to start) and the bars + // are very close we also change the path so it comes in from + // the left on the activity + $c = array($x1,$y1,$x1+$this->iPathExtend,$y1, + $x1+$this->iPathExtend,$midy, + $x2,$midy,$x2,$y2); + break; + case 3: + if( $y2-$midy < 6 ) { + $c = array($x1,$y1,$x1,$midy, + $x2-$this->iPathExtend,$midy, + $x2-$this->iPathExtend,$y2, + $x2,$y2); + $arrowtype = ARROW_RIGHT; + } + else { + $c = array($x1,$y1,$x1,$midy,$x2,$midy,$x2,$y2); + } + break; + default: + JpGraphError::RaiseL(6032,$this->iPathType); + //('Internal error: Unknown path type specified for link.'); + exit(1); + break; + } + } + $arrow = new LinkArrow($x2,$y2,$arrowtype); + } + else { + // Y2 < Y1 + $arrowtype = ARROW_UP; + $midy = round(($y1-$y2)/2+$y2); + if( $x2 > $x1 ) { + switch ( $this->iPathType ) { + case 0: + case 1: + $c = array($x1,$y1,$x1,$midy,$x2,$midy,$x2,$y2); + break; + case 3: + if( $midy-$y2 < 8 ) { + $arrowtype = ARROW_RIGHT; + $c = array($x1,$y1,$x1,$y2,$x2,$y2); + } + else { + $c = array($x1,$y1,$x1,$midy,$x2,$midy,$x2,$y2); + } + break; + default: + JpGraphError::RaiseL(6032,$this->iPathType); + //('Internal error: Unknown path type specified for link.'); + break; + } + } + else { + switch ( $this->iPathType ) { + case 0: + case 1: + $c = array($x1,$y1,$x1,$midy,$x2,$midy,$x2,$y2); + break; + case 2: + // Always extend out horizontally a bit from the first point + $c = array($x1,$y1,$x1+$this->iPathExtend,$y1, + $x1+$this->iPathExtend,$midy, + $x2,$midy,$x2,$y2); + break; + case 3: + if( $midy-$y2 < 16 ) { + $arrowtype = ARROW_RIGHT; + $c = array($x1,$y1,$x1,$midy,$x2-$this->iPathExtend,$midy, + $x2-$this->iPathExtend,$y2, + $x2,$y2); + } + else { + $c = array($x1,$y1,$x1,$midy,$x2,$midy,$x2,$y2); + } + break; + default: + JpGraphError::RaiseL(6032,$this->iPathType); + //('Internal error: Unknown path type specified for link.'); + break; + } + } + $arrow = new LinkArrow($x2,$y2,$arrowtype); + } + $aImg->SetColor($this->iColor); + $aImg->SetLineWeight($this->iWeight); + $aImg->Polygon($c); + $aImg->SetLineWeight(1); + $arrow->SetColor($this->iColor); + $arrow->SetSize($this->iArrowSize); + $arrow->SetType($this->iArrowType); + $arrow->Stroke($aImg); + } +} + +// <EOF> +?> diff --git a/html/jpgraph/jpgraph_gb2312.php b/html/jpgraph/jpgraph_gb2312.php new file mode 100644 index 0000000..eff07cb --- /dev/null +++ b/html/jpgraph/jpgraph_gb2312.php @@ -0,0 +1,1552 @@ +<?php +//======================================================================= +// File: JPGRAPH_GB2312.PHP +// Description: Chinese font conversions +// Created: 2003-05-30 +// Ver: $Id: jpgraph_gb2312.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +class GB2312toUTF8 { + // -------------------------------------------------------------------- + // This code table is used to translate GB2312 code (key) to + // it's corresponding Unicode value (data) + // -------------------------------------------------------------------- + private $codetable = array( + 8481 => 12288, 8482 => 12289, 8483 => 12290, 8484 => 12539, 8485 => 713, + 8486 => 711, 8487 => 168, 8488 => 12291, 8489 => 12293, 8490 => 8213, + 8491 => 65374, 8492 => 8214, 8493 => 8230, 8494 => 8216, 8495 => 8217, + 8496 => 8220, 8497 => 8221, 8498 => 12308, 8499 => 12309, 8500 => 12296, + 8501 => 12297, 8502 => 12298, 8503 => 12299, 8504 => 12300, 8505 => 12301, + 8506 => 12302, 8507 => 12303, 8508 => 12310, 8509 => 12311, 8510 => 12304, + 8511 => 12305, 8512 => 177, 8513 => 215, 8514 => 247, 8515 => 8758, + 8516 => 8743, 8517 => 8744, 8518 => 8721, 8519 => 8719, 8520 => 8746, + 8521 => 8745, 8522 => 8712, 8523 => 8759, 8524 => 8730, 8525 => 8869, + 8526 => 8741, 8527 => 8736, 8528 => 8978, 8529 => 8857, 8530 => 8747, + 8531 => 8750, 8532 => 8801, 8533 => 8780, 8534 => 8776, 8535 => 8765, + 8536 => 8733, 8537 => 8800, 8538 => 8814, 8539 => 8815, 8540 => 8804, + 8541 => 8805, 8542 => 8734, 8543 => 8757, 8544 => 8756, 8545 => 9794, + 8546 => 9792, 8547 => 176, 8548 => 8242, 8549 => 8243, 8550 => 8451, + 8551 => 65284, 8552 => 164, 8553 => 65504, 8554 => 65505, 8555 => 8240, + 8556 => 167, 8557 => 8470, 8558 => 9734, 8559 => 9733, 8560 => 9675, + 8561 => 9679, 8562 => 9678, 8563 => 9671, 8564 => 9670, 8565 => 9633, + 8566 => 9632, 8567 => 9651, 8568 => 9650, 8569 => 8251, 8570 => 8594, + 8571 => 8592, 8572 => 8593, 8573 => 8595, 8574 => 12307, 8753 => 9352, + 8754 => 9353, 8755 => 9354, 8756 => 9355, 8757 => 9356, 8758 => 9357, + 8759 => 9358, 8760 => 9359, 8761 => 9360, 8762 => 9361, 8763 => 9362, + 8764 => 9363, 8765 => 9364, 8766 => 9365, 8767 => 9366, 8768 => 9367, + 8769 => 9368, 8770 => 9369, 8771 => 9370, 8772 => 9371, 8773 => 9332, + 8774 => 9333, 8775 => 9334, 8776 => 9335, 8777 => 9336, 8778 => 9337, + 8779 => 9338, 8780 => 9339, 8781 => 9340, 8782 => 9341, 8783 => 9342, + 8784 => 9343, 8785 => 9344, 8786 => 9345, 8787 => 9346, 8788 => 9347, + 8789 => 9348, 8790 => 9349, 8791 => 9350, 8792 => 9351, 8793 => 9312, + 8794 => 9313, 8795 => 9314, 8796 => 9315, 8797 => 9316, 8798 => 9317, + 8799 => 9318, 8800 => 9319, 8801 => 9320, 8802 => 9321, 8805 => 12832, + 8806 => 12833, 8807 => 12834, 8808 => 12835, 8809 => 12836, 8810 => 12837, + 8811 => 12838, 8812 => 12839, 8813 => 12840, 8814 => 12841, 8817 => 8544, + 8818 => 8545, 8819 => 8546, 8820 => 8547, 8821 => 8548, 8822 => 8549, + 8823 => 8550, 8824 => 8551, 8825 => 8552, 8826 => 8553, 8827 => 8554, + 8828 => 8555, 8993 => 65281, 8994 => 65282, 8995 => 65283, 8996 => 65509, + 8997 => 65285, 8998 => 65286, 8999 => 65287, 9000 => 65288, 9001 => 65289, + 9002 => 65290, 9003 => 65291, 9004 => 65292, 9005 => 65293, 9006 => 65294, + 9007 => 65295, 9008 => 65296, 9009 => 65297, 9010 => 65298, 9011 => 65299, + 9012 => 65300, 9013 => 65301, 9014 => 65302, 9015 => 65303, 9016 => 65304, + 9017 => 65305, 9018 => 65306, 9019 => 65307, 9020 => 65308, 9021 => 65309, + 9022 => 65310, 9023 => 65311, 9024 => 65312, 9025 => 65313, 9026 => 65314, + 9027 => 65315, 9028 => 65316, 9029 => 65317, 9030 => 65318, 9031 => 65319, + 9032 => 65320, 9033 => 65321, 9034 => 65322, 9035 => 65323, 9036 => 65324, + 9037 => 65325, 9038 => 65326, 9039 => 65327, 9040 => 65328, 9041 => 65329, + 9042 => 65330, 9043 => 65331, 9044 => 65332, 9045 => 65333, 9046 => 65334, + 9047 => 65335, 9048 => 65336, 9049 => 65337, 9050 => 65338, 9051 => 65339, + 9052 => 65340, 9053 => 65341, 9054 => 65342, 9055 => 65343, 9056 => 65344, + 9057 => 65345, 9058 => 65346, 9059 => 65347, 9060 => 65348, 9061 => 65349, + 9062 => 65350, 9063 => 65351, 9064 => 65352, 9065 => 65353, 9066 => 65354, + 9067 => 65355, 9068 => 65356, 9069 => 65357, 9070 => 65358, 9071 => 65359, + 9072 => 65360, 9073 => 65361, 9074 => 65362, 9075 => 65363, 9076 => 65364, + 9077 => 65365, 9078 => 65366, 9079 => 65367, 9080 => 65368, 9081 => 65369, + 9082 => 65370, 9083 => 65371, 9084 => 65372, 9085 => 65373, 9086 => 65507, + 9249 => 12353, 9250 => 12354, 9251 => 12355, 9252 => 12356, 9253 => 12357, + 9254 => 12358, 9255 => 12359, 9256 => 12360, 9257 => 12361, 9258 => 12362, + 9259 => 12363, 9260 => 12364, 9261 => 12365, 9262 => 12366, 9263 => 12367, + 9264 => 12368, 9265 => 12369, 9266 => 12370, 9267 => 12371, 9268 => 12372, + 9269 => 12373, 9270 => 12374, 9271 => 12375, 9272 => 12376, 9273 => 12377, + 9274 => 12378, 9275 => 12379, 9276 => 12380, 9277 => 12381, 9278 => 12382, + 9279 => 12383, 9280 => 12384, 9281 => 12385, 9282 => 12386, 9283 => 12387, + 9284 => 12388, 9285 => 12389, 9286 => 12390, 9287 => 12391, 9288 => 12392, + 9289 => 12393, 9290 => 12394, 9291 => 12395, 9292 => 12396, 9293 => 12397, + 9294 => 12398, 9295 => 12399, 9296 => 12400, 9297 => 12401, 9298 => 12402, + 9299 => 12403, 9300 => 12404, 9301 => 12405, 9302 => 12406, 9303 => 12407, + 9304 => 12408, 9305 => 12409, 9306 => 12410, 9307 => 12411, 9308 => 12412, + 9309 => 12413, 9310 => 12414, 9311 => 12415, 9312 => 12416, 9313 => 12417, + 9314 => 12418, 9315 => 12419, 9316 => 12420, 9317 => 12421, 9318 => 12422, + 9319 => 12423, 9320 => 12424, 9321 => 12425, 9322 => 12426, 9323 => 12427, + 9324 => 12428, 9325 => 12429, 9326 => 12430, 9327 => 12431, 9328 => 12432, + 9329 => 12433, 9330 => 12434, 9331 => 12435, 9505 => 12449, 9506 => 12450, + 9507 => 12451, 9508 => 12452, 9509 => 12453, 9510 => 12454, 9511 => 12455, + 9512 => 12456, 9513 => 12457, 9514 => 12458, 9515 => 12459, 9516 => 12460, + 9517 => 12461, 9518 => 12462, 9519 => 12463, 9520 => 12464, 9521 => 12465, + 9522 => 12466, 9523 => 12467, 9524 => 12468, 9525 => 12469, 9526 => 12470, + 9527 => 12471, 9528 => 12472, 9529 => 12473, 9530 => 12474, 9531 => 12475, + 9532 => 12476, 9533 => 12477, 9534 => 12478, 9535 => 12479, 9536 => 12480, + 9537 => 12481, 9538 => 12482, 9539 => 12483, 9540 => 12484, 9541 => 12485, + 9542 => 12486, 9543 => 12487, 9544 => 12488, 9545 => 12489, 9546 => 12490, + 9547 => 12491, 9548 => 12492, 9549 => 12493, 9550 => 12494, 9551 => 12495, + 9552 => 12496, 9553 => 12497, 9554 => 12498, 9555 => 12499, 9556 => 12500, + 9557 => 12501, 9558 => 12502, 9559 => 12503, 9560 => 12504, 9561 => 12505, + 9562 => 12506, 9563 => 12507, 9564 => 12508, 9565 => 12509, 9566 => 12510, + 9567 => 12511, 9568 => 12512, 9569 => 12513, 9570 => 12514, 9571 => 12515, + 9572 => 12516, 9573 => 12517, 9574 => 12518, 9575 => 12519, 9576 => 12520, + 9577 => 12521, 9578 => 12522, 9579 => 12523, 9580 => 12524, 9581 => 12525, + 9582 => 12526, 9583 => 12527, 9584 => 12528, 9585 => 12529, 9586 => 12530, + 9587 => 12531, 9588 => 12532, 9589 => 12533, 9590 => 12534, 9761 => 913, + 9762 => 914, 9763 => 915, 9764 => 916, 9765 => 917, 9766 => 918, + 9767 => 919, 9768 => 920, 9769 => 921, 9770 => 922, 9771 => 923, + 9772 => 924, 9773 => 925, 9774 => 926, 9775 => 927, 9776 => 928, + 9777 => 929, 9778 => 931, 9779 => 932, 9780 => 933, 9781 => 934, + 9782 => 935, 9783 => 936, 9784 => 937, 9793 => 945, 9794 => 946, + 9795 => 947, 9796 => 948, 9797 => 949, 9798 => 950, 9799 => 951, + 9800 => 952, 9801 => 953, 9802 => 954, 9803 => 955, 9804 => 956, + 9805 => 957, 9806 => 958, 9807 => 959, 9808 => 960, 9809 => 961, + 9810 => 963, 9811 => 964, 9812 => 965, 9813 => 966, 9814 => 967, + 9815 => 968, 9816 => 969, 10017 => 1040, 10018 => 1041, 10019 => 1042, + 10020 => 1043, 10021 => 1044, 10022 => 1045, 10023 => 1025, 10024 => 1046, + 10025 => 1047, 10026 => 1048, 10027 => 1049, 10028 => 1050, 10029 => 1051, + 10030 => 1052, 10031 => 1053, 10032 => 1054, 10033 => 1055, 10034 => 1056, + 10035 => 1057, 10036 => 1058, 10037 => 1059, 10038 => 1060, 10039 => 1061, + 10040 => 1062, 10041 => 1063, 10042 => 1064, 10043 => 1065, 10044 => 1066, + 10045 => 1067, 10046 => 1068, 10047 => 1069, 10048 => 1070, 10049 => 1071, + 10065 => 1072, 10066 => 1073, 10067 => 1074, 10068 => 1075, 10069 => 1076, + 10070 => 1077, 10071 => 1105, 10072 => 1078, 10073 => 1079, 10074 => 1080, + 10075 => 1081, 10076 => 1082, 10077 => 1083, 10078 => 1084, 10079 => 1085, + 10080 => 1086, 10081 => 1087, 10082 => 1088, 10083 => 1089, 10084 => 1090, + 10085 => 1091, 10086 => 1092, 10087 => 1093, 10088 => 1094, 10089 => 1095, + 10090 => 1096, 10091 => 1097, 10092 => 1098, 10093 => 1099, 10094 => 1100, + 10095 => 1101, 10096 => 1102, 10097 => 1103, 10273 => 257, 10274 => 225, + 10275 => 462, 10276 => 224, 10277 => 275, 10278 => 233, 10279 => 283, + 10280 => 232, 10281 => 299, 10282 => 237, 10283 => 464, 10284 => 236, + 10285 => 333, 10286 => 243, 10287 => 466, 10288 => 242, 10289 => 363, + 10290 => 250, 10291 => 468, 10292 => 249, 10293 => 470, 10294 => 472, + 10295 => 474, 10296 => 476, 10297 => 252, 10298 => 234, 10309 => 12549, + 10310 => 12550, 10311 => 12551, 10312 => 12552, 10313 => 12553, 10314 => 12554, + 10315 => 12555, 10316 => 12556, 10317 => 12557, 10318 => 12558, 10319 => 12559, + 10320 => 12560, 10321 => 12561, 10322 => 12562, 10323 => 12563, 10324 => 12564, + 10325 => 12565, 10326 => 12566, 10327 => 12567, 10328 => 12568, 10329 => 12569, + 10330 => 12570, 10331 => 12571, 10332 => 12572, 10333 => 12573, 10334 => 12574, + 10335 => 12575, 10336 => 12576, 10337 => 12577, 10338 => 12578, 10339 => 12579, + 10340 => 12580, 10341 => 12581, 10342 => 12582, 10343 => 12583, 10344 => 12584, + 10345 => 12585, 10532 => 9472, 10533 => 9473, 10534 => 9474, 10535 => 9475, + 10536 => 9476, 10537 => 9477, 10538 => 9478, 10539 => 9479, 10540 => 9480, + 10541 => 9481, 10542 => 9482, 10543 => 9483, 10544 => 9484, 10545 => 9485, + 10546 => 9486, 10547 => 9487, 10548 => 9488, 10549 => 9489, 10550 => 9490, + 10551 => 9491, 10552 => 9492, 10553 => 9493, 10554 => 9494, 10555 => 9495, + 10556 => 9496, 10557 => 9497, 10558 => 9498, 10559 => 9499, 10560 => 9500, + 10561 => 9501, 10562 => 9502, 10563 => 9503, 10564 => 9504, 10565 => 9505, + 10566 => 9506, 10567 => 9507, 10568 => 9508, 10569 => 9509, 10570 => 9510, + 10571 => 9511, 10572 => 9512, 10573 => 9513, 10574 => 9514, 10575 => 9515, + 10576 => 9516, 10577 => 9517, 10578 => 9518, 10579 => 9519, 10580 => 9520, + 10581 => 9521, 10582 => 9522, 10583 => 9523, 10584 => 9524, 10585 => 9525, + 10586 => 9526, 10587 => 9527, 10588 => 9528, 10589 => 9529, 10590 => 9530, + 10591 => 9531, 10592 => 9532, 10593 => 9533, 10594 => 9534, 10595 => 9535, + 10596 => 9536, 10597 => 9537, 10598 => 9538, 10599 => 9539, 10600 => 9540, + 10601 => 9541, 10602 => 9542, 10603 => 9543, 10604 => 9544, 10605 => 9545, + 10606 => 9546, 10607 => 9547, 12321 => 21834, 12322 => 38463, 12323 => 22467, + 12324 => 25384, 12325 => 21710, 12326 => 21769, 12327 => 21696, 12328 => 30353, + 12329 => 30284, 12330 => 34108, 12331 => 30702, 12332 => 33406, 12333 => 30861, + 12334 => 29233, 12335 => 38552, 12336 => 38797, 12337 => 27688, 12338 => 23433, + 12339 => 20474, 12340 => 25353, 12341 => 26263, 12342 => 23736, 12343 => 33018, + 12344 => 26696, 12345 => 32942, 12346 => 26114, 12347 => 30414, 12348 => 20985, + 12349 => 25942, 12350 => 29100, 12351 => 32753, 12352 => 34948, 12353 => 20658, + 12354 => 22885, 12355 => 25034, 12356 => 28595, 12357 => 33453, 12358 => 25420, + 12359 => 25170, 12360 => 21485, 12361 => 21543, 12362 => 31494, 12363 => 20843, + 12364 => 30116, 12365 => 24052, 12366 => 25300, 12367 => 36299, 12368 => 38774, + 12369 => 25226, 12370 => 32793, 12371 => 22365, 12372 => 38712, 12373 => 32610, + 12374 => 29240, 12375 => 30333, 12376 => 26575, 12377 => 30334, 12378 => 25670, + 12379 => 20336, 12380 => 36133, 12381 => 25308, 12382 => 31255, 12383 => 26001, + 12384 => 29677, 12385 => 25644, 12386 => 25203, 12387 => 33324, 12388 => 39041, + 12389 => 26495, 12390 => 29256, 12391 => 25198, 12392 => 25292, 12393 => 20276, + 12394 => 29923, 12395 => 21322, 12396 => 21150, 12397 => 32458, 12398 => 37030, + 12399 => 24110, 12400 => 26758, 12401 => 27036, 12402 => 33152, 12403 => 32465, + 12404 => 26834, 12405 => 30917, 12406 => 34444, 12407 => 38225, 12408 => 20621, + 12409 => 35876, 12410 => 33502, 12411 => 32990, 12412 => 21253, 12413 => 35090, + 12414 => 21093, 12577 => 34180, 12578 => 38649, 12579 => 20445, 12580 => 22561, + 12581 => 39281, 12582 => 23453, 12583 => 25265, 12584 => 25253, 12585 => 26292, + 12586 => 35961, 12587 => 40077, 12588 => 29190, 12589 => 26479, 12590 => 30865, + 12591 => 24754, 12592 => 21329, 12593 => 21271, 12594 => 36744, 12595 => 32972, + 12596 => 36125, 12597 => 38049, 12598 => 20493, 12599 => 29384, 12600 => 22791, + 12601 => 24811, 12602 => 28953, 12603 => 34987, 12604 => 22868, 12605 => 33519, + 12606 => 26412, 12607 => 31528, 12608 => 23849, 12609 => 32503, 12610 => 29997, + 12611 => 27893, 12612 => 36454, 12613 => 36856, 12614 => 36924, 12615 => 40763, + 12616 => 27604, 12617 => 37145, 12618 => 31508, 12619 => 24444, 12620 => 30887, + 12621 => 34006, 12622 => 34109, 12623 => 27605, 12624 => 27609, 12625 => 27606, + 12626 => 24065, 12627 => 24199, 12628 => 30201, 12629 => 38381, 12630 => 25949, + 12631 => 24330, 12632 => 24517, 12633 => 36767, 12634 => 22721, 12635 => 33218, + 12636 => 36991, 12637 => 38491, 12638 => 38829, 12639 => 36793, 12640 => 32534, + 12641 => 36140, 12642 => 25153, 12643 => 20415, 12644 => 21464, 12645 => 21342, + 12646 => 36776, 12647 => 36777, 12648 => 36779, 12649 => 36941, 12650 => 26631, + 12651 => 24426, 12652 => 33176, 12653 => 34920, 12654 => 40150, 12655 => 24971, + 12656 => 21035, 12657 => 30250, 12658 => 24428, 12659 => 25996, 12660 => 28626, + 12661 => 28392, 12662 => 23486, 12663 => 25672, 12664 => 20853, 12665 => 20912, + 12666 => 26564, 12667 => 19993, 12668 => 31177, 12669 => 39292, 12670 => 28851, + 12833 => 30149, 12834 => 24182, 12835 => 29627, 12836 => 33760, 12837 => 25773, + 12838 => 25320, 12839 => 38069, 12840 => 27874, 12841 => 21338, 12842 => 21187, + 12843 => 25615, 12844 => 38082, 12845 => 31636, 12846 => 20271, 12847 => 24091, + 12848 => 33334, 12849 => 33046, 12850 => 33162, 12851 => 28196, 12852 => 27850, + 12853 => 39539, 12854 => 25429, 12855 => 21340, 12856 => 21754, 12857 => 34917, + 12858 => 22496, 12859 => 19981, 12860 => 24067, 12861 => 27493, 12862 => 31807, + 12863 => 37096, 12864 => 24598, 12865 => 25830, 12866 => 29468, 12867 => 35009, + 12868 => 26448, 12869 => 25165, 12870 => 36130, 12871 => 30572, 12872 => 36393, + 12873 => 37319, 12874 => 24425, 12875 => 33756, 12876 => 34081, 12877 => 39184, + 12878 => 21442, 12879 => 34453, 12880 => 27531, 12881 => 24813, 12882 => 24808, + 12883 => 28799, 12884 => 33485, 12885 => 33329, 12886 => 20179, 12887 => 27815, + 12888 => 34255, 12889 => 25805, 12890 => 31961, 12891 => 27133, 12892 => 26361, + 12893 => 33609, 12894 => 21397, 12895 => 31574, 12896 => 20391, 12897 => 20876, + 12898 => 27979, 12899 => 23618, 12900 => 36461, 12901 => 25554, 12902 => 21449, + 12903 => 33580, 12904 => 33590, 12905 => 26597, 12906 => 30900, 12907 => 25661, + 12908 => 23519, 12909 => 23700, 12910 => 24046, 12911 => 35815, 12912 => 25286, + 12913 => 26612, 12914 => 35962, 12915 => 25600, 12916 => 25530, 12917 => 34633, + 12918 => 39307, 12919 => 35863, 12920 => 32544, 12921 => 38130, 12922 => 20135, + 12923 => 38416, 12924 => 39076, 12925 => 26124, 12926 => 29462, 13089 => 22330, + 13090 => 23581, 13091 => 24120, 13092 => 38271, 13093 => 20607, 13094 => 32928, + 13095 => 21378, 13096 => 25950, 13097 => 30021, 13098 => 21809, 13099 => 20513, + 13100 => 36229, 13101 => 25220, 13102 => 38046, 13103 => 26397, 13104 => 22066, + 13105 => 28526, 13106 => 24034, 13107 => 21557, 13108 => 28818, 13109 => 36710, + 13110 => 25199, 13111 => 25764, 13112 => 25507, 13113 => 24443, 13114 => 28552, + 13115 => 37108, 13116 => 33251, 13117 => 36784, 13118 => 23576, 13119 => 26216, + 13120 => 24561, 13121 => 27785, 13122 => 38472, 13123 => 36225, 13124 => 34924, + 13125 => 25745, 13126 => 31216, 13127 => 22478, 13128 => 27225, 13129 => 25104, + 13130 => 21576, 13131 => 20056, 13132 => 31243, 13133 => 24809, 13134 => 28548, + 13135 => 35802, 13136 => 25215, 13137 => 36894, 13138 => 39563, 13139 => 31204, + 13140 => 21507, 13141 => 30196, 13142 => 25345, 13143 => 21273, 13144 => 27744, + 13145 => 36831, 13146 => 24347, 13147 => 39536, 13148 => 32827, 13149 => 40831, + 13150 => 20360, 13151 => 23610, 13152 => 36196, 13153 => 32709, 13154 => 26021, + 13155 => 28861, 13156 => 20805, 13157 => 20914, 13158 => 34411, 13159 => 23815, + 13160 => 23456, 13161 => 25277, 13162 => 37228, 13163 => 30068, 13164 => 36364, + 13165 => 31264, 13166 => 24833, 13167 => 31609, 13168 => 20167, 13169 => 32504, + 13170 => 30597, 13171 => 19985, 13172 => 33261, 13173 => 21021, 13174 => 20986, + 13175 => 27249, 13176 => 21416, 13177 => 36487, 13178 => 38148, 13179 => 38607, + 13180 => 28353, 13181 => 38500, 13182 => 26970, 13345 => 30784, 13346 => 20648, + 13347 => 30679, 13348 => 25616, 13349 => 35302, 13350 => 22788, 13351 => 25571, + 13352 => 24029, 13353 => 31359, 13354 => 26941, 13355 => 20256, 13356 => 33337, + 13357 => 21912, 13358 => 20018, 13359 => 30126, 13360 => 31383, 13361 => 24162, + 13362 => 24202, 13363 => 38383, 13364 => 21019, 13365 => 21561, 13366 => 28810, + 13367 => 25462, 13368 => 38180, 13369 => 22402, 13370 => 26149, 13371 => 26943, + 13372 => 37255, 13373 => 21767, 13374 => 28147, 13375 => 32431, 13376 => 34850, + 13377 => 25139, 13378 => 32496, 13379 => 30133, 13380 => 33576, 13381 => 30913, + 13382 => 38604, 13383 => 36766, 13384 => 24904, 13385 => 29943, 13386 => 35789, + 13387 => 27492, 13388 => 21050, 13389 => 36176, 13390 => 27425, 13391 => 32874, + 13392 => 33905, 13393 => 22257, 13394 => 21254, 13395 => 20174, 13396 => 19995, + 13397 => 20945, 13398 => 31895, 13399 => 37259, 13400 => 31751, 13401 => 20419, + 13402 => 36479, 13403 => 31713, 13404 => 31388, 13405 => 25703, 13406 => 23828, + 13407 => 20652, 13408 => 33030, 13409 => 30209, 13410 => 31929, 13411 => 28140, + 13412 => 32736, 13413 => 26449, 13414 => 23384, 13415 => 23544, 13416 => 30923, + 13417 => 25774, 13418 => 25619, 13419 => 25514, 13420 => 25387, 13421 => 38169, + 13422 => 25645, 13423 => 36798, 13424 => 31572, 13425 => 30249, 13426 => 25171, + 13427 => 22823, 13428 => 21574, 13429 => 27513, 13430 => 20643, 13431 => 25140, + 13432 => 24102, 13433 => 27526, 13434 => 20195, 13435 => 36151, 13436 => 34955, + 13437 => 24453, 13438 => 36910, 13601 => 24608, 13602 => 32829, 13603 => 25285, + 13604 => 20025, 13605 => 21333, 13606 => 37112, 13607 => 25528, 13608 => 32966, + 13609 => 26086, 13610 => 27694, 13611 => 20294, 13612 => 24814, 13613 => 28129, + 13614 => 35806, 13615 => 24377, 13616 => 34507, 13617 => 24403, 13618 => 25377, + 13619 => 20826, 13620 => 33633, 13621 => 26723, 13622 => 20992, 13623 => 25443, + 13624 => 36424, 13625 => 20498, 13626 => 23707, 13627 => 31095, 13628 => 23548, + 13629 => 21040, 13630 => 31291, 13631 => 24764, 13632 => 36947, 13633 => 30423, + 13634 => 24503, 13635 => 24471, 13636 => 30340, 13637 => 36460, 13638 => 28783, + 13639 => 30331, 13640 => 31561, 13641 => 30634, 13642 => 20979, 13643 => 37011, + 13644 => 22564, 13645 => 20302, 13646 => 28404, 13647 => 36842, 13648 => 25932, + 13649 => 31515, 13650 => 29380, 13651 => 28068, 13652 => 32735, 13653 => 23265, + 13654 => 25269, 13655 => 24213, 13656 => 22320, 13657 => 33922, 13658 => 31532, + 13659 => 24093, 13660 => 24351, 13661 => 36882, 13662 => 32532, 13663 => 39072, + 13664 => 25474, 13665 => 28359, 13666 => 30872, 13667 => 28857, 13668 => 20856, + 13669 => 38747, 13670 => 22443, 13671 => 30005, 13672 => 20291, 13673 => 30008, + 13674 => 24215, 13675 => 24806, 13676 => 22880, 13677 => 28096, 13678 => 27583, + 13679 => 30857, 13680 => 21500, 13681 => 38613, 13682 => 20939, 13683 => 20993, + 13684 => 25481, 13685 => 21514, 13686 => 38035, 13687 => 35843, 13688 => 36300, + 13689 => 29241, 13690 => 30879, 13691 => 34678, 13692 => 36845, 13693 => 35853, + 13694 => 21472, 13857 => 19969, 13858 => 30447, 13859 => 21486, 13860 => 38025, + 13861 => 39030, 13862 => 40718, 13863 => 38189, 13864 => 23450, 13865 => 35746, + 13866 => 20002, 13867 => 19996, 13868 => 20908, 13869 => 33891, 13870 => 25026, + 13871 => 21160, 13872 => 26635, 13873 => 20375, 13874 => 24683, 13875 => 20923, + 13876 => 27934, 13877 => 20828, 13878 => 25238, 13879 => 26007, 13880 => 38497, + 13881 => 35910, 13882 => 36887, 13883 => 30168, 13884 => 37117, 13885 => 30563, + 13886 => 27602, 13887 => 29322, 13888 => 29420, 13889 => 35835, 13890 => 22581, + 13891 => 30585, 13892 => 36172, 13893 => 26460, 13894 => 38208, 13895 => 32922, + 13896 => 24230, 13897 => 28193, 13898 => 22930, 13899 => 31471, 13900 => 30701, + 13901 => 38203, 13902 => 27573, 13903 => 26029, 13904 => 32526, 13905 => 22534, + 13906 => 20817, 13907 => 38431, 13908 => 23545, 13909 => 22697, 13910 => 21544, + 13911 => 36466, 13912 => 25958, 13913 => 39039, 13914 => 22244, 13915 => 38045, + 13916 => 30462, 13917 => 36929, 13918 => 25479, 13919 => 21702, 13920 => 22810, + 13921 => 22842, 13922 => 22427, 13923 => 36530, 13924 => 26421, 13925 => 36346, + 13926 => 33333, 13927 => 21057, 13928 => 24816, 13929 => 22549, 13930 => 34558, + 13931 => 23784, 13932 => 40517, 13933 => 20420, 13934 => 39069, 13935 => 35769, + 13936 => 23077, 13937 => 24694, 13938 => 21380, 13939 => 25212, 13940 => 36943, + 13941 => 37122, 13942 => 39295, 13943 => 24681, 13944 => 32780, 13945 => 20799, + 13946 => 32819, 13947 => 23572, 13948 => 39285, 13949 => 27953, 13950 => 20108, + 14113 => 36144, 14114 => 21457, 14115 => 32602, 14116 => 31567, 14117 => 20240, + 14118 => 20047, 14119 => 38400, 14120 => 27861, 14121 => 29648, 14122 => 34281, + 14123 => 24070, 14124 => 30058, 14125 => 32763, 14126 => 27146, 14127 => 30718, + 14128 => 38034, 14129 => 32321, 14130 => 20961, 14131 => 28902, 14132 => 21453, + 14133 => 36820, 14134 => 33539, 14135 => 36137, 14136 => 29359, 14137 => 39277, + 14138 => 27867, 14139 => 22346, 14140 => 33459, 14141 => 26041, 14142 => 32938, + 14143 => 25151, 14144 => 38450, 14145 => 22952, 14146 => 20223, 14147 => 35775, + 14148 => 32442, 14149 => 25918, 14150 => 33778, 14151 => 38750, 14152 => 21857, + 14153 => 39134, 14154 => 32933, 14155 => 21290, 14156 => 35837, 14157 => 21536, + 14158 => 32954, 14159 => 24223, 14160 => 27832, 14161 => 36153, 14162 => 33452, + 14163 => 37210, 14164 => 21545, 14165 => 27675, 14166 => 20998, 14167 => 32439, + 14168 => 22367, 14169 => 28954, 14170 => 27774, 14171 => 31881, 14172 => 22859, + 14173 => 20221, 14174 => 24575, 14175 => 24868, 14176 => 31914, 14177 => 20016, + 14178 => 23553, 14179 => 26539, 14180 => 34562, 14181 => 23792, 14182 => 38155, + 14183 => 39118, 14184 => 30127, 14185 => 28925, 14186 => 36898, 14187 => 20911, + 14188 => 32541, 14189 => 35773, 14190 => 22857, 14191 => 20964, 14192 => 20315, + 14193 => 21542, 14194 => 22827, 14195 => 25975, 14196 => 32932, 14197 => 23413, + 14198 => 25206, 14199 => 25282, 14200 => 36752, 14201 => 24133, 14202 => 27679, + 14203 => 31526, 14204 => 20239, 14205 => 20440, 14206 => 26381, 14369 => 28014, + 14370 => 28074, 14371 => 31119, 14372 => 34993, 14373 => 24343, 14374 => 29995, + 14375 => 25242, 14376 => 36741, 14377 => 20463, 14378 => 37340, 14379 => 26023, + 14380 => 33071, 14381 => 33105, 14382 => 24220, 14383 => 33104, 14384 => 36212, + 14385 => 21103, 14386 => 35206, 14387 => 36171, 14388 => 22797, 14389 => 20613, + 14390 => 20184, 14391 => 38428, 14392 => 29238, 14393 => 33145, 14394 => 36127, + 14395 => 23500, 14396 => 35747, 14397 => 38468, 14398 => 22919, 14399 => 32538, + 14400 => 21648, 14401 => 22134, 14402 => 22030, 14403 => 35813, 14404 => 25913, + 14405 => 27010, 14406 => 38041, 14407 => 30422, 14408 => 28297, 14409 => 24178, + 14410 => 29976, 14411 => 26438, 14412 => 26577, 14413 => 31487, 14414 => 32925, + 14415 => 36214, 14416 => 24863, 14417 => 31174, 14418 => 25954, 14419 => 36195, + 14420 => 20872, 14421 => 21018, 14422 => 38050, 14423 => 32568, 14424 => 32923, + 14425 => 32434, 14426 => 23703, 14427 => 28207, 14428 => 26464, 14429 => 31705, + 14430 => 30347, 14431 => 39640, 14432 => 33167, 14433 => 32660, 14434 => 31957, + 14435 => 25630, 14436 => 38224, 14437 => 31295, 14438 => 21578, 14439 => 21733, + 14440 => 27468, 14441 => 25601, 14442 => 25096, 14443 => 40509, 14444 => 33011, + 14445 => 30105, 14446 => 21106, 14447 => 38761, 14448 => 33883, 14449 => 26684, + 14450 => 34532, 14451 => 38401, 14452 => 38548, 14453 => 38124, 14454 => 20010, + 14455 => 21508, 14456 => 32473, 14457 => 26681, 14458 => 36319, 14459 => 32789, + 14460 => 26356, 14461 => 24218, 14462 => 32697, 14625 => 22466, 14626 => 32831, + 14627 => 26775, 14628 => 24037, 14629 => 25915, 14630 => 21151, 14631 => 24685, + 14632 => 40858, 14633 => 20379, 14634 => 36524, 14635 => 20844, 14636 => 23467, + 14637 => 24339, 14638 => 24041, 14639 => 27742, 14640 => 25329, 14641 => 36129, + 14642 => 20849, 14643 => 38057, 14644 => 21246, 14645 => 27807, 14646 => 33503, + 14647 => 29399, 14648 => 22434, 14649 => 26500, 14650 => 36141, 14651 => 22815, + 14652 => 36764, 14653 => 33735, 14654 => 21653, 14655 => 31629, 14656 => 20272, + 14657 => 27837, 14658 => 23396, 14659 => 22993, 14660 => 40723, 14661 => 21476, + 14662 => 34506, 14663 => 39592, 14664 => 35895, 14665 => 32929, 14666 => 25925, + 14667 => 39038, 14668 => 22266, 14669 => 38599, 14670 => 21038, 14671 => 29916, + 14672 => 21072, 14673 => 23521, 14674 => 25346, 14675 => 35074, 14676 => 20054, + 14677 => 25296, 14678 => 24618, 14679 => 26874, 14680 => 20851, 14681 => 23448, + 14682 => 20896, 14683 => 35266, 14684 => 31649, 14685 => 39302, 14686 => 32592, + 14687 => 24815, 14688 => 28748, 14689 => 36143, 14690 => 20809, 14691 => 24191, + 14692 => 36891, 14693 => 29808, 14694 => 35268, 14695 => 22317, 14696 => 30789, + 14697 => 24402, 14698 => 40863, 14699 => 38394, 14700 => 36712, 14701 => 39740, + 14702 => 35809, 14703 => 30328, 14704 => 26690, 14705 => 26588, 14706 => 36330, + 14707 => 36149, 14708 => 21053, 14709 => 36746, 14710 => 28378, 14711 => 26829, + 14712 => 38149, 14713 => 37101, 14714 => 22269, 14715 => 26524, 14716 => 35065, + 14717 => 36807, 14718 => 21704, 14881 => 39608, 14882 => 23401, 14883 => 28023, + 14884 => 27686, 14885 => 20133, 14886 => 23475, 14887 => 39559, 14888 => 37219, + 14889 => 25000, 14890 => 37039, 14891 => 38889, 14892 => 21547, 14893 => 28085, + 14894 => 23506, 14895 => 20989, 14896 => 21898, 14897 => 32597, 14898 => 32752, + 14899 => 25788, 14900 => 25421, 14901 => 26097, 14902 => 25022, 14903 => 24717, + 14904 => 28938, 14905 => 27735, 14906 => 27721, 14907 => 22831, 14908 => 26477, + 14909 => 33322, 14910 => 22741, 14911 => 22158, 14912 => 35946, 14913 => 27627, + 14914 => 37085, 14915 => 22909, 14916 => 32791, 14917 => 21495, 14918 => 28009, + 14919 => 21621, 14920 => 21917, 14921 => 33655, 14922 => 33743, 14923 => 26680, + 14924 => 31166, 14925 => 21644, 14926 => 20309, 14927 => 21512, 14928 => 30418, + 14929 => 35977, 14930 => 38402, 14931 => 27827, 14932 => 28088, 14933 => 36203, + 14934 => 35088, 14935 => 40548, 14936 => 36154, 14937 => 22079, 14938 => 40657, + 14939 => 30165, 14940 => 24456, 14941 => 29408, 14942 => 24680, 14943 => 21756, + 14944 => 20136, 14945 => 27178, 14946 => 34913, 14947 => 24658, 14948 => 36720, + 14949 => 21700, 14950 => 28888, 14951 => 34425, 14952 => 40511, 14953 => 27946, + 14954 => 23439, 14955 => 24344, 14956 => 32418, 14957 => 21897, 14958 => 20399, + 14959 => 29492, 14960 => 21564, 14961 => 21402, 14962 => 20505, 14963 => 21518, + 14964 => 21628, 14965 => 20046, 14966 => 24573, 14967 => 29786, 14968 => 22774, + 14969 => 33899, 14970 => 32993, 14971 => 34676, 14972 => 29392, 14973 => 31946, + 14974 => 28246, 15137 => 24359, 15138 => 34382, 15139 => 21804, 15140 => 25252, + 15141 => 20114, 15142 => 27818, 15143 => 25143, 15144 => 33457, 15145 => 21719, + 15146 => 21326, 15147 => 29502, 15148 => 28369, 15149 => 30011, 15150 => 21010, + 15151 => 21270, 15152 => 35805, 15153 => 27088, 15154 => 24458, 15155 => 24576, + 15156 => 28142, 15157 => 22351, 15158 => 27426, 15159 => 29615, 15160 => 26707, + 15161 => 36824, 15162 => 32531, 15163 => 25442, 15164 => 24739, 15165 => 21796, + 15166 => 30186, 15167 => 35938, 15168 => 28949, 15169 => 28067, 15170 => 23462, + 15171 => 24187, 15172 => 33618, 15173 => 24908, 15174 => 40644, 15175 => 30970, + 15176 => 34647, 15177 => 31783, 15178 => 30343, 15179 => 20976, 15180 => 24822, + 15181 => 29004, 15182 => 26179, 15183 => 24140, 15184 => 24653, 15185 => 35854, + 15186 => 28784, 15187 => 25381, 15188 => 36745, 15189 => 24509, 15190 => 24674, + 15191 => 34516, 15192 => 22238, 15193 => 27585, 15194 => 24724, 15195 => 24935, + 15196 => 21321, 15197 => 24800, 15198 => 26214, 15199 => 36159, 15200 => 31229, + 15201 => 20250, 15202 => 28905, 15203 => 27719, 15204 => 35763, 15205 => 35826, + 15206 => 32472, 15207 => 33636, 15208 => 26127, 15209 => 23130, 15210 => 39746, + 15211 => 27985, 15212 => 28151, 15213 => 35905, 15214 => 27963, 15215 => 20249, + 15216 => 28779, 15217 => 33719, 15218 => 25110, 15219 => 24785, 15220 => 38669, + 15221 => 36135, 15222 => 31096, 15223 => 20987, 15224 => 22334, 15225 => 22522, + 15226 => 26426, 15227 => 30072, 15228 => 31293, 15229 => 31215, 15230 => 31637, + 15393 => 32908, 15394 => 39269, 15395 => 36857, 15396 => 28608, 15397 => 35749, + 15398 => 40481, 15399 => 23020, 15400 => 32489, 15401 => 32521, 15402 => 21513, + 15403 => 26497, 15404 => 26840, 15405 => 36753, 15406 => 31821, 15407 => 38598, + 15408 => 21450, 15409 => 24613, 15410 => 30142, 15411 => 27762, 15412 => 21363, + 15413 => 23241, 15414 => 32423, 15415 => 25380, 15416 => 20960, 15417 => 33034, + 15418 => 24049, 15419 => 34015, 15420 => 25216, 15421 => 20864, 15422 => 23395, + 15423 => 20238, 15424 => 31085, 15425 => 21058, 15426 => 24760, 15427 => 27982, + 15428 => 23492, 15429 => 23490, 15430 => 35745, 15431 => 35760, 15432 => 26082, + 15433 => 24524, 15434 => 38469, 15435 => 22931, 15436 => 32487, 15437 => 32426, + 15438 => 22025, 15439 => 26551, 15440 => 22841, 15441 => 20339, 15442 => 23478, + 15443 => 21152, 15444 => 33626, 15445 => 39050, 15446 => 36158, 15447 => 30002, + 15448 => 38078, 15449 => 20551, 15450 => 31292, 15451 => 20215, 15452 => 26550, + 15453 => 39550, 15454 => 23233, 15455 => 27516, 15456 => 30417, 15457 => 22362, + 15458 => 23574, 15459 => 31546, 15460 => 38388, 15461 => 29006, 15462 => 20860, + 15463 => 32937, 15464 => 33392, 15465 => 22904, 15466 => 32516, 15467 => 33575, + 15468 => 26816, 15469 => 26604, 15470 => 30897, 15471 => 30839, 15472 => 25315, + 15473 => 25441, 15474 => 31616, 15475 => 20461, 15476 => 21098, 15477 => 20943, + 15478 => 33616, 15479 => 27099, 15480 => 37492, 15481 => 36341, 15482 => 36145, + 15483 => 35265, 15484 => 38190, 15485 => 31661, 15486 => 20214, 15649 => 20581, + 15650 => 33328, 15651 => 21073, 15652 => 39279, 15653 => 28176, 15654 => 28293, + 15655 => 28071, 15656 => 24314, 15657 => 20725, 15658 => 23004, 15659 => 23558, + 15660 => 27974, 15661 => 27743, 15662 => 30086, 15663 => 33931, 15664 => 26728, + 15665 => 22870, 15666 => 35762, 15667 => 21280, 15668 => 37233, 15669 => 38477, + 15670 => 34121, 15671 => 26898, 15672 => 30977, 15673 => 28966, 15674 => 33014, + 15675 => 20132, 15676 => 37066, 15677 => 27975, 15678 => 39556, 15679 => 23047, + 15680 => 22204, 15681 => 25605, 15682 => 38128, 15683 => 30699, 15684 => 20389, + 15685 => 33050, 15686 => 29409, 15687 => 35282, 15688 => 39290, 15689 => 32564, + 15690 => 32478, 15691 => 21119, 15692 => 25945, 15693 => 37237, 15694 => 36735, + 15695 => 36739, 15696 => 21483, 15697 => 31382, 15698 => 25581, 15699 => 25509, + 15700 => 30342, 15701 => 31224, 15702 => 34903, 15703 => 38454, 15704 => 25130, + 15705 => 21163, 15706 => 33410, 15707 => 26708, 15708 => 26480, 15709 => 25463, + 15710 => 30571, 15711 => 31469, 15712 => 27905, 15713 => 32467, 15714 => 35299, + 15715 => 22992, 15716 => 25106, 15717 => 34249, 15718 => 33445, 15719 => 30028, + 15720 => 20511, 15721 => 20171, 15722 => 30117, 15723 => 35819, 15724 => 23626, + 15725 => 24062, 15726 => 31563, 15727 => 26020, 15728 => 37329, 15729 => 20170, + 15730 => 27941, 15731 => 35167, 15732 => 32039, 15733 => 38182, 15734 => 20165, + 15735 => 35880, 15736 => 36827, 15737 => 38771, 15738 => 26187, 15739 => 31105, + 15740 => 36817, 15741 => 28908, 15742 => 28024, 15905 => 23613, 15906 => 21170, + 15907 => 33606, 15908 => 20834, 15909 => 33550, 15910 => 30555, 15911 => 26230, + 15912 => 40120, 15913 => 20140, 15914 => 24778, 15915 => 31934, 15916 => 31923, + 15917 => 32463, 15918 => 20117, 15919 => 35686, 15920 => 26223, 15921 => 39048, + 15922 => 38745, 15923 => 22659, 15924 => 25964, 15925 => 38236, 15926 => 24452, + 15927 => 30153, 15928 => 38742, 15929 => 31455, 15930 => 31454, 15931 => 20928, + 15932 => 28847, 15933 => 31384, 15934 => 25578, 15935 => 31350, 15936 => 32416, + 15937 => 29590, 15938 => 38893, 15939 => 20037, 15940 => 28792, 15941 => 20061, + 15942 => 37202, 15943 => 21417, 15944 => 25937, 15945 => 26087, 15946 => 33276, + 15947 => 33285, 15948 => 21646, 15949 => 23601, 15950 => 30106, 15951 => 38816, + 15952 => 25304, 15953 => 29401, 15954 => 30141, 15955 => 23621, 15956 => 39545, + 15957 => 33738, 15958 => 23616, 15959 => 21632, 15960 => 30697, 15961 => 20030, + 15962 => 27822, 15963 => 32858, 15964 => 25298, 15965 => 25454, 15966 => 24040, + 15967 => 20855, 15968 => 36317, 15969 => 36382, 15970 => 38191, 15971 => 20465, + 15972 => 21477, 15973 => 24807, 15974 => 28844, 15975 => 21095, 15976 => 25424, + 15977 => 40515, 15978 => 23071, 15979 => 20518, 15980 => 30519, 15981 => 21367, + 15982 => 32482, 15983 => 25733, 15984 => 25899, 15985 => 25225, 15986 => 25496, + 15987 => 20500, 15988 => 29237, 15989 => 35273, 15990 => 20915, 15991 => 35776, + 15992 => 32477, 15993 => 22343, 15994 => 33740, 15995 => 38055, 15996 => 20891, + 15997 => 21531, 15998 => 23803, 16161 => 20426, 16162 => 31459, 16163 => 27994, + 16164 => 37089, 16165 => 39567, 16166 => 21888, 16167 => 21654, 16168 => 21345, + 16169 => 21679, 16170 => 24320, 16171 => 25577, 16172 => 26999, 16173 => 20975, + 16174 => 24936, 16175 => 21002, 16176 => 22570, 16177 => 21208, 16178 => 22350, + 16179 => 30733, 16180 => 30475, 16181 => 24247, 16182 => 24951, 16183 => 31968, + 16184 => 25179, 16185 => 25239, 16186 => 20130, 16187 => 28821, 16188 => 32771, + 16189 => 25335, 16190 => 28900, 16191 => 38752, 16192 => 22391, 16193 => 33499, + 16194 => 26607, 16195 => 26869, 16196 => 30933, 16197 => 39063, 16198 => 31185, + 16199 => 22771, 16200 => 21683, 16201 => 21487, 16202 => 28212, 16203 => 20811, + 16204 => 21051, 16205 => 23458, 16206 => 35838, 16207 => 32943, 16208 => 21827, + 16209 => 22438, 16210 => 24691, 16211 => 22353, 16212 => 21549, 16213 => 31354, + 16214 => 24656, 16215 => 23380, 16216 => 25511, 16217 => 25248, 16218 => 21475, + 16219 => 25187, 16220 => 23495, 16221 => 26543, 16222 => 21741, 16223 => 31391, + 16224 => 33510, 16225 => 37239, 16226 => 24211, 16227 => 35044, 16228 => 22840, + 16229 => 22446, 16230 => 25358, 16231 => 36328, 16232 => 33007, 16233 => 22359, + 16234 => 31607, 16235 => 20393, 16236 => 24555, 16237 => 23485, 16238 => 27454, + 16239 => 21281, 16240 => 31568, 16241 => 29378, 16242 => 26694, 16243 => 30719, + 16244 => 30518, 16245 => 26103, 16246 => 20917, 16247 => 20111, 16248 => 30420, + 16249 => 23743, 16250 => 31397, 16251 => 33909, 16252 => 22862, 16253 => 39745, + 16254 => 20608, 16417 => 39304, 16418 => 24871, 16419 => 28291, 16420 => 22372, + 16421 => 26118, 16422 => 25414, 16423 => 22256, 16424 => 25324, 16425 => 25193, + 16426 => 24275, 16427 => 38420, 16428 => 22403, 16429 => 25289, 16430 => 21895, + 16431 => 34593, 16432 => 33098, 16433 => 36771, 16434 => 21862, 16435 => 33713, + 16436 => 26469, 16437 => 36182, 16438 => 34013, 16439 => 23146, 16440 => 26639, + 16441 => 25318, 16442 => 31726, 16443 => 38417, 16444 => 20848, 16445 => 28572, + 16446 => 35888, 16447 => 25597, 16448 => 35272, 16449 => 25042, 16450 => 32518, + 16451 => 28866, 16452 => 28389, 16453 => 29701, 16454 => 27028, 16455 => 29436, + 16456 => 24266, 16457 => 37070, 16458 => 26391, 16459 => 28010, 16460 => 25438, + 16461 => 21171, 16462 => 29282, 16463 => 32769, 16464 => 20332, 16465 => 23013, + 16466 => 37226, 16467 => 28889, 16468 => 28061, 16469 => 21202, 16470 => 20048, + 16471 => 38647, 16472 => 38253, 16473 => 34174, 16474 => 30922, 16475 => 32047, + 16476 => 20769, 16477 => 22418, 16478 => 25794, 16479 => 32907, 16480 => 31867, + 16481 => 27882, 16482 => 26865, 16483 => 26974, 16484 => 20919, 16485 => 21400, + 16486 => 26792, 16487 => 29313, 16488 => 40654, 16489 => 31729, 16490 => 29432, + 16491 => 31163, 16492 => 28435, 16493 => 29702, 16494 => 26446, 16495 => 37324, + 16496 => 40100, 16497 => 31036, 16498 => 33673, 16499 => 33620, 16500 => 21519, + 16501 => 26647, 16502 => 20029, 16503 => 21385, 16504 => 21169, 16505 => 30782, + 16506 => 21382, 16507 => 21033, 16508 => 20616, 16509 => 20363, 16510 => 20432, + 16673 => 30178, 16674 => 31435, 16675 => 31890, 16676 => 27813, 16677 => 38582, + 16678 => 21147, 16679 => 29827, 16680 => 21737, 16681 => 20457, 16682 => 32852, + 16683 => 33714, 16684 => 36830, 16685 => 38256, 16686 => 24265, 16687 => 24604, + 16688 => 28063, 16689 => 24088, 16690 => 25947, 16691 => 33080, 16692 => 38142, + 16693 => 24651, 16694 => 28860, 16695 => 32451, 16696 => 31918, 16697 => 20937, + 16698 => 26753, 16699 => 31921, 16700 => 33391, 16701 => 20004, 16702 => 36742, + 16703 => 37327, 16704 => 26238, 16705 => 20142, 16706 => 35845, 16707 => 25769, + 16708 => 32842, 16709 => 20698, 16710 => 30103, 16711 => 29134, 16712 => 23525, + 16713 => 36797, 16714 => 28518, 16715 => 20102, 16716 => 25730, 16717 => 38243, + 16718 => 24278, 16719 => 26009, 16720 => 21015, 16721 => 35010, 16722 => 28872, + 16723 => 21155, 16724 => 29454, 16725 => 29747, 16726 => 26519, 16727 => 30967, + 16728 => 38678, 16729 => 20020, 16730 => 37051, 16731 => 40158, 16732 => 28107, + 16733 => 20955, 16734 => 36161, 16735 => 21533, 16736 => 25294, 16737 => 29618, + 16738 => 33777, 16739 => 38646, 16740 => 40836, 16741 => 38083, 16742 => 20278, + 16743 => 32666, 16744 => 20940, 16745 => 28789, 16746 => 38517, 16747 => 23725, + 16748 => 39046, 16749 => 21478, 16750 => 20196, 16751 => 28316, 16752 => 29705, + 16753 => 27060, 16754 => 30827, 16755 => 39311, 16756 => 30041, 16757 => 21016, + 16758 => 30244, 16759 => 27969, 16760 => 26611, 16761 => 20845, 16762 => 40857, + 16763 => 32843, 16764 => 21657, 16765 => 31548, 16766 => 31423, 16929 => 38534, + 16930 => 22404, 16931 => 25314, 16932 => 38471, 16933 => 27004, 16934 => 23044, + 16935 => 25602, 16936 => 31699, 16937 => 28431, 16938 => 38475, 16939 => 33446, + 16940 => 21346, 16941 => 39045, 16942 => 24208, 16943 => 28809, 16944 => 25523, + 16945 => 21348, 16946 => 34383, 16947 => 40065, 16948 => 40595, 16949 => 30860, + 16950 => 38706, 16951 => 36335, 16952 => 36162, 16953 => 40575, 16954 => 28510, + 16955 => 31108, 16956 => 24405, 16957 => 38470, 16958 => 25134, 16959 => 39540, + 16960 => 21525, 16961 => 38109, 16962 => 20387, 16963 => 26053, 16964 => 23653, + 16965 => 23649, 16966 => 32533, 16967 => 34385, 16968 => 27695, 16969 => 24459, + 16970 => 29575, 16971 => 28388, 16972 => 32511, 16973 => 23782, 16974 => 25371, + 16975 => 23402, 16976 => 28390, 16977 => 21365, 16978 => 20081, 16979 => 25504, + 16980 => 30053, 16981 => 25249, 16982 => 36718, 16983 => 20262, 16984 => 20177, + 16985 => 27814, 16986 => 32438, 16987 => 35770, 16988 => 33821, 16989 => 34746, + 16990 => 32599, 16991 => 36923, 16992 => 38179, 16993 => 31657, 16994 => 39585, + 16995 => 35064, 16996 => 33853, 16997 => 27931, 16998 => 39558, 16999 => 32476, + 17000 => 22920, 17001 => 40635, 17002 => 29595, 17003 => 30721, 17004 => 34434, + 17005 => 39532, 17006 => 39554, 17007 => 22043, 17008 => 21527, 17009 => 22475, + 17010 => 20080, 17011 => 40614, 17012 => 21334, 17013 => 36808, 17014 => 33033, + 17015 => 30610, 17016 => 39314, 17017 => 34542, 17018 => 28385, 17019 => 34067, + 17020 => 26364, 17021 => 24930, 17022 => 28459, 17185 => 35881, 17186 => 33426, + 17187 => 33579, 17188 => 30450, 17189 => 27667, 17190 => 24537, 17191 => 33725, + 17192 => 29483, 17193 => 33541, 17194 => 38170, 17195 => 27611, 17196 => 30683, + 17197 => 38086, 17198 => 21359, 17199 => 33538, 17200 => 20882, 17201 => 24125, + 17202 => 35980, 17203 => 36152, 17204 => 20040, 17205 => 29611, 17206 => 26522, + 17207 => 26757, 17208 => 37238, 17209 => 38665, 17210 => 29028, 17211 => 27809, + 17212 => 30473, 17213 => 23186, 17214 => 38209, 17215 => 27599, 17216 => 32654, + 17217 => 26151, 17218 => 23504, 17219 => 22969, 17220 => 23194, 17221 => 38376, + 17222 => 38391, 17223 => 20204, 17224 => 33804, 17225 => 33945, 17226 => 27308, + 17227 => 30431, 17228 => 38192, 17229 => 29467, 17230 => 26790, 17231 => 23391, + 17232 => 30511, 17233 => 37274, 17234 => 38753, 17235 => 31964, 17236 => 36855, + 17237 => 35868, 17238 => 24357, 17239 => 31859, 17240 => 31192, 17241 => 35269, + 17242 => 27852, 17243 => 34588, 17244 => 23494, 17245 => 24130, 17246 => 26825, + 17247 => 30496, 17248 => 32501, 17249 => 20885, 17250 => 20813, 17251 => 21193, + 17252 => 23081, 17253 => 32517, 17254 => 38754, 17255 => 33495, 17256 => 25551, + 17257 => 30596, 17258 => 34256, 17259 => 31186, 17260 => 28218, 17261 => 24217, + 17262 => 22937, 17263 => 34065, 17264 => 28781, 17265 => 27665, 17266 => 25279, + 17267 => 30399, 17268 => 25935, 17269 => 24751, 17270 => 38397, 17271 => 26126, + 17272 => 34719, 17273 => 40483, 17274 => 38125, 17275 => 21517, 17276 => 21629, + 17277 => 35884, 17278 => 25720, 17441 => 25721, 17442 => 34321, 17443 => 27169, + 17444 => 33180, 17445 => 30952, 17446 => 25705, 17447 => 39764, 17448 => 25273, + 17449 => 26411, 17450 => 33707, 17451 => 22696, 17452 => 40664, 17453 => 27819, + 17454 => 28448, 17455 => 23518, 17456 => 38476, 17457 => 35851, 17458 => 29279, + 17459 => 26576, 17460 => 25287, 17461 => 29281, 17462 => 20137, 17463 => 22982, + 17464 => 27597, 17465 => 22675, 17466 => 26286, 17467 => 24149, 17468 => 21215, + 17469 => 24917, 17470 => 26408, 17471 => 30446, 17472 => 30566, 17473 => 29287, + 17474 => 31302, 17475 => 25343, 17476 => 21738, 17477 => 21584, 17478 => 38048, + 17479 => 37027, 17480 => 23068, 17481 => 32435, 17482 => 27670, 17483 => 20035, + 17484 => 22902, 17485 => 32784, 17486 => 22856, 17487 => 21335, 17488 => 30007, + 17489 => 38590, 17490 => 22218, 17491 => 25376, 17492 => 33041, 17493 => 24700, + 17494 => 38393, 17495 => 28118, 17496 => 21602, 17497 => 39297, 17498 => 20869, + 17499 => 23273, 17500 => 33021, 17501 => 22958, 17502 => 38675, 17503 => 20522, + 17504 => 27877, 17505 => 23612, 17506 => 25311, 17507 => 20320, 17508 => 21311, + 17509 => 33147, 17510 => 36870, 17511 => 28346, 17512 => 34091, 17513 => 25288, + 17514 => 24180, 17515 => 30910, 17516 => 25781, 17517 => 25467, 17518 => 24565, + 17519 => 23064, 17520 => 37247, 17521 => 40479, 17522 => 23615, 17523 => 25423, + 17524 => 32834, 17525 => 23421, 17526 => 21870, 17527 => 38218, 17528 => 38221, + 17529 => 28037, 17530 => 24744, 17531 => 26592, 17532 => 29406, 17533 => 20957, + 17534 => 23425, 17697 => 25319, 17698 => 27870, 17699 => 29275, 17700 => 25197, + 17701 => 38062, 17702 => 32445, 17703 => 33043, 17704 => 27987, 17705 => 20892, + 17706 => 24324, 17707 => 22900, 17708 => 21162, 17709 => 24594, 17710 => 22899, + 17711 => 26262, 17712 => 34384, 17713 => 30111, 17714 => 25386, 17715 => 25062, + 17716 => 31983, 17717 => 35834, 17718 => 21734, 17719 => 27431, 17720 => 40485, + 17721 => 27572, 17722 => 34261, 17723 => 21589, 17724 => 20598, 17725 => 27812, + 17726 => 21866, 17727 => 36276, 17728 => 29228, 17729 => 24085, 17730 => 24597, + 17731 => 29750, 17732 => 25293, 17733 => 25490, 17734 => 29260, 17735 => 24472, + 17736 => 28227, 17737 => 27966, 17738 => 25856, 17739 => 28504, 17740 => 30424, + 17741 => 30928, 17742 => 30460, 17743 => 30036, 17744 => 21028, 17745 => 21467, + 17746 => 20051, 17747 => 24222, 17748 => 26049, 17749 => 32810, 17750 => 32982, + 17751 => 25243, 17752 => 21638, 17753 => 21032, 17754 => 28846, 17755 => 34957, + 17756 => 36305, 17757 => 27873, 17758 => 21624, 17759 => 32986, 17760 => 22521, + 17761 => 35060, 17762 => 36180, 17763 => 38506, 17764 => 37197, 17765 => 20329, + 17766 => 27803, 17767 => 21943, 17768 => 30406, 17769 => 30768, 17770 => 25256, + 17771 => 28921, 17772 => 28558, 17773 => 24429, 17774 => 34028, 17775 => 26842, + 17776 => 30844, 17777 => 31735, 17778 => 33192, 17779 => 26379, 17780 => 40527, + 17781 => 25447, 17782 => 30896, 17783 => 22383, 17784 => 30738, 17785 => 38713, + 17786 => 25209, 17787 => 25259, 17788 => 21128, 17789 => 29749, 17790 => 27607, + 17953 => 21860, 17954 => 33086, 17955 => 30130, 17956 => 30382, 17957 => 21305, + 17958 => 30174, 17959 => 20731, 17960 => 23617, 17961 => 35692, 17962 => 31687, + 17963 => 20559, 17964 => 29255, 17965 => 39575, 17966 => 39128, 17967 => 28418, + 17968 => 29922, 17969 => 31080, 17970 => 25735, 17971 => 30629, 17972 => 25340, + 17973 => 39057, 17974 => 36139, 17975 => 21697, 17976 => 32856, 17977 => 20050, + 17978 => 22378, 17979 => 33529, 17980 => 33805, 17981 => 24179, 17982 => 20973, + 17983 => 29942, 17984 => 35780, 17985 => 23631, 17986 => 22369, 17987 => 27900, + 17988 => 39047, 17989 => 23110, 17990 => 30772, 17991 => 39748, 17992 => 36843, + 17993 => 31893, 17994 => 21078, 17995 => 25169, 17996 => 38138, 17997 => 20166, + 17998 => 33670, 17999 => 33889, 18000 => 33769, 18001 => 33970, 18002 => 22484, + 18003 => 26420, 18004 => 22275, 18005 => 26222, 18006 => 28006, 18007 => 35889, + 18008 => 26333, 18009 => 28689, 18010 => 26399, 18011 => 27450, 18012 => 26646, + 18013 => 25114, 18014 => 22971, 18015 => 19971, 18016 => 20932, 18017 => 28422, + 18018 => 26578, 18019 => 27791, 18020 => 20854, 18021 => 26827, 18022 => 22855, + 18023 => 27495, 18024 => 30054, 18025 => 23822, 18026 => 33040, 18027 => 40784, + 18028 => 26071, 18029 => 31048, 18030 => 31041, 18031 => 39569, 18032 => 36215, + 18033 => 23682, 18034 => 20062, 18035 => 20225, 18036 => 21551, 18037 => 22865, + 18038 => 30732, 18039 => 22120, 18040 => 27668, 18041 => 36804, 18042 => 24323, + 18043 => 27773, 18044 => 27875, 18045 => 35755, 18046 => 25488, 18209 => 24688, + 18210 => 27965, 18211 => 29301, 18212 => 25190, 18213 => 38030, 18214 => 38085, + 18215 => 21315, 18216 => 36801, 18217 => 31614, 18218 => 20191, 18219 => 35878, + 18220 => 20094, 18221 => 40660, 18222 => 38065, 18223 => 38067, 18224 => 21069, + 18225 => 28508, 18226 => 36963, 18227 => 27973, 18228 => 35892, 18229 => 22545, + 18230 => 23884, 18231 => 27424, 18232 => 27465, 18233 => 26538, 18234 => 21595, + 18235 => 33108, 18236 => 32652, 18237 => 22681, 18238 => 34103, 18239 => 24378, + 18240 => 25250, 18241 => 27207, 18242 => 38201, 18243 => 25970, 18244 => 24708, + 18245 => 26725, 18246 => 30631, 18247 => 20052, 18248 => 20392, 18249 => 24039, + 18250 => 38808, 18251 => 25772, 18252 => 32728, 18253 => 23789, 18254 => 20431, + 18255 => 31373, 18256 => 20999, 18257 => 33540, 18258 => 19988, 18259 => 24623, + 18260 => 31363, 18261 => 38054, 18262 => 20405, 18263 => 20146, 18264 => 31206, + 18265 => 29748, 18266 => 21220, 18267 => 33465, 18268 => 25810, 18269 => 31165, + 18270 => 23517, 18271 => 27777, 18272 => 38738, 18273 => 36731, 18274 => 27682, + 18275 => 20542, 18276 => 21375, 18277 => 28165, 18278 => 25806, 18279 => 26228, + 18280 => 27696, 18281 => 24773, 18282 => 39031, 18283 => 35831, 18284 => 24198, + 18285 => 29756, 18286 => 31351, 18287 => 31179, 18288 => 19992, 18289 => 37041, + 18290 => 29699, 18291 => 27714, 18292 => 22234, 18293 => 37195, 18294 => 27845, + 18295 => 36235, 18296 => 21306, 18297 => 34502, 18298 => 26354, 18299 => 36527, + 18300 => 23624, 18301 => 39537, 18302 => 28192, 18465 => 21462, 18466 => 23094, + 18467 => 40843, 18468 => 36259, 18469 => 21435, 18470 => 22280, 18471 => 39079, + 18472 => 26435, 18473 => 37275, 18474 => 27849, 18475 => 20840, 18476 => 30154, + 18477 => 25331, 18478 => 29356, 18479 => 21048, 18480 => 21149, 18481 => 32570, + 18482 => 28820, 18483 => 30264, 18484 => 21364, 18485 => 40522, 18486 => 27063, + 18487 => 30830, 18488 => 38592, 18489 => 35033, 18490 => 32676, 18491 => 28982, + 18492 => 29123, 18493 => 20873, 18494 => 26579, 18495 => 29924, 18496 => 22756, + 18497 => 25880, 18498 => 22199, 18499 => 35753, 18500 => 39286, 18501 => 25200, + 18502 => 32469, 18503 => 24825, 18504 => 28909, 18505 => 22764, 18506 => 20161, + 18507 => 20154, 18508 => 24525, 18509 => 38887, 18510 => 20219, 18511 => 35748, + 18512 => 20995, 18513 => 22922, 18514 => 32427, 18515 => 25172, 18516 => 20173, + 18517 => 26085, 18518 => 25102, 18519 => 33592, 18520 => 33993, 18521 => 33635, + 18522 => 34701, 18523 => 29076, 18524 => 28342, 18525 => 23481, 18526 => 32466, + 18527 => 20887, 18528 => 25545, 18529 => 26580, 18530 => 32905, 18531 => 33593, + 18532 => 34837, 18533 => 20754, 18534 => 23418, 18535 => 22914, 18536 => 36785, + 18537 => 20083, 18538 => 27741, 18539 => 20837, 18540 => 35109, 18541 => 36719, + 18542 => 38446, 18543 => 34122, 18544 => 29790, 18545 => 38160, 18546 => 38384, + 18547 => 28070, 18548 => 33509, 18549 => 24369, 18550 => 25746, 18551 => 27922, + 18552 => 33832, 18553 => 33134, 18554 => 40131, 18555 => 22622, 18556 => 36187, + 18557 => 19977, 18558 => 21441, 18721 => 20254, 18722 => 25955, 18723 => 26705, + 18724 => 21971, 18725 => 20007, 18726 => 25620, 18727 => 39578, 18728 => 25195, + 18729 => 23234, 18730 => 29791, 18731 => 33394, 18732 => 28073, 18733 => 26862, + 18734 => 20711, 18735 => 33678, 18736 => 30722, 18737 => 26432, 18738 => 21049, + 18739 => 27801, 18740 => 32433, 18741 => 20667, 18742 => 21861, 18743 => 29022, + 18744 => 31579, 18745 => 26194, 18746 => 29642, 18747 => 33515, 18748 => 26441, + 18749 => 23665, 18750 => 21024, 18751 => 29053, 18752 => 34923, 18753 => 38378, + 18754 => 38485, 18755 => 25797, 18756 => 36193, 18757 => 33203, 18758 => 21892, + 18759 => 27733, 18760 => 25159, 18761 => 32558, 18762 => 22674, 18763 => 20260, + 18764 => 21830, 18765 => 36175, 18766 => 26188, 18767 => 19978, 18768 => 23578, + 18769 => 35059, 18770 => 26786, 18771 => 25422, 18772 => 31245, 18773 => 28903, + 18774 => 33421, 18775 => 21242, 18776 => 38902, 18777 => 23569, 18778 => 21736, + 18779 => 37045, 18780 => 32461, 18781 => 22882, 18782 => 36170, 18783 => 34503, + 18784 => 33292, 18785 => 33293, 18786 => 36198, 18787 => 25668, 18788 => 23556, + 18789 => 24913, 18790 => 28041, 18791 => 31038, 18792 => 35774, 18793 => 30775, + 18794 => 30003, 18795 => 21627, 18796 => 20280, 18797 => 36523, 18798 => 28145, + 18799 => 23072, 18800 => 32453, 18801 => 31070, 18802 => 27784, 18803 => 23457, + 18804 => 23158, 18805 => 29978, 18806 => 32958, 18807 => 24910, 18808 => 28183, + 18809 => 22768, 18810 => 29983, 18811 => 29989, 18812 => 29298, 18813 => 21319, + 18814 => 32499, 18977 => 30465, 18978 => 30427, 18979 => 21097, 18980 => 32988, + 18981 => 22307, 18982 => 24072, 18983 => 22833, 18984 => 29422, 18985 => 26045, + 18986 => 28287, 18987 => 35799, 18988 => 23608, 18989 => 34417, 18990 => 21313, + 18991 => 30707, 18992 => 25342, 18993 => 26102, 18994 => 20160, 18995 => 39135, + 18996 => 34432, 18997 => 23454, 18998 => 35782, 18999 => 21490, 19000 => 30690, + 19001 => 20351, 19002 => 23630, 19003 => 39542, 19004 => 22987, 19005 => 24335, + 19006 => 31034, 19007 => 22763, 19008 => 19990, 19009 => 26623, 19010 => 20107, + 19011 => 25325, 19012 => 35475, 19013 => 36893, 19014 => 21183, 19015 => 26159, + 19016 => 21980, 19017 => 22124, 19018 => 36866, 19019 => 20181, 19020 => 20365, + 19021 => 37322, 19022 => 39280, 19023 => 27663, 19024 => 24066, 19025 => 24643, + 19026 => 23460, 19027 => 35270, 19028 => 35797, 19029 => 25910, 19030 => 25163, + 19031 => 39318, 19032 => 23432, 19033 => 23551, 19034 => 25480, 19035 => 21806, + 19036 => 21463, 19037 => 30246, 19038 => 20861, 19039 => 34092, 19040 => 26530, + 19041 => 26803, 19042 => 27530, 19043 => 25234, 19044 => 36755, 19045 => 21460, + 19046 => 33298, 19047 => 28113, 19048 => 30095, 19049 => 20070, 19050 => 36174, + 19051 => 23408, 19052 => 29087, 19053 => 34223, 19054 => 26257, 19055 => 26329, + 19056 => 32626, 19057 => 34560, 19058 => 40653, 19059 => 40736, 19060 => 23646, + 19061 => 26415, 19062 => 36848, 19063 => 26641, 19064 => 26463, 19065 => 25101, + 19066 => 31446, 19067 => 22661, 19068 => 24246, 19069 => 25968, 19070 => 28465, + 19233 => 24661, 19234 => 21047, 19235 => 32781, 19236 => 25684, 19237 => 34928, + 19238 => 29993, 19239 => 24069, 19240 => 26643, 19241 => 25332, 19242 => 38684, + 19243 => 21452, 19244 => 29245, 19245 => 35841, 19246 => 27700, 19247 => 30561, + 19248 => 31246, 19249 => 21550, 19250 => 30636, 19251 => 39034, 19252 => 33308, + 19253 => 35828, 19254 => 30805, 19255 => 26388, 19256 => 28865, 19257 => 26031, + 19258 => 25749, 19259 => 22070, 19260 => 24605, 19261 => 31169, 19262 => 21496, + 19263 => 19997, 19264 => 27515, 19265 => 32902, 19266 => 23546, 19267 => 21987, + 19268 => 22235, 19269 => 20282, 19270 => 20284, 19271 => 39282, 19272 => 24051, + 19273 => 26494, 19274 => 32824, 19275 => 24578, 19276 => 39042, 19277 => 36865, + 19278 => 23435, 19279 => 35772, 19280 => 35829, 19281 => 25628, 19282 => 33368, + 19283 => 25822, 19284 => 22013, 19285 => 33487, 19286 => 37221, 19287 => 20439, + 19288 => 32032, 19289 => 36895, 19290 => 31903, 19291 => 20723, 19292 => 22609, + 19293 => 28335, 19294 => 23487, 19295 => 35785, 19296 => 32899, 19297 => 37240, + 19298 => 33948, 19299 => 31639, 19300 => 34429, 19301 => 38539, 19302 => 38543, + 19303 => 32485, 19304 => 39635, 19305 => 30862, 19306 => 23681, 19307 => 31319, + 19308 => 36930, 19309 => 38567, 19310 => 31071, 19311 => 23385, 19312 => 25439, + 19313 => 31499, 19314 => 34001, 19315 => 26797, 19316 => 21766, 19317 => 32553, + 19318 => 29712, 19319 => 32034, 19320 => 38145, 19321 => 25152, 19322 => 22604, + 19323 => 20182, 19324 => 23427, 19325 => 22905, 19326 => 22612, 19489 => 29549, + 19490 => 25374, 19491 => 36427, 19492 => 36367, 19493 => 32974, 19494 => 33492, + 19495 => 25260, 19496 => 21488, 19497 => 27888, 19498 => 37214, 19499 => 22826, + 19500 => 24577, 19501 => 27760, 19502 => 22349, 19503 => 25674, 19504 => 36138, + 19505 => 30251, 19506 => 28393, 19507 => 22363, 19508 => 27264, 19509 => 30192, + 19510 => 28525, 19511 => 35885, 19512 => 35848, 19513 => 22374, 19514 => 27631, + 19515 => 34962, 19516 => 30899, 19517 => 25506, 19518 => 21497, 19519 => 28845, + 19520 => 27748, 19521 => 22616, 19522 => 25642, 19523 => 22530, 19524 => 26848, + 19525 => 33179, 19526 => 21776, 19527 => 31958, 19528 => 20504, 19529 => 36538, + 19530 => 28108, 19531 => 36255, 19532 => 28907, 19533 => 25487, 19534 => 28059, + 19535 => 28372, 19536 => 32486, 19537 => 33796, 19538 => 26691, 19539 => 36867, + 19540 => 28120, 19541 => 38518, 19542 => 35752, 19543 => 22871, 19544 => 29305, + 19545 => 34276, 19546 => 33150, 19547 => 30140, 19548 => 35466, 19549 => 26799, + 19550 => 21076, 19551 => 36386, 19552 => 38161, 19553 => 25552, 19554 => 39064, + 19555 => 36420, 19556 => 21884, 19557 => 20307, 19558 => 26367, 19559 => 22159, + 19560 => 24789, 19561 => 28053, 19562 => 21059, 19563 => 23625, 19564 => 22825, + 19565 => 28155, 19566 => 22635, 19567 => 30000, 19568 => 29980, 19569 => 24684, + 19570 => 33300, 19571 => 33094, 19572 => 25361, 19573 => 26465, 19574 => 36834, + 19575 => 30522, 19576 => 36339, 19577 => 36148, 19578 => 38081, 19579 => 24086, + 19580 => 21381, 19581 => 21548, 19582 => 28867, 19745 => 27712, 19746 => 24311, + 19747 => 20572, 19748 => 20141, 19749 => 24237, 19750 => 25402, 19751 => 33351, + 19752 => 36890, 19753 => 26704, 19754 => 37230, 19755 => 30643, 19756 => 21516, + 19757 => 38108, 19758 => 24420, 19759 => 31461, 19760 => 26742, 19761 => 25413, + 19762 => 31570, 19763 => 32479, 19764 => 30171, 19765 => 20599, 19766 => 25237, + 19767 => 22836, 19768 => 36879, 19769 => 20984, 19770 => 31171, 19771 => 31361, + 19772 => 22270, 19773 => 24466, 19774 => 36884, 19775 => 28034, 19776 => 23648, + 19777 => 22303, 19778 => 21520, 19779 => 20820, 19780 => 28237, 19781 => 22242, + 19782 => 25512, 19783 => 39059, 19784 => 33151, 19785 => 34581, 19786 => 35114, + 19787 => 36864, 19788 => 21534, 19789 => 23663, 19790 => 33216, 19791 => 25302, + 19792 => 25176, 19793 => 33073, 19794 => 40501, 19795 => 38464, 19796 => 39534, + 19797 => 39548, 19798 => 26925, 19799 => 22949, 19800 => 25299, 19801 => 21822, + 19802 => 25366, 19803 => 21703, 19804 => 34521, 19805 => 27964, 19806 => 23043, + 19807 => 29926, 19808 => 34972, 19809 => 27498, 19810 => 22806, 19811 => 35916, + 19812 => 24367, 19813 => 28286, 19814 => 29609, 19815 => 39037, 19816 => 20024, + 19817 => 28919, 19818 => 23436, 19819 => 30871, 19820 => 25405, 19821 => 26202, + 19822 => 30358, 19823 => 24779, 19824 => 23451, 19825 => 23113, 19826 => 19975, + 19827 => 33109, 19828 => 27754, 19829 => 29579, 19830 => 20129, 19831 => 26505, + 19832 => 32593, 19833 => 24448, 19834 => 26106, 19835 => 26395, 19836 => 24536, + 19837 => 22916, 19838 => 23041, 20001 => 24013, 20002 => 24494, 20003 => 21361, + 20004 => 38886, 20005 => 36829, 20006 => 26693, 20007 => 22260, 20008 => 21807, + 20009 => 24799, 20010 => 20026, 20011 => 28493, 20012 => 32500, 20013 => 33479, + 20014 => 33806, 20015 => 22996, 20016 => 20255, 20017 => 20266, 20018 => 23614, + 20019 => 32428, 20020 => 26410, 20021 => 34074, 20022 => 21619, 20023 => 30031, + 20024 => 32963, 20025 => 21890, 20026 => 39759, 20027 => 20301, 20028 => 28205, + 20029 => 35859, 20030 => 23561, 20031 => 24944, 20032 => 21355, 20033 => 30239, + 20034 => 28201, 20035 => 34442, 20036 => 25991, 20037 => 38395, 20038 => 32441, + 20039 => 21563, 20040 => 31283, 20041 => 32010, 20042 => 38382, 20043 => 21985, + 20044 => 32705, 20045 => 29934, 20046 => 25373, 20047 => 34583, 20048 => 28065, + 20049 => 31389, 20050 => 25105, 20051 => 26017, 20052 => 21351, 20053 => 25569, + 20054 => 27779, 20055 => 24043, 20056 => 21596, 20057 => 38056, 20058 => 20044, + 20059 => 27745, 20060 => 35820, 20061 => 23627, 20062 => 26080, 20063 => 33436, + 20064 => 26791, 20065 => 21566, 20066 => 21556, 20067 => 27595, 20068 => 27494, + 20069 => 20116, 20070 => 25410, 20071 => 21320, 20072 => 33310, 20073 => 20237, + 20074 => 20398, 20075 => 22366, 20076 => 25098, 20077 => 38654, 20078 => 26212, + 20079 => 29289, 20080 => 21247, 20081 => 21153, 20082 => 24735, 20083 => 35823, + 20084 => 26132, 20085 => 29081, 20086 => 26512, 20087 => 35199, 20088 => 30802, + 20089 => 30717, 20090 => 26224, 20091 => 22075, 20092 => 21560, 20093 => 38177, + 20094 => 29306, 20257 => 31232, 20258 => 24687, 20259 => 24076, 20260 => 24713, + 20261 => 33181, 20262 => 22805, 20263 => 24796, 20264 => 29060, 20265 => 28911, + 20266 => 28330, 20267 => 27728, 20268 => 29312, 20269 => 27268, 20270 => 34989, + 20271 => 24109, 20272 => 20064, 20273 => 23219, 20274 => 21916, 20275 => 38115, + 20276 => 27927, 20277 => 31995, 20278 => 38553, 20279 => 25103, 20280 => 32454, + 20281 => 30606, 20282 => 34430, 20283 => 21283, 20284 => 38686, 20285 => 36758, + 20286 => 26247, 20287 => 23777, 20288 => 20384, 20289 => 29421, 20290 => 19979, + 20291 => 21414, 20292 => 22799, 20293 => 21523, 20294 => 25472, 20295 => 38184, + 20296 => 20808, 20297 => 20185, 20298 => 40092, 20299 => 32420, 20300 => 21688, + 20301 => 36132, 20302 => 34900, 20303 => 33335, 20304 => 38386, 20305 => 28046, + 20306 => 24358, 20307 => 23244, 20308 => 26174, 20309 => 38505, 20310 => 29616, + 20311 => 29486, 20312 => 21439, 20313 => 33146, 20314 => 39301, 20315 => 32673, + 20316 => 23466, 20317 => 38519, 20318 => 38480, 20319 => 32447, 20320 => 30456, + 20321 => 21410, 20322 => 38262, 20323 => 39321, 20324 => 31665, 20325 => 35140, + 20326 => 28248, 20327 => 20065, 20328 => 32724, 20329 => 31077, 20330 => 35814, + 20331 => 24819, 20332 => 21709, 20333 => 20139, 20334 => 39033, 20335 => 24055, + 20336 => 27233, 20337 => 20687, 20338 => 21521, 20339 => 35937, 20340 => 33831, + 20341 => 30813, 20342 => 38660, 20343 => 21066, 20344 => 21742, 20345 => 22179, + 20346 => 38144, 20347 => 28040, 20348 => 23477, 20349 => 28102, 20350 => 26195, + 20513 => 23567, 20514 => 23389, 20515 => 26657, 20516 => 32918, 20517 => 21880, + 20518 => 31505, 20519 => 25928, 20520 => 26964, 20521 => 20123, 20522 => 27463, + 20523 => 34638, 20524 => 38795, 20525 => 21327, 20526 => 25375, 20527 => 25658, + 20528 => 37034, 20529 => 26012, 20530 => 32961, 20531 => 35856, 20532 => 20889, + 20533 => 26800, 20534 => 21368, 20535 => 34809, 20536 => 25032, 20537 => 27844, + 20538 => 27899, 20539 => 35874, 20540 => 23633, 20541 => 34218, 20542 => 33455, + 20543 => 38156, 20544 => 27427, 20545 => 36763, 20546 => 26032, 20547 => 24571, + 20548 => 24515, 20549 => 20449, 20550 => 34885, 20551 => 26143, 20552 => 33125, + 20553 => 29481, 20554 => 24826, 20555 => 20852, 20556 => 21009, 20557 => 22411, + 20558 => 24418, 20559 => 37026, 20560 => 34892, 20561 => 37266, 20562 => 24184, + 20563 => 26447, 20564 => 24615, 20565 => 22995, 20566 => 20804, 20567 => 20982, + 20568 => 33016, 20569 => 21256, 20570 => 27769, 20571 => 38596, 20572 => 29066, + 20573 => 20241, 20574 => 20462, 20575 => 32670, 20576 => 26429, 20577 => 21957, + 20578 => 38152, 20579 => 31168, 20580 => 34966, 20581 => 32483, 20582 => 22687, + 20583 => 25100, 20584 => 38656, 20585 => 34394, 20586 => 22040, 20587 => 39035, + 20588 => 24464, 20589 => 35768, 20590 => 33988, 20591 => 37207, 20592 => 21465, + 20593 => 26093, 20594 => 24207, 20595 => 30044, 20596 => 24676, 20597 => 32110, + 20598 => 23167, 20599 => 32490, 20600 => 32493, 20601 => 36713, 20602 => 21927, + 20603 => 23459, 20604 => 24748, 20605 => 26059, 20606 => 29572, 20769 => 36873, + 20770 => 30307, 20771 => 30505, 20772 => 32474, 20773 => 38772, 20774 => 34203, + 20775 => 23398, 20776 => 31348, 20777 => 38634, 20778 => 34880, 20779 => 21195, + 20780 => 29071, 20781 => 24490, 20782 => 26092, 20783 => 35810, 20784 => 23547, + 20785 => 39535, 20786 => 24033, 20787 => 27529, 20788 => 27739, 20789 => 35757, + 20790 => 35759, 20791 => 36874, 20792 => 36805, 20793 => 21387, 20794 => 25276, + 20795 => 40486, 20796 => 40493, 20797 => 21568, 20798 => 20011, 20799 => 33469, + 20800 => 29273, 20801 => 34460, 20802 => 23830, 20803 => 34905, 20804 => 28079, + 20805 => 38597, 20806 => 21713, 20807 => 20122, 20808 => 35766, 20809 => 28937, + 20810 => 21693, 20811 => 38409, 20812 => 28895, 20813 => 28153, 20814 => 30416, + 20815 => 20005, 20816 => 30740, 20817 => 34578, 20818 => 23721, 20819 => 24310, + 20820 => 35328, 20821 => 39068, 20822 => 38414, 20823 => 28814, 20824 => 27839, + 20825 => 22852, 20826 => 25513, 20827 => 30524, 20828 => 34893, 20829 => 28436, + 20830 => 33395, 20831 => 22576, 20832 => 29141, 20833 => 21388, 20834 => 30746, + 20835 => 38593, 20836 => 21761, 20837 => 24422, 20838 => 28976, 20839 => 23476, + 20840 => 35866, 20841 => 39564, 20842 => 27523, 20843 => 22830, 20844 => 40495, + 20845 => 31207, 20846 => 26472, 20847 => 25196, 20848 => 20335, 20849 => 30113, + 20850 => 32650, 20851 => 27915, 20852 => 38451, 20853 => 27687, 20854 => 20208, + 20855 => 30162, 20856 => 20859, 20857 => 26679, 20858 => 28478, 20859 => 36992, + 20860 => 33136, 20861 => 22934, 20862 => 29814, 21025 => 25671, 21026 => 23591, + 21027 => 36965, 21028 => 31377, 21029 => 35875, 21030 => 23002, 21031 => 21676, + 21032 => 33280, 21033 => 33647, 21034 => 35201, 21035 => 32768, 21036 => 26928, + 21037 => 22094, 21038 => 32822, 21039 => 29239, 21040 => 37326, 21041 => 20918, + 21042 => 20063, 21043 => 39029, 21044 => 25494, 21045 => 19994, 21046 => 21494, + 21047 => 26355, 21048 => 33099, 21049 => 22812, 21050 => 28082, 21051 => 19968, + 21052 => 22777, 21053 => 21307, 21054 => 25558, 21055 => 38129, 21056 => 20381, + 21057 => 20234, 21058 => 34915, 21059 => 39056, 21060 => 22839, 21061 => 36951, + 21062 => 31227, 21063 => 20202, 21064 => 33008, 21065 => 30097, 21066 => 27778, + 21067 => 23452, 21068 => 23016, 21069 => 24413, 21070 => 26885, 21071 => 34433, + 21072 => 20506, 21073 => 24050, 21074 => 20057, 21075 => 30691, 21076 => 20197, + 21077 => 33402, 21078 => 25233, 21079 => 26131, 21080 => 37009, 21081 => 23673, + 21082 => 20159, 21083 => 24441, 21084 => 33222, 21085 => 36920, 21086 => 32900, + 21087 => 30123, 21088 => 20134, 21089 => 35028, 21090 => 24847, 21091 => 27589, + 21092 => 24518, 21093 => 20041, 21094 => 30410, 21095 => 28322, 21096 => 35811, + 21097 => 35758, 21098 => 35850, 21099 => 35793, 21100 => 24322, 21101 => 32764, + 21102 => 32716, 21103 => 32462, 21104 => 33589, 21105 => 33643, 21106 => 22240, + 21107 => 27575, 21108 => 38899, 21109 => 38452, 21110 => 23035, 21111 => 21535, + 21112 => 38134, 21113 => 28139, 21114 => 23493, 21115 => 39278, 21116 => 23609, + 21117 => 24341, 21118 => 38544, 21281 => 21360, 21282 => 33521, 21283 => 27185, + 21284 => 23156, 21285 => 40560, 21286 => 24212, 21287 => 32552, 21288 => 33721, + 21289 => 33828, 21290 => 33829, 21291 => 33639, 21292 => 34631, 21293 => 36814, + 21294 => 36194, 21295 => 30408, 21296 => 24433, 21297 => 39062, 21298 => 30828, + 21299 => 26144, 21300 => 21727, 21301 => 25317, 21302 => 20323, 21303 => 33219, + 21304 => 30152, 21305 => 24248, 21306 => 38605, 21307 => 36362, 21308 => 34553, + 21309 => 21647, 21310 => 27891, 21311 => 28044, 21312 => 27704, 21313 => 24703, + 21314 => 21191, 21315 => 29992, 21316 => 24189, 21317 => 20248, 21318 => 24736, + 21319 => 24551, 21320 => 23588, 21321 => 30001, 21322 => 37038, 21323 => 38080, + 21324 => 29369, 21325 => 27833, 21326 => 28216, 21327 => 37193, 21328 => 26377, + 21329 => 21451, 21330 => 21491, 21331 => 20305, 21332 => 37321, 21333 => 35825, + 21334 => 21448, 21335 => 24188, 21336 => 36802, 21337 => 28132, 21338 => 20110, + 21339 => 30402, 21340 => 27014, 21341 => 34398, 21342 => 24858, 21343 => 33286, + 21344 => 20313, 21345 => 20446, 21346 => 36926, 21347 => 40060, 21348 => 24841, + 21349 => 28189, 21350 => 28180, 21351 => 38533, 21352 => 20104, 21353 => 23089, + 21354 => 38632, 21355 => 19982, 21356 => 23679, 21357 => 31161, 21358 => 23431, + 21359 => 35821, 21360 => 32701, 21361 => 29577, 21362 => 22495, 21363 => 33419, + 21364 => 37057, 21365 => 21505, 21366 => 36935, 21367 => 21947, 21368 => 23786, + 21369 => 24481, 21370 => 24840, 21371 => 27442, 21372 => 29425, 21373 => 32946, + 21374 => 35465, 21537 => 28020, 21538 => 23507, 21539 => 35029, 21540 => 39044, + 21541 => 35947, 21542 => 39533, 21543 => 40499, 21544 => 28170, 21545 => 20900, + 21546 => 20803, 21547 => 22435, 21548 => 34945, 21549 => 21407, 21550 => 25588, + 21551 => 36757, 21552 => 22253, 21553 => 21592, 21554 => 22278, 21555 => 29503, + 21556 => 28304, 21557 => 32536, 21558 => 36828, 21559 => 33489, 21560 => 24895, + 21561 => 24616, 21562 => 38498, 21563 => 26352, 21564 => 32422, 21565 => 36234, + 21566 => 36291, 21567 => 38053, 21568 => 23731, 21569 => 31908, 21570 => 26376, + 21571 => 24742, 21572 => 38405, 21573 => 32792, 21574 => 20113, 21575 => 37095, + 21576 => 21248, 21577 => 38504, 21578 => 20801, 21579 => 36816, 21580 => 34164, + 21581 => 37213, 21582 => 26197, 21583 => 38901, 21584 => 23381, 21585 => 21277, + 21586 => 30776, 21587 => 26434, 21588 => 26685, 21589 => 21705, 21590 => 28798, + 21591 => 23472, 21592 => 36733, 21593 => 20877, 21594 => 22312, 21595 => 21681, + 21596 => 25874, 21597 => 26242, 21598 => 36190, 21599 => 36163, 21600 => 33039, + 21601 => 33900, 21602 => 36973, 21603 => 31967, 21604 => 20991, 21605 => 34299, + 21606 => 26531, 21607 => 26089, 21608 => 28577, 21609 => 34468, 21610 => 36481, + 21611 => 22122, 21612 => 36896, 21613 => 30338, 21614 => 28790, 21615 => 29157, + 21616 => 36131, 21617 => 25321, 21618 => 21017, 21619 => 27901, 21620 => 36156, + 21621 => 24590, 21622 => 22686, 21623 => 24974, 21624 => 26366, 21625 => 36192, + 21626 => 25166, 21627 => 21939, 21628 => 28195, 21629 => 26413, 21630 => 36711, + 21793 => 38113, 21794 => 38392, 21795 => 30504, 21796 => 26629, 21797 => 27048, + 21798 => 21643, 21799 => 20045, 21800 => 28856, 21801 => 35784, 21802 => 25688, + 21803 => 25995, 21804 => 23429, 21805 => 31364, 21806 => 20538, 21807 => 23528, + 21808 => 30651, 21809 => 27617, 21810 => 35449, 21811 => 31896, 21812 => 27838, + 21813 => 30415, 21814 => 26025, 21815 => 36759, 21816 => 23853, 21817 => 23637, + 21818 => 34360, 21819 => 26632, 21820 => 21344, 21821 => 25112, 21822 => 31449, + 21823 => 28251, 21824 => 32509, 21825 => 27167, 21826 => 31456, 21827 => 24432, + 21828 => 28467, 21829 => 24352, 21830 => 25484, 21831 => 28072, 21832 => 26454, + 21833 => 19976, 21834 => 24080, 21835 => 36134, 21836 => 20183, 21837 => 32960, + 21838 => 30260, 21839 => 38556, 21840 => 25307, 21841 => 26157, 21842 => 25214, + 21843 => 27836, 21844 => 36213, 21845 => 29031, 21846 => 32617, 21847 => 20806, + 21848 => 32903, 21849 => 21484, 21850 => 36974, 21851 => 25240, 21852 => 21746, + 21853 => 34544, 21854 => 36761, 21855 => 32773, 21856 => 38167, 21857 => 34071, + 21858 => 36825, 21859 => 27993, 21860 => 29645, 21861 => 26015, 21862 => 30495, + 21863 => 29956, 21864 => 30759, 21865 => 33275, 21866 => 36126, 21867 => 38024, + 21868 => 20390, 21869 => 26517, 21870 => 30137, 21871 => 35786, 21872 => 38663, + 21873 => 25391, 21874 => 38215, 21875 => 38453, 21876 => 33976, 21877 => 25379, + 21878 => 30529, 21879 => 24449, 21880 => 29424, 21881 => 20105, 21882 => 24596, + 21883 => 25972, 21884 => 25327, 21885 => 27491, 21886 => 25919, 22049 => 24103, + 22050 => 30151, 22051 => 37073, 22052 => 35777, 22053 => 33437, 22054 => 26525, + 22055 => 25903, 22056 => 21553, 22057 => 34584, 22058 => 30693, 22059 => 32930, + 22060 => 33026, 22061 => 27713, 22062 => 20043, 22063 => 32455, 22064 => 32844, + 22065 => 30452, 22066 => 26893, 22067 => 27542, 22068 => 25191, 22069 => 20540, + 22070 => 20356, 22071 => 22336, 22072 => 25351, 22073 => 27490, 22074 => 36286, + 22075 => 21482, 22076 => 26088, 22077 => 32440, 22078 => 24535, 22079 => 25370, + 22080 => 25527, 22081 => 33267, 22082 => 33268, 22083 => 32622, 22084 => 24092, + 22085 => 23769, 22086 => 21046, 22087 => 26234, 22088 => 31209, 22089 => 31258, + 22090 => 36136, 22091 => 28825, 22092 => 30164, 22093 => 28382, 22094 => 27835, + 22095 => 31378, 22096 => 20013, 22097 => 30405, 22098 => 24544, 22099 => 38047, + 22100 => 34935, 22101 => 32456, 22102 => 31181, 22103 => 32959, 22104 => 37325, + 22105 => 20210, 22106 => 20247, 22107 => 33311, 22108 => 21608, 22109 => 24030, + 22110 => 27954, 22111 => 35788, 22112 => 31909, 22113 => 36724, 22114 => 32920, + 22115 => 24090, 22116 => 21650, 22117 => 30385, 22118 => 23449, 22119 => 26172, + 22120 => 39588, 22121 => 29664, 22122 => 26666, 22123 => 34523, 22124 => 26417, + 22125 => 29482, 22126 => 35832, 22127 => 35803, 22128 => 36880, 22129 => 31481, + 22130 => 28891, 22131 => 29038, 22132 => 25284, 22133 => 30633, 22134 => 22065, + 22135 => 20027, 22136 => 33879, 22137 => 26609, 22138 => 21161, 22139 => 34496, + 22140 => 36142, 22141 => 38136, 22142 => 31569, 22305 => 20303, 22306 => 27880, + 22307 => 31069, 22308 => 39547, 22309 => 25235, 22310 => 29226, 22311 => 25341, + 22312 => 19987, 22313 => 30742, 22314 => 36716, 22315 => 25776, 22316 => 36186, + 22317 => 31686, 22318 => 26729, 22319 => 24196, 22320 => 35013, 22321 => 22918, + 22322 => 25758, 22323 => 22766, 22324 => 29366, 22325 => 26894, 22326 => 38181, + 22327 => 36861, 22328 => 36184, 22329 => 22368, 22330 => 32512, 22331 => 35846, + 22332 => 20934, 22333 => 25417, 22334 => 25305, 22335 => 21331, 22336 => 26700, + 22337 => 29730, 22338 => 33537, 22339 => 37196, 22340 => 21828, 22341 => 30528, + 22342 => 28796, 22343 => 27978, 22344 => 20857, 22345 => 21672, 22346 => 36164, + 22347 => 23039, 22348 => 28363, 22349 => 28100, 22350 => 23388, 22351 => 32043, + 22352 => 20180, 22353 => 31869, 22354 => 28371, 22355 => 23376, 22356 => 33258, + 22357 => 28173, 22358 => 23383, 22359 => 39683, 22360 => 26837, 22361 => 36394, + 22362 => 23447, 22363 => 32508, 22364 => 24635, 22365 => 32437, 22366 => 37049, + 22367 => 36208, 22368 => 22863, 22369 => 25549, 22370 => 31199, 22371 => 36275, + 22372 => 21330, 22373 => 26063, 22374 => 31062, 22375 => 35781, 22376 => 38459, + 22377 => 32452, 22378 => 38075, 22379 => 32386, 22380 => 22068, 22381 => 37257, + 22382 => 26368, 22383 => 32618, 22384 => 23562, 22385 => 36981, 22386 => 26152, + 22387 => 24038, 22388 => 20304, 22389 => 26590, 22390 => 20570, 22391 => 20316, + 22392 => 22352, 22393 => 24231, 22561 => 20109, 22562 => 19980, 22563 => 20800, + 22564 => 19984, 22565 => 24319, 22566 => 21317, 22567 => 19989, 22568 => 20120, + 22569 => 19998, 22570 => 39730, 22571 => 23404, 22572 => 22121, 22573 => 20008, + 22574 => 31162, 22575 => 20031, 22576 => 21269, 22577 => 20039, 22578 => 22829, + 22579 => 29243, 22580 => 21358, 22581 => 27664, 22582 => 22239, 22583 => 32996, + 22584 => 39319, 22585 => 27603, 22586 => 30590, 22587 => 40727, 22588 => 20022, + 22589 => 20127, 22590 => 40720, 22591 => 20060, 22592 => 20073, 22593 => 20115, + 22594 => 33416, 22595 => 23387, 22596 => 21868, 22597 => 22031, 22598 => 20164, + 22599 => 21389, 22600 => 21405, 22601 => 21411, 22602 => 21413, 22603 => 21422, + 22604 => 38757, 22605 => 36189, 22606 => 21274, 22607 => 21493, 22608 => 21286, + 22609 => 21294, 22610 => 21310, 22611 => 36188, 22612 => 21350, 22613 => 21347, + 22614 => 20994, 22615 => 21000, 22616 => 21006, 22617 => 21037, 22618 => 21043, + 22619 => 21055, 22620 => 21056, 22621 => 21068, 22622 => 21086, 22623 => 21089, + 22624 => 21084, 22625 => 33967, 22626 => 21117, 22627 => 21122, 22628 => 21121, + 22629 => 21136, 22630 => 21139, 22631 => 20866, 22632 => 32596, 22633 => 20155, + 22634 => 20163, 22635 => 20169, 22636 => 20162, 22637 => 20200, 22638 => 20193, + 22639 => 20203, 22640 => 20190, 22641 => 20251, 22642 => 20211, 22643 => 20258, + 22644 => 20324, 22645 => 20213, 22646 => 20261, 22647 => 20263, 22648 => 20233, + 22649 => 20267, 22650 => 20318, 22651 => 20327, 22652 => 25912, 22653 => 20314, + 22654 => 20317, 22817 => 20319, 22818 => 20311, 22819 => 20274, 22820 => 20285, + 22821 => 20342, 22822 => 20340, 22823 => 20369, 22824 => 20361, 22825 => 20355, + 22826 => 20367, 22827 => 20350, 22828 => 20347, 22829 => 20394, 22830 => 20348, + 22831 => 20396, 22832 => 20372, 22833 => 20454, 22834 => 20456, 22835 => 20458, + 22836 => 20421, 22837 => 20442, 22838 => 20451, 22839 => 20444, 22840 => 20433, + 22841 => 20447, 22842 => 20472, 22843 => 20521, 22844 => 20556, 22845 => 20467, + 22846 => 20524, 22847 => 20495, 22848 => 20526, 22849 => 20525, 22850 => 20478, + 22851 => 20508, 22852 => 20492, 22853 => 20517, 22854 => 20520, 22855 => 20606, + 22856 => 20547, 22857 => 20565, 22858 => 20552, 22859 => 20558, 22860 => 20588, + 22861 => 20603, 22862 => 20645, 22863 => 20647, 22864 => 20649, 22865 => 20666, + 22866 => 20694, 22867 => 20742, 22868 => 20717, 22869 => 20716, 22870 => 20710, + 22871 => 20718, 22872 => 20743, 22873 => 20747, 22874 => 20189, 22875 => 27709, + 22876 => 20312, 22877 => 20325, 22878 => 20430, 22879 => 40864, 22880 => 27718, + 22881 => 31860, 22882 => 20846, 22883 => 24061, 22884 => 40649, 22885 => 39320, + 22886 => 20865, 22887 => 22804, 22888 => 21241, 22889 => 21261, 22890 => 35335, + 22891 => 21264, 22892 => 20971, 22893 => 22809, 22894 => 20821, 22895 => 20128, + 22896 => 20822, 22897 => 20147, 22898 => 34926, 22899 => 34980, 22900 => 20149, + 22901 => 33044, 22902 => 35026, 22903 => 31104, 22904 => 23348, 22905 => 34819, + 22906 => 32696, 22907 => 20907, 22908 => 20913, 22909 => 20925, 22910 => 20924, + 23073 => 20935, 23074 => 20886, 23075 => 20898, 23076 => 20901, 23077 => 35744, + 23078 => 35750, 23079 => 35751, 23080 => 35754, 23081 => 35764, 23082 => 35765, + 23083 => 35767, 23084 => 35778, 23085 => 35779, 23086 => 35787, 23087 => 35791, + 23088 => 35790, 23089 => 35794, 23090 => 35795, 23091 => 35796, 23092 => 35798, + 23093 => 35800, 23094 => 35801, 23095 => 35804, 23096 => 35807, 23097 => 35808, + 23098 => 35812, 23099 => 35816, 23100 => 35817, 23101 => 35822, 23102 => 35824, + 23103 => 35827, 23104 => 35830, 23105 => 35833, 23106 => 35836, 23107 => 35839, + 23108 => 35840, 23109 => 35842, 23110 => 35844, 23111 => 35847, 23112 => 35852, + 23113 => 35855, 23114 => 35857, 23115 => 35858, 23116 => 35860, 23117 => 35861, + 23118 => 35862, 23119 => 35865, 23120 => 35867, 23121 => 35864, 23122 => 35869, + 23123 => 35871, 23124 => 35872, 23125 => 35873, 23126 => 35877, 23127 => 35879, + 23128 => 35882, 23129 => 35883, 23130 => 35886, 23131 => 35887, 23132 => 35890, + 23133 => 35891, 23134 => 35893, 23135 => 35894, 23136 => 21353, 23137 => 21370, + 23138 => 38429, 23139 => 38434, 23140 => 38433, 23141 => 38449, 23142 => 38442, + 23143 => 38461, 23144 => 38460, 23145 => 38466, 23146 => 38473, 23147 => 38484, + 23148 => 38495, 23149 => 38503, 23150 => 38508, 23151 => 38514, 23152 => 38516, + 23153 => 38536, 23154 => 38541, 23155 => 38551, 23156 => 38576, 23157 => 37015, + 23158 => 37019, 23159 => 37021, 23160 => 37017, 23161 => 37036, 23162 => 37025, + 23163 => 37044, 23164 => 37043, 23165 => 37046, 23166 => 37050, 23329 => 37048, + 23330 => 37040, 23331 => 37071, 23332 => 37061, 23333 => 37054, 23334 => 37072, + 23335 => 37060, 23336 => 37063, 23337 => 37075, 23338 => 37094, 23339 => 37090, + 23340 => 37084, 23341 => 37079, 23342 => 37083, 23343 => 37099, 23344 => 37103, + 23345 => 37118, 23346 => 37124, 23347 => 37154, 23348 => 37150, 23349 => 37155, + 23350 => 37169, 23351 => 37167, 23352 => 37177, 23353 => 37187, 23354 => 37190, + 23355 => 21005, 23356 => 22850, 23357 => 21154, 23358 => 21164, 23359 => 21165, + 23360 => 21182, 23361 => 21759, 23362 => 21200, 23363 => 21206, 23364 => 21232, + 23365 => 21471, 23366 => 29166, 23367 => 30669, 23368 => 24308, 23369 => 20981, + 23370 => 20988, 23371 => 39727, 23372 => 21430, 23373 => 24321, 23374 => 30042, + 23375 => 24047, 23376 => 22348, 23377 => 22441, 23378 => 22433, 23379 => 22654, + 23380 => 22716, 23381 => 22725, 23382 => 22737, 23383 => 22313, 23384 => 22316, + 23385 => 22314, 23386 => 22323, 23387 => 22329, 23388 => 22318, 23389 => 22319, + 23390 => 22364, 23391 => 22331, 23392 => 22338, 23393 => 22377, 23394 => 22405, + 23395 => 22379, 23396 => 22406, 23397 => 22396, 23398 => 22395, 23399 => 22376, + 23400 => 22381, 23401 => 22390, 23402 => 22387, 23403 => 22445, 23404 => 22436, + 23405 => 22412, 23406 => 22450, 23407 => 22479, 23408 => 22439, 23409 => 22452, + 23410 => 22419, 23411 => 22432, 23412 => 22485, 23413 => 22488, 23414 => 22490, + 23415 => 22489, 23416 => 22482, 23417 => 22456, 23418 => 22516, 23419 => 22511, + 23420 => 22520, 23421 => 22500, 23422 => 22493, 23585 => 22539, 23586 => 22541, + 23587 => 22525, 23588 => 22509, 23589 => 22528, 23590 => 22558, 23591 => 22553, + 23592 => 22596, 23593 => 22560, 23594 => 22629, 23595 => 22636, 23596 => 22657, + 23597 => 22665, 23598 => 22682, 23599 => 22656, 23600 => 39336, 23601 => 40729, + 23602 => 25087, 23603 => 33401, 23604 => 33405, 23605 => 33407, 23606 => 33423, + 23607 => 33418, 23608 => 33448, 23609 => 33412, 23610 => 33422, 23611 => 33425, + 23612 => 33431, 23613 => 33433, 23614 => 33451, 23615 => 33464, 23616 => 33470, + 23617 => 33456, 23618 => 33480, 23619 => 33482, 23620 => 33507, 23621 => 33432, + 23622 => 33463, 23623 => 33454, 23624 => 33483, 23625 => 33484, 23626 => 33473, + 23627 => 33449, 23628 => 33460, 23629 => 33441, 23630 => 33450, 23631 => 33439, + 23632 => 33476, 23633 => 33486, 23634 => 33444, 23635 => 33505, 23636 => 33545, + 23637 => 33527, 23638 => 33508, 23639 => 33551, 23640 => 33543, 23641 => 33500, + 23642 => 33524, 23643 => 33490, 23644 => 33496, 23645 => 33548, 23646 => 33531, + 23647 => 33491, 23648 => 33553, 23649 => 33562, 23650 => 33542, 23651 => 33556, + 23652 => 33557, 23653 => 33504, 23654 => 33493, 23655 => 33564, 23656 => 33617, + 23657 => 33627, 23658 => 33628, 23659 => 33544, 23660 => 33682, 23661 => 33596, + 23662 => 33588, 23663 => 33585, 23664 => 33691, 23665 => 33630, 23666 => 33583, + 23667 => 33615, 23668 => 33607, 23669 => 33603, 23670 => 33631, 23671 => 33600, + 23672 => 33559, 23673 => 33632, 23674 => 33581, 23675 => 33594, 23676 => 33587, + 23677 => 33638, 23678 => 33637, 23841 => 33640, 23842 => 33563, 23843 => 33641, + 23844 => 33644, 23845 => 33642, 23846 => 33645, 23847 => 33646, 23848 => 33712, + 23849 => 33656, 23850 => 33715, 23851 => 33716, 23852 => 33696, 23853 => 33706, + 23854 => 33683, 23855 => 33692, 23856 => 33669, 23857 => 33660, 23858 => 33718, + 23859 => 33705, 23860 => 33661, 23861 => 33720, 23862 => 33659, 23863 => 33688, + 23864 => 33694, 23865 => 33704, 23866 => 33722, 23867 => 33724, 23868 => 33729, + 23869 => 33793, 23870 => 33765, 23871 => 33752, 23872 => 22535, 23873 => 33816, + 23874 => 33803, 23875 => 33757, 23876 => 33789, 23877 => 33750, 23878 => 33820, + 23879 => 33848, 23880 => 33809, 23881 => 33798, 23882 => 33748, 23883 => 33759, + 23884 => 33807, 23885 => 33795, 23886 => 33784, 23887 => 33785, 23888 => 33770, + 23889 => 33733, 23890 => 33728, 23891 => 33830, 23892 => 33776, 23893 => 33761, + 23894 => 33884, 23895 => 33873, 23896 => 33882, 23897 => 33881, 23898 => 33907, + 23899 => 33927, 23900 => 33928, 23901 => 33914, 23902 => 33929, 23903 => 33912, + 23904 => 33852, 23905 => 33862, 23906 => 33897, 23907 => 33910, 23908 => 33932, + 23909 => 33934, 23910 => 33841, 23911 => 33901, 23912 => 33985, 23913 => 33997, + 23914 => 34000, 23915 => 34022, 23916 => 33981, 23917 => 34003, 23918 => 33994, + 23919 => 33983, 23920 => 33978, 23921 => 34016, 23922 => 33953, 23923 => 33977, + 23924 => 33972, 23925 => 33943, 23926 => 34021, 23927 => 34019, 23928 => 34060, + 23929 => 29965, 23930 => 34104, 23931 => 34032, 23932 => 34105, 23933 => 34079, + 23934 => 34106, 24097 => 34134, 24098 => 34107, 24099 => 34047, 24100 => 34044, + 24101 => 34137, 24102 => 34120, 24103 => 34152, 24104 => 34148, 24105 => 34142, + 24106 => 34170, 24107 => 30626, 24108 => 34115, 24109 => 34162, 24110 => 34171, + 24111 => 34212, 24112 => 34216, 24113 => 34183, 24114 => 34191, 24115 => 34169, + 24116 => 34222, 24117 => 34204, 24118 => 34181, 24119 => 34233, 24120 => 34231, + 24121 => 34224, 24122 => 34259, 24123 => 34241, 24124 => 34268, 24125 => 34303, + 24126 => 34343, 24127 => 34309, 24128 => 34345, 24129 => 34326, 24130 => 34364, + 24131 => 24318, 24132 => 24328, 24133 => 22844, 24134 => 22849, 24135 => 32823, + 24136 => 22869, 24137 => 22874, 24138 => 22872, 24139 => 21263, 24140 => 23586, + 24141 => 23589, 24142 => 23596, 24143 => 23604, 24144 => 25164, 24145 => 25194, + 24146 => 25247, 24147 => 25275, 24148 => 25290, 24149 => 25306, 24150 => 25303, + 24151 => 25326, 24152 => 25378, 24153 => 25334, 24154 => 25401, 24155 => 25419, + 24156 => 25411, 24157 => 25517, 24158 => 25590, 24159 => 25457, 24160 => 25466, + 24161 => 25486, 24162 => 25524, 24163 => 25453, 24164 => 25516, 24165 => 25482, + 24166 => 25449, 24167 => 25518, 24168 => 25532, 24169 => 25586, 24170 => 25592, + 24171 => 25568, 24172 => 25599, 24173 => 25540, 24174 => 25566, 24175 => 25550, + 24176 => 25682, 24177 => 25542, 24178 => 25534, 24179 => 25669, 24180 => 25665, + 24181 => 25611, 24182 => 25627, 24183 => 25632, 24184 => 25612, 24185 => 25638, + 24186 => 25633, 24187 => 25694, 24188 => 25732, 24189 => 25709, 24190 => 25750, + 24353 => 25722, 24354 => 25783, 24355 => 25784, 24356 => 25753, 24357 => 25786, + 24358 => 25792, 24359 => 25808, 24360 => 25815, 24361 => 25828, 24362 => 25826, + 24363 => 25865, 24364 => 25893, 24365 => 25902, 24366 => 24331, 24367 => 24530, + 24368 => 29977, 24369 => 24337, 24370 => 21343, 24371 => 21489, 24372 => 21501, + 24373 => 21481, 24374 => 21480, 24375 => 21499, 24376 => 21522, 24377 => 21526, + 24378 => 21510, 24379 => 21579, 24380 => 21586, 24381 => 21587, 24382 => 21588, + 24383 => 21590, 24384 => 21571, 24385 => 21537, 24386 => 21591, 24387 => 21593, + 24388 => 21539, 24389 => 21554, 24390 => 21634, 24391 => 21652, 24392 => 21623, + 24393 => 21617, 24394 => 21604, 24395 => 21658, 24396 => 21659, 24397 => 21636, + 24398 => 21622, 24399 => 21606, 24400 => 21661, 24401 => 21712, 24402 => 21677, + 24403 => 21698, 24404 => 21684, 24405 => 21714, 24406 => 21671, 24407 => 21670, + 24408 => 21715, 24409 => 21716, 24410 => 21618, 24411 => 21667, 24412 => 21717, + 24413 => 21691, 24414 => 21695, 24415 => 21708, 24416 => 21721, 24417 => 21722, + 24418 => 21724, 24419 => 21673, 24420 => 21674, 24421 => 21668, 24422 => 21725, + 24423 => 21711, 24424 => 21726, 24425 => 21787, 24426 => 21735, 24427 => 21792, + 24428 => 21757, 24429 => 21780, 24430 => 21747, 24431 => 21794, 24432 => 21795, + 24433 => 21775, 24434 => 21777, 24435 => 21799, 24436 => 21802, 24437 => 21863, + 24438 => 21903, 24439 => 21941, 24440 => 21833, 24441 => 21869, 24442 => 21825, + 24443 => 21845, 24444 => 21823, 24445 => 21840, 24446 => 21820, 24609 => 21815, + 24610 => 21846, 24611 => 21877, 24612 => 21878, 24613 => 21879, 24614 => 21811, + 24615 => 21808, 24616 => 21852, 24617 => 21899, 24618 => 21970, 24619 => 21891, + 24620 => 21937, 24621 => 21945, 24622 => 21896, 24623 => 21889, 24624 => 21919, + 24625 => 21886, 24626 => 21974, 24627 => 21905, 24628 => 21883, 24629 => 21983, + 24630 => 21949, 24631 => 21950, 24632 => 21908, 24633 => 21913, 24634 => 21994, + 24635 => 22007, 24636 => 21961, 24637 => 22047, 24638 => 21969, 24639 => 21995, + 24640 => 21996, 24641 => 21972, 24642 => 21990, 24643 => 21981, 24644 => 21956, + 24645 => 21999, 24646 => 21989, 24647 => 22002, 24648 => 22003, 24649 => 21964, + 24650 => 21965, 24651 => 21992, 24652 => 22005, 24653 => 21988, 24654 => 36756, + 24655 => 22046, 24656 => 22024, 24657 => 22028, 24658 => 22017, 24659 => 22052, + 24660 => 22051, 24661 => 22014, 24662 => 22016, 24663 => 22055, 24664 => 22061, + 24665 => 22104, 24666 => 22073, 24667 => 22103, 24668 => 22060, 24669 => 22093, + 24670 => 22114, 24671 => 22105, 24672 => 22108, 24673 => 22092, 24674 => 22100, + 24675 => 22150, 24676 => 22116, 24677 => 22129, 24678 => 22123, 24679 => 22139, + 24680 => 22140, 24681 => 22149, 24682 => 22163, 24683 => 22191, 24684 => 22228, + 24685 => 22231, 24686 => 22237, 24687 => 22241, 24688 => 22261, 24689 => 22251, + 24690 => 22265, 24691 => 22271, 24692 => 22276, 24693 => 22282, 24694 => 22281, + 24695 => 22300, 24696 => 24079, 24697 => 24089, 24698 => 24084, 24699 => 24081, + 24700 => 24113, 24701 => 24123, 24702 => 24124, 24865 => 24119, 24866 => 24132, + 24867 => 24148, 24868 => 24155, 24869 => 24158, 24870 => 24161, 24871 => 23692, + 24872 => 23674, 24873 => 23693, 24874 => 23696, 24875 => 23702, 24876 => 23688, + 24877 => 23704, 24878 => 23705, 24879 => 23697, 24880 => 23706, 24881 => 23708, + 24882 => 23733, 24883 => 23714, 24884 => 23741, 24885 => 23724, 24886 => 23723, + 24887 => 23729, 24888 => 23715, 24889 => 23745, 24890 => 23735, 24891 => 23748, + 24892 => 23762, 24893 => 23780, 24894 => 23755, 24895 => 23781, 24896 => 23810, + 24897 => 23811, 24898 => 23847, 24899 => 23846, 24900 => 23854, 24901 => 23844, + 24902 => 23838, 24903 => 23814, 24904 => 23835, 24905 => 23896, 24906 => 23870, + 24907 => 23860, 24908 => 23869, 24909 => 23916, 24910 => 23899, 24911 => 23919, + 24912 => 23901, 24913 => 23915, 24914 => 23883, 24915 => 23882, 24916 => 23913, + 24917 => 23924, 24918 => 23938, 24919 => 23961, 24920 => 23965, 24921 => 35955, + 24922 => 23991, 24923 => 24005, 24924 => 24435, 24925 => 24439, 24926 => 24450, + 24927 => 24455, 24928 => 24457, 24929 => 24460, 24930 => 24469, 24931 => 24473, + 24932 => 24476, 24933 => 24488, 24934 => 24493, 24935 => 24501, 24936 => 24508, + 24937 => 34914, 24938 => 24417, 24939 => 29357, 24940 => 29360, 24941 => 29364, + 24942 => 29367, 24943 => 29368, 24944 => 29379, 24945 => 29377, 24946 => 29390, + 24947 => 29389, 24948 => 29394, 24949 => 29416, 24950 => 29423, 24951 => 29417, + 24952 => 29426, 24953 => 29428, 24954 => 29431, 24955 => 29441, 24956 => 29427, + 24957 => 29443, 24958 => 29434, 25121 => 29435, 25122 => 29463, 25123 => 29459, + 25124 => 29473, 25125 => 29450, 25126 => 29470, 25127 => 29469, 25128 => 29461, + 25129 => 29474, 25130 => 29497, 25131 => 29477, 25132 => 29484, 25133 => 29496, + 25134 => 29489, 25135 => 29520, 25136 => 29517, 25137 => 29527, 25138 => 29536, + 25139 => 29548, 25140 => 29551, 25141 => 29566, 25142 => 33307, 25143 => 22821, + 25144 => 39143, 25145 => 22820, 25146 => 22786, 25147 => 39267, 25148 => 39271, + 25149 => 39272, 25150 => 39273, 25151 => 39274, 25152 => 39275, 25153 => 39276, + 25154 => 39284, 25155 => 39287, 25156 => 39293, 25157 => 39296, 25158 => 39300, + 25159 => 39303, 25160 => 39306, 25161 => 39309, 25162 => 39312, 25163 => 39313, + 25164 => 39315, 25165 => 39316, 25166 => 39317, 25167 => 24192, 25168 => 24209, + 25169 => 24203, 25170 => 24214, 25171 => 24229, 25172 => 24224, 25173 => 24249, + 25174 => 24245, 25175 => 24254, 25176 => 24243, 25177 => 36179, 25178 => 24274, + 25179 => 24273, 25180 => 24283, 25181 => 24296, 25182 => 24298, 25183 => 33210, + 25184 => 24516, 25185 => 24521, 25186 => 24534, 25187 => 24527, 25188 => 24579, + 25189 => 24558, 25190 => 24580, 25191 => 24545, 25192 => 24548, 25193 => 24574, + 25194 => 24581, 25195 => 24582, 25196 => 24554, 25197 => 24557, 25198 => 24568, + 25199 => 24601, 25200 => 24629, 25201 => 24614, 25202 => 24603, 25203 => 24591, + 25204 => 24589, 25205 => 24617, 25206 => 24619, 25207 => 24586, 25208 => 24639, + 25209 => 24609, 25210 => 24696, 25211 => 24697, 25212 => 24699, 25213 => 24698, + 25214 => 24642, 25377 => 24682, 25378 => 24701, 25379 => 24726, 25380 => 24730, + 25381 => 24749, 25382 => 24733, 25383 => 24707, 25384 => 24722, 25385 => 24716, + 25386 => 24731, 25387 => 24812, 25388 => 24763, 25389 => 24753, 25390 => 24797, + 25391 => 24792, 25392 => 24774, 25393 => 24794, 25394 => 24756, 25395 => 24864, + 25396 => 24870, 25397 => 24853, 25398 => 24867, 25399 => 24820, 25400 => 24832, + 25401 => 24846, 25402 => 24875, 25403 => 24906, 25404 => 24949, 25405 => 25004, + 25406 => 24980, 25407 => 24999, 25408 => 25015, 25409 => 25044, 25410 => 25077, + 25411 => 24541, 25412 => 38579, 25413 => 38377, 25414 => 38379, 25415 => 38385, + 25416 => 38387, 25417 => 38389, 25418 => 38390, 25419 => 38396, 25420 => 38398, + 25421 => 38403, 25422 => 38404, 25423 => 38406, 25424 => 38408, 25425 => 38410, + 25426 => 38411, 25427 => 38412, 25428 => 38413, 25429 => 38415, 25430 => 38418, + 25431 => 38421, 25432 => 38422, 25433 => 38423, 25434 => 38425, 25435 => 38426, + 25436 => 20012, 25437 => 29247, 25438 => 25109, 25439 => 27701, 25440 => 27732, + 25441 => 27740, 25442 => 27722, 25443 => 27811, 25444 => 27781, 25445 => 27792, + 25446 => 27796, 25447 => 27788, 25448 => 27752, 25449 => 27753, 25450 => 27764, + 25451 => 27766, 25452 => 27782, 25453 => 27817, 25454 => 27856, 25455 => 27860, + 25456 => 27821, 25457 => 27895, 25458 => 27896, 25459 => 27889, 25460 => 27863, + 25461 => 27826, 25462 => 27872, 25463 => 27862, 25464 => 27898, 25465 => 27883, + 25466 => 27886, 25467 => 27825, 25468 => 27859, 25469 => 27887, 25470 => 27902, + 25633 => 27961, 25634 => 27943, 25635 => 27916, 25636 => 27971, 25637 => 27976, + 25638 => 27911, 25639 => 27908, 25640 => 27929, 25641 => 27918, 25642 => 27947, + 25643 => 27981, 25644 => 27950, 25645 => 27957, 25646 => 27930, 25647 => 27983, + 25648 => 27986, 25649 => 27988, 25650 => 27955, 25651 => 28049, 25652 => 28015, + 25653 => 28062, 25654 => 28064, 25655 => 27998, 25656 => 28051, 25657 => 28052, + 25658 => 27996, 25659 => 28000, 25660 => 28028, 25661 => 28003, 25662 => 28186, + 25663 => 28103, 25664 => 28101, 25665 => 28126, 25666 => 28174, 25667 => 28095, + 25668 => 28128, 25669 => 28177, 25670 => 28134, 25671 => 28125, 25672 => 28121, + 25673 => 28182, 25674 => 28075, 25675 => 28172, 25676 => 28078, 25677 => 28203, + 25678 => 28270, 25679 => 28238, 25680 => 28267, 25681 => 28338, 25682 => 28255, + 25683 => 28294, 25684 => 28243, 25685 => 28244, 25686 => 28210, 25687 => 28197, + 25688 => 28228, 25689 => 28383, 25690 => 28337, 25691 => 28312, 25692 => 28384, + 25693 => 28461, 25694 => 28386, 25695 => 28325, 25696 => 28327, 25697 => 28349, + 25698 => 28347, 25699 => 28343, 25700 => 28375, 25701 => 28340, 25702 => 28367, + 25703 => 28303, 25704 => 28354, 25705 => 28319, 25706 => 28514, 25707 => 28486, + 25708 => 28487, 25709 => 28452, 25710 => 28437, 25711 => 28409, 25712 => 28463, + 25713 => 28470, 25714 => 28491, 25715 => 28532, 25716 => 28458, 25717 => 28425, + 25718 => 28457, 25719 => 28553, 25720 => 28557, 25721 => 28556, 25722 => 28536, + 25723 => 28530, 25724 => 28540, 25725 => 28538, 25726 => 28625, 25889 => 28617, + 25890 => 28583, 25891 => 28601, 25892 => 28598, 25893 => 28610, 25894 => 28641, + 25895 => 28654, 25896 => 28638, 25897 => 28640, 25898 => 28655, 25899 => 28698, + 25900 => 28707, 25901 => 28699, 25902 => 28729, 25903 => 28725, 25904 => 28751, + 25905 => 28766, 25906 => 23424, 25907 => 23428, 25908 => 23445, 25909 => 23443, + 25910 => 23461, 25911 => 23480, 25912 => 29999, 25913 => 39582, 25914 => 25652, + 25915 => 23524, 25916 => 23534, 25917 => 35120, 25918 => 23536, 25919 => 36423, + 25920 => 35591, 25921 => 36790, 25922 => 36819, 25923 => 36821, 25924 => 36837, + 25925 => 36846, 25926 => 36836, 25927 => 36841, 25928 => 36838, 25929 => 36851, + 25930 => 36840, 25931 => 36869, 25932 => 36868, 25933 => 36875, 25934 => 36902, + 25935 => 36881, 25936 => 36877, 25937 => 36886, 25938 => 36897, 25939 => 36917, + 25940 => 36918, 25941 => 36909, 25942 => 36911, 25943 => 36932, 25944 => 36945, + 25945 => 36946, 25946 => 36944, 25947 => 36968, 25948 => 36952, 25949 => 36962, + 25950 => 36955, 25951 => 26297, 25952 => 36980, 25953 => 36989, 25954 => 36994, + 25955 => 37000, 25956 => 36995, 25957 => 37003, 25958 => 24400, 25959 => 24407, + 25960 => 24406, 25961 => 24408, 25962 => 23611, 25963 => 21675, 25964 => 23632, + 25965 => 23641, 25966 => 23409, 25967 => 23651, 25968 => 23654, 25969 => 32700, + 25970 => 24362, 25971 => 24361, 25972 => 24365, 25973 => 33396, 25974 => 24380, + 25975 => 39739, 25976 => 23662, 25977 => 22913, 25978 => 22915, 25979 => 22925, + 25980 => 22953, 25981 => 22954, 25982 => 22947, 26145 => 22935, 26146 => 22986, + 26147 => 22955, 26148 => 22942, 26149 => 22948, 26150 => 22994, 26151 => 22962, + 26152 => 22959, 26153 => 22999, 26154 => 22974, 26155 => 23045, 26156 => 23046, + 26157 => 23005, 26158 => 23048, 26159 => 23011, 26160 => 23000, 26161 => 23033, + 26162 => 23052, 26163 => 23049, 26164 => 23090, 26165 => 23092, 26166 => 23057, + 26167 => 23075, 26168 => 23059, 26169 => 23104, 26170 => 23143, 26171 => 23114, + 26172 => 23125, 26173 => 23100, 26174 => 23138, 26175 => 23157, 26176 => 33004, + 26177 => 23210, 26178 => 23195, 26179 => 23159, 26180 => 23162, 26181 => 23230, + 26182 => 23275, 26183 => 23218, 26184 => 23250, 26185 => 23252, 26186 => 23224, + 26187 => 23264, 26188 => 23267, 26189 => 23281, 26190 => 23254, 26191 => 23270, + 26192 => 23256, 26193 => 23260, 26194 => 23305, 26195 => 23319, 26196 => 23318, + 26197 => 23346, 26198 => 23351, 26199 => 23360, 26200 => 23573, 26201 => 23580, + 26202 => 23386, 26203 => 23397, 26204 => 23411, 26205 => 23377, 26206 => 23379, + 26207 => 23394, 26208 => 39541, 26209 => 39543, 26210 => 39544, 26211 => 39546, + 26212 => 39551, 26213 => 39549, 26214 => 39552, 26215 => 39553, 26216 => 39557, + 26217 => 39560, 26218 => 39562, 26219 => 39568, 26220 => 39570, 26221 => 39571, + 26222 => 39574, 26223 => 39576, 26224 => 39579, 26225 => 39580, 26226 => 39581, + 26227 => 39583, 26228 => 39584, 26229 => 39586, 26230 => 39587, 26231 => 39589, + 26232 => 39591, 26233 => 32415, 26234 => 32417, 26235 => 32419, 26236 => 32421, + 26237 => 32424, 26238 => 32425, 26401 => 32429, 26402 => 32432, 26403 => 32446, + 26404 => 32448, 26405 => 32449, 26406 => 32450, 26407 => 32457, 26408 => 32459, + 26409 => 32460, 26410 => 32464, 26411 => 32468, 26412 => 32471, 26413 => 32475, + 26414 => 32480, 26415 => 32481, 26416 => 32488, 26417 => 32491, 26418 => 32494, + 26419 => 32495, 26420 => 32497, 26421 => 32498, 26422 => 32525, 26423 => 32502, + 26424 => 32506, 26425 => 32507, 26426 => 32510, 26427 => 32513, 26428 => 32514, + 26429 => 32515, 26430 => 32519, 26431 => 32520, 26432 => 32523, 26433 => 32524, + 26434 => 32527, 26435 => 32529, 26436 => 32530, 26437 => 32535, 26438 => 32537, + 26439 => 32540, 26440 => 32539, 26441 => 32543, 26442 => 32545, 26443 => 32546, + 26444 => 32547, 26445 => 32548, 26446 => 32549, 26447 => 32550, 26448 => 32551, + 26449 => 32554, 26450 => 32555, 26451 => 32556, 26452 => 32557, 26453 => 32559, + 26454 => 32560, 26455 => 32561, 26456 => 32562, 26457 => 32563, 26458 => 32565, + 26459 => 24186, 26460 => 30079, 26461 => 24027, 26462 => 30014, 26463 => 37013, + 26464 => 29582, 26465 => 29585, 26466 => 29614, 26467 => 29602, 26468 => 29599, + 26469 => 29647, 26470 => 29634, 26471 => 29649, 26472 => 29623, 26473 => 29619, + 26474 => 29632, 26475 => 29641, 26476 => 29640, 26477 => 29669, 26478 => 29657, + 26479 => 39036, 26480 => 29706, 26481 => 29673, 26482 => 29671, 26483 => 29662, + 26484 => 29626, 26485 => 29682, 26486 => 29711, 26487 => 29738, 26488 => 29787, + 26489 => 29734, 26490 => 29733, 26491 => 29736, 26492 => 29744, 26493 => 29742, + 26494 => 29740, 26657 => 29723, 26658 => 29722, 26659 => 29761, 26660 => 29788, + 26661 => 29783, 26662 => 29781, 26663 => 29785, 26664 => 29815, 26665 => 29805, + 26666 => 29822, 26667 => 29852, 26668 => 29838, 26669 => 29824, 26670 => 29825, + 26671 => 29831, 26672 => 29835, 26673 => 29854, 26674 => 29864, 26675 => 29865, + 26676 => 29840, 26677 => 29863, 26678 => 29906, 26679 => 29882, 26680 => 38890, + 26681 => 38891, 26682 => 38892, 26683 => 26444, 26684 => 26451, 26685 => 26462, + 26686 => 26440, 26687 => 26473, 26688 => 26533, 26689 => 26503, 26690 => 26474, + 26691 => 26483, 26692 => 26520, 26693 => 26535, 26694 => 26485, 26695 => 26536, + 26696 => 26526, 26697 => 26541, 26698 => 26507, 26699 => 26487, 26700 => 26492, + 26701 => 26608, 26702 => 26633, 26703 => 26584, 26704 => 26634, 26705 => 26601, + 26706 => 26544, 26707 => 26636, 26708 => 26585, 26709 => 26549, 26710 => 26586, + 26711 => 26547, 26712 => 26589, 26713 => 26624, 26714 => 26563, 26715 => 26552, + 26716 => 26594, 26717 => 26638, 26718 => 26561, 26719 => 26621, 26720 => 26674, + 26721 => 26675, 26722 => 26720, 26723 => 26721, 26724 => 26702, 26725 => 26722, + 26726 => 26692, 26727 => 26724, 26728 => 26755, 26729 => 26653, 26730 => 26709, + 26731 => 26726, 26732 => 26689, 26733 => 26727, 26734 => 26688, 26735 => 26686, + 26736 => 26698, 26737 => 26697, 26738 => 26665, 26739 => 26805, 26740 => 26767, + 26741 => 26740, 26742 => 26743, 26743 => 26771, 26744 => 26731, 26745 => 26818, + 26746 => 26990, 26747 => 26876, 26748 => 26911, 26749 => 26912, 26750 => 26873, + 26913 => 26916, 26914 => 26864, 26915 => 26891, 26916 => 26881, 26917 => 26967, + 26918 => 26851, 26919 => 26896, 26920 => 26993, 26921 => 26937, 26922 => 26976, + 26923 => 26946, 26924 => 26973, 26925 => 27012, 26926 => 26987, 26927 => 27008, + 26928 => 27032, 26929 => 27000, 26930 => 26932, 26931 => 27084, 26932 => 27015, + 26933 => 27016, 26934 => 27086, 26935 => 27017, 26936 => 26982, 26937 => 26979, + 26938 => 27001, 26939 => 27035, 26940 => 27047, 26941 => 27067, 26942 => 27051, + 26943 => 27053, 26944 => 27092, 26945 => 27057, 26946 => 27073, 26947 => 27082, + 26948 => 27103, 26949 => 27029, 26950 => 27104, 26951 => 27021, 26952 => 27135, + 26953 => 27183, 26954 => 27117, 26955 => 27159, 26956 => 27160, 26957 => 27237, + 26958 => 27122, 26959 => 27204, 26960 => 27198, 26961 => 27296, 26962 => 27216, + 26963 => 27227, 26964 => 27189, 26965 => 27278, 26966 => 27257, 26967 => 27197, + 26968 => 27176, 26969 => 27224, 26970 => 27260, 26971 => 27281, 26972 => 27280, + 26973 => 27305, 26974 => 27287, 26975 => 27307, 26976 => 29495, 26977 => 29522, + 26978 => 27521, 26979 => 27522, 26980 => 27527, 26981 => 27524, 26982 => 27538, + 26983 => 27539, 26984 => 27533, 26985 => 27546, 26986 => 27547, 26987 => 27553, + 26988 => 27562, 26989 => 36715, 26990 => 36717, 26991 => 36721, 26992 => 36722, + 26993 => 36723, 26994 => 36725, 26995 => 36726, 26996 => 36728, 26997 => 36727, + 26998 => 36729, 26999 => 36730, 27000 => 36732, 27001 => 36734, 27002 => 36737, + 27003 => 36738, 27004 => 36740, 27005 => 36743, 27006 => 36747, 27169 => 36749, + 27170 => 36750, 27171 => 36751, 27172 => 36760, 27173 => 36762, 27174 => 36558, + 27175 => 25099, 27176 => 25111, 27177 => 25115, 27178 => 25119, 27179 => 25122, + 27180 => 25121, 27181 => 25125, 27182 => 25124, 27183 => 25132, 27184 => 33255, + 27185 => 29935, 27186 => 29940, 27187 => 29951, 27188 => 29967, 27189 => 29969, + 27190 => 29971, 27191 => 25908, 27192 => 26094, 27193 => 26095, 27194 => 26096, + 27195 => 26122, 27196 => 26137, 27197 => 26482, 27198 => 26115, 27199 => 26133, + 27200 => 26112, 27201 => 28805, 27202 => 26359, 27203 => 26141, 27204 => 26164, + 27205 => 26161, 27206 => 26166, 27207 => 26165, 27208 => 32774, 27209 => 26207, + 27210 => 26196, 27211 => 26177, 27212 => 26191, 27213 => 26198, 27214 => 26209, + 27215 => 26199, 27216 => 26231, 27217 => 26244, 27218 => 26252, 27219 => 26279, + 27220 => 26269, 27221 => 26302, 27222 => 26331, 27223 => 26332, 27224 => 26342, + 27225 => 26345, 27226 => 36146, 27227 => 36147, 27228 => 36150, 27229 => 36155, + 27230 => 36157, 27231 => 36160, 27232 => 36165, 27233 => 36166, 27234 => 36168, + 27235 => 36169, 27236 => 36167, 27237 => 36173, 27238 => 36181, 27239 => 36185, + 27240 => 35271, 27241 => 35274, 27242 => 35275, 27243 => 35276, 27244 => 35278, + 27245 => 35279, 27246 => 35280, 27247 => 35281, 27248 => 29294, 27249 => 29343, + 27250 => 29277, 27251 => 29286, 27252 => 29295, 27253 => 29310, 27254 => 29311, + 27255 => 29316, 27256 => 29323, 27257 => 29325, 27258 => 29327, 27259 => 29330, + 27260 => 25352, 27261 => 25394, 27262 => 25520, 27425 => 25663, 27426 => 25816, + 27427 => 32772, 27428 => 27626, 27429 => 27635, 27430 => 27645, 27431 => 27637, + 27432 => 27641, 27433 => 27653, 27434 => 27655, 27435 => 27654, 27436 => 27661, + 27437 => 27669, 27438 => 27672, 27439 => 27673, 27440 => 27674, 27441 => 27681, + 27442 => 27689, 27443 => 27684, 27444 => 27690, 27445 => 27698, 27446 => 25909, + 27447 => 25941, 27448 => 25963, 27449 => 29261, 27450 => 29266, 27451 => 29270, + 27452 => 29232, 27453 => 34402, 27454 => 21014, 27455 => 32927, 27456 => 32924, + 27457 => 32915, 27458 => 32956, 27459 => 26378, 27460 => 32957, 27461 => 32945, + 27462 => 32939, 27463 => 32941, 27464 => 32948, 27465 => 32951, 27466 => 32999, + 27467 => 33000, 27468 => 33001, 27469 => 33002, 27470 => 32987, 27471 => 32962, + 27472 => 32964, 27473 => 32985, 27474 => 32973, 27475 => 32983, 27476 => 26384, + 27477 => 32989, 27478 => 33003, 27479 => 33009, 27480 => 33012, 27481 => 33005, + 27482 => 33037, 27483 => 33038, 27484 => 33010, 27485 => 33020, 27486 => 26389, + 27487 => 33042, 27488 => 35930, 27489 => 33078, 27490 => 33054, 27491 => 33068, + 27492 => 33048, 27493 => 33074, 27494 => 33096, 27495 => 33100, 27496 => 33107, + 27497 => 33140, 27498 => 33113, 27499 => 33114, 27500 => 33137, 27501 => 33120, + 27502 => 33129, 27503 => 33148, 27504 => 33149, 27505 => 33133, 27506 => 33127, + 27507 => 22605, 27508 => 23221, 27509 => 33160, 27510 => 33154, 27511 => 33169, + 27512 => 28373, 27513 => 33187, 27514 => 33194, 27515 => 33228, 27516 => 26406, + 27517 => 33226, 27518 => 33211, 27681 => 33217, 27682 => 33190, 27683 => 27428, + 27684 => 27447, 27685 => 27449, 27686 => 27459, 27687 => 27462, 27688 => 27481, + 27689 => 39121, 27690 => 39122, 27691 => 39123, 27692 => 39125, 27693 => 39129, + 27694 => 39130, 27695 => 27571, 27696 => 24384, 27697 => 27586, 27698 => 35315, + 27699 => 26000, 27700 => 40785, 27701 => 26003, 27702 => 26044, 27703 => 26054, + 27704 => 26052, 27705 => 26051, 27706 => 26060, 27707 => 26062, 27708 => 26066, + 27709 => 26070, 27710 => 28800, 27711 => 28828, 27712 => 28822, 27713 => 28829, + 27714 => 28859, 27715 => 28864, 27716 => 28855, 27717 => 28843, 27718 => 28849, + 27719 => 28904, 27720 => 28874, 27721 => 28944, 27722 => 28947, 27723 => 28950, + 27724 => 28975, 27725 => 28977, 27726 => 29043, 27727 => 29020, 27728 => 29032, + 27729 => 28997, 27730 => 29042, 27731 => 29002, 27732 => 29048, 27733 => 29050, + 27734 => 29080, 27735 => 29107, 27736 => 29109, 27737 => 29096, 27738 => 29088, + 27739 => 29152, 27740 => 29140, 27741 => 29159, 27742 => 29177, 27743 => 29213, + 27744 => 29224, 27745 => 28780, 27746 => 28952, 27747 => 29030, 27748 => 29113, + 27749 => 25150, 27750 => 25149, 27751 => 25155, 27752 => 25160, 27753 => 25161, + 27754 => 31035, 27755 => 31040, 27756 => 31046, 27757 => 31049, 27758 => 31067, + 27759 => 31068, 27760 => 31059, 27761 => 31066, 27762 => 31074, 27763 => 31063, + 27764 => 31072, 27765 => 31087, 27766 => 31079, 27767 => 31098, 27768 => 31109, + 27769 => 31114, 27770 => 31130, 27771 => 31143, 27772 => 31155, 27773 => 24529, + 27774 => 24528, 27937 => 24636, 27938 => 24669, 27939 => 24666, 27940 => 24679, + 27941 => 24641, 27942 => 24665, 27943 => 24675, 27944 => 24747, 27945 => 24838, + 27946 => 24845, 27947 => 24925, 27948 => 25001, 27949 => 24989, 27950 => 25035, + 27951 => 25041, 27952 => 25094, 27953 => 32896, 27954 => 32895, 27955 => 27795, + 27956 => 27894, 27957 => 28156, 27958 => 30710, 27959 => 30712, 27960 => 30720, + 27961 => 30729, 27962 => 30743, 27963 => 30744, 27964 => 30737, 27965 => 26027, + 27966 => 30765, 27967 => 30748, 27968 => 30749, 27969 => 30777, 27970 => 30778, + 27971 => 30779, 27972 => 30751, 27973 => 30780, 27974 => 30757, 27975 => 30764, + 27976 => 30755, 27977 => 30761, 27978 => 30798, 27979 => 30829, 27980 => 30806, + 27981 => 30807, 27982 => 30758, 27983 => 30800, 27984 => 30791, 27985 => 30796, + 27986 => 30826, 27987 => 30875, 27988 => 30867, 27989 => 30874, 27990 => 30855, + 27991 => 30876, 27992 => 30881, 27993 => 30883, 27994 => 30898, 27995 => 30905, + 27996 => 30885, 27997 => 30932, 27998 => 30937, 27999 => 30921, 28000 => 30956, + 28001 => 30962, 28002 => 30981, 28003 => 30964, 28004 => 30995, 28005 => 31012, + 28006 => 31006, 28007 => 31028, 28008 => 40859, 28009 => 40697, 28010 => 40699, + 28011 => 40700, 28012 => 30449, 28013 => 30468, 28014 => 30477, 28015 => 30457, + 28016 => 30471, 28017 => 30472, 28018 => 30490, 28019 => 30498, 28020 => 30489, + 28021 => 30509, 28022 => 30502, 28023 => 30517, 28024 => 30520, 28025 => 30544, + 28026 => 30545, 28027 => 30535, 28028 => 30531, 28029 => 30554, 28030 => 30568, + 28193 => 30562, 28194 => 30565, 28195 => 30591, 28196 => 30605, 28197 => 30589, + 28198 => 30592, 28199 => 30604, 28200 => 30609, 28201 => 30623, 28202 => 30624, + 28203 => 30640, 28204 => 30645, 28205 => 30653, 28206 => 30010, 28207 => 30016, + 28208 => 30030, 28209 => 30027, 28210 => 30024, 28211 => 30043, 28212 => 30066, + 28213 => 30073, 28214 => 30083, 28215 => 32600, 28216 => 32609, 28217 => 32607, + 28218 => 35400, 28219 => 32616, 28220 => 32628, 28221 => 32625, 28222 => 32633, + 28223 => 32641, 28224 => 32638, 28225 => 30413, 28226 => 30437, 28227 => 34866, + 28228 => 38021, 28229 => 38022, 28230 => 38023, 28231 => 38027, 28232 => 38026, + 28233 => 38028, 28234 => 38029, 28235 => 38031, 28236 => 38032, 28237 => 38036, + 28238 => 38039, 28239 => 38037, 28240 => 38042, 28241 => 38043, 28242 => 38044, + 28243 => 38051, 28244 => 38052, 28245 => 38059, 28246 => 38058, 28247 => 38061, + 28248 => 38060, 28249 => 38063, 28250 => 38064, 28251 => 38066, 28252 => 38068, + 28253 => 38070, 28254 => 38071, 28255 => 38072, 28256 => 38073, 28257 => 38074, + 28258 => 38076, 28259 => 38077, 28260 => 38079, 28261 => 38084, 28262 => 38088, + 28263 => 38089, 28264 => 38090, 28265 => 38091, 28266 => 38092, 28267 => 38093, + 28268 => 38094, 28269 => 38096, 28270 => 38097, 28271 => 38098, 28272 => 38101, + 28273 => 38102, 28274 => 38103, 28275 => 38105, 28276 => 38104, 28277 => 38107, + 28278 => 38110, 28279 => 38111, 28280 => 38112, 28281 => 38114, 28282 => 38116, + 28283 => 38117, 28284 => 38119, 28285 => 38120, 28286 => 38122, 28449 => 38121, + 28450 => 38123, 28451 => 38126, 28452 => 38127, 28453 => 38131, 28454 => 38132, + 28455 => 38133, 28456 => 38135, 28457 => 38137, 28458 => 38140, 28459 => 38141, + 28460 => 38143, 28461 => 38147, 28462 => 38146, 28463 => 38150, 28464 => 38151, + 28465 => 38153, 28466 => 38154, 28467 => 38157, 28468 => 38158, 28469 => 38159, + 28470 => 38162, 28471 => 38163, 28472 => 38164, 28473 => 38165, 28474 => 38166, + 28475 => 38168, 28476 => 38171, 28477 => 38173, 28478 => 38174, 28479 => 38175, + 28480 => 38178, 28481 => 38186, 28482 => 38187, 28483 => 38185, 28484 => 38188, + 28485 => 38193, 28486 => 38194, 28487 => 38196, 28488 => 38198, 28489 => 38199, + 28490 => 38200, 28491 => 38204, 28492 => 38206, 28493 => 38207, 28494 => 38210, + 28495 => 38197, 28496 => 38212, 28497 => 38213, 28498 => 38214, 28499 => 38217, + 28500 => 38220, 28501 => 38222, 28502 => 38223, 28503 => 38226, 28504 => 38227, + 28505 => 38228, 28506 => 38230, 28507 => 38231, 28508 => 38232, 28509 => 38233, + 28510 => 38235, 28511 => 38238, 28512 => 38239, 28513 => 38237, 28514 => 38241, + 28515 => 38242, 28516 => 38244, 28517 => 38245, 28518 => 38246, 28519 => 38247, + 28520 => 38248, 28521 => 38249, 28522 => 38250, 28523 => 38251, 28524 => 38252, + 28525 => 38255, 28526 => 38257, 28527 => 38258, 28528 => 38259, 28529 => 38202, + 28530 => 30695, 28531 => 30700, 28532 => 38601, 28533 => 31189, 28534 => 31213, + 28535 => 31203, 28536 => 31211, 28537 => 31238, 28538 => 23879, 28539 => 31235, + 28540 => 31234, 28541 => 31262, 28542 => 31252, 28705 => 31289, 28706 => 31287, + 28707 => 31313, 28708 => 40655, 28709 => 39333, 28710 => 31344, 28711 => 30344, + 28712 => 30350, 28713 => 30355, 28714 => 30361, 28715 => 30372, 28716 => 29918, + 28717 => 29920, 28718 => 29996, 28719 => 40480, 28720 => 40482, 28721 => 40488, + 28722 => 40489, 28723 => 40490, 28724 => 40491, 28725 => 40492, 28726 => 40498, + 28727 => 40497, 28728 => 40502, 28729 => 40504, 28730 => 40503, 28731 => 40505, + 28732 => 40506, 28733 => 40510, 28734 => 40513, 28735 => 40514, 28736 => 40516, + 28737 => 40518, 28738 => 40519, 28739 => 40520, 28740 => 40521, 28741 => 40523, + 28742 => 40524, 28743 => 40526, 28744 => 40529, 28745 => 40533, 28746 => 40535, + 28747 => 40538, 28748 => 40539, 28749 => 40540, 28750 => 40542, 28751 => 40547, + 28752 => 40550, 28753 => 40551, 28754 => 40552, 28755 => 40553, 28756 => 40554, + 28757 => 40555, 28758 => 40556, 28759 => 40561, 28760 => 40557, 28761 => 40563, + 28762 => 30098, 28763 => 30100, 28764 => 30102, 28765 => 30112, 28766 => 30109, + 28767 => 30124, 28768 => 30115, 28769 => 30131, 28770 => 30132, 28771 => 30136, + 28772 => 30148, 28773 => 30129, 28774 => 30128, 28775 => 30147, 28776 => 30146, + 28777 => 30166, 28778 => 30157, 28779 => 30179, 28780 => 30184, 28781 => 30182, + 28782 => 30180, 28783 => 30187, 28784 => 30183, 28785 => 30211, 28786 => 30193, + 28787 => 30204, 28788 => 30207, 28789 => 30224, 28790 => 30208, 28791 => 30213, + 28792 => 30220, 28793 => 30231, 28794 => 30218, 28795 => 30245, 28796 => 30232, + 28797 => 30229, 28798 => 30233, 28961 => 30235, 28962 => 30268, 28963 => 30242, + 28964 => 30240, 28965 => 30272, 28966 => 30253, 28967 => 30256, 28968 => 30271, + 28969 => 30261, 28970 => 30275, 28971 => 30270, 28972 => 30259, 28973 => 30285, + 28974 => 30302, 28975 => 30292, 28976 => 30300, 28977 => 30294, 28978 => 30315, + 28979 => 30319, 28980 => 32714, 28981 => 31462, 28982 => 31352, 28983 => 31353, + 28984 => 31360, 28985 => 31366, 28986 => 31368, 28987 => 31381, 28988 => 31398, + 28989 => 31392, 28990 => 31404, 28991 => 31400, 28992 => 31405, 28993 => 31411, + 28994 => 34916, 28995 => 34921, 28996 => 34930, 28997 => 34941, 28998 => 34943, + 28999 => 34946, 29000 => 34978, 29001 => 35014, 29002 => 34999, 29003 => 35004, + 29004 => 35017, 29005 => 35042, 29006 => 35022, 29007 => 35043, 29008 => 35045, + 29009 => 35057, 29010 => 35098, 29011 => 35068, 29012 => 35048, 29013 => 35070, + 29014 => 35056, 29015 => 35105, 29016 => 35097, 29017 => 35091, 29018 => 35099, + 29019 => 35082, 29020 => 35124, 29021 => 35115, 29022 => 35126, 29023 => 35137, + 29024 => 35174, 29025 => 35195, 29026 => 30091, 29027 => 32997, 29028 => 30386, + 29029 => 30388, 29030 => 30684, 29031 => 32786, 29032 => 32788, 29033 => 32790, + 29034 => 32796, 29035 => 32800, 29036 => 32802, 29037 => 32805, 29038 => 32806, + 29039 => 32807, 29040 => 32809, 29041 => 32808, 29042 => 32817, 29043 => 32779, + 29044 => 32821, 29045 => 32835, 29046 => 32838, 29047 => 32845, 29048 => 32850, + 29049 => 32873, 29050 => 32881, 29051 => 35203, 29052 => 39032, 29053 => 39040, + 29054 => 39043, 29217 => 39049, 29218 => 39052, 29219 => 39053, 29220 => 39055, + 29221 => 39060, 29222 => 39066, 29223 => 39067, 29224 => 39070, 29225 => 39071, + 29226 => 39073, 29227 => 39074, 29228 => 39077, 29229 => 39078, 29230 => 34381, + 29231 => 34388, 29232 => 34412, 29233 => 34414, 29234 => 34431, 29235 => 34426, + 29236 => 34428, 29237 => 34427, 29238 => 34472, 29239 => 34445, 29240 => 34443, + 29241 => 34476, 29242 => 34461, 29243 => 34471, 29244 => 34467, 29245 => 34474, + 29246 => 34451, 29247 => 34473, 29248 => 34486, 29249 => 34500, 29250 => 34485, + 29251 => 34510, 29252 => 34480, 29253 => 34490, 29254 => 34481, 29255 => 34479, + 29256 => 34505, 29257 => 34511, 29258 => 34484, 29259 => 34537, 29260 => 34545, + 29261 => 34546, 29262 => 34541, 29263 => 34547, 29264 => 34512, 29265 => 34579, + 29266 => 34526, 29267 => 34548, 29268 => 34527, 29269 => 34520, 29270 => 34513, + 29271 => 34563, 29272 => 34567, 29273 => 34552, 29274 => 34568, 29275 => 34570, + 29276 => 34573, 29277 => 34569, 29278 => 34595, 29279 => 34619, 29280 => 34590, + 29281 => 34597, 29282 => 34606, 29283 => 34586, 29284 => 34622, 29285 => 34632, + 29286 => 34612, 29287 => 34609, 29288 => 34601, 29289 => 34615, 29290 => 34623, + 29291 => 34690, 29292 => 34594, 29293 => 34685, 29294 => 34686, 29295 => 34683, + 29296 => 34656, 29297 => 34672, 29298 => 34636, 29299 => 34670, 29300 => 34699, + 29301 => 34643, 29302 => 34659, 29303 => 34684, 29304 => 34660, 29305 => 34649, + 29306 => 34661, 29307 => 34707, 29308 => 34735, 29309 => 34728, 29310 => 34770, + 29473 => 34758, 29474 => 34696, 29475 => 34693, 29476 => 34733, 29477 => 34711, + 29478 => 34691, 29479 => 34731, 29480 => 34789, 29481 => 34732, 29482 => 34741, + 29483 => 34739, 29484 => 34763, 29485 => 34771, 29486 => 34749, 29487 => 34769, + 29488 => 34752, 29489 => 34762, 29490 => 34779, 29491 => 34794, 29492 => 34784, + 29493 => 34798, 29494 => 34838, 29495 => 34835, 29496 => 34814, 29497 => 34826, + 29498 => 34843, 29499 => 34849, 29500 => 34873, 29501 => 34876, 29502 => 32566, + 29503 => 32578, 29504 => 32580, 29505 => 32581, 29506 => 33296, 29507 => 31482, + 29508 => 31485, 29509 => 31496, 29510 => 31491, 29511 => 31492, 29512 => 31509, + 29513 => 31498, 29514 => 31531, 29515 => 31503, 29516 => 31559, 29517 => 31544, + 29518 => 31530, 29519 => 31513, 29520 => 31534, 29521 => 31537, 29522 => 31520, + 29523 => 31525, 29524 => 31524, 29525 => 31539, 29526 => 31550, 29527 => 31518, + 29528 => 31576, 29529 => 31578, 29530 => 31557, 29531 => 31605, 29532 => 31564, + 29533 => 31581, 29534 => 31584, 29535 => 31598, 29536 => 31611, 29537 => 31586, + 29538 => 31602, 29539 => 31601, 29540 => 31632, 29541 => 31654, 29542 => 31655, + 29543 => 31672, 29544 => 31660, 29545 => 31645, 29546 => 31656, 29547 => 31621, + 29548 => 31658, 29549 => 31644, 29550 => 31650, 29551 => 31659, 29552 => 31668, + 29553 => 31697, 29554 => 31681, 29555 => 31692, 29556 => 31709, 29557 => 31706, + 29558 => 31717, 29559 => 31718, 29560 => 31722, 29561 => 31756, 29562 => 31742, + 29563 => 31740, 29564 => 31759, 29565 => 31766, 29566 => 31755, 29729 => 31775, + 29730 => 31786, 29731 => 31782, 29732 => 31800, 29733 => 31809, 29734 => 31808, + 29735 => 33278, 29736 => 33281, 29737 => 33282, 29738 => 33284, 29739 => 33260, + 29740 => 34884, 29741 => 33313, 29742 => 33314, 29743 => 33315, 29744 => 33325, + 29745 => 33327, 29746 => 33320, 29747 => 33323, 29748 => 33336, 29749 => 33339, + 29750 => 33331, 29751 => 33332, 29752 => 33342, 29753 => 33348, 29754 => 33353, + 29755 => 33355, 29756 => 33359, 29757 => 33370, 29758 => 33375, 29759 => 33384, + 29760 => 34942, 29761 => 34949, 29762 => 34952, 29763 => 35032, 29764 => 35039, + 29765 => 35166, 29766 => 32669, 29767 => 32671, 29768 => 32679, 29769 => 32687, + 29770 => 32688, 29771 => 32690, 29772 => 31868, 29773 => 25929, 29774 => 31889, + 29775 => 31901, 29776 => 31900, 29777 => 31902, 29778 => 31906, 29779 => 31922, + 29780 => 31932, 29781 => 31933, 29782 => 31937, 29783 => 31943, 29784 => 31948, + 29785 => 31949, 29786 => 31944, 29787 => 31941, 29788 => 31959, 29789 => 31976, + 29790 => 33390, 29791 => 26280, 29792 => 32703, 29793 => 32718, 29794 => 32725, + 29795 => 32741, 29796 => 32737, 29797 => 32742, 29798 => 32745, 29799 => 32750, + 29800 => 32755, 29801 => 31992, 29802 => 32119, 29803 => 32166, 29804 => 32174, + 29805 => 32327, 29806 => 32411, 29807 => 40632, 29808 => 40628, 29809 => 36211, + 29810 => 36228, 29811 => 36244, 29812 => 36241, 29813 => 36273, 29814 => 36199, + 29815 => 36205, 29816 => 35911, 29817 => 35913, 29818 => 37194, 29819 => 37200, + 29820 => 37198, 29821 => 37199, 29822 => 37220, 29985 => 37218, 29986 => 37217, + 29987 => 37232, 29988 => 37225, 29989 => 37231, 29990 => 37245, 29991 => 37246, + 29992 => 37234, 29993 => 37236, 29994 => 37241, 29995 => 37260, 29996 => 37253, + 29997 => 37264, 29998 => 37261, 29999 => 37265, 30000 => 37282, 30001 => 37283, + 30002 => 37290, 30003 => 37293, 30004 => 37294, 30005 => 37295, 30006 => 37301, + 30007 => 37300, 30008 => 37306, 30009 => 35925, 30010 => 40574, 30011 => 36280, + 30012 => 36331, 30013 => 36357, 30014 => 36441, 30015 => 36457, 30016 => 36277, + 30017 => 36287, 30018 => 36284, 30019 => 36282, 30020 => 36292, 30021 => 36310, + 30022 => 36311, 30023 => 36314, 30024 => 36318, 30025 => 36302, 30026 => 36303, + 30027 => 36315, 30028 => 36294, 30029 => 36332, 30030 => 36343, 30031 => 36344, + 30032 => 36323, 30033 => 36345, 30034 => 36347, 30035 => 36324, 30036 => 36361, + 30037 => 36349, 30038 => 36372, 30039 => 36381, 30040 => 36383, 30041 => 36396, + 30042 => 36398, 30043 => 36387, 30044 => 36399, 30045 => 36410, 30046 => 36416, + 30047 => 36409, 30048 => 36405, 30049 => 36413, 30050 => 36401, 30051 => 36425, + 30052 => 36417, 30053 => 36418, 30054 => 36433, 30055 => 36434, 30056 => 36426, + 30057 => 36464, 30058 => 36470, 30059 => 36476, 30060 => 36463, 30061 => 36468, + 30062 => 36485, 30063 => 36495, 30064 => 36500, 30065 => 36496, 30066 => 36508, + 30067 => 36510, 30068 => 35960, 30069 => 35970, 30070 => 35978, 30071 => 35973, + 30072 => 35992, 30073 => 35988, 30074 => 26011, 30075 => 35286, 30076 => 35294, + 30077 => 35290, 30078 => 35292, 30241 => 35301, 30242 => 35307, 30243 => 35311, + 30244 => 35390, 30245 => 35622, 30246 => 38739, 30247 => 38633, 30248 => 38643, + 30249 => 38639, 30250 => 38662, 30251 => 38657, 30252 => 38664, 30253 => 38671, + 30254 => 38670, 30255 => 38698, 30256 => 38701, 30257 => 38704, 30258 => 38718, + 30259 => 40832, 30260 => 40835, 30261 => 40837, 30262 => 40838, 30263 => 40839, + 30264 => 40840, 30265 => 40841, 30266 => 40842, 30267 => 40844, 30268 => 40702, + 30269 => 40715, 30270 => 40717, 30271 => 38585, 30272 => 38588, 30273 => 38589, + 30274 => 38606, 30275 => 38610, 30276 => 30655, 30277 => 38624, 30278 => 37518, + 30279 => 37550, 30280 => 37576, 30281 => 37694, 30282 => 37738, 30283 => 37834, + 30284 => 37775, 30285 => 37950, 30286 => 37995, 30287 => 40063, 30288 => 40066, + 30289 => 40069, 30290 => 40070, 30291 => 40071, 30292 => 40072, 30293 => 31267, + 30294 => 40075, 30295 => 40078, 30296 => 40080, 30297 => 40081, 30298 => 40082, + 30299 => 40084, 30300 => 40085, 30301 => 40090, 30302 => 40091, 30303 => 40094, + 30304 => 40095, 30305 => 40096, 30306 => 40097, 30307 => 40098, 30308 => 40099, + 30309 => 40101, 30310 => 40102, 30311 => 40103, 30312 => 40104, 30313 => 40105, + 30314 => 40107, 30315 => 40109, 30316 => 40110, 30317 => 40112, 30318 => 40113, + 30319 => 40114, 30320 => 40115, 30321 => 40116, 30322 => 40117, 30323 => 40118, + 30324 => 40119, 30325 => 40122, 30326 => 40123, 30327 => 40124, 30328 => 40125, + 30329 => 40132, 30330 => 40133, 30331 => 40134, 30332 => 40135, 30333 => 40138, + 30334 => 40139, 30497 => 40140, 30498 => 40141, 30499 => 40142, 30500 => 40143, + 30501 => 40144, 30502 => 40147, 30503 => 40148, 30504 => 40149, 30505 => 40151, + 30506 => 40152, 30507 => 40153, 30508 => 40156, 30509 => 40157, 30510 => 40159, + 30511 => 40162, 30512 => 38780, 30513 => 38789, 30514 => 38801, 30515 => 38802, + 30516 => 38804, 30517 => 38831, 30518 => 38827, 30519 => 38819, 30520 => 38834, + 30521 => 38836, 30522 => 39601, 30523 => 39600, 30524 => 39607, 30525 => 40536, + 30526 => 39606, 30527 => 39610, 30528 => 39612, 30529 => 39617, 30530 => 39616, + 30531 => 39621, 30532 => 39618, 30533 => 39627, 30534 => 39628, 30535 => 39633, + 30536 => 39749, 30537 => 39747, 30538 => 39751, 30539 => 39753, 30540 => 39752, + 30541 => 39757, 30542 => 39761, 30543 => 39144, 30544 => 39181, 30545 => 39214, + 30546 => 39253, 30547 => 39252, 30548 => 39647, 30549 => 39649, 30550 => 39654, + 30551 => 39663, 30552 => 39659, 30553 => 39675, 30554 => 39661, 30555 => 39673, + 30556 => 39688, 30557 => 39695, 30558 => 39699, 30559 => 39711, 30560 => 39715, + 30561 => 40637, 30562 => 40638, 30563 => 32315, 30564 => 40578, 30565 => 40583, + 30566 => 40584, 30567 => 40587, 30568 => 40594, 30569 => 37846, 30570 => 40605, + 30571 => 40607, 30572 => 40667, 30573 => 40668, 30574 => 40669, 30575 => 40672, + 30576 => 40671, 30577 => 40674, 30578 => 40681, 30579 => 40679, 30580 => 40677, + 30581 => 40682, 30582 => 40687, 30583 => 40738, 30584 => 40748, 30585 => 40751, + 30586 => 40761, 30587 => 40759, 30588 => 40765, 30589 => 40766, 30590 => 40772, + 0 => 0 ); + + function gb2utf8($gb) { + if( !trim($gb) ) return $gb; + $utf8=''; + while($gb) { + if( ord(substr($gb,0,1)) > 127 ) { + $t=substr($gb,0,2); + $gb=substr($gb,2); + $utf8 .= $this->u2utf8($this->codetable[hexdec(bin2hex($t))-0x8080]); + } + else { + $t=substr($gb,0,1); + $gb=substr($gb,1); + $utf8 .= $this->u2utf8($t); + } + } + return $utf8; + } + + function u2utf8($c) { + $str=''; + if ($c < 0x80) { + $str.=$c; + } + else if ($c < 0x800) { + $str.=chr(0xC0 | $c>>6); + $str.=chr(0x80 | $c & 0x3F); + } + else if ($c < 0x10000) { + $str.=chr(0xE0 | $c>>12); + $str.=chr(0x80 | $c>>6 & 0x3F); + $str.=chr(0x80 | $c & 0x3F); + } + else if ($c < 0x200000) { + $str.=chr(0xF0 | $c>>18); + $str.=chr(0x80 | $c>>12 & 0x3F); + $str.=chr(0x80 | $c>>6 & 0x3F); + $str.=chr(0x80 | $c & 0x3F); + } + return $str; + } + +} // END Class + +?> diff --git a/html/jpgraph/jpgraph_gradient.php b/html/jpgraph/jpgraph_gradient.php new file mode 100644 index 0000000..225cf60 --- /dev/null +++ b/html/jpgraph/jpgraph_gradient.php @@ -0,0 +1,434 @@ +<?php +/*======================================================================= + // File: JPGRAPH_GRADIENT.PHP + // Description: Create a color gradient + // Created: 2003-02-01 + // Ver: $Id: jpgraph_gradient.php 1761 2009-08-01 08:31:28Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +// Styles for gradient color fill +define("GRAD_VER",1); +define("GRAD_VERT",1); +define("GRAD_HOR",2); +define("GRAD_MIDHOR",3); +define("GRAD_MIDVER",4); +define("GRAD_CENTER",5); +define("GRAD_WIDE_MIDVER",6); +define("GRAD_WIDE_MIDHOR",7); +define("GRAD_LEFT_REFLECTION",8); +define("GRAD_RIGHT_REFLECTION",9); +define("GRAD_RAISED_PANEL",10); +define("GRAD_DIAGONAL",11); + +//=================================================== +// CLASS Gradient +// Description: Handles gradient fills. This is to be +// considered a "friend" class of Class Image. +//=================================================== +class Gradient { + private $img=null, $numcolors=100; + //--------------- + // CONSTRUCTOR + function __construct(&$img) { + $this->img = $img; + } + + + function SetNumColors($aNum) { + $this->numcolors=$aNum; + } + //--------------- + // PUBLIC METHODS + // Produce a gradient filled rectangle with a smooth transition between + // two colors. + // ($xl,$yt) Top left corner + // ($xr,$yb) Bottom right + // $from_color Starting color in gradient + // $to_color End color in the gradient + // $style Which way is the gradient oriented? + function FilledRectangle($xl,$yt,$xr,$yb,$from_color,$to_color,$style=1) { + $this->img->SetLineWeight(1); + switch( $style ) { + case GRAD_VER: + $steps = ceil(abs($xr-$xl)+1); + $delta = $xr>=$xl ? 1 : -1; + $this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors); + for( $i=0, $x=$xl; $i < $steps; ++$i ) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yt,$x,$yb); + $x += $delta; + } + break; + + case GRAD_HOR: + $steps = ceil(abs($yb-$yt)+1); + $delta = $yb >= $yt ? 1 : -1; + $this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors); + for($i=0,$y=$yt; $i < $steps; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($xl,$y,$xr,$y); + $y += $delta; + } + break; + + case GRAD_MIDHOR: + $steps = ceil(abs($yb-$yt)/2); + $delta = $yb >= $yt ? 1 : -1; + $this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors); + for($y=$yt, $i=0; $i < $steps; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($xl,$y,$xr,$y); + $y += $delta; + } + --$i; + if( abs($yb-$yt) % 2 == 1 ) { + --$steps; + } + for($j=0; $j < $steps; ++$j, --$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($xl,$y,$xr,$y); + $y += $delta; + } + $this->img->Line($xl,$y,$xr,$y); + break; + + case GRAD_MIDVER: + $steps = ceil(abs($xr-$xl)/2); + $delta = $xr>=$xl ? 1 : -1; + $this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors); + for($x=$xl, $i=0; $i < $steps; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + --$i; + if( abs($xr-$xl) % 2 == 1 ) { + --$steps; + } + for($j=0; $j < $steps; ++$j, --$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + $this->img->Line($x,$yb,$x,$yt); + break; + + case GRAD_WIDE_MIDVER: + $diff = ceil(abs($xr-$xl)); + $steps = floor(abs($diff)/3); + $firststep = $diff - 2*$steps ; + $delta = $xr >= $xl ? 1 : -1; + $this->GetColArray($from_color,$to_color,$firststep,$colors,$this->numcolors); + for($x=$xl, $i=0; $i < $firststep; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + --$i; + $this->img->current_color = $colors[$i]; + for($j=0; $j< $steps; ++$j) { + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + + for($j=0; $j < $steps; ++$j, --$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + break; + + case GRAD_WIDE_MIDHOR: + $diff = ceil(abs($yb-$yt)); + $steps = floor(abs($diff)/3); + $firststep = $diff - 2*$steps ; + $delta = $yb >= $yt? 1 : -1; + $this->GetColArray($from_color,$to_color,$firststep,$colors,$this->numcolors); + for($y=$yt, $i=0; $i < $firststep; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($xl,$y,$xr,$y); + $y += $delta; + } + --$i; + $this->img->current_color = $colors[$i]; + for($j=0; $j < $steps; ++$j) { + $this->img->Line($xl,$y,$xr,$y); + $y += $delta; + } + for($j=0; $j < $steps; ++$j, --$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($xl,$y,$xr,$y); + $y += $delta; + } + break; + + case GRAD_LEFT_REFLECTION: + $steps1 = ceil(0.3*abs($xr-$xl)); + $delta = $xr>=$xl ? 1 : -1; + + $from_color = $this->img->rgb->Color($from_color); + $adj = 1.4; + $m = ($adj-1.0)*(255-min(255,min($from_color[0],min($from_color[1],$from_color[2])))); + $from_color2 = array(min(255,$from_color[0]+$m), + min(255,$from_color[1]+$m), min(255,$from_color[2]+$m)); + + $this->GetColArray($from_color2,$to_color,$steps1,$colors,$this->numcolors); + $n = count($colors); + for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + $steps2 = max(1,ceil(0.08*abs($xr-$xl))); + $this->img->SetColor($to_color); + for($j=0; $j< $steps2; ++$j) { + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + $steps = abs($xr-$xl)-$steps1-$steps2; + $this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors); + $n = count($colors); + for($i=0; $i < $steps && $i < $n; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + break; + + case GRAD_RIGHT_REFLECTION: + $steps1 = ceil(0.7*abs($xr-$xl)); + $delta = $xr>=$xl ? 1 : -1; + + $this->GetColArray($from_color,$to_color,$steps1,$colors,$this->numcolors); + $n = count($colors); + for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + $steps2 = max(1,ceil(0.08*abs($xr-$xl))); + $this->img->SetColor($to_color); + for($j=0; $j< $steps2; ++$j) { + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + + $from_color = $this->img->rgb->Color($from_color); + $adj = 1.4; + $m = ($adj-1.0)*(255-min(255,min($from_color[0],min($from_color[1],$from_color[2])))); + $from_color = array(min(255,$from_color[0]+$m), + min(255,$from_color[1]+$m), min(255,$from_color[2]+$m)); + + $steps = abs($xr-$xl)-$steps1-$steps2; + $this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors); + $n = count($colors); + for($i=0; $i < $steps && $i < $n; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + break; + + case GRAD_CENTER: + $steps = ceil(min(($yb-$yt)+1,($xr-$xl)+1)/2); + $this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors); + $dx = ($xr-$xl)/2; + $dy = ($yb-$yt)/2; + $x=$xl;$y=$yt;$x2=$xr;$y2=$yb; + $n = count($colors); + for($x=$xl, $i=0; $x < $xl+$dx && $y < $yt+$dy && $i < $n; ++$x, ++$y, --$x2, --$y2, ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Rectangle($x,$y,$x2,$y2); + } + $this->img->Line($x,$y,$x2,$y2); + break; + + case GRAD_RAISED_PANEL: + // right to left + $steps1 = $xr-$xl; + $delta = $xr>=$xl ? 1 : -1; + $this->GetColArray($to_color,$from_color,$steps1,$colors,$this->numcolors); + $n = count($colors); + for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) { + $this->img->current_color = $colors[$i]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + + // left to right + $xr -= 3; + $xl += 3; + $yb -= 3; + $yt += 3; + $steps2 = $xr-$xl; + $delta = $xr>=$xl ? 1 : -1; + for($x=$xl, $j=$steps2; $j >= 0; --$j) { + $this->img->current_color = $colors[$j]; + $this->img->Line($x,$yb,$x,$yt); + $x += $delta; + } + break; + + case GRAD_DIAGONAL: + // use the longer dimension to determine the required number of steps. + // first loop draws from one corner to the mid-diagonal and the second + // loop draws from the mid-diagonal to the opposing corner. + if($xr-$xl > $yb - $yt) { + // width is greater than height -> use x-dimension for steps + $steps = $xr-$xl; + $delta = $xr>=$xl ? 1 : -1; + $this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors); + $n = count($colors); + + for($x=$xl, $i=0; $i < $steps && $i < $n; ++$i) { + $this->img->current_color = $colors[$i]; + $y = $yt+($i/$steps)*($yb-$yt)*$delta; + $this->img->Line($x,$yt,$xl,$y); + $x += $delta; + } + + for($x=$xl, $i = 0; $i < $steps && $i < $n; ++$i) { + $this->img->current_color = $colors[$steps+$i]; + $y = $yt+($i/$steps)*($yb-$yt)*$delta; + $this->img->Line($x,$yb,$xr,$y); + $x += $delta; + } + } else { + // height is greater than width -> use y-dimension for steps + $steps = $yb-$yt; + $delta = $yb>=$yt ? 1 : -1; + $this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors); + $n = count($colors); + + for($y=$yt, $i=0; $i < $steps && $i < $n; ++$i) { + $this->img->current_color = $colors[$i]; + $x = $xl+($i/$steps)*($xr-$xl)*$delta; + $this->img->Line($x,$yt,$xl,$y); + $y += $delta; + } + + for($y=$yt, $i = 0; $i < $steps && $i < $n; ++$i) { + $this->img->current_color = $colors[$steps+$i]; + $x = $xl+($i/$steps)*($xr-$xl)*$delta; + $this->img->Line($x,$yb,$xr,$y); + $x += $delta; + } + + } + break; + + default: + JpGraphError::RaiseL(7001,$style); + //("Unknown gradient style (=$style)."); + break; + } + } + + // Fill a special case of a polygon with a flat bottom + // with a gradient. Can be used for filled line plots. + // Please note that this is NOT a generic gradient polygon fill + // routine. It assumes that the bottom is flat (like a drawing + // of a mountain) + function FilledFlatPolygon($pts,$from_color,$to_color) { + if( count($pts) == 0 ) return; + + $maxy=$pts[1]; + $miny=$pts[1]; + $n = count($pts) ; + for( $i=0, $idx=0; $i < $n; $i += 2) { + $x = round($pts[$i]); + $y = round($pts[$i+1]); + $miny = min($miny,$y); + $maxy = max($maxy,$y); + } + + $colors = array(); + $this->GetColArray($from_color,$to_color,abs($maxy-$miny)+1,$colors,$this->numcolors); + for($i=$miny, $idx=0; $i <= $maxy; ++$i ) { + $colmap[$i] = $colors[$idx++]; + } + + $n = count($pts)/2 ; + $idx = 0 ; + while( $idx < $n-1 ) { + $p1 = array(round($pts[$idx*2]),round($pts[$idx*2+1])); + $p2 = array(round($pts[++$idx*2]),round($pts[$idx*2+1])); + + // Find the largest rectangle we can fill + $y = max($p1[1],$p2[1]) ; + for($yy=$maxy; $yy > $y; --$yy) { + $this->img->current_color = $colmap[$yy]; + $this->img->Line($p1[0],$yy,$p2[0]-1,$yy); + } + + if( $p1[1] == $p2[1] ) { + continue; + } + + // Fill the rest using lines (slow...) + $slope = ($p2[0]-$p1[0])/($p1[1]-$p2[1]); + $x1 = $p1[0]; + $x2 = $p2[0]-1; + $start = $y; + if( $p1[1] > $p2[1] ) { + while( $y >= $p2[1] ) { + $x1=$slope*($start-$y)+$p1[0]; + $this->img->current_color = $colmap[$y]; + $this->img->Line($x1,$y,$x2,$y); + --$y; + } + } + else { + while( $y >= $p1[1] ) { + $x2=$p2[0]+$slope*($start-$y); + $this->img->current_color = $colmap[$y]; + $this->img->Line($x1,$y,$x2,$y); + --$y; + } + } + } + } + + //--------------- + // PRIVATE METHODS + // Add to the image color map the necessary colors to do the transition + // between the two colors using $numcolors intermediate colors + function GetColArray($from_color,$to_color,$arr_size,&$colors,$numcols=100) { + if( $arr_size==0 ) { + return; + } + + // If color is given as text get it's corresponding r,g,b values + $from_color = $this->img->rgb->Color($from_color); + $to_color = $this->img->rgb->Color($to_color); + + $rdelta=($to_color[0]-$from_color[0])/$numcols; + $gdelta=($to_color[1]-$from_color[1])/$numcols; + $bdelta=($to_color[2]-$from_color[2])/$numcols; + $colorsperstep = $numcols/$arr_size; + $prevcolnum = -1; + $from_alpha = $from_color[3]; + $to_alpha = $to_color[3]; + $adelta = ( $to_alpha - $from_alpha ) / $numcols ; + for ($i=0; $i < $arr_size; ++$i) { + $colnum = floor($colorsperstep*$i); + if ( $colnum == $prevcolnum ) { + $colors[$i] = $colidx; + } + else { + $r = floor($from_color[0] + $colnum*$rdelta); + $g = floor($from_color[1] + $colnum*$gdelta); + $b = floor($from_color[2] + $colnum*$bdelta); + $alpha = $from_alpha + $colnum*$adelta; + $colidx = $this->img->rgb->Allocate(sprintf("#%02x%02x%02x",$r,$g,$b),$alpha); + $colors[$i] = $colidx; + } + $prevcolnum = $colnum; + } + } +} // Class + +?> diff --git a/html/jpgraph/jpgraph_iconplot.php b/html/jpgraph/jpgraph_iconplot.php new file mode 100644 index 0000000..584f801 --- /dev/null +++ b/html/jpgraph/jpgraph_iconplot.php @@ -0,0 +1,190 @@ +<?php +//======================================================================= +// File: JPGRAPH_ICONPLOT.PHP +// Description: Extension module to add icons to plots +// Created: 2004-02-18 +// Ver: $Id: jpgraph_iconplot.php 1404 2009-06-28 15:25:41Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +//=================================================== +// CLASS IconPlot +// Description: Make it possible to add a (small) image +// to the graph +//=================================================== +class IconPlot { + public $iX=0,$iY=0,$iScale=1.0,$iMix=100; + private $iHorAnchor='left',$iVertAnchor='top'; + private $iFile=''; + private $iAnchors = array('left','right','top','bottom','center'); + private $iCountryFlag='',$iCountryStdSize=3; + private $iScalePosY=null,$iScalePosX=null; + private $iImgString=''; + + + function __construct($aFile="",$aX=0,$aY=0,$aScale=1.0,$aMix=100) { + $this->iFile = $aFile; + $this->iX=$aX; + $this->iY=$aY; + $this->iScale= $aScale; + if( $aMix < 0 || $aMix > 100 ) { + JpGraphError::RaiseL(8001); //('Mix value for icon must be between 0 and 100.'); + } + $this->iMix = $aMix ; + } + + function SetCountryFlag($aFlag,$aX=0,$aY=0,$aScale=1.0,$aMix=100,$aStdSize=3) { + $this->iCountryFlag = $aFlag; + $this->iX=$aX; + $this->iY=$aY; + $this->iScale= $aScale; + if( $aMix < 0 || $aMix > 100 ) { + JpGraphError::RaiseL(8001);//'Mix value for icon must be between 0 and 100.'); + } + $this->iMix = $aMix; + $this->iCountryStdSize = $aStdSize; + } + + function SetPos($aX,$aY) { + $this->iX=$aX; + $this->iY=$aY; + } + + function CreateFromString($aStr) { + $this->iImgString = $aStr; + } + + function SetScalePos($aX,$aY) { + $this->iScalePosX = $aX; + $this->iScalePosY = $aY; + } + + function SetScale($aScale) { + $this->iScale = $aScale; + } + + function SetMix($aMix) { + if( $aMix < 0 || $aMix > 100 ) { + JpGraphError::RaiseL(8001);//('Mix value for icon must be between 0 and 100.'); + } + $this->iMix = $aMix ; + } + + function SetAnchor($aXAnchor='left',$aYAnchor='center') { + if( !in_array($aXAnchor,$this->iAnchors) || + !in_array($aYAnchor,$this->iAnchors) ) { + JpGraphError::RaiseL(8002);//("Anchor position for icons must be one of 'top', 'bottom', 'left', 'right' or 'center'"); + } + $this->iHorAnchor=$aXAnchor; + $this->iVertAnchor=$aYAnchor; + } + + function PreStrokeAdjust($aGraph) { + // Nothing to do ... + } + + function DoLegend($aGraph) { + // Nothing to do ... + } + + function Max() { + return array(false,false); + } + + + // The next four function are framework function tht gets called + // from Gantt and is not menaiungfull in the context of Icons but + // they must be implemented to avoid errors. + function GetMaxDate() { return false; } + function GetMinDate() { return false; } + function GetLineNbr() { return 0; } + function GetAbsHeight() {return 0; } + + + function Min() { + return array(false,false); + } + + function StrokeMargin(&$aImg) { + return true; + } + + function Stroke($aImg,$axscale=null,$ayscale=null) { + $this->StrokeWithScale($aImg,$axscale,$ayscale); + } + + function StrokeWithScale($aImg,$axscale,$ayscale) { + if( $this->iScalePosX === null || $this->iScalePosY === null || + $axscale === null || $ayscale === null ) { + $this->_Stroke($aImg); + } + else { + $this->_Stroke($aImg, + round($axscale->Translate($this->iScalePosX)), + round($ayscale->Translate($this->iScalePosY))); + } + } + + function GetWidthHeight() { + $dummy=0; + return $this->_Stroke($dummy,null,null,true); + } + + function _Stroke($aImg,$x=null,$y=null,$aReturnWidthHeight=false) { + if( $this->iFile != '' && $this->iCountryFlag != '' ) { + JpGraphError::RaiseL(8003);//('It is not possible to specify both an image file and a country flag for the same icon.'); + } + if( $this->iFile != '' ) { + $gdimg = Graph::LoadBkgImage('',$this->iFile); + } + elseif( $this->iImgString != '') { + $gdimg = Image::CreateFromString($this->iImgString); + } + + else { + if( ! class_exists('FlagImages',false) ) { + JpGraphError::RaiseL(8004);//('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.'); + } + $fobj = new FlagImages($this->iCountryStdSize); + $dummy=''; + $gdimg = $fobj->GetImgByName($this->iCountryFlag,$dummy); + } + + $iconw = imagesx($gdimg); + $iconh = imagesy($gdimg); + + if( $aReturnWidthHeight ) { + return array(round($iconw*$this->iScale),round($iconh*$this->iScale)); + } + + if( $x !== null && $y !== null ) { + $this->iX = $x; $this->iY = $y; + } + if( $this->iX >= 0 && $this->iX <= 1.0 ) { + $w = imagesx($aImg->img); + $this->iX = round($w*$this->iX); + } + if( $this->iY >= 0 && $this->iY <= 1.0 ) { + $h = imagesy($aImg->img); + $this->iY = round($h*$this->iY); + } + + if( $this->iHorAnchor == 'center' ) + $this->iX -= round($iconw*$this->iScale/2); + if( $this->iHorAnchor == 'right' ) + $this->iX -= round($iconw*$this->iScale); + if( $this->iVertAnchor == 'center' ) + $this->iY -= round($iconh*$this->iScale/2); + if( $this->iVertAnchor == 'bottom' ) + $this->iY -= round($iconh*$this->iScale); + + $aImg->CopyMerge($gdimg,$this->iX,$this->iY,0,0, + round($iconw*$this->iScale),round($iconh*$this->iScale), + $iconw,$iconh, + $this->iMix); + } +} + +?> diff --git a/html/jpgraph/jpgraph_imgtrans.php b/html/jpgraph/jpgraph_imgtrans.php new file mode 100644 index 0000000..411a781 --- /dev/null +++ b/html/jpgraph/jpgraph_imgtrans.php @@ -0,0 +1,223 @@ +<?php +//======================================================================= +// File: JPGRAPH_IMGTRANS.PHP +// Description: Extension for JpGraph to do some simple img transformations +// Created: 2003-09-06 +// Ver: $Id: jpgraph_imgtrans.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +//------------------------------------------------------------------------ +// Class ImgTrans +// Perform some simple image transformations. +//------------------------------------------------------------------------ +class ImgTrans { + private $gdImg=null; + + function __construct($aGdImg) { + // Constructor + $this->gdImg = $aGdImg; + } + + // -------------------------------------------------------------------- + // _TransVert3D() and _TransHor3D() are helper methods to + // Skew3D(). + // -------------------------------------------------------------------- + function _TransVert3D($aGdImg,$aHorizon=100,$aSkewDist=120,$aDir=SKEW3D_DOWN,$aMinSize=true,$aFillColor='#FFFFFF',$aQuality=false,$aBorder=false,$aHorizonPos=0.5) { + + + // Parameter check + if( $aHorizonPos < 0 || $aHorizonPos > 1.0 ) { + JpGraphError::RaiseL(9001); + //("Value for image transformation out of bounds.\nVanishing point on horizon must be specified as a value between 0 and 1."); + } + + $w = imagesx($aGdImg); + $h = imagesy($aGdImg); + + // Create new image + $ww = $w; + if( $aMinSize ) + $hh = ceil($h * $aHorizon / ($aSkewDist+$h)); + else + $hh = $h; + + $newgdh = imagecreatetruecolor($ww,$hh); + $crgb = new RGB( $newgdh ); + $fillColor = $crgb->Allocate($aFillColor); + imagefilledrectangle($newgdh,0,0,$ww-1,$hh-1,$fillColor); + + if( $aBorder ) { + $colidx = $crgb->Allocate($aBorder); + imagerectangle($newgdh,0,0,$ww-1,$hh-1,$colidx); + } + + $mid = round($w * $aHorizonPos); + + $last=$h; + for($y=0; $y < $h; ++$y) { + + $yp = $h-$y-1; + $yt = floor($yp * $aHorizon / ($aSkewDist + $yp)); + + if( !$aQuality ) { + if( $last <= $yt ) continue ; + $last = $yt; + } + + for($x=0; $x < $w; ++$x) { + $xt = ($x-$mid) * $aSkewDist / ($aSkewDist + $yp); + if( $aDir == SKEW3D_UP ) + $rgb = imagecolorat($aGdImg,$x,$h-$y-1); + else + $rgb = imagecolorat($aGdImg,$x,$y); + $r = ($rgb >> 16) & 0xFF; + $g = ($rgb >> 8) & 0xFF; + $b = $rgb & 0xFF; + $colidx = imagecolorallocate($newgdh,$r,$g,$b); + $xt = round($xt+$mid); + if( $aDir == SKEW3D_UP ) { + $syt = $yt; + } + else { + $syt = $hh-$yt-1; + } + + if( !empty($set[$yt]) ) { + $nrgb = imagecolorat($newgdh,$xt,$syt); + $nr = ($nrgb >> 16) & 0xFF; + $ng = ($nrgb >> 8) & 0xFF; + $nb = $nrgb & 0xFF; + $colidx = imagecolorallocate($newgdh,floor(($r+$nr)/2), + floor(($g+$ng)/2),floor(($b+$nb)/2)); + } + + imagesetpixel($newgdh,$xt,$syt,$colidx); + } + + $set[$yt] = true; + } + + return $newgdh; + } + + // -------------------------------------------------------------------- + // _TransVert3D() and _TransHor3D() are helper methods to + // Skew3D(). + // -------------------------------------------------------------------- + function _TransHor3D($aGdImg,$aHorizon=100,$aSkewDist=120,$aDir=SKEW3D_LEFT,$aMinSize=true,$aFillColor='#FFFFFF',$aQuality=false,$aBorder=false,$aHorizonPos=0.5) { + + $w = imagesx($aGdImg); + $h = imagesy($aGdImg); + + // Create new image + $hh = $h; + if( $aMinSize ) + $ww = ceil($w * $aHorizon / ($aSkewDist+$w)); + else + $ww = $w; + + $newgdh = imagecreatetruecolor($ww,$hh); + $crgb = new RGB( $newgdh ); + $fillColor = $crgb->Allocate($aFillColor); + imagefilledrectangle($newgdh,0,0,$ww-1,$hh-1,$fillColor); + + if( $aBorder ) { + $colidx = $crgb->Allocate($aBorder); + imagerectangle($newgdh,0,0,$ww-1,$hh-1,$colidx); + } + + $mid = round($h * $aHorizonPos); + + $last = -1; + for($x=0; $x < $w-1; ++$x) { + $xt = floor($x * $aHorizon / ($aSkewDist + $x)); + if( !$aQuality ) { + if( $last >= $xt ) continue ; + $last = $xt; + } + + for($y=0; $y < $h; ++$y) { + $yp = $h-$y-1; + $yt = ($yp-$mid) * $aSkewDist / ($aSkewDist + $x); + + if( $aDir == SKEW3D_RIGHT ) + $rgb = imagecolorat($aGdImg,$w-$x-1,$y); + else + $rgb = imagecolorat($aGdImg,$x,$y); + $r = ($rgb >> 16) & 0xFF; + $g = ($rgb >> 8) & 0xFF; + $b = $rgb & 0xFF; + $colidx = imagecolorallocate($newgdh,$r,$g,$b); + $yt = floor($hh-$yt-$mid-1); + if( $aDir == SKEW3D_RIGHT ) { + $sxt = $ww-$xt-1; + } + else + $sxt = $xt ; + + if( !empty($set[$xt]) ) { + $nrgb = imagecolorat($newgdh,$sxt,$yt); + $nr = ($nrgb >> 16) & 0xFF; + $ng = ($nrgb >> 8) & 0xFF; + $nb = $nrgb & 0xFF; + $colidx = imagecolorallocate($newgdh,floor(($r+$nr)/2), + floor(($g+$ng)/2),floor(($b+$nb)/2)); + } + imagesetpixel($newgdh,$sxt,$yt,$colidx); + } + + $set[$xt] = true; + } + + return $newgdh; + } + + // -------------------------------------------------------------------- + // Skew image for the apperance of a 3D effect + // This transforms an image into a 3D-skewed version + // of the image. The transformation is specified by giving the height + // of the artificial horizon and specifying a "skew" factor which + // is the distance on the horizon line between the point of + // convergence and perspective line. + // + // The function returns the GD handle of the transformed image + // leaving the original image untouched. + // + // Parameters: + // * $aGdImg, GD handle to the image to be transformed + // * $aHorizon, Distance to the horizon + // * $aSkewDist, Distance from the horizon point of convergence + // on the horizon line to the perspective points. A larger + // value will fore-shorten the image more + // * $aDir, parameter specifies type of convergence. This of this + // as the walls in a room you are looking at. This specifies if the + // image should be applied on the left,right,top or bottom walls. + // * $aMinSize, true=make the new image just as big as needed, + // false = keep the image the same size as the original image + // * $aFillColor, Background fill color in the image + // * $aHiQuality, true=performa some interpolation that improves + // the image quality but at the expense of performace. Enabling + // high quality will have a dramatic effect on the time it takes + // to transform an image. + // * $aBorder, if set to anything besides false this will draw a + // a border of the speciied color around the image + // -------------------------------------------------------------------- + function Skew3D($aHorizon=120,$aSkewDist=150,$aDir=SKEW3D_DOWN,$aHiQuality=false,$aMinSize=true,$aFillColor='#FFFFFF',$aBorder=false) { + return $this->_Skew3D($this->gdImg,$aHorizon,$aSkewDist,$aDir,$aHiQuality, + $aMinSize,$aFillColor,$aBorder); + } + + function _Skew3D($aGdImg,$aHorizon=120,$aSkewDist=150,$aDir=SKEW3D_DOWN,$aHiQuality=false,$aMinSize=true,$aFillColor='#FFFFFF',$aBorder=false) { + if( $aDir == SKEW3D_DOWN || $aDir == SKEW3D_UP ) + return $this->_TransVert3D($aGdImg,$aHorizon,$aSkewDist,$aDir,$aMinSize,$aFillColor,$aHiQuality,$aBorder); + else + return $this->_TransHor3D($aGdImg,$aHorizon,$aSkewDist,$aDir,$aMinSize,$aFillColor,$aHiQuality,$aBorder); + + } + +} + + +?> diff --git a/html/jpgraph/jpgraph_led.php b/html/jpgraph/jpgraph_led.php new file mode 100644 index 0000000..83bb269 --- /dev/null +++ b/html/jpgraph/jpgraph_led.php @@ -0,0 +1,311 @@ +<?php +//======================================================================= +// File: JPGRAPH_LED.PHP +// Description: Module to generate Dotted LED-like digits +// Created: 2006-11-26 +// Ver: $Id: jpgraph_led.php 1674 2009-07-22 19:42:23Z ljp $ +// +// Copyright 2006 (c) Asial Corporation. All rights reserved. +// +// Changed: 2007-08-06 by Alexander Kurochkin (inspector@list.ru) +//======================================================================== + +// Constants for color schema +DEFINE('LEDC_RED', 0); +DEFINE('LEDC_GREEN', 1); +DEFINE('LEDC_BLUE', 2); +DEFINE('LEDC_YELLOW', 3); +DEFINE('LEDC_GRAY', 4); +DEFINE('LEDC_CHOCOLATE', 5); +DEFINE('LEDC_PERU', 6); +DEFINE('LEDC_GOLDENROD', 7); +DEFINE('LEDC_KHAKI', 8); +DEFINE('LEDC_OLIVE', 9); +DEFINE('LEDC_LIMEGREEN', 10); +DEFINE('LEDC_FORESTGREEN', 11); +DEFINE('LEDC_TEAL', 12); +DEFINE('LEDC_STEELBLUE', 13); +DEFINE('LEDC_NAVY', 14); +DEFINE('LEDC_INVERTGRAY', 15); + +// Check that mb_strlen() is available +if( ! function_exists('mb_strlen') ) { + JpGraphError::RaiseL(25500); + //'Multibyte strings must be enabled in the PHP installation in order to run the LED module + // so that the function mb_strlen() is available. See PHP documentation for more information.' +} + +//======================================================================== +// CLASS DigitalLED74 +// Description: +// Construct a number as an image that looks like LED numbers in a +// 7x4 digital matrix +//======================================================================== +class DigitalLED74 +{ + private $iLED_X = 4, $iLED_Y=7, + + // fg-up, fg-down, bg + $iColorSchema = array( + LEDC_RED => array('red','darkred:0.9','red:0.3'),// 0 + LEDC_GREEN => array('green','darkgreen','green:0.3'),// 1 + LEDC_BLUE => array('lightblue:0.9','darkblue:0.85','darkblue:0.7'),// 2 + LEDC_YELLOW => array('yellow','yellow:0.4','yellow:0.3'),// 3 + LEDC_GRAY => array('gray:1.4','darkgray:0.85','darkgray:0.7'), + LEDC_CHOCOLATE => array('chocolate','chocolate:0.7','chocolate:0.5'), + LEDC_PERU => array('peru:0.95','peru:0.6','peru:0.5'), + LEDC_GOLDENROD => array('goldenrod','goldenrod:0.6','goldenrod:0.5'), + LEDC_KHAKI => array('khaki:0.7','khaki:0.4','khaki:0.3'), + LEDC_OLIVE => array('#808000','#808000:0.7','#808000:0.6'), + LEDC_LIMEGREEN => array('limegreen:0.9','limegreen:0.5','limegreen:0.4'), + LEDC_FORESTGREEN => array('forestgreen','forestgreen:0.7','forestgreen:0.5'), + LEDC_TEAL => array('teal','teal:0.7','teal:0.5'), + LEDC_STEELBLUE => array('steelblue','steelblue:0.65','steelblue:0.5'), + LEDC_NAVY => array('navy:1.3','navy:0.95','navy:0.8'),//14 + LEDC_INVERTGRAY => array('darkgray','lightgray:1.5','white')//15 + ), + + /* Each line of the character is encoded as a 4 bit value + 0 ____ + 1 ___x + 2 __x_ + 3 __xx + 4 _x__ + 5 _x_x + 6 _xx_ + 7 _xxx + 8 x___ + 9 x__x + 10 x_x_ + 11 x_xx + 12 xx__ + 13 xx_x + 14 xxx_ + 15 xxxx + */ + + $iLEDSpec = array( + 0 => array(6,9,11,15,13,9,6), + 1 => array(2,6,10,2,2,2,2), + 2 => array(6,9,1,2,4,8,15), + 3 => array(6,9,1,6,1,9,6), + 4 => array(1,3,5,9,15,1,1), + 5 => array(15,8,8,14,1,9,6), + 6 => array(6,8,8,14,9,9,6), + 7 => array(15,1,1,2,4,4,4), + 8 => array(6,9,9,6,9,9,6), + 9 => array(6,9,9,7,1,1,6), + '!' => array(4,4,4,4,4,0,4), + '?' => array(6,9,1,2,2,0,2), + '#' => array(0,9,15,9,15,9,0), + '@' => array(6,9,11,11,10,9,6), + '-' => array(0,0,0,15,0,0,0), + '_' => array(0,0,0,0,0,0,15), + '=' => array(0,0,15,0,15,0,0), + '+' => array(0,0,4,14,4,0,0), + '|' => array(4,4,4,4,4,4,4), //vertical line, used for simulate rus 'Ы' + ',' => array(0,0,0,0,0,12,4), + '.' => array(0,0,0,0,0,12,12), + ':' => array(12,12,0,0,0,12,12), + ';' => array(12,12,0,0,0,12,4), + '[' => array(3,2,2,2,2,2,3), + ']' => array(12,4,4,4,4,4,12), + '(' => array(1,2,2,2,2,2,1), + ')' => array(8,4,4,4,4,4,8), + '{' => array(3,2,2,6,2,2,3), + '}' => array(12,4,4,6,4,4,12), + '<' => array(1,2,4,8,4,2,1), + '>' => array(8,4,2,1,2,4,8), + '*' => array(9,6,15,6,9,0,0), + '"' => array(10,10,0,0,0,0,0), + '\'' => array(4,4,0,0,0,0,0), + '`' => array(4,2,0,0,0,0,0), + '~' => array(13,11,0,0,0,0,0), + '^' => array(4,10,0,0,0,0,0), + '\\' => array(8,8,4,6,2,1,1), + '/' => array(1,1,2,6,4,8,8), + '%' => array(1,9,2,6,4,9,8), + '&' => array(0,4,10,4,11,10,5), + '$' => array(2,7,8,6,1,14,4), + ' ' => array(0,0,0,0,0,0,0), + '•' => array(0,0,6,6,0,0,0), //149 + '°' => array(14,10,14,0,0,0,0), //176 + '†' => array(4,4,14,4,4,4,4), //134 + '‡' => array(4,4,14,4,14,4,4), //135 + '±' => array(0,4,14,4,0,14,0), //177 + '‰' => array(0,4,2,15,2,4,0), //137 show right arrow + '™' => array(0,2,4,15,4,2,0), //156 show left arrow + 'Ў' => array(0,0,8,8,0,0,0), //159 show small hi-stick - that need for simulate rus 'Ф' + "\t" => array(8,8,8,0,0,0,0), //show hi-stick - that need for simulate rus 'У' + "\r" => array(8,8,8,8,8,8,8), //vertical line - that need for simulate 'M', 'W' and rus 'М','Ш' ,'Щ' + "\n" => array(15,15,15,15,15,15,15), //fill up - that need for simulate rus 'Ж' + "Ґ" => array(10,5,10,5,10,5,10), //chess + "µ" => array(15,0,15,0,15,0,15), //4 horizontal lines + // latin + 'A' => array(6,9,9,15,9,9,9), + 'B' => array(14,9,9,14,9,9,14), + 'C' => array(6,9,8,8,8,9,6), + 'D' => array(14,9,9,9,9,9,14), + 'E' => array(15,8,8,14,8,8,15), + 'F' => array(15,8,8,14,8,8,8), + 'G' => array(6,9,8,8,11,9,6), + 'H' => array(9,9,9,15,9,9,9), + 'I' => array(14,4,4,4,4,4,14), + 'J' => array(15,1,1,1,1,9,6), + 'K' => array(8,9,10,12,12,10,9), + 'L' => array(8,8,8,8,8,8,15), + 'M' => array(8,13,10,8,8,8,8),// need to add \r + 'N' => array(9,9,13,11,9,9,9), + 'O' => array(6,9,9,9,9,9,6), + 'P' => array(14,9,9,14,8,8,8), + 'Q' => array(6,9,9,9,13,11,6), + 'R' => array(14,9,9,14,12,10,9), + 'S' => array(6,9,8,6,1,9,6), + 'T' => array(14,4,4,4,4,4,4), + 'U' => array(9,9,9,9,9,9,6), + 'V' => array(0,0,0,10,10,10,4), + 'W' => array(8,8,8,8,10,13,8),// need to add \r + 'X' => array(9,9,6,6,6,9,9), + 'Y' => array(10,10,10,10,4,4,4), + 'Z' => array(15,1,2,6,4,8,15), + // russian utf-8 + 'А' => array(6,9,9,15,9,9,9), + 'Б' => array(14,8,8,14,9,9,14), + 'В' => array(14,9,9,14,9,9,14), + 'Г' => array(15,8,8,8,8,8,8), + 'Д' => array(14,9,9,9,9,9,14), + 'Е' => array(15,8,8,14,8,8,15), + 'Ё' => array(6,15,8,14,8,8,15), + //Ж is combine: >\n< + 'З' => array(6,9,1,2,1,9,6), + 'И' => array(9,9,9,11,13,9,9), + 'Й' => array(13,9,9,11,13,9,9), + 'К' => array(9,10,12,10,9,9,9), + 'Л' => array(7,9,9,9,9,9,9), + 'М' => array(8,13,10,8,8,8,8),// need to add \r + 'Н' => array(9,9,9,15,9,9,9), + 'О' => array(6,9,9,9,9,9,6), + 'П' => array(15,9,9,9,9,9,9), + 'Р' => array(14,9,9,14,8,8,8), + 'С' => array(6,9,8,8,8,9,6), + 'Т' => array(14,4,4,4,4,4,4), + 'У' => array(9,9,9,7,1,9,6), + 'Ф' => array(2,7,10,10,7,2,2),// need to add Ў + 'Х' => array(9,9,6,6,6,9,9), + 'Ц' => array(10,10,10,10,10,15,1), + 'Ч' => array(9,9,9,7,1,1,1), + 'Ш' => array(10,10,10,10,10,10,15),// \r + 'Щ' => array(10,10,10,10,10,15,0),// need to add \r + 'Ъ' => array(12,4,4,6,5,5,6), + 'Ы' => array(8,8,8,14,9,9,14),// need to add | + 'Ь' => array(8,8,8,14,9,9,14), + 'Э' => array(6,9,1,7,1,9,6), + 'Ю' => array(2,2,2,3,2,2,2),// need to add O + 'Я' => array(7,9,9,7,3,5,9) + ), + + $iSuperSampling = 3, $iMarg = 1, $iRad = 4; + + function __construct($aRadius = 2, $aMargin= 0.6) { + $this->iRad = $aRadius; + $this->iMarg = $aMargin; + } + + function SetSupersampling($aSuperSampling = 2) { + $this->iSuperSampling = $aSuperSampling; + } + + function _GetLED($aLedIdx, $aColor = 0) { + $width= $this->iLED_X*$this->iRad*2 + ($this->iLED_X+1)*$this->iMarg + $this->iRad ; + $height= $this->iLED_Y*$this->iRad*2 + ($this->iLED_Y)*$this->iMarg + $this->iRad * 2; + + // Adjust radious for supersampling + $rad = $this->iRad * $this->iSuperSampling; + + // Margin in between "Led" dots + $marg = $this->iMarg * $this->iSuperSampling; + + $swidth = $width*$this->iSuperSampling; + $sheight = $height*$this->iSuperSampling; + + $simg = new RotImage($swidth, $sheight, 0, DEFAULT_GFORMAT, false); + $simg->SetColor($this->iColorSchema[$aColor][2]); + $simg->FilledRectangle(0, 0, $swidth-1, $sheight-1); + + if( array_key_exists($aLedIdx, $this->iLEDSpec) ) { + $d = $this->iLEDSpec[$aLedIdx]; + } + else { + $d = array(0,0,0,0,0,0,0); + } + + for($r = 0; $r < 7; ++$r) { + $dr = $d[$r]; + for($c = 0; $c < 4; ++$c) { + if( ($dr & pow(2,3-$c)) !== 0 ) { + $color = $this->iColorSchema[$aColor][0]; + } + else { + $color = $this->iColorSchema[$aColor][1]; + } + + $x = 2*$rad*$c+$rad + ($c+1)*$marg + $rad ; + $y = 2*$rad*$r+$rad + ($r+1)*$marg + $rad ; + + $simg->SetColor($color); + $simg->FilledCircle($x,$y,$rad); + } + } + + $img = new Image($width, $height, DEFAULT_GFORMAT, false); + $img->Copy($simg->img, 0, 0, 0, 0, $width, $height, $swidth, $sheight); + $simg->Destroy(); + unset($simg); + return $img; + } + + + function Stroke($aValStr, $aColor = 0, $aFileName = '') { + $this->StrokeNumber($aValStr, $aColor, $aFileName); + } + + + function StrokeNumber($aValStr, $aColor = 0, $aFileName = '') { + if( $aColor < 0 || $aColor >= sizeof($this->iColorSchema) ) { + $aColor = 0; + } + + if(($n = mb_strlen($aValStr,'utf8')) == 0) { + $aValStr = ' '; + $n = 1; + } + + for($i = 0; $i < $n; ++$i) { + $d = mb_substr($aValStr, $i, 1, 'utf8'); + if( ctype_digit($d) ) { + $d = (int)$d; + } + else { + $d = strtoupper($d); + } + $digit_img[$i] = $this->_GetLED($d, $aColor); + } + + $w = imagesx($digit_img[0]->img); + $h = imagesy($digit_img[0]->img); + + $number_img = new Image($w*$n, $h, DEFAULT_GFORMAT, false); + + for($i = 0; $i < $n; ++$i) { + $number_img->Copy($digit_img[$i]->img, $i*$w, 0, 0, 0, $w, $h, $w, $h); + } + + if( $aFileName != '' ) { + $number_img->Stream($aFileName); + } else { + $number_img->Headers(); + $number_img->Stream(); + } + } +} +?> diff --git a/html/jpgraph/jpgraph_legend.inc.php b/html/jpgraph/jpgraph_legend.inc.php new file mode 100644 index 0000000..c7f38b5 --- /dev/null +++ b/html/jpgraph/jpgraph_legend.inc.php @@ -0,0 +1,494 @@ +<?php +//======================================================================= +// File: JPGRAPH_LEGEND.INC.PHP +// Description: Class to handle the legend box in the graph that gives +// names on the data series. The number of rows and columns +// in the legend are user specifyable. +// Created: 2001-01-08 (Refactored to separate file 2008-08-01) +// Ver: $Id: jpgraph_legend.inc.php 1926 2010-01-11 16:33:07Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +DEFINE('_DEFAULT_LPM_SIZE',8); // Default Legend Plot Mark size + + +//=================================================== +// CLASS Legend +// Description: Responsible for drawing the box containing +// all the legend text for the graph +//=================================================== + +class Legend { + public $txtcol=array(); + public $font_family=FF_DEFAULT,$font_style=FS_NORMAL,$font_size=8; // old. 12 + private $color=array(120,120,120); // Default frame color + private $fill_color=array(245,245,245); // Default fill color + private $shadow=false; // Shadow around legend "box" + private $shadow_color='darkgray'; + private $mark_abs_hsize=_DEFAULT_LPM_SIZE,$mark_abs_vsize=_DEFAULT_LPM_SIZE; + private $xmargin=10,$ymargin=0,$shadow_width=2; + private $xlmargin=4; + private $ylinespacing=5; + + // We need a separate margin since the baseline of the last text would coincide with the bottom otherwise + private $ybottom_margin = 8; + + private $xpos=0.05, $ypos=0.15, $xabspos=-1, $yabspos=-1; + private $halign="right", $valign="top"; + private $font_color='black'; + private $hide=false,$layout_n=1; + private $weight=1,$frameweight=1; + private $csimareas=''; + private $reverse = false ; + private $bkg_gradtype=-1, $bkg_gradfrom='lightgray', $bkg_gradto='gray'; + + //--------------- + // CONSTRUCTOR + function __construct() { + // Empty + } + //--------------- + // PUBLIC METHODS + function Hide($aHide=true) { + $this->hide=$aHide; + } + + function SetHColMargin($aXMarg) { + $this->xmargin = $aXMarg; + } + + function SetVColMargin($aSpacing) { + $this->ylinespacing = $aSpacing ; + } + + function SetLeftMargin($aXMarg) { + $this->xlmargin = $aXMarg; + } + + // Synonym + function SetLineSpacing($aSpacing) { + $this->ylinespacing = $aSpacing ; + } + + function SetShadow($aShow='gray',$aWidth=4) { + if( is_string($aShow) ) { + $this->shadow_color = $aShow; + $this->shadow=true; + } + else { + $this->shadow = $aShow; + } + $this->shadow_width = $aWidth; + } + + function SetMarkAbsSize($aSize) { + $this->mark_abs_vsize = $aSize ; + $this->mark_abs_hsize = $aSize ; + } + + function SetMarkAbsVSize($aSize) { + $this->mark_abs_vsize = $aSize ; + } + + function SetMarkAbsHSize($aSize) { + $this->mark_abs_hsize = $aSize ; + } + + function SetLineWeight($aWeight) { + $this->weight = $aWeight; + } + + function SetFrameWeight($aWeight) { + $this->frameweight = $aWeight; + } + + function SetLayout($aDirection=LEGEND_VERT) { + $this->layout_n = $aDirection==LEGEND_VERT ? 1 : 99 ; + } + + function SetColumns($aCols) { + $this->layout_n = $aCols ; + } + + function SetReverse($f=true) { + $this->reverse = $f ; + } + + // Set color on frame around box + function SetColor($aFontColor,$aColor='black') { + $this->font_color=$aFontColor; + $this->color=$aColor; + } + + function SetFont($aFamily,$aStyle=FS_NORMAL,$aSize=10) { + $this->font_family = $aFamily; + $this->font_style = $aStyle; + $this->font_size = $aSize; + } + + function SetPos($aX,$aY,$aHAlign='right',$aVAlign='top') { + $this->Pos($aX,$aY,$aHAlign,$aVAlign); + } + + function SetAbsPos($aX,$aY,$aHAlign='right',$aVAlign='top') { + $this->xabspos=$aX; + $this->yabspos=$aY; + $this->halign=$aHAlign; + $this->valign=$aVAlign; + } + + function Pos($aX,$aY,$aHAlign='right',$aVAlign='top') { + if( !($aX<1 && $aY<1) ) { + JpGraphError::RaiseL(25120);//(" Position for legend must be given as percentage in range 0-1"); + } + $this->xpos=$aX; + $this->ypos=$aY; + $this->halign=$aHAlign; + $this->valign=$aVAlign; + } + + function SetFillColor($aColor) { + $this->fill_color=$aColor; + } + + function Clear() { + $this->txtcol = array(); + } + + function Add($aTxt,$aColor,$aPlotmark='',$aLinestyle=0,$csimtarget='',$csimalt='',$csimwintarget='') { + $this->txtcol[]=array($aTxt,$aColor,$aPlotmark,$aLinestyle,$csimtarget,$csimalt,$csimwintarget); + } + + function GetCSIMAreas() { + return $this->csimareas; + } + + function SetBackgroundGradient($aFrom='navy',$aTo='silver',$aGradType=2) { + $this->bkg_gradtype=$aGradType; + $this->bkg_gradfrom = $aFrom; + $this->bkg_gradto = $aTo; + } + + function HasItems() { + return (boolean)(count($this->txtcol)); + } + + function Stroke($aImg) { + // Constant + $fillBoxFrameWeight=1; + + if( $this->hide ) return; + + $aImg->SetFont($this->font_family,$this->font_style,$this->font_size); + + if( $this->reverse ) { + $this->txtcol = array_reverse($this->txtcol); + } + + $n=count($this->txtcol); + if( $n == 0 ) return; + + // Find out the max width and height of each column to be able + // to size the legend box. + $numcolumns = ($n > $this->layout_n ? $this->layout_n : $n); + for( $i=0; $i < $numcolumns; ++$i ) { + $colwidth[$i] = $aImg->GetTextWidth($this->txtcol[$i][0]) + + 2*$this->xmargin + 2*$this->mark_abs_hsize; + $colheight[$i] = 0; + + } + + // Find our maximum height in each row + $rows = 0 ; $rowheight[0] = 0; + for( $i=0; $i < $n; ++$i ) { + $h = max($this->mark_abs_vsize,$aImg->GetTextHeight($this->txtcol[$i][0]))+$this->ylinespacing; + + // Makes sure we always have a minimum of 1/4 (1/2 on each side) of the mark as space + // between two vertical legend entries + //$h = round(max($h,$this->mark_abs_vsize+$this->ymargin)); + //echo "Textheight #$i: tetxheight=".$aImg->GetTextHeight($this->txtcol[$i][0]).', '; + //echo "h=$h ({$this->mark_abs_vsize},{$this->ymargin})<br>"; + if( $i % $numcolumns == 0 ) { + $rows++; + $rowheight[$rows-1] = 0; + } + $rowheight[$rows-1] = max($rowheight[$rows-1],$h)+1; + } + + $abs_height = 0; + for( $i=0; $i < $rows; ++$i ) { + $abs_height += $rowheight[$i] ; + } + + // Make sure that the height is at least as high as mark size + ymargin + $abs_height = max($abs_height,$this->mark_abs_vsize); + $abs_height += $this->ybottom_margin; + + // Find out the maximum width in each column + for( $i=$numcolumns; $i < $n; ++$i ) { + $colwidth[$i % $numcolumns] = max( + $aImg->GetTextWidth($this->txtcol[$i][0])+2*$this->xmargin+2*$this->mark_abs_hsize, + $colwidth[$i % $numcolumns]); + } + + // Get the total width + $mtw = 0; + for( $i=0; $i < $numcolumns; ++$i ) { + $mtw += $colwidth[$i] ; + } + + // remove the last rows interpace margin (since there is no next row) + $abs_height -= $this->ylinespacing; + + + // Find out maximum width we need for legend box + $abs_width = $mtw+$this->xlmargin+($numcolumns-1)*$this->mark_abs_hsize; + + if( $this->xabspos === -1 && $this->yabspos === -1 ) { + $this->xabspos = $this->xpos*$aImg->width ; + $this->yabspos = $this->ypos*$aImg->height ; + } + + // Positioning of the legend box + if( $this->halign == 'left' ) { + $xp = $this->xabspos; + } + elseif( $this->halign == 'center' ) { + $xp = $this->xabspos - $abs_width/2; + } + else { + $xp = $aImg->width - $this->xabspos - $abs_width; + } + + $yp=$this->yabspos; + if( $this->valign == 'center' ) { + $yp-=$abs_height/2; + } + elseif( $this->valign == 'bottom' ) { + $yp-=$abs_height; + } + + // Stroke legend box + $aImg->SetColor($this->color); + $aImg->SetLineWeight($this->frameweight); + $aImg->SetLineStyle('solid'); + + if( $this->shadow ) { + $aImg->ShadowRectangle($xp,$yp, + $xp+$abs_width+$this->shadow_width+2, + $yp+$abs_height+$this->shadow_width+2, + $this->fill_color,$this->shadow_width+2,$this->shadow_color); + } + else { + $aImg->SetColor($this->fill_color); + $aImg->FilledRectangle($xp,$yp,$xp+$abs_width,$yp+$abs_height); + $aImg->SetColor($this->color); + $aImg->Rectangle($xp,$yp,$xp+$abs_width,$yp+$abs_height); + } + + if( $this->bkg_gradtype >= 0 ) { + $grad = new Gradient($aImg); + $grad->FilledRectangle($xp+1, $yp+1, + $xp+$abs_width-3, $yp+$abs_height-3, + $this->bkg_gradfrom, $this->bkg_gradto, + $this->bkg_gradtype); + } + + // x1,y1 is the position for the legend marker + text + // The vertical position is the baseline position for the text + // and every marker is adjusted acording to that. + + // For multiline texts this get more complicated. + + $x1 = $xp + $this->xlmargin; + $y1 = $yp + $rowheight[0] - $this->ylinespacing + 2 ; // The ymargin is included in rowheight + + // Now, y1 is the bottom vertical position of the first legend, i.e if + // the legend has multiple lines it is the bottom line. + + $grad = new Gradient($aImg); + $patternFactory = null; + + // Now stroke each legend in turn + // Each plot has added the following information to the legend + // p[0] = Legend text + // p[1] = Color, + // p[2] = For markers a reference to the PlotMark object + // p[3] = For lines the line style, for gradient the negative gradient style + // p[4] = CSIM target + // p[5] = CSIM Alt text + $i = 1 ; $row = 0; + foreach($this->txtcol as $p) { + + // STROKE DEBUG BOX + if( _JPG_DEBUG ) { + $aImg->SetLineWeight(1); + $aImg->SetColor('red'); + $aImg->SetLineStyle('solid'); + $aImg->Rectangle($x1,$y1,$xp+$abs_width-1,$y1-$rowheight[$row]); + } + + $aImg->SetLineWeight($this->weight); + $x1 = round($x1)+1; // We add one to not collide with the border + $y1=round($y1); + + // This is the center offset up from the baseline which is + // considered the "center" of the marks. This gets slightly complicated since + // we need to consider if the text is a multiline paragraph or if it is only + // a single line. The reason is that for single line the y1 corresponds to the baseline + // and that is fine. However for a multiline paragraph there is no single baseline + // and in that case the y1 corresponds to the lowest y for the bounding box. In that + // case we center the mark in the middle of the paragraph + if( !preg_match('/\n/',$p[0]) ) { + // Single line + $marky = ceil($y1-$this->mark_abs_vsize/2)-1; + } else { + // Paragraph + $marky = $y1 - $aImg->GetTextHeight($p[0])/2; + + // echo "y1=$y1, p[o]={$p[0]}, marky=$marky<br>"; + } + + //echo "<br>Mark #$i: marky=$marky<br>"; + + $x1 += $this->mark_abs_hsize; + + if ( !empty($p[2]) && $p[2]->GetType() > -1 ) { + + + // Make a plot mark legend. This is constructed with a mark which + // is run through with a line + + // First construct a bit of the line that looks exactly like the + // line in the plot + $aImg->SetColor($p[1]); + if( is_string($p[3]) || $p[3]>0 ) { + $aImg->SetLineStyle($p[3]); + $aImg->StyleLine($x1-$this->mark_abs_hsize,$marky,$x1+$this->mark_abs_hsize,$marky); + } + + // Stroke a mark using image + if( $p[2]->GetType() == MARK_IMG ) { + $p[2]->Stroke($aImg,$x1,$marky); + } + + // Stroke a mark with the standard size + // (As long as it is not an image mark ) + if( $p[2]->GetType() != MARK_IMG ) { + + // Clear any user callbacks since we ont want them called for + // the legend marks + $p[2]->iFormatCallback = ''; + $p[2]->iFormatCallback2 = ''; + + // Since size for circles is specified as the radius + // this means that we must half the size to make the total + // width behave as the other marks + if( $p[2]->GetType() == MARK_FILLEDCIRCLE || $p[2]->GetType() == MARK_CIRCLE ) { + $p[2]->SetSize(min($this->mark_abs_vsize,$this->mark_abs_hsize)/2); + $p[2]->Stroke($aImg,$x1,$marky); + } + else { + $p[2]->SetSize(min($this->mark_abs_vsize,$this->mark_abs_hsize)); + $p[2]->Stroke($aImg,$x1,$marky); + } + } + } + elseif ( !empty($p[2]) && (is_string($p[3]) || $p[3]>0 ) ) { + // Draw a styled line + $aImg->SetColor($p[1]); + $aImg->SetLineStyle($p[3]); + $aImg->StyleLine($x1-$this->mark_abs_hsize,$marky,$x1+$this->mark_abs_hsize,$marky); + $aImg->StyleLine($x1-$this->mark_abs_hsize,$marky+1,$x1+$this->mark_abs_hsize,$marky+1); + } + else { + // Draw a colored box + $color = $p[1] ; + + // We make boxes slightly larger to better show + $boxsize = max($this->mark_abs_vsize,$this->mark_abs_hsize) + 2 ; + + $ym = $marky-ceil($boxsize/2) ; // Marker y-coordinate + + // We either need to plot a gradient or a + // pattern. To differentiate we use a kludge. + // Patterns have a p[3] value of < -100 + if( $p[3] < -100 ) { + // p[1][0] == iPattern, p[1][1] == iPatternColor, p[1][2] == iPatternDensity + if( $patternFactory == null ) { + $patternFactory = new RectPatternFactory(); + } + $prect = $patternFactory->Create($p[1][0],$p[1][1],1); + $prect->SetBackground($p[1][3]); + $prect->SetDensity($p[1][2]+1); + $prect->SetPos(new Rectangle($x1,$ym,$boxsize,$boxsize)); + $prect->Stroke($aImg); + $prect=null; + } + else { + if( is_array($color) && count($color)==2 ) { + // The client want a gradient color + $grad->FilledRectangle($x1-$boxsize/2,$ym, + $x1+$boxsize/2,$ym+$boxsize, + $color[0],$color[1],-$p[3]); + } + else { + $aImg->SetColor($p[1]); + $aImg->FilledRectangle($x1-$boxsize/2,$ym, $x1+$boxsize/2,$ym+$boxsize); + } + + // Draw a plot frame line + $aImg->SetColor($this->color); + $aImg->SetLineWeight($fillBoxFrameWeight); + $aImg->Rectangle($x1-$boxsize/2,$ym, + $x1+$boxsize/2,$ym+$boxsize); + } + } + $aImg->SetColor($this->font_color); + $aImg->SetFont($this->font_family,$this->font_style,$this->font_size); + $aImg->SetTextAlign('left','baseline'); + + $debug=false; + $aImg->StrokeText($x1+$this->mark_abs_hsize+$this->xmargin,$y1,$p[0], + 0,'left',$debug); + + // Add CSIM for Legend if defined + if( !empty($p[4]) ) { + + $xs = $x1 - $this->mark_abs_hsize ; + $ys = $y1 + 1 ; + $xe = $x1 + $aImg->GetTextWidth($p[0]) + $this->mark_abs_hsize + $this->xmargin ; + $ye = $y1-$rowheight[$row]+1; + $coords = "$xs,$ys,$xe,$y1,$xe,$ye,$xs,$ye"; + if( ! empty($p[4]) ) { + $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($p[4])."\""; + + if( !empty($p[6]) ) { + $this->csimareas .= " target=\"".$p[6]."\""; + } + + if( !empty($p[5]) ) { + $tmp=sprintf($p[5],$p[0]); + $this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimareas .= " />\n"; + } + } + + if( $i >= $this->layout_n ) { + $x1 = $xp+$this->xlmargin; + $row++; + if( !empty($rowheight[$row]) ) + $y1 += $rowheight[$row]; + $i = 1; + } + else { + $x1 += $colwidth[($i-1) % $numcolumns] ; + ++$i; + } + } + } +} // Class + +?> diff --git a/html/jpgraph/jpgraph_line.php b/html/jpgraph/jpgraph_line.php new file mode 100644 index 0000000..21dd821 --- /dev/null +++ b/html/jpgraph/jpgraph_line.php @@ -0,0 +1,682 @@ +<?php +/*======================================================================= + // File: JPGRAPH_LINE.PHP + // Description: Line plot extension for JpGraph + // Created: 2001-01-08 + // Ver: $Id: jpgraph_line.php 1921 2009-12-11 11:46:39Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +require_once ('jpgraph_plotmark.inc.php'); + +// constants for the (filled) area +DEFINE("LP_AREA_FILLED", true); +DEFINE("LP_AREA_NOT_FILLED", false); +DEFINE("LP_AREA_BORDER",false); +DEFINE("LP_AREA_NO_BORDER",true); + +//=================================================== +// CLASS LinePlot +// Description: +//=================================================== +class LinePlot extends Plot{ + public $mark=null; + protected $filled=false; + protected $fill_color='blue'; + protected $step_style=false, $center=false; + protected $line_style=1; // Default to solid + protected $filledAreas = array(); // array of arrays(with min,max,col,filled in them) + public $barcenter=false; // When we mix line and bar. Should we center the line in the bar. + protected $fillFromMin = false, $fillFromMax = false; + protected $fillgrad=false,$fillgrad_fromcolor='navy',$fillgrad_tocolor='silver',$fillgrad_numcolors=100; + protected $iFastStroke=false; + + //--------------- + // CONSTRUCTOR + function LinePlot($datay,$datax=false) { + parent::__construct($datay,$datax); + $this->mark = new PlotMark() ; + $this->color = ColorFactory::getColor(); + $this->fill_color = $this->color; + } + //--------------- + // PUBLIC METHODS + + function SetFilled($aFlg=true) { + $this->filled = $aFlg; + } + + function SetBarCenter($aFlag=true) { + $this->barcenter=$aFlag; + } + + function SetStyle($aStyle) { + $this->line_style=$aStyle; + } + + function SetStepStyle($aFlag=true) { + $this->step_style = $aFlag; + } + + function SetColor($aColor) { + parent::SetColor($aColor); + } + + function SetFillFromYMin($f=true) { + $this->fillFromMin = $f ; + } + + function SetFillFromYMax($f=true) { + $this->fillFromMax = $f ; + } + + function SetFillColor($aColor,$aFilled=true) { + //$this->color = $aColor; + $this->fill_color=$aColor; + $this->filled=$aFilled; + } + + function SetFillGradient($aFromColor,$aToColor,$aNumColors=100,$aFilled=true) { + $this->fillgrad_fromcolor = $aFromColor; + $this->fillgrad_tocolor = $aToColor; + $this->fillgrad_numcolors = $aNumColors; + $this->filled = $aFilled; + $this->fillgrad = true; + } + + function Legend($graph) { + if( $this->legend!="" ) { + if( $this->filled && !$this->fillgrad ) { + $graph->legend->Add($this->legend, + $this->fill_color,$this->mark,0, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + elseif( $this->fillgrad ) { + $color=array($this->fillgrad_fromcolor,$this->fillgrad_tocolor); + // In order to differentiate between gradients and cooors specified as an RGB triple + $graph->legend->Add($this->legend,$color,"",-2 /* -GRAD_HOR */, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } else { + $graph->legend->Add($this->legend, + $this->color,$this->mark,$this->line_style, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + } + } + + function AddArea($aMin=0,$aMax=0,$aFilled=LP_AREA_NOT_FILLED,$aColor="gray9",$aBorder=LP_AREA_BORDER) { + if($aMin > $aMax) { + // swap + $tmp = $aMin; + $aMin = $aMax; + $aMax = $tmp; + } + $this->filledAreas[] = array($aMin,$aMax,$aColor,$aFilled,$aBorder); + } + + // Gets called before any axis are stroked + function PreStrokeAdjust($graph) { + + // If another plot type have already adjusted the + // offset we don't touch it. + // (We check for empty in case the scale is a log scale + // and hence doesn't contain any xlabel_offset) + if( empty($graph->xaxis->scale->ticks->xlabel_offset) || $graph->xaxis->scale->ticks->xlabel_offset == 0 ) { + if( $this->center ) { + ++$this->numpoints; + $a=0.5; $b=0.5; + } else { + $a=0; $b=0; + } + $graph->xaxis->scale->ticks->SetXLabelOffset($a); + $graph->SetTextScaleOff($b); + //$graph->xaxis->scale->ticks->SupressMinorTickMarks(); + } + } + + function SetFastStroke($aFlg=true) { + $this->iFastStroke = $aFlg; + } + + function FastStroke($img,$xscale,$yscale,$aStartPoint=0,$exist_x=true) { + // An optimized stroke for many data points with no extra + // features but 60% faster. You can't have values or line styles, or null + // values in plots. + $numpoints=count($this->coords[0]); + if( $this->barcenter ) { + $textadj = 0.5-$xscale->text_scale_off; + } + else { + $textadj = 0; + } + + $img->SetColor($this->color); + $img->SetLineWeight($this->weight); + $pnts=$aStartPoint; + while( $pnts < $numpoints ) { + if( $exist_x ) { + $x=$this->coords[1][$pnts]; + } + else { + $x=$pnts+$textadj; + } + $xt = $xscale->Translate($x); + $y=$this->coords[0][$pnts]; + $yt = $yscale->Translate($y); + if( is_numeric($y) ) { + $cord[] = $xt; + $cord[] = $yt; + } + elseif( $y == '-' && $pnts > 0 ) { + // Just ignore + } + else { + JpGraphError::RaiseL(10002);//('Plot too complicated for fast line Stroke. Use standard Stroke()'); + } + ++$pnts; + } // WHILE + + $img->Polygon($cord,false,true); + } + + function Stroke($img,$xscale,$yscale) { + $idx=0; + $numpoints=count($this->coords[0]); + if( isset($this->coords[1]) ) { + if( count($this->coords[1])!=$numpoints ) { + JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints); + //("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints"); + } + else { + $exist_x = true; + } + } + else { + $exist_x = false; + } + + if( $this->barcenter ) { + $textadj = 0.5-$xscale->text_scale_off; + } + else { + $textadj = 0; + } + + // Find the first numeric data point + $startpoint=0; + while( $startpoint < $numpoints && !is_numeric($this->coords[0][$startpoint]) ) { + ++$startpoint; + } + + // Bail out if no data points + if( $startpoint == $numpoints ) return; + + if( $this->iFastStroke ) { + $this->FastStroke($img,$xscale,$yscale,$startpoint,$exist_x); + return; + } + + if( $exist_x ) { + $xs=$this->coords[1][$startpoint]; + } + else { + $xs= $textadj+$startpoint; + } + + $img->SetStartPoint($xscale->Translate($xs), + $yscale->Translate($this->coords[0][$startpoint])); + + if( $this->filled ) { + if( $this->fillFromMax ) { + //$max = $yscale->GetMaxVal(); + $cord[$idx++] = $xscale->Translate($xs); + $cord[$idx++] = $yscale->scale_abs[1]; + } + else { + $min = $yscale->GetMinVal(); + if( $min > 0 || $this->fillFromMin ) { + $fillmin = $yscale->scale_abs[0];//Translate($min); + } + else { + $fillmin = $yscale->Translate(0); + } + + $cord[$idx++] = $xscale->Translate($xs); + $cord[$idx++] = $fillmin; + } + } + $xt = $xscale->Translate($xs); + $yt = $yscale->Translate($this->coords[0][$startpoint]); + $cord[$idx++] = $xt; + $cord[$idx++] = $yt; + $yt_old = $yt; + $xt_old = $xt; + $y_old = $this->coords[0][$startpoint]; + + $this->value->Stroke($img,$this->coords[0][$startpoint],$xt,$yt); + + $img->SetColor($this->color); + $img->SetLineWeight($this->weight); + $img->SetLineStyle($this->line_style); + $pnts=$startpoint+1; + $firstnonumeric = false; + + + while( $pnts < $numpoints ) { + + if( $exist_x ) { + $x=$this->coords[1][$pnts]; + } + else { + $x=$pnts+$textadj; + } + $xt = $xscale->Translate($x); + $yt = $yscale->Translate($this->coords[0][$pnts]); + + $y=$this->coords[0][$pnts]; + if( $this->step_style ) { + // To handle null values within step style we need to record the + // first non numeric value so we know from where to start if the + // non value is '-'. + if( is_numeric($y) ) { + $firstnonumeric = false; + if( is_numeric($y_old) ) { + $img->StyleLine($xt_old,$yt_old,$xt,$yt_old); + $img->StyleLine($xt,$yt_old,$xt,$yt); + } + elseif( $y_old == '-' ) { + $img->StyleLine($xt_first,$yt_first,$xt,$yt_first); + $img->StyleLine($xt,$yt_first,$xt,$yt); + } + else { + $yt_old = $yt; + $xt_old = $xt; + } + $cord[$idx++] = $xt; + $cord[$idx++] = $yt_old; + $cord[$idx++] = $xt; + $cord[$idx++] = $yt; + } + elseif( $firstnonumeric==false ) { + $firstnonumeric = true; + $yt_first = $yt_old; + $xt_first = $xt_old; + } + } + else { + $tmp1=$y; + $prev=$this->coords[0][$pnts-1]; + if( $tmp1==='' || $tmp1===NULL || $tmp1==='X' ) $tmp1 = 'x'; + if( $prev==='' || $prev===null || $prev==='X' ) $prev = 'x'; + + if( is_numeric($y) || (is_string($y) && $y != '-') ) { + if( is_numeric($y) && (is_numeric($prev) || $prev === '-' ) ) { + $img->StyleLineTo($xt,$yt); + } + else { + $img->SetStartPoint($xt,$yt); + } + } + if( $this->filled && $tmp1 !== '-' ) { + if( $tmp1 === 'x' ) { + $cord[$idx++] = $cord[$idx-3]; + $cord[$idx++] = $fillmin; + } + elseif( $prev === 'x' ) { + $cord[$idx++] = $xt; + $cord[$idx++] = $fillmin; + $cord[$idx++] = $xt; + $cord[$idx++] = $yt; + } + else { + $cord[$idx++] = $xt; + $cord[$idx++] = $yt; + } + } + else { + if( is_numeric($tmp1) && (is_numeric($prev) || $prev === '-' ) ) { + $cord[$idx++] = $xt; + $cord[$idx++] = $yt; + } + } + } + $yt_old = $yt; + $xt_old = $xt; + $y_old = $y; + + $this->StrokeDataValue($img,$this->coords[0][$pnts],$xt,$yt); + + ++$pnts; + } + + if( $this->filled ) { + $cord[$idx++] = $xt; + if( $this->fillFromMax ) { + $cord[$idx++] = $yscale->scale_abs[1]; + } + else { + if( $min > 0 || $this->fillFromMin ) { + $cord[$idx++] = $yscale->Translate($min); + } + else { + $cord[$idx++] = $yscale->Translate(0); + } + } + if( $this->fillgrad ) { + $img->SetLineWeight(1); + $grad = new Gradient($img); + $grad->SetNumColors($this->fillgrad_numcolors); + $grad->FilledFlatPolygon($cord,$this->fillgrad_fromcolor,$this->fillgrad_tocolor); + $img->SetLineWeight($this->weight); + } + else { + $img->SetColor($this->fill_color); + $img->FilledPolygon($cord); + } + if( $this->weight > 0 ) { + $img->SetLineWeight($this->weight); + $img->SetColor($this->color); + // Remove first and last coordinate before drawing the line + // sine we otherwise get the vertical start and end lines which + // doesn't look appropriate + $img->Polygon(array_slice($cord,2,count($cord)-4)); + } + } + + if(!empty($this->filledAreas)) { + + $minY = $yscale->Translate($yscale->GetMinVal()); + $factor = ($this->step_style ? 4 : 2); + + for($i = 0; $i < sizeof($this->filledAreas); ++$i) { + // go through all filled area elements ordered by insertion + // fill polygon array + $areaCoords[] = $cord[$this->filledAreas[$i][0] * $factor]; + $areaCoords[] = $minY; + + $areaCoords = + array_merge($areaCoords, + array_slice($cord, + $this->filledAreas[$i][0] * $factor, + ($this->filledAreas[$i][1] - $this->filledAreas[$i][0] + ($this->step_style ? 0 : 1)) * $factor)); + $areaCoords[] = $areaCoords[sizeof($areaCoords)-2]; // last x + $areaCoords[] = $minY; // last y + + if($this->filledAreas[$i][3]) { + $img->SetColor($this->filledAreas[$i][2]); + $img->FilledPolygon($areaCoords); + $img->SetColor($this->color); + } + // Check if we should draw the frame. + // If not we still re-draw the line since it might have been + // partially overwritten by the filled area and it doesn't look + // very good. + if( $this->filledAreas[$i][4] ) { + $img->Polygon($areaCoords); + } + else { + $img->Polygon($cord); + } + + $areaCoords = array(); + } + } + + if( $this->mark->type == -1 || $this->mark->show == false ) + return; + + for( $pnts=0; $pnts<$numpoints; ++$pnts) { + + if( $exist_x ) { + $x=$this->coords[1][$pnts]; + } + else { + $x=$pnts+$textadj; + } + $xt = $xscale->Translate($x); + $yt = $yscale->Translate($this->coords[0][$pnts]); + + if( is_numeric($this->coords[0][$pnts]) ) { + if( !empty($this->csimtargets[$pnts]) ) { + if( !empty($this->csimwintargets[$pnts]) ) { + $this->mark->SetCSIMTarget($this->csimtargets[$pnts],$this->csimwintargets[$pnts]); + } + else { + $this->mark->SetCSIMTarget($this->csimtargets[$pnts]); + } + $this->mark->SetCSIMAlt($this->csimalts[$pnts]); + } + if( $exist_x ) { + $x=$this->coords[1][$pnts]; + } + else { + $x=$pnts; + } + $this->mark->SetCSIMAltVal($this->coords[0][$pnts],$x); + $this->mark->Stroke($img,$xt,$yt); + $this->csimareas .= $this->mark->GetCSIMAreas(); + } + } + } +} // Class + + +//=================================================== +// CLASS AccLinePlot +// Description: +//=================================================== +class AccLinePlot extends Plot { + protected $plots=null,$nbrplots=0; + private $iStartEndZero=true; + //--------------- + // CONSTRUCTOR + function __construct($plots) { + $this->plots = $plots; + $this->nbrplots = count($plots); + $this->numpoints = $plots[0]->numpoints; + + // Verify that all plots have the same number of data points + for( $i=1; $i < $this->nbrplots; ++$i ) { + if( $plots[$i]->numpoints != $this->numpoints ) { + JpGraphError::RaiseL(10003);//('Each plot in an accumulated lineplot must have the same number of data points',0) + } + } + + for($i=0; $i < $this->nbrplots; ++$i ) { + $this->LineInterpolate($this->plots[$i]->coords[0]); + } + } + + //--------------- + // PUBLIC METHODS + function Legend($graph) { + foreach( $this->plots as $p ) { + $p->DoLegend($graph); + } + } + + function Max() { + list($xmax) = $this->plots[0]->Max(); + $nmax=0; + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + $nc = count($this->plots[$i]->coords[0]); + $nmax = max($nmax,$nc); + list($x) = $this->plots[$i]->Max(); + $xmax = Max($xmax,$x); + } + for( $i = 0; $i < $nmax; $i++ ) { + // Get y-value for line $i by adding the + // individual bars from all the plots added. + // It would be wrong to just add the + // individual plots max y-value since that + // would in most cases give to large y-value. + $y=$this->plots[0]->coords[0][$i]; + for( $j = 1; $j < $this->nbrplots; $j++ ) { + $y += $this->plots[ $j ]->coords[0][$i]; + } + $ymax[$i] = $y; + } + $ymax = max($ymax); + return array($xmax,$ymax); + } + + function Min() { + $nmax=0; + list($xmin,$ysetmin) = $this->plots[0]->Min(); + $n = count($this->plots); + for($i=0; $i < $n; ++$i) { + $nc = count($this->plots[$i]->coords[0]); + $nmax = max($nmax,$nc); + list($x,$y) = $this->plots[$i]->Min(); + $xmin = Min($xmin,$x); + $ysetmin = Min($y,$ysetmin); + } + for( $i = 0; $i < $nmax; $i++ ) { + // Get y-value for line $i by adding the + // individual bars from all the plots added. + // It would be wrong to just add the + // individual plots min y-value since that + // would in most cases give to small y-value. + $y=$this->plots[0]->coords[0][$i]; + for( $j = 1; $j < $this->nbrplots; $j++ ) { + $y += $this->plots[ $j ]->coords[0][$i]; + } + $ymin[$i] = $y; + } + $ymin = Min($ysetmin,Min($ymin)); + return array($xmin,$ymin); + } + + // Gets called before any axis are stroked + function PreStrokeAdjust($graph) { + + // If another plot type have already adjusted the + // offset we don't touch it. + // (We check for empty in case the scale is a log scale + // and hence doesn't contain any xlabel_offset) + + if( empty($graph->xaxis->scale->ticks->xlabel_offset) || + $graph->xaxis->scale->ticks->xlabel_offset == 0 ) { + if( $this->center ) { + ++$this->numpoints; + $a=0.5; $b=0.5; + } else { + $a=0; $b=0; + } + $graph->xaxis->scale->ticks->SetXLabelOffset($a); + $graph->SetTextScaleOff($b); + $graph->xaxis->scale->ticks->SupressMinorTickMarks(); + } + + } + + function SetInterpolateMode($aIntMode) { + $this->iStartEndZero=$aIntMode; + } + + // Replace all '-' with an interpolated value. We use straightforward + // linear interpolation. If the data starts with one or several '-' they + // will be replaced by the the first valid data point + function LineInterpolate(&$aData) { + + $n=count($aData); + $i=0; + + // If first point is undefined we will set it to the same as the first + // valid data + if( $aData[$i]==='-' ) { + // Find the first valid data + while( $i < $n && $aData[$i]==='-' ) { + ++$i; + } + if( $i < $n ) { + for($j=0; $j < $i; ++$j ) { + if( $this->iStartEndZero ) + $aData[$i] = 0; + else + $aData[$j] = $aData[$i]; + } + } + else { + // All '-' => Error + return false; + } + } + + while($i < $n) { + while( $i < $n && $aData[$i] !== '-' ) { + ++$i; + } + if( $i < $n ) { + $pstart=$i-1; + + // Now see how long this segment of '-' are + while( $i < $n && $aData[$i] === '-' ) { + ++$i; + } + if( $i < $n ) { + $pend=$i; + $size=$pend-$pstart; + $k=($aData[$pend]-$aData[$pstart])/$size; + // Replace the segment of '-' with a linear interpolated value. + for($j=1; $j < $size; ++$j ) { + $aData[$pstart+$j] = $aData[$pstart] + $j*$k ; + } + } + else { + // There are no valid end point. The '-' goes all the way to the end + // In that case we just set all the remaining values the the same as the + // last valid data point. + for( $j=$pstart+1; $j < $n; ++$j ) + if( $this->iStartEndZero ) { + $aData[$j] = 0; + } + else { + $aData[$j] = $aData[$pstart] ; + } + } + } + } + return true; + } + + // To avoid duplicate of line drawing code here we just + // change the y-values for each plot and then restore it + // after we have made the stroke. We must do this copy since + // it wouldn't be possible to create an acc line plot + // with the same graphs, i.e AccLinePlot(array($pl,$pl,$pl)); + // since this method would have a side effect. + function Stroke($img,$xscale,$yscale) { + $img->SetLineWeight($this->weight); + $this->numpoints = count($this->plots[0]->coords[0]); + // Allocate array + $coords[$this->nbrplots][$this->numpoints]=0; + for($i=0; $i<$this->numpoints; $i++) { + $coords[0][$i]=$this->plots[0]->coords[0][$i]; + $accy=$coords[0][$i]; + for($j=1; $j<$this->nbrplots; ++$j ) { + $coords[$j][$i] = $this->plots[$j]->coords[0][$i]+$accy; + $accy = $coords[$j][$i]; + } + } + for($j=$this->nbrplots-1; $j>=0; --$j) { + $p=$this->plots[$j]; + for( $i=0; $i<$this->numpoints; ++$i) { + $tmp[$i]=$p->coords[0][$i]; + $p->coords[0][$i]=$coords[$j][$i]; + } + $p->Stroke($img,$xscale,$yscale); + for( $i=0; $i<$this->numpoints; ++$i) { + $p->coords[0][$i]=$tmp[$i]; + } + $p->coords[0][]=$tmp; + } + } +} // Class + + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_log.php b/html/jpgraph/jpgraph_log.php new file mode 100644 index 0000000..d5146ec --- /dev/null +++ b/html/jpgraph/jpgraph_log.php @@ -0,0 +1,305 @@ +<?php +/*======================================================================= + // File: JPGRAPH_LOG.PHP + // Description: Log scale plot extension for JpGraph + // Created: 2001-01-08 + // Ver: $Id: jpgraph_log.php 1106 2009-02-22 20:16:35Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +DEFINE('LOGLABELS_PLAIN',0); +DEFINE('LOGLABELS_MAGNITUDE',1); + +//=================================================== +// CLASS LogScale +// Description: Logarithmic scale between world and screen +//=================================================== +class LogScale extends LinearScale { + //--------------- + // CONSTRUCTOR + + // Log scale is specified using the log of min and max + function __construct($min,$max,$type="y") { + parent::__construct($min,$max,$type); + $this->ticks = new LogTicks(); + $this->name = 'log'; + } + + //---------------- + // PUBLIC METHODS + + // Translate between world and screen + function Translate($a) { + if( !is_numeric($a) ) { + if( $a != '' && $a != '-' && $a != 'x' ) { + JpGraphError::RaiseL(11001); + // ('Your data contains non-numeric values.'); + } + return 1; + } + if( $a < 0 ) { + JpGraphError::RaiseL(11002); + //("Negative data values can not be used in a log scale."); + exit(1); + } + if( $a==0 ) $a=1; + $a=log10($a); + return ceil($this->off + ($a*1.0 - $this->scale[0]) * $this->scale_factor); + } + + // Relative translate (don't include offset) usefull when we just want + // to know the relative position (in pixels) on the axis + function RelTranslate($a) { + if( !is_numeric($a) ) { + if( $a != '' && $a != '-' && $a != 'x' ) { + JpGraphError::RaiseL(11001); + //('Your data contains non-numeric values.'); + } + return 1; + } + if( $a==0 ) { + $a=1; + } + $a=log10($a); + return round(($a*1.0 - $this->scale[0]) * $this->scale_factor); + } + + // Use bcpow() for increased precision + function GetMinVal() { + if( function_exists("bcpow") ) { + return round(bcpow(10,$this->scale[0],15),14); + } + else { + return round(pow(10,$this->scale[0]),14); + } + } + + function GetMaxVal() { + if( function_exists("bcpow") ) { + return round(bcpow(10,$this->scale[1],15),14); + } + else { + return round(pow(10,$this->scale[1]),14); + } + } + + // Logarithmic autoscaling is much simplier since we just + // set the min and max to logs of the min and max values. + // Note that for log autoscale the "maxstep" the fourth argument + // isn't used. This is just included to give the method the same + // signature as the linear counterpart. + function AutoScale($img,$min,$max,$maxsteps,$majend=true) { + if( $min==0 ) $min=1; + + if( $max <= 0 ) { + JpGraphError::RaiseL(11004); + //('Scale error for logarithmic scale. You have a problem with your data values. The max value must be greater than 0. It is mathematically impossible to have 0 in a logarithmic scale.'); + } + if( is_numeric($this->autoscale_min) ) { + $smin = round($this->autoscale_min); + $smax = ceil(log10($max)); + if( $min >= $max ) { + JpGraphError::RaiseL(25071);//('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.'); + } + } + else { + $smin = floor(log10($min)); + if( is_numeric($this->autoscale_max) ) { + $smax = round($this->autoscale_max); + if( $smin >= $smax ) { + JpGraphError::RaiseL(25072);//('You have specified a max value with SetAutoMax() which is smaller than the miminum value used for the scale. This is not possible.'); + } + } + else + $smax = ceil(log10($max)); + } + + $this->Update($img,$smin,$smax); + } + //--------------- + // PRIVATE METHODS +} // Class + +//=================================================== +// CLASS LogTicks +// Description: +//=================================================== +class LogTicks extends Ticks{ + private $label_logtype=LOGLABELS_MAGNITUDE; + private $ticklabels_pos = array(); + //--------------- + // CONSTRUCTOR + function LogTicks() { + } + //--------------- + // PUBLIC METHODS + function IsSpecified() { + return true; + } + + function SetLabelLogType($aType) { + $this->label_logtype = $aType; + } + + // For log scale it's meaningless to speak about a major step + // We just return -1 to make the framework happy (specifically + // StrokeLabels() ) + function GetMajor() { + return -1; + } + + function SetTextLabelStart($aStart) { + JpGraphError::RaiseL(11005); + //('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.'); + } + + function SetXLabelOffset($dummy) { + // For log scales we dont care about XLabel offset + } + + // Draw ticks on image "img" using scale "scale". The axis absolute + // position in the image is specified in pos, i.e. for an x-axis + // it specifies the absolute y-coord and for Y-ticks it specified the + // absolute x-position. + function Stroke($img,$scale,$pos) { + $start = $scale->GetMinVal(); + $limit = $scale->GetMaxVal(); + $nextMajor = 10*$start; + $step = $nextMajor / 10.0; + + + $img->SetLineWeight($this->weight); + + if( $scale->type == "y" ) { + // member direction specified if the ticks should be on + // left or right side. + $a=$pos + $this->direction*$this->GetMinTickAbsSize(); + $a2=$pos + $this->direction*$this->GetMajTickAbsSize(); + + $count=1; + $this->maj_ticks_pos[0]=$scale->Translate($start); + $this->maj_ticklabels_pos[0]=$scale->Translate($start); + if( $this->supress_first ) + $this->maj_ticks_label[0]=""; + else { + if( $this->label_formfunc != '' ) { + $f = $this->label_formfunc; + $this->maj_ticks_label[0]=call_user_func($f,$start); + } + elseif( $this->label_logtype == LOGLABELS_PLAIN ) { + $this->maj_ticks_label[0]=$start; + } + else { + $this->maj_ticks_label[0]='10^'.round(log10($start)); + } + } + $i=1; + for($y=$start; $y<=$limit; $y+=$step,++$count ) { + $ys=$scale->Translate($y); + $this->ticks_pos[]=$ys; + $this->ticklabels_pos[]=$ys; + if( $count % 10 == 0 ) { + if( !$this->supress_tickmarks ) { + if( $this->majcolor!="" ) { + $img->PushColor($this->majcolor); + $img->Line($pos,$ys,$a2,$ys); + $img->PopColor(); + } + else { + $img->Line($pos,$ys,$a2,$ys); + } + } + + $this->maj_ticks_pos[$i]=$ys; + $this->maj_ticklabels_pos[$i]=$ys; + + if( $this->label_formfunc != '' ) { + $f = $this->label_formfunc; + $this->maj_ticks_label[$i]=call_user_func($f,$nextMajor); + } + elseif( $this->label_logtype == 0 ) { + $this->maj_ticks_label[$i]=$nextMajor; + } + else { + $this->maj_ticks_label[$i]='10^'.round(log10($nextMajor)); + } + ++$i; + $nextMajor *= 10; + $step *= 10; + $count=1; + } + else { + if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) { + if( $this->mincolor!="" ) { + $img->PushColor($this->mincolor); + } + $img->Line($pos,$ys,$a,$ys); + if( $this->mincolor!="" ) { + $img->PopColor(); + } + } + } + } + } + else { + $a=$pos - $this->direction*$this->GetMinTickAbsSize(); + $a2=$pos - $this->direction*$this->GetMajTickAbsSize(); + $count=1; + $this->maj_ticks_pos[0]=$scale->Translate($start); + $this->maj_ticklabels_pos[0]=$scale->Translate($start); + if( $this->supress_first ) { + $this->maj_ticks_label[0]=""; + } + else { + if( $this->label_formfunc != '' ) { + $f = $this->label_formfunc; + $this->maj_ticks_label[0]=call_user_func($f,$start); + } + elseif( $this->label_logtype == 0 ) { + $this->maj_ticks_label[0]=$start; + } + else { + $this->maj_ticks_label[0]='10^'.round(log10($start)); + } + } + $i=1; + for($x=$start; $x<=$limit; $x+=$step,++$count ) { + $xs=$scale->Translate($x); + $this->ticks_pos[]=$xs; + $this->ticklabels_pos[]=$xs; + if( $count % 10 == 0 ) { + if( !$this->supress_tickmarks ) { + $img->Line($xs,$pos,$xs,$a2); + } + $this->maj_ticks_pos[$i]=$xs; + $this->maj_ticklabels_pos[$i]=$xs; + + if( $this->label_formfunc != '' ) { + $f = $this->label_formfunc; + $this->maj_ticks_label[$i]=call_user_func($f,$nextMajor); + } + elseif( $this->label_logtype == 0 ) { + $this->maj_ticks_label[$i]=$nextMajor; + } + else { + $this->maj_ticks_label[$i]='10^'.round(log10($nextMajor)); + } + ++$i; + $nextMajor *= 10; + $step *= 10; + $count=1; + } + else { + if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) { + $img->Line($xs,$pos,$xs,$a); + } + } + } + } + return true; + } +} // Class +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_meshinterpolate.inc.php b/html/jpgraph/jpgraph_meshinterpolate.inc.php new file mode 100644 index 0000000..7e8ae53 --- /dev/null +++ b/html/jpgraph/jpgraph_meshinterpolate.inc.php @@ -0,0 +1,105 @@ +<?php +/*======================================================================= +// File: JPGRAPH_MESHINTERPOLATE.INC.PHP +// Description: Utility class to do mesh linear interpolation of a matrix +// Created: 2009-03-09 +// Ver: $Id: jpgraph_meshinterpolate.inc.php 1709 2009-07-30 08:00:08Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== +*/ + +/** +* Utility function to do linear mesh interpolation +* @param $aDat Matrix to interpolate +* @param $aFactor Interpolation factor +*/ +function doMeshInterpolate( &$aData, $aFactor ) { + $m = new MeshInterpolate(); + $aData = $m->Linear($aData,$aFactor); +} + +/** + * Utility class to interpolate a given data matrix + * + */ +class MeshInterpolate { + private $data = array(); + + /** + * Calculate the mid points of the given rectangle which has its top left + * corner at $row,$col. The $aFactordecides how many spliots should be done. + * i.e. how many more divisions should be done recursively + * + * @param $row Top left corner of square to work with + * @param $col Top left corner of square to work with + * $param $aFactor In how many subsquare should we split this square. A value of 1 indicates that no action + */ + function IntSquare( $aRow, $aCol, $aFactor ) { + if ( $aFactor <= 1 ) + return; + + $step = pow( 2, $aFactor-1 ); + + $v0 = $this->data[$aRow][$aCol]; + $v1 = $this->data[$aRow][$aCol + $step]; + $v2 = $this->data[$aRow + $step][$aCol]; + $v3 = $this->data[$aRow + $step][$aCol + $step]; + + $this->data[$aRow][$aCol + $step / 2] = ( $v0 + $v1 ) / 2; + $this->data[$aRow + $step / 2][$aCol] = ( $v0 + $v2 ) / 2; + $this->data[$aRow + $step][$aCol + $step / 2] = ( $v2 + $v3 ) / 2; + $this->data[$aRow + $step / 2][$aCol + $step] = ( $v1 + $v3 ) / 2; + $this->data[$aRow + $step / 2][$aCol + $step / 2] = ( $v0 + $v1 + $v2 + $v3 ) / 4; + + $this->IntSquare( $aRow, $aCol, $aFactor-1 ); + $this->IntSquare( $aRow, $aCol + $step / 2, $aFactor-1 ); + $this->IntSquare( $aRow + $step / 2, $aCol, $aFactor-1 ); + $this->IntSquare( $aRow + $step / 2, $aCol + $step / 2, $aFactor-1 ); + } + + /** + * Interpolate values in a matrice so that the total number of data points + * in vert and horizontal axis are $aIntNbr more. For example $aIntNbr=2 will + * make the data matrice have tiwce as many vertical and horizontal dta points. + * + * Note: This will blow up the matrcide in memory size in the order of $aInNbr^2 + * + * @param $ &$aData The original data matricde + * @param $aInNbr Interpolation factor + * @return the interpolated matrice + */ + function Linear( &$aData, $aIntFactor ) { + $step = pow( 2, $aIntFactor-1 ); + + $orig_cols = count( $aData[0] ); + $orig_rows = count( $aData ); + // Number of new columns/rows + // N = (a-1) * 2^(f-1) + 1 + $p = pow( 2, $aIntFactor-1 ); + $new_cols = $p * ( $orig_cols - 1 ) + 1; + $new_rows = $p * ( $orig_rows - 1 ) + 1; + + $this->data = array_fill( 0, $new_rows, array_fill( 0, $new_cols, 0 ) ); + // Initialize the new matrix with the values that we know + for ( $i = 0; $i < $new_rows; $i++ ) { + for ( $j = 0; $j < $new_cols; $j++ ) { + $v = 0 ; + if ( ( $i % $step == 0 ) && ( $j % $step == 0 ) ) { + $v = $aData[$i / $step][$j / $step]; + } + $this->data[$i][$j] = $v; + } + } + + for ( $i = 0; $i < $new_rows-1; $i += $step ) { + for ( $j = 0; $j < $new_cols-1; $j += $step ) { + $this->IntSquare( $i, $j, $aIntFactor ); + } + } + + return $this->data; + } +} + +?> diff --git a/html/jpgraph/jpgraph_mgraph.php b/html/jpgraph/jpgraph_mgraph.php new file mode 100644 index 0000000..80b2b6d --- /dev/null +++ b/html/jpgraph/jpgraph_mgraph.php @@ -0,0 +1,345 @@ +<?php +/*======================================================================= + // File: JPGRAPH_MGRAPH.PHP + // Description: Class to handle multiple graphs in the same image + // Created: 2006-01-15 + // Ver: $Id: jpgraph_mgraph.php 1770 2009-08-17 06:10:22Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +//============================================================================= +// CLASS MGraph +// Description: Create a container image that can hold several graph +//============================================================================= +class MGraph { + + public $title = null, $subtitle = null, $subsubtitle = null; + + protected $img=NULL; + protected $iCnt=0,$iGraphs = array(); // image_handle, x, y, fx, fy, sizex, sizey + protected $iFillColor='white', $iCurrentColor=0; + protected $lm=4,$rm=4,$tm=4,$bm=4; + protected $iDoFrame = FALSE, $iFrameColor = 'black', $iFrameWeight = 1; + protected $iLineWeight = 1; + protected $expired=false; + protected $cache=null,$cache_name = '',$inline=true; + protected $image_format='png',$image_quality=75; + protected $iWidth=NULL,$iHeight=NULL; + protected $background_image='',$background_image_center=true, + $backround_image_format='',$background_image_mix=100, + $background_image_y=NULL, $background_image_x=NULL; + private $doshadow=false, $shadow_width=4, $shadow_color='gray@0.5'; + public $footer; + + + // Create a new instane of the combined graph + function __construct($aWidth=NULL,$aHeight=NULL,$aCachedName='',$aTimeOut=0,$aInline=true) { + $this->iWidth = $aWidth; + $this->iHeight = $aHeight; + + // If the cached version exist just read it directly from the + // cache, stream it back to browser and exit + if( $aCachedName!='' && READ_CACHE && $aInline ) { + $this->cache = new ImgStreamCache(); + $this->cache->SetTimeOut($aTimeOut); + $image = new Image(); + if( $this->cache->GetAndStream($image,$aCachedName) ) { + exit(); + } + } + $this->inline = $aInline; + $this->cache_name = $aCachedName; + + $this->title = new Text(); + $this->title->ParagraphAlign('center'); + $this->title->SetFont(FF_FONT2,FS_BOLD); + $this->title->SetMargin(3); + $this->title->SetAlign('center'); + + $this->subtitle = new Text(); + $this->subtitle->ParagraphAlign('center'); + $this->subtitle->SetFont(FF_FONT1,FS_BOLD); + $this->subtitle->SetMargin(3); + $this->subtitle->SetAlign('center'); + + $this->subsubtitle = new Text(); + $this->subsubtitle->ParagraphAlign('center'); + $this->subsubtitle->SetFont(FF_FONT1,FS_NORMAL); + $this->subsubtitle->SetMargin(3); + $this->subsubtitle->SetAlign('center'); + + $this->footer = new Footer(); + + } + + // Specify background fill color for the combined graph + function SetFillColor($aColor) { + $this->iFillColor = $aColor; + } + + // Add a frame around the combined graph + function SetFrame($aFlg,$aColor='black',$aWeight=1) { + $this->iDoFrame = $aFlg; + $this->iFrameColor = $aColor; + $this->iFrameWeight = $aWeight; + } + + // Specify a background image blend + function SetBackgroundImageMix($aMix) { + $this->background_image_mix = $aMix ; + } + + // Specify a background image + function SetBackgroundImage($aFileName,$aCenter_aX=NULL,$aY=NULL) { + // Second argument can be either a boolean value or + // a numeric + $aCenter=TRUE; + $aX=NULL; + + if( is_numeric($aCenter_aX) ) { + $aX=$aCenter_aX; + } + + // Get extension to determine image type + $e = explode('.',$aFileName); + if( !$e ) { + JpGraphError::RaiseL(12002,$aFileName); + //('Incorrect file name for MGraph::SetBackgroundImage() : '.$aFileName.' Must have a valid image extension (jpg,gif,png) when using autodetection of image type'); + } + + $valid_formats = array('png', 'jpg', 'gif'); + $aImgFormat = strtolower($e[count($e)-1]); + if ($aImgFormat == 'jpeg') { + $aImgFormat = 'jpg'; + } + elseif (!in_array($aImgFormat, $valid_formats) ) { + JpGraphError::RaiseL(12003,$aImgFormat,$aFileName); + //('Unknown file extension ($aImgFormat) in MGraph::SetBackgroundImage() for filename: '.$aFileName); + } + + $this->background_image = $aFileName; + $this->background_image_center=$aCenter; + $this->background_image_format=$aImgFormat; + $this->background_image_x = $aX; + $this->background_image_y = $aY; + } + + function _strokeBackgroundImage() { + if( $this->background_image == '' ) return; + + $bkgimg = Graph::LoadBkgImage('',$this->background_image); + + // Background width & Heoght + $bw = imagesx($bkgimg); + $bh = imagesy($bkgimg); + + // Canvas width and height + $cw = imagesx($this->img); + $ch = imagesy($this->img); + + if( $this->doshadow ) { + $cw -= $this->shadow_width; + $ch -= $this->shadow_width; + } + + if( $this->background_image_x === NULL || $this->background_image_y === NULL ) { + if( $this->background_image_center ) { + // Center original image in the plot area + $x = round($cw/2-$bw/2); $y = round($ch/2-$bh/2); + } + else { + // Just copy the image from left corner, no resizing + $x=0; $y=0; + } + } + else { + $x = $this->background_image_x; + $y = $this->background_image_y; + } + imagecopymerge($this->img,$bkgimg,$x,$y,0,0,$bw,$bh,$this->background_image_mix); + } + + function AddMix($aGraph,$x=0,$y=0,$mix=100,$fx=0,$fy=0,$w=0,$h=0) { + $this->_gdImgHandle($aGraph->Stroke( _IMG_HANDLER),$x,$y,$fx=0,$fy=0,$w,$h,$mix); + } + + function Add($aGraph,$x=0,$y=0,$fx=0,$fy=0,$w=0,$h=0) { + $this->_gdImgHandle($aGraph->Stroke( _IMG_HANDLER),$x,$y,$fx=0,$fy=0,$w,$h); + } + + function _gdImgHandle($agdCanvas,$x,$y,$fx=0,$fy=0,$w=0,$h=0,$mix=100) { + if( $w == 0 ) { + $w = @imagesx($agdCanvas); + } + if( $w === NULL ) { + JpGraphError::RaiseL(12007); + //('Argument to MGraph::Add() is not a valid GD image handle.'); + return; + } + if( $h == 0 ) { + $h = @imagesy($agdCanvas); + } + $this->iGraphs[$this->iCnt++] = array($agdCanvas,$x,$y,$fx,$fy,$w,$h,$mix); + } + + function SetMargin($lm,$rm,$tm,$bm) { + $this->lm = $lm; + $this->rm = $rm; + $this->tm = $tm; + $this->bm = $bm; + } + + function SetExpired($aFlg=true) { + $this->expired = $aFlg; + } + + function SetImgFormat($aFormat,$aQuality=75) { + $this->image_format = $aFormat; + $this->image_quality = $aQuality; + } + + // Set the shadow around the whole image + function SetShadow($aShowShadow=true,$aShadowWidth=4,$aShadowColor='gray@0.3') { + $this->doshadow = $aShowShadow; + $this->shadow_color = $aShadowColor; + $this->shadow_width = $aShadowWidth; + $this->footer->iBottomMargin += $aShadowWidth; + $this->footer->iRightMargin += $aShadowWidth; + } + + function StrokeTitle($image,$w,$h) { + // Stroke title + if( $this->title->t !== '' ) { + + $margin = 3; + + $y = $this->title->margin; + if( $this->title->halign == 'center' ) { + $this->title->Center(0,$w,$y); + } + elseif( $this->title->halign == 'left' ) { + $this->title->SetPos($this->title->margin+2,$y); + } + elseif( $this->title->halign == 'right' ) { + $indent = 0; + if( $this->doshadow ) { + $indent = $this->shadow_width+2; + } + $this->title->SetPos($w-$this->title->margin-$indent,$y,'right'); + } + $this->title->Stroke($image); + + // ... and subtitle + $y += $this->title->GetTextHeight($image) + $margin + $this->subtitle->margin; + if( $this->subtitle->halign == 'center' ) { + $this->subtitle->Center(0,$w,$y); + } + elseif( $this->subtitle->halign == 'left' ) { + $this->subtitle->SetPos($this->subtitle->margin+2,$y); + } + elseif( $this->subtitle->halign == 'right' ) { + $indent = 0; + if( $this->doshadow ) { + $indent = $this->shadow_width+2; + } + $this->subtitle->SetPos($this->img->width-$this->subtitle->margin-$indent,$y,'right'); + } + $this->subtitle->Stroke($image); + + // ... and subsubtitle + $y += $this->subtitle->GetTextHeight($image) + $margin + $this->subsubtitle->margin; + if( $this->subsubtitle->halign == 'center' ) { + $this->subsubtitle->Center(0,$w,$y); + } + elseif( $this->subsubtitle->halign == 'left' ) { + $this->subsubtitle->SetPos($this->subsubtitle->margin+2,$y); + } + elseif( $this->subsubtitle->halign == 'right' ) { + $indent = 0; + if( $this->doshadow ) { + $indent = $this->shadow_width+2; + } + $this->subsubtitle->SetPos($w-$this->subsubtitle->margin-$indent,$y,'right'); + } + $this->subsubtitle->Stroke($image); + + } + } + + function Stroke($aFileName='') { + // Find out the necessary size for the container image + $w=0; $h=0; + for($i=0; $i < $this->iCnt; ++$i ) { + $maxw = $this->iGraphs[$i][1]+$this->iGraphs[$i][5]; + $maxh = $this->iGraphs[$i][2]+$this->iGraphs[$i][6]; + $w = max( $w, $maxw ); + $h = max( $h, $maxh ); + } + $w += $this->lm+$this->rm; + $h += $this->tm+$this->bm; + + // User specified width,height overrides + if( $this->iWidth !== NULL && $this->iWidth !== 0 ) $w = $this->iWidth; + if( $this->iHeight!== NULL && $this->iHeight !== 0) $h = $this->iHeight; + + if( $this->doshadow ) { + $w += $this->shadow_width; + $h += $this->shadow_width; + } + + $image = new Image($w,$h); + $image->SetImgFormat( $this->image_format,$this->image_quality); + + if( $this->doshadow ) { + $image->SetColor($this->iFrameColor); + $image->ShadowRectangle(0,0,$w-1,$h-1,$this->iFillColor,$this->shadow_width,$this->shadow_color); + $w -= $this->shadow_width; + $h -= $this->shadow_width; + } + else { + $image->SetColor($this->iFillColor); + $image->FilledRectangle(0,0,$w-1,$h-1); + } + $image->SetExpired($this->expired); + + $this->img = $image->img; + $this->_strokeBackgroundImage(); + + if( $this->iDoFrame && ! $this->doshadow ) { + $image->SetColor($this->iFrameColor); + $image->SetLineWeight($this->iFrameWeight); + $image->Rectangle(0,0,$w-1,$h-1); + } + + // Copy all sub graphs to the container + for($i=0; $i < $this->iCnt; ++$i ) { + $image->CopyMerge($this->iGraphs[$i][0], + $this->iGraphs[$i][1]+$this->lm,$this->iGraphs[$i][2]+$this->tm, + $this->iGraphs[$i][3],$this->iGraphs[$i][4], + $this->iGraphs[$i][5],$this->iGraphs[$i][6], + -1,-1, /* Full from width and height */ + $this->iGraphs[$i][7]); + + + } + + $this->StrokeTitle($image,$w,$h); + $this->footer->Stroke($image); + + // Output image + if( $aFileName == _IMG_HANDLER ) { + return $image->img; + } + else { + //Finally stream the generated picture + $this->cache = new ImgStreamCache(); + $this->cache->PutAndStream($image,$this->cache_name,$this->inline,$aFileName); + } + } +} + +// EOF + +?> diff --git a/html/jpgraph/jpgraph_pie.php b/html/jpgraph/jpgraph_pie.php new file mode 100644 index 0000000..c79d30f --- /dev/null +++ b/html/jpgraph/jpgraph_pie.php @@ -0,0 +1,1495 @@ +<?php +/*======================================================================= + // File: JPGRAPH_PIE.PHP + // Description: Pie plot extension for JpGraph + // Created: 2001-02-14 + // Ver: $Id: jpgraph_pie.php 1926 2010-01-11 16:33:07Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + + +// Defines for PiePlot::SetLabelType() +define("PIE_VALUE_ABS",1); +define("PIE_VALUE_PER",0); +define("PIE_VALUE_PERCENTAGE",0); +define("PIE_VALUE_ADJPERCENTAGE",2); +define("PIE_VALUE_ADJPER",2); + +//=================================================== +// CLASS PiePlot +// Description: Draws a pie plot +//=================================================== +class PiePlot { + public $posx=0.5,$posy=0.5; + public $is_using_plot_theme = false; + public $theme="earth"; + protected $use_plot_theme_colors = false; + protected $radius=0.3; + protected $explode_radius=array(),$explode_all=false,$explode_r=20; + protected $labels=null, $legends=null; + protected $csimtargets=null,$csimwintargets=null; // Array of targets for CSIM + protected $csimareas=''; // Generated CSIM text + protected $csimalts=null; // ALT tags for corresponding target + protected $data=null; + public $title; + protected $startangle=0; + protected $weight=1, $color="black"; + protected $legend_margin=6,$show_labels=true; + protected $themearr = array( + "earth" => array(136,34,40,45,46,62,63,134,74,10,120,136,141,168,180,77,209,218,346,395,89,430), + "pastel" => array(27,415,128,59,66,79,105,110,42,147,152,230,236,240,331,337,405,38), + "water" => array(8,370,24,40,335,56,213,237,268,14,326,387,10,388), + "sand" => array(27,168,34,170,19,50,65,72,131,209,46,393)); + protected $setslicecolors=array(); + protected $labeltype=0; // Default to percentage + protected $pie_border=true,$pie_interior_border=true; + public $value; + protected $ishadowcolor='',$ishadowdrop=4; + protected $ilabelposadj=1; + protected $legendcsimtargets = array(),$legendcsimwintargets = array(); + protected $legendcsimalts = array(); + protected $adjusted_data = array(); + public $guideline = null; + protected $guidelinemargin=10,$iShowGuideLineForSingle = false; + protected $iGuideLineCurve = false,$iGuideVFactor=1.4,$iGuideLineRFactor=0.8; + protected $la = array(); // Holds the exact angle for each label + + //--------------- + // CONSTRUCTOR + function __construct($data) { + $this->data = array_reverse($data); + $this->title = new Text(""); + $this->title->SetFont(FF_DEFAULT,FS_BOLD); + $this->value = new DisplayValue(); + $this->value->Show(); + $this->value->SetFormat('%.1f%%'); + $this->guideline = new LineProperty(); + } + + //--------------- + // PUBLIC METHODS + function SetCenter($x,$y=0.5) { + $this->posx = $x; + $this->posy = $y; + } + + // Enable guideline and set drwaing policy + function SetGuideLines($aFlg=true,$aCurved=true,$aAlways=false) { + $this->guideline->Show($aFlg); + $this->iShowGuideLineForSingle = $aAlways; + $this->iGuideLineCurve = $aCurved; + } + + // Adjuste the distance between labels and labels and pie + function SetGuideLinesAdjust($aVFactor,$aRFactor=0.8) { + $this->iGuideVFactor=$aVFactor; + $this->iGuideLineRFactor=$aRFactor; + } + + function SetColor($aColor) { + $this->color = $aColor; + } + + function SetSliceColors($aColors) { + $this->setslicecolors = $aColors; + } + + function SetShadow($aColor='darkgray',$aDropWidth=4) { + $this->ishadowcolor = $aColor; + $this->ishadowdrop = $aDropWidth; + } + + function SetCSIMTargets($aTargets,$aAlts='',$aWinTargets='') { + $this->csimtargets=array_reverse($aTargets); + if( is_array($aWinTargets) ) + $this->csimwintargets=array_reverse($aWinTargets); + if( is_array($aAlts) ) + $this->csimalts=array_reverse($aAlts); + } + + function GetCSIMareas() { + return $this->csimareas; + } + + function AddSliceToCSIM($i,$xc,$yc,$radius,$sa,$ea) { + //Slice number, ellipse centre (x,y), height, width, start angle, end angle + while( $sa > 2*M_PI ) $sa = $sa - 2*M_PI; + while( $ea > 2*M_PI ) $ea = $ea - 2*M_PI; + + $sa = 2*M_PI - $sa; + $ea = 2*M_PI - $ea; + + // Special case when we have only one slice since then both start and end + // angle will be == 0 + if( abs($sa - $ea) < 0.0001 ) { + $sa=2*M_PI; $ea=0; + } + + //add coordinates of the centre to the map + $xc = floor($xc);$yc=floor($yc); + $coords = "$xc, $yc"; + + //add coordinates of the first point on the arc to the map + $xp = floor(($radius*cos($ea))+$xc); + $yp = floor($yc-$radius*sin($ea)); + $coords.= ", $xp, $yp"; + + //add coordinates every 0.2 radians + $a=$ea+0.2; + + // If we cross the 360-limit with a slice we need to handle + // the fact that end angle is smaller than start + if( $sa < $ea ) { + while ($a <= 2*M_PI) { + $xp = floor($radius*cos($a)+$xc); + $yp = floor($yc-$radius*sin($a)); + $coords.= ", $xp, $yp"; + $a += 0.2; + } + $a -= 2*M_PI; + } + + + while ($a < $sa) { + $xp = floor($radius*cos($a)+$xc); + $yp = floor($yc-$radius*sin($a)); + $coords.= ", $xp, $yp"; + $a += 0.2; + } + + //Add the last point on the arc + $xp = floor($radius*cos($sa)+$xc); + $yp = floor($yc-$radius*sin($sa)); + $coords.= ", $xp, $yp"; + if( !empty($this->csimtargets[$i]) ) { + $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".$this->csimtargets[$i]."\""; + $tmp=""; + if( !empty($this->csimwintargets[$i]) ) { + $this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" "; + } + if( !empty($this->csimalts[$i]) ) { + $tmp=sprintf($this->csimalts[$i],$this->data[$i]); + $this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimareas .= " />\n"; + } + } + + + function SetTheme($aTheme) { +// JpGraphError::RaiseL(15012,$aTheme); +// return; + + if( in_array($aTheme,array_keys($this->themearr)) ) { + $this->theme = $aTheme; + $this->is_using_plot_theme = true; + } else { + JpGraphError::RaiseL(15001,$aTheme);//("PiePLot::SetTheme() Unknown theme: $aTheme"); + } + } + + function ExplodeSlice($e,$radius=20) { + if( ! is_integer($e) ) + JpGraphError::RaiseL(15002);//('Argument to PiePlot::ExplodeSlice() must be an integer'); + $this->explode_radius[$e]=$radius; + } + + function ExplodeAll($radius=20) { + $this->explode_all=true; + $this->explode_r = $radius; + } + + function Explode($aExplodeArr) { + if( !is_array($aExplodeArr) ) { + JpGraphError::RaiseL(15003); + //("Argument to PiePlot::Explode() must be an array with integer distances."); + } + $this->explode_radius = $aExplodeArr; + } + + function SetStartAngle($aStart) { + if( $aStart < 0 || $aStart > 360 ) { + JpGraphError::RaiseL(15004);//('Slice start angle must be between 0 and 360 degrees.'); + } + if( $aStart == 0 ) { + $this->startangle = 0; + } + else { + $this->startangle = 360-$aStart; + $this->startangle *= M_PI/180; + } + } + + // Size in percentage + function SetSize($aSize) { + if( ($aSize>0 && $aSize<=0.5) || ($aSize>10 && $aSize<1000) ) + $this->radius = $aSize; + else + JpGraphError::RaiseL(15006); + //("PiePlot::SetSize() Radius for pie must either be specified as a fraction [0, 0.5] of the size of the image or as an absolute size in pixels in the range [10, 1000]"); + } + + // Set label arrays + function SetLegends($aLegend) { + $this->legends = $aLegend; + } + + // Set text labels for slices + function SetLabels($aLabels,$aLblPosAdj="auto") { + $this->labels = array_reverse($aLabels); + $this->ilabelposadj=$aLblPosAdj; + } + + function SetLabelPos($aLblPosAdj) { + $this->ilabelposadj=$aLblPosAdj; + } + + // Should we display actual value or percentage? + function SetLabelType($aType) { + if( $aType < 0 || $aType > 2 ) + JpGraphError::RaiseL(15008,$aType); + //("PiePlot::SetLabelType() Type for pie plots must be 0 or 1 (not $t)."); + $this->labeltype = $aType; + } + + // Deprecated. + function SetValueType($aType) { + $this->SetLabelType($aType); + } + + // Should the circle around a pie plot be displayed + function ShowBorder($exterior=true,$interior=true) { + $this->pie_border = $exterior; + $this->pie_interior_border = $interior; + } + + // Setup the legends + function Legend($graph) { + $colors = array_keys($graph->img->rgb->rgb_table); + sort($colors); + $ta=$this->themearr[$this->theme]; + $n = count($this->data); + + if( $this->setslicecolors==null ) { + $numcolors=count($ta); + if( class_exists('PiePlot3D',false) && ($this instanceof PiePlot3D) ) { + $ta = array_reverse(array_slice($ta,0,$n)); + } + } + else { + $this->setslicecolors = array_slice($this->setslicecolors,0,$n); + $numcolors=count($this->setslicecolors); + if( $graph->pieaa && !($this instanceof PiePlot3D) ) { + $this->setslicecolors = array_reverse($this->setslicecolors); + } + } + + $sum=0; + for($i=0; $i < $n; ++$i) + $sum += $this->data[$i]; + + // Bail out with error if the sum is 0 + if( $sum==0 ) + JpGraphError::RaiseL(15009);//("Illegal pie plot. Sum of all data is zero for Pie!"); + + // Make sure we don't plot more values than data points + // (in case the user added more legends than data points) + $n = min(count($this->legends),count($this->data)); + if( $this->legends != "" ) { + $this->legends = array_reverse(array_slice($this->legends,0,$n)); + } + for( $i=$n-1; $i >= 0; --$i ) { + $l = $this->legends[$i]; + // Replace possible format with actual values + if( count($this->csimalts) > $i ) { + $fmt = $this->csimalts[$i]; + } + else { + $fmt = "%d"; // Deafult Alt if no other has been specified + } + if( $this->labeltype==0 ) { + $l = sprintf($l,100*$this->data[$i]/$sum); + $alt = sprintf($fmt,$this->data[$i]); + + } + elseif( $this->labeltype == 1) { + $l = sprintf($l,$this->data[$i]); + $alt = sprintf($fmt,$this->data[$i]); + + } + else { + $l = sprintf($l,$this->adjusted_data[$i]); + $alt = sprintf($fmt,$this->adjusted_data[$i]); + } + + if( empty($this->csimwintargets[$i]) ) { + $wintarg = ''; + } + else { + $wintarg = $this->csimwintargets[$i]; + } + + if( $this->setslicecolors==null ) { + $graph->legend->Add($l,$colors[$ta[$i%$numcolors]],"",0,$this->csimtargets[$i],$alt,$wintarg); + } + else { + $graph->legend->Add($l,$this->setslicecolors[$i%$numcolors],"",0,$this->csimtargets[$i],$alt,$wintarg); + } + } + } + + // Adjust the rounded percetage value so that the sum of + // of the pie slices are always 100% + // Using the Hare/Niemeyer method + function AdjPercentage($aData,$aPrec=0) { + $mul=100; + if( $aPrec > 0 && $aPrec < 3 ) { + if( $aPrec == 1 ) + $mul=1000; + else + $mul=10000; + } + + $tmp = array(); + $result = array(); + $quote_sum=0; + $n = count($aData) ; + for( $i=0, $sum=0; $i < $n; ++$i ) + $sum+=$aData[$i]; + foreach($aData as $index => $value) { + $tmp_percentage=$value/$sum*$mul; + $result[$index]=floor($tmp_percentage); + $tmp[$index]=$tmp_percentage-$result[$index]; + $quote_sum+=$result[$index]; + } + if( $quote_sum == $mul) { + if( $mul > 100 ) { + $tmp = $mul / 100; + for( $i=0; $i < $n; ++$i ) { + $result[$i] /= $tmp ; + } + } + return $result; + } + arsort($tmp,SORT_NUMERIC); + reset($tmp); + for($i=0; $i < $mul-$quote_sum; $i++) + { + $result[key($tmp)]++; + next($tmp); + } + if( $mul > 100 ) { + $tmp = $mul / 100; + for( $i=0; $i < $n; ++$i ) { + $result[$i] /= $tmp ; + } + } + return $result; + } + + + function Stroke($img,$aaoption=0) { + // aaoption is used to handle antialias + // aaoption == 0 a normal pie + // aaoption == 1 just the body + // aaoption == 2 just the values + + // Explode scaling. If anti alias we scale the image + // twice and we also need to scale the exploding distance + $expscale = $aaoption === 1 ? 2 : 1; + + if( $this->labeltype == 2 ) { + // Adjust the data so that it will add up to 100% + $this->adjusted_data = $this->AdjPercentage($this->data); + } + + if ($this->use_plot_theme_colors) { + $this->setslicecolors = null; + } + + $colors = array_keys($img->rgb->rgb_table); + sort($colors); + $ta=$this->themearr[$this->theme]; + $n = count($this->data); + + if( $this->setslicecolors==null ) { + $numcolors=count($ta); + } + else { + // We need to create an array of colors as long as the data + // since we need to reverse it to get the colors in the right order + $numcolors=count($this->setslicecolors); + $i = 2*$numcolors; + while( $n > $i ) { + $this->setslicecolors = array_merge($this->setslicecolors,$this->setslicecolors); + $i += $n; + } + $tt = array_slice($this->setslicecolors,0,$n % $numcolors); + $this->setslicecolors = array_merge($this->setslicecolors,$tt); + $this->setslicecolors = array_reverse($this->setslicecolors); + } + + // Draw the slices + $sum=0; + for($i=0; $i < $n; ++$i) + $sum += $this->data[$i]; + + // Bail out with error if the sum is 0 + if( $sum==0 ) { + JpGraphError::RaiseL(15009);//("Sum of all data is 0 for Pie."); + } + + // Set up the pie-circle + if( $this->radius <= 1 ) { + $radius = floor($this->radius*min($img->width,$img->height)); + } + else { + $radius = $aaoption === 1 ? $this->radius*2 : $this->radius; + } + + if( $this->posx <= 1 && $this->posx > 0 ) { + $xc = round($this->posx*$img->width); + } + else { + $xc = $this->posx ; + } + + if( $this->posy <= 1 && $this->posy > 0 ) { + $yc = round($this->posy*$img->height); + } + else { + $yc = $this->posy ; + } + + $n = count($this->data); + + if( $this->explode_all ) { + for($i=0; $i < $n; ++$i) { + $this->explode_radius[$i]=$this->explode_r; + } + } + + // If we have a shadow and not just drawing the labels + if( $this->ishadowcolor != "" && $aaoption !== 2) { + $accsum=0; + $angle2 = $this->startangle; + $img->SetColor($this->ishadowcolor); + for($i=0; $sum > 0 && $i < $n; ++$i) { + $j = $n-$i-1; + $d = $this->data[$i]; + $angle1 = $angle2; + $accsum += $d; + $angle2 = $this->startangle+2*M_PI*$accsum/$sum; + if( empty($this->explode_radius[$j]) ) { + $this->explode_radius[$j]=0; + } + + if( $d < 0.00001 ) continue; + + $la = 2*M_PI - (abs($angle2-$angle1)/2.0+$angle1); + + $xcm = $xc + $this->explode_radius[$j]*cos($la)*$expscale; + $ycm = $yc - $this->explode_radius[$j]*sin($la)*$expscale; + + $xcm += $this->ishadowdrop*$expscale; + $ycm += $this->ishadowdrop*$expscale; + + $_sa = round($angle1*180/M_PI); + $_ea = round($angle2*180/M_PI); + + // The CakeSlice method draws a full circle in case of start angle = end angle + // for pie slices we don't want this behaviour unless we only have one + // slice in the pie in case it is the wanted behaviour + if( $_ea-$_sa > 0.1 || $n==1 ) { + $img->CakeSlice($xcm,$ycm,$radius-1,$radius-1, + $angle1*180/M_PI,$angle2*180/M_PI,$this->ishadowcolor); + } + } + } + + //-------------------------------------------------------------------------------- + // This is the main loop to draw each cake slice + //-------------------------------------------------------------------------------- + + // Set up the accumulated sum, start angle for first slice and border color + $accsum=0; + $angle2 = $this->startangle; + $img->SetColor($this->color); + + // Loop though all the slices if there is a pie to draw (sum>0) + // There are n slices in total + for($i=0; $sum>0 && $i < $n; ++$i) { + + // $j is the actual index used for the slice + $j = $n-$i-1; + + // Make sure we havea valid distance to explode the slice + if( empty($this->explode_radius[$j]) ) { + $this->explode_radius[$j]=0; + } + + // The actual numeric value for the slice + $d = $this->data[$i]; + + $angle1 = $angle2; + + // Accumlate the sum + $accsum += $d; + + // The new angle when we add the "size" of this slice + // angle1 is then the start and angle2 the end of this slice + $angle2 = $this->NormAngle($this->startangle+2*M_PI*$accsum/$sum); + + // We avoid some trouble by not allowing end angle to be 0, in that case + // we translate to 360 + + // la is used to hold the label angle, which is centered on the slice + if( $angle2 < 0.0001 && $angle1 > 0.0001 ) { + $this->la[$i] = 2*M_PI - (abs(2*M_PI-$angle1)/2.0+$angle1); + } + elseif( $angle1 > $angle2 ) { + // The case where the slice crosses the 3 a'clock line + // Remember that the slices are counted clockwise and + // labels are counted counter clockwise so we need to revert with 2 PI + $this->la[$i] = 2*M_PI-$this->NormAngle($angle1 + ((2*M_PI - $angle1)+$angle2)/2); + } + else { + $this->la[$i] = 2*M_PI - (abs($angle2-$angle1)/2.0+$angle1); + } + + // Too avoid rounding problems we skip the slice if it is too small + if( $d < 0.00001 ) continue; + + // If the user has specified an array of colors for each slice then use + // that a color otherwise use the theme array (ta) of colors + if( $this->setslicecolors==null ) { + $slicecolor=$colors[$ta[$i%$numcolors]]; + } + else { + $slicecolor=$this->setslicecolors[$i%$numcolors]; + } + +// $_sa = round($angle1*180/M_PI); +// $_ea = round($angle2*180/M_PI); +// $_la = round($this->la[$i]*180/M_PI); +// echo "Slice#$i: ang1=$_sa , ang2=$_ea, la=$_la, color=$slicecolor<br>"; + + + // If we have enabled antialias then we don't draw any border so + // make the bordedr color the same as the slice color + if( $this->pie_interior_border && $aaoption===0 ) { + $img->SetColor($this->color); + } + else { + $img->SetColor($slicecolor); + } + $arccolor = $this->pie_border && $aaoption===0 ? $this->color : ""; + + // Calculate the x,y coordinates for the base of this slice taking + // the exploded distance into account. Here we use the mid angle as the + // ray of extension and we have the mid angle handy as it is also the + // label angle + $xcm = $xc + $this->explode_radius[$j]*cos($this->la[$i])*$expscale; + $ycm = $yc - $this->explode_radius[$j]*sin($this->la[$i])*$expscale; + + // If we are not just drawing the labels then draw this cake slice + if( $aaoption !== 2 ) { + + $_sa = round($angle1*180/M_PI); + $_ea = round($angle2*180/M_PI); + $_la = round($this->la[$i]*180/M_PI); + //echo "[$i] sa=$_sa, ea=$_ea, la[$i]=$_la, (color=$slicecolor)<br>"; + + // The CakeSlice method draws a full circle in case of start angle = end angle + // for pie slices we want this in case the slice have a value larger than 99% of the + // total sum + if( abs($_ea-$_sa) >= 1 || $d == $sum ) { + $img->CakeSlice($xcm,$ycm,$radius-1,$radius-1,$_sa,$_ea,$slicecolor,$arccolor); + } + } + + // If the CSIM is used then make sure we register a CSIM area for this slice as well + if( $this->csimtargets && $aaoption !== 1 ) { + $this->AddSliceToCSIM($i,$xcm,$ycm,$radius,$angle1,$angle2); + } + } + + // Format the titles for each slice + if( $aaoption !== 2 ) { + for( $i=0; $i < $n; ++$i) { + if( $this->labeltype==0 ) { + if( $sum != 0 ) + $l = 100.0*$this->data[$i]/$sum; + else + $l = 0.0; + } + elseif( $this->labeltype==1 ) { + $l = $this->data[$i]*1.0; + } + else { + $l = $this->adjusted_data[$i]; + } + if( isset($this->labels[$i]) && is_string($this->labels[$i]) ) + $this->labels[$i]=sprintf($this->labels[$i],$l); + else + $this->labels[$i]=$l; + } + } + + if( $this->value->show && $aaoption !== 1 ) { + $this->StrokeAllLabels($img,$xc,$yc,$radius); + } + + // Adjust title position + if( $aaoption !== 1 ) { + $this->title->SetPos($xc, + $yc-$this->title->GetFontHeight($img)-$radius-$this->title->margin, + "center","bottom"); + $this->title->Stroke($img); + } + + } + + //--------------- + // PRIVATE METHODS + + function NormAngle($a) { + while( $a < 0 ) $a += 2*M_PI; + while( $a > 2*M_PI ) $a -= 2*M_PI; + return $a; + } + + function Quadrant($a) { + $a=$this->NormAngle($a); + if( $a > 0 && $a <= M_PI/2 ) + return 0; + if( $a > M_PI/2 && $a <= M_PI ) + return 1; + if( $a > M_PI && $a <= 1.5*M_PI ) + return 2; + if( $a > 1.5*M_PI ) + return 3; + } + + function StrokeGuideLabels($img,$xc,$yc,$radius) { + $n = count($this->labels); + + //----------------------------------------------------------------------- + // Step 1 of the algorithm is to construct a number of clusters + // a cluster is defined as all slices within the same quadrant (almost) + // that has an angular distance less than the treshold + //----------------------------------------------------------------------- + $tresh_hold=25 * M_PI/180; // 25 degrees difference to be in a cluster + $incluster=false; // flag if we are currently in a cluster or not + $clusters = array(); // array of clusters + $cidx=-1; // running cluster index + + // Go through all the labels and construct a number of clusters + for($i=0; $i < $n-1; ++$i) { + // Calc the angle distance between two consecutive slices + $a1=$this->la[$i]; + $a2=$this->la[$i+1]; + $q1 = $this->Quadrant($a1); + $q2 = $this->Quadrant($a2); + $diff = abs($a1-$a2); + if( $diff < $tresh_hold ) { + if( $incluster ) { + $clusters[$cidx][1]++; + // Each cluster can only cover one quadrant + // Do we cross a quadrant ( and must break the cluster) + if( $q1 != $q2 ) { + // If we cross a quadrant boundary we normally start a + // new cluster. However we need to take the 12'a clock + // and 6'a clock positions into a special consideration. + // Case 1: WE go from q=1 to q=2 if the last slice on + // the cluster for q=1 is close to 12'a clock and the + // first slice in q=0 is small we extend the previous + // cluster + if( $q1 == 1 && $q2 == 0 && $a2 > (90-15)*M_PI/180 ) { + if( $i < $n-2 ) { + $a3 = $this->la[$i+2]; + // If there isn't a cluster coming up with the next-next slice + // we extend the previous cluster to cover this slice as well + if( abs($a3-$a2) >= $tresh_hold ) { + $clusters[$cidx][1]++; + $i++; + } + } + } + elseif( $q1 == 3 && $q2 == 2 && $a2 > (270-15)*M_PI/180 ) { + if( $i < $n-2 ) { + $a3 = $this->la[$i+2]; + // If there isn't a cluster coming up with the next-next slice + // we extend the previous cluster to cover this slice as well + if( abs($a3-$a2) >= $tresh_hold ) { + $clusters[$cidx][1]++; + $i++; + } + } + } + + if( $q1==2 && $q2==1 && $a2 > (180-15)*M_PI/180 ) { + $clusters[$cidx][1]++; + $i++; + } + + $incluster = false; + } + } + elseif( $q1 == $q2) { + $incluster = true; + // Now we have a special case for quadrant 0. If we previously + // have a cluster of one in quadrant 0 we just extend that + // cluster. If we don't do this then we risk that the label + // for the cluster of one will cross the guide-line + if( $q1 == 0 && $cidx > -1 && + $clusters[$cidx][1] == 1 && + $this->Quadrant($this->la[$clusters[$cidx][0]]) == 0 ) { + $clusters[$cidx][1]++; + } + else { + $cidx++; + $clusters[$cidx][0] = $i; + $clusters[$cidx][1] = 1; + } + } + else { + // Create a "cluster" of one since we are just crossing + // a quadrant + $cidx++; + $clusters[$cidx][0] = $i; + $clusters[$cidx][1] = 1; + } + } + else { + if( $incluster ) { + // Add the last slice + $clusters[$cidx][1]++; + $incluster = false; + } + else { // Create a "cluster" of one + $cidx++; + $clusters[$cidx][0] = $i; + $clusters[$cidx][1] = 1; + } + } + } + // Handle the very last slice + if( $incluster ) { + $clusters[$cidx][1]++; + } + else { // Create a "cluster" of one + $cidx++; + $clusters[$cidx][0] = $i; + $clusters[$cidx][1] = 1; + } + + /* + if( true ) { + // Debug printout in labels + for( $i=0; $i <= $cidx; ++$i ) { + for( $j=0; $j < $clusters[$i][1]; ++$j ) { + $a = $this->la[$clusters[$i][0]+$j]; + $aa = round($a*180/M_PI); + $q = $this->Quadrant($a); + $this->labels[$clusters[$i][0]+$j]="[$q:$aa] $i:$j"; + } + } + } + */ + + //----------------------------------------------------------------------- + // Step 2 of the algorithm is use the clusters and draw the labels + // and guidelines + //----------------------------------------------------------------------- + + // We use the font height as the base factor for how far we need to + // spread the labels in the Y-direction. + $this->value->ApplyFont($img); + $fh = $img->GetFontHeight(); + $origvstep=$fh*$this->iGuideVFactor; + $this->value->SetMargin(0); + + // Number of clusters found + $nc = count($clusters); + + // Walk through all the clusters + for($i=0; $i < $nc; ++$i) { + + // Start angle and number of slices in this cluster + $csize = $clusters[$i][1]; + $a = $this->la[$clusters[$i][0]]; + $q = $this->Quadrant($a); + + // Now set up the start and end conditions to make sure that + // in each cluster we walk through the all the slices starting with the slice + // closest to the equator. Since all slices are numbered clockwise from "3'a clock" + // we have different conditions depending on in which quadrant the slice lies within. + if( $q == 0 ) { + $start = $csize-1; $idx = $start; $step = -1; $vstep = -$origvstep; + } + elseif( $q == 1 ) { + $start = 0; $idx = $start; $step = 1; $vstep = -$origvstep; + } + elseif( $q == 2 ) { + $start = $csize-1; $idx = $start; $step = -1; $vstep = $origvstep; + } + elseif( $q == 3 ) { + $start = 0; $idx = $start; $step = 1; $vstep = $origvstep; + } + + // Walk through all slices within this cluster + for($j=0; $j < $csize; ++$j) { + // Now adjust the position of the labels in each cluster starting + // with the slice that is closest to the equator of the pie + $a = $this->la[$clusters[$i][0]+$idx]; + + // Guide line start in the center of the arc of the slice + $r = $radius+$this->explode_radius[$n-1-($clusters[$i][0]+$idx)]; + $x = round($r*cos($a)+$xc); + $y = round($yc-$r*sin($a)); + + // The distance from the arc depends on chosen font and the "R-Factor" + $r += $fh*$this->iGuideLineRFactor; + + // Should the labels be placed curved along the pie or in straight columns + // outside the pie? + if( $this->iGuideLineCurve ) + $xt=round($r*cos($a)+$xc); + + // If this is the first slice in the cluster we need some first time + // proessing + if( $idx == $start ) { + if( ! $this->iGuideLineCurve ) + $xt=round($r*cos($a)+$xc); + $yt=round($yc-$r*sin($a)); + + // Some special consideration in case this cluster starts + // in quadrant 1 or 3 very close to the "equator" (< 20 degrees) + // and the previous clusters last slice is within the tolerance. + // In that case we add a font height to this labels Y-position + // so it doesn't collide with + // the slice in the previous cluster + $prevcluster = ($i + ($nc-1) ) % $nc; + $previdx=$clusters[$prevcluster][0]+$clusters[$prevcluster][1]-1; + if( $q == 1 && $a > 160*M_PI/180 ) { + // Get the angle for the previous clusters last slice + $diff = abs($a-$this->la[$previdx]); + if( $diff < $tresh_hold ) { + $yt -= $fh; + } + } + elseif( $q == 3 && $a > 340*M_PI/180 ) { + // We need to subtract 360 to compare angle distance between + // q=0 and q=3 + $diff = abs($a-$this->la[$previdx]-360*M_PI/180); + if( $diff < $tresh_hold ) { + $yt += $fh; + } + } + + } + else { + // The step is at minimum $vstep but if the slices are relatively large + // we make sure that we add at least a step that corresponds to the vertical + // distance between the centers at the arc on the slice + $prev_a = $this->la[$clusters[$i][0]+($idx-$step)]; + $dy = abs($radius*(sin($a)-sin($prev_a))*1.2); + if( $vstep > 0 ) + $yt += max($vstep,$dy); + else + $yt += min($vstep,-$dy); + } + + $label = $this->labels[$clusters[$i][0]+$idx]; + + if( $csize == 1 ) { + // A "meta" cluster with only one slice + $r = $radius+$this->explode_radius[$n-1-($clusters[$i][0]+$idx)]; + $rr = $r+$img->GetFontHeight()/2; + $xt=round($rr*cos($a)+$xc); + $yt=round($yc-$rr*sin($a)); + $this->StrokeLabel($label,$img,$xc,$yc,$a,$r); + if( $this->iShowGuideLineForSingle ) + $this->guideline->Stroke($img,$x,$y,$xt,$yt); + } + else { + $this->guideline->Stroke($img,$x,$y,$xt,$yt); + if( $q==1 || $q==2 ) { + // Left side of Pie + $this->guideline->Stroke($img,$xt,$yt,$xt-$this->guidelinemargin,$yt); + $lbladj = -$this->guidelinemargin-5; + $this->value->halign = "right"; + $this->value->valign = "center"; + } + else { + // Right side of pie + $this->guideline->Stroke($img,$xt,$yt,$xt+$this->guidelinemargin,$yt); + $lbladj = $this->guidelinemargin+5; + $this->value->halign = "left"; + $this->value->valign = "center"; + } + $this->value->Stroke($img,$label,$xt+$lbladj,$yt); + } + + // Udate idx to point to next slice in the cluster to process + $idx += $step; + } + } + } + + function StrokeAllLabels($img,$xc,$yc,$radius) { + // First normalize all angles for labels + $n = count($this->la); + for($i=0; $i < $n; ++$i) { + $this->la[$i] = $this->NormAngle($this->la[$i]); + } + if( $this->guideline->iShow ) { + $this->StrokeGuideLabels($img,$xc,$yc,$radius); + } + else { + $n = count($this->labels); + for($i=0; $i < $n; ++$i) { + $this->StrokeLabel($this->labels[$i],$img,$xc,$yc, + $this->la[$i], + $radius + $this->explode_radius[$n-1-$i]); + } + } + } + + // Position the labels of each slice + function StrokeLabel($label,$img,$xc,$yc,$a,$r) { + + // Default value + if( $this->ilabelposadj === 'auto' ) + $this->ilabelposadj = 0.65; + + // We position the values diferently depending on if they are inside + // or outside the pie + if( $this->ilabelposadj < 1.0 ) { + + $this->value->SetAlign('center','center'); + $this->value->margin = 0; + + $xt=round($this->ilabelposadj*$r*cos($a)+$xc); + $yt=round($yc-$this->ilabelposadj*$r*sin($a)); + + $this->value->Stroke($img,$label,$xt,$yt); + } + else { + + $this->value->halign = "left"; + $this->value->valign = "top"; + $this->value->margin = 0; + + // Position the axis title. + // dx, dy is the offset from the top left corner of the bounding box that sorrounds the text + // that intersects with the extension of the corresponding axis. The code looks a little + // bit messy but this is really the only way of having a reasonable position of the + // axis titles. + $this->value->ApplyFont($img); + $h=$img->GetTextHeight($label); + // For numeric values the format of the display value + // must be taken into account + if( is_numeric($label) ) { + if( $label > 0 ) + $w=$img->GetTextWidth(sprintf($this->value->format,$label)); + else + $w=$img->GetTextWidth(sprintf($this->value->negformat,$label)); + } + else + $w=$img->GetTextWidth($label); + + if( $this->ilabelposadj > 1.0 && $this->ilabelposadj < 5.0) { + $r *= $this->ilabelposadj; + } + + $r += $img->GetFontHeight()/1.5; + + $xt=round($r*cos($a)+$xc); + $yt=round($yc-$r*sin($a)); + + // Normalize angle + while( $a < 0 ) $a += 2*M_PI; + while( $a > 2*M_PI ) $a -= 2*M_PI; + + if( $a>=7*M_PI/4 || $a <= M_PI/4 ) $dx=0; + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dx=($a-M_PI/4)*2/M_PI; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dx=1; + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dx=(1-($a-M_PI*5/4)*2/M_PI); + + if( $a>=7*M_PI/4 ) $dy=(($a-M_PI)-3*M_PI/4)*2/M_PI; + if( $a<=M_PI/4 ) $dy=(1-$a*2/M_PI); + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dy=1; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dy=(1-($a-3*M_PI/4)*2/M_PI); + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dy=0; + + $this->value->Stroke($img,$label,$xt-$dx*$w,$yt-$dy*$h); + } + } + + function UsePlotThemeColors($flag = true) { + $this->use_plot_theme_colors = $flag; + } +} // Class + + +//=================================================== +// CLASS PiePlotC +// Description: Same as a normal pie plot but with a +// filled circle in the center +//=================================================== +class PiePlotC extends PiePlot { + private $imidsize=0.5; // Fraction of total width + private $imidcolor='white'; + public $midtitle=''; + private $middlecsimtarget='',$middlecsimwintarget='',$middlecsimalt=''; + + function __construct($data,$aCenterTitle='') { + parent::__construct($data); + $this->midtitle = new Text(); + $this->midtitle->ParagraphAlign('center'); + } + + function SetMid($aTitle,$aColor='white',$aSize=0.5) { + $this->midtitle->Set($aTitle); + + $this->imidsize = $aSize ; + $this->imidcolor = $aColor ; + } + + function SetMidTitle($aTitle) { + $this->midtitle->Set($aTitle); + } + + function SetMidSize($aSize) { + $this->imidsize = $aSize ; + } + + function SetMidColor($aColor) { + $this->imidcolor = $aColor ; + } + + function SetMidCSIM($aTarget,$aAlt='',$aWinTarget='') { + $this->middlecsimtarget = $aTarget; + $this->middlecsimwintarget = $aWinTarget; + $this->middlecsimalt = $aAlt; + } + + function AddSliceToCSIM($i,$xc,$yc,$radius,$sa,$ea) { + //Slice number, ellipse centre (x,y), radius, start angle, end angle + while( $sa > 2*M_PI ) $sa = $sa - 2*M_PI; + while( $ea > 2*M_PI ) $ea = $ea - 2*M_PI; + + $sa = 2*M_PI - $sa; + $ea = 2*M_PI - $ea; + + // Special case when we have only one slice since then both start and end + // angle will be == 0 + if( abs($sa - $ea) < 0.0001 ) { + $sa=2*M_PI; $ea=0; + } + + // Add inner circle first point + $xp = floor(($this->imidsize*$radius*cos($ea))+$xc); + $yp = floor($yc-($this->imidsize*$radius*sin($ea))); + $coords = "$xp, $yp"; + + //add coordinates every 0.25 radians + $a=$ea+0.25; + + // If we cross the 360-limit with a slice we need to handle + // the fact that end angle is smaller than start + if( $sa < $ea ) { + while ($a <= 2*M_PI) { + $xp = floor($radius*cos($a)+$xc); + $yp = floor($yc-$radius*sin($a)); + $coords.= ", $xp, $yp"; + $a += 0.25; + } + $a -= 2*M_PI; + } + + while ($a < $sa) { + $xp = floor(($this->imidsize*$radius*cos($a)+$xc)); + $yp = floor($yc-($this->imidsize*$radius*sin($a))); + $coords.= ", $xp, $yp"; + $a += 0.25; + } + + // Make sure we end at the last point + $xp = floor(($this->imidsize*$radius*cos($sa)+$xc)); + $yp = floor($yc-($this->imidsize*$radius*sin($sa))); + $coords.= ", $xp, $yp"; + + // Straight line to outer circle + $xp = floor($radius*cos($sa)+$xc); + $yp = floor($yc-$radius*sin($sa)); + $coords.= ", $xp, $yp"; + + //add coordinates every 0.25 radians + $a=$sa - 0.25; + while ($a > $ea) { + $xp = floor($radius*cos($a)+$xc); + $yp = floor($yc-$radius*sin($a)); + $coords.= ", $xp, $yp"; + $a -= 0.25; + } + + //Add the last point on the arc + $xp = floor($radius*cos($ea)+$xc); + $yp = floor($yc-$radius*sin($ea)); + $coords.= ", $xp, $yp"; + + // Close the arc + $xp = floor(($this->imidsize*$radius*cos($ea))+$xc); + $yp = floor($yc-($this->imidsize*$radius*sin($ea))); + $coords .= ", $xp, $yp"; + + if( !empty($this->csimtargets[$i]) ) { + $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"". + $this->csimtargets[$i]."\""; + if( !empty($this->csimwintargets[$i]) ) { + $this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" "; + } + if( !empty($this->csimalts[$i]) ) { + $tmp=sprintf($this->csimalts[$i],$this->data[$i]); + $this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimareas .= " />\n"; + } + } + + + function Stroke($img,$aaoption=0) { + + // Stroke the pie but don't stroke values + $tmp = $this->value->show; + $this->value->show = false; + parent::Stroke($img,$aaoption); + $this->value->show = $tmp; + + $xc = round($this->posx*$img->width); + $yc = round($this->posy*$img->height); + + $radius = floor($this->radius * min($img->width,$img->height)) ; + + + if( $this->imidsize > 0 && $aaoption !== 2 ) { + + if( $this->ishadowcolor != "" ) { + $img->SetColor($this->ishadowcolor); + $img->FilledCircle($xc+$this->ishadowdrop,$yc+$this->ishadowdrop, + round($radius*$this->imidsize)); + } + + $img->SetColor($this->imidcolor); + $img->FilledCircle($xc,$yc,round($radius*$this->imidsize)); + + if( $this->pie_border && $aaoption === 0 ) { + $img->SetColor($this->color); + $img->Circle($xc,$yc,round($radius*$this->imidsize)); + } + + if( !empty($this->middlecsimtarget) ) + $this->AddMiddleCSIM($xc,$yc,round($radius*$this->imidsize)); + + } + + if( $this->value->show && $aaoption !== 1) { + $this->StrokeAllLabels($img,$xc,$yc,$radius); + $this->midtitle->SetPos($xc,$yc,'center','center'); + $this->midtitle->Stroke($img); + } + + } + + function AddMiddleCSIM($xc,$yc,$r) { + $xc=round($xc);$yc=round($yc);$r=round($r); + $this->csimareas .= "<area shape=\"circle\" coords=\"$xc,$yc,$r\" href=\"". + $this->middlecsimtarget."\""; + if( !empty($this->middlecsimwintarget) ) { + $this->csimareas .= " target=\"".$this->middlecsimwintarget."\""; + } + if( !empty($this->middlecsimalt) ) { + $tmp = $this->middlecsimalt; + $this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimareas .= " />\n"; + } + + function StrokeLabel($label,$img,$xc,$yc,$a,$r) { + + if( $this->ilabelposadj === 'auto' ) + $this->ilabelposadj = (1-$this->imidsize)/2+$this->imidsize; + + parent::StrokeLabel($label,$img,$xc,$yc,$a,$r); + + } + +} + + +//=================================================== +// CLASS PieGraph +// Description: +//=================================================== +class PieGraph extends Graph { + private $posx, $posy, $radius; + private $legends=array(); + public $plots=array(); + public $pieaa = false ; + //--------------- + // CONSTRUCTOR + function __construct($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) { + parent::__construct($width,$height,$cachedName,$timeout,$inline); + $this->posx=$width/2; + $this->posy=$height/2; + $this->SetColor(array(255,255,255)); + + if ($this->graph_theme) { + $this->graph_theme->ApplyGraph($this); + } + } + + //--------------- + // PUBLIC METHODS + function Add($aObj) { + + if( is_array($aObj) && count($aObj) > 0 ) + $cl = $aObj[0]; + else + $cl = $aObj; + + if( $cl instanceof Text ) + $this->AddText($aObj); + elseif( class_exists('IconPlot',false) && ($cl instanceof IconPlot) ) + $this->AddIcon($aObj); + else { + if( is_array($aObj) ) { + $n = count($aObj); + for($i=0; $i < $n; ++$i ) { + //if ($aObj[$i]->theme) { + // $this->ClearTheme(); + //} + $this->plots[] = $aObj[$i]; + } + } + else { + //if ($aObj->theme) { + // $this->ClearTheme(); + //} + $this->plots[] = $aObj; + } + } + + if ($this->graph_theme) { + $this->graph_theme->SetupPlot($aObj); + if ($aObj->is_using_plot_theme) { + $aObj->UsePlotThemeColors(); + } + } + } + + function SetAntiAliasing($aFlg=true) { + $this->pieaa = $aFlg; + } + + function SetColor($c) { + $this->SetMarginColor($c); + } + + + function DisplayCSIMAreas() { + $csim=""; + foreach($this->plots as $p ) { + $csim .= $p->GetCSIMareas(); + } + + $csim.= $this->legend->GetCSIMareas(); + if (preg_match_all("/area shape=\"(\w+)\" coords=\"([0-9\, ]+)\"/", $csim, $coords)) { + $this->img->SetColor($this->csimcolor); + $n = count($coords[0]); + for ($i=0; $i < $n; $i++) { + if ($coords[1][$i]=="poly") { + preg_match_all('/\s*([0-9]+)\s*,\s*([0-9]+)\s*,*/',$coords[2][$i],$pts); + $this->img->SetStartPoint($pts[1][count($pts[0])-1],$pts[2][count($pts[0])-1]); + $m = count($pts[0]); + for ($j=0; $j < $m; $j++) { + $this->img->LineTo($pts[1][$j],$pts[2][$j]); + } + } else if ($coords[1][$i]=="rect") { + $pts = preg_split('/,/', $coords[2][$i]); + $this->img->SetStartPoint($pts[0],$pts[1]); + $this->img->LineTo($pts[2],$pts[1]); + $this->img->LineTo($pts[2],$pts[3]); + $this->img->LineTo($pts[0],$pts[3]); + $this->img->LineTo($pts[0],$pts[1]); + + } + } + } + } + + // Method description + function Stroke($aStrokeFileName="") { + + // If the filename is the predefined value = '_csim_special_' + // we assume that the call to stroke only needs to do enough + // to correctly generate the CSIM maps. + // We use this variable to skip things we don't strictly need + // to do to generate the image map to improve performance + // a best we can. Therefor you will see a lot of tests !$_csim in the + // code below. + $_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); + + // If we are called the second time (perhaps the user has called GetHTMLImageMap() + // himself then the legends have alsready been populated once in order to get the + // CSIM coordinats. Since we do not want the legends to be populated a second time + // we clear the legends + $this->legend->Clear(); + + // We need to know if we have stroked the plot in the + // GetCSIMareas. Otherwise the CSIM hasn't been generated + // and in the case of GetCSIM called before stroke to generate + // CSIM without storing an image to disk GetCSIM must call Stroke. + $this->iHasStroked = true; + + $n = count($this->plots); + + if( $this->pieaa ) { + + if( !$_csim ) { + if( $this->background_image != "" ) { + $this->StrokeFrameBackground(); + } + else { + $this->StrokeFrame(); + $this->StrokeBackgroundGrad(); + } + } + + + $w = $this->img->width; + $h = $this->img->height; + $oldimg = $this->img->img; + + $this->img->CreateImgCanvas(2*$w,2*$h); + + $this->img->SetColor( $this->margin_color ); + $this->img->FilledRectangle(0,0,2*$w-1,2*$h-1); + + // Make all icons *2 i size since we will be scaling down the + // imahe to do the anti aliasing + $ni = count($this->iIcons); + for($i=0; $i < $ni; ++$i) { + $this->iIcons[$i]->iScale *= 2 ; + if( $this->iIcons[$i]->iX > 1 ) + $this->iIcons[$i]->iX *= 2 ; + if( $this->iIcons[$i]->iY > 1 ) + $this->iIcons[$i]->iY *= 2 ; + } + + $this->StrokeIcons(); + + for($i=0; $i < $n; ++$i) { + if( $this->plots[$i]->posx > 1 ) + $this->plots[$i]->posx *= 2 ; + if( $this->plots[$i]->posy > 1 ) + $this->plots[$i]->posy *= 2 ; + + $this->plots[$i]->Stroke($this->img,1); + + if( $this->plots[$i]->posx > 1 ) + $this->plots[$i]->posx /= 2 ; + if( $this->plots[$i]->posy > 1 ) + $this->plots[$i]->posy /= 2 ; + } + + $indent = $this->doframe ? ($this->frame_weight + ($this->doshadow ? $this->shadow_width : 0 )) : 0 ; + $indent += $this->framebevel ? $this->framebeveldepth + 1 : 0 ; + $this->img->CopyCanvasH($oldimg,$this->img->img,$indent,$indent,$indent,$indent, + $w-2*$indent,$h-2*$indent,2*($w-$indent),2*($h-$indent)); + + $this->img->img = $oldimg ; + $this->img->width = $w ; + $this->img->height = $h ; + + for($i=0; $i < $n; ++$i) { + $this->plots[$i]->Stroke($this->img,2); // Stroke labels + $this->plots[$i]->Legend($this); + } + + } + else { + + if( !$_csim ) { + if( $this->background_image != "" ) { + $this->StrokeFrameBackground(); + } + else { + $this->StrokeFrame(); + $this->StrokeBackgroundGrad(); + } + } + + $this->StrokeIcons(); + + for($i=0; $i < $n; ++$i) { + $this->plots[$i]->Stroke($this->img); + $this->plots[$i]->Legend($this); + } + } + + $this->legend->Stroke($this->img); + $this->footer->Stroke($this->img); + $this->StrokeTitles(); + + if( !$_csim ) { + + // Stroke texts + if( $this->texts != null ) { + $n = count($this->texts); + for($i=0; $i < $n; ++$i ) { + $this->texts[$i]->Stroke($this->img); + } + } + + if( _JPG_DEBUG ) { + $this->DisplayCSIMAreas(); + } + + // Should we do any final image transformation + if( $this->iImgTrans ) { + if( !class_exists('ImgTrans',false) ) { + require_once('jpgraph_imgtrans.php'); + //JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.'); + } + + $tform = new ImgTrans($this->img->img); + $this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, + $this->iImgTransDirection,$this->iImgTransHighQ, + $this->iImgTransMinSize,$this->iImgTransFillColor, + $this->iImgTransBorder); + } + + + // If the filename is given as the special "__handle" + // then the image handler is returned and the image is NOT + // streamed back + if( $aStrokeFileName == _IMG_HANDLER ) { + return $this->img->img; + } + else { + // Finally stream the generated picture + $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline, + $aStrokeFileName); + } + } + } +} // Class + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_pie3d.php b/html/jpgraph/jpgraph_pie3d.php new file mode 100644 index 0000000..52b8631 --- /dev/null +++ b/html/jpgraph/jpgraph_pie3d.php @@ -0,0 +1,933 @@ +<?php +/*======================================================================= + // File: JPGRAPH_PIE3D.PHP + // Description: 3D Pie plot extension for JpGraph + // Created: 2001-03-24 + // Ver: $Id: jpgraph_pie3d.php 1329 2009-06-20 19:23:30Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +//=================================================== +// CLASS PiePlot3D +// Description: Plots a 3D pie with a specified projection +// angle between 20 and 70 degrees. +//=================================================== +class PiePlot3D extends PiePlot { + private $labelhintcolor="red",$showlabelhint=true; + private $angle=50; + private $edgecolor="", $edgeweight=1; + private $iThickness=false; + + //--------------- + // CONSTRUCTOR + function __construct($data) { + $this->radius = 0.5; + $this->data = $data; + $this->title = new Text(""); + $this->title->SetFont(FF_FONT1,FS_BOLD); + $this->value = new DisplayValue(); + $this->value->Show(); + $this->value->SetFormat('%.0f%%'); + } + + //--------------- + // PUBLIC METHODS + + // Set label arrays + function SetLegends($aLegend) { + $this->legends = array_reverse(array_slice($aLegend,0,count($this->data))); + } + + function SetSliceColors($aColors) { + $this->setslicecolors = $aColors; + } + + function Legend($aGraph) { + parent::Legend($aGraph); + $aGraph->legend->txtcol = array_reverse($aGraph->legend->txtcol); + } + + function SetCSIMTargets($aTargets,$aAlts='',$aWinTargets='') { + $this->csimtargets = $aTargets; + $this->csimwintargets = $aWinTargets; + $this->csimalts = $aAlts; + } + + // Should the slices be separated by a line? If color is specified as "" no line + // will be used to separate pie slices. + function SetEdge($aColor='black',$aWeight=1) { + $this->edgecolor = $aColor; + $this->edgeweight = $aWeight; + } + + // Specify projection angle for 3D in degrees + // Must be between 20 and 70 degrees + function SetAngle($a) { + if( $a<5 || $a>90 ) { + JpGraphError::RaiseL(14002); + //("PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees."); + } + else { + $this->angle = $a; + } + } + + function Add3DSliceToCSIM($i,$xc,$yc,$height,$width,$thick,$sa,$ea) { //Slice number, ellipse centre (x,y), height, width, start angle, end angle + + $sa *= M_PI/180; + $ea *= M_PI/180; + + //add coordinates of the centre to the map + $coords = "$xc, $yc"; + + //add coordinates of the first point on the arc to the map + $xp = floor($width*cos($sa)/2+$xc); + $yp = floor($yc-$height*sin($sa)/2); + $coords.= ", $xp, $yp"; + + //If on the front half, add the thickness offset + if ($sa >= M_PI && $sa <= 2*M_PI*1.01) { + $yp = floor($yp+$thick); + $coords.= ", $xp, $yp"; + } + + //add coordinates every 0.2 radians + $a=$sa+0.2; + while ($a<$ea) { + $xp = floor($width*cos($a)/2+$xc); + if ($a >= M_PI && $a <= 2*M_PI*1.01) { + $yp = floor($yc-($height*sin($a)/2)+$thick); + } else { + $yp = floor($yc-$height*sin($a)/2); + } + $coords.= ", $xp, $yp"; + $a += 0.2; + } + + //Add the last point on the arc + $xp = floor($width*cos($ea)/2+$xc); + $yp = floor($yc-$height*sin($ea)/2); + + + if ($ea >= M_PI && $ea <= 2*M_PI*1.01) { + $coords.= ", $xp, ".floor($yp+$thick); + } + $coords.= ", $xp, $yp"; + $alt=''; + + if( !empty($this->csimtargets[$i]) ) { + $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".$this->csimtargets[$i]."\""; + + if( !empty($this->csimwintargets[$i]) ) { + $this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" "; + } + + if( !empty($this->csimalts[$i]) ) { + $tmp=sprintf($this->csimalts[$i],$this->data[$i]); + $this->csimareas .= "alt=\"$tmp\" title=\"$tmp\" "; + } + $this->csimareas .= " />\n"; + } + + } + + function SetLabels($aLabels,$aLblPosAdj="auto") { + $this->labels = $aLabels; + $this->ilabelposadj=$aLblPosAdj; + } + + + // Distance from the pie to the labels + function SetLabelMargin($m) { + $this->value->SetMargin($m); + } + + // Show a thin line from the pie to the label for a specific slice + function ShowLabelHint($f=true) { + $this->showlabelhint=$f; + } + + // Set color of hint line to label for each slice + function SetLabelHintColor($c) { + $this->labelhintcolor=$c; + } + + function SetHeight($aHeight) { + $this->iThickness = $aHeight; + } + + + // Normalize Angle between 0-360 + function NormAngle($a) { + // Normalize anle to 0 to 2M_PI + // + if( $a > 0 ) { + while($a > 360) $a -= 360; + } + else { + while($a < 0) $a += 360; + } + if( $a < 0 ) + $a = 360 + $a; + + if( $a == 360 ) $a=0; + return $a; + } + + + + // Draw one 3D pie slice at position ($xc,$yc) with height $z + function Pie3DSlice($img,$xc,$yc,$w,$h,$sa,$ea,$z,$fillcolor,$shadow=0.65) { + + // Due to the way the 3D Pie algorithm works we are + // guaranteed that any slice we get into this method + // belongs to either the left or right side of the + // pie ellipse. Hence, no slice will cross 90 or 270 + // point. + if( ($sa < 90 && $ea > 90) || ( ($sa > 90 && $sa < 270) && $ea > 270) ) { + JpGraphError::RaiseL(14003);//('Internal assertion failed. Pie3D::Pie3DSlice'); + exit(1); + } + + $p[] = array(); + + // Setup pre-calculated values + $rsa = $sa/180*M_PI; // to Rad + $rea = $ea/180*M_PI; // to Rad + $sinsa = sin($rsa); + $cossa = cos($rsa); + $sinea = sin($rea); + $cosea = cos($rea); + + // p[] is the points for the overall slice and + // pt[] is the points for the top pie + + // Angular step when approximating the arc with a polygon train. + $step = 0.05; + + if( $sa >= 270 ) { + if( $ea > 360 || ($ea > 0 && $ea <= 90) ) { + if( $ea > 0 && $ea <= 90 ) { + // Adjust angle to simplify conditions in loops + $rea += 2*M_PI; + } + + $p = array($xc,$yc,$xc,$yc+$z, + $xc+$w*$cossa,$z+$yc-$h*$sinsa); + $pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa); + + for( $a=$rsa; $a < 2*M_PI; $a += $step ) { + $tca = cos($a); + $tsa = sin($a); + $p[] = $xc+$w*$tca; + $p[] = $z+$yc-$h*$tsa; + $pt[] = $xc+$w*$tca; + $pt[] = $yc-$h*$tsa; + } + + $pt[] = $xc+$w; + $pt[] = $yc; + + $p[] = $xc+$w; + $p[] = $z+$yc; + $p[] = $xc+$w; + $p[] = $yc; + $p[] = $xc; + $p[] = $yc; + + for( $a=2*M_PI+$step; $a < $rea; $a += $step ) { + $pt[] = $xc + $w*cos($a); + $pt[] = $yc - $h*sin($a); + } + + $pt[] = $xc+$w*$cosea; + $pt[] = $yc-$h*$sinea; + $pt[] = $xc; + $pt[] = $yc; + + } + else { + $p = array($xc,$yc,$xc,$yc+$z, + $xc+$w*$cossa,$z+$yc-$h*$sinsa); + $pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa); + + $rea = $rea == 0.0 ? 2*M_PI : $rea; + for( $a=$rsa; $a < $rea; $a += $step ) { + $tca = cos($a); + $tsa = sin($a); + $p[] = $xc+$w*$tca; + $p[] = $z+$yc-$h*$tsa; + $pt[] = $xc+$w*$tca; + $pt[] = $yc-$h*$tsa; + } + + $pt[] = $xc+$w*$cosea; + $pt[] = $yc-$h*$sinea; + $pt[] = $xc; + $pt[] = $yc; + + $p[] = $xc+$w*$cosea; + $p[] = $z+$yc-$h*$sinea; + $p[] = $xc+$w*$cosea; + $p[] = $yc-$h*$sinea; + $p[] = $xc; + $p[] = $yc; + } + } + elseif( $sa >= 180 ) { + $p = array($xc,$yc,$xc,$yc+$z,$xc+$w*$cosea,$z+$yc-$h*$sinea); + $pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea); + + for( $a=$rea; $a>$rsa; $a -= $step ) { + $tca = cos($a); + $tsa = sin($a); + $p[] = $xc+$w*$tca; + $p[] = $z+$yc-$h*$tsa; + $pt[] = $xc+$w*$tca; + $pt[] = $yc-$h*$tsa; + } + + $pt[] = $xc+$w*$cossa; + $pt[] = $yc-$h*$sinsa; + $pt[] = $xc; + $pt[] = $yc; + + $p[] = $xc+$w*$cossa; + $p[] = $z+$yc-$h*$sinsa; + $p[] = $xc+$w*$cossa; + $p[] = $yc-$h*$sinsa; + $p[] = $xc; + $p[] = $yc; + + } + elseif( $sa >= 90 ) { + if( $ea > 180 ) { + $p = array($xc,$yc,$xc,$yc+$z,$xc+$w*$cosea,$z+$yc-$h*$sinea); + $pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea); + + for( $a=$rea; $a > M_PI; $a -= $step ) { + $tca = cos($a); + $tsa = sin($a); + $p[] = $xc+$w*$tca; + $p[] = $z + $yc - $h*$tsa; + $pt[] = $xc+$w*$tca; + $pt[] = $yc-$h*$tsa; + } + + $p[] = $xc-$w; + $p[] = $z+$yc; + $p[] = $xc-$w; + $p[] = $yc; + $p[] = $xc; + $p[] = $yc; + + $pt[] = $xc-$w; + $pt[] = $z+$yc; + $pt[] = $xc-$w; + $pt[] = $yc; + + for( $a=M_PI-$step; $a > $rsa; $a -= $step ) { + $pt[] = $xc + $w*cos($a); + $pt[] = $yc - $h*sin($a); + } + + $pt[] = $xc+$w*$cossa; + $pt[] = $yc-$h*$sinsa; + $pt[] = $xc; + $pt[] = $yc; + + } + else { // $sa >= 90 && $ea <= 180 + $p = array($xc,$yc,$xc,$yc+$z, + $xc+$w*$cosea,$z+$yc-$h*$sinea, + $xc+$w*$cosea,$yc-$h*$sinea, + $xc,$yc); + + $pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea); + + for( $a=$rea; $a>$rsa; $a -= $step ) { + $pt[] = $xc + $w*cos($a); + $pt[] = $yc - $h*sin($a); + } + + $pt[] = $xc+$w*$cossa; + $pt[] = $yc-$h*$sinsa; + $pt[] = $xc; + $pt[] = $yc; + + } + } + else { // sa > 0 && ea < 90 + + $p = array($xc,$yc,$xc,$yc+$z, + $xc+$w*$cossa,$z+$yc-$h*$sinsa, + $xc+$w*$cossa,$yc-$h*$sinsa, + $xc,$yc); + + $pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa); + + for( $a=$rsa; $a < $rea; $a += $step ) { + $pt[] = $xc + $w*cos($a); + $pt[] = $yc - $h*sin($a); + } + + $pt[] = $xc+$w*$cosea; + $pt[] = $yc-$h*$sinea; + $pt[] = $xc; + $pt[] = $yc; + } + + $img->PushColor($fillcolor.":".$shadow); + $img->FilledPolygon($p); + $img->PopColor(); + + $img->PushColor($fillcolor); + $img->FilledPolygon($pt); + $img->PopColor(); + } + + function SetStartAngle($aStart) { + if( $aStart < 0 || $aStart > 360 ) { + JpGraphError::RaiseL(14004);//('Slice start angle must be between 0 and 360 degrees.'); + } + $this->startangle = $aStart; + } + + // Draw a 3D Pie + function Pie3D($aaoption,$img,$data,$colors,$xc,$yc,$d,$angle,$z, + $shadow=0.65,$startangle=0,$edgecolor="",$edgeweight=1) { + + //--------------------------------------------------------------------------- + // As usual the algorithm get more complicated than I originally + // envisioned. I believe that this is as simple as it is possible + // to do it with the features I want. It's a good exercise to start + // thinking on how to do this to convince your self that all this + // is really needed for the general case. + // + // The algorithm two draw 3D pies without "real 3D" is done in + // two steps. + // First imagine the pie cut in half through a thought line between + // 12'a clock and 6'a clock. It now easy to imagine that we can plot + // the individual slices for each half by starting with the topmost + // pie slice and continue down to 6'a clock. + // + // In the algortithm this is done in three principal steps + // Step 1. Do the knife cut to ensure by splitting slices that extends + // over the cut line. This is done by splitting the original slices into + // upto 3 subslices. + // Step 2. Find the top slice for each half + // Step 3. Draw the slices from top to bottom + // + // The thing that slightly complicates this scheme with all the + // angle comparisons below is that we can have an arbitrary start + // angle so we must take into account the different equivalence classes. + // For the same reason we must walk through the angle array in a + // modulo fashion. + // + // Limitations of algorithm: + // * A small exploded slice which crosses the 270 degree point + // will get slightly nagged close to the center due to the fact that + // we print the slices in Z-order and that the slice left part + // get printed first and might get slightly nagged by a larger + // slice on the right side just before the right part of the small + // slice. Not a major problem though. + //--------------------------------------------------------------------------- + + + // Determine the height of the ellippse which gives an + // indication of the inclination angle + $h = ($angle/90.0)*$d; + $sum = 0; + for($i=0; $i<count($data); ++$i ) { + $sum += $data[$i]; + } + + // Special optimization + if( $sum==0 ) return; + + if( $this->labeltype == 2 ) { + $this->adjusted_data = $this->AdjPercentage($data); + } + + // Setup the start + $accsum = 0; + $a = $startangle; + $a = $this->NormAngle($a); + + // + // Step 1 . Split all slices that crosses 90 or 270 + // + $idx=0; + $adjexplode=array(); + $numcolors = count($colors); + for($i=0; $i<count($data); ++$i, ++$idx ) { + $da = $data[$i]/$sum * 360; + + if( empty($this->explode_radius[$i]) ) { + $this->explode_radius[$i]=0; + } + + $expscale=1; + if( $aaoption == 1 ) { + $expscale=2; + } + + $la = $a + $da/2; + $explode = array( $xc + $this->explode_radius[$i]*cos($la*M_PI/180)*$expscale, + $yc - $this->explode_radius[$i]*sin($la*M_PI/180) * ($h/$d) *$expscale ); + $adjexplode[$idx] = $explode; + $labeldata[$i] = array($la,$explode[0],$explode[1]); + $originalangles[$i] = array($a,$a+$da); + + $ne = $this->NormAngle($a+$da); + if( $da <= 180 ) { + // If the slice size is <= 90 it can at maximum cut across + // one boundary (either 90 or 270) where it needs to be split + $split=-1; // no split + if( ($da<=90 && ($a <= 90 && $ne > 90)) || + (($da <= 180 && $da >90) && (($a < 90 || $a >= 270) && $ne > 90)) ) { + $split = 90; + } + elseif( ($da<=90 && ($a <= 270 && $ne > 270)) || + (($da<=180 && $da>90) && ($a >= 90 && $a < 270 && ($a+$da) > 270 )) ) { + $split = 270; + } + if( $split > 0 ) { // split in two + $angles[$idx] = array($a,$split); + $adjcolors[$idx] = $colors[$i % $numcolors]; + $adjexplode[$idx] = $explode; + $angles[++$idx] = array($split,$ne); + $adjcolors[$idx] = $colors[$i % $numcolors]; + $adjexplode[$idx] = $explode; + } + else { // no split + $angles[$idx] = array($a,$ne); + $adjcolors[$idx] = $colors[$i % $numcolors]; + $adjexplode[$idx] = $explode; + } + } + else { + // da>180 + // Slice may, depending on position, cross one or two + // bonudaries + + if( $a < 90 ) $split = 90; + elseif( $a <= 270 ) $split = 270; + else $split = 90; + + $angles[$idx] = array($a,$split); + $adjcolors[$idx] = $colors[$i % $numcolors]; + $adjexplode[$idx] = $explode; + //if( $a+$da > 360-$split ) { + // For slices larger than 270 degrees we might cross + // another boundary as well. This means that we must + // split the slice further. The comparison gets a little + // bit complicated since we must take into accound that + // a pie might have a startangle >0 and hence a slice might + // wrap around the 0 angle. + // Three cases: + // a) Slice starts before 90 and hence gets a split=90, but + // we must also check if we need to split at 270 + // b) Slice starts after 90 but before 270 and slices + // crosses 90 (after a wrap around of 0) + // c) If start is > 270 (hence the firstr split is at 90) + // and the slice is so large that it goes all the way + // around 270. + if( ($a < 90 && ($a+$da > 270)) || ($a > 90 && $a<=270 && ($a+$da>360+90) ) || ($a > 270 && $this->NormAngle($a+$da)>270) ) { + $angles[++$idx] = array($split,360-$split); + $adjcolors[$idx] = $colors[$i % $numcolors]; + $adjexplode[$idx] = $explode; + $angles[++$idx] = array(360-$split,$ne); + $adjcolors[$idx] = $colors[$i % $numcolors]; + $adjexplode[$idx] = $explode; + } + else { + // Just a simple split to the previous decided + // angle. + $angles[++$idx] = array($split,$ne); + $adjcolors[$idx] = $colors[$i % $numcolors]; + $adjexplode[$idx] = $explode; + } + } + $a += $da; + $a = $this->NormAngle($a); + } + + // Total number of slices + $n = count($angles); + + for($i=0; $i<$n; ++$i) { + list($dbgs,$dbge) = $angles[$i]; + } + + // + // Step 2. Find start index (first pie that starts in upper left quadrant) + // + $minval = $angles[0][0]; + $min = 0; + for( $i=0; $i<$n; ++$i ) { + if( $angles[$i][0] < $minval ) { + $minval = $angles[$i][0]; + $min = $i; + } + } + $j = $min; + $cnt = 0; + while( $angles[$j][1] <= 90 ) { + $j++; + if( $j>=$n) { + $j=0; + } + if( $cnt > $n ) { + JpGraphError::RaiseL(14005); + //("Pie3D Internal error (#1). Trying to wrap twice when looking for start index"); + } + ++$cnt; + } + $start = $j; + + // + // Step 3. Print slices in z-order + // + $cnt = 0; + + // First stroke all the slices between 90 and 270 (left half circle) + // counterclockwise + + while( $angles[$j][0] < 270 && $aaoption !== 2 ) { + + list($x,$y) = $adjexplode[$j]; + + $this->Pie3DSlice($img,$x,$y,$d,$h,$angles[$j][0],$angles[$j][1], + $z,$adjcolors[$j],$shadow); + + $last = array($x,$y,$j); + + $j++; + if( $j >= $n ) $j=0; + if( $cnt > $n ) { + JpGraphError::RaiseL(14006); + //("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking."); + } + ++$cnt; + } + + $slice_left = $n-$cnt; + $j=$start-1; + if($j<0) $j=$n-1; + $cnt = 0; + + // The stroke all slices from 90 to -90 (right half circle) + // clockwise + while( $cnt < $slice_left && $aaoption !== 2 ) { + + list($x,$y) = $adjexplode[$j]; + + $this->Pie3DSlice($img,$x,$y,$d,$h,$angles[$j][0],$angles[$j][1], + $z,$adjcolors[$j],$shadow); + $j--; + if( $cnt > $n ) { + JpGraphError::RaiseL(14006); + //("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking."); + } + if($j<0) $j=$n-1; + $cnt++; + } + + // Now do a special thing. Stroke the last slice on the left + // halfcircle one more time. This is needed in the case where + // the slice close to 270 have been exploded. In that case the + // part of the slice close to the center of the pie might be + // slightly nagged. + if( $aaoption !== 2 ) + $this->Pie3DSlice($img,$last[0],$last[1],$d,$h,$angles[$last[2]][0], + $angles[$last[2]][1],$z,$adjcolors[$last[2]],$shadow); + + + if( $aaoption !== 1 ) { + // Now print possible labels and add csim + $this->value->ApplyFont($img); + $margin = $img->GetFontHeight()/2 + $this->value->margin ; + for($i=0; $i < count($data); ++$i ) { + $la = $labeldata[$i][0]; + $x = $labeldata[$i][1] + cos($la*M_PI/180)*($d+$margin)*$this->ilabelposadj; + $y = $labeldata[$i][2] - sin($la*M_PI/180)*($h+$margin)*$this->ilabelposadj; + if( $this->ilabelposadj >= 1.0 ) { + if( $la > 180 && $la < 360 ) $y += $z; + } + if( $this->labeltype == 0 ) { + if( $sum > 0 ) $l = 100*$data[$i]/$sum; + else $l = 0; + } + elseif( $this->labeltype == 1 ) { + $l = $data[$i]; + } + else { + $l = $this->adjusted_data[$i]; + } + if( isset($this->labels[$i]) && is_string($this->labels[$i]) ) { + $l=sprintf($this->labels[$i],$l); + } + + $this->StrokeLabels($l,$img,$labeldata[$i][0]*M_PI/180,$x,$y,$z); + + $this->Add3DSliceToCSIM($i,$labeldata[$i][1],$labeldata[$i][2],$h*2,$d*2,$z, + $originalangles[$i][0],$originalangles[$i][1]); + } + } + + // + // Finally add potential lines in pie + // + + if( $edgecolor=="" || $aaoption !== 0 ) return; + + $accsum = 0; + $a = $startangle; + $a = $this->NormAngle($a); + + $a *= M_PI/180.0; + + $idx=0; + $img->PushColor($edgecolor); + $img->SetLineWeight($edgeweight); + + $fulledge = true; + for($i=0; $i < count($data) && $fulledge; ++$i ) { + if( empty($this->explode_radius[$i]) ) { + $this->explode_radius[$i]=0; + } + if( $this->explode_radius[$i] > 0 ) { + $fulledge = false; + } + } + + + for($i=0; $i < count($data); ++$i, ++$idx ) { + + $da = $data[$i]/$sum * 2*M_PI; + $this->StrokeFullSliceFrame($img,$xc,$yc,$a,$a+$da,$d,$h,$z,$edgecolor, + $this->explode_radius[$i],$fulledge); + $a += $da; + } + $img->PopColor(); + } + + function StrokeFullSliceFrame($img,$xc,$yc,$sa,$ea,$w,$h,$z,$edgecolor,$exploderadius,$fulledge) { + $step = 0.02; + + if( $exploderadius > 0 ) { + $la = ($sa+$ea)/2; + $xc += $exploderadius*cos($la); + $yc -= $exploderadius*sin($la) * ($h/$w) ; + + } + + $p = array($xc,$yc,$xc+$w*cos($sa),$yc-$h*sin($sa)); + + for($a=$sa; $a < $ea; $a += $step ) { + $p[] = $xc + $w*cos($a); + $p[] = $yc - $h*sin($a); + } + + $p[] = $xc+$w*cos($ea); + $p[] = $yc-$h*sin($ea); + $p[] = $xc; + $p[] = $yc; + + $img->SetColor($edgecolor); + $img->Polygon($p); + + // Unfortunately we can't really draw the full edge around the whole of + // of the slice if any of the slices are exploded. The reason is that + // this algorithm is to simply. There are cases where the edges will + // "overwrite" other slices when they have been exploded. + // Doing the full, proper 3D hidden lines stiff is actually quite + // tricky. So for exploded pies we only draw the top edge. Not perfect + // but the "real" solution is much more complicated. + if( $fulledge && !( $sa > 0 && $sa < M_PI && $ea < M_PI) ) { + + if($sa < M_PI && $ea > M_PI) { + $sa = M_PI; + } + + if($sa < 2*M_PI && (($ea >= 2*M_PI) || ($ea > 0 && $ea < $sa ) ) ) { + $ea = 2*M_PI; + } + + if( $sa >= M_PI && $ea <= 2*M_PI ) { + $p = array($xc + $w*cos($sa),$yc - $h*sin($sa), + $xc + $w*cos($sa),$z + $yc - $h*sin($sa)); + + for($a=$sa+$step; $a < $ea; $a += $step ) { + $p[] = $xc + $w*cos($a); + $p[] = $z + $yc - $h*sin($a); + } + $p[] = $xc + $w*cos($ea); + $p[] = $z + $yc - $h*sin($ea); + $p[] = $xc + $w*cos($ea); + $p[] = $yc - $h*sin($ea); + $img->SetColor($edgecolor); + $img->Polygon($p); + } + } + } + + function Stroke($img,$aaoption=0) { + $n = count($this->data); + + // If user hasn't set the colors use the theme array + if( $this->setslicecolors==null ) { + $colors = array_keys($img->rgb->rgb_table); + sort($colors); + $idx_a=$this->themearr[$this->theme]; + $ca = array(); + $m = count($idx_a); + for($i=0; $i < $m; ++$i) { + $ca[$i] = $colors[$idx_a[$i]]; + } + $ca = array_reverse(array_slice($ca,0,$n)); + } + else { + $ca = $this->setslicecolors; + } + + + if( $this->posx <= 1 && $this->posx > 0 ) { + $xc = round($this->posx*$img->width); + } + else { + $xc = $this->posx ; + } + + if( $this->posy <= 1 && $this->posy > 0 ) { + $yc = round($this->posy*$img->height); + } + else { + $yc = $this->posy ; + } + + if( $this->radius <= 1 ) { + $width = floor($this->radius*min($img->width,$img->height)); + // Make sure that the pie doesn't overflow the image border + // The 0.9 factor is simply an extra margin to leave some space + // between the pie an the border of the image. + $width = min($width,min($xc*0.9,($yc*90/$this->angle-$width/4)*0.9)); + } + else { + $width = $this->radius * ($aaoption === 1 ? 2 : 1 ) ; + } + + // Add a sanity check for width + if( $width < 1 ) { + JpGraphError::RaiseL(14007);//("Width for 3D Pie is 0. Specify a size > 0"); + } + + // Establish a thickness. By default the thickness is a fifth of the + // pie slice width (=pie radius) but since the perspective depends + // on the inclination angle we use some heuristics to make the edge + // slightly thicker the less the angle. + + // Has user specified an absolute thickness? In that case use + // that instead + + if( $this->iThickness ) { + $thick = $this->iThickness; + $thick *= ($aaoption === 1 ? 2 : 1 ); + } + else { + $thick = $width/12; + } + $a = $this->angle; + + if( $a <= 30 ) $thick *= 1.6; + elseif( $a <= 40 ) $thick *= 1.4; + elseif( $a <= 50 ) $thick *= 1.2; + elseif( $a <= 60 ) $thick *= 1.0; + elseif( $a <= 70 ) $thick *= 0.8; + elseif( $a <= 80 ) $thick *= 0.7; + else $thick *= 0.6; + + $thick = floor($thick); + + if( $this->explode_all ) { + for($i=0; $i < $n; ++$i) + $this->explode_radius[$i]=$this->explode_r; + } + + $this->Pie3D($aaoption,$img,$this->data, $ca, $xc, $yc, $width, $this->angle, + $thick, 0.65, $this->startangle, $this->edgecolor, $this->edgeweight); + + // Adjust title position + if( $aaoption != 1 ) { + $this->title->SetPos($xc,$yc-$this->title->GetFontHeight($img)-$width/2-$this->title->margin, "center","bottom"); + $this->title->Stroke($img); + } + } + + //--------------- + // PRIVATE METHODS + + // Position the labels of each slice + function StrokeLabels($label,$img,$a,$xp,$yp,$z) { + $this->value->halign="left"; + $this->value->valign="top"; + + // Position the axis title. + // dx, dy is the offset from the top left corner of the bounding box that sorrounds the text + // that intersects with the extension of the corresponding axis. The code looks a little + // bit messy but this is really the only way of having a reasonable position of the + // axis titles. + $this->value->ApplyFont($img); + $h=$img->GetTextHeight($label); + // For numeric values the format of the display value + // must be taken into account + if( is_numeric($label) ) { + if( $label >= 0 ) { + $w=$img->GetTextWidth(sprintf($this->value->format,$label)); + } + else { + $w=$img->GetTextWidth(sprintf($this->value->negformat,$label)); + } + } + else { + $w=$img->GetTextWidth($label); + } + + while( $a > 2*M_PI ) { + $a -= 2*M_PI; + } + + if( $a>=7*M_PI/4 || $a <= M_PI/4 ) $dx=0; + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dx=($a-M_PI/4)*2/M_PI; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dx=1; + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dx=(1-($a-M_PI*5/4)*2/M_PI); + + if( $a>=7*M_PI/4 ) $dy=(($a-M_PI)-3*M_PI/4)*2/M_PI; + if( $a<=M_PI/4 ) $dy=(1-$a*2/M_PI); + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dy=1; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dy=(1-($a-3*M_PI/4)*2/M_PI); + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dy=0; + + $x = round($xp-$dx*$w); + $y = round($yp-$dy*$h); + + // Mark anchor point for debugging + /* + $img->SetColor('red'); + $img->Line($xp-10,$yp,$xp+10,$yp); + $img->Line($xp,$yp-10,$xp,$yp+10); + */ + + $oldmargin = $this->value->margin; + $this->value->margin=0; + $this->value->Stroke($img,$label,$x,$y); + $this->value->margin=$oldmargin; + + } +} // Class + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_plotband.php b/html/jpgraph/jpgraph_plotband.php new file mode 100644 index 0000000..b7aef75 --- /dev/null +++ b/html/jpgraph/jpgraph_plotband.php @@ -0,0 +1,635 @@ +<?php +//======================================================================= +// File: JPGRAPH_PLOTBAND.PHP +// Description: PHP4 Graph Plotting library. Extension module. +// Created: 2004-02-18 +// Ver: $Id: jpgraph_plotband.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +// Constants for types of static bands in plot area +define("BAND_RDIAG",1); // Right diagonal lines +define("BAND_LDIAG",2); // Left diagonal lines +define("BAND_SOLID",3); // Solid one color +define("BAND_VLINE",4); // Vertical lines +define("BAND_HLINE",5); // Horizontal lines +define("BAND_3DPLANE",6); // "3D" Plane +define("BAND_HVCROSS",7); // Vertical/Hor crosses +define("BAND_DIAGCROSS",8); // Diagonal crosses + + +// Utility class to hold coordinates for a rectangle +class Rectangle { + public $x,$y,$w,$h; + public $xe, $ye; + function __construct($aX,$aY,$aWidth,$aHeight) { + $this->x=$aX; + $this->y=$aY; + $this->w=$aWidth; + $this->h=$aHeight; + $this->xe=$aX+$aWidth-1; + $this->ye=$aY+$aHeight-1; + } +} + +//===================================================================== +// Class RectPattern +// Base class for pattern hierarchi that is used to display patterned +// bands on the graph. Any subclass that doesn't override Stroke() +// must at least implement method DoPattern($aImg) which is responsible +// for drawing the pattern onto the graph. +//===================================================================== +class RectPattern { + protected $color; + protected $weight; + protected $rect=null; + protected $doframe=true; + protected $linespacing; // Line spacing in pixels + protected $iBackgroundColor=-1; // Default is no background fill + + function __construct($aColor,$aWeight=1) { + $this->color = $aColor; + $this->weight = $aWeight; + } + + function SetBackground($aBackgroundColor) { + $this->iBackgroundColor=$aBackgroundColor; + } + + function SetPos($aRect) { + $this->rect = $aRect; + } + + function ShowFrame($aShow=true) { + $this->doframe=$aShow; + } + + function SetDensity($aDens) { + if( $aDens < 1 || $aDens > 100 ) + JpGraphError::RaiseL(16001,$aDens); + //(" Desity for pattern must be between 1 and 100. (You tried $aDens)"); + // 1% corresponds to linespacing=50 + // 100 % corresponds to linespacing 1 + $this->linespacing = floor(((100-$aDens)/100.0)*50)+1; + + } + + function Stroke($aImg) { + if( $this->rect == null ) + JpGraphError::RaiseL(16002); + //(" No positions specified for pattern."); + + if( !(is_numeric($this->iBackgroundColor) && $this->iBackgroundColor==-1) ) { + $aImg->SetColor($this->iBackgroundColor); + $aImg->FilledRectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye); + } + + $aImg->SetColor($this->color); + $aImg->SetLineWeight($this->weight); + + // Virtual function implemented by subclass + $this->DoPattern($aImg); + + // Frame around the pattern area + if( $this->doframe ) + $aImg->Rectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye); + } + +} + + +//===================================================================== +// Class RectPatternSolid +// Implements a solid band +//===================================================================== +class RectPatternSolid extends RectPattern { + + function __construct($aColor="black",$aWeight=1) { + parent::__construct($aColor,$aWeight); + } + + function DoPattern($aImg) { + $aImg->SetColor($this->color); + $aImg->FilledRectangle($this->rect->x,$this->rect->y, + $this->rect->xe,$this->rect->ye); + } +} + +//===================================================================== +// Class RectPatternHor +// Implements horizontal line pattern +//===================================================================== +class RectPatternHor extends RectPattern { + + function __construct($aColor="black",$aWeight=1,$aLineSpacing=7) { + parent::__construct($aColor,$aWeight); + $this->linespacing = $aLineSpacing; + } + + function DoPattern($aImg) { + $x0 = $this->rect->x; + $x1 = $this->rect->xe; + $y = $this->rect->y; + while( $y < $this->rect->ye ) { + $aImg->Line($x0,$y,$x1,$y); + $y += $this->linespacing; + } + } +} + +//===================================================================== +// Class RectPatternVert +// Implements vertical line pattern +//===================================================================== +class RectPatternVert extends RectPattern { + + function __construct($aColor="black",$aWeight=1,$aLineSpacing=7) { + parent::__construct($aColor,$aWeight); + $this->linespacing = $aLineSpacing; + } + + //-------------------- + // Private methods + // + function DoPattern($aImg) { + $x = $this->rect->x; + $y0 = $this->rect->y; + $y1 = $this->rect->ye; + while( $x < $this->rect->xe ) { + $aImg->Line($x,$y0,$x,$y1); + $x += $this->linespacing; + } + } +} + + +//===================================================================== +// Class RectPatternRDiag +// Implements right diagonal pattern +//===================================================================== +class RectPatternRDiag extends RectPattern { + + function __construct($aColor="black",$aWeight=1,$aLineSpacing=12) { + parent::__construct($aColor,$aWeight); + $this->linespacing = $aLineSpacing; + } + + function DoPattern($aImg) { + // -------------------- + // | / / / / /| + // |/ / / / / | + // | / / / / | + // -------------------- + $xe = $this->rect->xe; + $ye = $this->rect->ye; + $x0 = $this->rect->x + round($this->linespacing/2); + $y0 = $this->rect->y; + $x1 = $this->rect->x; + $y1 = $this->rect->y + round($this->linespacing/2); + + while($x0<=$xe && $y1<=$ye) { + $aImg->Line($x0,$y0,$x1,$y1); + $x0 += $this->linespacing; + $y1 += $this->linespacing; + } + + if( $xe-$x1 > $ye-$y0 ) { + // Width larger than height + $x1 = $this->rect->x + ($y1-$ye); + $y1 = $ye; + $y0 = $this->rect->y; + while( $x0 <= $xe ) { + $aImg->Line($x0,$y0,$x1,$y1); + $x0 += $this->linespacing; + $x1 += $this->linespacing; + } + + $y0=$this->rect->y + ($x0-$xe); + $x0=$xe; + } + else { + // Height larger than width + $diff = $x0-$xe; + $y0 = $diff+$this->rect->y; + $x0 = $xe; + $x1 = $this->rect->x; + while( $y1 <= $ye ) { + $aImg->Line($x0,$y0,$x1,$y1); + $y1 += $this->linespacing; + $y0 += $this->linespacing; + } + + $diff = $y1-$ye; + $y1 = $ye; + $x1 = $diff + $this->rect->x; + } + + while( $y0 <= $ye ) { + $aImg->Line($x0,$y0,$x1,$y1); + $y0 += $this->linespacing; + $x1 += $this->linespacing; + } + } +} + +//===================================================================== +// Class RectPatternLDiag +// Implements left diagonal pattern +//===================================================================== +class RectPatternLDiag extends RectPattern { + + function __construct($aColor="black",$aWeight=1,$aLineSpacing=12) { + $this->linespacing = $aLineSpacing; + parent::__construct($aColor,$aWeight); + } + + function DoPattern($aImg) { + // -------------------- + // |\ \ \ \ \ | + // | \ \ \ \ \| + // | \ \ \ \ | + // |------------------| + $xe = $this->rect->xe; + $ye = $this->rect->ye; + $x0 = $this->rect->x + round($this->linespacing/2); + $y0 = $this->rect->ye; + $x1 = $this->rect->x; + $y1 = $this->rect->ye - round($this->linespacing/2); + + while($x0<=$xe && $y1>=$this->rect->y) { + $aImg->Line($x0,$y0,$x1,$y1); + $x0 += $this->linespacing; + $y1 -= $this->linespacing; + } + if( $xe-$x1 > $ye-$this->rect->y ) { + // Width larger than height + $x1 = $this->rect->x + ($this->rect->y-$y1); + $y0=$ye; $y1=$this->rect->y; + while( $x0 <= $xe ) { + $aImg->Line($x0,$y0,$x1,$y1); + $x0 += $this->linespacing; + $x1 += $this->linespacing; + } + + $y0=$this->rect->ye - ($x0-$xe); + $x0=$xe; + } + else { + // Height larger than width + $diff = $x0-$xe; + $y0 = $ye-$diff; + $x0 = $xe; + while( $y1 >= $this->rect->y ) { + $aImg->Line($x0,$y0,$x1,$y1); + $y0 -= $this->linespacing; + $y1 -= $this->linespacing; + } + $diff = $this->rect->y - $y1; + $x1 = $this->rect->x + $diff; + $y1 = $this->rect->y; + } + while( $y0 >= $this->rect->y ) { + $aImg->Line($x0,$y0,$x1,$y1); + $y0 -= $this->linespacing; + $x1 += $this->linespacing; + } + } +} + +//===================================================================== +// Class RectPattern3DPlane +// Implements "3D" plane pattern +//===================================================================== +class RectPattern3DPlane extends RectPattern { + private $alpha=50; // Parameter that specifies the distance + // to "simulated" horizon in pixel from the + // top of the band. Specifies how fast the lines + // converge. + + function __construct($aColor="black",$aWeight=1) { + parent::__construct($aColor,$aWeight); + $this->SetDensity(10); // Slightly larger default + } + + function SetHorizon($aHorizon) { + $this->alpha=$aHorizon; + } + + function DoPattern($aImg) { + // "Fake" a nice 3D grid-effect. + $x0 = $this->rect->x + $this->rect->w/2; + $y0 = $this->rect->y; + $x1 = $x0; + $y1 = $this->rect->ye; + $x0_right = $x0; + $x1_right = $x1; + + // BTW "apa" means monkey in Swedish but is really a shortform for + // "alpha+a" which was the labels I used on paper when I derived the + // geometric to get the 3D perspective right. + // $apa is the height of the bounding rectangle plus the distance to the + // artifical horizon (alpha) + $apa = $this->rect->h + $this->alpha; + + // Three cases and three loops + // 1) The endpoint of the line ends on the bottom line + // 2) The endpoint ends on the side + // 3) Horizontal lines + + // Endpoint falls on bottom line + $middle=$this->rect->x + $this->rect->w/2; + $dist=$this->linespacing; + $factor=$this->alpha /($apa); + while($x1>$this->rect->x) { + $aImg->Line($x0,$y0,$x1,$y1); + $aImg->Line($x0_right,$y0,$x1_right,$y1); + $x1 = $middle - $dist; + $x0 = $middle - $dist * $factor; + $x1_right = $middle + $dist; + $x0_right = $middle + $dist * $factor; + $dist += $this->linespacing; + } + + // Endpoint falls on sides + $dist -= $this->linespacing; + $d=$this->rect->w/2; + $c = $apa - $d*$apa/$dist; + while( $x0>$this->rect->x ) { + $aImg->Line($x0,$y0,$this->rect->x,$this->rect->ye-$c); + $aImg->Line($x0_right,$y0,$this->rect->xe,$this->rect->ye-$c); + $dist += $this->linespacing; + $x0 = $middle - $dist * $factor; + $x1 = $middle - $dist; + $x0_right = $middle + $dist * $factor; + $c = $apa - $d*$apa/$dist; + } + + // Horizontal lines + // They need some serious consideration since they are a function + // of perspective depth (alpha) and density (linespacing) + $x0=$this->rect->x; + $x1=$this->rect->xe; + $y=$this->rect->ye; + + // The first line is drawn directly. Makes the loop below slightly + // more readable. + $aImg->Line($x0,$y,$x1,$y); + $hls = $this->linespacing; + + // A correction factor for vertical "brick" line spacing to account for + // a) the difference in number of pixels hor vs vert + // b) visual apperance to make the first layer of "bricks" look more + // square. + $vls = $this->linespacing*0.6; + + $ds = $hls*($apa-$vls)/$apa; + // Get the slope for the "perspective line" going from bottom right + // corner to top left corner of the "first" brick. + + // Uncomment the following lines if you want to get a visual understanding + // of what this helpline does. BTW this mimics the way you would get the + // perspective right when drawing on paper. + /* + $x0 = $middle; + $y0 = $this->rect->ye; + $len=floor(($this->rect->ye-$this->rect->y)/$vls); + $x1 = $middle+round($len*$ds); + $y1 = $this->rect->ye-$len*$vls; + $aImg->PushColor("red"); + $aImg->Line($x0,$y0,$x1,$y1); + $aImg->PopColor(); + */ + + $y -= $vls; + $k=($this->rect->ye-($this->rect->ye-$vls))/($middle-($middle-$ds)); + $dist = $hls; + while( $y>$this->rect->y ) { + $aImg->Line($this->rect->x,$y,$this->rect->xe,$y); + $adj = $k*$dist/(1+$dist*$k/$apa); + if( $adj < 2 ) $adj=1; + $y = $this->rect->ye - round($adj); + $dist += $hls; + } + } +} + +//===================================================================== +// Class RectPatternCross +// Vert/Hor crosses +//===================================================================== +class RectPatternCross extends RectPattern { + private $vert=null; + private $hor=null; + function __construct($aColor="black",$aWeight=1) { + parent::__construct($aColor,$aWeight); + $this->vert = new RectPatternVert($aColor,$aWeight); + $this->hor = new RectPatternHor($aColor,$aWeight); + } + + function SetOrder($aDepth) { + $this->vert->SetOrder($aDepth); + $this->hor->SetOrder($aDepth); + } + + function SetPos($aRect) { + parent::SetPos($aRect); + $this->vert->SetPos($aRect); + $this->hor->SetPos($aRect); + } + + function SetDensity($aDens) { + $this->vert->SetDensity($aDens); + $this->hor->SetDensity($aDens); + } + + function DoPattern($aImg) { + $this->vert->DoPattern($aImg); + $this->hor->DoPattern($aImg); + } +} + +//===================================================================== +// Class RectPatternDiagCross +// Vert/Hor crosses +//===================================================================== + +class RectPatternDiagCross extends RectPattern { + private $left=null; + private $right=null; + function __construct($aColor="black",$aWeight=1) { + parent::__construct($aColor,$aWeight); + $this->right = new RectPatternRDiag($aColor,$aWeight); + $this->left = new RectPatternLDiag($aColor,$aWeight); + } + + function SetOrder($aDepth) { + $this->left->SetOrder($aDepth); + $this->right->SetOrder($aDepth); + } + + function SetPos($aRect) { + parent::SetPos($aRect); + $this->left->SetPos($aRect); + $this->right->SetPos($aRect); + } + + function SetDensity($aDens) { + $this->left->SetDensity($aDens); + $this->right->SetDensity($aDens); + } + + function DoPattern($aImg) { + $this->left->DoPattern($aImg); + $this->right->DoPattern($aImg); + } + +} + +//===================================================================== +// Class RectPatternFactory +// Factory class for rectangular pattern +//===================================================================== +class RectPatternFactory { + function __construct() { + // Empty + } + function Create($aPattern,$aColor,$aWeight=1) { + switch($aPattern) { + case BAND_RDIAG: + $obj = new RectPatternRDiag($aColor,$aWeight); + break; + case BAND_LDIAG: + $obj = new RectPatternLDiag($aColor,$aWeight); + break; + case BAND_SOLID: + $obj = new RectPatternSolid($aColor,$aWeight); + break; + case BAND_VLINE: + $obj = new RectPatternVert($aColor,$aWeight); + break; + case BAND_HLINE: + $obj = new RectPatternHor($aColor,$aWeight); + break; + case BAND_3DPLANE: + $obj = new RectPattern3DPlane($aColor,$aWeight); + break; + case BAND_HVCROSS: + $obj = new RectPatternCross($aColor,$aWeight); + break; + case BAND_DIAGCROSS: + $obj = new RectPatternDiagCross($aColor,$aWeight); + break; + default: + JpGraphError::RaiseL(16003,$aPattern); + //(" Unknown pattern specification ($aPattern)"); + } + return $obj; + } +} + + +//===================================================================== +// Class PlotBand +// Factory class which is used by the client. +// It is responsible for factoring the corresponding pattern +// concrete class. +//===================================================================== +class PlotBand { + public $depth; // Determine if band should be over or under the plots + private $prect=null; + private $dir, $min, $max; + + function __construct($aDir,$aPattern,$aMin,$aMax,$aColor="black",$aWeight=1,$aDepth=DEPTH_BACK) { + $f = new RectPatternFactory(); + $this->prect = $f->Create($aPattern,$aColor,$aWeight); + if( is_numeric($aMin) && is_numeric($aMax) && ($aMin > $aMax) ) + JpGraphError::RaiseL(16004); + //('Min value for plotband is larger than specified max value. Please correct.'); + $this->dir = $aDir; + $this->min = $aMin; + $this->max = $aMax; + $this->depth=$aDepth; + } + + // Set position. aRect contains absolute image coordinates + function SetPos($aRect) { + assert( $this->prect != null ) ; + $this->prect->SetPos($aRect); + } + + function ShowFrame($aFlag=true) { + $this->prect->ShowFrame($aFlag); + } + + // Set z-order. In front of pplot or in the back + function SetOrder($aDepth) { + $this->depth=$aDepth; + } + + function SetDensity($aDens) { + $this->prect->SetDensity($aDens); + } + + function GetDir() { + return $this->dir; + } + + function GetMin() { + return $this->min; + } + + function GetMax() { + return $this->max; + } + + function PreStrokeAdjust($aGraph) { + // Nothing to do + } + + // Display band + function Stroke($aImg,$aXScale,$aYScale) { + assert( $this->prect != null ) ; + if( $this->dir == HORIZONTAL ) { + if( $this->min === 'min' ) $this->min = $aYScale->GetMinVal(); + if( $this->max === 'max' ) $this->max = $aYScale->GetMaxVal(); + + // Only draw the bar if it actually appears in the range + if ($this->min < $aYScale->GetMaxVal() && $this->max > $aYScale->GetMinVal()) { + + // Trucate to limit of axis + $this->min = max($this->min, $aYScale->GetMinVal()); + $this->max = min($this->max, $aYScale->GetMaxVal()); + + $x=$aXScale->scale_abs[0]; + $y=$aYScale->Translate($this->max); + $width=$aXScale->scale_abs[1]-$aXScale->scale_abs[0]+1; + $height=abs($y-$aYScale->Translate($this->min))+1; + $this->prect->SetPos(new Rectangle($x,$y,$width,$height)); + $this->prect->Stroke($aImg); + } + } + else { // VERTICAL + if( $this->min === 'min' ) $this->min = $aXScale->GetMinVal(); + if( $this->max === 'max' ) $this->max = $aXScale->GetMaxVal(); + + // Only draw the bar if it actually appears in the range + if ($this->min < $aXScale->GetMaxVal() && $this->max > $aXScale->GetMinVal()) { + + // Trucate to limit of axis + $this->min = max($this->min, $aXScale->GetMinVal()); + $this->max = min($this->max, $aXScale->GetMaxVal()); + + $y=$aYScale->scale_abs[1]; + $x=$aXScale->Translate($this->min); + $height=abs($aYScale->scale_abs[1]-$aYScale->scale_abs[0]); + $width=abs($x-$aXScale->Translate($this->max)); + $this->prect->SetPos(new Rectangle($x,$y,$width,$height)); + $this->prect->Stroke($aImg); + } + } + } +} + + +?> diff --git a/html/jpgraph/jpgraph_plotline.php b/html/jpgraph/jpgraph_plotline.php new file mode 100644 index 0000000..4ee0f56 --- /dev/null +++ b/html/jpgraph/jpgraph_plotline.php @@ -0,0 +1,142 @@ +<?php +/*======================================================================= + // File: JPGRAPH_PLOTLINE.PHP + // Description: PlotLine extension for JpGraph + // Created: 2009-03-24 + // Ver: $Id: jpgraph_plotline.php 1931 2010-03-22 15:05:48Z ljp $ + // + // CLASS PlotLine + // Data container class to hold properties for a static + // line that is drawn directly in the plot area. + // Useful to add static borders inside a plot to show for example set-values + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +class PlotLine { + public $scaleposition, $direction=-1; + protected $weight=1; + protected $color = 'black'; + private $legend='',$hidelegend=false, $legendcsimtarget='', $legendcsimalt='',$legendcsimwintarget=''; + private $iLineStyle='solid'; + public $numpoints=0; // Needed since the framework expects this property + + function __construct($aDir=HORIZONTAL,$aPos=0,$aColor='black',$aWeight=1) { + $this->direction = $aDir; + $this->color=$aColor; + $this->weight=$aWeight; + $this->scaleposition=$aPos; + } + + function SetLegend($aLegend,$aCSIM='',$aCSIMAlt='',$aCSIMWinTarget='') { + $this->legend = $aLegend; + $this->legendcsimtarget = $aCSIM; + $this->legendcsimwintarget = $aCSIMWinTarget; + $this->legendcsimalt = $aCSIMAlt; + } + + function HideLegend($f=true) { + $this->hidelegend = $f; + } + + function SetPosition($aScalePosition) { + $this->scaleposition=$aScalePosition; + } + + function SetDirection($aDir) { + $this->direction = $aDir; + } + + function SetColor($aColor) { + $this->color=$aColor; + } + + function SetWeight($aWeight) { + $this->weight=$aWeight; + } + + function SetLineStyle($aStyle) { + $this->iLineStyle = $aStyle; + } + + function GetCSIMAreas() { + return ''; + } + + //--------------- + // PRIVATE METHODS + + function DoLegend($graph) { + if( !$this->hidelegend ) $this->Legend($graph); + } + + // Framework function the chance for each plot class to set a legend + function Legend($aGraph) { + if( $this->legend != '' ) { + $dummyPlotMark = new PlotMark(); + $lineStyle = 1; + $aGraph->legend->Add($this->legend,$this->color,$dummyPlotMark,$lineStyle, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + } + + function PreStrokeAdjust($aGraph) { + // Nothing to do + } + + // Called by framework to allow the object to draw + // optional information in the margin area + function StrokeMargin($aImg) { + // Nothing to do + } + + // Framework function to allow the object to adjust the scale + function PrescaleSetup($aGraph) { + // Nothing to do + } + + function Min() { + return array(null,null); + } + + function Max() { + return array(null,null); + } + + function _Stroke($aImg,$aMinX,$aMinY,$aMaxX,$aMaxY,$aXPos,$aYPos) { + $aImg->SetColor($this->color); + $aImg->SetLineWeight($this->weight); + $oldStyle = $aImg->SetLineStyle($this->iLineStyle); + if( $this->direction == VERTICAL ) { + $ymin_abs = $aMinY; + $ymax_abs = $aMaxY; + $xpos_abs = $aXPos; + $aImg->StyleLine($xpos_abs, $ymin_abs, $xpos_abs, $ymax_abs); + } + elseif( $this->direction == HORIZONTAL ) { + $xmin_abs = $aMinX; + $xmax_abs = $aMaxX; + $ypos_abs = $aYPos; + $aImg->StyleLine($xmin_abs, $ypos_abs, $xmax_abs, $ypos_abs); + } + else { + JpGraphError::RaiseL(25125);//(" Illegal direction for static line"); + } + $aImg->SetLineStyle($oldStyle); + } + + function Stroke($aImg,$aXScale,$aYScale) { + $this->_Stroke($aImg, + $aImg->left_margin, + $aYScale->Translate($aYScale->GetMinVal()), + $aImg->width-$aImg->right_margin, + $aYScale->Translate($aYScale->GetMaxVal()), + $aXScale->Translate($this->scaleposition), + $aYScale->Translate($this->scaleposition) + ); + } +} + + +?> diff --git a/html/jpgraph/jpgraph_plotmark.inc.php b/html/jpgraph/jpgraph_plotmark.inc.php new file mode 100644 index 0000000..88af849 --- /dev/null +++ b/html/jpgraph/jpgraph_plotmark.inc.php @@ -0,0 +1,504 @@ +<?php +//======================================================================= +// File: JPGRAPH_PLOTMARK.PHP +// Description: Class file. Handles plotmarks +// Created: 2003-03-21 +// Ver: $Id: jpgraph_plotmark.inc.php 1106 2009-02-22 20:16:35Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +//=================================================== +// CLASS PlotMark +// Description: Handles the plot marks in graphs +//=================================================== + +class PlotMark { + public $title, $show=true; + public $type,$weight=1; + public $iFormatCallback="", $iFormatCallback2=""; + public $fill_color="blue"; + public $color="black", $width=4; + private $yvalue,$xvalue='',$csimtarget,$csimwintarget='',$csimalt,$csimareas; + private $markimg='',$iScale=1.0; + private $oldfilename='',$iFileName=''; + private $imgdata_balls = null; + private $imgdata_diamonds = null; + private $imgdata_squares = null; + private $imgdata_bevels = null; + private $imgdata_stars = null; + private $imgdata_pushpins = null; + + //-------------- + // CONSTRUCTOR + function __construct() { + $this->title = new Text(); + $this->title->Hide(); + $this->csimareas = ''; + $this->type=-1; + } + //--------------- + // PUBLIC METHODS + function SetType($aType,$aFileName='',$aScale=1.0) { + $this->type = $aType; + if( $aType == MARK_IMG && $aFileName=='' ) { + JpGraphError::RaiseL(23003);//('A filename must be specified if you set the mark type to MARK_IMG.'); + } + $this->iFileName = $aFileName; + $this->iScale = $aScale; + } + + function SetCallback($aFunc) { + $this->iFormatCallback = $aFunc; + } + + function SetCallbackYX($aFunc) { + $this->iFormatCallback2 = $aFunc; + } + + function GetType() { + return $this->type; + } + + function SetColor($aColor) { + $this->color=$aColor; + } + + function SetFillColor($aFillColor) { + $this->fill_color = $aFillColor; + } + + function SetWeight($aWeight) { + $this->weight = $aWeight; + } + + // Synonym for SetWidth() + function SetSize($aWidth) { + $this->width=$aWidth; + } + + function SetWidth($aWidth) { + $this->width=$aWidth; + } + + function SetDefaultWidth() { + switch( $this->type ) { + case MARK_CIRCLE: + case MARK_FILLEDCIRCLE: + $this->width=4; + break; + default: + $this->width=7; + } + } + + function GetWidth() { + return $this->width; + } + + function Hide($aHide=true) { + $this->show = !$aHide; + } + + function Show($aShow=true) { + $this->show = $aShow; + } + + function SetCSIMAltVal($aY,$aX='') { + $this->yvalue=$aY; + $this->xvalue=$aX; + } + + function SetCSIMTarget($aTarget,$aWinTarget='') { + $this->csimtarget=$aTarget; + $this->csimwintarget=$aWinTarget; + } + + function SetCSIMAlt($aAlt) { + $this->csimalt=$aAlt; + } + + function GetCSIMAreas(){ + return $this->csimareas; + } + + function AddCSIMPoly($aPts) { + $coords = round($aPts[0]).", ".round($aPts[1]); + $n = count($aPts)/2; + for( $i=1; $i < $n; ++$i){ + $coords .= ", ".round($aPts[2*$i]).", ".round($aPts[2*$i+1]); + } + $this->csimareas=""; + if( !empty($this->csimtarget) ) { + $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($this->csimtarget)."\""; + + if( !empty($this->csimwintarget) ) { + $this->csimareas .= " target=\"".$this->csimwintarget."\" "; + } + + if( !empty($this->csimalt) ) { + $tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue); + $this->csimareas .= " title=\"$tmp\" alt=\"$tmp\""; + } + $this->csimareas .= " />\n"; + } + } + + function AddCSIMCircle($x,$y,$r) { + $x = round($x); $y=round($y); $r=round($r); + $this->csimareas=""; + if( !empty($this->csimtarget) ) { + $this->csimareas .= "<area shape=\"circle\" coords=\"$x,$y,$r\" href=\"".htmlentities($this->csimtarget)."\""; + + if( !empty($this->csimwintarget) ) { + $this->csimareas .= " target=\"".$this->csimwintarget."\" "; + } + + if( !empty($this->csimalt) ) { + $tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue); + $this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimareas .= " />\n"; + } + } + + function Stroke($img,$x,$y) { + if( !$this->show ) return; + + if( $this->iFormatCallback != '' || $this->iFormatCallback2 != '' ) { + + if( $this->iFormatCallback != '' ) { + $f = $this->iFormatCallback; + list($width,$color,$fcolor) = call_user_func($f,$this->yvalue); + $filename = $this->iFileName; + $imgscale = $this->iScale; + } + else { + $f = $this->iFormatCallback2; + list($width,$color,$fcolor,$filename,$imgscale) = call_user_func($f,$this->yvalue,$this->xvalue); + if( $filename=="" ) $filename = $this->iFileName; + if( $imgscale=="" ) $imgscale = $this->iScale; + } + + if( $width=="" ) $width = $this->width; + if( $color=="" ) $color = $this->color; + if( $fcolor=="" ) $fcolor = $this->fill_color; + + } + else { + $fcolor = $this->fill_color; + $color = $this->color; + $width = $this->width; + $filename = $this->iFileName; + $imgscale = $this->iScale; + } + + if( $this->type == MARK_IMG || + ($this->type >= MARK_FLAG1 && $this->type <= MARK_FLAG4 ) || + $this->type >= MARK_IMG_PUSHPIN ) { + + // Note: For the builtin images we use the "filename" parameter + // to denote the color + $anchor_x = 0.5; + $anchor_y = 0.5; + switch( $this->type ) { + case MARK_FLAG1: + case MARK_FLAG2: + case MARK_FLAG3: + case MARK_FLAG4: + $this->markimg = FlagCache::GetFlagImgByName($this->type-MARK_FLAG1+1,$filename); + break; + + case MARK_IMG : + // Load an image and use that as a marker + // Small optimization, if we have already read an image don't + // waste time reading it again. + if( $this->markimg == '' || !($this->oldfilename === $filename) ) { + $this->markimg = Graph::LoadBkgImage('',$filename); + $this->oldfilename = $filename ; + } + break; + + case MARK_IMG_PUSHPIN: + case MARK_IMG_SPUSHPIN: + case MARK_IMG_LPUSHPIN: + if( $this->imgdata_pushpins == null ) { + require_once 'imgdata_pushpins.inc.php'; + $this->imgdata_pushpins = new ImgData_PushPins(); + } + $this->markimg = $this->imgdata_pushpins->GetImg($this->type,$filename); + list($anchor_x,$anchor_y) = $this->imgdata_pushpins->GetAnchor(); + break; + + case MARK_IMG_SQUARE: + if( $this->imgdata_squares == null ) { + require_once 'imgdata_squares.inc.php'; + $this->imgdata_squares = new ImgData_Squares(); + } + $this->markimg = $this->imgdata_squares->GetImg($this->type,$filename); + list($anchor_x,$anchor_y) = $this->imgdata_squares->GetAnchor(); + break; + + case MARK_IMG_STAR: + if( $this->imgdata_stars == null ) { + require_once 'imgdata_stars.inc.php'; + $this->imgdata_stars = new ImgData_Stars(); + } + $this->markimg = $this->imgdata_stars->GetImg($this->type,$filename); + list($anchor_x,$anchor_y) = $this->imgdata_stars->GetAnchor(); + break; + + case MARK_IMG_BEVEL: + if( $this->imgdata_bevels == null ) { + require_once 'imgdata_bevels.inc.php'; + $this->imgdata_bevels = new ImgData_Bevels(); + } + $this->markimg = $this->imgdata_bevels->GetImg($this->type,$filename); + list($anchor_x,$anchor_y) = $this->imgdata_bevels->GetAnchor(); + break; + + case MARK_IMG_DIAMOND: + if( $this->imgdata_diamonds == null ) { + require_once 'imgdata_diamonds.inc.php'; + $this->imgdata_diamonds = new ImgData_Diamonds(); + } + $this->markimg = $this->imgdata_diamonds->GetImg($this->type,$filename); + list($anchor_x,$anchor_y) = $this->imgdata_diamonds->GetAnchor(); + break; + + case MARK_IMG_BALL: + case MARK_IMG_SBALL: + case MARK_IMG_MBALL: + case MARK_IMG_LBALL: + if( $this->imgdata_balls == null ) { + require_once 'imgdata_balls.inc.php'; + $this->imgdata_balls = new ImgData_Balls(); + } + $this->markimg = $this->imgdata_balls->GetImg($this->type,$filename); + list($anchor_x,$anchor_y) = $this->imgdata_balls->GetAnchor(); + break; + } + + $w = $img->GetWidth($this->markimg); + $h = $img->GetHeight($this->markimg); + + $dw = round($imgscale * $w ); + $dh = round($imgscale * $h ); + + // Do potential rotation + list($x,$y) = $img->Rotate($x,$y); + + $dx = round($x-$dw*$anchor_x); + $dy = round($y-$dh*$anchor_y); + + $this->width = max($dx,$dy); + + $img->Copy($this->markimg,$dx,$dy,0,0,$dw,$dh,$w,$h); + if( !empty($this->csimtarget) ) { + $this->csimareas = "<area shape=\"rect\" coords=\"". + $dx.','.$dy.','.round($dx+$dw).','.round($dy+$dh).'" '. + "href=\"".htmlentities($this->csimtarget)."\""; + + if( !empty($this->csimwintarget) ) { + $this->csimareas .= " target=\"".$this->csimwintarget."\" "; + } + + if( !empty($this->csimalt) ) { + $tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue); + $this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" "; + } + $this->csimareas .= " />\n"; + } + + // Stroke title + $this->title->Align("center","top"); + $this->title->Stroke($img,$x,$y+round($dh/2)); + return; + } + + $weight = $this->weight; + $dx=round($width/2,0); + $dy=round($width/2,0); + $pts=0; + + switch( $this->type ) { + case MARK_SQUARE: + $c[]=$x-$dx;$c[]=$y-$dy; + $c[]=$x+$dx;$c[]=$y-$dy; + $c[]=$x+$dx;$c[]=$y+$dy; + $c[]=$x-$dx;$c[]=$y+$dy; + $c[]=$x-$dx;$c[]=$y-$dy; + $pts=5; + break; + case MARK_UTRIANGLE: + ++$dx;++$dy; + $c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx + $c[]=$x;$c[]=$y-0.87*$dy; + $c[]=$x+$dx;$c[]=$y+0.87*$dy; + $c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx + $pts=4; + break; + case MARK_DTRIANGLE: + ++$dx;++$dy; + $c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx + $c[]=$x-$dx;$c[]=$y-0.87*$dy; + $c[]=$x+$dx;$c[]=$y-0.87*$dy; + $c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx + $pts=4; + break; + case MARK_DIAMOND: + $c[]=$x;$c[]=$y+$dy; + $c[]=$x-$dx;$c[]=$y; + $c[]=$x;$c[]=$y-$dy; + $c[]=$x+$dx;$c[]=$y; + $c[]=$x;$c[]=$y+$dy; + $pts=5; + break; + case MARK_LEFTTRIANGLE: + $c[]=$x;$c[]=$y; + $c[]=$x;$c[]=$y+2*$dy; + $c[]=$x+$dx*2;$c[]=$y; + $c[]=$x;$c[]=$y; + $pts=4; + break; + case MARK_RIGHTTRIANGLE: + $c[]=$x-$dx*2;$c[]=$y; + $c[]=$x;$c[]=$y+2*$dy; + $c[]=$x;$c[]=$y; + $c[]=$x-$dx*2;$c[]=$y; + $pts=4; + break; + case MARK_FLASH: + $dy *= 2; + $c[]=$x+$dx/2; $c[]=$y-$dy; + $c[]=$x-$dx+$dx/2; $c[]=$y+$dy*0.7-$dy; + $c[]=$x+$dx/2; $c[]=$y+$dy*1.3-$dy; + $c[]=$x-$dx+$dx/2; $c[]=$y+2*$dy-$dy; + $img->SetLineWeight($weight); + $img->SetColor($color); + $img->Polygon($c); + $img->SetLineWeight(1); + $this->AddCSIMPoly($c); + break; + } + + if( $pts>0 ) { + $this->AddCSIMPoly($c); + $img->SetLineWeight($weight); + $img->SetColor($fcolor); + $img->FilledPolygon($c); + $img->SetColor($color); + $img->Polygon($c); + $img->SetLineWeight(1); + } + elseif( $this->type==MARK_CIRCLE ) { + $img->SetColor($color); + $img->Circle($x,$y,$width); + $this->AddCSIMCircle($x,$y,$width); + } + elseif( $this->type==MARK_FILLEDCIRCLE ) { + $img->SetColor($fcolor); + $img->FilledCircle($x,$y,$width); + $img->SetColor($color); + $img->Circle($x,$y,$width); + $this->AddCSIMCircle($x,$y,$width); + } + elseif( $this->type==MARK_CROSS ) { + // Oversize by a pixel to match the X + $img->SetColor($color); + $img->SetLineWeight($weight); + $img->Line($x,$y+$dy+1,$x,$y-$dy-1); + $img->Line($x-$dx-1,$y,$x+$dx+1,$y); + $this->AddCSIMCircle($x,$y,$dx); + } + elseif( $this->type==MARK_X ) { + $img->SetColor($color); + $img->SetLineWeight($weight); + $img->Line($x+$dx,$y+$dy,$x-$dx,$y-$dy); + $img->Line($x-$dx,$y+$dy,$x+$dx,$y-$dy); + $this->AddCSIMCircle($x,$y,$dx+$dy); + } + elseif( $this->type==MARK_STAR ) { + $img->SetColor($color); + $img->SetLineWeight($weight); + $img->Line($x+$dx,$y+$dy,$x-$dx,$y-$dy); + $img->Line($x-$dx,$y+$dy,$x+$dx,$y-$dy); + // Oversize by a pixel to match the X + $img->Line($x,$y+$dy+1,$x,$y-$dy-1); + $img->Line($x-$dx-1,$y,$x+$dx+1,$y); + $this->AddCSIMCircle($x,$y,$dx+$dy); + } + + // Stroke title + $this->title->Align("center","center"); + $this->title->Stroke($img,$x,$y); + } +} // Class + + + +//======================================================================== +// CLASS ImgData +// Description: Base class for all image data classes that contains the +// real image data. +//======================================================================== +class ImgData { + protected $name = ''; // Each subclass gives a name + protected $an = array(); // Data array names + protected $colors = array(); // Available colors + protected $index = array(); // Index for colors + protected $maxidx = 0 ; // Max color index + protected $anchor_x=0.5, $anchor_y=0.5 ; // Where is the center of the image + + function __construct() { + // Empty + } + + // Create a GD image from the data and return a GD handle + function GetImg($aMark,$aIdx) { + $n = $this->an[$aMark]; + if( is_string($aIdx) ) { + if( !in_array($aIdx,$this->colors) ) { + JpGraphError::RaiseL(23001,$this->name,$aIdx);//('This marker "'.($this->name).'" does not exist in color: '.$aIdx); + } + $idx = $this->index[$aIdx]; + } + elseif( !is_integer($aIdx) || + (is_integer($aIdx) && $aIdx > $this->maxidx ) ) { + JpGraphError::RaiseL(23002,$this->name);//('Mark color index too large for marker "'.($this->name).'"'); + } + else + $idx = $aIdx ; + return Image::CreateFromString(base64_decode($this->{$n}[$idx][1])); + } + + function GetAnchor() { + return array($this->anchor_x,$this->anchor_y); + } +} + + +// Keep a global flag cache to reduce memory usage +_gFlagCache=array( +1 => null, +2 => null, +3 => null, +4 => null, +); +// Only supposed to b called as statics +class FlagCache { + + static function GetFlagImgByName($aSize,$aName) { + global $_gFlagCache; + require_once('jpgraph_flags.php'); + if( $_gFlagCache[$aSize] === null ) { + $_gFlagCache[$aSize] = new FlagImages($aSize); + } + $f = $_gFlagCache[$aSize]; + $idx = $f->GetIdxByName($aName,$aFullName); + return $f->GetImgByIdx($idx); + } +} + +?> diff --git a/html/jpgraph/jpgraph_polar.php b/html/jpgraph/jpgraph_polar.php new file mode 100644 index 0000000..62c6bbc --- /dev/null +++ b/html/jpgraph/jpgraph_polar.php @@ -0,0 +1,897 @@ +<?php +/*======================================================================= + // File: JPGRAPH_POLAR.PHP + // Description: Polar plot extension for JpGraph + // Created: 2003-02-02 + // Ver: $Id: jpgraph_polar.php 1796 2009-09-07 09:37:19Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +require_once ('jpgraph_plotmark.inc.php'); +require_once "jpgraph_log.php"; + + +define('POLAR_360',1); +define('POLAR_180',2); + +// +// Note. Don't attempt to make sense of this code. +// In order not to have to be able to inherit the scaling code +// from the main graph package we have had to make some "tricks" since +// the original scaling and axis was not designed to do what is +// required here. +// There were two option. 1: Re-implement everything and get a clean design +// and 2: do some "small" trickery and be able to inherit most of +// the functionlity from the main graph package. +// We choose 2: here in order to save some time. +// + +//-------------------------------------------------------------------------- +// class PolarPlot +//-------------------------------------------------------------------------- +class PolarPlot { + public $line_style='solid',$mark; + public $legendcsimtarget=''; + public $legendcsimalt=''; + public $legend=""; + public $csimtargets=array(); // Array of targets for CSIM + public $csimareas=""; // Resultant CSIM area tags + public $csimalts=null; // ALT:s for corresponding target + public $scale=null; + private $numpoints=0; + private $iColor='navy',$iFillColor=''; + private $iLineWeight=1; + private $coord=null; + + function __construct($aData) { + $n = count($aData); + if( $n & 1 ) { + JpGraphError::RaiseL(17001); + //('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).'); + } + $this->numpoints = $n/2; + $this->coord = $aData; + $this->mark = new PlotMark(); + } + + function SetWeight($aWeight) { + $this->iLineWeight = $aWeight; + } + + function SetColor($aColor){ + $this->iColor = $aColor; + } + + function SetFillColor($aColor){ + $this->iFillColor = $aColor; + } + + function Max() { + $m = $this->coord[1]; + $i=1; + while( $i < $this->numpoints ) { + $m = max($m,$this->coord[2*$i+1]); + ++$i; + } + return $m; + } + // Set href targets for CSIM + function SetCSIMTargets($aTargets,$aAlts=null) { + $this->csimtargets=$aTargets; + $this->csimalts=$aAlts; + } + + // Get all created areas + function GetCSIMareas() { + return $this->csimareas; + } + + function SetLegend($aLegend,$aCSIM="",$aCSIMAlt="") { + $this->legend = $aLegend; + $this->legendcsimtarget = $aCSIM; + $this->legendcsimalt = $aCSIMAlt; + } + + // Private methods + + function Legend($aGraph) { + $color = $this->iColor ; + if( $this->legend != "" ) { + if( $this->iFillColor!='' ) { + $color = $this->iFillColor; + $aGraph->legend->Add($this->legend,$color,$this->mark,0, + $this->legendcsimtarget,$this->legendcsimalt); + } + else { + $aGraph->legend->Add($this->legend,$color,$this->mark,$this->line_style, + $this->legendcsimtarget,$this->legendcsimalt); + } + } + } + + function Stroke($img,$scale) { + + $i=0; + $p=array(); + $this->csimareas=''; + while($i < $this->numpoints) { + list($x1,$y1) = $scale->PTranslate($this->coord[2*$i],$this->coord[2*$i+1]); + $p[2*$i] = $x1; + $p[2*$i+1] = $y1; + + if( isset($this->csimtargets[$i]) ) { + $this->mark->SetCSIMTarget($this->csimtargets[$i]); + $this->mark->SetCSIMAlt($this->csimalts[$i]); + $this->mark->SetCSIMAltVal($this->coord[2*$i], $this->coord[2*$i+1]); + $this->mark->Stroke($img,$x1,$y1); + $this->csimareas .= $this->mark->GetCSIMAreas(); + } + else { + $this->mark->Stroke($img,$x1,$y1); + } + + ++$i; + } + + if( $this->iFillColor != '' ) { + $img->SetColor($this->iFillColor); + $img->FilledPolygon($p); + } + $img->SetLineWeight($this->iLineWeight); + $img->SetColor($this->iColor); + $img->Polygon($p,$this->iFillColor!=''); + } +} + +//-------------------------------------------------------------------------- +// class PolarAxis +//-------------------------------------------------------------------------- +class PolarAxis extends Axis { + private $angle_step=15,$angle_color='lightgray',$angle_label_color='black'; + private $angle_fontfam=FF_FONT1,$angle_fontstyle=FS_NORMAL,$angle_fontsize=10; + private $angle_fontcolor = 'navy'; + private $gridminor_color='lightgray',$gridmajor_color='lightgray'; + private $show_minor_grid = false, $show_major_grid = true ; + private $show_angle_mark=true, $show_angle_grid=true, $show_angle_label=true; + private $angle_tick_len=3, $angle_tick_len2=3, $angle_tick_color='black'; + private $show_angle_tick=true; + private $radius_tick_color='black'; + + function __construct($img,$aScale) { + parent::__construct($img,$aScale); + } + + function ShowAngleDegreeMark($aFlg=true) { + $this->show_angle_mark = $aFlg; + } + + function SetAngleStep($aStep) { + $this->angle_step=$aStep; + } + + function HideTicks($aFlg=true,$aAngleFlg=true) { + parent::HideTicks($aFlg,$aFlg); + $this->show_angle_tick = !$aAngleFlg; + } + + function ShowAngleLabel($aFlg=true) { + $this->show_angle_label = $aFlg; + } + + function ShowGrid($aMajor=true,$aMinor=false,$aAngle=true) { + $this->show_minor_grid = $aMinor; + $this->show_major_grid = $aMajor; + $this->show_angle_grid = $aAngle ; + } + + function SetAngleFont($aFontFam,$aFontStyle=FS_NORMAL,$aFontSize=10) { + $this->angle_fontfam = $aFontFam; + $this->angle_fontstyle = $aFontStyle; + $this->angle_fontsize = $aFontSize; + } + + function SetColor($aColor,$aRadColor='',$aAngleColor='') { + if( $aAngleColor == '' ) + $aAngleColor=$aColor; + parent::SetColor($aColor,$aRadColor); + $this->angle_fontcolor = $aAngleColor; + } + + function SetGridColor($aMajorColor,$aMinorColor='',$aAngleColor='') { + if( $aMinorColor == '' ) + $aMinorColor = $aMajorColor; + if( $aAngleColor == '' ) + $aAngleColor = $aMajorColor; + + $this->gridminor_color = $aMinorColor; + $this->gridmajor_color = $aMajorColor; + $this->angle_color = $aAngleColor; + } + + function SetTickColors($aRadColor,$aAngleColor='') { + $this->radius_tick_color = $aRadColor; + $this->angle_tick_color = $aAngleColor; + } + + // Private methods + function StrokeGrid($pos) { + $x = round($this->img->left_margin + $this->img->plotwidth/2); + $this->scale->ticks->Stroke($this->img,$this->scale,$pos); + + // Stroke the minor arcs + $pmin = array(); + $p = $this->scale->ticks->ticks_pos; + $n = count($p); + $i = 0; + $this->img->SetColor($this->gridminor_color); + while( $i < $n ) { + $r = $p[$i]-$x+1; + $pmin[]=$r; + if( $this->show_minor_grid ) { + $this->img->Circle($x,$pos,$r); + } + $i++; + } + + $limit = max($this->img->plotwidth,$this->img->plotheight)*1.4 ; + while( $r < $limit ) { + $off = $r; + $i=1; + $r = $off + round($p[$i]-$x+1); + while( $r < $limit && $i < $n ) { + $r = $off+$p[$i]-$x; + $pmin[]=$r; + if( $this->show_minor_grid ) { + $this->img->Circle($x,$pos,$r); + } + $i++; + } + } + + // Stroke the major arcs + if( $this->show_major_grid ) { + // First determine how many minor step on + // every major step. We have recorded the minor radius + // in pmin and use these values. This is done in order + // to avoid rounding errors if we were to recalculate the + // different major radius. + $pmaj = $this->scale->ticks->maj_ticks_pos; + $p = $this->scale->ticks->ticks_pos; + if( $this->scale->name == 'lin' ) { + $step=round(($pmaj[1] - $pmaj[0])/($p[1] - $p[0])); + } + else { + $step=9; + } + $n = round(count($pmin)/$step); + $i = 0; + $this->img->SetColor($this->gridmajor_color); + $limit = max($this->img->plotwidth,$this->img->plotheight)*1.4 ; + $off = $r; + $i=0; + $r = $pmin[$i*$step]; + while( $r < $limit && $i < $n ) { + $r = $pmin[$i*$step]; + $this->img->Circle($x,$pos,$r); + $i++; + } + } + + // Draw angles + if( $this->show_angle_grid ) { + $this->img->SetColor($this->angle_color); + $d = max($this->img->plotheight,$this->img->plotwidth)*1.4 ; + $a = 0; + $p = $this->scale->ticks->ticks_pos; + $start_radius = $p[1]-$x; + while( $a < 360 ) { + if( $a == 90 || $a == 270 ) { + // Make sure there are no rounding problem with + // exactly vertical lines + $this->img->Line($x+$start_radius*cos($a/180*M_PI)+1, + $pos-$start_radius*sin($a/180*M_PI), + $x+$start_radius*cos($a/180*M_PI)+1, + $pos-$d*sin($a/180*M_PI)); + + } + else { + $this->img->Line($x+$start_radius*cos($a/180*M_PI)+1, + $pos-$start_radius*sin($a/180*M_PI), + $x+$d*cos($a/180*M_PI), + $pos-$d*sin($a/180*M_PI)); + } + $a += $this->angle_step; + } + } + } + + function StrokeAngleLabels($pos,$type) { + + if( !$this->show_angle_label ) + return; + + $x0 = round($this->img->left_margin+$this->img->plotwidth/2)+1; + + $d = max($this->img->plotwidth,$this->img->plotheight)*1.42; + $a = $this->angle_step; + $t = new Text(); + $t->SetColor($this->angle_fontcolor); + $t->SetFont($this->angle_fontfam,$this->angle_fontstyle,$this->angle_fontsize); + $xright = $this->img->width - $this->img->right_margin; + $ytop = $this->img->top_margin; + $xleft = $this->img->left_margin; + $ybottom = $this->img->height - $this->img->bottom_margin; + $ha = 'left'; + $va = 'center'; + $w = $this->img->plotwidth/2; + $h = $this->img->plotheight/2; + $xt = $x0; $yt = $pos; + $margin=5; + + $tl = $this->angle_tick_len ; // Outer len + $tl2 = $this->angle_tick_len2 ; // Interior len + + $this->img->SetColor($this->angle_tick_color); + $rot90 = $this->img->a == 90 ; + + if( $type == POLAR_360 ) { + + // Corner angles of the four corners + $ca1 = atan($h/$w)/M_PI*180; + $ca2 = 180-$ca1; + $ca3 = $ca1+180; + $ca4 = 360-$ca1; + $end = 360; + + while( $a < $end ) { + $ca = cos($a/180*M_PI); + $sa = sin($a/180*M_PI); + $x = $d*$ca; + $y = $d*$sa; + $xt=1000;$yt=1000; + if( $a <= $ca1 || $a >= $ca4 ) { + $yt = $pos - $w * $y/$x; + $xt = $xright + $margin; + if( $rot90 ) { + $ha = 'center'; + $va = 'top'; + } + else { + $ha = 'left'; + $va = 'center'; + } + $x1=$xright-$tl2; $x2=$xright+$tl; + $y1=$y2=$yt; + } + elseif( $a > $ca1 && $a < $ca2 ) { + $xt = $x0 + $h * $x/$y; + $yt = $ytop - $margin; + if( $rot90 ) { + $ha = 'left'; + $va = 'center'; + } + else { + $ha = 'center'; + $va = 'bottom'; + } + $y1=$ytop+$tl2;$y2=$ytop-$tl; + $x1=$x2=$xt; + } + elseif( $a >= $ca2 && $a <= $ca3 ) { + $yt = $pos + $w * $y/$x; + $xt = $xleft - $margin; + if( $rot90 ) { + $ha = 'center'; + $va = 'bottom'; + } + else { + $ha = 'right'; + $va = 'center'; + } + $x1=$xleft+$tl2;$x2=$xleft-$tl; + $y1=$y2=$yt; + } + else { + $xt = $x0 - $h * $x/$y; + $yt = $ybottom + $margin; + if( $rot90 ) { + $ha = 'right'; + $va = 'center'; + } + else { + $ha = 'center'; + $va = 'top'; + } + $y1=$ybottom-$tl2;$y2=$ybottom+$tl; + $x1=$x2=$xt; + } + if( $a != 0 && $a != 180 ) { + $t->Align($ha,$va); + if( $this->scale->clockwise ) { + $t->Set(360-$a); + } + else { + $t->Set($a); + } + if( $this->show_angle_mark && $t->font_family > 4 ) { + $a .= SymChar::Get('degree'); + } + $t->Stroke($this->img,$xt,$yt); + if( $this->show_angle_tick ) { + $this->img->Line($x1,$y1,$x2,$y2); + } + } + $a += $this->angle_step; + } + } + else { + // POLAR_HALF + $ca1 = atan($h/$w*2)/M_PI*180; + $ca2 = 180-$ca1; + $end = 180; + while( $a < $end ) { + $ca = cos($a/180*M_PI); + $sa = sin($a/180*M_PI); + $x = $d*$ca; + $y = $d*$sa; + if( $a <= $ca1 ) { + $yt = $pos - $w * $y/$x; + $xt = $xright + $margin; + if( $rot90 ) { + $ha = 'center'; + $va = 'top'; + } + else { + $ha = 'left'; + $va = 'center'; + } + $x1=$xright-$tl2; $x2=$xright+$tl; + $y1=$y2=$yt; + } + elseif( $a > $ca1 && $a < $ca2 ) { + $xt = $x0 + 2*$h * $x/$y; + $yt = $ytop - $margin; + if( $rot90 ) { + $ha = 'left'; + $va = 'center'; + } + else { + $ha = 'center'; + $va = 'bottom'; + } + $y1=$ytop+$tl2;$y2=$ytop-$tl; + $x1=$x2=$xt; + } + elseif( $a >= $ca2 ) { + $yt = $pos + $w * $y/$x; + $xt = $xleft - $margin; + if( $rot90 ) { + $ha = 'center'; + $va = 'bottom'; + } + else { + $ha = 'right'; + $va = 'center'; + } + $x1=$xleft+$tl2;$x2=$xleft-$tl; + $y1=$y2=$yt; + } + $t->Align($ha,$va); + if( $this->show_angle_mark && $t->font_family > 4 ) { + $a .= SymChar::Get('degree'); + } + $t->Set($a); + $t->Stroke($this->img,$xt,$yt); + if( $this->show_angle_tick ) { + $this->img->Line($x1,$y1,$x2,$y2); + } + $a += $this->angle_step; + } + } + } + + function Stroke($pos,$dummy=true) { + + $this->img->SetLineWeight($this->weight); + $this->img->SetColor($this->color); + $this->img->SetFont($this->font_family,$this->font_style,$this->font_size); + if( !$this->hide_line ) { + $this->img->FilledRectangle($this->img->left_margin,$pos, + $this->img->width-$this->img->right_margin, + $pos+$this->weight-1); + } + $y=$pos+$this->img->GetFontHeight()+$this->title_margin+$this->title->margin; + if( $this->title_adjust=="high" ) { + $this->title->SetPos($this->img->width-$this->img->right_margin,$y,"right","top"); + } + elseif( $this->title_adjust=="middle" || $this->title_adjust=="center" ) { + $this->title->SetPos(($this->img->width-$this->img->left_margin-$this->img->right_margin)/2+$this->img->left_margin, + $y,"center","top"); + } + elseif($this->title_adjust=="low") { + $this->title->SetPos($this->img->left_margin,$y,"left","top"); + } + else { + JpGraphError::RaiseL(17002,$this->title_adjust); + //('Unknown alignment specified for X-axis title. ('.$this->title_adjust.')'); + } + + + if (!$this->hide_labels) { + $this->StrokeLabels($pos,false); + } + $this->img->SetColor($this->radius_tick_color); + $this->scale->ticks->Stroke($this->img,$this->scale,$pos); + + // + // Mirror the positions for the left side of the scale + // + $mid = 2*($this->img->left_margin+$this->img->plotwidth/2); + $n = count($this->scale->ticks->ticks_pos); + $i=0; + while( $i < $n ) { + $this->scale->ticks->ticks_pos[$i] = + $mid-$this->scale->ticks->ticks_pos[$i] ; + ++$i; + } + + $n = count($this->scale->ticks->maj_ticks_pos); + $i=0; + while( $i < $n ) { + $this->scale->ticks->maj_ticks_pos[$i] = + $mid-$this->scale->ticks->maj_ticks_pos[$i] ; + ++$i; + } + + $n = count($this->scale->ticks->maj_ticklabels_pos); + $i=1; + while( $i < $n ) { + $this->scale->ticks->maj_ticklabels_pos[$i] = + $mid-$this->scale->ticks->maj_ticklabels_pos[$i] ; + ++$i; + } + + // Draw the left side of the scale + $n = count($this->scale->ticks->ticks_pos); + $yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMinTickAbsSize(); + + + // Minor ticks + if( ! $this->scale->ticks->supress_minor_tickmarks ) { + $i=1; + while( $i < $n/2 ) { + $x = round($this->scale->ticks->ticks_pos[$i]) ; + $this->img->Line($x,$pos,$x,$yu); + ++$i; + } + } + + $n = count($this->scale->ticks->maj_ticks_pos); + $yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMajTickAbsSize(); + + + // Major ticks + if( ! $this->scale->ticks->supress_tickmarks ) { + $i=1; + while( $i < $n/2 ) { + $x = round($this->scale->ticks->maj_ticks_pos[$i]) ; + $this->img->Line($x,$pos,$x,$yu); + ++$i; + } + } + if (!$this->hide_labels) { + $this->StrokeLabels($pos,false); + } + $this->title->Stroke($this->img); + } +} + +class PolarScale extends LinearScale { + private $graph; + public $clockwise=false; + + function __construct($aMax,$graph,$aClockwise) { + parent::__construct(0,$aMax,'x'); + $this->graph = $graph; + $this->clockwise = $aClockwise; + } + + function SetClockwise($aFlg) { + $this->clockwise = $aFlg; + } + + function _Translate($v) { + return parent::Translate($v); + } + + function PTranslate($aAngle,$aRad) { + + $m = $this->scale[1]; + $w = $this->graph->img->plotwidth/2; + $aRad = $aRad/$m*$w; + + $a = $aAngle/180 * M_PI; + if( $this->clockwise ) { + $a = 2*M_PI-$a; + } + + $x = cos($a) * $aRad; + $y = sin($a) * $aRad; + + $x += $this->_Translate(0); + + if( $this->graph->iType == POLAR_360 ) { + $y = ($this->graph->img->top_margin + $this->graph->img->plotheight/2) - $y; + } + else { + $y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y; + } + return array($x,$y); + } +} + +class PolarLogScale extends LogScale { + private $graph; + public $clockwise=false; + + function __construct($aMax,$graph,$aClockwise=false) { + parent::__construct(0,$aMax,'x'); + $this->graph = $graph; + $this->ticks->SetLabelLogType(LOGLABELS_MAGNITUDE); + $this->clockwise = $aClockwise; + + } + + function SetClockwise($aFlg) { + $this->clockwise = $aFlg; + } + + function PTranslate($aAngle,$aRad) { + + if( $aRad == 0 ) + $aRad = 1; + $aRad = log10($aRad); + $m = $this->scale[1]; + $w = $this->graph->img->plotwidth/2; + $aRad = $aRad/$m*$w; + + $a = $aAngle/180 * M_PI; + if( $this->clockwise ) { + $a = 2*M_PI-$a; + } + + $x = cos( $a ) * $aRad; + $y = sin( $a ) * $aRad; + + $x += $w+$this->graph->img->left_margin;//$this->_Translate(0); + if( $this->graph->iType == POLAR_360 ) { + $y = ($this->graph->img->top_margin + $this->graph->img->plotheight/2) - $y; + } + else { + $y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y; + } + return array($x,$y); + } +} + +class PolarGraph extends Graph { + public $scale; + public $axis; + public $iType=POLAR_360; + private $iClockwise=false; + + function __construct($aWidth=300,$aHeight=200,$aCachedName="",$aTimeOut=0,$aInline=true) { + parent::__construct($aWidth,$aHeight,$aCachedName,$aTimeOut,$aInline) ; + $this->SetDensity(TICKD_DENSE); + $this->SetBox(); + $this->SetMarginColor('white'); + } + + function SetDensity($aDense) { + $this->SetTickDensity(TICKD_NORMAL,$aDense); + } + + function SetClockwise($aFlg) { + $this->scale->SetClockwise($aFlg); + } + + function Set90AndMargin($lm=0,$rm=0,$tm=0,$bm=0) { + $adj = ($this->img->height - $this->img->width)/2; + $this->SetAngle(90); + $lm2 = -$adj + ($lm-$rm+$tm+$bm)/2; + $rm2 = -$adj + (-$lm+$rm+$tm+$bm)/2; + $tm2 = $adj + ($tm-$bm+$lm+$rm)/2; + $bm2 = $adj + (-$tm+$bm+$lm+$rm)/2; + $this->SetMargin($lm2, $rm2, $tm2, $bm2); + $this->axis->SetLabelAlign('right','center'); + } + + function SetScale($aScale,$rmax=0,$dummy1=1,$dummy2=1,$dummy3=1) { + if( $aScale == 'lin' ) { + $this->scale = new PolarScale($rmax,$this,$this->iClockwise); + } + elseif( $aScale == 'log' ) { + $this->scale = new PolarLogScale($rmax,$this,$this->iClockwise); + } + else { + JpGraphError::RaiseL(17004);//('Unknown scale type for polar graph. Must be "lin" or "log"'); + } + + $this->axis = new PolarAxis($this->img,$this->scale); + $this->SetMargin(40,40,50,40); + } + + function SetType($aType) { + $this->iType = $aType; + } + + function SetPlotSize($w,$h) { + $this->SetMargin(($this->img->width-$w)/2,($this->img->width-$w)/2, + ($this->img->height-$h)/2,($this->img->height-$h)/2); + } + + // Private methods + function GetPlotsMax() { + $n = count($this->plots); + $m = $this->plots[0]->Max(); + $i=1; + while($i < $n) { + $m = max($this->plots[$i]->Max(),$m); + ++$i; + } + return $m; + } + + function Stroke($aStrokeFileName="") { + + // Start by adjusting the margin so that potential titles will fit. + $this->AdjustMarginsForTitles(); + + // If the filename is the predefined value = '_csim_special_' + // we assume that the call to stroke only needs to do enough + // to correctly generate the CSIM maps. + // We use this variable to skip things we don't strictly need + // to do to generate the image map to improve performance + // a best we can. Therefor you will see a lot of tests !$_csim in the + // code below. + $_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); + + // We need to know if we have stroked the plot in the + // GetCSIMareas. Otherwise the CSIM hasn't been generated + // and in the case of GetCSIM called before stroke to generate + // CSIM without storing an image to disk GetCSIM must call Stroke. + $this->iHasStroked = true; + + //Check if we should autoscale axis + if( !$this->scale->IsSpecified() && count($this->plots)>0 ) { + $max = $this->GetPlotsMax(); + $t1 = $this->img->plotwidth; + $this->img->plotwidth /= 2; + $t2 = $this->img->left_margin; + $this->img->left_margin += $this->img->plotwidth+1; + $this->scale->AutoScale($this->img,0,$max, + $this->img->plotwidth/$this->xtick_factor/2); + $this->img->plotwidth = $t1; + $this->img->left_margin = $t2; + } + else { + // The tick calculation will use the user suplied min/max values to determine + // the ticks. If auto_ticks is false the exact user specifed min and max + // values will be used for the scale. + // If auto_ticks is true then the scale might be slightly adjusted + // so that the min and max values falls on an even major step. + //$min = 0; + $max = $this->scale->scale[1]; + $t1 = $this->img->plotwidth; + $this->img->plotwidth /= 2; + $t2 = $this->img->left_margin; + $this->img->left_margin += $this->img->plotwidth+1; + $this->scale->AutoScale($this->img,0,$max, + $this->img->plotwidth/$this->xtick_factor/2); + $this->img->plotwidth = $t1; + $this->img->left_margin = $t2; + } + + if( $this->iType == POLAR_180 ) { + $pos = $this->img->height - $this->img->bottom_margin; + } + else { + $pos = $this->img->plotheight/2 + $this->img->top_margin; + } + + if( !$_csim ) { + $this->StrokePlotArea(); + } + + $this->iDoClipping = true; + + if( $this->iDoClipping ) { + $oldimage = $this->img->CloneCanvasH(); + } + + if( !$_csim ) { + $this->axis->StrokeGrid($pos); + } + + // Stroke all plots for Y1 axis + for($i=0; $i < count($this->plots); ++$i) { + $this->plots[$i]->Stroke($this->img,$this->scale); + } + + + if( $this->iDoClipping ) { + // Clipping only supports graphs at 0 and 90 degrees + if( $this->img->a == 0 ) { + $this->img->CopyCanvasH($oldimage,$this->img->img, + $this->img->left_margin,$this->img->top_margin, + $this->img->left_margin,$this->img->top_margin, + $this->img->plotwidth+1,$this->img->plotheight+1); + } + elseif( $this->img->a == 90 ) { + $adj1 = round(($this->img->height - $this->img->width)/2); + $adj2 = round(($this->img->width - $this->img->height)/2); + $lm = $this->img->left_margin; + $rm = $this->img->right_margin; + $tm = $this->img->top_margin; + $bm = $this->img->bottom_margin; + $this->img->CopyCanvasH($oldimage,$this->img->img, + $adj2 + round(($lm-$rm+$tm+$bm)/2), + $adj1 + round(($tm-$bm+$lm+$rm)/2), + $adj2 + round(($lm-$rm+$tm+$bm)/2), + $adj1 + round(($tm-$bm+$lm+$rm)/2), + $this->img->plotheight+1, + $this->img->plotwidth+1); + } + $this->img->Destroy(); + $this->img->SetCanvasH($oldimage); + } + + if( !$_csim ) { + $this->axis->Stroke($pos); + $this->axis->StrokeAngleLabels($pos,$this->iType); + } + + if( !$_csim ) { + $this->StrokePlotBox(); + $this->footer->Stroke($this->img); + + // The titles and legends never gets rotated so make sure + // that the angle is 0 before stroking them + $aa = $this->img->SetAngle(0); + $this->StrokeTitles(); + } + + for($i=0; $i < count($this->plots) ; ++$i ) { + $this->plots[$i]->Legend($this); + } + + $this->legend->Stroke($this->img); + + if( !$_csim ) { + + $this->StrokeTexts(); + $this->img->SetAngle($aa); + + // Draw an outline around the image map + if(_JPG_DEBUG) + $this->DisplayClientSideaImageMapAreas(); + + // If the filename is given as the special "__handle" + // then the image handler is returned and the image is NOT + // streamed back + if( $aStrokeFileName == _IMG_HANDLER ) { + return $this->img->img; + } + else { + // Finally stream the generated picture + $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName); + } + } + } +} + + + +?> diff --git a/html/jpgraph/jpgraph_radar.php b/html/jpgraph/jpgraph_radar.php new file mode 100644 index 0000000..1d3de62 --- /dev/null +++ b/html/jpgraph/jpgraph_radar.php @@ -0,0 +1,861 @@ +<?php +/*======================================================================= + // File: JPGRAPH_RADAR.PHP + // Description: Radar plot extension for JpGraph + // Created: 2001-02-04 + // Ver: $Id: jpgraph_radar.php 1783 2009-08-25 11:41:01Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +require_once('jpgraph_plotmark.inc.php'); + +//=================================================== +// CLASS RadarLogTicks +// Description: Logarithmic ticks +//=================================================== +class RadarLogTicks extends Ticks { + + function __construct() { + // Empty + } + + function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) { + $start = $aScale->GetMinVal(); + $limit = $aScale->GetMaxVal(); + $nextMajor = 10*$start; + $step = $nextMajor / 10.0; + $count=1; + + $ticklen_maj=5; + $dx_maj=round(sin($aAxisAngle)*$ticklen_maj); + $dy_maj=round(cos($aAxisAngle)*$ticklen_maj); + $ticklen_min=3; + $dx_min=round(sin($aAxisAngle)*$ticklen_min); + $dy_min=round(cos($aAxisAngle)*$ticklen_min); + + $aMajPos=array(); + $aMajLabel=array(); + + if( $this->supress_first ) { + $aMajLabel[] = ''; + } + else { + $aMajLabel[]=$start; + } + + $yr=$aScale->RelTranslate($start); + $xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0]; + $yt=$aPos-round($yr*sin($aAxisAngle)); + $aMajPos[]=$xt+2*$dx_maj; + $aMajPos[]=$yt-$aImg->GetFontheight()/2; + $grid[]=$xt; + $grid[]=$yt; + + $aImg->SetLineWeight($this->weight); + + for($y=$start; $y<=$limit; $y+=$step,++$count ) { + $yr=$aScale->RelTranslate($y); + $xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0]; + $yt=$aPos-round($yr*sin($aAxisAngle)); + if( $count % 10 == 0 ) { + $grid[]=$xt; + $grid[]=$yt; + $aMajPos[]=$xt+2*$dx_maj; + $aMajPos[]=$yt-$aImg->GetFontheight()/2; + if( !$this->supress_tickmarks ) { + if( $this->majcolor != '' ) { + $aImg->PushColor($this->majcolor); + } + $aImg->Line($xt+$dx_maj,$yt+$dy_maj,$xt-$dx_maj,$yt-$dy_maj); + if( $this->majcolor != '' ) { + $aImg->PopColor(); + } + } + if( $this->label_formfunc != '' ) { + $f=$this->label_formfunc; + $l = call_user_func($f,$nextMajor); + } + else { + $l = $nextMajor; + } + + $aMajLabel[]=$l; + $nextMajor *= 10; + $step *= 10; + $count=1; + } + else { + if( !$this->supress_minor_tickmarks ) { + if( $this->mincolor != '' ) { + $aImg->PushColor($this->mincolor); + } + $aImg->Line($xt+$dx_min,$yt+$dy_min,$xt-$dx_min,$yt-$dy_min); + if( $this->mincolor != '' ) { + $aImg->PopColor(); + } + } + } + } + } +} + +//=================================================== +// CLASS RadarLinear +// Description: Linear ticks +//=================================================== +class RadarLinearTicks extends Ticks { + + private $minor_step=1, $major_step=2; + private $xlabel_offset=0,$xtick_offset=0; + + function __construct() { + // Empty + } + + // Return major step size in world coordinates + function GetMajor() { + return $this->major_step; + } + + // Return minor step size in world coordinates + function GetMinor() { + return $this->minor_step; + } + + // Set Minor and Major ticks (in world coordinates) + function Set($aMajStep,$aMinStep=false) { + if( $aMinStep==false ) { + $aMinStep=$aMajStep; + } + + if( $aMajStep <= 0 || $aMinStep <= 0 ) { + JpGraphError::RaiseL(25064); + //JpGraphError::Raise(" Minor or major step size is 0. Check that you haven't got an accidental SetTextTicks(0) in your code. If this is not the case you might have stumbled upon a bug in JpGraph. Please report this and if possible include the data that caused the problem."); + } + + $this->major_step=$aMajStep; + $this->minor_step=$aMinStep; + $this->is_set = true; + } + + function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) { + // Prepare to draw linear ticks + $maj_step_abs = abs($aScale->scale_factor*$this->major_step); + $min_step_abs = abs($aScale->scale_factor*$this->minor_step); + $nbrmaj = round($aScale->world_abs_size/$maj_step_abs); + $nbrmin = round($aScale->world_abs_size/$min_step_abs); + $skip = round($nbrmin/$nbrmaj); // Don't draw minor on top of major + + // Draw major ticks + $ticklen2=$this->major_abs_size; + $dx=round(sin($aAxisAngle)*$ticklen2); + $dy=round(cos($aAxisAngle)*$ticklen2); + $label=$aScale->scale[0]+$this->major_step; + + $aImg->SetLineWeight($this->weight); + + $aMajPos = array(); + $aMajLabel = array(); + + for($i=1; $i<=$nbrmaj; ++$i) { + $xt=round($i*$maj_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0]; + $yt=$aPos-round($i*$maj_step_abs*sin($aAxisAngle)); + + if( $this->label_formfunc != '' ) { + $f=$this->label_formfunc; + $l = call_user_func($f,$label); + } + else { + $l = $label; + } + + $aMajLabel[]=$l; + $label += $this->major_step; + $grid[]=$xt; + $grid[]=$yt; + $aMajPos[($i-1)*2]=$xt+2*$dx; + $aMajPos[($i-1)*2+1]=$yt-$aImg->GetFontheight()/2; + if( !$this->supress_tickmarks ) { + if( $this->majcolor != '' ) { + $aImg->PushColor($this->majcolor); + } + $aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy); + if( $this->majcolor != '' ) { + $aImg->PopColor(); + } + } + } + + // Draw minor ticks + $ticklen2=$this->minor_abs_size; + $dx=round(sin($aAxisAngle)*$ticklen2); + $dy=round(cos($aAxisAngle)*$ticklen2); + if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) { + if( $this->mincolor != '' ) { + $aImg->PushColor($this->mincolor); + } + for($i=1; $i<=$nbrmin; ++$i) { + if( ($i % $skip) == 0 ) { + continue; + } + $xt=round($i*$min_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0]; + $yt=$aPos-round($i*$min_step_abs*sin($aAxisAngle)); + $aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy); + } + if( $this->mincolor != '' ) { + $aImg->PopColor(); + } + } + } +} + + +//=================================================== +// CLASS RadarAxis +// Description: Implements axis for the radar graph +//=================================================== +class RadarAxis extends AxisPrototype { + public $title=null; + private $title_color='navy'; + private $len=0; + + function __construct($img,$aScale,$color=array(0,0,0)) { + parent::__construct($img,$aScale,$color); + $this->len = $img->plotheight; + $this->title = new Text(); + $this->title->SetFont(FF_FONT1,FS_BOLD); + $this->color = array(0,0,0); + } + + // Stroke the axis + // $pos = Vertical position of axis + // $aAxisAngle = Axis angle + // $grid = Returns an array with positions used to draw the grid + // $lf = Label flag, TRUE if the axis should have labels + function Stroke($pos,$aAxisAngle,&$grid,$title,$lf) { + $this->img->SetColor($this->color); + + // Determine end points for the axis + $x=round($this->scale->world_abs_size*cos($aAxisAngle)+$this->scale->scale_abs[0]); + $y=round($pos-$this->scale->world_abs_size*sin($aAxisAngle)); + + // Draw axis + $this->img->SetColor($this->color); + $this->img->SetLineWeight($this->weight); + if( !$this->hide ) { + $this->img->Line($this->scale->scale_abs[0],$pos,$x,$y); + } + + $this->scale->ticks->Stroke($this->img,$grid,$pos,$aAxisAngle,$this->scale,$majpos,$majlabel); + $ncolor=0; + if( isset($this->ticks_label_colors) ) { + $ncolor=count($this->ticks_label_colors); + } + + // Draw labels + if( $lf && !$this->hide ) { + $this->img->SetFont($this->font_family,$this->font_style,$this->font_size); + $this->img->SetTextAlign('left','top'); + $this->img->SetColor($this->label_color); + + // majpos contains (x,y) coordinates for labels + if( ! $this->hide_labels ) { + $n = floor(count($majpos)/2); + for($i=0; $i < $n; ++$i) { + // Set specific label color if specified + if( $ncolor > 0 ) { + $this->img->SetColor($this->ticks_label_colors[$i % $ncolor]); + } + + if( $this->ticks_label != null && isset($this->ticks_label[$i]) ) { + $this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$this->ticks_label[$i]); + } + else { + $this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$majlabel[$i]); + } + } + } + } + $this->_StrokeAxisTitle($pos,$aAxisAngle,$title); + } + + function _StrokeAxisTitle($pos,$aAxisAngle,$title) { + $this->title->Set($title); + $marg=6+$this->title->margin; + $xt=round(($this->scale->world_abs_size+$marg)*cos($aAxisAngle)+$this->scale->scale_abs[0]); + $yt=round($pos-($this->scale->world_abs_size+$marg)*sin($aAxisAngle)); + + // Position the axis title. + // dx, dy is the offset from the top left corner of the bounding box that sorrounds the text + // that intersects with the extension of the corresponding axis. The code looks a little + // bit messy but this is really the only way of having a reasonable position of the + // axis titles. + if( $this->title->iWordwrap > 0 ) { + $title = wordwrap($title,$this->title->iWordwrap,"\n"); + } + + $h=$this->img->GetTextHeight($title)*1.2; + $w=$this->img->GetTextWidth($title)*1.2; + + while( $aAxisAngle > 2*M_PI ) + $aAxisAngle -= 2*M_PI; + + // Around 3 a'clock + if( $aAxisAngle>=7*M_PI/4 || $aAxisAngle <= M_PI/4 ) $dx=-0.15; // Small trimming to make the dist to the axis more even + + // Around 12 a'clock + if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dx=($aAxisAngle-M_PI/4)*2/M_PI; + + // Around 9 a'clock + if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dx=1; + + // Around 6 a'clock + if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dx=(1-($aAxisAngle-M_PI*5/4)*2/M_PI); + + if( $aAxisAngle>=7*M_PI/4 ) $dy=(($aAxisAngle-M_PI)-3*M_PI/4)*2/M_PI; + if( $aAxisAngle<=M_PI/12 ) $dy=(0.5-$aAxisAngle*2/M_PI); + if( $aAxisAngle<=M_PI/4 && $aAxisAngle > M_PI/12) $dy=(1-$aAxisAngle*2/M_PI); + if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dy=1; + if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dy=(1-($aAxisAngle-3*M_PI/4)*2/M_PI); + if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dy=0; + + if( !$this->hide ) { + $this->title->Stroke($this->img,$xt-$dx*$w,$yt-$dy*$h,$title); + } + } + +} // Class + + +//=================================================== +// CLASS RadarGrid +// Description: Draws grid for the radar graph +//=================================================== +class RadarGrid { //extends Grid { + private $type='solid'; + private $grid_color='#DDDDDD'; + private $show=false, $weight=1; + + function __construct() { + // Empty + } + + function SetColor($aMajColor) { + $this->grid_color = $aMajColor; + } + + function SetWeight($aWeight) { + $this->weight=$aWeight; + } + + // Specify if grid should be dashed, dotted or solid + function SetLineStyle($aType) { + $this->type = $aType; + } + + // Decide if both major and minor grid should be displayed + function Show($aShowMajor=true) { + $this->show=$aShowMajor; + } + + function Stroke($img,$grid) { + if( !$this->show ) { + return; + } + + $nbrticks = count($grid[0])/2; + $nbrpnts = count($grid); + $img->SetColor($this->grid_color); + $img->SetLineWeight($this->weight); + + for($i=0; $i<$nbrticks; ++$i) { + for($j=0; $j<$nbrpnts; ++$j) { + $pnts[$j*2]=$grid[$j][$i*2]; + $pnts[$j*2+1]=$grid[$j][$i*2+1]; + } + for($k=0; $k<$nbrpnts; ++$k ){ + $l=($k+1)%$nbrpnts; + if( $this->type == 'solid' ) + $img->Line($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1]); + elseif( $this->type == 'dotted' ) + $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],1,6); + elseif( $this->type == 'dashed' ) + $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],2,4); + elseif( $this->type == 'longdashed' ) + $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],8,6); + } + $pnts=array(); + } + } +} // Class + + +//=================================================== +// CLASS RadarPlot +// Description: Plot a radarplot +//=================================================== +class RadarPlot { + public $mark=null; + public $legend=''; + public $legendcsimtarget=''; + public $legendcsimalt=''; + public $csimtargets=array(); // Array of targets for CSIM + public $csimareas=""; // Resultant CSIM area tags + public $csimalts=null; // ALT:s for corresponding target + private $data=array(); + private $fill=false, $fill_color=array(200,170,180); + private $color=array(0,0,0); + private $weight=1; + private $linestyle='solid'; + + //--------------- + // CONSTRUCTOR + function __construct($data) { + $this->data = $data; + $this->mark = new PlotMark(); + } + + function Min() { + return Min($this->data); + } + + function Max() { + return Max($this->data); + } + + function SetLegend($legend) { + $this->legend=$legend; + } + + function SetLineStyle($aStyle) { + $this->linestyle=$aStyle; + } + + function SetLineWeight($w) { + $this->weight=$w; + } + + function SetFillColor($aColor) { + $this->fill_color = $aColor; + $this->fill = true; + } + + function SetFill($f=true) { + $this->fill = $f; + } + + function SetColor($aColor,$aFillColor=false) { + $this->color = $aColor; + if( $aFillColor ) { + $this->SetFillColor($aFillColor); + $this->fill = true; + } + } + + // Set href targets for CSIM + function SetCSIMTargets($aTargets,$aAlts=null) { + $this->csimtargets=$aTargets; + $this->csimalts=$aAlts; + } + + // Get all created areas + function GetCSIMareas() { + return $this->csimareas; + } + + function Stroke($img, $pos, $scale, $startangle) { + $nbrpnts = count($this->data); + $astep=2*M_PI/$nbrpnts; + $a=$startangle; + + for($i=0; $i<$nbrpnts; ++$i) { + + // Rotate each non null point to the correct axis-angle + $cs=$scale->RelTranslate($this->data[$i]); + $x=round($cs*cos($a)+$scale->scale_abs[0]); + $y=round($pos-$cs*sin($a)); + + $pnts[$i*2]=$x; + $pnts[$i*2+1]=$y; + + // If the next point is null then we draw this polygon segment + // to the center, skip the next and draw the next segment from + // the center up to the point on the axis with the first non-null + // value and continues from that point. Some additoinal logic is necessary + // to handle the boundary conditions + if( $i < $nbrpnts-1 ) { + if( is_null($this->data[$i+1]) ) { + $cs = 0; + $x=round($cs*cos($a)+$scale->scale_abs[0]); + $y=round($pos-$cs*sin($a)); + $pnts[$i*2]=$x; + $pnts[$i*2+1]=$y; + $a += $astep; + } + } + + $a += $astep; + } + + if( $this->fill ) { + $img->SetColor($this->fill_color); + $img->FilledPolygon($pnts); + } + + $img->SetLineWeight($this->weight); + $img->SetColor($this->color); + $img->SetLineStyle($this->linestyle); + $pnts[] = $pnts[0]; + $pnts[] = $pnts[1]; + $img->Polygon($pnts); + $img->SetLineStyle('solid'); // Reset line style to default + + // Add plotmarks on top + if( $this->mark->show ) { + for($i=0; $i < $nbrpnts; ++$i) { + if( isset($this->csimtargets[$i]) ) { + $this->mark->SetCSIMTarget($this->csimtargets[$i]); + $this->mark->SetCSIMAlt($this->csimalts[$i]); + $this->mark->SetCSIMAltVal($pnts[$i*2], $pnts[$i*2+1]); + $this->mark->Stroke($img, $pnts[$i*2], $pnts[$i*2+1]); + $this->csimareas .= $this->mark->GetCSIMAreas(); + } + else { + $this->mark->Stroke($img,$pnts[$i*2],$pnts[$i*2+1]); + } + } + } + + } + + function GetCount() { + return count($this->data); + } + + function Legend($graph) { + if( $this->legend == '' ) { + return; + } + if( $this->fill ) { + $graph->legend->Add($this->legend,$this->fill_color,$this->mark); + } else { + $graph->legend->Add($this->legend,$this->color,$this->mark); + } + } + +} // Class + +//=================================================== +// CLASS RadarGraph +// Description: Main container for a radar graph +//=================================================== +class RadarGraph extends Graph { + public $grid,$axis=null; + private $posx,$posy; + private $len; + private $axis_title=null; + + function __construct($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) { + parent::__construct($width,$height,$cachedName,$timeout,$inline); + $this->posx = $width/2; + $this->posy = $height/2; + $this->len = min($width,$height)*0.35; + $this->SetColor(array(255,255,255)); + $this->SetTickDensity(TICKD_NORMAL); + $this->SetScale('lin'); + $this->SetGridDepth(DEPTH_FRONT); + } + + function HideTickMarks($aFlag=true) { + $this->axis->scale->ticks->SupressTickMarks($aFlag); + } + + function ShowMinorTickmarks($aFlag=true) { + $this->yscale->ticks->SupressMinorTickMarks(!$aFlag); + } + + function SetScale($axtype,$ymin=1,$ymax=1,$dummy1=null,$dumy2=null) { + if( $axtype != 'lin' && $axtype != 'log' ) { + JpGraphError::RaiseL(18003,$axtype); + //("Illegal scale for radarplot ($axtype). Must be \"lin\" or \"log\""); + } + if( $axtype == 'lin' ) { + $this->yscale = new LinearScale($ymin,$ymax); + $this->yscale->ticks = new RadarLinearTicks(); + $this->yscale->ticks->SupressMinorTickMarks(); + } + elseif( $axtype == 'log' ) { + $this->yscale = new LogScale($ymin,$ymax); + $this->yscale->ticks = new RadarLogTicks(); + } + + $this->axis = new RadarAxis($this->img,$this->yscale); + $this->grid = new RadarGrid(); + } + + function SetSize($aSize) { + if( $aSize < 0.1 || $aSize>1 ) { + JpGraphError::RaiseL(18004,$aSize); + //("Radar Plot size must be between 0.1 and 1. (Your value=$s)"); + } + $this->len=min($this->img->width,$this->img->height)*$aSize/2; + } + + function SetPlotSize($aSize) { + $this->SetSize($aSize); + } + + function SetTickDensity($densy=TICKD_NORMAL,$dummy1=null) { + $this->ytick_factor=25; + switch( $densy ) { + case TICKD_DENSE: + $this->ytick_factor=12; + break; + case TICKD_NORMAL: + $this->ytick_factor=25; + break; + case TICKD_SPARSE: + $this->ytick_factor=40; + break; + case TICKD_VERYSPARSE: + $this->ytick_factor=70; + break; + default: + JpGraphError::RaiseL(18005,$densy); + //("RadarPlot Unsupported Tick density: $densy"); + } + } + + function SetPos($px,$py=0.5) { + $this->SetCenter($px,$py); + } + + function SetCenter($px,$py=0.5) { + if( $px >= 0 && $px <= 1 ) { + $this->posx = $this->img->width*$px; + } + else { + $this->posx = $px; + } + if( $py >= 0 && $py <= 1 ) { + $this->posy = $this->img->height*$py; + } + else { + $this->posy = $py; + } + } + + function SetColor($aColor) { + $this->SetMarginColor($aColor); + } + + function SetTitles($aTitleArray) { + $this->axis_title = $aTitleArray; + } + + function Add($aPlot) { + if( $aPlot == null ) { + JpGraphError::RaiseL(25010);//("Graph::Add() You tried to add a null plot to the graph."); + } + if( is_array($aPlot) && count($aPlot) > 0 ) { + $cl = $aPlot[0]; + } + else { + $cl = $aPlot; + } + + if( $cl instanceof Text ) $this->AddText($aPlot); + elseif( class_exists('IconPlot',false) && ($cl instanceof IconPlot) ) $this->AddIcon($aPlot); + else { + $this->plots[] = $aPlot; + } + } + + function GetPlotsYMinMax($aPlots) { + $min=$aPlots[0]->Min(); + $max=$aPlots[0]->Max(); + foreach( $this->plots as $p ) { + $max=max($max,$p->Max()); + $min=min($min,$p->Min()); + } + if( $min < 0 ) { + JpGraphError::RaiseL(18006,$min); + //("Minimum data $min (Radar plots should only be used when all data points > 0)"); + } + return array($min,$max); + } + + function StrokeIcons() { + if( $this->iIcons != null ) { + $n = count($this->iIcons); + for( $i=0; $i < $n; ++$i ) { + $this->iIcons[$i]->Stroke($this->img); + } + } + } + + function StrokeTexts() { + if( $this->texts != null ) { + $n = count($this->texts); + for( $i=0; $i < $n; ++$i ) { + $this->texts[$i]->Stroke($this->img); + } + } + } + + // Stroke the Radar graph + function Stroke($aStrokeFileName='') { + + // If the filename is the predefined value = '_csim_special_' + // we assume that the call to stroke only needs to do enough + // to correctly generate the CSIM maps. + // We use this variable to skip things we don't strictly need + // to do to generate the image map to improve performance + // a best we can. Therefor you will see a lot of tests !$_csim in the + // code below. + $_csim = ( $aStrokeFileName === _CSIM_SPECIALFILE ); + + // We need to know if we have stroked the plot in the + // GetCSIMareas. Otherwise the CSIM hasn't been generated + // and in the case of GetCSIM called before stroke to generate + // CSIM without storing an image to disk GetCSIM must call Stroke. + $this->iHasStroked = true; + + $n = count($this->plots); + // Set Y-scale + + if( !$this->yscale->IsSpecified() && count($this->plots) > 0 ) { + list($min,$max) = $this->GetPlotsYMinMax($this->plots); + $this->yscale->AutoScale($this->img,0,$max,$this->len/$this->ytick_factor); + } + elseif( $this->yscale->IsSpecified() && + ( $this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified()) ) { + + // The tick calculation will use the user suplied min/max values to determine + // the ticks. If auto_ticks is false the exact user specifed min and max + // values will be used for the scale. + // If auto_ticks is true then the scale might be slightly adjusted + // so that the min and max values falls on an even major step. + $min = $this->yscale->scale[0]; + $max = $this->yscale->scale[1]; + $this->yscale->AutoScale($this->img,$min,$max, + $this->len/$this->ytick_factor, + $this->yscale->auto_ticks); + } + + // Set start position end length of scale (in absolute pixels) + $this->yscale->SetConstants($this->posx,$this->len); + + // We need as many axis as there are data points + $nbrpnts=$this->plots[0]->GetCount(); + + // If we have no titles just number the axis 1,2,3,... + if( $this->axis_title==null ) { + for($i=0; $i < $nbrpnts; ++$i ) { + $this->axis_title[$i] = $i+1; + } + } + elseif( count($this->axis_title) < $nbrpnts) { + JpGraphError::RaiseL(18007); + // ("Number of titles does not match number of points in plot."); + } + for( $i=0; $i < $n; ++$i ) { + if( $nbrpnts != $this->plots[$i]->GetCount() ) { + JpGraphError::RaiseL(18008); + //("Each radar plot must have the same number of data points."); + } + } + + if( !$_csim ) { + if( $this->background_image != '' ) { + $this->StrokeFrameBackground(); + } + else { + $this->StrokeFrame(); + $this->StrokeBackgroundGrad(); + } + } + $astep=2*M_PI/$nbrpnts; + + if( !$_csim ) { + if( $this->iIconDepth == DEPTH_BACK ) { + $this->StrokeIcons(); + } + + + // Prepare legends + for($i=0; $i < $n; ++$i) { + $this->plots[$i]->Legend($this); + } + $this->legend->Stroke($this->img); + $this->footer->Stroke($this->img); + } + + if( !$_csim ) { + if( $this->grid_depth == DEPTH_BACK ) { + // Draw axis and grid + for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) { + $this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0); + } + $this->grid->Stroke($this->img,$grid); + } + if( $this->iIconDepth == DEPTH_BACK ) { + $this->StrokeIcons(); + } + + } + + // Plot points + $a=M_PI/2; + for($i=0; $i < $n; ++$i ) { + $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a); + } + + if( !$_csim ) { + if( $this->grid_depth != DEPTH_BACK ) { + // Draw axis and grid + for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) { + $this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0); + } + $this->grid->Stroke($this->img,$grid); + } + + $this->StrokeTitles(); + $this->StrokeTexts(); + if( $this->iIconDepth == DEPTH_FRONT ) { + $this->StrokeIcons(); + } + } + + // Should we do any final image transformation + if( $this->iImgTrans && !$_csim ) { + if( !class_exists('ImgTrans',false) ) { + require_once('jpgraph_imgtrans.php'); + } + + $tform = new ImgTrans($this->img->img); + $this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, + $this->iImgTransDirection,$this->iImgTransHighQ, + $this->iImgTransMinSize,$this->iImgTransFillColor, + $this->iImgTransBorder); + } + + if( !$_csim ) { + // If the filename is given as the special "__handle" + // then the image handler is returned and the image is NOT + // streamed back + if( $aStrokeFileName == _IMG_HANDLER ) { + return $this->img->img; + } + else { + // Finally stream the generated picture + $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName); + } + } + } +} // Class + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_regstat.php b/html/jpgraph/jpgraph_regstat.php new file mode 100644 index 0000000..0f6c96b --- /dev/null +++ b/html/jpgraph/jpgraph_regstat.php @@ -0,0 +1,215 @@ +<?php +/*======================================================================= + // File: JPGRAPH_REGSTAT.PHP + // Description: Regression and statistical analysis helper classes + // Created: 2002-12-01 + // Ver: $Id: jpgraph_regstat.php 1131 2009-03-11 20:08:24Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +//------------------------------------------------------------------------ +// CLASS Spline +// Create a new data array from an existing data array but with more points. +// The new points are interpolated using a cubic spline algorithm +//------------------------------------------------------------------------ +class Spline { + // 3:rd degree polynom approximation + + private $xdata,$ydata; // Data vectors + private $y2; // 2:nd derivate of ydata + private $n=0; + + function __construct($xdata,$ydata) { + $this->y2 = array(); + $this->xdata = $xdata; + $this->ydata = $ydata; + + $n = count($ydata); + $this->n = $n; + if( $this->n !== count($xdata) ) { + JpGraphError::RaiseL(19001); + //('Spline: Number of X and Y coordinates must be the same'); + } + + // Natural spline 2:derivate == 0 at endpoints + $this->y2[0] = 0.0; + $this->y2[$n-1] = 0.0; + $delta[0] = 0.0; + + // Calculate 2:nd derivate + for($i=1; $i < $n-1; ++$i) { + $d = ($xdata[$i+1]-$xdata[$i-1]); + if( $d == 0 ) { + JpGraphError::RaiseL(19002); + //('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.'); + } + $s = ($xdata[$i]-$xdata[$i-1])/$d; + $p = $s*$this->y2[$i-1]+2.0; + $this->y2[$i] = ($s-1.0)/$p; + $delta[$i] = ($ydata[$i+1]-$ydata[$i])/($xdata[$i+1]-$xdata[$i]) - + ($ydata[$i]-$ydata[$i-1])/($xdata[$i]-$xdata[$i-1]); + $delta[$i] = (6.0*$delta[$i]/($xdata[$i+1]-$xdata[$i-1])-$s*$delta[$i-1])/$p; + } + + // Backward substitution + for( $j=$n-2; $j >= 0; --$j ) { + $this->y2[$j] = $this->y2[$j]*$this->y2[$j+1] + $delta[$j]; + } + } + + // Return the two new data vectors + function Get($num=50) { + $n = $this->n ; + $step = ($this->xdata[$n-1]-$this->xdata[0]) / ($num-1); + $xnew=array(); + $ynew=array(); + $xnew[0] = $this->xdata[0]; + $ynew[0] = $this->ydata[0]; + for( $j=1; $j < $num; ++$j ) { + $xnew[$j] = $xnew[0]+$j*$step; + $ynew[$j] = $this->Interpolate($xnew[$j]); + } + return array($xnew,$ynew); + } + + // Return a single interpolated Y-value from an x value + function Interpolate($xpoint) { + + $max = $this->n-1; + $min = 0; + + // Binary search to find interval + while( $max-$min > 1 ) { + $k = ($max+$min) / 2; + if( $this->xdata[$k] > $xpoint ) + $max=$k; + else + $min=$k; + } + + // Each interval is interpolated by a 3:degree polynom function + $h = $this->xdata[$max]-$this->xdata[$min]; + + if( $h == 0 ) { + JpGraphError::RaiseL(19002); + //('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.'); + } + + + $a = ($this->xdata[$max]-$xpoint)/$h; + $b = ($xpoint-$this->xdata[$min])/$h; + return $a*$this->ydata[$min]+$b*$this->ydata[$max]+ + (($a*$a*$a-$a)*$this->y2[$min]+($b*$b*$b-$b)*$this->y2[$max])*($h*$h)/6.0; + } +} + +//------------------------------------------------------------------------ +// CLASS Bezier +// Create a new data array from a number of control points +//------------------------------------------------------------------------ +class Bezier { + /** + * @author Thomas Despoix, openXtrem company + * @license released under QPL + * @abstract Bezier interoplated point generation, + * computed from control points data sets, based on Paul Bourke algorithm : + * http://local.wasp.uwa.edu.au/~pbourke/geometry/bezier/index2.html + */ + private $datax = array(); + private $datay = array(); + private $n=0; + + function __construct($datax, $datay, $attraction_factor = 1) { + // Adding control point multiple time will raise their attraction power over the curve + $this->n = count($datax); + if( $this->n !== count($datay) ) { + JpGraphError::RaiseL(19003); + //('Bezier: Number of X and Y coordinates must be the same'); + } + $idx=0; + foreach($datax as $datumx) { + for ($i = 0; $i < $attraction_factor; $i++) { + $this->datax[$idx++] = $datumx; + } + } + $idx=0; + foreach($datay as $datumy) { + for ($i = 0; $i < $attraction_factor; $i++) { + $this->datay[$idx++] = $datumy; + } + } + $this->n *= $attraction_factor; + } + + /** + * Return a set of data points that specifies the bezier curve with $steps points + * @param $steps Number of new points to return + * @return array($datax, $datay) + */ + function Get($steps) { + $datax = array(); + $datay = array(); + for ($i = 0; $i < $steps; $i++) { + list($datumx, $datumy) = $this->GetPoint((double) $i / (double) $steps); + $datax[$i] = $datumx; + $datay[$i] = $datumy; + } + + $datax[] = end($this->datax); + $datay[] = end($this->datay); + + return array($datax, $datay); + } + + /** + * Return one point on the bezier curve. $mu is the position on the curve where $mu is in the + * range 0 $mu < 1 where 0 is tha start point and 1 is the end point. Note that every newly computed + * point depends on all the existing points + * + * @param $mu Position on the bezier curve + * @return array($x, $y) + */ + function GetPoint($mu) { + $n = $this->n - 1; + $k = 0; + $kn = 0; + $nn = 0; + $nkn = 0; + $blend = 0.0; + $newx = 0.0; + $newy = 0.0; + + $muk = 1.0; + $munk = (double) pow(1-$mu,(double) $n); + + for ($k = 0; $k <= $n; $k++) { + $nn = $n; + $kn = $k; + $nkn = $n - $k; + $blend = $muk * $munk; + $muk *= $mu; + $munk /= (1-$mu); + while ($nn >= 1) { + $blend *= $nn; + $nn--; + if ($kn > 1) { + $blend /= (double) $kn; + $kn--; + } + if ($nkn > 1) { + $blend /= (double) $nkn; + $nkn--; + } + } + $newx += $this->datax[$k] * $blend; + $newy += $this->datay[$k] * $blend; + } + + return array($newx, $newy); + } +} + +// EOF +?> diff --git a/html/jpgraph/jpgraph_rgb.inc.php b/html/jpgraph/jpgraph_rgb.inc.php new file mode 100644 index 0000000..5389261 --- /dev/null +++ b/html/jpgraph/jpgraph_rgb.inc.php @@ -0,0 +1,615 @@ +<?php +//======================================================================= +// File: JPGRAPH_RGB.INC.PHP +// Description: Class to handle RGb color space specification and +// named colors +// Created: 2001-01-08 (Refactored to separate file 2008-08-01) +// Ver: $Id: jpgraph_rgb.inc.php 1893 2009-10-02 23:15:25Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +/*=================================================== +// CLASS RGB +// Description: Color definitions as RGB triples +//=================================================== +*/ + +class RGB { + public $rgb_table; + public $img; + + function __construct($aImg=null) { + $this->img = $aImg; + + // Conversion array between color names and RGB + $this->rgb_table = array( + 'aqua'=> array(0,255,255), + 'lime'=> array(0,255,0), + 'teal'=> array(0,128,128), + 'whitesmoke'=>array(245,245,245), + 'gainsboro'=>array(220,220,220), + 'oldlace'=>array(253,245,230), + 'linen'=>array(250,240,230), + 'antiquewhite'=>array(250,235,215), + 'papayawhip'=>array(255,239,213), + 'blanchedalmond'=>array(255,235,205), + 'bisque'=>array(255,228,196), + 'peachpuff'=>array(255,218,185), + 'navajowhite'=>array(255,222,173), + 'moccasin'=>array(255,228,181), + 'cornsilk'=>array(255,248,220), + 'ivory'=>array(255,255,240), + 'lemonchiffon'=>array(255,250,205), + 'seashell'=>array(255,245,238), + 'mintcream'=>array(245,255,250), + 'azure'=>array(240,255,255), + 'aliceblue'=>array(240,248,255), + 'lavender'=>array(230,230,250), + 'lavenderblush'=>array(255,240,245), + 'mistyrose'=>array(255,228,225), + 'white'=>array(255,255,255), + 'black'=>array(0,0,0), + 'darkslategray'=>array(47,79,79), + 'dimgray'=>array(105,105,105), + 'slategray'=>array(112,128,144), + 'lightslategray'=>array(119,136,153), + 'gray'=>array(190,190,190), + 'lightgray'=>array(211,211,211), + 'midnightblue'=>array(25,25,112), + 'navy'=>array(0,0,128), + 'indigo'=>array(75,0,130), + 'electricindigo'=>array(102,0,255), + 'deepindigo'=>array(138,43,226), + 'pigmentindigo'=>array(75,0,130), + 'indigodye'=>array(0,65,106), + 'cornflowerblue'=>array(100,149,237), + 'darkslateblue'=>array(72,61,139), + 'slateblue'=>array(106,90,205), + 'mediumslateblue'=>array(123,104,238), + 'lightslateblue'=>array(132,112,255), + 'mediumblue'=>array(0,0,205), + 'royalblue'=>array(65,105,225), + 'blue'=>array(0,0,255), + 'dodgerblue'=>array(30,144,255), + 'deepskyblue'=>array(0,191,255), + 'skyblue'=>array(135,206,235), + 'lightskyblue'=>array(135,206,250), + 'steelblue'=>array(70,130,180), + 'lightred'=>array(211,167,168), + 'lightsteelblue'=>array(176,196,222), + 'lightblue'=>array(173,216,230), + 'powderblue'=>array(176,224,230), + 'paleturquoise'=>array(175,238,238), + 'darkturquoise'=>array(0,206,209), + 'mediumturquoise'=>array(72,209,204), + 'turquoise'=>array(64,224,208), + 'cyan'=>array(0,255,255), + 'lightcyan'=>array(224,255,255), + 'cadetblue'=>array(95,158,160), + 'mediumaquamarine'=>array(102,205,170), + 'aquamarine'=>array(127,255,212), + 'darkgreen'=>array(0,100,0), + 'darkolivegreen'=>array(85,107,47), + 'darkseagreen'=>array(143,188,143), + 'seagreen'=>array(46,139,87), + 'mediumseagreen'=>array(60,179,113), + 'lightseagreen'=>array(32,178,170), + 'palegreen'=>array(152,251,152), + 'springgreen'=>array(0,255,127), + 'lawngreen'=>array(124,252,0), + 'green'=>array(0,255,0), + 'chartreuse'=>array(127,255,0), + 'mediumspringgreen'=>array(0,250,154), + 'greenyellow'=>array(173,255,47), + 'limegreen'=>array(50,205,50), + 'yellowgreen'=>array(154,205,50), + 'forestgreen'=>array(34,139,34), + 'olivedrab'=>array(107,142,35), + 'darkkhaki'=>array(189,183,107), + 'khaki'=>array(240,230,140), + 'palegoldenrod'=>array(238,232,170), + 'lightgoldenrodyellow'=>array(250,250,210), + 'lightyellow'=>array(255,255,200), + 'yellow'=>array(255,255,0), + 'gold'=>array(255,215,0), + 'lightgoldenrod'=>array(238,221,130), + 'goldenrod'=>array(218,165,32), + 'darkgoldenrod'=>array(184,134,11), + 'rosybrown'=>array(188,143,143), + 'indianred'=>array(205,92,92), + 'saddlebrown'=>array(139,69,19), + 'sienna'=>array(160,82,45), + 'peru'=>array(205,133,63), + 'burlywood'=>array(222,184,135), + 'beige'=>array(245,245,220), + 'wheat'=>array(245,222,179), + 'sandybrown'=>array(244,164,96), + 'tan'=>array(210,180,140), + 'chocolate'=>array(210,105,30), + 'firebrick'=>array(178,34,34), + 'brown'=>array(165,42,42), + 'darksalmon'=>array(233,150,122), + 'salmon'=>array(250,128,114), + 'lightsalmon'=>array(255,160,122), + 'orange'=>array(255,165,0), + 'darkorange'=>array(255,140,0), + 'coral'=>array(255,127,80), + 'lightcoral'=>array(240,128,128), + 'tomato'=>array(255,99,71), + 'orangered'=>array(255,69,0), + 'red'=>array(255,0,0), + 'hotpink'=>array(255,105,180), + 'deeppink'=>array(255,20,147), + 'pink'=>array(255,192,203), + 'lightpink'=>array(255,182,193), + 'palevioletred'=>array(219,112,147), + 'maroon'=>array(176,48,96), + 'mediumvioletred'=>array(199,21,133), + 'violetred'=>array(208,32,144), + 'magenta'=>array(255,0,255), + 'violet'=>array(238,130,238), + 'plum'=>array(221,160,221), + 'orchid'=>array(218,112,214), + 'mediumorchid'=>array(186,85,211), + 'darkorchid'=>array(153,50,204), + 'darkviolet'=>array(148,0,211), + 'blueviolet'=>array(138,43,226), + 'purple'=>array(160,32,240), + 'mediumpurple'=>array(147,112,219), + 'thistle'=>array(216,191,216), + 'snow1'=>array(255,250,250), + 'snow2'=>array(238,233,233), + 'snow3'=>array(205,201,201), + 'snow4'=>array(139,137,137), + 'seashell1'=>array(255,245,238), + 'seashell2'=>array(238,229,222), + 'seashell3'=>array(205,197,191), + 'seashell4'=>array(139,134,130), + 'AntiqueWhite1'=>array(255,239,219), + 'AntiqueWhite2'=>array(238,223,204), + 'AntiqueWhite3'=>array(205,192,176), + 'AntiqueWhite4'=>array(139,131,120), + 'bisque1'=>array(255,228,196), + 'bisque2'=>array(238,213,183), + 'bisque3'=>array(205,183,158), + 'bisque4'=>array(139,125,107), + 'peachPuff1'=>array(255,218,185), + 'peachpuff2'=>array(238,203,173), + 'peachpuff3'=>array(205,175,149), + 'peachpuff4'=>array(139,119,101), + 'navajowhite1'=>array(255,222,173), + 'navajowhite2'=>array(238,207,161), + 'navajowhite3'=>array(205,179,139), + 'navajowhite4'=>array(139,121,94), + 'lemonchiffon1'=>array(255,250,205), + 'lemonchiffon2'=>array(238,233,191), + 'lemonchiffon3'=>array(205,201,165), + 'lemonchiffon4'=>array(139,137,112), + 'ivory1'=>array(255,255,240), + 'ivory2'=>array(238,238,224), + 'ivory3'=>array(205,205,193), + 'ivory4'=>array(139,139,131), + 'honeydew'=>array(193,205,193), + 'lavenderblush1'=>array(255,240,245), + 'lavenderblush2'=>array(238,224,229), + 'lavenderblush3'=>array(205,193,197), + 'lavenderblush4'=>array(139,131,134), + 'mistyrose1'=>array(255,228,225), + 'mistyrose2'=>array(238,213,210), + 'mistyrose3'=>array(205,183,181), + 'mistyrose4'=>array(139,125,123), + 'azure1'=>array(240,255,255), + 'azure2'=>array(224,238,238), + 'azure3'=>array(193,205,205), + 'azure4'=>array(131,139,139), + 'slateblue1'=>array(131,111,255), + 'slateblue2'=>array(122,103,238), + 'slateblue3'=>array(105,89,205), + 'slateblue4'=>array(71,60,139), + 'royalblue1'=>array(72,118,255), + 'royalblue2'=>array(67,110,238), + 'royalblue3'=>array(58,95,205), + 'royalblue4'=>array(39,64,139), + 'dodgerblue1'=>array(30,144,255), + 'dodgerblue2'=>array(28,134,238), + 'dodgerblue3'=>array(24,116,205), + 'dodgerblue4'=>array(16,78,139), + 'steelblue1'=>array(99,184,255), + 'steelblue2'=>array(92,172,238), + 'steelblue3'=>array(79,148,205), + 'steelblue4'=>array(54,100,139), + 'deepskyblue1'=>array(0,191,255), + 'deepskyblue2'=>array(0,178,238), + 'deepskyblue3'=>array(0,154,205), + 'deepskyblue4'=>array(0,104,139), + 'skyblue1'=>array(135,206,255), + 'skyblue2'=>array(126,192,238), + 'skyblue3'=>array(108,166,205), + 'skyblue4'=>array(74,112,139), + 'lightskyblue1'=>array(176,226,255), + 'lightskyblue2'=>array(164,211,238), + 'lightskyblue3'=>array(141,182,205), + 'lightskyblue4'=>array(96,123,139), + 'slategray1'=>array(198,226,255), + 'slategray2'=>array(185,211,238), + 'slategray3'=>array(159,182,205), + 'slategray4'=>array(108,123,139), + 'lightsteelblue1'=>array(202,225,255), + 'lightsteelblue2'=>array(188,210,238), + 'lightsteelblue3'=>array(162,181,205), + 'lightsteelblue4'=>array(110,123,139), + 'lightblue1'=>array(191,239,255), + 'lightblue2'=>array(178,223,238), + 'lightblue3'=>array(154,192,205), + 'lightblue4'=>array(104,131,139), + 'lightcyan1'=>array(224,255,255), + 'lightcyan2'=>array(209,238,238), + 'lightcyan3'=>array(180,205,205), + 'lightcyan4'=>array(122,139,139), + 'paleturquoise1'=>array(187,255,255), + 'paleturquoise2'=>array(174,238,238), + 'paleturquoise3'=>array(150,205,205), + 'paleturquoise4'=>array(102,139,139), + 'cadetblue1'=>array(152,245,255), + 'cadetblue2'=>array(142,229,238), + 'cadetblue3'=>array(122,197,205), + 'cadetblue4'=>array(83,134,139), + 'turquoise1'=>array(0,245,255), + 'turquoise2'=>array(0,229,238), + 'turquoise3'=>array(0,197,205), + 'turquoise4'=>array(0,134,139), + 'cyan1'=>array(0,255,255), + 'cyan2'=>array(0,238,238), + 'cyan3'=>array(0,205,205), + 'cyan4'=>array(0,139,139), + 'darkslategray1'=>array(151,255,255), + 'darkslategray2'=>array(141,238,238), + 'darkslategray3'=>array(121,205,205), + 'darkslategray4'=>array(82,139,139), + 'aquamarine1'=>array(127,255,212), + 'aquamarine2'=>array(118,238,198), + 'aquamarine3'=>array(102,205,170), + 'aquamarine4'=>array(69,139,116), + 'darkseagreen1'=>array(193,255,193), + 'darkseagreen2'=>array(180,238,180), + 'darkseagreen3'=>array(155,205,155), + 'darkseagreen4'=>array(105,139,105), + 'seagreen1'=>array(84,255,159), + 'seagreen2'=>array(78,238,148), + 'seagreen3'=>array(67,205,128), + 'seagreen4'=>array(46,139,87), + 'palegreen1'=>array(154,255,154), + 'palegreen2'=>array(144,238,144), + 'palegreen3'=>array(124,205,124), + 'palegreen4'=>array(84,139,84), + 'springgreen1'=>array(0,255,127), + 'springgreen2'=>array(0,238,118), + 'springgreen3'=>array(0,205,102), + 'springgreen4'=>array(0,139,69), + 'chartreuse1'=>array(127,255,0), + 'chartreuse2'=>array(118,238,0), + 'chartreuse3'=>array(102,205,0), + 'chartreuse4'=>array(69,139,0), + 'olivedrab1'=>array(192,255,62), + 'olivedrab2'=>array(179,238,58), + 'olivedrab3'=>array(154,205,50), + 'olivedrab4'=>array(105,139,34), + 'darkolivegreen1'=>array(202,255,112), + 'darkolivegreen2'=>array(188,238,104), + 'darkolivegreen3'=>array(162,205,90), + 'darkolivegreen4'=>array(110,139,61), + 'khaki1'=>array(255,246,143), + 'khaki2'=>array(238,230,133), + 'khaki3'=>array(205,198,115), + 'khaki4'=>array(139,134,78), + 'lightgoldenrod1'=>array(255,236,139), + 'lightgoldenrod2'=>array(238,220,130), + 'lightgoldenrod3'=>array(205,190,112), + 'lightgoldenrod4'=>array(139,129,76), + 'yellow1'=>array(255,255,0), + 'yellow2'=>array(238,238,0), + 'yellow3'=>array(205,205,0), + 'yellow4'=>array(139,139,0), + 'gold1'=>array(255,215,0), + 'gold2'=>array(238,201,0), + 'gold3'=>array(205,173,0), + 'gold4'=>array(139,117,0), + 'goldenrod1'=>array(255,193,37), + 'goldenrod2'=>array(238,180,34), + 'goldenrod3'=>array(205,155,29), + 'goldenrod4'=>array(139,105,20), + 'darkgoldenrod1'=>array(255,185,15), + 'darkgoldenrod2'=>array(238,173,14), + 'darkgoldenrod3'=>array(205,149,12), + 'darkgoldenrod4'=>array(139,101,8), + 'rosybrown1'=>array(255,193,193), + 'rosybrown2'=>array(238,180,180), + 'rosybrown3'=>array(205,155,155), + 'rosybrown4'=>array(139,105,105), + 'indianred1'=>array(255,106,106), + 'indianred2'=>array(238,99,99), + 'indianred3'=>array(205,85,85), + 'indianred4'=>array(139,58,58), + 'sienna1'=>array(255,130,71), + 'sienna2'=>array(238,121,66), + 'sienna3'=>array(205,104,57), + 'sienna4'=>array(139,71,38), + 'burlywood1'=>array(255,211,155), + 'burlywood2'=>array(238,197,145), + 'burlywood3'=>array(205,170,125), + 'burlywood4'=>array(139,115,85), + 'wheat1'=>array(255,231,186), + 'wheat2'=>array(238,216,174), + 'wheat3'=>array(205,186,150), + 'wheat4'=>array(139,126,102), + 'tan1'=>array(255,165,79), + 'tan2'=>array(238,154,73), + 'tan3'=>array(205,133,63), + 'tan4'=>array(139,90,43), + 'chocolate1'=>array(255,127,36), + 'chocolate2'=>array(238,118,33), + 'chocolate3'=>array(205,102,29), + 'chocolate4'=>array(139,69,19), + 'firebrick1'=>array(255,48,48), + 'firebrick2'=>array(238,44,44), + 'firebrick3'=>array(205,38,38), + 'firebrick4'=>array(139,26,26), + 'brown1'=>array(255,64,64), + 'brown2'=>array(238,59,59), + 'brown3'=>array(205,51,51), + 'brown4'=>array(139,35,35), + 'salmon1'=>array(255,140,105), + 'salmon2'=>array(238,130,98), + 'salmon3'=>array(205,112,84), + 'salmon4'=>array(139,76,57), + 'lightsalmon1'=>array(255,160,122), + 'lightsalmon2'=>array(238,149,114), + 'lightsalmon3'=>array(205,129,98), + 'lightsalmon4'=>array(139,87,66), + 'orange1'=>array(255,165,0), + 'orange2'=>array(238,154,0), + 'orange3'=>array(205,133,0), + 'orange4'=>array(139,90,0), + 'darkorange1'=>array(255,127,0), + 'darkorange2'=>array(238,118,0), + 'darkorange3'=>array(205,102,0), + 'darkorange4'=>array(139,69,0), + 'coral1'=>array(255,114,86), + 'coral2'=>array(238,106,80), + 'coral3'=>array(205,91,69), + 'coral4'=>array(139,62,47), + 'tomato1'=>array(255,99,71), + 'tomato2'=>array(238,92,66), + 'tomato3'=>array(205,79,57), + 'tomato4'=>array(139,54,38), + 'orangered1'=>array(255,69,0), + 'orangered2'=>array(238,64,0), + 'orangered3'=>array(205,55,0), + 'orangered4'=>array(139,37,0), + 'deeppink1'=>array(255,20,147), + 'deeppink2'=>array(238,18,137), + 'deeppink3'=>array(205,16,118), + 'deeppink4'=>array(139,10,80), + 'hotpink1'=>array(255,110,180), + 'hotpink2'=>array(238,106,167), + 'hotpink3'=>array(205,96,144), + 'hotpink4'=>array(139,58,98), + 'pink1'=>array(255,181,197), + 'pink2'=>array(238,169,184), + 'pink3'=>array(205,145,158), + 'pink4'=>array(139,99,108), + 'lightpink1'=>array(255,174,185), + 'lightpink2'=>array(238,162,173), + 'lightpink3'=>array(205,140,149), + 'lightpink4'=>array(139,95,101), + 'palevioletred1'=>array(255,130,171), + 'palevioletred2'=>array(238,121,159), + 'palevioletred3'=>array(205,104,137), + 'palevioletred4'=>array(139,71,93), + 'maroon1'=>array(255,52,179), + 'maroon2'=>array(238,48,167), + 'maroon3'=>array(205,41,144), + 'maroon4'=>array(139,28,98), + 'violetred1'=>array(255,62,150), + 'violetred2'=>array(238,58,140), + 'violetred3'=>array(205,50,120), + 'violetred4'=>array(139,34,82), + 'magenta1'=>array(255,0,255), + 'magenta2'=>array(238,0,238), + 'magenta3'=>array(205,0,205), + 'magenta4'=>array(139,0,139), + 'mediumred'=>array(140,34,34), + 'orchid1'=>array(255,131,250), + 'orchid2'=>array(238,122,233), + 'orchid3'=>array(205,105,201), + 'orchid4'=>array(139,71,137), + 'plum1'=>array(255,187,255), + 'plum2'=>array(238,174,238), + 'plum3'=>array(205,150,205), + 'plum4'=>array(139,102,139), + 'mediumorchid1'=>array(224,102,255), + 'mediumorchid2'=>array(209,95,238), + 'mediumorchid3'=>array(180,82,205), + 'mediumorchid4'=>array(122,55,139), + 'darkorchid1'=>array(191,62,255), + 'darkorchid2'=>array(178,58,238), + 'darkorchid3'=>array(154,50,205), + 'darkorchid4'=>array(104,34,139), + 'purple1'=>array(155,48,255), + 'purple2'=>array(145,44,238), + 'purple3'=>array(125,38,205), + 'purple4'=>array(85,26,139), + 'mediumpurple1'=>array(171,130,255), + 'mediumpurple2'=>array(159,121,238), + 'mediumpurple3'=>array(137,104,205), + 'mediumpurple4'=>array(93,71,139), + 'thistle1'=>array(255,225,255), + 'thistle2'=>array(238,210,238), + 'thistle3'=>array(205,181,205), + 'thistle4'=>array(139,123,139), + 'gray1'=>array(10,10,10), + 'gray2'=>array(40,40,30), + 'gray3'=>array(70,70,70), + 'gray4'=>array(100,100,100), + 'gray5'=>array(130,130,130), + 'gray6'=>array(160,160,160), + 'gray7'=>array(190,190,190), + 'gray8'=>array(210,210,210), + 'gray9'=>array(240,240,240), + 'darkgray'=>array(100,100,100), + 'darkblue'=>array(0,0,139), + 'darkcyan'=>array(0,139,139), + 'darkmagenta'=>array(139,0,139), + 'darkred'=>array(139,0,0), + 'silver'=>array(192, 192, 192), + 'eggplant'=>array(144,176,168), + 'lightgreen'=>array(144,238,144)); + } + + + //---------------- + // PUBLIC METHODS + // Colors can be specified as either + // 1. #xxxxxx HTML style + // 2. "colorname" as a named color + // 3. array(r,g,b) RGB triple + // This function translates this to a native RGB format and returns an + // RGB triple. + + function Color($aColor) { + if (is_string($aColor)) { + $matches = array(); + // this regex will parse a color string and fill the $matches array as such: + // 0: the full match if any + // 1: a hex string preceded by a hash, can be 3 characters (#fff) or 6 (#ffffff) (4 or 5 also accepted but...) + // 2,3,4: r,g,b values in hex if the first character of the string is # + // 5: all alpha-numeric characters at the beginning of the string if string does not start with # + // 6: alpha value prefixed by @ if supplied + // 7: alpha value with @ stripped + // 8: adjust value prefixed with : if supplied + // 9: adjust value with : stripped + $regex = '/(#([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2}))?([\w]+)?(@([\d\.,]+))?(:([\d\.,]+))?/'; + if(!preg_match($regex, $aColor, $matches)) { + JpGraphError::RaiseL(25078,$aColor);//(" Unknown color: $aColor"); + } + if(empty($matches[5])) { + $r = strlen($matches[2]) == 1 ? $matches[2].$matches[2] : $matches[2]; + $g = strlen($matches[3]) == 1 ? $matches[3].$matches[3] : $matches[3]; + $b = strlen($matches[4]) == 1 ? $matches[4].$matches[4] : $matches[4]; + $r = hexdec($r); + $g = hexdec($g); + $b = hexdec($b); + }else { + if(!isset($this->rgb_table[$matches[5]]) ) { + JpGraphError::RaiseL(25078,$aColor);//(" Unknown color: $aColor"); + } + $r = $this->rgb_table[$matches[5]][0]; + $g = $this->rgb_table[$matches[5]][1]; + $b = $this->rgb_table[$matches[5]][2]; + } + $alpha = isset($matches[7]) ? str_replace(',','.',$matches[7]) : 0; + $adj = isset($matches[9]) ? str_replace(',','.',$matches[9]) : 1.0; + + if( $adj < 0 ) { + JpGraphError::RaiseL(25077);//('Adjustment factor for color must be > 0'); + } + + // Scale adj so that an adj=2 always + // makes the color 100% white (i.e. 255,255,255. + // and adj=1 neutral and adj=0 black. + if( $adj == 1) { + return array($r,$g,$b,$alpha); + } + elseif( $adj > 1 ) { + $m = ($adj-1.0)*(255-min(255,min($r,min($g,$b)))); + return array(min(255,$r+$m), min(255,$g+$m), min(255,$b+$m),$alpha); + } + elseif( $adj < 1 ) { + $m = ($adj-1.0)*max(255,max($r,max($g,$b))); + return array(max(0,$r+$m), max(0,$g+$m), max(0,$b+$m),$alpha); + } + } elseif( is_array($aColor) ) { + if(!isset($aColor[3])) $aColor[3] = 0; + return $aColor; + } + else { + JpGraphError::RaiseL(25079,$aColor,count($aColor));//(" Unknown color specification: $aColor , size=".count($aColor)); + } + } + + // Compare two colors + // return true if equal + function Equal($aCol1,$aCol2) { + $c1 = $this->Color($aCol1); + $c2 = $this->Color($aCol2); + return $c1[0]==$c2[0] && $c1[1]==$c2[1] && $c1[2]==$c2[2] ; + } + + // Allocate a new color in the current image + // Return new color index, -1 if no more colors could be allocated + function Allocate($aColor,$aAlpha=0.0) { + list ($r, $g, $b, $a) = $this->color($aColor); + // If alpha is specified in the color string then this + // takes precedence over the second argument + if( $a > 0 ) { + $aAlpha = $a; + } + if( $aAlpha < 0 || $aAlpha > 1 ) { + JpGraphError::RaiseL(25080);//('Alpha parameter for color must be between 0.0 and 1.0'); + } + return imagecolorresolvealpha($this->img, $r, $g, $b, round($aAlpha * 127)); + } + + // Try to convert an array with three valid numbers to the corresponding hex array + // This is currenly only used in processing the colors for barplots in order to be able + // to handle the case where the color might be specified as an array of colros as well. + // In that case we must be able to find out if an array of values should be interpretated as + // a single color (specifeid as an RGB triple) + static function tryHexConversion($aColor) { + if( is_array( $aColor ) ) { + if( count( $aColor ) == 3 ) { + if( is_numeric($aColor[0]) && is_numeric($aColor[1]) && is_numeric($aColor[2]) ) { + if( ($aColor[0] >= 0 && $aColor[0] <= 255) && + ($aColor[1] >= 0 && $aColor[1] <= 255) && + ($aColor[2] >= 0 && $aColor[2] <= 255) ) { + return sprintf('#%02x%02x%02x',$aColor[0],$aColor[1],$aColor[2]); + } + } + } + } + return $aColor; + } + + // Return a RGB tripple corresponding to a position in the normal light spectrum + // The argumen values is in the range [0, 1] where a value of 0 correponds to blue and + // a value of 1 corresponds to red. Values in betwen is mapped to a linear interpolation + // of the constituting colors in the visible color spectra. + // The $aDynamicRange specified how much of the dynamic range we shold use + // a value of 1.0 give the full dyanmic range and a lower value give more dark + // colors. In the extreme of 0.0 then all colors will be black. + static function GetSpectrum($aVal,$aDynamicRange=1.0) { + if( $aVal < 0 || $aVal > 1.0001 ) { + return array(0,0,0); // Invalid case - just return black + } + + $sat = round(255*$aDynamicRange); + $a = 0.25; + if( $aVal <= 0.25 ) { + return array(0, round($sat*$aVal/$a), $sat); + } + elseif( $aVal <= 0.5 ) { + return array(0, $sat, round($sat-$sat*($aVal-0.25)/$a)); + } + elseif( $aVal <= 0.75 ) { + return array(round($sat*($aVal-0.5)/$a), $sat, 0); + } + else { + return array($sat, round($sat-$sat*($aVal-0.75)/$a), 0); + } + } + +} // Class + +?> diff --git a/html/jpgraph/jpgraph_scatter.php b/html/jpgraph/jpgraph_scatter.php new file mode 100644 index 0000000..fe987c2 --- /dev/null +++ b/html/jpgraph/jpgraph_scatter.php @@ -0,0 +1,242 @@ +<?php +/*======================================================================= + // File: JPGRAPH_SCATTER.PHP + // Description: Scatter (and impuls) plot extension for JpGraph + // Created: 2001-02-11 + // Ver: $Id: jpgraph_scatter.php 1397 2009-06-27 21:34:14Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ +require_once ('jpgraph_plotmark.inc.php'); + +//=================================================== +// CLASS FieldArrow +// Description: Draw an arrow at (x,y) with angle a +//=================================================== +class FieldArrow { + public $iColor='black'; + public $iSize=10; // Length in pixels for arrow + public $iArrowSize = 2; + private $isizespec = array( + array(2,1),array(3,2),array(4,3),array(6,4),array(7,4),array(8,5),array(10,6),array(12,7),array(16,8),array(20,10) + ); + function __construct() { + // Empty + } + + function SetSize($aSize,$aArrowSize=2) { + $this->iSize = $aSize; + $this->iArrowSize = $aArrowSize; + } + + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function Stroke($aImg,$x,$y,$a) { + // First rotate the center coordinates + list($x,$y) = $aImg->Rotate($x,$y); + + $old_origin = $aImg->SetCenter($x,$y); + $old_a = $aImg->a; + $aImg->SetAngle(-$a+$old_a); + + $dx = round($this->iSize/2); + $c = array($x-$dx,$y,$x+$dx,$y); + $x += $dx; + + list($dx,$dy) = $this->isizespec[$this->iArrowSize]; + $ca = array($x,$y,$x-$dx,$y-$dy,$x-$dx,$y+$dy,$x,$y); + + $aImg->SetColor($this->iColor); + $aImg->Polygon($c); + $aImg->FilledPolygon($ca); + + $aImg->SetCenter($old_origin[0],$old_origin[1]); + $aImg->SetAngle($old_a); + } +} + +//=================================================== +// CLASS FieldPlot +// Description: Render a field plot +//=================================================== +class FieldPlot extends Plot { + public $arrow = ''; + private $iAngles = array(); + private $iCallback = ''; + + function __construct($datay,$datax,$angles) { + if( (count($datax) != count($datay)) ) + JpGraphError::RaiseL(20001);//("Fieldplots must have equal number of X and Y points."); + if( (count($datax) != count($angles)) ) + JpGraphError::RaiseL(20002);//("Fieldplots must have an angle specified for each X and Y points."); + + $this->iAngles = $angles; + + parent::__construct($datay,$datax); + $this->value->SetAlign('center','center'); + $this->value->SetMargin(15); + + $this->arrow = new FieldArrow(); + } + + function SetCallback($aFunc) { + $this->iCallback = $aFunc; + } + + function Stroke($img,$xscale,$yscale) { + + // Remeber base color and size + $bc = $this->arrow->iColor; + $bs = $this->arrow->iSize; + $bas = $this->arrow->iArrowSize; + + for( $i=0; $i<$this->numpoints; ++$i ) { + // Skip null values + if( $this->coords[0][$i]==="" ) + continue; + + $f = $this->iCallback; + if( $f != "" ) { + list($cc,$cs,$cas) = call_user_func($f,$this->coords[1][$i],$this->coords[0][$i],$this->iAngles[$i]); + // Fall back on global data if the callback isn't set + if( $cc == "" ) $cc = $bc; + if( $cs == "" ) $cs = $bs; + if( $cas == "" ) $cas = $bas; + $this->arrow->SetColor($cc); + $this->arrow->SetSize($cs,$cas); + } + + $xt = $xscale->Translate($this->coords[1][$i]); + $yt = $yscale->Translate($this->coords[0][$i]); + + $this->arrow->Stroke($img,$xt,$yt,$this->iAngles[$i]); + $this->value->Stroke($img,$this->coords[0][$i],$xt,$yt); + } + } + + // Framework function + function Legend($aGraph) { + if( $this->legend != "" ) { + $aGraph->legend->Add($this->legend,$this->mark->fill_color,$this->mark,0, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + } +} + +//=================================================== +// CLASS ScatterPlot +// Description: Render X and Y plots +//=================================================== +class ScatterPlot extends Plot { + public $mark,$link; + private $impuls = false; + //--------------- + // CONSTRUCTOR + function __construct($datay,$datax=false) { + if( (count($datax) != count($datay)) && is_array($datax)) { + JpGraphError::RaiseL(20003);//("Scatterplot must have equal number of X and Y points."); + } + parent::__construct($datay,$datax); + $this->mark = new PlotMark(); + $this->mark->SetType(MARK_SQUARE); + $this->mark->SetColor($this->color); + $this->value->SetAlign('center','center'); + $this->value->SetMargin(0); + $this->link = new LineProperty(1,'black','solid'); + $this->link->iShow = false; + } + + //--------------- + // PUBLIC METHODS + function SetImpuls($f=true) { + $this->impuls = $f; + } + + function SetStem($f=true) { + $this->impuls = $f; + } + + // Combine the scatter plot points with a line + function SetLinkPoints($aFlag=true,$aColor="black",$aWeight=1,$aStyle='solid') { + $this->link->iShow = $aFlag; + $this->link->iColor = $aColor; + $this->link->iWeight = $aWeight; + $this->link->iStyle = $aStyle; + } + + function Stroke($img,$xscale,$yscale) { + + $ymin=$yscale->scale_abs[0]; + if( $yscale->scale[0] < 0 ) + $yzero=$yscale->Translate(0); + else + $yzero=$yscale->scale_abs[0]; + + $this->csimareas = ''; + for( $i=0; $i<$this->numpoints; ++$i ) { + + // Skip null values + if( $this->coords[0][$i]==='' || $this->coords[0][$i]==='-' || $this->coords[0][$i]==='x') + continue; + + if( isset($this->coords[1]) ) + $xt = $xscale->Translate($this->coords[1][$i]); + else + $xt = $xscale->Translate($i); + $yt = $yscale->Translate($this->coords[0][$i]); + + + if( $this->link->iShow && isset($yt_old) ) { + $img->SetColor($this->link->iColor); + $img->SetLineWeight($this->link->iWeight); + $old = $img->SetLineStyle($this->link->iStyle); + $img->StyleLine($xt_old,$yt_old,$xt,$yt); + $img->SetLineStyle($old); + } + + if( $this->impuls ) { + $img->SetColor($this->color); + $img->SetLineWeight($this->weight); + $img->Line($xt,$yzero,$xt,$yt); + } + + if( !empty($this->csimtargets[$i]) ) { + if( !empty($this->csimwintargets[$i]) ) { + $this->mark->SetCSIMTarget($this->csimtargets[$i],$this->csimwintargets[$i]); + } + else { + $this->mark->SetCSIMTarget($this->csimtargets[$i]); + } + $this->mark->SetCSIMAlt($this->csimalts[$i]); + } + + if( isset($this->coords[1]) ) { + $this->mark->SetCSIMAltVal($this->coords[0][$i],$this->coords[1][$i]); + } + else { + $this->mark->SetCSIMAltVal($this->coords[0][$i],$i); + } + + $this->mark->Stroke($img,$xt,$yt); + + $this->csimareas .= $this->mark->GetCSIMAreas(); + $this->value->Stroke($img,$this->coords[0][$i],$xt,$yt); + + $xt_old = $xt; + $yt_old = $yt; + } + } + + // Framework function + function Legend($aGraph) { + if( $this->legend != "" ) { + $aGraph->legend->Add($this->legend,$this->mark->fill_color,$this->mark,0, + $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); + } + } +} // Class +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_stock.php b/html/jpgraph/jpgraph_stock.php new file mode 100644 index 0000000..88c4208 --- /dev/null +++ b/html/jpgraph/jpgraph_stock.php @@ -0,0 +1,198 @@ +<?php +/*======================================================================= + // File: JPGRAPH_STOCK.PHP + // Description: Stock plot extension for JpGraph + // Created: 2003-01-27 + // Ver: $Id: jpgraph_stock.php 1364 2009-06-24 07:07:44Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +//=================================================== +// CLASS StockPlot +//=================================================== +class StockPlot extends Plot { + protected $iTupleSize = 4; + private $iWidth=9; + private $iEndLines=1; + private $iStockColor1='white',$iStockColor2='darkred',$iStockColor3='darkred'; + //--------------- + // CONSTRUCTOR + function __construct($datay,$datax=false) { + if( count($datay) % $this->iTupleSize ) { + JpGraphError::RaiseL(21001,$this->iTupleSize); + //('Data values for Stock charts must contain an even multiple of '.$this->iTupleSize.' data points.'); + } + parent::__construct($datay,$datax); + $this->numpoints /= $this->iTupleSize; + } + //--------------- + // PUBLIC METHODS + + function SetColor($aColor,$aColor1='white',$aColor2='darkred',$aColor3='darkred') { + $this->color = $aColor; + $this->iStockColor1 = $aColor1; + $this->iStockColor2 = $aColor2; + $this->iStockColor3 = $aColor3; + } + + function SetWidth($aWidth) { + // Make sure it's odd + $this->iWidth = 2*floor($aWidth/2)+1; + } + + function HideEndLines($aHide=true) { + $this->iEndLines = !$aHide; + } + + // Gets called before any axis are stroked + function PreStrokeAdjust($graph) { + if( $this->center ) { + $a=0.5; $b=0.5; + $this->numpoints++; + } else { + $a=0; $b=0; + } + $graph->xaxis->scale->ticks->SetXLabelOffset($a); + $graph->SetTextScaleOff($b); + } + + // Method description + function Stroke($img,$xscale,$yscale) { + $n=$this->numpoints; + if( $this->center ) $n--; + if( isset($this->coords[1]) ) { + if( count($this->coords[1])!=$n ) { + JpGraphError::RaiseL(2003,count($this->coords[1]),$n); + // ("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints"); + } + else { + $exist_x = true; + } + } + else { + $exist_x = false; + } + + if( $exist_x ) { + $xs=$this->coords[1][0]; + } + else { + $xs=0; + } + + $ts = $this->iTupleSize; + $this->csimareas = ''; + for( $i=0; $i<$n; ++$i) { + + //If value is NULL, then don't draw a bar at all + if ($this->coords[0][$i*$ts] === null) continue; + + if( $exist_x ) { + $x=$this->coords[1][$i]; + if ($x === null) continue; + } + else { + $x=$i; + } + $xt = $xscale->Translate($x); + + $neg = $this->coords[0][$i*$ts] > $this->coords[0][$i*$ts+1] ; + $yopen = $yscale->Translate($this->coords[0][$i*$ts]); + $yclose = $yscale->Translate($this->coords[0][$i*$ts+1]); + $ymin = $yscale->Translate($this->coords[0][$i*$ts+2]); + $ymax = $yscale->Translate($this->coords[0][$i*$ts+3]); + + $dx = floor($this->iWidth/2); + $xl = $xt - $dx; + $xr = $xt + $dx; + + if( $neg ) { + $img->SetColor($this->iStockColor3); + } + else { + $img->SetColor($this->iStockColor1); + } + $img->FilledRectangle($xl,$yopen,$xr,$yclose); + $img->SetLineWeight($this->weight); + if( $neg ) { + $img->SetColor($this->iStockColor2); + } + else { + $img->SetColor($this->color); + } + + $img->Rectangle($xl,$yopen,$xr,$yclose); + + if( $yopen < $yclose ) { + $ytop = $yopen ; + $ybottom = $yclose ; + } + else { + $ytop = $yclose ; + $ybottom = $yopen ; + } + $img->SetColor($this->color); + $img->Line($xt,$ytop,$xt,$ymax); + $img->Line($xt,$ybottom,$xt,$ymin); + + if( $this->iEndLines ) { + $img->Line($xl,$ymax,$xr,$ymax); + $img->Line($xl,$ymin,$xr,$ymin); + } + + // A chance for subclasses to add things to the bar + // for data point i + $this->ModBox($img,$xscale,$yscale,$i,$xl,$xr,$neg); + + // Setup image maps + if( !empty($this->csimtargets[$i]) ) { + $this->csimareas.= '<area shape="rect" coords="'. + round($xl).','.round($ytop).','. + round($xr).','.round($ybottom).'" '; + $this->csimareas .= ' href="'.$this->csimtargets[$i].'"'; + if( !empty($this->csimalts[$i]) ) { + $sval=$this->csimalts[$i]; + $this->csimareas .= " title=\"$sval\" alt=\"$sval\" "; + } + $this->csimareas.= " />\n"; + } + } + return true; + } + + // A hook for subclasses to modify the plot + function ModBox($img,$xscale,$yscale,$i,$xl,$xr,$neg) {} + +} // Class + +//=================================================== +// CLASS BoxPlot +//=================================================== +class BoxPlot extends StockPlot { + private $iPColor='black',$iNColor='white'; + + function __construct($datay,$datax=false) { + $this->iTupleSize=5; + parent::__construct($datay,$datax); + } + + function SetMedianColor($aPos,$aNeg) { + $this->iPColor = $aPos; + $this->iNColor = $aNeg; + } + + function ModBox($img,$xscale,$yscale,$i,$xl,$xr,$neg) { + if( $neg ) + $img->SetColor($this->iNColor); + else + $img->SetColor($this->iPColor); + + $y = $yscale->Translate($this->coords[0][$i*5+4]); + $img->Line($xl,$y,$xr,$y); + } +} + +/* EOF */ +?> diff --git a/html/jpgraph/jpgraph_table.php b/html/jpgraph/jpgraph_table.php new file mode 100644 index 0000000..852d78b --- /dev/null +++ b/html/jpgraph/jpgraph_table.php @@ -0,0 +1,1325 @@ +<?php +/*======================================================================= + // File: JPGRAPH_TABLE.PHP + // Description: Classes to create basic tables of data + // Created: 2006-01-25 + // Ver: $Id: jpgraph_table.php 1514 2009-07-07 11:15:58Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +// Style of grid lines in table +DEFINE('TGRID_SINGLE',1); +DEFINE('TGRID_DOUBLE',2); +DEFINE('TGRID_DOUBLE2',3); + +// Type of constrain for image constrain +DEFINE('TIMG_WIDTH',1); +DEFINE('TIMG_HEIGHT',2); + +//--------------------------------------------------------------------- +// CLASS GTextTableCell +// Description: +// Internal class that represents each cell in the table +//--------------------------------------------------------------------- +class GTextTableCell { + public $iColSpan=1,$iRowSpan=1; + public $iMarginLeft=5,$iMarginRight=5,$iMarginTop=5,$iMarginBottom=5; + public $iVal=NULL; + private $iBGColor='', $iFontColor='black'; + private $iFF=FF_FONT1,$iFS=FS_NORMAL,$iFSize=10; + private $iRow=0, $iCol=0; + private $iVertAlign = 'bottom', $iHorAlign = 'left'; + private $iMerged=FALSE,$iPRow=NULL,$iPCol=NULL; + private $iTable=NULL; + private $iGridColor=array('darkgray','darkgray','darkgray','darkgray'); + private $iGridWeight=array(1,1,0,0); // left,top,bottom,right; + private $iGridStyle=array(TGRID_SINGLE,TGRID_SINGLE,TGRID_SINGLE,TGRID_SINGLE); // left,top,bottom,right; + private $iNumberFormat=null; + private $iIcon=null, $iIconConstrain=array(); + private $iCSIMtarget = '',$iCSIMwintarget = '', $iCSIMalt = '', $iCSIMArea = ''; + + function __construct($aVal='',$aRow=0,$aCol=0) { + $this->iVal = new Text($aVal); + $this->iRow = $aRow; + $this->iCol = $aCol; + $this->iPRow = $aRow; // Initialiy each cell is its own parent + $this->iPCol = $aCol; + $this->iIconConstrain = array(-1,-1); + } + + function Init($aTable) { + $this->iTable = $aTable; + } + + function SetCSIMTarget($aTarget,$aAlt='',$aWinTarget='') { + $this->iCSIMtarget = $aTarget; + $this->iCSIMwintarget = $aWinTarget; + $this->iCSIMalt = $aAlt; + } + + function GetCSIMArea() { + if( $this->iCSIMtarget !== '' ) + return $this->iCSIMArea; + else + return ''; + } + + function SetImageConstrain($aType,$aVal) { + if( !in_array($aType,array(TIMG_WIDTH, TIMG_HEIGHT)) ) { + JpGraphError::RaiseL(27015); + } + $this->iIconConstrain = array($aType,$aVal); + } + + function SetCountryFlag($aFlag,$aScale=1.0,$aMix=100,$aStdSize=3) { + $this->iIcon = new IconPlot(); + $this->iIcon->SetCountryFlag($aFlag,0,0,$aScale,$aMix,$aStdSize); + } + + function SetImage($aFile,$aScale=1.0,$aMix=100) { + $this->iIcon = new IconPlot($aFile,0,0,$aScale,$aMix); + } + + function SetImageFromString($aStr,$aScale=1.0,$aMix=100) { + $this->iIcon = new IconPlot("",0,0,$aScale,$aMix); + $this->iIcon->CreateFromString($aStr); + } + + function SetRowColSpan($aRowSpan,$aColSpan) { + $this->iRowSpan = $aRowSpan; + $this->iColSpan = $aColSpan; + $this->iMerged = true; + } + + function SetMerged($aPRow,$aPCol,$aFlg=true) { + $this->iMerged = $aFlg; + $this->iPRow=$aPRow; + $this->iPCol=$aPCol; + } + + function IsMerged() { + return $this->iMerged; + } + + function SetNumberFormat($aF) { + $this->iNumberFormat = $aF; + } + + function Set($aTxt) { + $this->iVal->Set($aTxt); + } + + function SetFont($aFF,$aFS,$aFSize) { + $this->iFF = $aFF; + $this->iFS = $aFS; + $this->iFSize = $aFSize; + $this->iVal->SetFont($aFF,$aFS,$aFSize); + } + + function SetFillColor($aColor) { + $this->iBGColor=$aColor; + } + + function SetFontColor($aColor) { + $this->iFontColor=$aColor; + } + + function SetGridColor($aLeft,$aTop=null,$aBottom=null,$aRight=null) { + if( $aLeft !== null ) $this->iGridColor[0] = $aLeft; + if( $aTop !== null ) $this->iGridColor[1] = $aTop; + if( $aBottom !== null ) $this->iGridColor[2] = $aBottom; + if( $aRight !== null )$this->iGridColor[3] = $aRight; + } + + function SetGridStyle($aLeft,$aTop=null,$aBottom=null,$aRight=null) { + if( $aLeft !== null ) $this->iGridStyle[0] = $aLeft; + if( $aTop !== null ) $this->iGridStyle[1] = $aTop; + if( $aBottom !== null ) $this->iGridStyle[2] = $aBottom; + if( $aRight !== null )$this->iGridStyle[3] = $aRight; + } + + function SetGridWeight($aLeft=null,$aTop=null,$aBottom=null,$aRight=null) { + if( $aLeft !== null ) $this->iGridWeight[0] = $aLeft; + if( $aTop !== null ) $this->iGridWeight[1] = $aTop; + if( $aBottom !== null ) $this->iGridWeight[2] = $aBottom; + if( $aRight !== null ) $this->iGridWeight[3] = $aRight; + } + + function SetMargin($aLeft,$aRight,$aTop,$aBottom) { + $this->iMarginLeft=$aLeft; + $this->iMarginRight=$aRight; + $this->iMarginTop=$aTop; + $this->iMarginBottom=$aBottom; + } + + function GetWidth($aImg) { + if( $this->iIcon !== null ) { + if( $this->iIconConstrain[0] == TIMG_WIDTH ) { + $this->iIcon->SetScale(1); + $tmp = $this->iIcon->GetWidthHeight(); + $this->iIcon->SetScale($this->iIconConstrain[1]/$tmp[0]); + } + elseif( $this->iIconConstrain[0] == TIMG_HEIGHT ) { + $this->iIcon->SetScale(1); + $tmp = $this->iIcon->GetWidthHeight(); + $this->iIcon->SetScale($this->iIconConstrain[1]/$tmp[1]); + } + $tmp = $this->iIcon->GetWidthHeight(); + $iwidth = $tmp[0]; + } + else { + $iwidth=0; + } + if( $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->dir == 0 ) { + $pwidth = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetWidth($aImg); + } + elseif( $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->dir == 90 ) { + $pwidth = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetFontHeight($aImg)+2; + } + else { + $pwidth = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetWidth($aImg)+2; + } + + $pcolspan = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iColSpan; + return round(max($iwidth,$pwidth)/$pcolspan) + $this->iMarginLeft + $this->iMarginRight; + } + + function GetHeight($aImg) { + if( $this->iIcon !== null ) { + if( $this->iIconConstrain[0] == TIMG_WIDTH ) { + $this->iIcon->SetScale(1); + $tmp = $this->iIcon->GetWidthHeight(); + $this->iIcon->SetScale($this->iIconConstrain[1]/$tmp[0]); + } + elseif( $this->iIconConstrain[0] == TIMG_HEIGHT ) { + $this->iIcon->SetScale(1); + $tmp = $this->iIcon->GetWidthHeight(); + $this->iIcon->SetScale($this->iIconConstrain[1]/$tmp[1]); + } + $tmp = $this->iIcon->GetWidthHeight(); + $iheight = $tmp[1]; + } + else { + $iheight = 0; + } + if( $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->dir == 0 ) { + $pheight = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetHeight($aImg); + } + else { + $pheight = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetHeight($aImg)+1; + } + $prowspan = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iRowSpan; + return round(max($iheight,$pheight)/$prowspan) + $this->iMarginTop + $this->iMarginBottom; + } + + function SetAlign($aHorAlign='left',$aVertAlign='bottom') { + $aHorAlign = strtolower($aHorAlign); + $aVertAlign = strtolower($aVertAlign); + $chk = array('left','right','center','bottom','top','middle'); + if( !in_array($aHorAlign,$chk) || !in_array($aVertAlign,$chk) ) { + JpGraphError::RaiseL(27011,$aHorAlign,$aVertAlign); + } + $this->iVertAlign = $aVertAlign; + $this->iHorAlign = $aHorAlign; + } + + function AdjustMarginsForGrid() { + if( $this->iCol > 0 ) { + switch( $this->iGridStyle[0] ) { + case TGRID_SINGLE: $wf=1; break; + case TGRID_DOUBLE: $wf=3; break; + case TGRID_DOUBLE2: $wf=4; break; + } + $this->iMarginLeft += $this->iGridWeight[0]*$wf; + } + if( $this->iRow > 0 ) { + switch( $this->iGridStyle[1] ) { + case TGRID_SINGLE: $wf=1; break; + case TGRID_DOUBLE: $wf=3; break; + case TGRID_DOUBLE2: $wf=4; break; + } + $this->iMarginTop += $this->iGridWeight[1]*$wf; + } + if( $this->iRow+$this->iRowSpan-1 < $this->iTable->iSize[0]-1 ) { + switch( $this->iGridStyle[2] ) { + case TGRID_SINGLE: $wf=1; break; + case TGRID_DOUBLE: $wf=3; break; + case TGRID_DOUBLE2: $wf=4; break; + } + $this->iMarginBottom += $this->iGridWeight[2]*$wf; + } + if( $this->iCol+$this->iColSpan-1 < $this->iTable->iSize[1]-1 ) { + switch( $this->iGridStyle[3] ) { + case TGRID_SINGLE: $wf=1; break; + case TGRID_DOUBLE: $wf=3; break; + case TGRID_DOUBLE2: $wf=4; break; + } + $this->iMarginRight += $this->iGridWeight[3]*$wf; + } + } + + function StrokeVGrid($aImg,$aX,$aY,$aWidth,$aHeight,$aDir=1) { + // Left or right grid line + // For the right we increase the X-pos and for the right we decrease it. This is + // determined by the direction argument. + $idx = $aDir==1 ? 0 : 3; + + // We don't stroke the grid lines that are on the edge of the table since this is + // the place of the border. + if( ( ($this->iCol > 0 && $idx==0) || ($this->iCol+$this->iColSpan-1 < $this->iTable->iSize[1]-1 && $idx==3) ) + && $this->iGridWeight[$idx] > 0 ) { + $x = $aDir==1 ? $aX : $aX + $aWidth-1; + $y = $aY+$aHeight-1; + $aImg->SetColor($this->iGridColor[$idx]); + switch( $this->iGridStyle[$idx] ) { + case TGRID_SINGLE: + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($x+$i*$aDir,$aY, $x+$i*$aDir,$y); + break; + + case TGRID_DOUBLE: + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($x+$i*$aDir,$aY, $x+$i*$aDir,$y); + $x += $this->iGridWeight[$idx]*2; + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($x+$i*$aDir,$aY, $x+$i*$aDir,$y); + break; + + case TGRID_DOUBLE2: + for( $i=0; $i < $this->iGridWeight[$idx]*2; ++$i ) + $aImg->Line($x+$i*$aDir,$aY,$x+$i*$aDir,$y); + $x += $this->iGridWeight[$idx]*3; + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($x+$i*$aDir,$aY, $x+$i*$aDir,$y); + break; + } + } + } + + function StrokeHGrid($aImg,$aX,$aY,$aWidth,$aHeight,$aDir=1) { + // Top or bottom grid line + // For the left we increase the X-pos and for the right we decrease it. This is + // determined by the direction argument. + $idx = $aDir==1 ? 1 : 2; + + // We don't stroke the grid lines that are on the edge of the table since this is + // the place of the border. + if( ( ($this->iRow > 0 && $idx==1) || ($this->iRow+$this->iRowSpan-1 < $this->iTable->iSize[0]-1 && $idx==2) ) + && $this->iGridWeight[$idx] > 0) { + $y = $aDir==1 ? $aY : $aY+$aHeight-1; + $x = $aX+$aWidth-1; + $aImg->SetColor($this->iGridColor[$idx]); + switch( $this->iGridStyle[$idx] ) { + case TGRID_SINGLE: + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($aX,$y+$i, $x,$y+$i); + break; + + case TGRID_DOUBLE: + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($aX,$y+$i, $x,$y+$i); + $y += $this->iGridWeight[$idx]*2; + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($aX,$y+$i, $x,$y+$i); + break; + + case TGRID_DOUBLE2: + for( $i=0; $i < $this->iGridWeight[$idx]*2; ++$i ) + $aImg->Line($aX,$y+$i, $x,$y+$i); + $y += $this->iGridWeight[$idx]*3; + for( $i=0; $i < $this->iGridWeight[$idx]; ++$i ) + $aImg->Line($aX,$y+$i, $x,$y+$i); + break; + } + } + } + + function Stroke($aImg,$aX,$aY,$aWidth,$aHeight) { + // If this is a merged cell we only stroke if it is the parent cell. + // The parent cell holds the merged cell block + if( $this->iMerged && ($this->iRow != $this->iPRow || $this->iCol != $this->iPCol) ) { + return; + } + + if( $this->iBGColor != '' ) { + $aImg->SetColor($this->iBGColor); + $aImg->FilledRectangle($aX,$aY,$aX+$aWidth-1,$aY+$aHeight-1); + } + + $coords = $aX.','.$aY.','.($aX+$aWidth-1).','.$aY.','.($aX+$aWidth-1).','.($aY+$aHeight-1).','.$aX.','.($aY+$aHeight-1); + if( ! empty($this->iCSIMtarget) ) { + $this->iCSIMArea = '<area shape="poly" coords="'.$coords.'" href="'.$this->iCSIMtarget.'"'; + if( ! empty($this->iCSIMwintarget) ) { + $this->iCSIMArea .= " target=\"".$this->iCSIMwintarget."\""; + } + if( ! empty($this->iCSIMalt) ) { + $this->iCSIMArea .= ' alt="'.$this->iCSIMalt.'" title="'.$this->iCSIMalt."\" "; + } + $this->iCSIMArea .= " />\n"; + } + + $this->StrokeVGrid($aImg,$aX,$aY,$aWidth,$aHeight); + $this->StrokeVGrid($aImg,$aX,$aY,$aWidth,$aHeight,-1); + $this->StrokeHGrid($aImg,$aX,$aY,$aWidth,$aHeight); + $this->StrokeHGrid($aImg,$aX,$aY,$aWidth,$aHeight,-1); + + if( $this->iIcon !== null ) { + switch( $this->iHorAlign ) { + case 'left': + $x = $aX+$this->iMarginLeft; + $hanchor='left'; + break; + case 'center': + case 'middle': + $x = $aX+$this->iMarginLeft+round(($aWidth-$this->iMarginLeft-$this->iMarginRight)/2); + $hanchor='center'; + break; + case 'right': + $x = $aX+$aWidth-$this->iMarginRight-1; + $hanchor='right'; + break; + default: + JpGraphError::RaiseL(27012,$this->iHorAlign); + } + + switch( $this->iVertAlign ) { + case 'top': + $y = $aY+$this->iMarginTop; + $vanchor='top'; + break; + case 'center': + case 'middle': + $y = $aY+$this->iMarginTop+round(($aHeight-$this->iMarginTop-$this->iMarginBottom)/2); + $vanchor='center'; + break; + case 'bottom': + $y = $aY+$aHeight-1-$this->iMarginBottom; + $vanchor='bottom'; + break; + default: + JpGraphError::RaiseL(27012,$this->iVertAlign); + } + $this->iIcon->SetAnchor($hanchor,$vanchor); + $this->iIcon->_Stroke($aImg,$x,$y); + } + $this->iVal->SetColor($this->iFontColor); + $this->iVal->SetFont($this->iFF,$this->iFS,$this->iFSize); + switch( $this->iHorAlign ) { + case 'left': + $x = $aX+$this->iMarginLeft; + break; + case 'center': + case 'middle': + $x = $aX+$this->iMarginLeft+round(($aWidth-$this->iMarginLeft-$this->iMarginRight)/2); + break; + case 'right': + $x = $aX+$aWidth-$this->iMarginRight-1; + break; + default: + JpGraphError::RaiseL(27012,$this->iHorAlign); + } + // A workaround for the shortcomings in the TTF font handling in GD + // The anchor position for rotated text (=90) is to "short" so we add + // an offset based on the actual font size + if( $this->iVal->dir != 0 && $this->iVal->font_family >= 10 ) { + $aY += 4 + round($this->iVal->font_size*0.8); + } + switch( $this->iVertAlign ) { + case 'top': + $y = $aY+$this->iMarginTop; + break; + case 'center': + case 'middle': + $y = $aY+$this->iMarginTop+round(($aHeight-$this->iMarginTop-$this->iMarginBottom)/2); + //$y -= round($this->iVal->GetFontHeight($aImg)/2); + $y -= round($this->iVal->GetHeight($aImg)/2); + break; + case 'bottom': + //$y = $aY+$aHeight-1-$this->iMarginBottom-$this->iVal->GetFontHeight($aImg); + $y = $aY+$aHeight-$this->iMarginBottom-$this->iVal->GetHeight($aImg); + break; + default: + JpGraphError::RaiseL(27012,$this->iVertAlign); + } + $this->iVal->SetAlign($this->iHorAlign,'top'); + if( $this->iNumberFormat !== null && is_numeric($this->iVal->t) ) { + $this->iVal->t = sprintf($this->iNumberFormat,$this->iVal->t); + } + $this->iVal->Stroke($aImg,$x,$y); + } +} + +//--------------------------------------------------------------------- +// CLASS GTextTable +// Description: +// Graphic text table +//--------------------------------------------------------------------- +class GTextTable { + public $iCells = array(), $iSize=array(0,0); // Need to be public since they are used by the cell + private $iWidth=0, $iHeight=0; + private $iColWidth=NULL,$iRowHeight=NULL; + private $iImg=NULL; + private $iXPos=0, $iYPos=0; + private $iScaleXPos=null,$iScaleYPos=null; + private $iBGColor=''; + private $iBorderColor='black',$iBorderWeight=1; + private $iInit=false; + private $iYAnchor='top',$iXAnchor='left'; + /*----------------------------------------------------------------- + * First and second phase constructors + *----------------------------------------------------------------- + */ + function __construct() { + // Empty + } + + function Init($aRows=0,$aCols=0,$aFillText='') { + $this->iSize[0] = $aRows; + $this->iSize[1] = $aCols; + for($i=0; $i < $this->iSize[0]; ++$i) { + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$i][$j] = new GTextTableCell($aFillText,$i,$j); + $this->iCells[$i][$j]->Init($this); + } + } + $this->iInit=true; + } + + /*----------------------------------------------------------------- + * Outer border of table + *----------------------------------------------------------------- + */ + function SetBorder($aWeight=1,$aColor='black') { + $this->iBorderColor=$aColor; + $this->iBorderWeight = $aWeight; + } + + + /*----------------------------------------------------------------- + * Position in graph of table + *----------------------------------------------------------------- + */ + function SetPos($aX,$aY) { + $this->iXPos = $aX; + $this->iYPos = $aY; + } + + function SetScalePos($aX,$aY) { + $this->iScaleXPos = $aX; + $this->iScaleYPos = $aY; + } + + function SetAnchorPos($aXAnchor,$aYAnchor='top') { + $this->iXAnchor = $aXAnchor; + $this->iYAnchor = $aYAnchor; + } + + /*----------------------------------------------------------------- + * Setup country flag in a cell + *----------------------------------------------------------------- + */ + function SetCellCountryFlag($aRow,$aCol,$aFlag,$aScale=1.0,$aMix=100,$aStdSize=3) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetCountryFlag($aFlag,$aScale,$aMix,$aStdSize); + + } + + /*----------------------------------------------------------------- + * Setup image in a cell + *----------------------------------------------------------------- + */ + function SetCellImage($aRow,$aCol,$aFile,$aScale=1.0,$aMix=100) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetImage($aFile,$aScale,$aMix); + } + + function SetRowImage($aRow,$aFile,$aScale=1.0,$aMix=100) { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetImage($aFile,$aScale,$aMix); + } + } + + function SetColImage($aCol,$aFile,$aScale=1.0,$aMix=100) { + $this->_chkC($aCol); + for($j=0; $j < $this->iSize[0]; ++$j) { + $this->iCells[$j][$aCol]->SetImage($aFile,$aScale,$aMix); + } + } + + function SetImage($aFileR1,$aScaleC1=null,$aMixR2=null,$aC2=null,$aFile=null,$aScale=1.0,$aMix=100) { + if( $aScaleC1 !== null && $aMixR2!==null && $aC2!==null && $aFile!==null ) { + $this->_chkR($aArgR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + } + else { + if( $aScaleC1 !== null ) $aScale = $aScaleC1; + if( $aMixR2 !== null ) $aMix = $aMixR2; + $aFile = $aFileR1; + $aMixR2 = $this->iSize[0]-1; $aFileR1 = 0; + $aC2 = $this->iSize[1]-1; $aScaleC1 = 0; + } + for($i=$aArgR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->SetImage($aFile,$aScale,$aMix); + } + } + } + + function SetCellImageConstrain($aRow,$aCol,$aType,$aVal) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetImageConstrain($aType,$aVal); + } + + /*----------------------------------------------------------------- + * Generate a HTML version of the table + *----------------------------------------------------------------- + */ + function toString() { + $t = '<table border=1 cellspacing=0 cellpadding=0>'; + for($i=0; $i < $this->iSize[0]; ++$i) { + $t .= '<tr>'; + for($j=0; $j < $this->iSize[1]; ++$j) { + $t .= '<td>'; + if( $this->iCells[$i][$j]->iMerged ) + $t .= 'M '; + $t .= 'val='.$this->iCells[$i][$j]->iVal->t; + $t .= ' (cs='.$this->iCells[$i][$j]->iColSpan. + ', rs='.$this->iCells[$i][$j]->iRowSpan.')'; + $t .= '</td>'; + } + $t .= '</tr>'; + } + $t .= '</table>'; + return $t; + } + + /*----------------------------------------------------------------- + * Specify data for table + *----------------------------------------------------------------- + */ + function Set($aArg1,$aArg2=NULL,$aArg3=NULL) { + if( $aArg2===NULL && $aArg3===NULL ) { + if( is_array($aArg1) ) { + if( is_array($aArg1[0]) ) { + $m = count($aArg1); + // Find the longest row + $n=0; + for($i=0; $i < $m; ++$i) + $n = max(count($aArg1[$i]),$n); + for($i=0; $i < $m; ++$i) { + for($j=0; $j < $n; ++$j) { + if( isset($aArg1[$i][$j]) ){ + $this->_setcell($i,$j,(string)$aArg1[$i][$j]); + } + else { + $this->_setcell($i,$j); + } + } + } + $this->iSize[0] = $m; + $this->iSize[1] = $n; + $this->iInit=true; + } + else { + JpGraphError::RaiseL(27001); + //('Illegal argument to GTextTable::Set(). Array must be 2 dimensional'); + } + } + else { + JpGraphError::RaiseL(27002); + //('Illegal argument to GTextTable::Set()'); + } + } + else { + // Must be in the form (row,col,val) + $this->_chkR($aArg1); + $this->_chkC($aArg2); + $this->_setcell($aArg1,$aArg2,(string)$aArg3); + } + } + + /*--------------------------------------------------------------------- + * Cell margin setting + *--------------------------------------------------------------------- + */ + function SetPadding($aArgR1,$aC1=null,$aR2=null,$aC2=null,$aPad=null) { + if( $aC1 !== null && $aR2!==null && $aC2!==null && $aPad!==null ) { + $this->_chkR($aArgR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + } + else { + $aPad = $aArgR1; + $aR2 = $this->iSize[0]-1; $aArgR1 = 0; + $aC2 = $this->iSize[1]-1; $aC1 = 0; + } + for($i=$aArgR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->SetMargin($aPad,$aPad,$aPad,$aPad); + } + } + } + + function SetRowPadding($aRow,$aPad) { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetMargin($aPad,$aPad,$aPad,$aPad); + } + } + + function SetColPadding($aCol,$aPad) { + $this->_chkC($aCol); + for($j=0; $j < $this->iSize[0]; ++$j) { + $this->iCells[$j][$aCol]->SetMargin($aPad,$aPad,$aPad,$aPad); + } + } + + function SetCellPadding($aRow,$aCol,$aPad) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetMargin($aPad,$aPad,$aPad,$aPad); + } + + + /*--------------------------------------------------------------------- + * Cell text orientation setting + *--------------------------------------------------------------------- + */ + function SetTextOrientation($aArgR1,$aC1=null,$aR2=null,$aC2=null,$aO=null) { + if( $aC1 !== null && $aR2!==null && $aC2!==null && $aPad!==null ) { + $this->_chkR($aArgR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + } + else { + $aO = $aArgR1; + $aR2 = $this->iSize[0]-1; $aArgR1 = 0; + $aC2 = $this->iSize[1]-1; $aC1 = 0; + } + for($i=$aArgR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->iVal->SetOrientation($aO); + } + } + } + + function SetRowTextOrientation($aRow,$aO) { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->iVal->SetOrientation($aO); + } + } + + function SetColTextOrientation($aCol,$aO) { + $this->_chkC($aCol); + for($j=0; $j < $this->iSize[0]; ++$j) { + $this->iCells[$j][$aCol]->iVal->SetOrientation($aO); + } + } + + function SetCellTextOrientation($aRow,$aCol,$aO) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->iVal->SetOrientation($aO); + } + + + + + /*--------------------------------------------------------------------- + * Font color setting + *--------------------------------------------------------------------- + */ + + function SetColor($aArgR1,$aC1=null,$aR2=null,$aC2=null,$aArg=null) { + if( $aC1 !== null && $aR2!==null && $aC2!==null && $aArg!==null ) { + $this->_chkR($aArgR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + } + else { + $aArg = $aArgR1; + $aR2 = $this->iSize[0]-1; $aArgR1 = 0; + $aC2 = $this->iSize[1]-1; $aC1 = 0; + } + for($i=$aArgR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->SetFontColor($aArg); + } + } + } + + function SetRowColor($aRow,$aColor) { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetFontColor($aColor); + } + } + + function SetColColor($aCol,$aColor) { + $this->_chkC($aCol); + for($i=0; $i < $this->iSize[0]; ++$i) { + $this->iCells[$i][$aCol]->SetFontColor($aColor); + } + } + + function SetCellColor($aRow,$aCol,$aColor) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetFontColor($aColor); + } + + /*--------------------------------------------------------------------- + * Fill color settings + *--------------------------------------------------------------------- + */ + + function SetFillColor($aArgR1,$aC1=null,$aR2=null,$aC2=null,$aArg=null) { + if( $aC1 !== null && $aR2!==null && $aC2!==null && $aArg!==null ) { + $this->_chkR($aArgR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + for($i=$aArgR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->SetFillColor($aArg); + } + } + } + else { + $this->iBGColor = $aArgR1; + } + } + + function SetRowFillColor($aRow,$aColor) { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetFillColor($aColor); + } + } + + function SetColFillColor($aCol,$aColor) { + $this->_chkC($aCol); + for($i=0; $i < $this->iSize[0]; ++$i) { + $this->iCells[$i][$aCol]->SetFillColor($aColor); + } + } + + function SetCellFillColor($aRow,$aCol,$aColor) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetFillColor($aColor); + } + + /*--------------------------------------------------------------------- + * Font family setting + *--------------------------------------------------------------------- + */ + function SetFont() { + $numargs = func_num_args(); + if( $numargs == 2 || $numargs == 3 ) { + $aFF = func_get_arg(0); + $aFS = func_get_arg(1); + if( $numargs == 3 ) + $aFSize=func_get_arg(2); + else + $aFSize=10; + $aR2 = $this->iSize[0]-1; $aR1 = 0; + $aC2 = $this->iSize[1]-1; $aC1 = 0; + + } + elseif($numargs == 6 || $numargs == 7 ) { + $aR1 = func_get_arg(0); $aC1 = func_get_arg(1); + $aR2 = func_get_arg(2); $aC2 = func_get_arg(3); + $aFF = func_get_arg(4); $aFS = func_get_arg(5); + if( $numargs == 7 ) + $aFSize=func_get_arg(6); + else + $aFSize=10; + } + else { + JpGraphError::RaiseL(27003); + //('Wrong number of arguments to GTextTable::SetColor()'); + } + $this->_chkR($aR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + for($i=$aR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->SetFont($aFF,$aFS,$aFSize); + } + } + } + + function SetRowFont($aRow,$aFF,$aFS,$aFSize=10) { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetFont($aFF,$aFS,$aFSize); + } + } + + function SetColFont($aCol,$aFF,$aFS,$aFSize=10) { + $this->_chkC($aCol); + for($i=0; $i < $this->iSize[0]; ++$i) { + $this->iCells[$i][$aCol]->SetFont($aFF,$aFS,$aFSize); + } + } + + function SetCellFont($aRow,$aCol,$aFF,$aFS,$aFSize=10) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetFont($aFF,$aFS,$aFSize); + } + + /*--------------------------------------------------------------------- + * Cell align settings + *--------------------------------------------------------------------- + */ + + function SetAlign($aR1HAlign=null,$aC1VAlign=null,$aR2=null,$aC2=null,$aHArg=null,$aVArg='center') { + if( $aC1VAlign !== null && $aR2!==null && $aC2!==null && $aHArg!==null ) { + $this->_chkR($aR1HAlign); $this->_chkC($aC1VAlign); + $this->_chkR($aR2); $this->_chkC($aC2); + } + else { + if( $aR1HAlign === null ) { + JpGraphError::RaiseL(27010); + } + if( $aC1VAlign === null ) { + $aC1VAlign = 'center'; + } + $aHArg = $aR1HAlign; + $aVArg = $aC1VAlign === null ? 'center' : $aC1VAlign ; + $aR2 = $this->iSize[0]-1; $aR1HAlign = 0; + $aC2 = $this->iSize[1]-1; $aC1VAlign = 0; + } + for($i=$aR1HAlign; $i <= $aR2; ++$i) { + for($j=$aC1VAlign; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->SetAlign($aHArg,$aVArg); + } + } + } + + function SetCellAlign($aRow,$aCol,$aHorAlign,$aVertAlign='bottom') { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetAlign($aHorAlign,$aVertAlign); + } + + function SetRowAlign($aRow,$aHorAlign,$aVertAlign='bottom') { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetAlign($aHorAlign,$aVertAlign); + } + } + + function SetColAlign($aCol,$aHorAlign,$aVertAlign='bottom') { + $this->_chkC($aCol); + for($i=0; $i < $this->iSize[0]; ++$i) { + $this->iCells[$i][$aCol]->SetAlign($aHorAlign,$aVertAlign); + } + } + + /*--------------------------------------------------------------------- + * Cell number format + *--------------------------------------------------------------------- + */ + + function SetNumberFormat($aArgR1,$aC1=null,$aR2=null,$aC2=null,$aArg=null) { + if( $aC1 !== null && $aR2!==null && $aC2!==null && $aArg!==null ) { + $this->_chkR($aArgR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + } + else { + $aArg = $aArgR1; + $aR2 = $this->iSize[0]-1; $aArgR1 = 0; + $aC2 = $this->iSize[1]-1; $aC1 = 0; + } + if( !is_string($aArg) ) { + JpGraphError::RaiseL(27013); // argument must be a string + } + for($i=$aArgR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + $this->iCells[$i][$j]->SetNumberFormat($aArg); + } + } + } + + function SetRowNumberFormat($aRow,$aF) { + $this->_chkR($aRow); + if( !is_string($aF) ) { + JpGraphError::RaiseL(27013); // argument must be a string + } + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetNumberFormat($aF); + } + } + + function SetColNumberFormat($aCol,$aF) { + $this->_chkC($aCol); + if( !is_string($aF) ) { + JpGraphError::RaiseL(27013); // argument must be a string + } + for($i=0; $i < $this->iSize[0]; ++$i) { + $this->iCells[$i][$aCol]->SetNumberFormat($aF); + } + } + + function SetCellNumberFormat($aRow,$aCol,$aF) { + $this->_chkR($aRow); $this->_chkC($aCol); + if( !is_string($aF) ) { + JpGraphError::RaiseL(27013); // argument must be a string + } + $this->iCells[$aRow][$aCol]->SetNumberFormat($aF); + } + + /*--------------------------------------------------------------------- + * Set row and column min size + *--------------------------------------------------------------------- + */ + + function SetMinColWidth($aColWidth,$aWidth=null) { + // If there is only one argument this means that all + // columns get set to the same width + if( $aWidth===null ) { + for($i=0; $i < $this->iSize[1]; ++$i) { + $this->iColWidth[$i] = $aColWidth; + } + } + else { + $this->_chkC($aColWidth); + $this->iColWidth[$aColWidth] = $aWidth; + } + } + + function SetMinRowHeight($aRowHeight,$aHeight=null) { + // If there is only one argument this means that all + // rows get set to the same height + if( $aHeight===null ) { + for($i=0; $i < $this->iSize[0]; ++$i) { + $this->iRowHeight[$i] = $aRowHeight; + } + } + else { + $this->_chkR($aRowHeight); + $this->iRowHeight[$aRowHeight] = $aHeight; + } + } + + /*--------------------------------------------------------------------- + * Grid line settings + *--------------------------------------------------------------------- + */ + + function SetGrid($aWeight=1,$aColor='black',$aStyle=TGRID_SINGLE) { + $rc = $this->iSize[0]; + $cc = $this->iSize[1]; + for($i=0; $i < $rc; ++$i) { + for($j=0; $j < $cc; ++$j) { + $this->iCells[$i][$j]->SetGridColor($aColor,$aColor); + $this->iCells[$i][$j]->SetGridWeight($aWeight,$aWeight); + $this->iCells[$i][$j]->SetGridStyle($aStyle); + } + } + } + + function SetColGrid($aCol,$aWeight=1,$aColor='black',$aStyle=TGRID_SINGLE) { + $this->_chkC($aCol); + for($i=0; $i < $this->iSize[0]; ++$i) { + $this->iCells[$i][$aCol]->SetGridWeight($aWeight); + $this->iCells[$i][$aCol]->SetGridColor($aColor); + $this->iCells[$i][$aCol]->SetGridStyle($aStyle); + } + } + + function SetRowGrid($aRow,$aWeight=1,$aColor='black',$aStyle=TGRID_SINGLE) { + $this->_chkR($aRow); + for($j=0; $j < $this->iSize[1]; ++$j) { + $this->iCells[$aRow][$j]->SetGridWeight(NULL,$aWeight); + $this->iCells[$aRow][$j]->SetGridColor(NULL,$aColor); + $this->iCells[$aRow][$j]->SetGridStyle(NULL,$aStyle); + } + } + + /*--------------------------------------------------------------------- + * Merge cells + *--------------------------------------------------------------------- + */ + + function MergeRow($aRow,$aHAlign='center',$aVAlign='center') { + $this->_chkR($aRow); + $this->MergeCells($aRow,0,$aRow,$this->iSize[1]-1,$aHAlign,$aVAlign); + } + + function MergeCol($aCol,$aHAlign='center',$aVAlign='center') { + $this->_chkC($aCol); + $this->MergeCells(0,$aCol,$this->iSize[0]-1,$aCol,$aHAlign,$aVAlign); + } + + function MergeCells($aR1,$aC1,$aR2,$aC2,$aHAlign='center',$aVAlign='center') { + if( $aR1 > $aR2 || $aC1 > $aC2 ) { + JpGraphError::RaiseL(27004); + //('GTextTable::MergeCells(). Specified cell range to be merged is not valid.'); + } + $this->_chkR($aR1); $this->_chkC($aC1); + $this->_chkR($aR2); $this->_chkC($aC2); + $rspan = $aR2-$aR1+1; + $cspan = $aC2-$aC1+1; + // Setup the parent cell for this merged group + if( $this->iCells[$aR1][$aC1]->IsMerged() ) { + JpGraphError::RaiseL(27005,$aR1,$aC1,$aR2,$aC2); + //("Cannot merge already merged cells in the range ($aR1,$aC1), ($aR2,$aC2)"); + } + $this->iCells[$aR1][$aC1]->SetRowColSpan($rspan,$cspan); + $this->iCells[$aR1][$aC1]->SetAlign($aHAlign,$aVAlign); + for($i=$aR1; $i <= $aR2; ++$i) { + for($j=$aC1; $j <= $aC2; ++$j) { + if( ! ($i == $aR1 && $j == $aC1) ) { + if( $this->iCells[$i][$j]->IsMerged() ) { + JpGraphError::RaiseL(27005,$aR1,$aC1,$aR2,$aC2); + //("Cannot merge already merged cells in the range ($aR1,$aC1), ($aR2,$aC2)"); + } + $this->iCells[$i][$j]->SetMerged($aR1,$aC1,true); + } + } + } + } + + + /*--------------------------------------------------------------------- + * CSIM methods + *--------------------------------------------------------------------- + */ + + function SetCSIMTarget($aTarget,$aAlt=null,$aAutoTarget=false) { + $m = $this->iSize[0]; + $n = $this->iSize[1]; + $csim = ''; + for($i=0; $i < $m; ++$i) { + for($j=0; $j < $n; ++$j) { + if( $aAutoTarget ) + $t = $aTarget."?row=$i&col=$j"; + else + $t = $aTarget; + $this->iCells[$i][$j]->SetCSIMTarget($t,$aAlt); + } + } + } + + function SetCellCSIMTarget($aRow,$aCol,$aTarget,$aAlt=null) { + $this->_chkR($aRow); + $this->_chkC($aCol); + $this->iCells[$aRow][$aCol]->SetCSIMTarget($aTarget,$aAlt); + } + + /*--------------------------------------------------------------------- + * Private methods + *--------------------------------------------------------------------- + */ + + function GetCSIMAreas() { + $m = $this->iSize[0]; + $n = $this->iSize[1]; + $csim = ''; + for($i=0; $i < $m; ++$i) { + for($j=0; $j < $n; ++$j) { + $csim .= $this->iCells[$i][$j]->GetCSIMArea(); + } + } + return $csim; + } + + function _chkC($aCol) { + if( ! $this->iInit ) { + JpGraphError::Raise(27014); // Table not initialized + } + if( $aCol < 0 || $aCol >= $this->iSize[1] ) + JpGraphError::RaiseL(27006,$aCol); + //("GTextTable:\nColumn argument ($aCol) is outside specified table size."); + } + + function _chkR($aRow) { + if( ! $this->iInit ) { + JpGraphError::Raise(27014); // Table not initialized + } + if( $aRow < 0 || $aRow >= $this->iSize[0] ) + JpGraphError::RaiseL(27007,$aRow); + //("GTextTable:\nRow argument ($aRow) is outside specified table size."); + } + + function _getScalePos() { + if( $this->iScaleXPos === null || $this->iScaleYPos === null ) { + return false; + } + return array($this->iScaleXPos, $this->iScaleYPos); + } + + function _autoSizeTable($aImg) { + // Get maximum column width and row height + $m = $this->iSize[0]; + $n = $this->iSize[1]; + $w=1;$h=1; + + // Get maximum row height per row + for($i=0; $i < $m; ++$i) { + $h=0; + for($j=0; $j < $n; ++$j) { + $h = max($h,$this->iCells[$i][$j]->GetHeight($aImg)); + } + if( isset($this->iRowHeight[$i]) ) { + $this->iRowHeight[$i] = max($h,$this->iRowHeight[$i]); + } + else + $this->iRowHeight[$i] = $h; + } + + // Get maximum col width per columns + for($j=0; $j < $n; ++$j) { + $w=0; + for($i=0; $i < $m; ++$i) { + $w = max($w,$this->iCells[$i][$j]->GetWidth($aImg)); + } + if( isset($this->iColWidth[$j]) ) { + $this->iColWidth[$j] = max($w,$this->iColWidth[$j]); + } + else + $this->iColWidth[$j] = $w; + } + } + + function _setcell($aRow,$aCol,$aVal='') { + if( isset($this->iCells[$aRow][$aCol]) ) { + $this->iCells[$aRow][$aCol]->Set($aVal); + } + else { + $this->iCells[$aRow][$aCol] = new GTextTableCell((string)$aVal,$aRow,$aCol); + $this->iCells[$aRow][$aCol]->Init($this); + } + } + + function StrokeWithScale($aImg,$aXScale,$aYScale) { + if( is_numeric($this->iScaleXPos) && is_numeric($this->iScaleYPos) ) { + $x = round($aXScale->Translate($this->iScaleXPos)); + $y = round($aYScale->Translate($this->iScaleYPos)); + $this->Stroke($aImg,$x,$y); + } + else { + $this->Stroke($aImg); + } + } + + function Stroke($aImg,$aX=NULL,$aY=NULL) { + if( $aX !== NULL && $aY !== NULL ) { + $this->iXPos = $aX; + $this->iYPos = $aY; + } + + $rc = $this->iSize[0]; // row count + $cc = $this->iSize[1]; // column count + + if( $rc == 0 || $cc == 0 ) { + JpGraphError::RaiseL(27009); + } + + // Adjust margins of each cell based on the weight of the grid. Each table grid line + // is actually occupying the left side and top part of each cell. + for($j=0; $j < $cc; ++$j) { + $this->iCells[0][$j]->iMarginTop += $this->iBorderWeight; + } + for($i=0; $i < $rc; ++$i) { + $this->iCells[$i][0]->iMarginLeft += $this->iBorderWeight; + } + for($i=0; $i < $rc; ++$i) { + for($j=0; $j < $cc; ++$j) { + $this->iCells[$i][$j]->AdjustMarginsForGrid(); + } + } + + // adjust row and column size depending on cell content + $this->_autoSizeTable($aImg); + + if( $this->iSize[1] != count($this->iColWidth) || $this->iSize[0] != count($this->iRowHeight) ) { + JpGraphError::RaiseL(27008); + //('Column and row size arrays must match the dimesnions of the table'); + } + + // Find out overall table size + $width=0; + for($i=0; $i < $cc; ++$i) { + $width += $this->iColWidth[$i]; + } + $height=0; + for($i=0; $i < $rc; ++$i) { + $height += $this->iRowHeight[$i]; + } + + // Adjust the X,Y position to alway be at the top left corner + // The anchor position, i.e. how the client want to interpret the specified + // x and y coordinate must be taken into account + switch( strtolower($this->iXAnchor) ) { + case 'left' : + break; + case 'center': + $this->iXPos -= round($width/2); + break; + case 'right': + $this->iXPos -= $width; + break; + } + switch( strtolower($this->iYAnchor) ) { + case 'top' : + break; + case 'center': + case 'middle': + $this->iYPos -= round($height/2); + break; + case 'bottom': + $this->iYPos -= $height; + break; + } + + // Set the overall background color of the table if set + if( $this->iBGColor !== '' ) { + $aImg->SetColor($this->iBGColor); + $aImg->FilledRectangle($this->iXPos,$this->iYPos,$this->iXPos+$width,$this->iYPos+$height); + } + + // Stroke all cells + $rpos=$this->iYPos; + for($i=0; $i < $rc; ++$i) { + $cpos=$this->iXPos; + for($j=0; $j < $cc; ++$j) { + // Calculate width and height of this cell if it is spanning + // more than one column or row + $cwidth=0; + for( $k=0; $k < $this->iCells[$i][$j]->iColSpan; ++$k ) { + $cwidth += $this->iColWidth[$j+$k]; + } + $cheight=0; + for( $k=0; $k < $this->iCells[$i][$j]->iRowSpan; ++$k ) { + $cheight += $this->iRowHeight[$i+$k]; + } + + $this->iCells[$i][$j]->Stroke($aImg,$cpos,$rpos,$cwidth,$cheight); + $cpos += $this->iColWidth[$j]; + } + $rpos += $this->iRowHeight[$i]; + } + + // Stroke outer border + $aImg->SetColor($this->iBorderColor); + if( $this->iBorderWeight == 1 ) + $aImg->Rectangle($this->iXPos,$this->iYPos,$this->iXPos+$width,$this->iYPos+$height); + else { + for( $i=0; $i < $this->iBorderWeight; ++$i ) + $aImg->Rectangle($this->iXPos+$i,$this->iYPos+$i, + $this->iXPos+$width-1+$this->iBorderWeight-$i, + $this->iYPos+$height-1+$this->iBorderWeight-$i); + } + } +} + +/* + EOF + */ +?> diff --git a/html/jpgraph/jpgraph_text.inc.php b/html/jpgraph/jpgraph_text.inc.php new file mode 100644 index 0000000..7d0f668 --- /dev/null +++ b/html/jpgraph/jpgraph_text.inc.php @@ -0,0 +1,327 @@ +<?php +//======================================================================= +// File: JPGRAPH_TEXT.INC.PHP +// Description: Class to handle text as object in the graph. +// The low level text layout engine is handled by the GD class +// Created: 2001-01-08 (Refactored to separate file 2008-08-01) +// Ver: $Id: jpgraph_text.inc.php 1844 2009-09-26 17:05:31Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +//=================================================== +// CLASS Text +// Description: Arbitrary text object that can be added to the graph +//=================================================== +class Text { + public $t; + public $x=0,$y=0,$halign="left",$valign="top",$color=array(0,0,0); + public $hide=false, $dir=0; + public $iScalePosY=null,$iScalePosX=null; + public $iWordwrap=0; + public $font_family=FF_DEFAULT,$font_style=FS_NORMAL; // old. FF_FONT1 + protected $boxed=false; // Should the text be boxed + protected $paragraph_align="left"; + protected $icornerradius=0,$ishadowwidth=3; + protected $fcolor='white',$bcolor='black',$shadow=false; + protected $iCSIMarea='',$iCSIMalt='',$iCSIMtarget='',$iCSIMWinTarget=''; + private $iBoxType = 1; // Which variant of filled box around text we want + + // for __get, __set + private $_margin; + private $_font_size=8; // old. 12 + + //--------------- + // CONSTRUCTOR + + // Create new text at absolute pixel coordinates + function __construct($aTxt="",$aXAbsPos=0,$aYAbsPos=0) { + if( ! is_string($aTxt) ) { + JpGraphError::RaiseL(25050);//('First argument to Text::Text() must be s atring.'); + } + $this->t = $aTxt; + $this->x = round($aXAbsPos); + $this->y = round($aYAbsPos); + $this->margin = 0; + } + //--------------- + // PUBLIC METHODS + // Set the string in the text object + function Set($aTxt) { + $this->t = $aTxt; + } + + // Alias for Pos() + function SetPos($aXAbsPos=0,$aYAbsPos=0,$aHAlign="left",$aVAlign="top") { + //$this->Pos($aXAbsPos,$aYAbsPos,$aHAlign,$aVAlign); + $this->x = $aXAbsPos; + $this->y = $aYAbsPos; + $this->halign = $aHAlign; + $this->valign = $aVAlign; + } + + function SetScalePos($aX,$aY) { + $this->iScalePosX = $aX; + $this->iScalePosY = $aY; + } + + // Specify alignment for the text + function Align($aHAlign,$aVAlign="top",$aParagraphAlign="") { + $this->halign = $aHAlign; + $this->valign = $aVAlign; + if( $aParagraphAlign != "" ) + $this->paragraph_align = $aParagraphAlign; + } + + // Alias + function SetAlign($aHAlign,$aVAlign="top",$aParagraphAlign="") { + $this->Align($aHAlign,$aVAlign,$aParagraphAlign); + } + + // Specifies the alignment for a multi line text + function ParagraphAlign($aAlign) { + $this->paragraph_align = $aAlign; + } + + // Specifies the alignment for a multi line text + function SetParagraphAlign($aAlign) { + $this->paragraph_align = $aAlign; + } + + function SetShadow($aShadowColor='gray',$aShadowWidth=3) { + $this->ishadowwidth=$aShadowWidth; + $this->shadow=$aShadowColor; + $this->boxed=true; + } + + function SetWordWrap($aCol) { + $this->iWordwrap = $aCol ; + } + + // Specify that the text should be boxed. fcolor=frame color, bcolor=border color, + // $shadow=drop shadow should be added around the text. + function SetBox($aFrameColor=array(255,255,255),$aBorderColor=array(0,0,0),$aShadowColor=false,$aCornerRadius=4,$aShadowWidth=3) { + if( $aFrameColor === false ) { + $this->boxed=false; + } + else { + $this->boxed=true; + } + $this->fcolor=$aFrameColor; + $this->bcolor=$aBorderColor; + // For backwards compatibility when shadow was just true or false + if( $aShadowColor === true ) { + $aShadowColor = 'gray'; + } + $this->shadow=$aShadowColor; + $this->icornerradius=$aCornerRadius; + $this->ishadowwidth=$aShadowWidth; + } + + function SetBox2($aFrameColor=array(255,255,255),$aBorderColor=array(0,0,0),$aShadowColor=false,$aCornerRadius=4,$aShadowWidth=3) { + $this->iBoxType=2; + $this->SetBox($aFrameColor,$aBorderColor,$aShadowColor,$aCornerRadius,$aShadowWidth); + } + + // Hide the text + function Hide($aHide=true) { + $this->hide=$aHide; + } + + // This looks ugly since it's not a very orthogonal design + // but I added this "inverse" of Hide() to harmonize + // with some classes which I designed more recently (especially) + // jpgraph_gantt + function Show($aShow=true) { + $this->hide=!$aShow; + } + + // Specify font + function SetFont($aFamily,$aStyle=FS_NORMAL,$aSize=10) { + $this->font_family=$aFamily; + $this->font_style=$aStyle; + $this->font_size=$aSize; + } + + // Center the text between $left and $right coordinates + function Center($aLeft,$aRight,$aYAbsPos=false) { + $this->x = $aLeft + ($aRight-$aLeft )/2; + $this->halign = "center"; + if( is_numeric($aYAbsPos) ) + $this->y = $aYAbsPos; + } + + // Set text color + function SetColor($aColor) { + $this->color = $aColor; + } + + function SetAngle($aAngle) { + $this->SetOrientation($aAngle); + } + + // Orientation of text. Note only TTF fonts can have an arbitrary angle + function SetOrientation($aDirection=0) { + if( is_numeric($aDirection) ) + $this->dir=$aDirection; + elseif( $aDirection=="h" ) + $this->dir = 0; + elseif( $aDirection=="v" ) + $this->dir = 90; + else + JpGraphError::RaiseL(25051);//(" Invalid direction specified for text."); + } + + // Total width of text + function GetWidth($aImg) { + $aImg->SetFont($this->font_family,$this->font_style,$this->raw_font_size); + $w = $aImg->GetTextWidth($this->t,$this->dir); + return $w; + } + + // Hight of font + function GetFontHeight($aImg) { + $aImg->SetFont($this->font_family,$this->font_style,$this->raw_font_size); + $h = $aImg->GetFontHeight(); + return $h; + + } + + function GetTextHeight($aImg) { + $aImg->SetFont($this->font_family,$this->font_style,$this->raw_font_size); + $h = $aImg->GetTextHeight($this->t,$this->dir); + return $h; + } + + function GetHeight($aImg) { + // Synonym for GetTextHeight() + $aImg->SetFont($this->font_family,$this->font_style,$this->raw_font_size); + $h = $aImg->GetTextHeight($this->t,$this->dir); + return $h; + } + + // Set the margin which will be interpretated differently depending + // on the context. + function SetMargin($aMarg) { + $this->margin = $aMarg; + } + + function StrokeWithScale($aImg,$axscale,$ayscale) { + if( $this->iScalePosX === null || $this->iScalePosY === null ) { + $this->Stroke($aImg); + } + else { + $this->Stroke($aImg, + round($axscale->Translate($this->iScalePosX)), + round($ayscale->Translate($this->iScalePosY))); + } + } + + function SetCSIMTarget($aURITarget,$aAlt='',$aWinTarget='') { + $this->iCSIMtarget = $aURITarget; + $this->iCSIMalt = $aAlt; + $this->iCSIMWinTarget = $aWinTarget; + } + + function GetCSIMareas() { + if( $this->iCSIMtarget !== '' ) { + return $this->iCSIMarea; + } + else { + return ''; + } + } + + // Display text in image + function Stroke($aImg,$x=null,$y=null) { + + if( $x !== null ) $this->x = round($x); + if( $y !== null ) $this->y = round($y); + + // Insert newlines + if( $this->iWordwrap > 0 ) { + $this->t = wordwrap($this->t,$this->iWordwrap,"\n"); + } + + // If position been given as a fraction of the image size + // calculate the absolute position + if( $this->x < 1 && $this->x > 0 ) $this->x *= $aImg->width; + if( $this->y < 1 && $this->y > 0 ) $this->y *= $aImg->height; + + $aImg->PushColor($this->color); + $aImg->SetFont($this->font_family,$this->font_style,$this->raw_font_size); + $aImg->SetTextAlign($this->halign,$this->valign); + + if( $this->boxed ) { + if( $this->fcolor=="nofill" ) { + $this->fcolor=false; + } + + $oldweight=$aImg->SetLineWeight(1); + + if( $this->iBoxType == 2 && $this->font_family > FF_FONT2+2 ) { + + $bbox = $aImg->StrokeBoxedText2($this->x, $this->y, + $this->t, $this->dir, + $this->fcolor, + $this->bcolor, + $this->shadow, + $this->paragraph_align, + 2,4, + $this->icornerradius, + $this->ishadowwidth); + } + else { + $bbox = $aImg->StrokeBoxedText($this->x,$this->y,$this->t, + $this->dir,$this->fcolor,$this->bcolor,$this->shadow, + $this->paragraph_align,3,3,$this->icornerradius, + $this->ishadowwidth); + } + + $aImg->SetLineWeight($oldweight); + } + else { + $debug=false; + $bbox = $aImg->StrokeText($this->x,$this->y,$this->t,$this->dir,$this->paragraph_align,$debug); + } + + // Create CSIM targets + $coords = $bbox[0].','.$bbox[1].','.$bbox[2].','.$bbox[3].','.$bbox[4].','.$bbox[5].','.$bbox[6].','.$bbox[7]; + $this->iCSIMarea = "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($this->iCSIMtarget)."\" "; + if( trim($this->iCSIMalt) != '' ) { + $this->iCSIMarea .= " alt=\"".$this->iCSIMalt."\" "; + $this->iCSIMarea .= " title=\"".$this->iCSIMalt."\" "; + } + if( trim($this->iCSIMWinTarget) != '' ) { + $this->iCSIMarea .= " target=\"".$this->iCSIMWinTarget."\" "; + } + $this->iCSIMarea .= " />\n"; + + $aImg->PopColor($this->color); + } + + function __get($name) { + + if (strpos($name, 'raw_') !== false) { + // if $name == 'raw_left_margin' , return $this->_left_margin; + $variable_name = '_' . str_replace('raw_', '', $name); + return $this->$variable_name; + } + + $variable_name = '_' . $name; + + if (isset($this->$variable_name)) { + return $this->$variable_name * SUPERSAMPLING_SCALE; + } else { + JpGraphError::RaiseL('25132', $name); + } + } + + function __set($name, $value) { + $this->{'_'.$name} = $value; + } +} // Class + + +?> diff --git a/html/jpgraph/jpgraph_theme.inc.php b/html/jpgraph/jpgraph_theme.inc.php new file mode 100644 index 0000000..0cc54c4 --- /dev/null +++ b/html/jpgraph/jpgraph_theme.inc.php @@ -0,0 +1,136 @@ +<?php +//======================================================================= +// File: JPGRAPH_THEME.INC.PHP +// Description: Class to define graph theme +// Created: 2010-09-29 +// Ver: $Id: jpgraph_theme.inc.php 83 2010-10-01 11:24:19Z atsushi $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + + +// include Theme classes +foreach (glob(dirname(__FILE__) . '/themes/*.php') as $theme_class_script) { + require_once($theme_class_script); +} + +//=================================================== +// CLASS +// Description: +//=================================================== +abstract class Theme { + protected $color_index; + + function __construct() { + $this->color_index = 0; + } + /** + * + */ + abstract function GetColorList(); + + /** + * + */ + abstract function ApplyPlot($plot); + + + /** + * + */ + function SetupPlot($plot) { + if (is_array($plot)) { + foreach ($plot as $obj) { + $this->ApplyPlot($obj); + } + } else { + $this->ApplyPlot($plot); + } + } + + /** + * + */ + function ApplyGraph($graph) { + + $this->graph = $graph; + $method_name = ''; + + if (get_class($graph) == 'Graph') { + $method_name = 'SetupGraph'; + } else { + $method_name = 'Setup' . get_class($graph); + } + + if (method_exists($this, $method_name)) { + $this->$method_name($graph); + } else { + JpGraphError::RaiseL(30001, $method_name, $method_name); //Theme::%s() is not defined. \nPlease make %s(\$graph) function in your theme classs. + } + } + + /** + * + */ + function PreStrokeApply($graph) { + } + + /** + * + */ + function GetThemeColors($num = 30) { + $result_list = array(); + + $old_index = $this->color_index; + $this->color_index = 0; + $count = 0; + + $i = 0; + while (true) { + for ($j = 0; $j < count($this->GetColorList()); $j++) { + if (++$count > $num) { + break 2; + } + $result_list[] = $this->GetNextColor(); + } + $i++; + } + + $this->color_index = $old_index; + + return $result_list; + } + + /** + * + */ + function GetNextColor() { + $color_list = $this->GetColorList(); + + $color = null; + if (isset($color_list[$this->color_index])) { + $color = $color_list[$this->color_index]; + } else { + $color_count = count($color_list); + if ($color_count <= $this->color_index) { + $color_tmp = $color_list[$this->color_index % $color_count]; + $brightness = 1.0 - intval($this->color_index / $color_count) * 0.2; + $rgb = new RGB(); + $color = $color_tmp . ':' . $brightness; + $color = $rgb->Color($color); + $alpha = array_pop($color); + $color = $rgb->tryHexConversion($color); + if ($alpha) { + $color .= '@' . $alpha; + } + } + } + + $this->color_index++; + + return $color; + } + +} // Class + +?> diff --git a/html/jpgraph/jpgraph_ttf.inc.php b/html/jpgraph/jpgraph_ttf.inc.php new file mode 100644 index 0000000..5a1bc3e --- /dev/null +++ b/html/jpgraph/jpgraph_ttf.inc.php @@ -0,0 +1,631 @@ +<?php +//======================================================================= +// File: jpgraph_ttf.inc.php +// Description: Handling of TTF fonts +// Created: 2006-11-19 +// Ver: $Id: jpgraph_ttf.inc.php 1858 2009-09-28 14:39:51Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== + +// TTF Font families +define("FF_COURIER",10); +define("FF_VERDANA",11); +define("FF_TIMES",12); +define("FF_COMIC",14); +define("FF_ARIAL",15); +define("FF_GEORGIA",16); +define("FF_TREBUCHE",17); + +// Gnome Vera font +// Available from http://www.gnome.org/fonts/ +define("FF_VERA",18); +define("FF_VERAMONO",19); +define("FF_VERASERIF",20); + +// Chinese font +define("FF_SIMSUN",30); +define("FF_CHINESE",31); +define("FF_BIG5",32); + +// Japanese font +define("FF_MINCHO",40); +define("FF_PMINCHO",41); +define("FF_GOTHIC",42); +define("FF_PGOTHIC",43); + +// Hebrew fonts +define("FF_DAVID",44); +define("FF_MIRIAM",45); +define("FF_AHRON",46); + +// Dejavu-fonts http://sourceforge.net/projects/dejavu +define("FF_DV_SANSSERIF",47); +define("FF_DV_SERIF",48); +define("FF_DV_SANSSERIFMONO",49); +define("FF_DV_SERIFCOND",50); +define("FF_DV_SANSSERIFCOND",51); + +// Extra fonts +// Download fonts from +// http://www.webfontlist.com +// http://www.webpagepublicity.com/free-fonts.html +// http://www.fontonic.com/fonts.asp?width=d&offset=120 +// http://www.fontspace.com/category/famous + +// define("FF_SPEEDO",71); // This font is also known as Bauer (Used for development gauge fascia) +define("FF_DIGITAL",72); // Digital readout font +define("FF_COMPUTER",73); // The classic computer font +define("FF_CALCULATOR",74); // Triad font + +define("FF_USERFONT",90); +define("FF_USERFONT1",90); +define("FF_USERFONT2",91); +define("FF_USERFONT3",92); + +// Limits for fonts +define("_FIRST_FONT",10); +define("_LAST_FONT",99); + +// TTF Font styles +define("FS_NORMAL",9001); +define("FS_BOLD",9002); +define("FS_ITALIC",9003); +define("FS_BOLDIT",9004); +define("FS_BOLDITALIC",9004); + +//Definitions for internal font +define("FF_FONT0",1); +define("FF_FONT1",2); +define("FF_FONT2",4); + +//------------------------------------------------------------------------ +// Defines for font setup +//------------------------------------------------------------------------ + +// Actual name of the TTF file used together with FF_CHINESE aka FF_BIG5 +// This is the TTF file being used when the font family is specified as +// either FF_CHINESE or FF_BIG5 +define('CHINESE_TTF_FONT','bkai00mp.ttf'); + +// Special unicode greek language support +define("LANGUAGE_GREEK",false); + +// If you are setting this config to true the conversion of greek characters +// will assume that the input text is windows 1251 +define("GREEK_FROM_WINDOWS",false); + +// Special unicode cyrillic language support +define("LANGUAGE_CYRILLIC",false); + +// If you are setting this config to true the conversion +// will assume that the input text is windows 1251, if +// false it will assume koi8-r +define("CYRILLIC_FROM_WINDOWS",false); + +// The following constant is used to auto-detect +// whether cyrillic conversion is really necessary +// if enabled. Just replace 'windows-1251' with a variable +// containing the input character encoding string +// of your application calling jpgraph. +// A typical such string would be 'UTF-8' or 'utf-8'. +// The comparison is case-insensitive. +// If this charset is not a 'koi8-r' or 'windows-1251' +// derivate then no conversion is done. +// +// This constant can be very important in multi-user +// multi-language environments where a cyrillic conversion +// could be needed for some cyrillic people +// and resulting in just erraneous conversions +// for not-cyrillic language based people. +// +// Example: In the free project management +// software dotproject.net $locale_char_set is dynamically +// set by the language environment the user has chosen. +// +// Usage: define('LANGUAGE_CHARSET', $locale_char_set); +// +// where $locale_char_set is a GLOBAL (string) variable +// from the application including JpGraph. +// +define('LANGUAGE_CHARSET', null); + +// Japanese TrueType font used with FF_MINCHO, FF_PMINCHO, FF_GOTHIC, FF_PGOTHIC +// Standard fonts from Infomation-technology Promotion Agency (IPA) +// See http://mix-mplus-ipa.sourceforge.jp/ +define('MINCHO_TTF_FONT','ipam.ttf'); +define('PMINCHO_TTF_FONT','ipamp.ttf'); +define('GOTHIC_TTF_FONT','ipag.ttf'); +define('PGOTHIC_TTF_FONT','ipagp.ttf'); + +// Assume that Japanese text have been entered in EUC-JP encoding. +// If this define is true then conversion from EUC-JP to UTF8 is done +// automatically in the library using the mbstring module in PHP. +define('ASSUME_EUCJP_ENCODING',false); + + +// Default font family +define('FF_DEFAULT', FF_DV_SANSSERIF); + + + +//================================================================= +// CLASS LanguageConv +// Description: +// Converts various character encoding into proper +// UTF-8 depending on how the library have been configured and +// what font family is being used +//================================================================= +class LanguageConv { + private $g2312 = null ; + + function Convert($aTxt,$aFF) { + if( LANGUAGE_GREEK ) { + if( GREEK_FROM_WINDOWS ) { + $unistring = LanguageConv::gr_win2uni($aTxt); + } else { + $unistring = LanguageConv::gr_iso2uni($aTxt); + } + return $unistring; + } elseif( LANGUAGE_CYRILLIC ) { + if( CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251')) ) { + $aTxt = convert_cyr_string($aTxt, "w", "k"); + } + if( !defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) { + $isostring = convert_cyr_string($aTxt, "k", "i"); + $unistring = LanguageConv::iso2uni($isostring); + } + else { + $unistring = $aTxt; + } + return $unistring; + } + elseif( $aFF === FF_SIMSUN ) { + // Do Chinese conversion + if( $this->g2312 == null ) { + include_once 'jpgraph_gb2312.php' ; + $this->g2312 = new GB2312toUTF8(); + } + return $this->g2312->gb2utf8($aTxt); + } + elseif( $aFF === FF_BIG5 ) { + if( !function_exists('iconv') ) { + JpGraphError::RaiseL(25006); + //('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).'); + } + return iconv('BIG5','UTF-8',$aTxt); + } + elseif( ASSUME_EUCJP_ENCODING && + ($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC) ) { + if( !function_exists('mb_convert_encoding') ) { + JpGraphError::RaiseL(25127); + } + return mb_convert_encoding($aTxt, 'UTF-8','EUC-JP'); + } + elseif( $aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON ) { + return LanguageConv::heb_iso2uni($aTxt); + } + else + return $aTxt; + } + + // Translate iso encoding to unicode + public static function iso2uni ($isoline){ + $uniline=''; + for ($i=0; $i < strlen($isoline); $i++){ + $thischar=substr($isoline,$i,1); + $charcode=ord($thischar); + $uniline.=($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar; + } + return $uniline; + } + + // Translate greek iso encoding to unicode + public static function gr_iso2uni ($isoline) { + $uniline=''; + for ($i=0; $i < strlen($isoline); $i++) { + $thischar=substr($isoline,$i,1); + $charcode=ord($thischar); + $uniline.=($charcode>179 && $charcode!=183 && $charcode!=187 && $charcode!=189) ? "&#" . (900+($charcode-180)). ";" : $thischar; + } + return $uniline; + } + + // Translate greek win encoding to unicode + public static function gr_win2uni ($winline) { + $uniline=''; + for ($i=0; $i < strlen($winline); $i++) { + $thischar=substr($winline,$i,1); + $charcode=ord($thischar); + if ($charcode==161 || $charcode==162) { + $uniline.="&#" . (740+$charcode). ";"; + } + else { + $uniline.=(($charcode>183 && $charcode!=187 && $charcode!=189) || $charcode==180) ? "&#" . (900+($charcode-180)). ";" : $thischar; + } + } + return $uniline; + } + + public static function heb_iso2uni($isoline) { + $isoline = hebrev($isoline); + $o = ''; + + $n = strlen($isoline); + for($i=0; $i < $n; $i++) { + $c=ord( substr($isoline,$i,1) ); + $o .= ($c > 223) && ($c < 251) ? '&#'.(1264+$c).';' : chr($c); + } + return utf8_encode($o); + } +} + +//============================================================= +// CLASS TTF +// Description: Handle TTF font names and mapping and loading of +// font files +//============================================================= +class TTF { + private $font_files,$style_names; + + function __construct() { + + // String names for font styles to be used in error messages + $this->style_names=array( + FS_NORMAL =>'normal', + FS_BOLD =>'bold', + FS_ITALIC =>'italic', + FS_BOLDITALIC =>'bolditalic'); + + // File names for available fonts + $this->font_files=array( + FF_COURIER => array(FS_NORMAL =>'cour.ttf', + FS_BOLD =>'courbd.ttf', + FS_ITALIC =>'couri.ttf', + FS_BOLDITALIC =>'courbi.ttf' ), + FF_GEORGIA => array(FS_NORMAL =>'georgia.ttf', + FS_BOLD =>'georgiab.ttf', + FS_ITALIC =>'georgiai.ttf', + FS_BOLDITALIC =>'' ), + FF_TREBUCHE =>array(FS_NORMAL =>'trebuc.ttf', + FS_BOLD =>'trebucbd.ttf', + FS_ITALIC =>'trebucit.ttf', + FS_BOLDITALIC =>'trebucbi.ttf' ), + FF_VERDANA => array(FS_NORMAL =>'verdana.ttf', + FS_BOLD =>'verdanab.ttf', + FS_ITALIC =>'verdanai.ttf', + FS_BOLDITALIC =>'' ), + FF_TIMES => array(FS_NORMAL =>'times.ttf', + FS_BOLD =>'timesbd.ttf', + FS_ITALIC =>'timesi.ttf', + FS_BOLDITALIC =>'timesbi.ttf' ), + FF_COMIC => array(FS_NORMAL =>'comic.ttf', + FS_BOLD =>'comicbd.ttf', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + FF_ARIAL => array(FS_NORMAL =>'arial.ttf', + FS_BOLD =>'arialbd.ttf', + FS_ITALIC =>'ariali.ttf', + FS_BOLDITALIC =>'arialbi.ttf' ) , + FF_VERA => array(FS_NORMAL =>'Vera.ttf', + FS_BOLD =>'VeraBd.ttf', + FS_ITALIC =>'VeraIt.ttf', + FS_BOLDITALIC =>'VeraBI.ttf' ), + FF_VERAMONO => array(FS_NORMAL =>'VeraMono.ttf', + FS_BOLD =>'VeraMoBd.ttf', + FS_ITALIC =>'VeraMoIt.ttf', + FS_BOLDITALIC =>'VeraMoBI.ttf' ), + FF_VERASERIF=> array(FS_NORMAL =>'VeraSe.ttf', + FS_BOLD =>'VeraSeBd.ttf', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ) , + + /* Chinese fonts */ + FF_SIMSUN => array( + FS_NORMAL =>'simsun.ttc', + FS_BOLD =>'simhei.ttf', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + FF_CHINESE => array( + FS_NORMAL =>CHINESE_TTF_FONT, + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + FF_BIG5 => array( + FS_NORMAL =>CHINESE_TTF_FONT, + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + /* Japanese fonts */ + FF_MINCHO => array( + FS_NORMAL =>MINCHO_TTF_FONT, + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_PMINCHO => array( + FS_NORMAL =>PMINCHO_TTF_FONT, + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_GOTHIC => array( + FS_NORMAL =>GOTHIC_TTF_FONT, + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_PGOTHIC => array( + FS_NORMAL =>PGOTHIC_TTF_FONT, + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + /* Hebrew fonts */ + FF_DAVID => array( + FS_NORMAL =>'DAVIDNEW.TTF', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_MIRIAM => array( + FS_NORMAL =>'MRIAMY.TTF', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_AHRON => array( + FS_NORMAL =>'ahronbd.ttf', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + /* Misc fonts */ + FF_DIGITAL => array( + FS_NORMAL =>'DIGIRU__.TTF', + FS_BOLD =>'Digirtu_.ttf', + FS_ITALIC =>'Digir___.ttf', + FS_BOLDITALIC =>'DIGIRT__.TTF' ), + + /* This is an experimental font for the speedometer development + FF_SPEEDO => array( + FS_NORMAL =>'Speedo.ttf', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + */ + + FF_COMPUTER => array( + FS_NORMAL =>'COMPUTER.TTF', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_CALCULATOR => array( + FS_NORMAL =>'Triad_xs.ttf', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + /* Dejavu fonts */ + FF_DV_SANSSERIF => array( + FS_NORMAL =>array('DejaVuSans.ttf'), + FS_BOLD =>array('DejaVuSans-Bold.ttf','DejaVuSansBold.ttf'), + FS_ITALIC =>array('DejaVuSans-Oblique.ttf','DejaVuSansOblique.ttf'), + FS_BOLDITALIC =>array('DejaVuSans-BoldOblique.ttf','DejaVuSansBoldOblique.ttf') ), + + FF_DV_SANSSERIFMONO => array( + FS_NORMAL =>array('DejaVuSansMono.ttf','DejaVuMonoSans.ttf'), + FS_BOLD =>array('DejaVuSansMono-Bold.ttf','DejaVuMonoSansBold.ttf'), + FS_ITALIC =>array('DejaVuSansMono-Oblique.ttf','DejaVuMonoSansOblique.ttf'), + FS_BOLDITALIC =>array('DejaVuSansMono-BoldOblique.ttf','DejaVuMonoSansBoldOblique.ttf') ), + + FF_DV_SANSSERIFCOND => array( + FS_NORMAL =>array('DejaVuSansCondensed.ttf','DejaVuCondensedSans.ttf'), + FS_BOLD =>array('DejaVuSansCondensed-Bold.ttf','DejaVuCondensedSansBold.ttf'), + FS_ITALIC =>array('DejaVuSansCondensed-Oblique.ttf','DejaVuCondensedSansOblique.ttf'), + FS_BOLDITALIC =>array('DejaVuSansCondensed-BoldOblique.ttf','DejaVuCondensedSansBoldOblique.ttf') ), + + FF_DV_SERIF => array( + FS_NORMAL =>array('DejaVuSerif.ttf'), + FS_BOLD =>array('DejaVuSerif-Bold.ttf','DejaVuSerifBold.ttf'), + FS_ITALIC =>array('DejaVuSerif-Italic.ttf','DejaVuSerifItalic.ttf'), + FS_BOLDITALIC =>array('DejaVuSerif-BoldItalic.ttf','DejaVuSerifBoldItalic.ttf') ), + + FF_DV_SERIFCOND => array( + FS_NORMAL =>array('DejaVuSerifCondensed.ttf','DejaVuCondensedSerif.ttf'), + FS_BOLD =>array('DejaVuSerifCondensed-Bold.ttf','DejaVuCondensedSerifBold.ttf'), + FS_ITALIC =>array('DejaVuSerifCondensed-Italic.ttf','DejaVuCondensedSerifItalic.ttf'), + FS_BOLDITALIC =>array('DejaVuSerifCondensed-BoldItalic.ttf','DejaVuCondensedSerifBoldItalic.ttf') ), + + + /* Placeholders for defined fonts */ + FF_USERFONT1 => array( + FS_NORMAL =>'', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_USERFONT2 => array( + FS_NORMAL =>'', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + FF_USERFONT3 => array( + FS_NORMAL =>'', + FS_BOLD =>'', + FS_ITALIC =>'', + FS_BOLDITALIC =>'' ), + + ); + } + + //--------------- + // PUBLIC METHODS + // Create the TTF file from the font specification + function File($family,$style=FS_NORMAL) { + $fam = @$this->font_files[$family]; + if( !$fam ) { + JpGraphError::RaiseL(25046,$family);//("Specified TTF font family (id=$family) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/"); + } + $ff = @$fam[$style]; + + // There are several optional file names. They are tried in order + // and the first one found is used + if( !is_array($ff) ) { + $ff = array($ff); + } + + $jpgraph_font_dir = dirname(__FILE__).'/fonts/'; + + foreach ($ff as $font_file) { + // All font families are guaranteed to have the normal style + + if( $font_file==='' ) + JpGraphError::RaiseL(25047,$this->style_names[$style],$this->font_files[$family][FS_NORMAL]);//('Style "'.$this->style_names[$style].'" is not available for font family '.$this->font_files[$family][FS_NORMAL].'.'); + if( !$font_file ) { + JpGraphError::RaiseL(25048,$fam);//("Unknown font style specification [$fam]."); + } + + // check jpgraph/src/fonts dir + $jpgraph_font_file = $jpgraph_font_dir . $font_file; + if (file_exists($jpgraph_font_file) === true && is_readable($jpgraph_font_file) === true) { + $font_file = $jpgraph_font_file; + break; + } + + // check OS font dir + if ($family >= FF_MINCHO && $family <= FF_PGOTHIC) { + $font_file = MBTTF_DIR.$font_file; + } else { + $font_file = TTF_DIR.$font_file; + } + if (file_exists($font_file) === true && is_readable($font_file) === true) { + break; + } + } + + if( !file_exists($font_file) ) { + JpGraphError::RaiseL(25049,$font_file);//("Font file \"$font_file\" is not readable or does not exist."); + } + + return $font_file; + } + + function SetUserFont($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->font_files[FF_USERFONT] = + array(FS_NORMAL => $aNormal, + FS_BOLD => $aBold, + FS_ITALIC => $aItalic, + FS_BOLDITALIC => $aBoldIt ) ; + } + + function SetUserFont1($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->font_files[FF_USERFONT1] = + array(FS_NORMAL => $aNormal, + FS_BOLD => $aBold, + FS_ITALIC => $aItalic, + FS_BOLDITALIC => $aBoldIt ) ; + } + + function SetUserFont2($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->font_files[FF_USERFONT2] = + array(FS_NORMAL => $aNormal, + FS_BOLD => $aBold, + FS_ITALIC => $aItalic, + FS_BOLDITALIC => $aBoldIt ) ; + } + + function SetUserFont3($aNormal,$aBold='',$aItalic='',$aBoldIt='') { + $this->font_files[FF_USERFONT3] = + array(FS_NORMAL => $aNormal, + FS_BOLD => $aBold, + FS_ITALIC => $aItalic, + FS_BOLDITALIC => $aBoldIt ) ; + } + +} // Class + + +//============================================================================= +// CLASS SymChar +// Description: Code values for some commonly used characters that +// normally isn't available directly on the keyboard, for example +// mathematical and greek symbols. +//============================================================================= +class SymChar { + static function Get($aSymb,$aCapital=FALSE) { + $iSymbols = array( + /* Greek */ + array('alpha','03B1','0391'), + array('beta','03B2','0392'), + array('gamma','03B3','0393'), + array('delta','03B4','0394'), + array('epsilon','03B5','0395'), + array('zeta','03B6','0396'), + array('ny','03B7','0397'), + array('eta','03B8','0398'), + array('theta','03B8','0398'), + array('iota','03B9','0399'), + array('kappa','03BA','039A'), + array('lambda','03BB','039B'), + array('mu','03BC','039C'), + array('nu','03BD','039D'), + array('xi','03BE','039E'), + array('omicron','03BF','039F'), + array('pi','03C0','03A0'), + array('rho','03C1','03A1'), + array('sigma','03C3','03A3'), + array('tau','03C4','03A4'), + array('upsilon','03C5','03A5'), + array('phi','03C6','03A6'), + array('chi','03C7','03A7'), + array('psi','03C8','03A8'), + array('omega','03C9','03A9'), + /* Money */ + array('euro','20AC'), + array('yen','00A5'), + array('pound','20A4'), + /* Math */ + array('approx','2248'), + array('neq','2260'), + array('not','2310'), + array('def','2261'), + array('inf','221E'), + array('sqrt','221A'), + array('int','222B'), + /* Misc */ + array('copy','00A9'), + array('para','00A7'), + array('tm','2122'), /* Trademark symbol */ + array('rtm','00AE'), /* Registered trademark */ + array('degree','00b0'), + array('lte','2264'), /* Less than or equal */ + array('gte','2265'), /* Greater than or equal */ + + ); + + $n = count($iSymbols); + $i=0; + $found = false; + $aSymb = strtolower($aSymb); + while( $i < $n && !$found ) { + $found = $aSymb === $iSymbols[$i++][0]; + } + if( $found ) { + $ca = $iSymbols[--$i]; + if( $aCapital && count($ca)==3 ) + $s = $ca[2]; + else + $s = $ca[1]; + return sprintf('&#%04d;',hexdec($s)); + } + else + return ''; + } +} + + +?> diff --git a/html/jpgraph/jpgraph_utils.inc.php b/html/jpgraph/jpgraph_utils.inc.php new file mode 100644 index 0000000..f0d002c --- /dev/null +++ b/html/jpgraph/jpgraph_utils.inc.php @@ -0,0 +1,685 @@ +<?php +/*======================================================================= + // File: JPGRAPH_UTILS.INC + // Description: Collection of non-essential "nice to have" utilities + // Created: 2005-11-20 + // Ver: $Id: jpgraph_utils.inc.php 1777 2009-08-23 17:34:36Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +//=================================================== +// CLASS FuncGenerator +// Description: Utility class to help generate data for function plots. +// The class supports both parametric and regular functions. +//=================================================== +class FuncGenerator { + private $iFunc='',$iXFunc='',$iMin,$iMax,$iStepSize; + + function __construct($aFunc,$aXFunc='') { + $this->iFunc = $aFunc; + $this->iXFunc = $aXFunc; + } + + function E($aXMin,$aXMax,$aSteps=50) { + $this->iMin = $aXMin; + $this->iMax = $aXMax; + $this->iStepSize = ($aXMax-$aXMin)/$aSteps; + + if( $this->iXFunc != '' ) + $t = 'for($i='.$aXMin.'; $i<='.$aXMax.'; $i += '.$this->iStepSize.') {$ya[]='.$this->iFunc.';$xa[]='.$this->iXFunc.';}'; + elseif( $this->iFunc != '' ) + $t = 'for($x='.$aXMin.'; $x<='.$aXMax.'; $x += '.$this->iStepSize.') {$ya[]='.$this->iFunc.';$xa[]=$x;} $x='.$aXMax.';$ya[]='.$this->iFunc.';$xa[]=$x;'; + else + JpGraphError::RaiseL(24001);//('FuncGenerator : No function specified. '); + + @eval($t); + + // If there is an error in the function specifcation this is the only + // way we can discover that. + if( empty($xa) || empty($ya) ) + JpGraphError::RaiseL(24002);//('FuncGenerator : Syntax error in function specification '); + + return array($xa,$ya); + } +} + + +//============================================================================= +// CLASS DateScaleUtils +// Description: Help to create a manual date scale +//============================================================================= +define('DSUTILS_MONTH',1); // Major and minor ticks on a monthly basis +define('DSUTILS_MONTH1',1); // Major and minor ticks on a monthly basis +define('DSUTILS_MONTH2',2); // Major ticks on a bi-monthly basis +define('DSUTILS_MONTH3',3); // Major icks on a tri-monthly basis +define('DSUTILS_MONTH6',4); // Major on a six-monthly basis +define('DSUTILS_WEEK1',5); // Major ticks on a weekly basis +define('DSUTILS_WEEK2',6); // Major ticks on a bi-weekly basis +define('DSUTILS_WEEK4',7); // Major ticks on a quod-weekly basis +define('DSUTILS_DAY1',8); // Major ticks on a daily basis +define('DSUTILS_DAY2',9); // Major ticks on a bi-daily basis +define('DSUTILS_DAY4',10); // Major ticks on a qoud-daily basis +define('DSUTILS_YEAR1',11); // Major ticks on a yearly basis +define('DSUTILS_YEAR2',12); // Major ticks on a bi-yearly basis +define('DSUTILS_YEAR5',13); // Major ticks on a five-yearly basis + + +class DateScaleUtils { + public static $iMin=0, $iMax=0; + + private static $starthour,$startmonth, $startday, $startyear; + private static $endmonth, $endyear, $endday; + private static $tickPositions=array(),$minTickPositions=array(); + private static $iUseWeeks = true; + + static function UseWeekFormat($aFlg) { + self::$iUseWeeks = $aFlg; + } + + static function doYearly($aType,$aMinor=false) { + $i=0; $j=0; + $m = self::$startmonth; + $y = self::$startyear; + + if( self::$startday == 1 ) { + self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y); + } + ++$m; + + + switch( $aType ) { + case DSUTILS_YEAR1: + for($y=self::$startyear; $y <= self::$endyear; ++$y ) { + if( $aMinor ) { + while( $m <= 12 ) { + if( !($y == self::$endyear && $m > self::$endmonth) ) { + self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y); + } + ++$m; + } + $m=1; + } + self::$tickPositions[$i++] = mktime(0,0,0,1,1,$y); + } + break; + case DSUTILS_YEAR2: + $y=self::$startyear; + while( $y <= self::$endyear ) { + self::$tickPositions[$i++] = mktime(0,0,0,1,1,$y); + for($k=0; $k < 1; ++$k ) { + ++$y; + if( $aMinor ) { + self::$minTickPositions[$j++] = mktime(0,0,0,1,1,$y); + } + } + ++$y; + } + break; + case DSUTILS_YEAR5: + $y=self::$startyear; + while( $y <= self::$endyear ) { + self::$tickPositions[$i++] = mktime(0,0,0,1,1,$y); + for($k=0; $k < 4; ++$k ) { + ++$y; + if( $aMinor ) { + self::$minTickPositions[$j++] = mktime(0,0,0,1,1,$y); + } + } + ++$y; + } + break; + } + } + + static function doDaily($aType,$aMinor=false) { + $m = self::$startmonth; + $y = self::$startyear; + $d = self::$startday; + $h = self::$starthour; + $i=0;$j=0; + + if( $h == 0 ) { + self::$tickPositions[$i++] = mktime(0,0,0,$m,$d,$y); + } + $t = mktime(0,0,0,$m,$d,$y); + + switch($aType) { + case DSUTILS_DAY1: + while( $t <= self::$iMax ) { + $t = strtotime('+1 day',$t); + self::$tickPositions[$i++] = $t; + if( $aMinor ) { + self::$minTickPositions[$j++] = strtotime('+12 hours',$t); + } + } + break; + case DSUTILS_DAY2: + while( $t <= self::$iMax ) { + $t = strtotime('+1 day',$t); + if( $aMinor ) { + self::$minTickPositions[$j++] = $t; + } + $t = strtotime('+1 day',$t); + self::$tickPositions[$i++] = $t; + } + break; + case DSUTILS_DAY4: + while( $t <= self::$iMax ) { + for($k=0; $k < 3; ++$k ) { + $t = strtotime('+1 day',$t); + if( $aMinor ) { + self::$minTickPositions[$j++] = $t; + } + } + $t = strtotime('+1 day',$t); + self::$tickPositions[$i++] = $t; + } + break; + } + } + + static function doWeekly($aType,$aMinor=false) { + $hpd = 3600*24; + $hpw = 3600*24*7; + // Find out week number of min date + $thursday = self::$iMin + $hpd * (3 - (date('w', self::$iMin) + 6) % 7); + $week = 1 + (date('z', $thursday) - (11 - date('w', mktime(0, 0, 0, 1, 1, date('Y', $thursday)))) % 7) / 7; + $daynumber = date('w',self::$iMin); + if( $daynumber == 0 ) $daynumber = 7; + $m = self::$startmonth; + $y = self::$startyear; + $d = self::$startday; + $i=0;$j=0; + // The assumption is that the weeks start on Monday. If the first day + // is later in the week then the first week tick has to be on the following + // week. + if( $daynumber == 1 ) { + self::$tickPositions[$i++] = mktime(0,0,0,$m,$d,$y); + $t = mktime(0,0,0,$m,$d,$y) + $hpw; + } + else { + $t = mktime(0,0,0,$m,$d,$y) + $hpd*(8-$daynumber); + } + + switch($aType) { + case DSUTILS_WEEK1: + $cnt=0; + break; + case DSUTILS_WEEK2: + $cnt=1; + break; + case DSUTILS_WEEK4: + $cnt=3; + break; + } + while( $t <= self::$iMax ) { + self::$tickPositions[$i++] = $t; + for($k=0; $k < $cnt; ++$k ) { + $t += $hpw; + if( $aMinor ) { + self::$minTickPositions[$j++] = $t; + } + } + $t += $hpw; + } + } + + static function doMonthly($aType,$aMinor=false) { + $monthcount=0; + $m = self::$startmonth; + $y = self::$startyear; + $i=0; $j=0; + + // Skip the first month label if it is before the startdate + if( self::$startday == 1 ) { + self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y); + $monthcount=1; + } + if( $aType == 1 ) { + if( self::$startday < 15 ) { + self::$minTickPositions[$j++] = mktime(0,0,0,$m,15,$y); + } + } + ++$m; + + // Loop through all the years included in the scale + for($y=self::$startyear; $y <= self::$endyear; ++$y ) { + // Loop through all the months. There are three cases to consider: + // 1. We are in the first year and must start with the startmonth + // 2. We are in the end year and we must stop at last month of the scale + // 3. A year in between where we run through all the 12 months + $stopmonth = $y == self::$endyear ? self::$endmonth : 12; + while( $m <= $stopmonth ) { + switch( $aType ) { + case DSUTILS_MONTH1: + // Set minor tick at the middle of the month + if( $aMinor ) { + if( $m <= $stopmonth ) { + if( !($y==self::$endyear && $m==$stopmonth && self::$endday < 15) ) + self::$minTickPositions[$j++] = mktime(0,0,0,$m,15,$y); + } + } + // Major at month + // Get timestamp of first hour of first day in each month + self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y); + + break; + case DSUTILS_MONTH2: + if( $aMinor ) { + // Set minor tick at start of each month + self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y); + } + + // Major at every second month + // Get timestamp of first hour of first day in each month + if( $monthcount % 2 == 0 ) { + self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y); + } + break; + case DSUTILS_MONTH3: + if( $aMinor ) { + // Set minor tick at start of each month + self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y); + } + // Major at every third month + // Get timestamp of first hour of first day in each month + if( $monthcount % 3 == 0 ) { + self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y); + } + break; + case DSUTILS_MONTH6: + if( $aMinor ) { + // Set minor tick at start of each month + self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y); + } + // Major at every third month + // Get timestamp of first hour of first day in each month + if( $monthcount % 6 == 0 ) { + self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y); + } + break; + } + ++$m; + ++$monthcount; + } + $m=1; + } + + // For the case where all dates are within the same month + // we want to make sure we have at least two ticks on the scale + // since the scale want work properly otherwise + if(self::$startmonth == self::$endmonth && self::$startyear == self::$endyear && $aType==1 ) { + self::$tickPositions[$i++] = mktime(0 ,0 ,0, self::$startmonth + 1, 1, self::$startyear); + } + + return array(self::$tickPositions,self::$minTickPositions); + } + + static function GetTicks($aData,$aType=1,$aMinor=false,$aEndPoints=false) { + $n = count($aData); + return self::GetTicksFromMinMax($aData[0],$aData[$n-1],$aType,$aMinor,$aEndPoints); + } + + static function GetAutoTicks($aMin,$aMax,$aMaxTicks=10,$aMinor=false) { + $diff = $aMax - $aMin; + $spd = 3600*24; + $spw = $spd*7; + $spm = $spd*30; + $spy = $spd*352; + + if( self::$iUseWeeks ) + $w = 'W'; + else + $w = 'd M'; + + // Decision table for suitable scales + // First value: Main decision point + // Second value: Array of formatting depending on divisor for wanted max number of ticks. <divisor><formatting><format-string>,.. + $tt = array( + array($spw, array(1,DSUTILS_DAY1,'d M',2,DSUTILS_DAY2,'d M',-1,DSUTILS_DAY4,'d M')), + array($spm, array(1,DSUTILS_DAY1,'d M',2,DSUTILS_DAY2,'d M',4,DSUTILS_DAY4,'d M',7,DSUTILS_WEEK1,$w,-1,DSUTILS_WEEK2,$w)), + array($spy, array(1,DSUTILS_DAY1,'d M',2,DSUTILS_DAY2,'d M',4,DSUTILS_DAY4,'d M',7,DSUTILS_WEEK1,$w,14,DSUTILS_WEEK2,$w,30,DSUTILS_MONTH1,'M',60,DSUTILS_MONTH2,'M',-1,DSUTILS_MONTH3,'M')), + array(-1, array(30,DSUTILS_MONTH1,'M-Y',60,DSUTILS_MONTH2,'M-Y',90,DSUTILS_MONTH3,'M-Y',180,DSUTILS_MONTH6,'M-Y',352,DSUTILS_YEAR1,'Y',704,DSUTILS_YEAR2,'Y',-1,DSUTILS_YEAR5,'Y'))); + + $ntt = count($tt); + $nd = floor($diff/$spd); + for($i=0; $i < $ntt; ++$i ) { + if( $diff <= $tt[$i][0] || $i==$ntt-1) { + $t = $tt[$i][1]; + $n = count($t)/3; + for( $j=0; $j < $n; ++$j ) { + if( $nd/$t[3*$j] <= $aMaxTicks || $j==$n-1) { + $type = $t[3*$j+1]; + $fs = $t[3*$j+2]; + list($tickPositions,$minTickPositions) = self::GetTicksFromMinMax($aMin,$aMax,$type,$aMinor); + return array($fs,$tickPositions,$minTickPositions,$type); + } + } + } + } + } + + static function GetTicksFromMinMax($aMin,$aMax,$aType,$aMinor=false,$aEndPoints=false) { + self::$starthour = date('G',$aMin); + self::$startmonth = date('n',$aMin); + self::$startday = date('j',$aMin); + self::$startyear = date('Y',$aMin); + self::$endmonth = date('n',$aMax); + self::$endyear = date('Y',$aMax); + self::$endday = date('j',$aMax); + self::$iMin = $aMin; + self::$iMax = $aMax; + + if( $aType <= DSUTILS_MONTH6 ) { + self::doMonthly($aType,$aMinor); + } + elseif( $aType <= DSUTILS_WEEK4 ) { + self::doWeekly($aType,$aMinor); + } + elseif( $aType <= DSUTILS_DAY4 ) { + self::doDaily($aType,$aMinor); + } + elseif( $aType <= DSUTILS_YEAR5 ) { + self::doYearly($aType,$aMinor); + } + else { + JpGraphError::RaiseL(24003); + } + // put a label at the very left data pos + if( $aEndPoints ) { + $tickPositions[$i++] = $aData[0]; + } + + // put a label at the very right data pos + if( $aEndPoints ) { + $tickPositions[$i] = $aData[$n-1]; + } + + return array(self::$tickPositions,self::$minTickPositions); + } +} + +//============================================================================= +// Class ReadFileData +//============================================================================= +Class ReadFileData { + //---------------------------------------------------------------------------- + // Desciption: + // Read numeric data from a file. + // Each value should be separated by either a new line or by a specified + // separator character (default is ','). + // Before returning the data each value is converted to a proper float + // value. The routine is robust in the sense that non numeric data in the + // file will be discarded. + // + // Returns: + // The number of data values read on success, FALSE on failure + //---------------------------------------------------------------------------- + static function FromCSV($aFile,&$aData,$aSepChar=',',$aMaxLineLength=1024) { + $rh = @fopen($aFile,'r'); + if( $rh === false ) { + return false; + } + $tmp = array(); + $lineofdata = fgetcsv($rh, 1000, ','); + while ( $lineofdata !== FALSE) { + $tmp = array_merge($tmp,$lineofdata); + $lineofdata = fgetcsv($rh, $aMaxLineLength, $aSepChar); + } + fclose($rh); + + // Now make sure that all data is numeric. By default + // all data is read as strings + $n = count($tmp); + $aData = array(); + $cnt=0; + for($i=0; $i < $n; ++$i) { + if( $tmp[$i] !== "" ) { + $aData[$cnt++] = floatval($tmp[$i]); + } + } + return $cnt; + } + + //---------------------------------------------------------------------------- + // Desciption: + // Read numeric data from a file. + // Each value should be separated by either a new line or by a specified + // separator character (default is ','). + // Before returning the data each value is converted to a proper float + // value. The routine is robust in the sense that non numeric data in the + // file will be discarded. + // + // Options: + // 'separator' => ',', + // 'enclosure' => '"', + // 'readlength' => 1024, + // 'ignore_first' => false, + // 'first_as_key' => false + // 'escape' => '\', # PHP >= 5.3 only + // + // Returns: + // The number of lines read on success, FALSE on failure + //---------------------------------------------------------------------------- + static function FromCSV2($aFile, &$aData, $aOptions = array()) { + $aDefaults = array( + 'separator' => ',', + 'enclosure' => chr(34), + 'escape' => chr(92), + 'readlength' => 1024, + 'ignore_first' => false, + 'first_as_key' => false + ); + + $aOptions = array_merge( + $aDefaults, is_array($aOptions) ? $aOptions : array()); + + if( $aOptions['first_as_key'] ) { + $aOptions['ignore_first'] = true; + } + + $rh = @fopen($aFile, 'r'); + + if( $rh === false ) { + return false; + } + + $aData = array(); + $aLine = fgetcsv($rh, + $aOptions['readlength'], + $aOptions['separator'], + $aOptions['enclosure'] + /*, $aOptions['escape'] # PHP >= 5.3 only */ + ); + + // Use numeric array keys for the columns by default + // If specified use first lines values as assoc keys instead + $keys = array_keys($aLine); + if( $aOptions['first_as_key'] ) { + $keys = array_values($aLine); + } + + $num_lines = 0; + $num_cols = count($aLine); + + while ($aLine !== false) { + if( is_array($aLine) && count($aLine) != $num_cols ) { + JpGraphError::RaiseL(24004); + // 'ReadCSV2: Column count mismatch in %s line %d' + } + + // fgetcsv returns NULL for empty lines + if( !is_null($aLine) ) { + $num_lines++; + + if( !($aOptions['ignore_first'] && $num_lines == 1) && is_numeric($aLine[0]) ) { + for( $i = 0; $i < $num_cols; $i++ ) { + $aData[ $keys[$i] ][] = floatval($aLine[$i]); + } + } + } + + $aLine = fgetcsv($rh, + $aOptions['readlength'], + $aOptions['separator'], + $aOptions['enclosure'] + /*, $aOptions['escape'] # PHP >= 5.3 only*/ + ); + } + + fclose($rh); + + if( $aOptions['ignore_first'] ) { + $num_lines--; + } + + return $num_lines; + } + + // Read data from two columns in a plain text file + static function From2Col($aFile, $aCol1, $aCol2, $aSepChar=' ') { + $lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); + if( $lines === false ) { + return false; + } + $s = '/[\s]+/'; + if( $aSepChar == ',' ) { + $s = '/[\s]*,[\s]*/'; + } + elseif( $aSepChar == ';' ) { + $s = '/[\s]*;[\s]*/'; + } + foreach( $lines as $line => $datarow ) { + $split = preg_split($s,$datarow); + $aCol1[] = floatval(trim($split[0])); + $aCol2[] = floatval(trim($split[1])); + } + + return count($lines); + } + + // Read data from one columns in a plain text file + static function From1Col($aFile, $aCol1) { + $lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); + if( $lines === false ) { + return false; + } + foreach( $lines as $line => $datarow ) { + $aCol1[] = floatval(trim($datarow)); + } + + return count($lines); + } + + static function FromMatrix($aFile,$aSepChar=' ') { + $lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); + if( $lines === false ) { + return false; + } + $mat = array(); + $reg = '/'.$aSepChar.'/'; + foreach( $lines as $line => $datarow ) { + $row = preg_split($reg,trim($datarow)); + foreach ($row as $key => $cell ) { + $row[$key] = floatval(trim($cell)); + } + $mat[] = $row; + } + return $mat; + } + + +} + +define('__LR_EPSILON', 1.0e-8); +//============================================================================= +// Class LinearRegression +//============================================================================= +class LinearRegression { + private $ix=array(),$iy=array(); + private $ib=0, $ia=0; + private $icalculated=false; + public $iDet=0, $iCorr=0, $iStdErr=0; + + public function __construct($aDataX,$aDataY) { + if( count($aDataX) !== count($aDataY) ) { + JpGraph::Raise('LinearRegression: X and Y data array must be of equal length.'); + } + $this->ix = $aDataX; + $this->iy = $aDataY; + } + + public function Calc() { + + $this->icalculated = true; + + $n = count($this->ix); + $sx2 = 0 ; + $sy2 = 0 ; + $sxy = 0 ; + $sx = 0 ; + $sy = 0 ; + + for( $i=0; $i < $n; ++$i ) { + $sx2 += $this->ix[$i] * $this->ix[$i]; + $sy2 += $this->iy[$i] * $this->iy[$i]; + $sxy += $this->ix[$i] * $this->iy[$i]; + $sx += $this->ix[$i]; + $sy += $this->iy[$i]; + } + + if( $n*$sx2 - $sx*$sx > __LR_EPSILON ) { + $this->ib = ($n*$sxy - $sx*$sy) / ( $n*$sx2 - $sx*$sx ); + $this->ia = ( $sy - $this->ib*$sx ) / $n; + + $sx = $this->ib * ( $sxy - $sx*$sy/$n ); + $sy2 = $sy2 - $sy*$sy/$n; + $sy = $sy2 - $sx; + + $this->iDet = $sx / $sy2; + $this->iCorr = sqrt($this->iDet); + if( $n > 2 ) { + $this->iStdErr = sqrt( $sy / ($n-2) ); + } + else { + $this->iStdErr = NAN ; + } + } + else { + $this->ib = 0; + $this->ia = 0; + } + + } + + public function GetAB() { + if( $this->icalculated == false ) + $this->Calc(); + return array($this->ia, $this->ib); + } + + public function GetStat() { + if( $this->icalculated == false ) + $this->Calc(); + return array($this->iStdErr, $this->iCorr, $this->iDet); + } + + public function GetY($aMinX, $aMaxX, $aStep=1) { + if( $this->icalculated == false ) + $this->Calc(); + + $yy = array(); + $i = 0; + for( $x=$aMinX; $x <= $aMaxX; $x += $aStep ) { + $xx[$i ] = $x; + $yy[$i++] = $this->ia + $this->ib * $x; + } + + return array($xx,$yy); + } + +} + +?> diff --git a/html/jpgraph/jpgraph_windrose.php b/html/jpgraph/jpgraph_windrose.php new file mode 100644 index 0000000..8eef2cb --- /dev/null +++ b/html/jpgraph/jpgraph_windrose.php @@ -0,0 +1,1566 @@ +<?php +/*======================================================================= + // File: JPGRAPH_WINDROSE.PHP + // Description: Windrose extension for JpGraph + // Created: 2003-09-17 + // Ver: $Id: jpgraph_windrose.php 1928 2010-01-11 19:56:51Z ljp $ + // + // Copyright (c) Asial Corporation. All rights reserved. + //======================================================================== + */ + +require_once('jpgraph_glayout_vh.inc.php'); + +//------------------------------------------------------------------------ +// Determine how many compass directions to show +//------------------------------------------------------------------------ +define('WINDROSE_TYPE4',1); +define('WINDROSE_TYPE8',2); +define('WINDROSE_TYPE16',3); +define('WINDROSE_TYPEFREE',4); + +//------------------------------------------------------------------------ +// How should the labels for the circular grids be aligned +//------------------------------------------------------------------------ +define('LBLALIGN_CENTER',1); +define('LBLALIGN_TOP',2); + +//------------------------------------------------------------------------ +// How should the labels around the plot be align +//------------------------------------------------------------------------ +define('LBLPOSITION_CENTER',1); +define('LBLPOSITION_EDGE',2); + +//------------------------------------------------------------------------ +// Interpretation of ordinal values in the data +//------------------------------------------------------------------------ +define('KEYENCODING_CLOCKWISE',1); +define('KEYENCODING_ANTICLOCKWISE',2); + +// Internal debug flag +define('__DEBUG',false); + + +//=================================================== +// CLASS WindrosePlotScale +//=================================================== +class WindrosePlotScale { + private $iMax,$iDelta=5; + private $iNumCirc=3; + public $iMaxNum=0; + private $iLblFmt='%.0f%%'; + public $iFontFamily=FF_VERDANA,$iFontStyle=FS_NORMAL,$iFontSize=10; + public $iZFontFamily=FF_ARIAL,$iZFontStyle=FS_NORMAL,$iZFontSize=10; + public $iFontColor='black',$iZFontColor='black'; + private $iFontFrameColor=false, $iFontBkgColor=false; + private $iLblZeroTxt=null; + private $iLblAlign=LBLALIGN_CENTER; + public $iAngle='auto'; + private $iManualScale = false; + private $iHideLabels = false; + + function __construct($aData) { + $max=0; + $totlegsum = 0; + $maxnum=0; + $this->iZeroSum=0; + foreach( $aData as $idx => $legdata ) { + $legsum = array_sum($legdata); + $maxnum = max($maxnum,count($legdata)-1); + $max = max($legsum-$legdata[0],$max); + $totlegsum += $legsum; + $this->iZeroSum += $legdata[0] ; + } + if( round($totlegsum) > 100 ) { + JpGraphError::RaiseL(22001,$legsum); + //("Total percentage for all windrose legs in a windrose plot can not exceed 100% !\n(Current max is: ".$legsum.')'); + } + $this->iMax = $max ; + $this->iMaxNum = $maxnum; + $this->iNumCirc = $this->GetNumCirc(); + $this->iMaxVal = $this->iNumCirc * $this->iDelta ; + } + + // Return number of grid circles + function GetNumCirc() { + // Never return less than 1 circles + $num = ceil($this->iMax / $this->iDelta); + return max(1,$num) ; + } + + function SetMaxValue($aMax) { + $this->iMax = $aMax; + $this->iNumCirc = $this->GetNumCirc(); + $this->iMaxVal = $this->iNumCirc * $this->iDelta ; + } + + // Set step size for circular grid + function Set($aMax,$aDelta=null) { + if( $aDelta==null ) { + $this->SetMaxValue($aMax); + return; + } + $this->iDelta = $aDelta; + $this->iNumCirc = ceil($aMax/$aDelta); //$this->GetNumCirc(); + $this->iMaxVal = $this->iNumCirc * $this->iDelta ; + $this->iMax=$aMax; + // Remember that user has specified interval so don't + // do autoscaling + $this->iManualScale = true; + } + + function AutoScale($aRadius,$aMinDist=30) { + + if( $this->iManualScale ) return; + + // Make sure distance (in pixels) between two circles + // is never less than $aMinDist pixels + $tst = ceil($aRadius / $this->iNumCirc) ; + + while( $tst <= $aMinDist && $this->iDelta < 100 ) { + $this->iDelta += 5; + $tst = ceil($aRadius / $this->GetNumCirc()) ; + } + + if( $this->iDelta >= 100 ) { + JpGraphError::RaiseL(22002);//('Graph is too small to have a scale. Please make the graph larger.'); + } + + // If the distance is to large try with multiples of 2 instead + if( $tst > $aMinDist * 3 ) { + $this->iDelta = 2; + $tst = ceil($aRadius / $this->iNumCirc) ; + + while( $tst <= $aMinDist && $this->iDelta < 100 ) { + $this->iDelta += 2; + $tst = ceil($aRadius / $this->GetNumCirc()) ; + } + + if( $this->iDelta >= 100 ) { + JpGraphError::RaiseL(22002); //('Graph is too small to have a scale. Please make the graph larger.'); + } + } + + $this->iNumCirc = $this->GetNumCirc(); + $this->iMaxVal = $this->iNumCirc * $this->iDelta ; + } + + // Return max of all leg values + function GetMax() { + return $this->iMax; + } + + function Hide($aFlg=true) { + $this->iHideLabels = $aFlg; + } + + function SetAngle($aAngle) { + $this->iAngle = $aAngle ; + } + + // Translate a Leg value to radius distance + function RelTranslate($aVal,$r,$ri) { + $tv = round($aVal/$this->iMaxVal*($r-$ri)); + return $tv ; + } + + function SetLabelAlign($aAlign) { + $this->iLblAlign = $aAlign ; + } + + function SetLabelFormat($aFmt) { + $this->iLblFmt = $aFmt ; + } + + function SetLabelFillColor($aBkgColor,$aBorderColor=false) { + + $this->iFontBkgColor = $aBkgColor; + if( $aBorderColor === false ) { + $this->iFontFrameColor = $aBkgColor; + } + else { + $this->iFontFrameColor = $aBorderColor; + } + } + + function SetFontColor($aColor) { + $this->iFontColor = $aColor ; + $this->iZFontColor = $aColor ; + } + + function SetFont($aFontFamily,$aFontStyle=FS_NORMAL,$aFontSize=10) { + $this->iFontFamily = $aFontFamily ; + $this->iFontStyle = $aFontStyle ; + $this->iFontSize = $aFontSize ; + $this->SetZFont($aFontFamily,$aFontStyle,$aFontSize); + } + + function SetZFont($aFontFamily,$aFontStyle=FS_NORMAL,$aFontSize=10) { + $this->iZFontFamily = $aFontFamily ; + $this->iZFontStyle = $aFontStyle ; + $this->iZFontSize = $aFontSize ; + } + + function SetZeroLabel($aTxt) { + $this->iLblZeroTxt = $aTxt ; + } + + function SetZFontColor($aColor) { + $this->iZFontColor = $aColor ; + } + + function StrokeLabels($aImg,$xc,$yc,$ri,$rr) { + + if( $this->iHideLabels ) return; + + // Setup some convinient vairables + $a = $this->iAngle * M_PI/180.0; + $n = $this->iNumCirc; + $d = $this->iDelta; + + // Setup the font and font color + $val = new Text(); + $val->SetFont($this->iFontFamily,$this->iFontStyle,$this->iFontSize); + $val->SetColor($this->iFontColor); + + if( $this->iFontBkgColor !== false ) { + $val->SetBox($this->iFontBkgColor,$this->iFontFrameColor); + } + + // Position the labels relative to the radiant circles + if( $this->iLblAlign == LBLALIGN_TOP ) { + if( $a > 0 && $a <= M_PI/2 ) { + $val->SetAlign('left','bottom'); + } + elseif( $a > M_PI/2 && $a <= M_PI ) { + $val->SetAlign('right','bottom'); + } + } + elseif( $this->iLblAlign == LBLALIGN_CENTER ) { + $val->SetAlign('center','center'); + } + + // Stroke the labels close to each circle + $v = $d ; + $si = sin($a); + $co = cos($a); + for( $i=0; $i < $n; ++$i, $v += $d ) { + $r = $ri + ($i+1) * $rr; + $x = $xc + $co * $r; + $y = $yc - $si * $r; + $val->Set(sprintf($this->iLblFmt,$v)); + $val->Stroke($aImg,$x,$y); + } + + // Print the text in the zero circle + if( $this->iLblZeroTxt === null ) { + $this->iLblZeroTxt = sprintf($this->iLblFmt,$this->iZeroSum); + } + else { + $this->iLblZeroTxt = sprintf($this->iLblZeroTxt,$this->iZeroSum); + } + + $val->Set($this->iLblZeroTxt); + $val->SetAlign('center','center'); + $val->SetParagraphAlign('center'); + $val->SetColor($this->iZFontColor); + $val->SetFont($this->iZFontFamily,$this->iZFontStyle,$this->iZFontSize); + $val->Stroke($aImg,$xc,$yc); + } +} + +//=================================================== +// CLASS LegendStyle +//=================================================== +class LegendStyle { + public $iLength = 40, $iMargin = 20 , $iBottomMargin=5; + public $iCircleWeight=2, $iCircleRadius = 18, $iCircleColor='black'; + public $iTxtFontFamily=FF_VERDANA,$iTxtFontStyle=FS_NORMAL,$iTxtFontSize=8; + public $iLblFontFamily=FF_VERDANA,$iLblFontStyle=FS_NORMAL,$iLblFontSize=8; + public $iCircleFontFamily=FF_VERDANA,$iCircleFontStyle=FS_NORMAL,$iCircleFontSize=8; + public $iLblFontColor='black',$iTxtFontColor='black',$iCircleFontColor='black'; + public $iShow=true; + public $iFormatString='%.1f'; + public $iTxtMargin=6, $iTxt=''; + public $iZCircleTxt='Calm'; + + function SetFont($aFontFamily,$aFontStyle=FS_NORMAL,$aFontSize=10) { + $this->iLblFontFamily = $aFontFamily ; + $this->iLblFontStyle = $aFontStyle ; + $this->iLblFontSize = $aFontSize ; + $this->iTxtFontFamily = $aFontFamily ; + $this->iTxtFontStyle = $aFontStyle ; + $this->iTxtFontSize = $aFontSize ; + $this->iCircleFontFamily = $aFontFamily ; + $this->iCircleFontStyle = $aFontStyle ; + $this->iCircleFontSize = $aFontSize ; + } + + function SetLFont($aFontFamily,$aFontStyle=FS_NORMAL,$aFontSize=10) { + $this->iLblFontFamily = $aFontFamily ; + $this->iLblFontStyle = $aFontStyle ; + $this->iLblFontSize = $aFontSize ; + } + + function SetTFont($aFontFamily,$aFontStyle=FS_NORMAL,$aFontSize=10) { + $this->iTxtFontFamily = $aFontFamily ; + $this->iTxtFontStyle = $aFontStyle ; + $this->iTxtFontSize = $aFontSize ; + } + + function SetCFont($aFontFamily,$aFontStyle=FS_NORMAL,$aFontSize=10) { + $this->iCircleFontFamily = $aFontFamily ; + $this->iCircleFontStyle = $aFontStyle ; + $this->iCircleFontSize = $aFontSize ; + } + + + function SetFontColor($aColor) { + $this->iTxtFontColor = $aColor ; + $this->iLblFontColor = $aColor ; + $this->iCircleFontColor = $aColor ; + } + + function SetTFontColor($aColor) { + $this->iTxtFontColor = $aColor ; + } + + function SetLFontColor($aColor) { + $this->iLblFontColor = $aColor ; + } + + function SetCFontColor($aColor) { + $this->iCircleFontColor = $aColor ; + } + + function SetCircleWeight($aWeight) { + $this->iCircleWeight = $aWeight; + } + + function SetCircleRadius($aRadius) { + $this->iCircleRadius = $aRadius; + } + + function SetCircleColor($aColor) { + $this->iCircleColor = $aColor ; + } + + function SetCircleText($aTxt) { + $this->iZCircleTxt = $aTxt; + } + + function SetMargin($aMarg,$aBottomMargin=5) { + $this->iMargin=$aMarg; + $this->iBottomMargin=$aBottomMargin; + } + + function SetLength($aLength) { + $this->iLength = $aLength ; + } + + function Show($aFlg=true) { + $this->iShow = $aFlg; + } + + function Hide($aFlg=true) { + $this->iShow = ! $aFlg; + } + + function SetFormat($aFmt) { + $this->iFormatString=$aFmt; + } + + function SetText($aTxt) { + $this->iTxt = $aTxt ; + } + +} + +define('RANGE_OVERLAPPING',0); +define('RANGE_DISCRETE',1); + +//=================================================== +// CLASS WindrosePlot +//=================================================== +class WindrosePlot { + private $iAntiAlias=true; + private $iData=array(); + public $iX=0.5,$iY=0.5; + public $iSize=0.55; + private $iGridColor1='gray',$iGridColor2='darkgreen'; + private $iRadialColorArray=array(); + private $iRadialWeightArray=array(); + private $iRadialStyleArray=array(); + private $iRanges = array(1,2,3,5,6,10,13.5,99.0); + private $iRangeStyle = RANGE_OVERLAPPING ; + public $iCenterSize=60; + private $iType = WINDROSE_TYPE16; + public $iFontFamily=FF_VERDANA,$iFontStyle=FS_NORMAL,$iFontSize=10; + public $iFontColor='darkgray'; + private $iRadialGridStyle='longdashed'; + private $iAllDirectionLabels = array('E','ENE','NE','NNE','N','NNW','NW','WNW','W','WSW','SW','SSW','S','SSE','SE','ESE'); + private $iStandardDirections = array(); + private $iCircGridWeight=3, $iRadialGridWeight=1; + private $iLabelMargin=12; + private $iLegweights = array(2,4,6,8,10,12,14,16,18,20); + private $iLegColors = array('orange','black','blue','red','green','purple','navy','yellow','brown'); + private $iLabelFormatString='', $iLabels=array(); + private $iLabelPositioning = LBLPOSITION_EDGE; + private $iColor='white'; + private $iShowBox=false, $iBoxColor='black',$iBoxWeight=1,$iBoxStyle='solid'; + private $iOrdinalEncoding=KEYENCODING_ANTICLOCKWISE; + public $legend=null; + + function __construct($aData) { + $this->iData = $aData; + $this->legend = new LegendStyle(); + + // Setup the scale + $this->scale = new WindrosePlotScale($this->iData); + + // default label for free type i agle and a degree sign + $this->iLabelFormatString = '%.1f'.SymChar::Get('degree'); + + $delta = 2*M_PI/16; + for( $i=0, $a=0; $i < 16; ++$i, $a += $delta ) { + $this->iStandardDirections[$this->iAllDirectionLabels[$i]] = $a; + } + } + + // Dummy method to make window plots have the same signature as the + // layout classes since windrose plots are "leaf" classes in the hierarchy + function LayoutSize() { + return 1; + } + + function SetSize($aSize) { + $this->iSize = $aSize; + } + + function SetDataKeyEncoding($aEncoding) { + $this->iOrdinalEncoding = $aEncoding; + } + + function SetColor($aColor) { + $this->iColor = $aColor; + } + + function SetRadialColors($aColors) { + $this->iRadialColorArray = $aColors; + } + + function SetRadialWeights($aWeights) { + $this->iRadialWeightArray = $aWeights; + } + + function SetRadialStyles($aStyles) { + $this->iRadialStyleArray = $aStyles; + } + + function SetBox($aColor='black',$aWeight=1, $aStyle='solid', $aShow=true) { + $this->iShowBox = $aShow ; + $this->iBoxColor = $aColor ; + $this->iBoxWeight = $aWeight ; + $this->iBoxStyle = $aStyle; + } + + function SetLabels($aLabels) { + $this->iLabels = $aLabels ; + } + + function SetLabelMargin($aMarg) { + $this->iLabelMargin = $aMarg ; + } + + function SetLabelFormat($aLblFormat) { + $this->iLabelFormatString = $aLblFormat ; + } + + function SetCompassLabels($aLabels) { + if( count($aLabels) != 16 ) { + JpgraphError::RaiseL(22004); //('Label specification for windrose directions must have 16 values (one for each compass direction).'); + } + $this->iAllDirectionLabels = $aLabels ; + + $delta = 2*M_PI/16; + for( $i=0, $a=0; $i < 16; ++$i, $a += $delta ) { + $this->iStandardDirections[$this->iAllDirectionLabels[$i]] = $a; + } + + } + + function SetCenterSize($aSize) { + $this->iCenterSize = $aSize; + } + // Alias for SetCenterSize + function SetZCircleSize($aSize) { + $this->iCenterSize = $aSize; + } + + function SetFont($aFFam,$aFStyle=FS_NORMAL,$aFSize=10) { + $this->iFontFamily = $aFFam ; + $this->iFontStyle = $aFStyle ; + $this->iFontSize = $aFSize ; + } + + function SetFontColor($aColor) { + $this->iFontColor=$aColor; + } + + function SetGridColor($aColor1,$aColor2) { + $this->iGridColor1 = $aColor1; + $this->iGridColor2 = $aColor2; + } + + function SetGridWeight($aGrid1=1,$aGrid2=2) { + $this->iCircGridWeight = $aGrid1 ; + $this->iRadialGridWeight = $aGrid2 ; + } + + function SetRadialGridStyle($aStyle) { + $aStyle = strtolower($aStyle); + if( !in_array($aStyle,array('solid','dotted','dashed','longdashed')) ) { + JpGraphError::RaiseL(22005); //("Line style for radial lines must be on of ('solid','dotted','dashed','longdashed') "); + } + $this->iRadialGridStyle=$aStyle; + } + + function SetRanges($aRanges) { + $this->iRanges = $aRanges; + } + + function SetRangeStyle($aStyle) { + $this->iRangeStyle = $aStyle; + } + + function SetRangeColors($aLegColors) { + $this->iLegColors = $aLegColors; + } + + function SetRangeWeights($aWeights) { + $n=count($aWeights); + for($i=0; $i< $n; ++$i ) { + $aWeights[$i] = floor($aWeights[$i]/2); + } + $this->iLegweights = $aWeights; + + } + + function SetType($aType) { + if( $aType < WINDROSE_TYPE4 || $aType > WINDROSE_TYPEFREE ) { + JpGraphError::RaiseL(22006); //('Illegal windrose type specified.'); + } + $this->iType = $aType; + } + + // Alias for SetPos() + function SetCenterPos($aX,$aY) { + $this->iX = $aX; + $this->iY = $aY; + } + + function SetPos($aX,$aY) { + $this->iX = $aX; + $this->iY = $aY; + } + + function SetAntiAlias($aFlag) { + $this->iAntiAlias = $aFlag ; + if( ! $aFlag ) + $this->iCircGridWeight = 1; + } + + function _ThickCircle($aImg,$aXC,$aYC,$aRad,$aWeight=2,$aColor) { + + $aImg->SetColor($aColor); + $aRad *= 2 ; + $aImg->Ellipse($aXC,$aYC,$aRad,$aRad); + if( $aWeight > 1 ) { + $aImg->Ellipse($aXC,$aYC,$aRad+1,$aRad+1); + $aImg->Ellipse($aXC,$aYC,$aRad+2,$aRad+2); + if( $aWeight > 2 ) { + $aImg->Ellipse($aXC,$aYC,$aRad+3,$aRad+3); + $aImg->Ellipse($aXC,$aYC,$aRad+3,$aRad+4); + $aImg->Ellipse($aXC,$aYC,$aRad+4,$aRad+3); + } + } + } + + function _StrokeWindLeg($aImg,$xc,$yc,$a,$ri,$r,$weight,$color) { + + // If less than 1 px long then we assume this has been caused by rounding problems + // and should not be stroked + if( $r < 1 ) return; + + $xt = $xc + cos($a)*$ri; + $yt = $yc - sin($a)*$ri; + $xxt = $xc + cos($a)*($ri+$r); + $yyt = $yc - sin($a)*($ri+$r); + + $x1 = $xt - $weight*sin($a); + $y1 = $yt - $weight*cos($a); + $x2 = $xxt - $weight*sin($a); + $y2 = $yyt - $weight*cos($a); + + $x3 = $xxt + $weight*sin($a); + $y3 = $yyt + $weight*cos($a); + $x4 = $xt + $weight*sin($a); + $y4 = $yt + $weight*cos($a); + + $pts = array($x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4); + $aImg->SetColor($color); + $aImg->FilledPolygon($pts); + + } + + function _StrokeLegend($aImg,$x,$y,$scaling=1,$aReturnWidth=false) { + + if( ! $this->legend->iShow ) return 0; + + $nlc = count($this->iLegColors); + $nlw = count($this->iLegweights); + + // Setup font for ranges + $value = new Text(); + $value->SetAlign('center','bottom'); + $value->SetFont($this->legend->iLblFontFamily, + $this->legend->iLblFontStyle, + $this->legend->iLblFontSize*$scaling); + $value->SetColor($this->legend->iLblFontColor); + + // Remember x-center + $xcenter = $x ; + + // Construct format string + $fmt = $this->legend->iFormatString.'-'.$this->legend->iFormatString; + + // Make sure that the length of each range is enough to cover the + // size of the labels + $tst = sprintf($fmt,$this->iRanges[0],$this->iRanges[1]); + $value->Set($tst); + $w = $value->GetWidth($aImg); + $l = round(max($this->legend->iLength * $scaling,$w*1.5)); + + $r = $this->legend->iCircleRadius * $scaling ; + $len = 2*$r + $this->scale->iMaxNum * $l; + + // We are called just to find out the width + if( $aReturnWidth ) return $len; + + $x -= round($len/2); + $x += $r; + + // 4 pixels extra vertical margin since the circle sometimes is +/- 1 pixel of the + // theorethical radius due to imperfection in the GD library + //$y -= round(max($r,$scaling*$this->iLegweights[($this->scale->iMaxNum-1) % $nlw])+4*$scaling); + $y -= ($this->legend->iCircleRadius + 2)*$scaling+$this->legend->iBottomMargin*$scaling; + + // Adjust for bottom text + if( $this->legend->iTxt != '' ) { + // Setup font for text + $value->Set($this->legend->iTxt); + $y -= /*$this->legend->iTxtMargin + */ $value->GetHeight($aImg); + } + + // Stroke 0-circle + $this->_ThickCircle($aImg,$x,$y,$r,$this->legend->iCircleWeight, + $this->legend->iCircleColor); + + // Remember the center of the circe + $xc=$x; $yc=$y; + + $value->SetAlign('center','bottom'); + $x += $r+1; + + // Stroke all used ranges + $txty = $y - + round($this->iLegweights[($this->scale->iMaxNum-1)%$nlw]*$scaling) - 4*$scaling; + if( $this->scale->iMaxNum >= count($this->iRanges) ) { + JpGraphError::RaiseL(22007); //('To few values for the range legend.'); + } + $i=0;$idx=0; + while( $i < $this->scale->iMaxNum ) { + $y1 = $y - round($this->iLegweights[$i % $nlw]*$scaling); + $y2 = $y + round($this->iLegweights[$i % $nlw]*$scaling); + $x2 = $x + $l ; + $aImg->SetColor($this->iLegColors[$i % $nlc]); + $aImg->FilledRectangle($x,$y1,$x2,$y2); + if( $this->iRangeStyle == RANGE_OVERLAPPING ) { + $lbl = sprintf($fmt,$this->iRanges[$idx],$this->iRanges[$idx+1]); + } + else { + $lbl = sprintf($fmt,$this->iRanges[$idx],$this->iRanges[$idx+1]); + ++$idx; + } + $value->Set($lbl); + $value->Stroke($aImg,$x+$l/2,$txty); + $x = $x2; + ++$i;++$idx; + } + + // Setup circle font + $value->SetFont($this->legend->iCircleFontFamily, + $this->legend->iCircleFontStyle, + $this->legend->iCircleFontSize*$scaling); + $value->SetColor($this->legend->iCircleFontColor); + + // Stroke 0-circle text + $value->Set($this->legend->iZCircleTxt); + $value->SetAlign('center','center'); + $value->ParagraphAlign('center'); + $value->Stroke($aImg,$xc,$yc); + + // Setup circle font + $value->SetFont($this->legend->iTxtFontFamily, + $this->legend->iTxtFontStyle, + $this->legend->iTxtFontSize*$scaling); + $value->SetColor($this->legend->iTxtFontColor); + + // Draw the text under the legend + $value->Set($this->legend->iTxt); + $value->SetAlign('center','top'); + $value->SetParagraphAlign('center'); + $value->Stroke($aImg,$xcenter,$y2+$this->legend->iTxtMargin*$scaling); + } + + function SetAutoScaleAngle($aIsRegRose=true) { + + // If the user already has manually set an angle don't + // trye to find a position + if( is_numeric($this->scale->iAngle) ) + return; + + if( $aIsRegRose ) { + + // Create a complete data for all directions + // and translate string directions to ordinal values. + // This will much simplify the logic below + for( $i=0; $i < 16; ++$i ) { + $dtxt = $this->iAllDirectionLabels[$i]; + if( !empty($this->iData[$dtxt]) ) { + $data[$i] = $this->iData[$dtxt]; + } + elseif( !empty($this->iData[strtolower($dtxt)]) ) { + $data[$i] = $this->iData[strtolower($dtxt)]; + } + elseif( !empty($this->iData[$i]) ) { + $data[$i] = $this->iData[$i]; + } + else { + $data[$i] = array(); + } + } + + // Find the leg which has the lowest weighted sum of number of data around it + $c0 = array_sum($data[0]); + $c1 = array_sum($data[1]); + $found = 1; + $min = $c0+$c1*100; // Initialize to a high value + for( $i=1; $i < 15; ++$i ) { + $c2 = array_sum($data[$i+1]); + + // Weight the leg we will use more to give preference + // to a short middle leg even if the 3 way sum is similair + $w = $c0 + 3*$c1 + $c2 ; + if( $w < $min ) { + $min = $w; + $found = $i; + } + $c0 = $c1; + $c1 = $c2; + } + $this->scale->iAngle = $found*22.5; + } + else { + $n = count($this->iData); + foreach( $this->iData as $dir => $leg ) { + if( !is_numeric($dir) ) { + $pos = array_search(strtoupper($dir),$this->iAllDirectionLabels); + if( $pos !== false ) { + $dir = $pos*22.5; + } + } + $data[round($dir)] = $leg; + } + + // Get all the angles for the data and sort it + $keys = array_keys($data); + sort($keys, SORT_NUMERIC); + + $n = count($data); + $found = false; + $max = 0 ; + for( $i=0; $i < 15; ++$i ) { + $try_a = round(22.5*$i); + + if( $try_a > $keys[$n-1] ) break; + + if( in_array($try_a,$keys) ) continue; + + // Find the angle just lower than this + $j=0; + while( $j < $n && $keys[$j] <= $try_a ) ++$j; + if( $j == 0 ) { + $kj = 0; $keys[$n-1]; + $d1 = 0; abs($kj-$try_a); + } + else { + --$j; + $kj = $keys[$j]; + $d1 = abs($kj-$try_a); + } + + // Find the angle just larger than this + $l=$n-1; + while( $l >= 0 && $keys[$l] >= $try_a ) --$l; + if( $l == $n-1) { + $kl = $keys[0]; + $d2 = abs($kl-$try_a); + } + else { + ++$l; + $kl = $keys[$l]; + $d2 = abs($kl-$try_a); + } + + // Weight the distance so that legs with large spread + // gets a better weight + $w = $d1 + $d2; + if( $i == 0 ) { + $w = round(1.4 * $w); + } + $diff = abs($d1 - $d2); + $w *= (360-$diff); + if( $w > $max ) { + $found = $i; + $max = $w; + } + } + + $a = $found*22.5; + + // Some heuristics to have some preferred positions + if( $keys[$n-1] < 25 ) $a = 45; + elseif( $keys[0] > 60 ) $a = 45; + elseif( $keys[0] > 25 && $keys[$n-1] < 340 ) $a = 0; + elseif( $keys[$n-1] < 75 ) $a = 90; + elseif( $keys[$n-1] < 120 ) $a = 135; + elseif( $keys[$n-1] < 160 ) $a = 180; + + $this->scale->iAngle = $a ; + } + } + + function NormAngle($a) { + while( $a > 360 ) { + $a -= 360; + } + return $a; + } + + function SetLabelPosition($aPos) { + $this->iLabelPositioning = $aPos ; + } + + function _StrokeFreeRose($dblImg,$value,$scaling,$xc,$yc,$r,$ri) { + + // Plot radial grid lines and remember the end position + // and the angle for later use when plotting the labels + if( $this->iType != WINDROSE_TYPEFREE ) { + JpGraphError::RaiseL(22008); //('Internal error: Trying to plot free Windrose even though type is not a free windorose'); + } + + // Check if we should auto-position the angle for the + // labels. Basically we try to find a firection with smallest + // (or none) data. + $this->SetAutoScaleAngle(false); + + $nlc = count($this->iLegColors); + $nlw = count($this->iLegweights); + + // Stroke grid lines for directions and remember the + // position for the labels + $txtpos=array(); + $num = count($this->iData); + + $keys = array_keys($this->iData); + + foreach( $this->iData as $dir => $legdata ) { + if( in_array($dir,$this->iAllDirectionLabels,true) === true) { + $a = $this->iStandardDirections[strtoupper($dir)]; + if( in_array($a*180/M_PI,$keys) ) { + JpGraphError::RaiseL(22009,round($a*180/M_PI)); + //('You have specified the same direction twice, once with an angle and once with a compass direction ('.$a*180/M_PI.' degrees.)'); + } + } + elseif( is_numeric($dir) ) { + $this->NormAngle($dir); + + if( $this->iOrdinalEncoding == KEYENCODING_CLOCKWISE ) { + $dir = 360-$dir; + } + + $a = $dir * M_PI/180; + } + else { + JpGraphError::RaiseL(22010);//('Direction must either be a numeric value or one of the 16 compass directions'); + } + + $xxc = round($xc + cos($a)*$ri); + $yyc = round($yc - sin($a)*$ri); + $x = round($xc + cos($a)*$r); + $y = round($yc - sin($a)*$r); + if( empty($this->iRadialColorArray[$dir]) ) { + $dblImg->SetColor($this->iGridColor2); + } + else { + $dblImg->SetColor($this->iRadialColorArray[$dir]); + } + if( empty($this->iRadialWeightArray[$dir]) ) { + $dblImg->SetLineWeight($this->iRadialGridWeight); + } + else { + $dblImg->SetLineWeight($this->iRadialWeightArray[$dir]); + } + if( empty($this->iRadialStyleArray[$dir]) ) { + $dblImg->SetLineStyle($this->iRadialGridStyle); + } + else { + $dblImg->SetLineStyle($this->iRadialStyleArray[$dir]); + } + $dblImg->StyleLine($xxc,$yyc,$x,$y); + $txtpos[] = array($x,$y,$a); + } + $dblImg->SetLineWeight(1); + + // Setup labels + $lr = $scaling * $this->iLabelMargin; + + if( $this->iLabelPositioning == LBLPOSITION_EDGE ) { + $value->SetAlign('left','top'); + } + else { + $value->SetAlign('center','center'); + $value->SetMargin(0); + } + + for($i=0; $i < $num; ++$i ) { + + list($x,$y,$a) = $txtpos[$i]; + + // Determine the label + + $da = $a*180/M_PI; + if( $this->iOrdinalEncoding == KEYENCODING_CLOCKWISE ) { + $da = 360 - $da; + } + + //$da = 360-$da; + + if( !empty($this->iLabels[$keys[$i]]) ) { + $lbl = $this->iLabels[$keys[$i]]; + } + else { + $lbl = sprintf($this->iLabelFormatString,$da); + } + + if( $this->iLabelPositioning == LBLPOSITION_CENTER ) { + $dx = $dy = 0; + } + else { + // LBLPOSIITON_EDGE + if( $a>=7*M_PI/4 || $a <= M_PI/4 ) $dx=0; + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dx=($a-M_PI/4)*2/M_PI; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dx=1; + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dx=(1-($a-M_PI*5/4)*2/M_PI); + + if( $a>=7*M_PI/4 ) $dy=(($a-M_PI)-3*M_PI/4)*2/M_PI; + if( $a<=M_PI/4 ) $dy=(0.5+$a*2/M_PI); + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dy=1; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dy=(1-($a-3*M_PI/4)*2/M_PI); + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dy=0; + } + + $value->Set($lbl); + $th = $value->GetHeight($dblImg); + $tw = $value->GetWidth($dblImg); + $xt=round($lr*cos($a)+$x) - $dx*$tw; + $yt=round($y-$lr*sin($a)) - $dy*$th; + + $value->Stroke($dblImg,$xt,$yt); + } + + if( __DEBUG ) { + $dblImg->SetColor('red'); + $dblImg->Circle($xc,$yc,$lr+$r); + } + + // Stroke all the legs + reset($this->iData); + $i=0; + foreach($this->iData as $dir => $legdata) { + $legdata = array_slice($legdata,1); + $nn = count($legdata); + + $a = $txtpos[$i][2]; + $rri = $ri/$scaling; + for( $j=0; $j < $nn; ++$j ) { + // We want the non scaled original radius + $legr = $this->scale->RelTranslate($legdata[$j],$r/$scaling,$ri/$scaling) ; + $this->_StrokeWindLeg($dblImg, $xc, $yc, $a, + $rri *$scaling, + $legr *$scaling, + $this->iLegweights[$j % $nlw] * $scaling, + $this->iLegColors[$j % $nlc]); + $rri += $legr; + } + ++$i; + } + } + + // Translate potential string specified compass labels to their + // corresponding index. + function FixupIndexes($aDataArray,$num) { + $ret = array(); + $keys = array_keys($aDataArray); + foreach($aDataArray as $idx => $data) { + if( is_string($idx) ) { + $idx = strtoupper($idx); + $res = array_search($idx,$this->iAllDirectionLabels); + if( $res === false ) { + JpGraphError::RaiseL(22011,$idx); //('Windrose index must be numeric or direction label. You have specified index='.$idx); + } + $idx = $res; + if( $idx % (16 / $num) !== 0 ) { + JpGraphError::RaiseL(22012); //('Windrose radial axis specification contains a direction which is not enabled.'); + } + $idx /= (16/$num) ; + + if( in_array($idx,$keys,1) ) { + JpgraphError::RaiseL(22013,$idx); //('You have specified the look&feel for the same compass direction twice, once with text and once with index (Index='.$idx.')'); + } + } + if( $idx < 0 || $idx > 15 ) { + JpgraphError::RaiseL(22014); //('Index for copmass direction must be between 0 and 15.'); + } + $ret[$idx] = $data; + } + return $ret; + } + + function _StrokeRegularRose($dblImg,$value,$scaling,$xc,$yc,$r,$ri) { + // _StrokeRegularRose($dblImg,$xc,$yc,$r,$ri) + // Plot radial grid lines and remember the end position + // and the angle for later use when plotting the labels + switch( $this->iType ) { + case WINDROSE_TYPE4: + $num = 4; break; + case WINDROSE_TYPE8: + $num = 8; break; + case WINDROSE_TYPE16: + $num = 16; break; + default: + JpGraphError::RaiseL(22015);//('You have specified an undefined Windrose plot type.'); + } + + // Check if we should auto-position the angle for the + // labels. Basically we try to find a firection with smallest + // (or none) data. + $this->SetAutoScaleAngle(true); + + $nlc = count($this->iLegColors); + $nlw = count($this->iLegweights); + + $this->iRadialColorArray = $this->FixupIndexes($this->iRadialColorArray,$num); + $this->iRadialWeightArray = $this->FixupIndexes($this->iRadialWeightArray,$num); + $this->iRadialStyleArray = $this->FixupIndexes($this->iRadialStyleArray,$num); + + $txtpos=array(); + $a = 2*M_PI/$num; + $dblImg->SetColor($this->iGridColor2); + $dblImg->SetLineStyle($this->iRadialGridStyle); + $dblImg->SetLineWeight($this->iRadialGridWeight); + + // Translate any name specified directions to the index + // so we can easily use it in the loop below + for($i=0; $i < $num; ++$i ) { + $xxc = round($xc + cos($a*$i)*$ri); + $yyc = round($yc - sin($a*$i)*$ri); + $x = round($xc + cos($a*$i)*$r); + $y = round($yc - sin($a*$i)*$r); + if( empty($this->iRadialColorArray[$i]) ) { + $dblImg->SetColor($this->iGridColor2); + } + else { + $dblImg->SetColor($this->iRadialColorArray[$i]); + } + if( empty($this->iRadialWeightArray[$i]) ) { + $dblImg->SetLineWeight($this->iRadialGridWeight); + } + else { + $dblImg->SetLineWeight($this->iRadialWeightArray[$i]); + } + if( empty($this->iRadialStyleArray[$i]) ) { + $dblImg->SetLineStyle($this->iRadialGridStyle); + } + else { + $dblImg->SetLineStyle($this->iRadialStyleArray[$i]); + } + + $dblImg->StyleLine($xxc,$yyc,$x,$y); + $txtpos[] = array($x,$y,$a*$i); + } + $dblImg->SetLineWeight(1); + + $lr = $scaling * $this->iLabelMargin; + if( $this->iLabelPositioning == LBLPOSITION_CENTER ) { + $value->SetAlign('center','center'); + } + else { + $value->SetAlign('left','top'); + $value->SetMargin(0); + $lr /= 2 ; + } + + for($i=0; $i < $num; ++$i ) { + list($x,$y,$a) = $txtpos[$i]; + + // Set the position of the label + if( $this->iLabelPositioning == LBLPOSITION_CENTER ) { + $dx = $dy = 0; + } + else { + // LBLPOSIITON_EDGE + if( $a>=7*M_PI/4 || $a <= M_PI/4 ) $dx=0; + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dx=($a-M_PI/4)*2/M_PI; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dx=1; + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dx=(1-($a-M_PI*5/4)*2/M_PI); + + if( $a>=7*M_PI/4 ) $dy=(($a-M_PI)-3*M_PI/4)*2/M_PI; + if( $a<=M_PI/4 ) $dy=(0.5+$a*2/M_PI); + if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dy=1; + if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dy=(1-($a-3*M_PI/4)*2/M_PI); + if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dy=0; + } + + $value->Set($this->iAllDirectionLabels[$i*(16/$num)]); + $th = $value->GetHeight($dblImg); + $tw = $value->GetWidth($dblImg); + $xt=round($lr*cos($a)+$x) - $dx*$tw; + $yt=round($y-$lr*sin($a)) - $dy*$th; + + $value->Stroke($dblImg,$xt,$yt); + } + + if( __DEBUG ) { + $dblImg->SetColor("red"); + $dblImg->Circle($xc,$yc,$lr+$r); + } + + // Stroke all the legs + reset($this->iData); + $keys = array_keys($this->iData); + foreach($this->iData as $idx => $legdata) { + $legdata = array_slice($legdata,1); + $nn = count($legdata); + if( is_string($idx) ) { + $idx = strtoupper($idx); + $idx = array_search($idx,$this->iAllDirectionLabels); + if( $idx === false ) { + JpGraphError::RaiseL(22016);//('Windrose leg index must be numeric or direction label.'); + } + if( $idx % (16 / $num) !== 0 ) { + JpGraphError::RaiseL(22017);//('Windrose data contains a direction which is not enabled. Please adjust what labels are displayed.'); + } + $idx /= (16/$num) ; + + if( in_array($idx,$keys,1) ) { + JpgraphError::RaiseL(22018,$idx);//('You have specified data for the same compass direction twice, once with text and once with index (Index='.$idx.')'); + + } + } + if( $idx < 0 || $idx > 15 ) { + JpgraphError::RaiseL(22019);//('Index for direction must be between 0 and 15. You can\'t specify angles for a Regular Windplot, only index and compass directions.'); + } + $a = $idx * (360 / $num) ; + $a *= M_PI/180.0; + $rri = $ri/$scaling; + for( $j=0; $j < $nn; ++$j ) { + // We want the non scaled original radius + $legr = $this->scale->RelTranslate($legdata[$j], $r/$scaling,$ri/$scaling) ; + $this->_StrokeWindLeg($dblImg, $xc, $yc, $a, + $rri *$scaling, + $legr *$scaling, + $this->iLegweights[$j % $nlw] * $scaling, + $this->iLegColors[$j % $nlc]); + $rri += $legr; + } + } + } + + + function getWidth($aImg) { + + $scaling = 1;//$this->iAntiAlias ? 2 : 1 ; + if( $this->iSize > 0 && $this->iSize < 1 ) { + $this->iSize *= min($aImg->width,$aImg->height); + } + + + $value = new Text(); + $value->SetFont($this->iFontFamily,$this->iFontStyle,$this->iFontSize*$scaling); + $value->SetColor($this->iFontColor); + // Setup extra size around the graph needed so that the labels + // doesn't get cut. For this we need to find the largest label. + // The code below gives a possible a little to large margin. The + // really, really proper way would be to account for what angle + // the label are at + $n = count($this->iLabels); + if( $n > 0 ) { + $maxh=0;$maxw=0; + foreach($this->iLabels as $key => $lbl) { + $value->Set($lbl); + $maxw = max($maxw,$value->GetWidth($aImg)); + } + } + else { + $value->Set('888.888'); // Dummy value to get width/height + $maxw = $value->GetWidth($aImg); + } + // Add an extra margin of 50% the font size + $maxw += round($this->iFontSize*$scaling * 0.4) ; + + $valxmarg = 1.5*$maxw+2*$this->iLabelMargin*$scaling; + $w = round($this->iSize*$scaling + $valxmarg); + + // Make sure that the width of the legend fits + $legendwidth = $this->_StrokeLegend($aImg,0,0,$scaling,true)+10*$scaling; + $w = max($w,$legendwidth); + + return $w; + } + + function getHeight($aImg) { + + $scaling = 1;//$this->iAntiAlias ? 2 : 1 ; + if( $this->iSize > 0 && $this->iSize < 1 ) { + $this->iSize *= min($aImg->width,$aImg->height); + } + + $value = new Text(); + $value->SetFont($this->iFontFamily,$this->iFontStyle,$this->iFontSize*$scaling); + $value->SetColor($this->iFontColor); + // Setup extra size around the graph needed so that the labels + // doesn't get cut. For this we need to find the largest label. + // The code below gives a possible a little to large margin. The + // really, really proper way would be to account for what angle + // the label are at + $n = count($this->iLabels); + if( $n > 0 ) { + $maxh=0;$maxw=0; + foreach($this->iLabels as $key => $lbl) { + $value->Set($lbl); + $maxh = max($maxh,$value->GetHeight($aImg)); + } + } + else { + $value->Set('180.8'); // Dummy value to get width/height + $maxh = $value->GetHeight($aImg); + } + // Add an extra margin of 50% the font size + //$maxh += round($this->iFontSize*$scaling * 0.5) ; + $valymarg = 2*$maxh+2*$this->iLabelMargin*$scaling; + + $legendheight = round($this->legend->iShow ? 1 : 0); + $legendheight *= max($this->legend->iCircleRadius*2,$this->legend->iTxtFontSize*2)+ + $this->legend->iMargin + $this->legend->iBottomMargin + 2; + $legendheight *= $scaling; + $h = round($this->iSize*$scaling + $valymarg) + $legendheight ; + + return $h; + } + + function Stroke($aGraph) { + + $aImg = $aGraph->img; + + if( $this->iX > 0 && $this->iX < 1 ) { + $this->iX = round( $aImg->width * $this->iX ) ; + } + + if( $this->iY > 0 && $this->iY < 1 ) { + $this->iY = round( $aImg->height * $this->iY ) ; + } + + if( $this->iSize > 0 && $this->iSize < 1 ) { + $this->iSize *= min($aImg->width,$aImg->height); + } + + if( $this->iCenterSize > 0 && $this->iCenterSize < 1 ) { + $this->iCenterSize *= $this->iSize; + } + + $this->scale->AutoScale(($this->iSize - $this->iCenterSize)/2, round(2.5*$this->scale->iFontSize)); + + $scaling = $this->iAntiAlias ? 2 : 1 ; + + $value = new Text(); + $value->SetFont($this->iFontFamily,$this->iFontStyle,$this->iFontSize*$scaling); + $value->SetColor($this->iFontColor); + + $legendheight = round($this->legend->iShow ? 1 : 0); + $legendheight *= max($this->legend->iCircleRadius*2,$this->legend->iTxtFontSize*2)+ + $this->legend->iMargin + $this->legend->iBottomMargin + 2; + $legendheight *= $scaling; + + $w = $scaling*$this->getWidth($aImg); + $h = $scaling*$this->getHeight($aImg); + + // Copy back the double buffered image to the proper canvas + $ww = $w / $scaling ; + $hh = $h / $scaling ; + + // Create the double buffer + if( $this->iAntiAlias ) { + $dblImg = new RotImage($w,$h); + // Set the background color + $dblImg->SetColor($this->iColor); + $dblImg->FilledRectangle(0,0,$w,$h); + } + else { + $dblImg = $aImg ; + // Make sure the ix and it coordinates correpond to the new top left center + $dblImg->SetTranslation($this->iX-$w/2, $this->iY-$h/2); + } + + if( __DEBUG ) { + $dblImg->SetColor('red'); + $dblImg->Rectangle(0,0,$w-1,$h-1); + } + + $dblImg->SetColor('black'); + + if( $this->iShowBox ) { + $dblImg->SetColor($this->iBoxColor); + $old = $dblImg->SetLineWeight($this->iBoxWeight); + $dblImg->SetLineStyle($this->iBoxStyle); + $dblImg->Rectangle(0,0,$w-1,$h-1); + $dblImg->SetLineWeight($old); + } + + $xc = round($w/2); + $yc = round(($h-$legendheight)/2); + + if( __DEBUG ) { + $dblImg->SetColor('red'); + $old = $dblImg->SetLineWeight(2); + $dblImg->Line($xc-5,$yc-5,$xc+5,$yc+5); + $dblImg->Line($xc+5,$yc-5,$xc-5,$yc+5); + $dblImg->SetLineWeight($old); + } + + $this->iSize *= $scaling; + + // Inner circle size + $ri = $this->iCenterSize/2 ; + + // Full circle radius + $r = round( $this->iSize/2 ); + + // Get number of grid circles + $n = $this->scale->GetNumCirc(); + + // Plot circle grids + $ri *= $scaling ; + $rr = round(($r-$ri)/$n); + for( $i = 1; $i <= $n; ++$i ) { + $this->_ThickCircle($dblImg,$xc,$yc,$rr*$i+$ri, + $this->iCircGridWeight,$this->iGridColor1); + } + + $num = 0 ; + + if( $this->iType == WINDROSE_TYPEFREE ) { + $this->_StrokeFreeRose($dblImg,$value,$scaling,$xc,$yc,$r,$ri); + } + else { + // Check if we need to re-code the interpretation of the ordinal + // number in the data. Internally ordinal value 0 is East and then + // counted anti-clockwise. The user might choose an encoding + // that have 0 being the first axis to the right of the "N" axis and then + // counted clock-wise + if( $this->iOrdinalEncoding == KEYENCODING_CLOCKWISE ) { + if( $this->iType == WINDROSE_TYPE16 ) { + $const1 = 19; $const2 = 16; + } + elseif( $this->iType == WINDROSE_TYPE8 ) { + $const1 = 9; $const2 = 8; + } + else { + $const1 = 4; $const2 = 4; + } + $tmp = array(); + $n=count($this->iData); + foreach( $this->iData as $key => $val ) { + if( is_numeric($key) ) { + $key = ($const1 - $key) % $const2 ; + } + $tmp[$key] = $val; + } + $this->iData = $tmp; + } + $this->_StrokeRegularRose($dblImg,$value,$scaling,$xc,$yc,$r,$ri); + } + + // Stroke the labels + $this->scale->iFontSize *= $scaling; + $this->scale->iZFontSize *= $scaling; + $this->scale->StrokeLabels($dblImg,$xc,$yc,$ri,$rr); + + // Stroke the inner circle again since the legs + // might have written over it + $this->_ThickCircle($dblImg,$xc,$yc,$ri,$this->iCircGridWeight,$this->iGridColor1); + + if( $ww > $aImg->width ) { + JpgraphError::RaiseL(22020); + //('Windrose plot is too large to fit the specified Graph size. Please use WindrosePlot::SetSize() to make the plot smaller or increase the size of the Graph in the initial WindroseGraph() call.'); + } + + $x = $xc; + $y = $h; + $this->_StrokeLegend($dblImg,$x,$y,$scaling); + + if( $this->iAntiAlias ) { + $aImg->Copy($dblImg->img, $this->iX-$ww/2, $this->iY-$hh/2, 0, 0, $ww,$hh, $w,$h); + } + + // We need to restore the translation matrix + $aImg->SetTranslation(0,0); + + } + +} + +//============================================================ +// CLASS WindroseGraph +//============================================================ +class WindroseGraph extends Graph { + private $posx, $posy; + public $plots=array(); + + function __construct($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) { + parent::__construct($width,$height,$cachedName,$timeout,$inline); + $this->posx=$width/2; + $this->posy=$height/2; + $this->SetColor('white'); + $this->title->SetFont(FF_VERDANA,FS_NORMAL,12); + $this->title->SetMargin(8); + $this->subtitle->SetFont(FF_VERDANA,FS_NORMAL,10); + $this->subtitle->SetMargin(0); + $this->subsubtitle->SetFont(FF_VERDANA,FS_NORMAL,8); + $this->subsubtitle->SetMargin(0); + } + + function StrokeTexts() { + if( $this->texts != null ) { + $n = count($this->texts); + for($i=0; $i < $n; ++$i ) { + $this->texts[$i]->Stroke($this->img); + } + } + } + + function StrokeIcons() { + if( $this->iIcons != null ) { + $n = count($this->iIcons); + for( $i=0; $i < $n; ++$i ) { + // Since Windrose graphs doesn't have any linear scale the position of + // each icon has to be given as absolute coordinates + $this->iIcons[$i]->_Stroke($this->img); + } + } + } + + //--------------- + // PUBLIC METHODS + function Add($aObj) { + if( is_array($aObj) && count($aObj) > 0 ) { + $cl = $aObj[0]; + } + else { + $cl = $aObj; + } + if( $cl instanceof Text ) { + $this->AddText($aObj); + } + elseif( $cl instanceof IconPlot ) { + $this->AddIcon($aObj); + } + elseif( ($cl instanceof WindrosePlot) || ($cl instanceof LayoutRect) || ($cl instanceof LayoutHor)) { + $this->plots[] = $aObj; + } + else { + JpgraphError::RaiseL(22021); + } + } + + function AddText($aTxt,$aToY2=false) { + parent::AddText($aTxt); + } + + function SetColor($c) { + $this->SetMarginColor($c); + } + + // Method description + function Stroke($aStrokeFileName="") { + + // If the filename is the predefined value = '_csim_special_' + // we assume that the call to stroke only needs to do enough + // to correctly generate the CSIM maps. + // We use this variable to skip things we don't strictly need + // to do to generate the image map to improve performance + // as best we can. Therefore you will see a lot of tests !$_csim in the + // code below. + $_csim = ($aStrokeFileName===_CSIM_SPECIALFILE); + + // We need to know if we have stroked the plot in the + // GetCSIMareas. Otherwise the CSIM hasn't been generated + // and in the case of GetCSIM called before stroke to generate + // CSIM without storing an image to disk GetCSIM must call Stroke. + $this->iHasStroked = true; + + if( $this->background_image != "" || $this->background_cflag != "" ) { + $this->StrokeFrameBackground(); + } + else { + $this->StrokeFrame(); + } + + // n holds number of plots + $n = count($this->plots); + for($i=0; $i < $n ; ++$i) { + $this->plots[$i]->Stroke($this); + } + + $this->footer->Stroke($this->img); + $this->StrokeIcons(); + $this->StrokeTexts(); + $this->StrokeTitles(); + + // If the filename is given as the special "__handle" + // then the image handler is returned and the image is NOT + // streamed back + if( $aStrokeFileName == _IMG_HANDLER ) { + return $this->img->img; + } + else { + // Finally stream the generated picture + $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline, + $aStrokeFileName); + } + } + +} // Class + +?> diff --git a/html/jpgraph/lang/de.inc.php b/html/jpgraph/lang/de.inc.php new file mode 100644 index 0000000..68233eb --- /dev/null +++ b/html/jpgraph/lang/de.inc.php @@ -0,0 +1,552 @@ +<?php +/*======================================================================= +// File: DE.INC.PHP +// Description: German language file for error messages +// Created: 2006-03-06 +// Author: Timo Leopold (timo@leopold-hh.de) +// Johan Persson (ljp@localhost.nil) +// Ver: $Id: de.inc.php 1886 2009-10-01 23:30:16Z ljp $ +// +// Copyright (c) +//======================================================================== +*/ + +// Notiz: Das Format fuer jede Fehlermeldung ist array(<Fehlermeldung>,<Anzahl der Argumente>) +_jpg_messages = array( + +/* +** Headers wurden bereits gesendet - Fehler. Dies wird als HTML formatiert, weil es direkt als text zurueckgesendet wird +*/ +10 => array('<table border="1"><tr><td style="color:darkred;font-size:1.2em;"><b>JpGraph Fehler:</b> +HTTP header wurden bereits gesendet.<br>Fehler in der Datei <b>%s</b> in der Zeile <b>%d</b>.</td></tr><tr><td><b>Erklärung:</b><br>HTTP header wurden bereits zum Browser gesendet, wobei die Daten als Text gekennzeichnet wurden, bevor die Bibliothek die Chance hatte, seinen Bild-HTTP-Header zum Browser zu schicken. Dies verhindert, dass die Bibliothek Bilddaten zum Browser schicken kann (weil sie vom Browser als Text interpretiert würden und daher nur Mist dargestellt würde).<p>Wahrscheinlich steht Text im Skript bevor <i>Graph::Stroke()</i> aufgerufen wird. Wenn dieser Text zum Browser gesendet wird, nimmt dieser an, dass die gesamten Daten aus Text bestehen. Such nach irgendwelchem Text, auch nach Leerzeichen und Zeilenumbrüchen, die eventuell bereits zum Browser gesendet wurden. <p>Zum Beispiel ist ein oft auftretender Fehler, eine Leerzeile am Anfang der Datei oder vor <i>Graph::Stroke()</i> zu lassen."<b><?php</b>".</td></tr></table>',2), + +/* +** Setup Fehler +*/ +11 => array('Es wurde kein Pfad für CACHE_DIR angegeben. Bitte gib einen Pfad CACHE_DIR in der Datei jpg-config.inc an.',0), +12 => array('Es wurde kein Pfad für TTF_DIR angegeben und der Pfad kann nicht automatisch ermittelt werden. Bitte gib den Pfad in der Datei jpg-config.inc an.',0), +13 => array('The installed PHP version (%s) is not compatible with this release of the library. The library requires at least PHP version %s',2), + +/* +** jpgraph_bar +*/ + +2001 => array('Die Anzahl der Farben ist nicht gleich der Anzahl der Vorlagen in BarPlot::SetPattern().',0), +2002 => array('Unbekannte Vorlage im Aufruf von BarPlot::SetPattern().',0), +2003 => array('Anzahl der X- und Y-Koordinaten sind nicht identisch. Anzahl der X-Koordinaten: %d; Anzahl der Y-Koordinaten: %d.',2), +2004 => array('Alle Werte für ein Balkendiagramm (barplot) müssen numerisch sein. Du hast den Wert nr [%d] == %s angegeben.',2), +2005 => array('Du hast einen leeren Vektor für die Schattierungsfarben im Balkendiagramm (barplot) angegeben.',0), +2006 => array('Unbekannte Position für die Werte der Balken: %s.',1), +2007 => array('Kann GroupBarPlot nicht aus einem leeren Vektor erzeugen.',0), +2008 => array('GroupBarPlot Element nbr %d wurde nicht definiert oder ist leer.',0), +2009 => array('Eins der Objekte, das an GroupBar weitergegeben wurde ist kein Balkendiagramm (BarPlot). Versichere Dich, dass Du den GroupBarPlot aus einem Vektor von Balkendiagrammen (barplot) oder AccBarPlot-Objekten erzeugst. (Class = %s)',1), +2010 => array('Kann AccBarPlot nicht aus einem leeren Vektor erzeugen.',0), +2011 => array('AccBarPlot-Element nbr %d wurde nicht definiert oder ist leer.',1), +2012 => array('Eins der Objekte, das an AccBar weitergegeben wurde ist kein Balkendiagramm (barplot). Versichere Dich, dass Du den AccBar-Plot aus einem Vektor von Balkendiagrammen (barplot) erzeugst. (Class=%s)',1), +2013 => array('Du hast einen leeren Vektor für die Schattierungsfarben im Balkendiagramm (barplot) angegeben.',0), +2014 => array('Die Anzahl der Datenpunkte jeder Datenreihe in AccBarPlot muss gleich sein.',0), +2015 => array('Individual bar plots in an AccBarPlot or GroupBarPlot can not have specified X-coordinates',0), + + +/* +** jpgraph_date +*/ + +3001 => array('Es ist nur möglich, entweder SetDateAlign() oder SetTimeAlign() zu benutzen, nicht beides!',0), + +/* +** jpgraph_error +*/ + +4002 => array('Fehler bei den Eingabedaten von LineErrorPlot. Die Anzahl der Datenpunkte mus ein Mehrfaches von drei sein!',0), + +/* +** jpgraph_flags +*/ + +5001 => array('Unbekannte Flaggen-Größe (%d).',1), +5002 => array('Der Flaggen-Index %s existiert nicht.',1), +5003 => array('Es wurde eine ungültige Ordnungszahl (%d) für den Flaggen-Index angegeben.',1), +5004 => array('Der Landesname %s hat kein korrespondierendes Flaggenbild. Die Flagge mag existieren, abr eventuell unter einem anderen Namen, z.B. versuche "united states" statt "usa".',1), + + +/* +** jpgraph_gantt +*/ + +6001 => array('Interner Fehler. Die Höhe für ActivityTitles ist < 0.',0), +6002 => array('Es dürfen keine negativen Werte für die Gantt-Diagramm-Dimensionen angegeben werden. Verwende 0, wenn die Dimensionen automatisch ermittelt werden sollen.',0), +6003 => array('Ungültiges Format für den Bedingungs-Parameter bei Index=%d in CreateSimple(). Der Parameter muss bei index 0 starten und Vektoren in der Form (Row,Constrain-To,Constrain-Type) enthalten.',1), +6004 => array('Ungültiges Format für den Fortschritts-Parameter bei Index=%d in CreateSimple(). Der Parameter muss bei Index 0 starten und Vektoren in der Form (Row,Progress) enthalten.',1), +6005 => array('SetScale() ist nicht sinnvoll bei Gantt-Diagrammen.',0), +6006 => array('Das Gantt-Diagramm kann nicht automatisch skaliert werden. Es existieren keine Aktivitäten mit Termin. [GetBarMinMax() start >= n]',0), +6007 => array('Plausibiltätsprüfung für die automatische Gantt-Diagramm-Größe schlug fehl. Entweder die Breite (=%d) oder die Höhe (=%d) ist größer als MAX_GANTTIMG_SIZE. Dies kann möglicherweise durch einen falschen Wert bei einer Aktivität hervorgerufen worden sein.',2), +6008 => array('Du hast eine Bedingung angegeben von Reihe=%d bis Reihe=%d, die keine Aktivität hat.',2), +6009 => array('Unbekannter Bedingungstyp von Reihe=%d bis Reihe=%d',2), +6010 => array('Ungültiger Icon-Index für das eingebaute Gantt-Icon [%d]',1), +6011 => array('Argument für IconImage muss entweder ein String oder ein Integer sein.',0), +6012 => array('Unbekannter Typ bei der Gantt-Objekt-Title-Definition.',0), +6015 => array('Ungültige vertikale Position %d',1), +6016 => array('Der eingegebene Datums-String (%s) für eine Gantt-Aktivität kann nicht interpretiert werden. Versichere Dich, dass es ein gültiger Datumsstring ist, z.B. 2005-04-23 13:30',1), +6017 => array('Unbekannter Datumstyp in GanttScale (%s).',1), +6018 => array('Intervall für Minuten muss ein gerader Teiler einer Stunde sein, z.B. 1,5,10,12,15,20,30, etc. Du hast ein Intervall von %d Minuten angegeben.',1), +6019 => array('Die vorhandene Breite (%d) für die Minuten ist zu klein, um angezeigt zu werden. Bitte benutze die automatische Größenermittlung oder vergrößere die Breite des Diagramms.',1), +6020 => array('Das Intervall für die Stunden muss ein gerader Teiler eines Tages sein, z.B. 0:30, 1:00, 1:30, 4:00, etc. Du hast ein Intervall von %d eingegeben.',1), +6021 => array('Unbekanntes Format für die Woche.',0), +6022 => array('Die Gantt-Skala wurde nicht eingegeben.',0), +6023 => array('Wenn Du sowohl Stunden als auch Minuten anzeigen lassen willst, muss das Stunden-Interval gleich 1 sein (anderenfalls ist es nicht sinnvoll, Minuten anzeigen zu lassen).',0), +6024 => array('Das CSIM-Ziel muss als String angegeben werden. Der Start des Ziels ist: %d',1), +6025 => array('Der CSIM-Alt-Text muss als String angegeben werden. Der Beginn des Alt-Textes ist: %d',1), +6027 => array('Der Fortschrittswert muss im Bereich [0, 1] liegen.',0), +6028 => array('Die eingegebene Höhe (%d) für GanttBar ist nicht im zulässigen Bereich.',1), +6029 => array('Der Offset für die vertikale Linie muss im Bereich [0,1] sein.',0), +6030 => array('Unbekannte Pfeilrichtung für eine Verbindung.',0), +6031 => array('Unbekannter Pfeiltyp für eine Verbindung.',0), +6032 => array('Interner Fehler: Unbekannter Pfadtyp (=%d) für eine Verbindung.',1), +6033 => array('Array of fonts must contain arrays with 3 elements, i.e. (Family, Style, Size)',0), + +/* +** jpgraph_gradient +*/ + +7001 => array('Unbekannter Gradiententyp (=%d).',1), + +/* +** jpgraph_iconplot +*/ + +8001 => array('Der Mix-Wert für das Icon muss zwischen 0 und 100 sein.',0), +8002 => array('Die Ankerposition für Icons muss entweder "top", "bottom", "left", "right" oder "center" sein.',0), +8003 => array('Es ist nicht möglich, gleichzeitig ein Bild und eine Landesflagge für dasselbe Icon zu definieren',0), +8004 => array('Wenn Du Landesflaggen benutzen willst, musst Du die Datei "jpgraph_flags.php" hinzufügen (per include).',0), + +/* +** jpgraph_imgtrans +*/ + +9001 => array('Der Wert für die Bildtransformation ist außerhalb des zulässigen Bereichs. Der verschwindende Punkt am Horizont muss als Wert zwischen 0 und 1 angegeben werden.',0), + +/* +** jpgraph_lineplot +*/ + +10001 => array('Die Methode LinePlot::SetFilled() sollte nicht mehr benutzt werden. Benutze lieber SetFillColor()',0), +10002 => array('Der Plot ist zu kompliziert für FastLineStroke. Benutze lieber den StandardStroke()',0), +10003 => array('Each plot in an accumulated lineplot must have the same number of data points.',0), +/* +** jpgraph_log +*/ + +11001 => array('Deine Daten enthalten nicht-numerische Werte.',0), +11002 => array('Negative Werte können nicht für logarithmische Achsen verwendet werden.',0), +11003 => array('Deine Daten enthalten nicht-numerische Werte.',0), +11004 => array('Skalierungsfehler für die logarithmische Achse. Es gibt ein Problem mit den Daten der Achse. Der größte Wert muss größer sein als Null. Es ist mathematisch nicht möglich, einen Wert gleich Null in der Skala zu haben.',0), +11005 => array('Das Tick-Intervall für die logarithmische Achse ist nicht definiert. Lösche jeden Aufruf von SetTextLabelStart() oder SetTextTickInterval() bei der logarithmischen Achse.',0), + +/* +** jpgraph_mgraph +*/ + +12001 => array("Du benutzt GD 2.x und versuchst ein Nicht-Truecolor-Bild als Hintergrundbild zu benutzen. Um Hintergrundbilder mit GD 2.x zu benutzen, ist es notwendig Truecolor zu aktivieren, indem die USE_TRUECOLOR-Konstante auf TRUE gesetzt wird. Wegen eines Bugs in GD 2.0.1 ist die Qualität der Truetype-Schriften sehr schlecht, wenn man Truetype-Schriften mit Truecolor-Bildern verwendet.",0), +12002 => array('Ungültiger Dateiname für MGraph::SetBackgroundImage() : %s. Die Datei muss eine gültige Dateierweiterung haben (jpg,gif,png), wenn die automatische Typerkennung verwendet wird.',1), +12003 => array('Unbekannte Dateierweiterung (%s) in MGraph::SetBackgroundImage() für Dateiname: %s',2), +12004 => array('Das Bildformat des Hintergrundbildes (%s) wird von Deiner System-Konfiguration nicht unterstützt. ',1), +12005 => array('Das Hintergrundbild kann nicht gelesen werden: %s',1), +12006 => array('Es wurden ungültige Größen für Breite oder Höhe beim Erstellen des Bildes angegeben, (Breite=%d, Höhe=%d)',2), +12007 => array('Das Argument für MGraph::Add() ist nicht gültig für GD.',0), +12008 => array('Deine PHP- (und GD-lib-) Installation scheint keine bekannten Bildformate zu unterstützen.',0), +12009 => array('Deine PHP-Installation unterstützt das gewählte Bildformat nicht: %s',1), +12010 => array('Es konnte kein Bild als Datei %s erzeugt werden. Überprüfe, ob Du die entsprechenden Schreibrechte im aktuellen Verzeichnis hast.',1), +12011 => array('Es konnte kein Truecolor-Bild erzeugt werden. Überprüfe, ob Du wirklich die GD2-Bibliothek installiert hast.',0), +12012 => array('Es konnte kein Bild erzeugt werden. Überprüfe, ob Du wirklich die GD2-Bibliothek installiert hast.',0), + +/* +** jpgraph_pie3d +*/ + +14001 => array('Pie3D::ShowBorder(). Missbilligte Funktion. Benutze Pie3D::SetEdge(), um die Ecken der Tortenstücke zu kontrollieren.',0), +14002 => array('PiePlot3D::SetAngle() 3D-Torten-Projektionswinkel muss zwischen 5 und 85 Grad sein.',0), +14003 => array('Interne Festlegung schlug fehl. Pie3D::Pie3DSlice',0), +14004 => array('Tortenstück-Startwinkel muss zwischen 0 und 360 Grad sein.',0), +14005 => array('Pie3D Interner Fehler: Versuch, zweimal zu umhüllen bei der Suche nach dem Startindex.',0,), +14006 => array('Pie3D Interner Fehler: Z-Sortier-Algorithmus für 3D-Tortendiagramme funktioniert nicht einwandfrei (2). Versuch, zweimal zu umhüllen beim Erstellen des Bildes.',0), +14007 => array('Die Breite für das 3D-Tortendiagramm ist 0. Gib eine Breite > 0 an.',0), + +/* +** jpgraph_pie +*/ + +15001 => array('PiePLot::SetTheme() Unbekannter Stil: %s',1), +15002 => array('Argument für PiePlot::ExplodeSlice() muss ein Integer-Wert sein',0), +15003 => array('Argument für PiePlot::Explode() muss ein Vektor mit Integer-Werten sein.',0), +15004 => array('Tortenstück-Startwinkel muss zwischen 0 und 360 Grad sein.',0), +15005 => array('PiePlot::SetFont() sollte nicht mehr verwendet werden. Benutze stattdessen PiePlot->value->SetFont().',0), +15006 => array('PiePlot::SetSize() Radius für Tortendiagramm muss entweder als Bruch [0, 0.5] der Bildgröße oder als Absoluwert in Pixel im Bereich [10, 1000] angegeben werden.',0), +15007 => array('PiePlot::SetFontColor() sollte nicht mehr verwendet werden. Benutze stattdessen PiePlot->value->SetColor()..',0), +15008 => array('PiePlot::SetLabelType() der Typ für Tortendiagramme muss entweder 0 or 1 sein (nicht %d).',1), +15009 => array('Ungültiges Tortendiagramm. Die Summe aller Daten ist Null.',0), +15010 => array('Die Summe aller Daten ist Null.',0), +15011 => array('Um Bildtransformationen benutzen zu können, muss die Datei jpgraph_imgtrans.php eingefügt werden (per include).',0), // @todo translate into German +15012 => array('PiePlot::SetTheme() is no longer recommended. Use PieGraph::SetTheme()',0), + +/* +** jpgraph_plotband +*/ + +16001 => array('Die Dichte für das Pattern muss zwischen 1 und 100 sein. (Du hast %f eingegeben)',1), +16002 => array('Es wurde keine Position für das Pattern angegeben.',0), +16003 => array('Unbekannte Pattern-Definition (%d)',0), +16004 => array('Der Mindeswert für das PlotBand ist größer als der Maximalwert. Bitte korrigiere dies!',0), + + +/* +** jpgraph_polar +*/ + +17001 => array('PolarPlots müssen eine gerade Anzahl von Datenpunkten haben. Jeder Datenpunkt ist ein Tupel (Winkel, Radius).',0), +17002 => array('Unbekannte Ausrichtung für X-Achsen-Titel. (%s)',1), +//17003 => array('Set90AndMargin() wird für PolarGraph nicht unterstützt.',0), +17004 => array('Unbekannter Achsentyp für PolarGraph. Er muss entweder \'lin\' oder \'log\' sein.',0), + +/* +** jpgraph_radar +*/ + +18001 => array('ClientSideImageMaps werden für RadarPlots nicht unterstützt.',0), +18002 => array('RadarGraph::SupressTickMarks() sollte nicht mehr verwendet werden. Benutze stattdessen HideTickMarks().',0), +18003 => array('Ungültiger Achsentyp für RadarPlot (%s). Er muss entweder \'lin\' oder \'log\' sein.',1), +18004 => array('Die RadarPlot-Größe muss zwischen 0.1 und 1 sein. (Dein Wert=%f)',1), +18005 => array('RadarPlot: nicht unterstützte Tick-Dichte: %d',1), +18006 => array('Minimum Daten %f (RadarPlots sollten nur verwendet werden, wenn alle Datenpunkte einen Wert > 0 haben).',1), +18007 => array('Die Anzahl der Titel entspricht nicht der Anzahl der Datenpunkte.',0), +18008 => array('Jeder RadarPlot muss die gleiche Anzahl von Datenpunkten haben.',0), + +/* +** jpgraph_regstat +*/ + +19001 => array('Spline: Anzahl der X- und Y-Koordinaten muss gleich sein.',0), +19002 => array('Ungültige Dateneingabe für Spline. Zwei oder mehr aufeinanderfolgende X-Werte sind identisch. Jeder eigegebene X-Wert muss unterschiedlich sein, weil vom mathematischen Standpunkt ein Eins-zu-Eins-Mapping vorliegen muss, d.h. jeder X-Wert korrespondiert mit exakt einem Y-Wert.',0), +19003 => array('Bezier: Anzahl der X- und Y-Koordinaten muss gleich sein.',0), + +/* +** jpgraph_scatter +*/ + +20001 => array('Fieldplots müssen die gleiche Anzahl von X und Y Datenpunkten haben.',0), +20002 => array('Bei Fieldplots muss ein Winkel für jeden X und Y Datenpunkt angegeben werden.',0), +20003 => array('Scatterplots müssen die gleiche Anzahl von X- und Y-Datenpunkten haben.',0), + +/* +** jpgraph_stock +*/ + +21001 => array('Die Anzahl der Datenwerte für Stock-Charts müssen ein Mehrfaches von %d Datenpunkten sein.',1), + +/* +** jpgraph_plotmark +*/ + +23001 => array('Der Marker "%s" existiert nicht in der Farbe: %d',2), +23002 => array('Der Farb-Index ist zu hoch für den Marker "%s"',1), +23003 => array('Ein Dateiname muss angegeben werden, wenn Du den Marker-Typ auf MARK_IMG setzt.',0), + +/* +** jpgraph_utils +*/ + +24001 => array('FuncGenerator : Keine Funktion definiert. ',0), +24002 => array('FuncGenerator : Syntax-Fehler in der Funktionsdefinition ',0), +24003 => array('DateScaleUtils: Unknown tick type specified in call to GetTicks()',0), +24004 => array('ReadCSV2: Die anzahl der spalten fehler in %s reihe %d',2), +/* +** jpgraph +*/ + +25001 => array('Diese PHP-Installation ist nicht mit der GD-Bibliothek kompiliert. Bitte kompiliere PHP mit GD-Unterstützung neu, damit JpGraph funktioniert. (Weder die Funktion imagetypes() noch imagecreatefromstring() existiert!)',0), +25002 => array('Diese PHP-Installation scheint nicht die benötigte GD-Bibliothek zu unterstützen. Bitte schau in der PHP-Dokumentation nach, wie man die GD-Bibliothek installiert und aktiviert.',0), +25003 => array('Genereller PHP Fehler : Bei %s:%d : %s',3), +25004 => array('Genereller PHP Fehler : %s ',1), +25005 => array('PHP_SELF, die PHP-Global-Variable kann nicht ermittelt werden. PHP kann nicht von der Kommandozeile gestartet werden, wenn der Cache oder die Bilddateien automatisch benannt werden sollen.',0), +25006 => array('Die Benutzung der FF_CHINESE (FF_BIG5) Schriftfamilie benötigt die iconv() Funktion in Deiner PHP-Konfiguration. Dies wird nicht defaultmäßig in PHP kompiliert (benötigt "--width-iconv" bei der Konfiguration).',0), +25007 => array('Du versuchst das lokale (%s) zu verwenden, was von Deiner PHP-Installation nicht unterstützt wird. Hinweis: Benutze \'\', um das defaultmäßige Lokale für diese geographische Region festzulegen.',1), +25008 => array('Die Bild-Breite und Höhe in Graph::Graph() müssen numerisch sein',0), +25009 => array('Die Skalierung der Achsen muss angegeben werden mit Graph::SetScale()',0), + +25010 => array('Graph::Add() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0), +25011 => array('Graph::AddY2() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0), +25012 => array('Graph::AddYN() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0), +25013 => array('Es können nur Standard-Plots zu multiplen Y-Achsen hinzugefügt werden',0), +25014 => array('Graph::AddText() Du hast versucht, einen leeren Text zum Graph hinzuzufügen.',0), +25015 => array('Graph::AddLine() Du hast versucht, eine leere Linie zum Graph hinzuzufügen.',0), +25016 => array('Graph::AddBand() Du hast versucht, ein leeres Band zum Graph hinzuzufügen.',0), +25017 => array('Du benutzt GD 2.x und versuchst, ein Hintergrundbild in einem Truecolor-Bild zu verwenden. Um Hintergrundbilder mit GD 2.x zu verwenden, ist es notwendig, Truecolor zu aktivieren, indem die USE_TRUECOLOR-Konstante auf TRUE gesetzt wird. Wegen eines Bugs in GD 2.0.1 ist die Qualität der Schrift sehr schlecht, wenn Truetype-Schrift in Truecolor-Bildern verwendet werden.',0), +25018 => array('Falscher Dateiname für Graph::SetBackgroundImage() : "%s" muss eine gültige Dateinamenerweiterung (jpg,gif,png) haben, wenn die automatische Dateityperkennung verwenndet werden soll.',1), +25019 => array('Unbekannte Dateinamenerweiterung (%s) in Graph::SetBackgroundImage() für Dateiname: "%s"',2), + +25020 => array('Graph::SetScale(): Dar Maximalwert muss größer sein als der Mindestwert.',0), +25021 => array('Unbekannte Achsendefinition für die Y-Achse. (%s)',1), +25022 => array('Unbekannte Achsendefinition für die X-Achse. (%s)',1), +25023 => array('Nicht unterstützter Y2-Achsentyp: "%s" muss einer von (lin,log,int) sein.',1), +25024 => array('Nicht unterstützter X-Achsentyp: "%s" muss einer von (lin,log,int) sein.',1), +25025 => array('Nicht unterstützte Tick-Dichte: %d',1), +25026 => array('Nicht unterstützter Typ der nicht angegebenen Y-Achse. Du hast entweder: 1. einen Y-Achsentyp für automatisches Skalieren definiert, aber keine Plots angegeben. 2. eine Achse direkt definiert, aber vergessen, die Tick-Dichte zu festzulegen.',0), +25027 => array('Kann cached CSIM "%s" zum Lesen nicht öffnen.',1), +25028 => array('Apache/PHP hat keine Schreibrechte, in das CSIM-Cache-Verzeichnis (%s) zu schreiben. Überprüfe die Rechte.',1), +25029 => array('Kann nicht in das CSIM "%s" schreiben. Überprüfe die Schreibrechte und den freien Speicherplatz.',1), + +25030 => array('Fehlender Skriptname für StrokeCSIM(). Der Name des aktuellen Skriptes muss als erster Parameter von StrokeCSIM() angegeben werden.',0), +25031 => array('Der Achsentyp muss mittels Graph::SetScale() angegeben werden.',0), +25032 => array('Es existieren keine Plots für die Y-Achse nbr:%d',1), +25033 => array('',0), +25034 => array('Undefinierte X-Achse kann nicht gezeichnet werden. Es wurden keine Plots definiert.',0), +25035 => array('Du hast Clipping aktiviert. Clipping wird nur für Diagramme mit 0 oder 90 Grad Rotation unterstützt. Bitte verändere Deinen Rotationswinkel (=%d Grad) dementsprechend oder deaktiviere Clipping.',1), +25036 => array('Unbekannter Achsentyp AxisStyle() : %s',1), +25037 => array('Das Bildformat Deines Hintergrundbildes (%s) wird von Deiner System-Konfiguration nicht unterstützt. ',1), +25038 => array('Das Hintergrundbild scheint von einem anderen Typ (unterschiedliche Dateierweiterung) zu sein als der angegebene Typ. Angegebenen: %s; Datei: %s',2), +25039 => array('Hintergrundbild kann nicht gelesen werden: "%s"',1), + +25040 => array('Es ist nicht möglich, sowohl ein Hintergrundbild als auch eine Hintergrund-Landesflagge anzugeben.',0), +25041 => array('Um Landesflaggen als Hintergrund benutzen zu können, muss die Datei "jpgraph_flags.php" eingefügt werden (per include).',0), +25042 => array('Unbekanntes Hintergrundbild-Layout',0), +25043 => array('Unbekannter Titelhintergrund-Stil.',0), +25044 => array('Automatisches Skalieren kann nicht verwendet werden, weil es unmöglich ist, einen gültigen min/max Wert für die Y-Achse zu ermitteln (nur Null-Werte).',0), +25045 => array('Die Schriftfamilien FF_HANDWRT und FF_BOOK sind wegen Copyright-Problemen nicht mehr verfügbar. Diese Schriften können nicht mehr mit JpGraph verteilt werden. Bitte lade Dir Schriften von http://corefonts.sourceforge.net/ herunter.',0), +25046 => array('Angegebene TTF-Schriftfamilie (id=%d) ist unbekannt oder existiert nicht. Bitte merke Dir, dass TTF-Schriften wegen Copyright-Problemen nicht mit JpGraph mitgeliefert werden. Du findest MS-TTF-Internetschriften (arial, courier, etc.) zum Herunterladen unter http://corefonts.sourceforge.net/',1), +25047 => array('Stil %s ist nicht verfügbar für Schriftfamilie %s',2), +25048 => array('Unbekannte Schriftstildefinition [%s].',1), +25049 => array('Schriftdatei "%s" ist nicht lesbar oder existiert nicht.',1), + +25050 => array('Erstes Argument für Text::Text() muss ein String sein.',0), +25051 => array('Ungültige Richtung angegeben für Text.',0), +25052 => array('PANIK: Interner Fehler in SuperScript::Stroke(). Unbekannte vertikale Ausrichtung für Text.',0), +25053 => array('PANIK: Interner Fehler in SuperScript::Stroke(). Unbekannte horizontale Ausrichtung für Text.',0), +25054 => array('Interner Fehler: Unbekannte Grid-Achse %s',1), +25055 => array('Axis::SetTickDirection() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetTickSide().',0), +25056 => array('SetTickLabelMargin() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetLabelMargin().',0), +25057 => array('SetTextTicks() sollte nicht mehr verwendet werden. Benutze stattdessen SetTextTickInterval().',0), +25058 => array('TextLabelIntevall >= 1 muss angegeben werden.',0), +25059 => array('SetLabelPos() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetLabelSide().',0), + +25060 => array('Unbekannte Ausrichtung angegeben für X-Achsentitel (%s).',1), +25061 => array('Unbekannte Ausrichtung angegeben für Y-Achsentitel (%s).',1), +25062 => array('Label unter einem Winkel werden für die Y-Achse nicht unterstützt.',0), +25063 => array('Ticks::SetPrecision() sollte nicht mehr verwendet werden. Benutze stattdessen Ticks::SetLabelFormat() (oder Ticks::SetFormatCallback()).',0), +25064 => array('Kleinere oder größere Schrittgröße ist 0. Überprüfe, ob Du fälschlicherweise SetTextTicks(0) in Deinem Skript hast. Wenn dies nicht der Fall ist, bist Du eventuell über einen Bug in JpGraph gestolpert. Bitte sende einen Report und füge den Code an, der den Fehler verursacht hat.',0), +25065 => array('Tick-Positionen müssen als array() angegeben werden',0), +25066 => array('Wenn die Tick-Positionen und -Label von Hand eingegeben werden, muss die Anzahl der Ticks und der Label gleich sein.',0), +25067 => array('Deine von Hand eingegebene Achse und Ticks sind nicht korrekt. Die Skala scheint zu klein zu sein für den Tickabstand.',0), +25068 => array('Ein Plot hat eine ungültige Achse. Dies kann beispielsweise der Fall sein, wenn Du automatisches Text-Skalieren verwendest, um ein Liniendiagramm zu zeichnen mit nur einem Datenpunkt, oder wenn die Bildfläche zu klein ist. Es kann auch der Fall sein, dass kein Datenpunkt einen numerischen Wert hat (vielleicht nur \'-\' oder \'x\').',0), +25069 => array('Grace muss größer sein als 0',0), + +25070 => array('Deine Daten enthalten nicht-numerische Werte.',0), +25071 => array('Du hast mit SetAutoMin() einen Mindestwert angegeben, der größer ist als der Maximalwert für die Achse. Dies ist nicht möglich.',0), +25072 => array('Du hast mit SetAutoMax() einen Maximalwert angegeben, der kleiner ist als der Minimalwert der Achse. Dies ist nicht möglich.',0), +25073 => array('Interner Fehler. Der Integer-Skalierungs-Algorithmus-Vergleich ist außerhalb der Grenzen (r=%f).',1), +25074 => array('Interner Fehler. Der Skalierungsbereich ist negativ (%f) [für %s Achse]. Dieses Problem könnte verursacht werden durch den Versuch, \'ungültige\' Werte in die Daten-Vektoren einzugeben (z.B. nur String- oder NULL-Werte), was beim automatischen Skalieren einen Fehler erzeugt.',2), +25075 => array('Die automatischen Ticks können nicht gesetzt werden, weil min==max.',0), +25077 => array('Einstellfaktor für die Farbe muss größer sein als 0',0), +25078 => array('Unbekannte Farbe: %s',1), +25079 => array('Unbekannte Farbdefinition: %s, Größe=%d',2), + +25080 => array('Der Alpha-Parameter für Farben muss zwischen 0.0 und 1.0 liegen.',0), +25081 => array('Das ausgewählte Grafikformat wird entweder nicht unterstützt oder ist unbekannt [%s]',1), +25082 => array('Es wurden ungültige Größen für Breite und Höhe beim Erstellen des Bildes definiert (Breite=%d, Höhe=%d).',2), +25083 => array('Es wurde eine ungültige Größe beim Kopieren des Bildes angegeben. Die Größe für das kopierte Bild wurde auf 1 Pixel oder weniger gesetzt.',0), +25084 => array('Fehler beim Erstellen eines temporären GD-Canvas. Möglicherweise liegt ein Arbeitsspeicherproblem vor.',0), +25085 => array('Ein Bild kann nicht aus dem angegebenen String erzeugt werden. Er ist entweder in einem nicht unterstützen Format oder er represäntiert ein kaputtes Bild.',0), +25086 => array('Du scheinst nur GD 1.x installiert zu haben. Um Alphablending zu aktivieren, ist GD 2.x oder höher notwendig. Bitte installiere GD 2.x oder versichere Dich, dass die Konstante USE_GD2 richtig gesetzt ist. Standardmäßig wird die installierte GD-Version automatisch erkannt. Ganz selten wird GD2 erkannt, obwohl nur GD1 installiert ist. Die Konstante USE_GD2 muss dann zu "false" gesetzt werden.',0), +25087 => array('Diese PHP-Version wurde ohne TTF-Unterstützung konfiguriert. PHP muss mit TTF-Unterstützung neu kompiliert und installiert werden.',0), +25088 => array('Die GD-Schriftunterstützung wurde falsch konfiguriert. Der Aufruf von imagefontwidth() ist fehlerhaft.',0), +25089 => array('Die GD-Schriftunterstützung wurde falsch konfiguriert. Der Aufruf von imagefontheight() ist fehlerhaft.',0), + +25090 => array('Unbekannte Richtung angegeben im Aufruf von StrokeBoxedText() [%s].',1), +25091 => array('Die interne Schrift untestützt das Schreiben von Text in einem beliebigen Winkel nicht. Benutze stattdessen TTF-Schriften.',0), +25092 => array('Es liegt entweder ein Konfigurationsproblem mit TrueType oder ein Problem beim Lesen der Schriftdatei "%s" vor. Versichere Dich, dass die Datei existiert und Leserechte und -pfad vergeben sind. (wenn \'basedir\' restriction in PHP aktiviert ist, muss die Schriftdatei im Dokumentwurzelverzeichnis abgelegt werden). Möglicherweise ist die FreeType-Bibliothek falsch installiert. Versuche, mindestens zur FreeType-Version 2.1.13 zu aktualisieren und kompiliere GD mit einem korrekten Setup neu, damit die FreeType-Bibliothek gefunden werden kann.',1), +25093 => array('Die Schriftdatei "%s" kann nicht gelesen werden beim Aufruf von Image::GetBBoxTTF. Bitte versichere Dich, dass die Schrift gesetzt wurde, bevor diese Methode aufgerufen wird, und dass die Schrift im TTF-Verzeichnis installiert ist.',1), +25094 => array('Die Textrichtung muss in einem Winkel zwischen 0 und 90 engegeben werden.',0), +25095 => array('Unbekannte Schriftfamilien-Definition. ',0), +25096 => array('Der Farbpalette können keine weiteren Farben zugewiesen werden. Dem Bild wurde bereits die größtmögliche Anzahl von Farben (%d) zugewiesen und die Palette ist voll. Verwende stattdessen ein TrueColor-Bild',0), +25097 => array('Eine Farbe wurde als leerer String im Aufruf von PushColor() angegegeben.',0), +25098 => array('Negativer Farbindex. Unpassender Aufruf von PopColor().',0), +25099 => array('Die Parameter für Helligkeit und Kontrast sind außerhalb des zulässigen Bereichs [-1,1]',0), + +25100 => array('Es liegt ein Problem mit der Farbpalette und dem GD-Setup vor. Bitte deaktiviere anti-aliasing oder verwende GD2 mit TrueColor. Wenn die GD2-Bibliothek installiert ist, versichere Dich, dass die Konstante USE_GD2 auf "true" gesetzt und TrueColor aktiviert ist.',0), +25101 => array('Ungültiges numerisches Argument für SetLineStyle(): (%d)',1), +25102 => array('Ungültiges String-Argument für SetLineStyle(): %s',1), +25103 => array('Ungültiges Argument für SetLineStyle %s',1), +25104 => array('Unbekannter Linientyp: %s',1), +25105 => array('Es wurden NULL-Daten für ein gefülltes Polygon angegeben. Sorge dafür, dass keine NULL-Daten angegeben werden.',0), +25106 => array('Image::FillToBorder : es können keine weiteren Farben zugewiesen werden.',0), +25107 => array('In Datei "%s" kann nicht geschrieben werden. Überprüfe die aktuellen Schreibrechte.',1), +25108 => array('Das Bild kann nicht gestreamt werden. Möglicherweise liegt ein Fehler im PHP/GD-Setup vor. Kompiliere PHP neu und verwende die eingebaute GD-Bibliothek, die mit PHP angeboten wird.',0), +25109 => array('Deine PHP- (und GD-lib-) Installation scheint keine bekannten Grafikformate zu unterstützen. Sorge zunächst dafür, dass GD als PHP-Modul kompiliert ist. Wenn Du außerdem JPEG-Bilder verwenden willst, musst Du die JPEG-Bibliothek installieren. Weitere Details sind in der PHP-Dokumentation zu finden.',0), + +25110 => array('Dein PHP-Installation unterstützt das gewählte Grafikformat nicht: %s',1), +25111 => array('Das gecachete Bild %s kann nicht gelöscht werden. Problem mit den Rechten?',1), +25112 => array('Das Datum der gecacheten Datei (%s) liegt in der Zukunft.',1), +25113 => array('Das gecachete Bild %s kann nicht gelöscht werden. Problem mit den Rechten?',1), +25114 => array('PHP hat nicht die erforderlichen Rechte, um in die Cache-Datei %s zu schreiben. Bitte versichere Dich, dass der Benutzer, der PHP anwendet, die entsprechenden Schreibrechte für die Datei hat, wenn Du das Cache-System in JPGraph verwenden willst.',1), +25115 => array('Berechtigung für gecachetes Bild %s kann nicht gesetzt werden. Problem mit den Rechten?',1), +25116 => array('Datei kann nicht aus dem Cache %s geöffnet werden',1), +25117 => array('Gecachetes Bild %s kann nicht zum Lesen geöffnet werden.',1), +25118 => array('Verzeichnis %s kann nicht angelegt werden. Versichere Dich, dass PHP die Schreibrechte in diesem Verzeichnis hat.',1), +25119 => array('Rechte für Datei %s können nicht gesetzt werden. Problem mit den Rechten?',1), + +25120 => array('Die Position für die Legende muss als Prozentwert im Bereich 0-1 angegeben werden.',0), +25121 => array('Eine leerer Datenvektor wurde für den Plot eingegeben. Es muss wenigstens ein Datenpunkt vorliegen.',0), +25122 => array('Stroke() muss als Subklasse der Klasse Plot definiert sein.',0), +25123 => array('Du kannst keine Text-X-Achse mit X-Koordinaten verwenden. Benutze stattdessen eine "int" oder "lin" Achse.',0), +25124 => array('Der Eingabedatenvektor mus aufeinanderfolgende Werte von 0 aufwärts beinhalten. Der angegebene Y-Vektor beginnt mit leeren Werten (NULL).',0), +25125 => array('Ungültige Richtung für statische Linie.',0), +25126 => array('Es kann kein TrueColor-Bild erzeugt werden. Überprüfe, ob die GD2-Bibliothek und PHP korrekt aufgesetzt wurden.',0), +25127 => array('The library has been configured for automatic encoding conversion of Japanese fonts. This requires that PHP has the mb_convert_encoding() function. Your PHP installation lacks this function (PHP needs the "--enable-mbstring" when compiled).',0), +25128 => array('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.',0), +25129 => array('Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.',0), +25130 => array('Too small plot area. (%d x %d). With the given image size and margins there is to little space left for the plot. Increase the plot size or reduce the margins.',2), + +25131 => array('StrokeBoxedText2() only supports TTF fonts and not built-in bitmap fonts.',0), +25132 => array('Undefined property %s.',1), // @todo translate +25133 => array('Use Graph::SetTheme() after Graph::SetScale().',0), // @todo translate + +/* +** jpgraph_led +*/ + +25500 => array('Multibyte strings must be enabled in the PHP installation in order to run the LED module so that the function mb_strlen() is available. See PHP documentation for more information.',0), + + +/* +**--------------------------------------------------------------------------------------------- +** Pro-version strings +**--------------------------------------------------------------------------------------------- +*/ + +/* +** jpgraph_table +*/ + +27001 => array('GTextTable: Ungültiges Argument für Set(). Das Array-Argument muss 2-- dimensional sein.',0), +27002 => array('GTextTable: Ungültiges Argument für Set()',0), +27003 => array('GTextTable: Falsche Anzahl von Argumenten für GTextTable::SetColor()',0), +27004 => array('GTextTable: Angegebener Zellenbereich, der verschmolzen werden soll, ist ungültig.',0), +27005 => array('GTextTable: Bereits verschmolzene Zellen im Bereich (%d,%d) bis (%d,%d) können nicht ein weiteres Mal verschmolzen werden.',4), +27006 => array('GTextTable: Spalten-Argument = %d liegt außerhalb der festgelegten Tabellengröße.',1), +27007 => array('GTextTable: Zeilen-Argument = %d liegt außerhalb der festgelegten Tabellengröße.',1), +27008 => array('GTextTable: Spalten- und Zeilengröße müssen zu den Dimensionen der Tabelle passen.',0), +27009 => array('GTextTable: Die Anzahl der Tabellenspalten oder -zeilen ist 0. Versichere Dich, dass die Methoden Init() oder Set() aufgerufen werden.',0), +27010 => array('GTextTable: Es wurde keine Ausrichtung beim Aufruf von SetAlign() angegeben.',0), +27011 => array('GTextTable: Es wurde eine unbekannte Ausrichtung beim Aufruf von SetAlign() abgegeben. Horizontal=%s, Vertikal=%s',2), +27012 => array('GTextTable: Interner Fehler. Es wurde ein ungültiges Argument festgeleget %s',1), +27013 => array('GTextTable: Das Argument für FormatNumber() muss ein String sein.',0), +27014 => array('GTextTable: Die Tabelle wurde weder mit einem Aufruf von Set() noch von Init() initialisiert.',0), +27015 => array('GTextTable: Der Zellenbildbedingungstyp muss entweder TIMG_WIDTH oder TIMG_HEIGHT sein.',0), + +/* +** jpgraph_windrose +*/ + +22001 => array('Die Gesamtsumme der prozentualen Anteile aller Windrosenarme darf 100%% nicht überschreiten!\n(Aktuell max: %d)',1), +22002 => array('Das Bild ist zu klein für eine Skala. Bitte vergrößere das Bild.',0), +22004 => array('Die Etikettendefinition für Windrosenrichtungen müssen 16 Werte haben (eine für jede Kompassrichtung).',0), +22005 => array('Der Linientyp für radiale Linien muss einer von ("solid","dotted","dashed","longdashed") sein.',0), +22006 => array('Es wurde ein ungültiger Windrosentyp angegeben.',0), +22007 => array('Es wurden zu wenig Werte für die Bereichslegende angegeben.',0), +22008 => array('Interner Fehler: Versuch, eine freie Windrose zu plotten, obwohl der Typ keine freie Windrose ist.',0), +22009 => array('Du hast die gleiche Richtung zweimal angegeben, einmal mit einem Winkel und einmal mit einer Kompassrichtung (%f Grad).',0), +22010 => array('Die Richtung muss entweder ein numerischer Wert sein oder eine der 16 Kompassrichtungen',0), +22011 => array('Der Windrosenindex muss ein numerischer oder Richtungswert sein. Du hast angegeben Index=%d',1), +22012 => array('Die radiale Achsendefinition für die Windrose enthält eine nicht aktivierte Richtung.',0), +22013 => array('Du hast dasselbe Look&Feel für die gleiche Kompassrichtung zweimal engegeben, einmal mit Text und einmal mit einem Index (Index=%d)',1), +22014 => array('Der Index für eine Kompassrichtung muss zwischen 0 und 15 sein.',0), +22015 => array('Du hast einen unbekannten Windrosenplottyp angegeben.',0), +22016 => array('Der Windrosenarmindex muss ein numerischer oder ein Richtungswert sein.',0), +22017 => array('Die Windrosendaten enthalten eine Richtung, die nicht aktiviert ist. Bitte berichtige, welche Label angezeigt werden sollen.',0), +22018 => array('Du hast für dieselbe Kompassrichtung zweimal Daten angegeben, einmal mit Text und einmal mit einem Index (Index=%d)',1), +22019 => array('Der Index für eine Richtung muss zwischen 0 und 15 sein. Winkel dürfen nicht für einen regelmäßigen Windplot angegeben werden, sondern entweder ein Index oder eine Kompassrichtung.',0), +22020 => array('Der Windrosenplot ist zu groß für die angegebene Bildgröße. Benutze entweder WindrosePlot::SetSize(), um den Plot kleiner zu machen oder vergrößere das Bild im ursprünglichen Aufruf von WindroseGraph().',0), +22021 => array('It is only possible to add Text, IconPlot or WindrosePlot to a Windrose Graph',0), + +/* +** jpgraph_odometer +*/ + +13001 => array('Unbekannter Nadeltypstil (%d).',1), +13002 => array('Ein Wert für das Odometer (%f) ist außerhalb des angegebenen Bereichs [%f,%f]',3), + +/* +** jpgraph_barcode +*/ + +1001 => array('Unbekannte Kodier-Specifikation: %s',1), +1002 => array('datenvalidierung schlug fehl. [%s] kann nicht mittels der Kodierung "%s" kodiert werden',2), +1003 => array('Interner Kodierfehler. Kodieren von %s ist nicht möglich in Code 128',1), +1004 => array('Interner barcode Fehler. Unbekannter UPC-E Kodiertyp: %s',1), +1005 => array('Interner Fehler. Das Textzeichen-Tupel (%s, %s) kann nicht im Code-128 Zeichensatz C kodiert werden.',2), +1006 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, CTRL in CHARSET != A zu kodieren.',0), +1007 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, DEL in CHARSET != B zu kodieren.',0), +1008 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, kleine Buchstaben in CHARSET != B zu kodieren.',0), +1009 => array('Kodieren mittels CODE 93 wird noch nicht unterstützt.',0), +1010 => array('Kodieren mittels POSTNET wird noch nicht unterstützt.',0), +1011 => array('Nicht untrstütztes Barcode-Backend für den Typ %s',1), + +/* +** PDF417 +*/ + +26000 => array('PDF417: The PDF417 module requires that the PHP installation must support the function bcmod(). This is normally enabled at compile time. See documentation for more information.',0), +26001 => array('PDF417: Die Anzahl der Spalten muss zwischen 1 und 30 sein.',0), +26002 => array('PDF417: Der Fehler-Level muss zwischen 0 und 8 sein.',0), +26003 => array('PDF417: Ungültiges Format für Eingabedaten, um sie mit PDF417 zu kodieren.',0), +26004 => array('PDF417: die eigebenen Daten können nicht mit Fehler-Level %d und %d spalten kodiert werden, weil daraus zu viele Symbole oder mehr als 90 Zeilen resultieren.',2), +26005 => array('PDF417: Die Datei "%s" kann nicht zum Schreiben geöffnet werden.',1), +26006 => array('PDF417: Interner Fehler. Die Eingabedatendatei für PDF417-Cluster %d ist fehlerhaft.',1), +26007 => array('PDF417: Interner Fehler. GetPattern: Ungültiger Code-Wert %d (Zeile %d)',2), +26008 => array('PDF417: Interner Fehler. Modus wurde nicht in der Modusliste!! Modus %d',1), +26009 => array('PDF417: Kodierfehler: Ungültiges Zeichen. Zeichen kann nicht mit ASCII-Code %d kodiert werden.',1), +26010 => array('PDF417: Interner Fehler: Keine Eingabedaten beim Dekodieren.',0), +26011 => array('PDF417: Kodierfehler. Numerisches Kodieren bei nicht-numerischen Daten nicht möglich.',0), +26012 => array('PDF417: Interner Fehler. Es wurden für den Binary-Kompressor keine Daten zum Dekodieren eingegeben.',0), +26013 => array('PDF417: Interner Fehler. Checksum Fehler. Koeffiziententabellen sind fehlerhaft.',0), +26014 => array('PDF417: Interner Fehler. Es wurden keine Daten zum Berechnen von Kodewörtern eingegeben.',0), +26015 => array('PDF417: Interner Fehler. Ein Eintrag 0 in die Statusübertragungstabellen ist nicht NULL. Eintrag 1 = (%s)',1), +26016 => array('PDF417: Interner Fehler: Nichtregistrierter Statusübertragungsmodus beim Dekodieren.',0), + + +/* +** jpgraph_contour +*/ + +28001 => array('Dritten parameter fur Contour muss ein vector der fargen sind.',0), +28002 => array('Die anzahlen der farges jeder isobar linien muss gleich sein.',0), +28003 => array('ContourPlot Interner Fehler: isobarHCrossing: Spalten index ist zu hoch (%d)',1), +28004 => array('ContourPlot Interner Fehler: isobarHCrossing: Reihe index ist zu hoch (%d)',1), +28005 => array('ContourPlot Interner Fehler: isobarVCrossing: Reihe index ist zu hoch (%d)',1), +28006 => array('ContourPlot Interner Fehler: isobarVCrossing: Spalten index ist zu hoch (%d)',1), +28007 => array('ContourPlot. Interpolation faktor ist zu hoch (>5)',0), + + +/* + * jpgraph_matrix and colormap +*/ +29201 => array('Min range value must be less or equal to max range value for colormaps',0), +29202 => array('The distance between min and max value is too small for numerical precision',0), +29203 => array('Number of color quantification level must be at least %d',1), +29204 => array('Number of colors (%d) is invalid for this colormap. It must be a number that can be written as: %d + k*%d',3), +29205 => array('Colormap specification out of range. Must be an integer in range [0,%d]',1), +29206 => array('Invalid object added to MatrixGraph',0), +29207 => array('Empty input data specified for MatrixPlot',0), +29208 => array('Unknown side specifiction for matrix labels "%s"',1), +29209 => array('CSIM Target matrix must be the same size as the data matrix (csim=%d x %d, data=%d x %d)',4), +29210 => array('CSIM Target for matrix labels does not match the number of labels (csim=%d, labels=%d)',2), + + +/* +* jpgraph_theme +*/ +30001 => array("Theme::%s() is not defined. \nPlease make %s(\$graph) function in your theme classs.",2), + + +); + +?> diff --git a/html/jpgraph/lang/en.inc.php b/html/jpgraph/lang/en.inc.php new file mode 100644 index 0000000..87fc95a --- /dev/null +++ b/html/jpgraph/lang/en.inc.php @@ -0,0 +1,545 @@ +<?php +/*======================================================================= +// File: EN.INC.PHP +// Description: English language file for error messages +// Created: 2006-01-25 +// Ver: $Id: en.inc.php 1886 2009-10-01 23:30:16Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== +*/ + +// Note: Format of each error message is array(<error message>,<number of arguments>) +_jpg_messages = array( + +/* +** Headers already sent error. This is formatted as HTML different since this will be sent back directly as text +*/ +10 => array('<table border="1"><tr><td style="color:darkred; font-size:1.2em;"><b>JpGraph Error:</b> +HTTP headers have already been sent.<br>Caused by output from file <b>%s</b> at line <b>%d</b>.</td></tr><tr><td><b>Explanation:</b><br>HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it\'s image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).<p>Most likely you have some text in your script before the call to <i>Graph::Stroke()</i>. If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. <p>For example it is a common mistake to leave a blank line before the opening "<b><?php</b>".</td></tr></table>',2), + +/* +** Setup errors +*/ +11 => array('No path specified for CACHE_DIR. Please specify CACHE_DIR manually in jpg-config.inc',0), +12 => array('No path specified for TTF_DIR and path can not be determined automatically. Please specify TTF_DIR manually (in jpg-config.inc).',0), +13 => array('The installed PHP version (%s) is not compatible with this release of the library. The library requires at least PHP version %s',2), + + +/* +** jpgraph_bar +*/ + +2001 => array('Number of colors is not the same as the number of patterns in BarPlot::SetPattern()',0), +2002 => array('Unknown pattern specified in call to BarPlot::SetPattern()',0), +2003 => array('Number of X and Y points are not equal. Number of X-points: %d Number of Y-points: %d',2), +2004 => array('All values for a barplot must be numeric. You have specified value nr [%d] == %s',2), +2005 => array('You have specified an empty array for shadow colors in the bar plot.',0), +2006 => array('Unknown position for values on bars : %s',1), +2007 => array('Cannot create GroupBarPlot from empty plot array.',0), +2008 => array('Group bar plot element nbr %d is undefined or empty.',0), +2009 => array('One of the objects submitted to GroupBar is not a BarPlot. Make sure that you create the GroupBar plot from an array of BarPlot or AccBarPlot objects. (Class = %s)',1), +2010 => array('Cannot create AccBarPlot from empty plot array.',0), +2011 => array('Acc bar plot element nbr %d is undefined or empty.',1), +2012 => array('One of the objects submitted to AccBar is not a BarPlot. Make sure that you create the AccBar plot from an array of BarPlot objects. (Class=%s)',1), +2013 => array('You have specified an empty array for shadow colors in the bar plot.',0), +2014 => array('Number of datapoints for each data set in accbarplot must be the same',0), +2015 => array('Individual bar plots in an AccBarPlot or GroupBarPlot can not have specified X-coordinates',0), + + +/* +** jpgraph_date +*/ + +3001 => array('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both',0), + +/* +** jpgraph_error +*/ + +4002 => array('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3',0), + +/* +** jpgraph_flags +*/ + +5001 => array('Unknown flag size (%d).',1), +5002 => array('Flag index %s does not exist.',1), +5003 => array('Invalid ordinal number (%d) specified for flag index.',1), +5004 => array('The (partial) country name %s does not have a corresponding flag image. The flag may still exist but under another name, e.g. instead of "usa" try "united states".',1), + + +/* +** jpgraph_gantt +*/ + +6001 => array('Internal error. Height for ActivityTitles is < 0',0), +6002 => array('You can\'t specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension.',0), +6003 => array('Invalid format for Constrain parameter at index=%d in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)',1), +6004 => array('Invalid format for Progress parameter at index=%d in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)',1), +6005 => array('SetScale() is not meaningful with Gantt charts.',0), +6006 => array('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]',0), +6007 => array('Sanity check for automatic Gantt chart size failed. Either the width (=%d) or height (=%d) is larger than MAX_GANTTIMG_SIZE. This could potentially be caused by a wrong date in one of the activities.',2), +6008 => array('You have specified a constrain from row=%d to row=%d which does not have any activity',2), +6009 => array('Unknown constrain type specified from row=%d to row=%d',2), +6010 => array('Illegal icon index for Gantt builtin icon [%d]',1), +6011 => array('Argument to IconImage must be string or integer',0), +6012 => array('Unknown type in Gantt object title specification',0), +6015 => array('Illegal vertical position %d',1), +6016 => array('Date string (%s) specified for Gantt activity can not be interpretated. Please make sure it is a valid time string, e.g. 2005-04-23 13:30',1), +6017 => array('Unknown date format in GanttScale (%s).',1), +6018 => array('Interval for minutes must divide the hour evenly, e.g. 1,5,10,12,15,20,30 etc You have specified an interval of %d minutes.',1), +6019 => array('The available width (%d) for minutes are to small for this scale to be displayed. Please use auto-sizing or increase the width of the graph.',1), +6020 => array('Interval for hours must divide the day evenly, e.g. 0:30, 1:00, 1:30, 4:00 etc. You have specified an interval of %d',1), +6021 => array('Unknown formatting style for week.',0), +6022 => array('Gantt scale has not been specified.',0), +6023 => array('If you display both hour and minutes the hour interval must be 1 (Otherwise it doesn\'t make sense to display minutes).',0), +6024 => array('CSIM Target must be specified as a string. Start of target is: %d',1), +6025 => array('CSIM Alt text must be specified as a string. Start of alt text is: %d',1), +6027 => array('Progress value must in range [0, 1]',0), +6028 => array('Specified height (%d) for gantt bar is out of range.',1), +6029 => array('Offset for vertical line must be in range [0,1]',0), +6030 => array('Unknown arrow direction for link.',0), +6031 => array('Unknown arrow type for link.',0), +6032 => array('Internal error: Unknown path type (=%d) specified for link.',1), +6033 => array('Array of fonts must contain arrays with 3 elements, i.e. (Family, Style, Size)',0), + +/* +** jpgraph_gradient +*/ + +7001 => array('Unknown gradient style (=%d).',1), + +/* +** jpgraph_iconplot +*/ + +8001 => array('Mix value for icon must be between 0 and 100.',0), +8002 => array('Anchor position for icons must be one of "top", "bottom", "left", "right" or "center"',0), +8003 => array('It is not possible to specify both an image file and a country flag for the same icon.',0), +8004 => array('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.',0), + +/* +** jpgraph_imgtrans +*/ + +9001 => array('Value for image transformation out of bounds. Vanishing point on horizon must be specified as a value between 0 and 1.',0), + +/* +** jpgraph_lineplot +*/ + +10001 => array('LinePlot::SetFilled() is deprecated. Use SetFillColor()',0), +10002 => array('Plot too complicated for fast line Stroke. Use standard Stroke()',0), +10003 => array('Each plot in an accumulated lineplot must have the same number of data points.',0), + +/* +** jpgraph_log +*/ + +11001 => array('Your data contains non-numeric values.',0), +11002 => array('Negative data values can not be used in a log scale.',0), +11003 => array('Your data contains non-numeric values.',0), +11004 => array('Scale error for logarithmic scale. You have a problem with your data values. The max value must be greater than 0. It is mathematically impossible to have 0 in a logarithmic scale.',0), +11005 => array('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.',0), + +/* +** jpgraph_mgraph +*/ + +12001 => array("You are using GD 2.x and are trying to use a background images on a non truecolor image. To use background images with GD 2.x it is necessary to enable truecolor by setting the USE_TRUECOLOR constant to TRUE. Due to a bug in GD 2.0.1 using any truetype fonts with truecolor images will result in very poor quality fonts.",0), +12002 => array('Incorrect file name for MGraph::SetBackgroundImage() : %s Must have a valid image extension (jpg,gif,png) when using auto detection of image type',1), +12003 => array('Unknown file extension (%s) in MGraph::SetBackgroundImage() for filename: %s',2), +12004 => array('The image format of your background image (%s) is not supported in your system configuration. ',1), +12005 => array('Can\'t read background image: %s',1), +12006 => array('Illegal sizes specified for width or height when creating an image, (width=%d, height=%d)',2), +12007 => array('Argument to MGraph::Add() is not a valid GD image handle.',0), +12008 => array('Your PHP (and GD-lib) installation does not appear to support any known graphic formats.',0), +12009 => array('Your PHP installation does not support the chosen graphic format: %s',1), +12010 => array('Can\'t create or stream image to file %s Check that PHP has enough permission to write a file to the current directory.',1), +12011 => array('Can\'t create truecolor image. Check that you really have GD2 library installed.',0), +12012 => array('Can\'t create image. Check that you really have GD2 library installed.',0), + +/* +** jpgraph_pie3d +*/ + +14001 => array('Pie3D::ShowBorder() . Deprecated function. Use Pie3D::SetEdge() to control the edges around slices.',0), +14002 => array('PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees.',0), +14003 => array('Internal assertion failed. Pie3D::Pie3DSlice',0), +14004 => array('Slice start angle must be between 0 and 360 degrees.',0), +14005 => array('Pie3D Internal error: Trying to wrap twice when looking for start index',0,), +14006 => array('Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.',0), +14007 => array('Width for 3D Pie is 0. Specify a size > 0',0), + +/* +** jpgraph_pie +*/ + +15001 => array('PiePLot::SetTheme() Unknown theme: %s',1), +15002 => array('Argument to PiePlot::ExplodeSlice() must be an integer',0), +15003 => array('Argument to PiePlot::Explode() must be an array with integer distances.',0), +15004 => array('Slice start angle must be between 0 and 360 degrees.',0), +15005 => array('PiePlot::SetFont() is deprecated. Use PiePlot->value->SetFont() instead.',0), +15006 => array('PiePlot::SetSize() Radius for pie must either be specified as a fraction [0, 0.5] of the size of the image or as an absolute size in pixels in the range [10, 1000]',0), +15007 => array('PiePlot::SetFontColor() is deprecated. Use PiePlot->value->SetColor() instead.',0), +15008 => array('PiePlot::SetLabelType() Type for pie plots must be 0 or 1 (not %d).',1), +15009 => array('Illegal pie plot. Sum of all data is zero for Pie Plot',0), +15010 => array('Sum of all data is 0 for Pie.',0), +15011 => array('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.',0), +15012 => array('PiePlot::SetTheme() is no longer supported. Use PieGraph::SetTheme()',0), + +/* +** jpgraph_plotband +*/ + +16001 => array('Density for pattern must be between 1 and 100. (You tried %f)',1), +16002 => array('No positions specified for pattern.',0), +16003 => array('Unknown pattern specification (%d)',0), +16004 => array('Min value for plotband is larger than specified max value. Please correct.',0), + + +/* +** jpgraph_polar +*/ + +17001 => array('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).',0), +17002 => array('Unknown alignment specified for X-axis title. (%s)',1), +//17003 => array('Set90AndMargin() is not supported for polar graphs.',0), +17004 => array('Unknown scale type for polar graph. Must be "lin" or "log"',0), + +/* +** jpgraph_radar +*/ + +18001 => array('Client side image maps not supported for RadarPlots.',0), +18002 => array('RadarGraph::SupressTickMarks() is deprecated. Use HideTickMarks() instead.',0), +18003 => array('Illegal scale for radarplot (%s). Must be \'lin\' or \'log\'',1), +18004 => array('Radar Plot size must be between 0.1 and 1. (Your value=%f)',1), +18005 => array('RadarPlot Unsupported Tick density: %d',1), +18006 => array('Minimum data %f (Radar plots should only be used when all data points > 0)',1), +18007 => array('Number of titles does not match number of points in plot.',0), +18008 => array('Each radar plot must have the same number of data points.',0), + +/* +** jpgraph_regstat +*/ + +19001 => array('Spline: Number of X and Y coordinates must be the same',0), +19002 => array('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.',0), +19003 => array('Bezier: Number of X and Y coordinates must be the same',0), + +/* +** jpgraph_scatter +*/ + +20001 => array('Fieldplots must have equal number of X and Y points.',0), +20002 => array('Fieldplots must have an angle specified for each X and Y points.',0), +20003 => array('Scatterplot must have equal number of X and Y points.',0), + +/* +** jpgraph_stock +*/ + +21001 => array('Data values for Stock charts must contain an even multiple of %d data points.',1), + +/* +** jpgraph_plotmark +*/ + +23001 => array('This marker "%s" does not exist in color with index: %d',2), +23002 => array('Mark color index too large for marker "%s"',1), +23003 => array('A filename must be specified if you set the mark type to MARK_IMG.',0), + +/* +** jpgraph_utils +*/ + +24001 => array('FuncGenerator : No function specified. ',0), +24002 => array('FuncGenerator : Syntax error in function specification ',0), +24003 => array('DateScaleUtils: Unknown tick type specified in call to GetTicks()',0), +24004 => array('ReadCSV2: Column count mismatch in %s line %d',2), +/* +** jpgraph +*/ + +25001 => array('This PHP installation is not configured with the GD library. Please recompile PHP with GD support to run JpGraph. (Neither function imagetypes() nor imagecreatefromstring() does exist)',0), +25002 => array('Your PHP installation does not seem to have the required GD library. Please see the PHP documentation on how to install and enable the GD library.',0), +25003 => array('General PHP error : At %s:%d : %s',3), +25004 => array('General PHP error : %s ',1), +25005 => array('Can\'t access PHP_SELF, PHP global variable. You can\'t run PHP from command line if you want to use the \'auto\' naming of cache or image files.',0), +25006 => array('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).',0), +25007 => array('You are trying to use the locale (%s) which your PHP installation does not support. Hint: Use \'\' to indicate the default locale for this geographic region.',1), +25008 => array('Image width/height argument in Graph::Graph() must be numeric',0), +25009 => array('You must specify what scale to use with a call to Graph::SetScale()',0), + +25010 => array('Graph::Add() You tried to add a null plot to the graph.',0), +25011 => array('Graph::AddY2() You tried to add a null plot to the graph.',0), +25012 => array('Graph::AddYN() You tried to add a null plot to the graph.',0), +25013 => array('You can only add standard plots to multiple Y-axis',0), +25014 => array('Graph::AddText() You tried to add a null text to the graph.',0), +25015 => array('Graph::AddLine() You tried to add a null line to the graph.',0), +25016 => array('Graph::AddBand() You tried to add a null band to the graph.',0), +25017 => array('You are using GD 2.x and are trying to use a background images on a non truecolor image. To use background images with GD 2.x it is necessary to enable truecolor by setting the USE_TRUECOLOR constant to TRUE. Due to a bug in GD 2.0.1 using any truetype fonts with truecolor images will result in very poor quality fonts.',0), +25018 => array('Incorrect file name for Graph::SetBackgroundImage() : "%s" Must have a valid image extension (jpg,gif,png) when using auto detection of image type',1), +25019 => array('Unknown file extension (%s) in Graph::SetBackgroundImage() for filename: "%s"',2), + +25020 => array('Graph::SetScale(): Specified Max value must be larger than the specified Min value.',0), +25021 => array('Unknown scale specification for Y-scale. (%s)',1), +25022 => array('Unknown scale specification for X-scale. (%s)',1), +25023 => array('Unsupported Y2 axis type: "%s" Must be one of (lin,log,int)',1), +25024 => array('Unsupported Y axis type: "%s" Must be one of (lin,log,int)',1), +25025 => array('Unsupported Tick density: %d',1), +25026 => array('Can\'t draw unspecified Y-scale. You have either: 1. Specified an Y axis for auto scaling but have not supplied any plots. 2. Specified a scale manually but have forgot to specify the tick steps',0), +25027 => array('Can\'t open cached CSIM "%s" for reading.',1), +25028 => array('Apache/PHP does not have permission to write to the CSIM cache directory (%s). Check permissions.',1), +25029 => array('Can\'t write CSIM "%s" for writing. Check free space and permissions.',1), + +25030 => array('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().',0), +25031 => array('You must specify what scale to use with a call to Graph::SetScale().',0), +25032 => array('No plots for Y-axis nbr:%d',1), +25033 => array('',0), +25034 => array('Can\'t draw unspecified X-scale. No plots specified.',0), +25035 => array('You have enabled clipping. Clipping is only supported for graphs at 0 or 90 degrees rotation. Please adjust you current angle (=%d degrees) or disable clipping.',1), +25036 => array('Unknown AxisStyle() : %s',1), +25037 => array('The image format of your background image (%s) is not supported in your system configuration. ',1), +25038 => array('Background image seems to be of different type (has different file extension) than specified imagetype. Specified: %s File: %s',2), +25039 => array('Can\'t read background image: "%s"',1), + +25040 => array('It is not possible to specify both a background image and a background country flag.',0), +25041 => array('In order to use Country flags as backgrounds you must include the "jpgraph_flags.php" file.',0), +25042 => array('Unknown background image layout',0), +25043 => array('Unknown title background style.',0), +25044 => array('Cannot use auto scaling since it is impossible to determine a valid min/max value of the Y-axis (only null values).',0), +25045 => array('Font families FF_HANDWRT and FF_BOOK are no longer available due to copyright problem with these fonts. Fonts can no longer be distributed with JpGraph. Please download fonts from http://corefonts.sourceforge.net/',0), +25046 => array('Specified TTF font family (id=%d) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/',1), +25047 => array('Style %s is not available for font family %s',2), +25048 => array('Unknown font style specification [%s].',1), +25049 => array('Font file "%s" is not readable or does not exist.',1), + +25050 => array('First argument to Text::Text() must be a string.',0), +25051 => array('Invalid direction specified for text.',0), +25052 => array('PANIC: Internal error in SuperScript::Stroke(). Unknown vertical alignment for text',0), +25053 => array('PANIC: Internal error in SuperScript::Stroke(). Unknown horizontal alignment for text',0), +25054 => array('Internal error: Unknown grid axis %s',1), +25055 => array('Axis::SetTickDirection() is deprecated. Use Axis::SetTickSide() instead',0), +25056 => array('SetTickLabelMargin() is deprecated. Use Axis::SetLabelMargin() instead.',0), +25057 => array('SetTextTicks() is deprecated. Use SetTextTickInterval() instead.',0), +25058 => array('Text label interval must be specified >= 1.',0), +25059 => array('SetLabelPos() is deprecated. Use Axis::SetLabelSide() instead.',0), + +25060 => array('Unknown alignment specified for X-axis title. (%s)',1), +25061 => array('Unknown alignment specified for Y-axis title. (%s)',1), +25062 => array('Labels at an angle are not supported on Y-axis',0), +25063 => array('Ticks::SetPrecision() is deprecated. Use Ticks::SetLabelFormat() (or Ticks::SetFormatCallback()) instead',0), +25064 => array('Minor or major step size is 0. Check that you haven\'t got an accidental SetTextTicks(0) in your code. If this is not the case you might have stumbled upon a bug in JpGraph. Please report this and if possible include the data that caused the problem',0), +25065 => array('Tick positions must be specified as an array()',0), +25066 => array('When manually specifying tick positions and labels the number of labels must be the same as the number of specified ticks.',0), +25067 => array('Your manually specified scale and ticks is not correct. The scale seems to be too small to hold any of the specified tick marks.',0), +25068 => array('A plot has an illegal scale. This could for example be that you are trying to use text auto scaling to draw a line plot with only one point or that the plot area is too small. It could also be that no input data value is numeric (perhaps only \'-\' or \'x\')',0), +25069 => array('Grace must be larger then 0',0), +25070 => array('Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings. It is an error to specify data for example as \'-2345.2\' (using quotes).',0), +25071 => array('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.',0), +25072 => array('You have specified a max value with SetAutoMax() which is smaller than the minimum value used for the scale. This is not possible.',0), +25073 => array('Internal error. Integer scale algorithm comparison out of bound (r=%f)',1), +25074 => array('Internal error. The scale range is negative (%f) [for %s scale] This problem could potentially be caused by trying to use \"illegal\" values in the input data arrays (like trying to send in strings or only NULL values) which causes the auto scaling to fail.',2), +25075 => array('Can\'t automatically determine ticks since min==max.',0), +25077 => array('Adjustment factor for color must be > 0',0), +25078 => array('Unknown color: %s',1), +25079 => array('Unknown color specification: %s, size=%d',2), + +25080 => array('Alpha parameter for color must be between 0.0 and 1.0',0), +25081 => array('Selected graphic format is either not supported or unknown [%s]',1), +25082 => array('Illegal sizes specified for width or height when creating an image, (width=%d, height=%d)',2), +25083 => array('Illegal image size when copying image. Size for copied to image is 1 pixel or less.',0), +25084 => array('Failed to create temporary GD canvas. Possible Out of memory problem.',0), +25085 => array('An image can not be created from the supplied string. It is either in a format not supported or the string is representing an corrupt image.',0), +25086 => array('You only seem to have GD 1.x installed. To enable Alphablending requires GD 2.x or higher. Please install GD or make sure the constant USE_GD2 is specified correctly to reflect your installation. By default it tries to auto detect what version of GD you have installed. On some very rare occasions it may falsely detect GD2 where only GD1 is installed. You must then set USE_GD2 to false.',0), +25087 => array('This PHP build has not been configured with TTF support. You need to recompile your PHP installation with FreeType support.',0), +25088 => array('You have a misconfigured GD font support. The call to imagefontwidth() fails.',0), +25089 => array('You have a misconfigured GD font support. The call to imagefontheight() fails.',0), + +25090 => array('Unknown direction specified in call to StrokeBoxedText() [%s]',1), +25091 => array('Internal font does not support drawing text at arbitrary angle. Use TTF fonts instead.',0), +25092 => array('There is either a configuration problem with TrueType or a problem reading font file "%s" Make sure file exists and is in a readable place for the HTTP process. (If \'basedir\' restriction is enabled in PHP then the font file must be located in the document root.). It might also be a wrongly installed FreeType library. Try upgrading to at least FreeType 2.1.13 and recompile GD with the correct setup so it can find the new FT library.',1), +25093 => array('Can not read font file "%s" in call to Image::GetBBoxTTF. Please make sure that you have set a font before calling this method and that the font is installed in the TTF directory.',1), +25094 => array('Direction for text most be given as an angle between 0 and 90.',0), +25095 => array('Unknown font font family specification. ',0), +25096 => array('Can\'t allocate any more colors in palette image. Image has already allocated maximum of %d colors and the palette is now full. Change to a truecolor image instead',0), +25097 => array('Color specified as empty string in PushColor().',0), +25098 => array('Negative Color stack index. Unmatched call to PopColor()',0), +25099 => array('Parameters for brightness and Contrast out of range [-1,1]',0), + +25100 => array('Problem with color palette and your GD setup. Please disable anti-aliasing or use GD2 with true-color. If you have GD2 library installed please make sure that you have set the USE_GD2 constant to true and truecolor is enabled.',0), +25101 => array('Illegal numeric argument to SetLineStyle(): (%d)',1), +25102 => array('Illegal string argument to SetLineStyle(): %s',1), +25103 => array('Illegal argument to SetLineStyle %s',1), +25104 => array('Unknown line style: %s',1), +25105 => array('NULL data specified for a filled polygon. Check that your data is not NULL.',0), +25106 => array('Image::FillToBorder : Can not allocate more colors',0), +25107 => array('Can\'t write to file "%s". Check that the process running PHP has enough permission.',1), +25108 => array('Can\'t stream image. This is most likely due to a faulty PHP/GD setup. Try to recompile PHP and use the built-in GD library that comes with PHP.',0), +25109 => array('Your PHP (and GD-lib) installation does not appear to support any known graphic formats. You need to first make sure GD is compiled as a module to PHP. If you also want to use JPEG images you must get the JPEG library. Please see the PHP docs for details.',0), + +25110 => array('Your PHP installation does not support the chosen graphic format: %s',1), +25111 => array('Can\'t delete cached image %s. Permission problem?',1), +25112 => array('Cached imagefile (%s) has file date in the future.',1), +25113 => array('Can\'t delete cached image "%s". Permission problem?',1), +25114 => array('PHP has not enough permissions to write to the cache file "%s". Please make sure that the user running PHP has write permission for this file if you wan to use the cache system with JpGraph.',1), +25115 => array('Can\'t set permission for cached image "%s". Permission problem?',1), +25116 => array('Cant open file from cache "%s"',1), +25117 => array('Can\'t open cached image "%s" for reading.',1), +25118 => array('Can\'t create directory "%s". Make sure PHP has write permission to this directory.',1), +25119 => array('Can\'t set permissions for "%s". Permission problems?',1), + +25120 => array('Position for legend must be given as percentage in range 0-1',0), +25121 => array('Empty input data array specified for plot. Must have at least one data point.',0), +25122 => array('Stroke() must be implemented by concrete subclass to class Plot',0), +25123 => array('You can\'t use a text X-scale with specified X-coords. Use a "int" or "lin" scale instead.',0), +25124 => array('The input data array must have consecutive values from position 0 and forward. The given y-array starts with empty values (NULL)',0), +25125 => array('Illegal direction for static line',0), +25126 => array('Can\'t create truecolor image. Check that the GD2 library is properly setup with PHP.',0), +25127 => array('The library has been configured for automatic encoding conversion of Japanese fonts. This requires that PHP has the mb_convert_encoding() function. Your PHP installation lacks this function (PHP needs the "--enable-mbstring" when compiled).',0), +25128 => array('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.',0), +25129 => array('Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.',0), +25130 => array('Too small plot area. (%d x %d). With the given image size and margins there is to little space left for the plot. Increase the plot size or reduce the margins.',2), + +25131 => array('StrokeBoxedText2() only supports TTF fonts and not built-in bitmap fonts.',0), +25132 => array('Undefined property %s.',1), +25133 => array('Use Graph::SetTheme() after Graph::SetScale().',0), + +/* +** jpgraph_led +*/ + +25500 => array('Multibyte strings must be enabled in the PHP installation in order to run the LED module so that the function mb_strlen() is available. See PHP documentation for more information.',0), + +/* +**--------------------------------------------------------------------------------------------- +** Pro-version strings +**--------------------------------------------------------------------------------------------- +*/ + +/* +** jpgraph_table +*/ + +27001 => array('GTextTable: Invalid argument to Set(). Array argument must be 2 dimensional',0), +27002 => array('GTextTable: Invalid argument to Set()',0), +27003 => array('GTextTable: Wrong number of arguments to GTextTable::SetColor()',0), +27004 => array('GTextTable: Specified cell range to be merged is not valid.',0), +27005 => array('GTextTable: Cannot merge already merged cells in the range: (%d,%d) to (%d,%d)',4), +27006 => array('GTextTable: Column argument = %d is outside specified table size.',1), +27007 => array('GTextTable: Row argument = %d is outside specified table size.',1), +27008 => array('GTextTable: Column and row size arrays must match the dimensions of the table',0), +27009 => array('GTextTable: Number of table columns or rows are 0. Make sure Init() or Set() is called.',0), +27010 => array('GTextTable: No alignment specified in call to SetAlign()',0), +27011 => array('GTextTable: Unknown alignment specified in SetAlign(). Horizontal=%s, Vertical=%s',2), +27012 => array('GTextTable: Internal error. Invalid alignment specified =%s',1), +27013 => array('GTextTable: Argument to FormatNumber() must be a string.',0), +27014 => array('GTextTable: Table is not initilaized with either a call to Set() or Init()',0), +27015 => array('GTextTable: Cell image constrain type must be TIMG_WIDTH or TIMG_HEIGHT',0), + +/* +** jpgraph_windrose +*/ + +22001 => array('Total percentage for all windrose legs in a windrose plot can not exceed 100%% !\n(Current max is: %d)',1), +22002 => array('Graph is too small to have a scale. Please make the graph larger.',0), +22004 => array('Label specification for windrose directions must have 16 values (one for each compass direction).',0), +22005 => array('Line style for radial lines must be on of ("solid","dotted","dashed","longdashed") ',0), +22006 => array('Illegal windrose type specified.',0), +22007 => array('To few values for the range legend.',0), +22008 => array('Internal error: Trying to plot free Windrose even though type is not a free windrose',0), +22009 => array('You have specified the same direction twice, once with an angle and once with a compass direction (%f degrees)',0), +22010 => array('Direction must either be a numeric value or one of the 16 compass directions',0), +22011 => array('Windrose index must be numeric or direction label. You have specified index=%d',1), +22012 => array('Windrose radial axis specification contains a direction which is not enabled.',0), +22013 => array('You have specified the look&feel for the same compass direction twice, once with text and once with index (Index=%d)',1), +22014 => array('Index for compass direction must be between 0 and 15.',0), +22015 => array('You have specified an undefined Windrose plot type.',0), +22016 => array('Windrose leg index must be numeric or direction label.',0), +22017 => array('Windrose data contains a direction which is not enabled. Please adjust what labels are displayed.',0), +22018 => array('You have specified data for the same compass direction twice, once with text and once with index (Index=%d)',1), +22019 => array('Index for direction must be between 0 and 15. You can\'t specify angles for a Regular Windplot, only index and compass directions.',0), +22020 => array('Windrose plot is too large to fit the specified Graph size. Please use WindrosePlot::SetSize() to make the plot smaller or increase the size of the Graph in the initial WindroseGraph() call.',0), +22021 => array('It is only possible to add Text, IconPlot or WindrosePlot to a Windrose Graph',0), +/* +** jpgraph_odometer +*/ + +13001 => array('Unknown needle style (%d).',1), +13002 => array('Value for odometer (%f) is outside specified scale [%f,%f]',3), + +/* +** jpgraph_barcode +*/ + +1001 => array('Unknown encoder specification: %s',1), +1002 => array('Data validation failed. Can\'t encode [%s] using encoding "%s"',2), +1003 => array('Internal encoding error. Trying to encode %s is not possible in Code 128',1), +1004 => array('Internal barcode error. Unknown UPC-E encoding type: %s',1), +1005 => array('Internal error. Can\'t encode character tuple (%s, %s) in Code-128 charset C',2), +1006 => array('Internal encoding error for CODE 128. Trying to encode control character in CHARSET != A',0), +1007 => array('Internal encoding error for CODE 128. Trying to encode DEL in CHARSET != B',0), +1008 => array('Internal encoding error for CODE 128. Trying to encode small letters in CHARSET != B',0), +1009 => array('Encoding using CODE 93 is not yet supported.',0), +1010 => array('Encoding using POSTNET is not yet supported.',0), +1011 => array('Non supported barcode backend for type %s',1), + +/* +** PDF417 +*/ +26000 => array('PDF417: The PDF417 module requires that the PHP installation must support the function bcmod(). This is normally enabled at compile time. See documentation for more information.',0), +26001 => array('PDF417: Number of Columns must be >= 1 and <= 30',0), +26002 => array('PDF417: Error level must be between 0 and 8',0), +26003 => array('PDF417: Invalid format for input data to encode with PDF417',0), +26004 => array('PDF417: Can\'t encode given data with error level %d and %d columns since it results in too many symbols or more than 90 rows.',2), +26005 => array('PDF417: Can\'t open file "%s" for writing',1), +26006 => array('PDF417: Internal error. Data files for PDF417 cluster %d is corrupted.',1), +26007 => array('PDF417: Internal error. GetPattern: Illegal Code Value = %d (row=%d)',2), +26008 => array('PDF417: Internal error. Mode not found in mode list!! mode=%d',1), +26009 => array('PDF417: Encode error: Illegal character. Can\'t encode character with ASCII code=%d',1), +26010 => array('PDF417: Internal error: No input data in decode.',0), +26011 => array('PDF417: Encoding error. Can\'t use numeric encoding on non-numeric data.',0), +26012 => array('PDF417: Internal error. No input data to decode for Binary compressor.',0), +26013 => array('PDF417: Internal error. Checksum error. Coefficient tables corrupted.',0), +26014 => array('PDF417: Internal error. No data to calculate codewords on.',0), +26015 => array('PDF417: Internal error. State transition table entry 0 is NULL. Entry 1 = (%s)',1), +26016 => array('PDF417: Internal error: Unrecognized state transition mode in decode.',0), + +/* +** jpgraph_contour +*/ + +28001 => array('Third argument to Contour must be an array of colors.',0), +28002 => array('Number of colors must equal the number of isobar lines specified',0), +28003 => array('ContourPlot Internal Error: isobarHCrossing: Coloumn index too large (%d)',1), +28004 => array('ContourPlot Internal Error: isobarHCrossing: Row index too large (%d)',1), +28005 => array('ContourPlot Internal Error: isobarVCrossing: Row index too large (%d)',1), +28006 => array('ContourPlot Internal Error: isobarVCrossing: Col index too large (%d)',1), +28007 => array('ContourPlot interpolation factor is too large (>5)',0), + +/* + * jpgraph_matrix and colormap +*/ +29201 => array('Min range value must be less or equal to max range value for colormaps',0), +29202 => array('The distance between min and max value is too small for numerical precision',0), +29203 => array('Number of color quantification level must be at least %d',1), +29204 => array('Number of colors (%d) is invalid for this colormap. It must be a number that can be written as: %d + k*%d',3), +29205 => array('Colormap specification out of range. Must be an integer in range [0,%d]',1), +29206 => array('Invalid object added to MatrixGraph',0), +29207 => array('Empty input data specified for MatrixPlot',0), +29208 => array('Unknown side specifiction for matrix labels "%s"',1), +29209 => array('CSIM Target matrix must be the same size as the data matrix (csim=%d x %d, data=%d x %d)',4), +29210 => array('CSIM Target for matrix labels does not match the number of labels (csim=%d, labels=%d)',2), + + +/* +* jpgraph_theme +*/ +30001 => array("Theme::%s() is not defined. \nPlease make %s(\$graph) function in your theme classs.",2), + +); + +?> diff --git a/html/jpgraph/lang/prod.inc.php b/html/jpgraph/lang/prod.inc.php new file mode 100644 index 0000000..a5d4ca2 --- /dev/null +++ b/html/jpgraph/lang/prod.inc.php @@ -0,0 +1,386 @@ +<?php +/*======================================================================= +// File: PROD.INC.PHP +// Description: Special localization file with the same error messages +// for all errors. +// Created: 2006-02-18 +// Ver: $Id: prod.inc.php 1886 2009-10-01 23:30:16Z ljp $ +// +// Copyright (c) Asial Corporation. All rights reserved. +//======================================================================== +*/ + +// The single error message for all errors +DEFINE('DEFAULT_ERROR_MESSAGE','We are sorry but the system could not generate the requested image. Please contact site support to resolve this problem. Problem no: #'); + +// Note: Format of each error message is array(<error message>,<number of arguments>) +_jpg_messages = array( + +/* +** Headers already sent error. This is formatted as HTML different since this will be sent back directly as text +*/ +10 => array('<table border=1><tr><td><font color=darkred size=4><b>JpGraph Error:</b> +HTTP headers have already been sent.<br>Caused by output from file <b>%s</b> at line <b>%d</b>.</font></td></tr><tr><td><b>Explanation:</b><br>HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it\'s image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).<p>Most likely you have some text in your script before the call to <i>Graph::Stroke()</i>. If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. <p>For example it is a common mistake to leave a blank line before the opening "<b><?php</b>".</td></tr></table>',2), + + +11 => array(DEFAULT_ERROR_MESSAGE.'11',0), +12 => array(DEFAULT_ERROR_MESSAGE.'12',0), +13 => array(DEFAULT_ERROR_MESSAGE.'13',0), +2001 => array(DEFAULT_ERROR_MESSAGE.'2001',0), +2002 => array(DEFAULT_ERROR_MESSAGE.'2002',0), +2003 => array(DEFAULT_ERROR_MESSAGE.'2003',0), +2004 => array(DEFAULT_ERROR_MESSAGE.'2004',0), +2005 => array(DEFAULT_ERROR_MESSAGE.'2005',0), +2006 => array(DEFAULT_ERROR_MESSAGE.'2006',0), +2007 => array(DEFAULT_ERROR_MESSAGE.'2007',0), +2008 => array(DEFAULT_ERROR_MESSAGE.'2008',0), +2009 => array(DEFAULT_ERROR_MESSAGE.'2009',0), +2010 => array(DEFAULT_ERROR_MESSAGE.'2010',0), +2011 => array(DEFAULT_ERROR_MESSAGE.'2011',0), +2012 => array(DEFAULT_ERROR_MESSAGE.'2012',0), +2013 => array(DEFAULT_ERROR_MESSAGE.'2013',0), +2014 => array(DEFAULT_ERROR_MESSAGE.'2014',0), +3001 => array(DEFAULT_ERROR_MESSAGE.'3001',0), +4002 => array(DEFAULT_ERROR_MESSAGE.'4002',0), +5001 => array(DEFAULT_ERROR_MESSAGE.'5001',0), +5002 => array(DEFAULT_ERROR_MESSAGE.'5002',0), +5003 => array(DEFAULT_ERROR_MESSAGE.'5003',0), +5004 => array(DEFAULT_ERROR_MESSAGE.'5004',0), +6001 => array(DEFAULT_ERROR_MESSAGE.'6001',0), +6002 => array(DEFAULT_ERROR_MESSAGE.'6002',0), +6003 => array(DEFAULT_ERROR_MESSAGE.'6003',0), +6004 => array(DEFAULT_ERROR_MESSAGE.'6004',0), +6005 => array(DEFAULT_ERROR_MESSAGE.'6005',0), +6006 => array(DEFAULT_ERROR_MESSAGE.'6006',0), +6007 => array(DEFAULT_ERROR_MESSAGE.'6007',0), +6008 => array(DEFAULT_ERROR_MESSAGE.'6008',0), +6009 => array(DEFAULT_ERROR_MESSAGE.'6009',0), +6010 => array(DEFAULT_ERROR_MESSAGE.'6010',0), +6011 => array(DEFAULT_ERROR_MESSAGE.'6011',0), +6012 => array(DEFAULT_ERROR_MESSAGE.'6012',0), +6015 => array(DEFAULT_ERROR_MESSAGE.'6015',0), +6016 => array(DEFAULT_ERROR_MESSAGE.'6016',0), +6017 => array(DEFAULT_ERROR_MESSAGE.'6017',0), +6018 => array(DEFAULT_ERROR_MESSAGE.'6018',0), +6019 => array(DEFAULT_ERROR_MESSAGE.'6019',0), +6020 => array(DEFAULT_ERROR_MESSAGE.'6020',0), +6021 => array(DEFAULT_ERROR_MESSAGE.'6021',0), +6022 => array(DEFAULT_ERROR_MESSAGE.'6022',0), +6023 => array(DEFAULT_ERROR_MESSAGE.'6023',0), +6024 => array(DEFAULT_ERROR_MESSAGE.'6024',0), +6025 => array(DEFAULT_ERROR_MESSAGE.'6025',0), +6027 => array(DEFAULT_ERROR_MESSAGE.'6027',0), +6028 => array(DEFAULT_ERROR_MESSAGE.'6028',0), +6029 => array(DEFAULT_ERROR_MESSAGE.'6029',0), +6030 => array(DEFAULT_ERROR_MESSAGE.'6030',0), +6031 => array(DEFAULT_ERROR_MESSAGE.'6031',0), +6032 => array(DEFAULT_ERROR_MESSAGE.'6032',0), +6033 => array(DEFAULT_ERROR_MESSAGE.'6033',0), +7001 => array(DEFAULT_ERROR_MESSAGE.'7001',0), +8001 => array(DEFAULT_ERROR_MESSAGE.'8001',0), +8002 => array(DEFAULT_ERROR_MESSAGE.'8002',0), +8003 => array(DEFAULT_ERROR_MESSAGE.'8003',0), +8004 => array(DEFAULT_ERROR_MESSAGE.'8004',0), +9001 => array(DEFAULT_ERROR_MESSAGE.'9001',0), +10001 => array(DEFAULT_ERROR_MESSAGE.'10001',0), +10002 => array(DEFAULT_ERROR_MESSAGE.'10002',0), +10003 => array(DEFAULT_ERROR_MESSAGE.'10003',0), +11001 => array(DEFAULT_ERROR_MESSAGE.'11001',0), +11002 => array(DEFAULT_ERROR_MESSAGE.'11002',0), +11003 => array(DEFAULT_ERROR_MESSAGE.'11003',0), +11004 => array(DEFAULT_ERROR_MESSAGE.'11004',0), +11005 => array(DEFAULT_ERROR_MESSAGE.'11005',0), +12001 => array(DEFAULT_ERROR_MESSAGE.'12001',0), +12002 => array(DEFAULT_ERROR_MESSAGE.'12002',0), +12003 => array(DEFAULT_ERROR_MESSAGE.'12003',0), +12004 => array(DEFAULT_ERROR_MESSAGE.'12004',0), +12005 => array(DEFAULT_ERROR_MESSAGE.'12005',0), +12006 => array(DEFAULT_ERROR_MESSAGE.'12006',0), +12007 => array(DEFAULT_ERROR_MESSAGE.'12007',0), +12008 => array(DEFAULT_ERROR_MESSAGE.'12008',0), +12009 => array(DEFAULT_ERROR_MESSAGE.'12009',0), +12010 => array(DEFAULT_ERROR_MESSAGE.'12010',0), +12011 => array(DEFAULT_ERROR_MESSAGE.'12011',0), +12012 => array(DEFAULT_ERROR_MESSAGE.'12012',0), +14001 => array(DEFAULT_ERROR_MESSAGE.'14001',0), +14002 => array(DEFAULT_ERROR_MESSAGE.'14002',0), +14003 => array(DEFAULT_ERROR_MESSAGE.'14003',0), +14004 => array(DEFAULT_ERROR_MESSAGE.'14004',0), +14005 => array(DEFAULT_ERROR_MESSAGE.'14005',0), +14006 => array(DEFAULT_ERROR_MESSAGE.'14006',0), +14007 => array(DEFAULT_ERROR_MESSAGE.'14007',0), +15001 => array(DEFAULT_ERROR_MESSAGE.'15001',0), +15002 => array(DEFAULT_ERROR_MESSAGE.'15002',0), +15003 => array(DEFAULT_ERROR_MESSAGE.'15003',0), +15004 => array(DEFAULT_ERROR_MESSAGE.'15004',0), +15005 => array(DEFAULT_ERROR_MESSAGE.'15005',0), +15006 => array(DEFAULT_ERROR_MESSAGE.'15006',0), +15007 => array(DEFAULT_ERROR_MESSAGE.'15007',0), +15008 => array(DEFAULT_ERROR_MESSAGE.'15008',0), +15009 => array(DEFAULT_ERROR_MESSAGE.'15009',0), +15010 => array(DEFAULT_ERROR_MESSAGE.'15010',0), +15011 => array(DEFAULT_ERROR_MESSAGE.'15011',0), +15012 => array(DEFAULT_ERROR_MESSAGE.'15012',0), +16001 => array(DEFAULT_ERROR_MESSAGE.'16001',0), +16002 => array(DEFAULT_ERROR_MESSAGE.'16002',0), +16003 => array(DEFAULT_ERROR_MESSAGE.'16003',0), +16004 => array(DEFAULT_ERROR_MESSAGE.'16004',0), +17001 => array(DEFAULT_ERROR_MESSAGE.'17001',0), +17002 => array(DEFAULT_ERROR_MESSAGE.'17002',0), +17004 => array(DEFAULT_ERROR_MESSAGE.'17004',0), +18001 => array(DEFAULT_ERROR_MESSAGE.'18001',0), +18002 => array(DEFAULT_ERROR_MESSAGE.'18002',0), +18003 => array(DEFAULT_ERROR_MESSAGE.'18003',0), +18004 => array(DEFAULT_ERROR_MESSAGE.'18004',0), +18005 => array(DEFAULT_ERROR_MESSAGE.'18005',0), +18006 => array(DEFAULT_ERROR_MESSAGE.'18006',0), +18007 => array(DEFAULT_ERROR_MESSAGE.'18007',0), +18008 => array(DEFAULT_ERROR_MESSAGE.'18008',0), +19001 => array(DEFAULT_ERROR_MESSAGE.'19001',0), +19002 => array(DEFAULT_ERROR_MESSAGE.'19002',0), +19003 => array(DEFAULT_ERROR_MESSAGE.'19003',0), +20001 => array(DEFAULT_ERROR_MESSAGE.'20001',0), +20002 => array(DEFAULT_ERROR_MESSAGE.'20002',0), +20003 => array(DEFAULT_ERROR_MESSAGE.'20003',0), +21001 => array(DEFAULT_ERROR_MESSAGE.'21001',0), +23001 => array(DEFAULT_ERROR_MESSAGE.'23001',0), +23002 => array(DEFAULT_ERROR_MESSAGE.'23002',0), +23003 => array(DEFAULT_ERROR_MESSAGE.'23003',0), +24001 => array(DEFAULT_ERROR_MESSAGE.'24001',0), +24002 => array(DEFAULT_ERROR_MESSAGE.'24002',0), +24003 => array(DEFAULT_ERROR_MESSAGE.'24003',0), +24004 => array(DEFAULT_ERROR_MESSAGE.'24004',0), +25001 => array(DEFAULT_ERROR_MESSAGE.'25001',0), +25002 => array(DEFAULT_ERROR_MESSAGE.'25002',0), +25003 => array(DEFAULT_ERROR_MESSAGE.'25003',0), +25004 => array(DEFAULT_ERROR_MESSAGE.'25004',0), +25005 => array(DEFAULT_ERROR_MESSAGE.'25005',0), +25006 => array(DEFAULT_ERROR_MESSAGE.'25006',0), +25007 => array(DEFAULT_ERROR_MESSAGE.'25007',0), +25008 => array(DEFAULT_ERROR_MESSAGE.'25008',0), +25009 => array(DEFAULT_ERROR_MESSAGE.'25009',0), +25010 => array(DEFAULT_ERROR_MESSAGE.'25010',0), +25011 => array(DEFAULT_ERROR_MESSAGE.'25011',0), +25012 => array(DEFAULT_ERROR_MESSAGE.'25012',0), +25013 => array(DEFAULT_ERROR_MESSAGE.'25013',0), +25014 => array(DEFAULT_ERROR_MESSAGE.'25014',0), +25015 => array(DEFAULT_ERROR_MESSAGE.'25015',0), +25016 => array(DEFAULT_ERROR_MESSAGE.'25016',0), +25017 => array(DEFAULT_ERROR_MESSAGE.'25017',0), +25018 => array(DEFAULT_ERROR_MESSAGE.'25018',0), +25019 => array(DEFAULT_ERROR_MESSAGE.'25019',0), +25020 => array(DEFAULT_ERROR_MESSAGE.'25020',0), +25021 => array(DEFAULT_ERROR_MESSAGE.'25021',0), +25022 => array(DEFAULT_ERROR_MESSAGE.'25022',0), +25023 => array(DEFAULT_ERROR_MESSAGE.'25023',0), +25024 => array(DEFAULT_ERROR_MESSAGE.'25024',0), +25025 => array(DEFAULT_ERROR_MESSAGE.'25025',0), +25026 => array(DEFAULT_ERROR_MESSAGE.'25026',0), +25027 => array(DEFAULT_ERROR_MESSAGE.'25027',0), +25028 => array(DEFAULT_ERROR_MESSAGE.'25028',0), +25029 => array(DEFAULT_ERROR_MESSAGE.'25029',0), +25030 => array(DEFAULT_ERROR_MESSAGE.'25030',0), +25031 => array(DEFAULT_ERROR_MESSAGE.'25031',0), +25032 => array(DEFAULT_ERROR_MESSAGE.'25032',0), +25033 => array(DEFAULT_ERROR_MESSAGE.'25033',0), +25034 => array(DEFAULT_ERROR_MESSAGE.'25034',0), +25035 => array(DEFAULT_ERROR_MESSAGE.'25035',0), +25036 => array(DEFAULT_ERROR_MESSAGE.'25036',0), +25037 => array(DEFAULT_ERROR_MESSAGE.'25037',0), +25038 => array(DEFAULT_ERROR_MESSAGE.'25038',0), +25039 => array(DEFAULT_ERROR_MESSAGE.'25039',0), +25040 => array(DEFAULT_ERROR_MESSAGE.'25040',0), +25041 => array(DEFAULT_ERROR_MESSAGE.'25041',0), +25042 => array(DEFAULT_ERROR_MESSAGE.'25042',0), +25043 => array(DEFAULT_ERROR_MESSAGE.'25043',0), +25044 => array(DEFAULT_ERROR_MESSAGE.'25044',0), +25045 => array(DEFAULT_ERROR_MESSAGE.'25045',0), +25046 => array(DEFAULT_ERROR_MESSAGE.'25046',0), +25047 => array(DEFAULT_ERROR_MESSAGE.'25047',0), +25048 => array(DEFAULT_ERROR_MESSAGE.'25048',0), +25049 => array(DEFAULT_ERROR_MESSAGE.'25049',0), +25050 => array(DEFAULT_ERROR_MESSAGE.'25050',0), +25051 => array(DEFAULT_ERROR_MESSAGE.'25051',0), +25052 => array(DEFAULT_ERROR_MESSAGE.'25052',0), +25053 => array(DEFAULT_ERROR_MESSAGE.'25053',0), +25054 => array(DEFAULT_ERROR_MESSAGE.'25054',0), +25055 => array(DEFAULT_ERROR_MESSAGE.'25055',0), +25056 => array(DEFAULT_ERROR_MESSAGE.'25056',0), +25057 => array(DEFAULT_ERROR_MESSAGE.'25057',0), +25058 => array(DEFAULT_ERROR_MESSAGE.'25058',0), +25059 => array(DEFAULT_ERROR_MESSAGE.'25059',0), +25060 => array(DEFAULT_ERROR_MESSAGE.'25060',0), +25061 => array(DEFAULT_ERROR_MESSAGE.'25061',0), +25062 => array(DEFAULT_ERROR_MESSAGE.'25062',0), +25063 => array(DEFAULT_ERROR_MESSAGE.'25063',0), +25064 => array(DEFAULT_ERROR_MESSAGE.'25064',0), +25065 => array(DEFAULT_ERROR_MESSAGE.'25065',0), +25066 => array(DEFAULT_ERROR_MESSAGE.'25066',0), +25067 => array(DEFAULT_ERROR_MESSAGE.'25067',0), +25068 => array(DEFAULT_ERROR_MESSAGE.'25068',0), +25069 => array(DEFAULT_ERROR_MESSAGE.'25069',0), +25070 => array(DEFAULT_ERROR_MESSAGE.'25070',0), +25071 => array(DEFAULT_ERROR_MESSAGE.'25071',0), +25072 => array(DEFAULT_ERROR_MESSAGE.'25072',0), +25073 => array(DEFAULT_ERROR_MESSAGE.'25073',0), +25074 => array(DEFAULT_ERROR_MESSAGE.'25074',0), +25075 => array(DEFAULT_ERROR_MESSAGE.'25075',0), +25077 => array(DEFAULT_ERROR_MESSAGE.'25077',0), +25078 => array(DEFAULT_ERROR_MESSAGE.'25078',0), +25079 => array(DEFAULT_ERROR_MESSAGE.'25079',0), +25080 => array(DEFAULT_ERROR_MESSAGE.'25080',0), +25081 => array(DEFAULT_ERROR_MESSAGE.'25081',0), +25082 => array(DEFAULT_ERROR_MESSAGE.'25082',0), +25083 => array(DEFAULT_ERROR_MESSAGE.'25083',0), +25084 => array(DEFAULT_ERROR_MESSAGE.'25084',0), +25085 => array(DEFAULT_ERROR_MESSAGE.'25085',0), +25086 => array(DEFAULT_ERROR_MESSAGE.'25086',0), +25087 => array(DEFAULT_ERROR_MESSAGE.'25087',0), +25088 => array(DEFAULT_ERROR_MESSAGE.'25088',0), +25089 => array(DEFAULT_ERROR_MESSAGE.'25089',0), +25090 => array(DEFAULT_ERROR_MESSAGE.'25090',0), +25091 => array(DEFAULT_ERROR_MESSAGE.'25091',0), +25092 => array(DEFAULT_ERROR_MESSAGE.'25092',0), +25093 => array(DEFAULT_ERROR_MESSAGE.'25093',0), +25094 => array(DEFAULT_ERROR_MESSAGE.'25094',0), +25095 => array(DEFAULT_ERROR_MESSAGE.'25095',0), +25096 => array(DEFAULT_ERROR_MESSAGE.'25096',0), +25097 => array(DEFAULT_ERROR_MESSAGE.'25097',0), +25098 => array(DEFAULT_ERROR_MESSAGE.'25098',0), +25099 => array(DEFAULT_ERROR_MESSAGE.'25099',0), +25100 => array(DEFAULT_ERROR_MESSAGE.'25100',0), +25101 => array(DEFAULT_ERROR_MESSAGE.'25101',0), +25102 => array(DEFAULT_ERROR_MESSAGE.'25102',0), +25103 => array(DEFAULT_ERROR_MESSAGE.'25103',0), +25104 => array(DEFAULT_ERROR_MESSAGE.'25104',0), +25105 => array(DEFAULT_ERROR_MESSAGE.'25105',0), +25106 => array(DEFAULT_ERROR_MESSAGE.'25106',0), +25107 => array(DEFAULT_ERROR_MESSAGE.'25107',0), +25108 => array(DEFAULT_ERROR_MESSAGE.'25108',0), +25109 => array(DEFAULT_ERROR_MESSAGE.'25109',0), +25110 => array(DEFAULT_ERROR_MESSAGE.'25110',0), +25111 => array(DEFAULT_ERROR_MESSAGE.'25111',0), +25112 => array(DEFAULT_ERROR_MESSAGE.'25112',0), +25113 => array(DEFAULT_ERROR_MESSAGE.'25113',0), +25114 => array(DEFAULT_ERROR_MESSAGE.'25114',0), +25115 => array(DEFAULT_ERROR_MESSAGE.'25115',0), +25116 => array(DEFAULT_ERROR_MESSAGE.'25116',0), +25117 => array(DEFAULT_ERROR_MESSAGE.'25117',0), +25118 => array(DEFAULT_ERROR_MESSAGE.'25118',0), +25119 => array(DEFAULT_ERROR_MESSAGE.'25119',0), +25120 => array(DEFAULT_ERROR_MESSAGE.'25120',0), +25121 => array(DEFAULT_ERROR_MESSAGE.'25121',0), +25122 => array(DEFAULT_ERROR_MESSAGE.'25122',0), +25123 => array(DEFAULT_ERROR_MESSAGE.'25123',0), +25124 => array(DEFAULT_ERROR_MESSAGE.'25124',0), +25125 => array(DEFAULT_ERROR_MESSAGE.'25125',0), +25126 => array(DEFAULT_ERROR_MESSAGE.'25126',0), +25127 => array(DEFAULT_ERROR_MESSAGE.'25127',0), +25128 => array(DEFAULT_ERROR_MESSAGE.'25128',0), +25129 => array(DEFAULT_ERROR_MESSAGE.'25129',0), +25130 => array(DEFAULT_ERROR_MESSAGE.'25130',0), +25131 => array(DEFAULT_ERROR_MESSAGE.'25131',0), +25132 => array(DEFAULT_ERROR_MESSAGE.'25132',0), +25133 => array(DEFAULT_ERROR_MESSAGE.'25133',0), +25500 => array(DEFAULT_ERROR_MESSAGE.'25500',0), +24003 => array(DEFAULT_ERROR_MESSAGE.'24003',0), +24004 => array(DEFAULT_ERROR_MESSAGE.'24004',0), +24005 => array(DEFAULT_ERROR_MESSAGE.'24005',0), +24006 => array(DEFAULT_ERROR_MESSAGE.'24006',0), +24007 => array(DEFAULT_ERROR_MESSAGE.'24007',0), +24008 => array(DEFAULT_ERROR_MESSAGE.'24008',0), +24009 => array(DEFAULT_ERROR_MESSAGE.'24009',0), +24010 => array(DEFAULT_ERROR_MESSAGE.'24010',0), +24011 => array(DEFAULT_ERROR_MESSAGE.'24011',0), +24012 => array(DEFAULT_ERROR_MESSAGE.'24012',0), +24013 => array(DEFAULT_ERROR_MESSAGE.'24013',0), +24014 => array(DEFAULT_ERROR_MESSAGE.'24014',0), +24015 => array(DEFAULT_ERROR_MESSAGE.'24015',0), +22001 => array(DEFAULT_ERROR_MESSAGE.'22001',0), +22002 => array(DEFAULT_ERROR_MESSAGE.'22002',0), +22004 => array(DEFAULT_ERROR_MESSAGE.'22004',0), +22005 => array(DEFAULT_ERROR_MESSAGE.'22005',0), +22006 => array(DEFAULT_ERROR_MESSAGE.'22006',0), +22007 => array(DEFAULT_ERROR_MESSAGE.'22007',0), +22008 => array(DEFAULT_ERROR_MESSAGE.'22008',0), +22009 => array(DEFAULT_ERROR_MESSAGE.'22009',0), +22010 => array(DEFAULT_ERROR_MESSAGE.'22010',0), +22011 => array(DEFAULT_ERROR_MESSAGE.'22011',0), +22012 => array(DEFAULT_ERROR_MESSAGE.'22012',0), +22013 => array(DEFAULT_ERROR_MESSAGE.'22013',0), +22014 => array(DEFAULT_ERROR_MESSAGE.'22014',0), +22015 => array(DEFAULT_ERROR_MESSAGE.'22015',0), +22016 => array(DEFAULT_ERROR_MESSAGE.'22016',0), +22017 => array(DEFAULT_ERROR_MESSAGE.'22017',0), +22018 => array(DEFAULT_ERROR_MESSAGE.'22018',0), +22019 => array(DEFAULT_ERROR_MESSAGE.'22019',0), +22020 => array(DEFAULT_ERROR_MESSAGE.'22020',0), +13001 => array(DEFAULT_ERROR_MESSAGE.'13001',0), +13002 => array(DEFAULT_ERROR_MESSAGE.'13002',0), +1001 => array(DEFAULT_ERROR_MESSAGE.'1001',0), +1002 => array(DEFAULT_ERROR_MESSAGE.'1002',0), +1003 => array(DEFAULT_ERROR_MESSAGE.'1003',0), +1004 => array(DEFAULT_ERROR_MESSAGE.'1004',0), +1005 => array(DEFAULT_ERROR_MESSAGE.'1005',0), +1006 => array(DEFAULT_ERROR_MESSAGE.'1006',0), +1007 => array(DEFAULT_ERROR_MESSAGE.'1007',0), +1008 => array(DEFAULT_ERROR_MESSAGE.'1008',0), +1009 => array(DEFAULT_ERROR_MESSAGE.'1009',0), +1010 => array(DEFAULT_ERROR_MESSAGE.'1010',0), +1011 => array(DEFAULT_ERROR_MESSAGE.'1011',0), +26000 => array(DEFAULT_ERROR_MESSAGE.'26000',0), +26001 => array(DEFAULT_ERROR_MESSAGE.'26001',0), +26002 => array(DEFAULT_ERROR_MESSAGE.'26002',0), +26003 => array(DEFAULT_ERROR_MESSAGE.'26003',0), +26004 => array(DEFAULT_ERROR_MESSAGE.'26004',0), +26005 => array(DEFAULT_ERROR_MESSAGE.'26005',0), +26006 => array(DEFAULT_ERROR_MESSAGE.'26006',0), +26007 => array(DEFAULT_ERROR_MESSAGE.'26007',0), +26008 => array(DEFAULT_ERROR_MESSAGE.'26008',0), +26009 => array(DEFAULT_ERROR_MESSAGE.'26009',0), +26010 => array(DEFAULT_ERROR_MESSAGE.'26010',0), +26011 => array(DEFAULT_ERROR_MESSAGE.'26011',0), +26012 => array(DEFAULT_ERROR_MESSAGE.'26012',0), +26013 => array(DEFAULT_ERROR_MESSAGE.'26013',0), +26014 => array(DEFAULT_ERROR_MESSAGE.'26014',0), +26015 => array(DEFAULT_ERROR_MESSAGE.'26015',0), +26016 => array(DEFAULT_ERROR_MESSAGE.'26016',0), + +27001 => array(DEFAULT_ERROR_MESSAGE.'27001',0), +27002 => array(DEFAULT_ERROR_MESSAGE.'27002',0), +27003 => array(DEFAULT_ERROR_MESSAGE.'27003',0), +27004 => array(DEFAULT_ERROR_MESSAGE.'27004',0), +27005 => array(DEFAULT_ERROR_MESSAGE.'27005',0), +27006 => array(DEFAULT_ERROR_MESSAGE.'27006',0), +27007 => array(DEFAULT_ERROR_MESSAGE.'27007',0), +27008 => array(DEFAULT_ERROR_MESSAGE.'27008',0), +27009 => array(DEFAULT_ERROR_MESSAGE.'27009',0), +27010 => array(DEFAULT_ERROR_MESSAGE.'27010',0), +27011 => array(DEFAULT_ERROR_MESSAGE.'27011',0), +27012 => array(DEFAULT_ERROR_MESSAGE.'27012',0), +27013 => array(DEFAULT_ERROR_MESSAGE.'27013',0), +27014 => array(DEFAULT_ERROR_MESSAGE.'27014',0), +27015 => array(DEFAULT_ERROR_MESSAGE.'27015',0), + +28001 => array(DEFAULT_ERROR_MESSAGE.'28001',0), +28002 => array(DEFAULT_ERROR_MESSAGE.'28002',0), +28003 => array(DEFAULT_ERROR_MESSAGE.'28003',0), +28004 => array(DEFAULT_ERROR_MESSAGE.'28004',0), +28005 => array(DEFAULT_ERROR_MESSAGE.'28005',0), +28006 => array(DEFAULT_ERROR_MESSAGE.'28006',0), +28007 => array(DEFAULT_ERROR_MESSAGE.'28007',0), + +29201 => array(DEFAULT_ERROR_MESSAGE.'28001',0), +29202 => array(DEFAULT_ERROR_MESSAGE.'28002',0), +29203 => array(DEFAULT_ERROR_MESSAGE.'28003',0), +29204 => array(DEFAULT_ERROR_MESSAGE.'28004',0), +29205 => array(DEFAULT_ERROR_MESSAGE.'28005',0), +29206 => array(DEFAULT_ERROR_MESSAGE.'28006',0), +29207 => array(DEFAULT_ERROR_MESSAGE.'28007',0), +29208 => array(DEFAULT_ERROR_MESSAGE.'28008',0), +29209 => array(DEFAULT_ERROR_MESSAGE.'28009',0), +29210 => array(DEFAULT_ERROR_MESSAGE.'28010',0), + +); + +?> diff --git a/html/jpgraph/themes/AquaTheme.class.php b/html/jpgraph/themes/AquaTheme.class.php new file mode 100644 index 0000000..751b420 --- /dev/null +++ b/html/jpgraph/themes/AquaTheme.class.php @@ -0,0 +1,202 @@ +<?php + +/** +* Aqua Theme class +*/ +class AquaTheme extends Theme +{ + protected $font_color = '#0044CC'; + protected $background_color = '#DDFFFF'; + protected $axis_color = '#0066CC'; + protected $grid_color = '#3366CC'; + + function GetColorList() { + return array( + '#183152', + '#C4D7ED', + '#375D81', + '#ABC8E2', + '#E1E6FA', + '#9BBAB2', + '#3B4259', + '#0063BC', + '#1D5A73', + '#ABABFF', + '#27ADC5', + '#EDFFCC', + +/* + + '#66FFFF', + '#00AABB', + '#00FFCC', + '#33CCFF', + '#008866', + '#99FFFF', + '#0099FF', + '#99FFCC', + '#3399FF', + '#2277FF', + '#445588', + '#003388', + '#338877', + '#55DDFF', + '#00FF99', + '#BBBBBB', + '#77AAFF', + '#00FFCC', +*/ + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.80, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(4); + + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin( + $img->raw_left_margin, + $img->raw_right_margin, + $img->raw_top_margin, + $height * 0.25 + ); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + //$plot->SetShadow(); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + $plot->SetColor($this->GetNextColor()); + $plot->SetWeight(2); +// $plot->SetBarCenter(); + break; + } + + case 'PiePlot': + { + $plot->SetCenter(0.5, 0.45); + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/GreenTheme.class.php b/html/jpgraph/themes/GreenTheme.class.php new file mode 100644 index 0000000..a61fbd8 --- /dev/null +++ b/html/jpgraph/themes/GreenTheme.class.php @@ -0,0 +1,178 @@ +<?php + +/** +* Green Theme class +*/ +class GreenTheme extends Theme +{ + private $font_color = '#009900'; + private $background_color = '#EEFFDD'; + private $axis_color = '#00CC00'; + private $grid_color = '#33CC33'; + + function GetColorList() { + return array( + '#66CC00', + '#009900', + '#AAFF77', + '#559922', + '#00CC33', + '#99FF00', + '#009966', + '#00FF99', + '#99BB66', + '#33FF00', + '#DDFFBB', + '#669933', + '#BBDDCC', + '#77CCBB', + '#668833', + '#BBEE66', + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + /* + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + */ + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + + $plot->SetColor($this->GetNextColor().'@0.4'); + $plot->SetWeight(2); + break; + } + + case 'PiePlot': + { + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/OceanTheme.class.php b/html/jpgraph/themes/OceanTheme.class.php new file mode 100644 index 0000000..b275036 --- /dev/null +++ b/html/jpgraph/themes/OceanTheme.class.php @@ -0,0 +1,180 @@ +<?php + +/** +* Ocean Theme class +*/ +class OceanTheme extends Theme +{ + protected $font_color = '#0066FF'; + private $background_color = '#DDEEFF'; + private $axis_color = '#0000CC'; + private $grid_color = '#3333CC'; + + function GetColorList() { + return array( + '#0066FF', + '#CCCCFF', + '#0000FF', + '#3366FF', + '#33CCFF', + '#660088', + '#3300FF', + '#0099FF', + '#6633FF', + '#0055EE', + '#2277EE', + '#3300FF', + '#AA00EE', + '#778899', + '#114499', + '#7744EE', + '#002288', + '#6666FF', + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + /* + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + */ + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + + $plot->SetColor($this->GetNextColor()); + $plot->SetWeight(2); + break; + } + + case 'PiePlot': + { + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/OrangeTheme.class.php b/html/jpgraph/themes/OrangeTheme.class.php new file mode 100644 index 0000000..ea26dad --- /dev/null +++ b/html/jpgraph/themes/OrangeTheme.class.php @@ -0,0 +1,180 @@ +<?php + +/** +* Orange Theme class +*/ +class OrangeTheme extends Theme +{ + private $font_color = '#CC4400'; + private $background_color = '#FFEEDD'; + private $axis_color = '#CC6600'; + private $grid_color = '#CC6633'; + + function GetColorList() { + return array( + '#FF9900', + '#FFCC00', + '#AA6600', + '#CCCC00', + '#CC6600', + '#FFFF66', + '#CCFF00', + '#CC3300', + '#669933', + '#EE7700', + '#AAEE33', + '#77AA00', + '#CCFF99', + '#FF6633', + '#885500', + '#AADD00', + '#99CC44', + '#887711', + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + /* + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + */ + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + + $plot->SetColor($this->GetNextColor().'@0.4'); + $plot->SetWeight(2); + break; + } + + case 'PiePlot': + { + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/PastelTheme.class.php b/html/jpgraph/themes/PastelTheme.class.php new file mode 100644 index 0000000..d3f1ddb --- /dev/null +++ b/html/jpgraph/themes/PastelTheme.class.php @@ -0,0 +1,175 @@ +<?php + +/** +* Pastel Theme class +*/ +class PastelTheme extends Theme +{ + private $font_color = '#0044CC'; + private $background_color = '#DDFFFF'; + private $axis_color = '#0066CC'; + private $grid_color = '#3366CC'; + + function GetColorList() { + return array( + '#FFAACC', + '#AAEECC', + '#AACCFF', + '#CCAAFF', + '#EEDDFF', + '#FFCCAA', + '#CCBBDD', + '#CCFFAA', + '#C7D7C2', + '#FFEEDD', + '#FFCCEE', + '#BFECFA', + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.80, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(4); + + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + $plot->SetColor($this->GetNextColor().'@0.4'); + $plot->SetWeight(2); +// $plot->SetBarCenter(); + break; + } + + case 'PiePlot': + { + $plot->SetCenter(0.5, 0.45); + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/RoseTheme.class.php b/html/jpgraph/themes/RoseTheme.class.php new file mode 100644 index 0000000..5a14630 --- /dev/null +++ b/html/jpgraph/themes/RoseTheme.class.php @@ -0,0 +1,180 @@ +<?php + +/** +* Rose Theme class +*/ +class RoseTheme extends Theme +{ + private $font_color = '#CC0044'; + private $background_color = '#FFDDDD'; + private $axis_color = '#CC0000'; + private $grid_color = '#CC3333'; + + function GetColorList() { + return array( + '#FF0000', + '#FF99FF', + '#AA0099', + '#FF00FF', + '#FF6666', + '#FF0099', + '#FFBB88', + '#AA2211', + '#FF6699', + '#BBAA88', + '#FF2200', + '#883333', + '#EE7777', + '#EE7711', + '#FF0066', + '#DD7711', + '#AA6600', + '#EE5500', + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + /* + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + */ + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + + $plot->SetColor($this->GetNextColor().'@0.4'); + $plot->SetWeight(2); + break; + } + + case 'PiePlot': + { + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/SoftyTheme.class.php b/html/jpgraph/themes/SoftyTheme.class.php new file mode 100644 index 0000000..222cf85 --- /dev/null +++ b/html/jpgraph/themes/SoftyTheme.class.php @@ -0,0 +1,209 @@ +<?php + +/** +* Softy Theme class +*/ +class SoftyTheme extends Theme +{ + protected $font_color = '#000000'; + protected $background_color = '#F7F8F4'; + protected $axis_color = '#000000'; + protected $grid_color = '#CCCCCC'; + + function GetColorList() { + return array( + '#CFE7FB', + '#F9D76F', + '#B9D566', + '#FFBB90', + '#66BBBB', + '#E69090', + '#BB90BB', + '#9AB67C', + '#D1CC66', + +/* + + '#AFD8F8', + '#F6BD0F', + '#8BBA00', + '#FF8E46', + '#008E8E', + + '#D64646', + '#8E468E', + '#588526', + '#B3AA00', + '#008ED6', + + '#9D080D', + '#A186BE', + */ + ); + } + + function SetupGraph($graph) { + + // graph + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // y2~ + if (isset($graph->y2axis)) { + $graph->y2axis->title->SetColor($this->font_color); + $graph->y2axis->SetColor($this->axis_color, $this->font_color); + $graph->y2axis->SetTickSide(SIDE_LEFT); + $graph->y2axis->SetLabelMargin(8); + $graph->y2axis->HideLine(); + $graph->y2axis->HideTicks(); + } + + // yn + if (isset($graph->y2axis)) { + foreach ($graph->ynaxis as $axis) { + $axis->title->SetColor($this->font_color); + $axis->SetColor($this->axis_color, $this->font_color); + $axis->SetTickSide(SIDE_LEFT); + $axis->SetLabelMargin(8); + $axis->HideLine(); + $axis->HideTicks(); + } + } + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + $graph->ygrid->SetFill(true, '#FFFFFF', $this->background_color); + $graph->xgrid->Show(); + $graph->xgrid->SetColor($this->grid_color); + $graph->xgrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $img->height * 0.25); +// $graph->SetMargin(200, $img->right_margin, $img->top_margin, $height * 0.25); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + $plot->value->SetAlign('center', 'center'); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + + $plot->SetColor($this->GetNextColor()); + $plot->SetWeight(2); +// $plot->SetBarCenter(); + break; + } + + case 'PiePlot': + { + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + $plot->value->SetAlign('center', 'center'); + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + $_plot->SetValuePos('center'); + } + break; + } + + case 'ScatterPlot': + { + break; + } + + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/UniversalTheme.class.php b/html/jpgraph/themes/UniversalTheme.class.php new file mode 100644 index 0000000..44b57a6 --- /dev/null +++ b/html/jpgraph/themes/UniversalTheme.class.php @@ -0,0 +1,188 @@ +<?php + +/** +* Universal Theme class +*/ +class UniversalTheme extends Theme +{ + private $font_color = '#444444'; + private $background_color = '#F4F4F4'; + private $axis_color = '#888888'; + private $grid_color = '#E3E3E3'; + + function GetColorList() { + return array( + '#61a9f3',#blue + '#f381b9',#red + '#61E3A9',#green + + #'#D56DE2', + '#85eD82', + '#F7b7b7', + '#CFDF49', + '#88d8f2', + '#07AF7B', + '#B9E3F9', + '#FFF3AD', + '#EF606A', + '#EC8833', + '#FFF100', + '#87C9A5', + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBox(true, '#DADADA'); +// $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + $graph->xaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + //$graph->xaxis->SetLabelMargin(30); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); +// $graph->yaxis->SetTickPositions(array(50, 100, 150)); +// $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetFill(true, '#FFFFFF', $this->background_color); + // $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.80, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(4); + + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin( + $img->raw_left_margin, + $img->raw_right_margin, + $img->raw_top_margin, + $height * 0.25 + ); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + $plot->SetColor($this->GetNextColor().'@0.4'); + $plot->SetWeight(2); + break; + } + + case 'PiePlot': + { + $plot->SetCenter(0.5, 0.45); + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/jpgraph/themes/VividTheme.class.php b/html/jpgraph/themes/VividTheme.class.php new file mode 100644 index 0000000..38a7709 --- /dev/null +++ b/html/jpgraph/themes/VividTheme.class.php @@ -0,0 +1,175 @@ +<?php + +/** +* Vivid Theme class +*/ +class VividTheme extends Theme +{ + private $font_color = '#0044CC'; + private $background_color = '#DDFFFF'; + private $axis_color = '#0066CC'; + private $grid_color = '#3366CC'; + + function GetColorList() { + return array( + '#FFFB11', + '#005EBC', + '#9AEB67', + '#FF4A26', + '#FDFF98', + '#6B7EFF', + '#BCE02E', + '#E0642E', + '#E0D62E', + '#2E97E0', + '#02927F', + '#FF005A', + ); + } + + function SetupGraph($graph) { + + // graph + /* + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + */ + $graph->SetFrame(false); + $graph->SetMarginColor('white'); + $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); + + // legend + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.85, 'center', 'top'); + $graph->legend->SetFillColor('white'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(3); + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // xaxis + $graph->xaxis->title->SetColor($this->font_color); + $graph->xaxis->SetColor($this->axis_color, $this->font_color); + $graph->xaxis->SetTickSide(SIDE_BOTTOM); + $graph->xaxis->SetLabelMargin(10); + + // yaxis + $graph->yaxis->title->SetColor($this->font_color); + $graph->yaxis->SetColor($this->axis_color, $this->font_color); + $graph->yaxis->SetTickSide(SIDE_LEFT); + $graph->yaxis->SetLabelMargin(8); + $graph->yaxis->HideLine(); + $graph->yaxis->HideTicks(); + $graph->xaxis->SetTitleMargin(15); + + // grid + $graph->ygrid->SetColor($this->grid_color); + $graph->ygrid->SetLineStyle('dotted'); + + + // font + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + +// $graph->img->SetAntiAliasing(); + } + + + function SetupPieGraph($graph) { + + // graph + $graph->SetFrame(false); + + // legend + $graph->legend->SetFillColor('white'); + + $graph->legend->SetFrameWeight(0); + $graph->legend->Pos(0.5, 0.80, 'center', 'top'); + $graph->legend->SetLayout(LEGEND_HOR); + $graph->legend->SetColumns(4); + + $graph->legend->SetShadow(false); + $graph->legend->SetMarkAbsSize(5); + + // title + $graph->title->SetColor($this->font_color); + $graph->subtitle->SetColor($this->font_color); + $graph->subsubtitle->SetColor($this->font_color); + + $graph->SetAntiAliasing(); + } + + + function PreStrokeApply($graph) { + if ($graph->legend->HasItems()) { + $img = $graph->img; + $height = $img->height; + $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); + } + } + + function ApplyPlot($plot) { + + switch (get_class($plot)) + { + case 'GroupBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'AccBarPlot': + { + foreach ($plot->plots as $_plot) { + $this->ApplyPlot($_plot); + } + break; + } + + case 'BarPlot': + { + $plot->Clear(); + + $color = $this->GetNextColor(); + $plot->SetColor($color); + $plot->SetFillColor($color); + $plot->SetShadow('red', 3, 4, false); + break; + } + + case 'LinePlot': + { + $plot->Clear(); + $plot->SetColor($this->GetNextColor().'@0.4'); + $plot->SetWeight(2); +// $plot->SetBarCenter(); + break; + } + + case 'PiePlot': + { + $plot->SetCenter(0.5, 0.45); + $plot->ShowBorder(false); + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + case 'PiePlot3D': + { + $plot->SetSliceColors($this->GetThemeColors()); + break; + } + + default: + { + } + } + } +} + + +?> diff --git a/html/pages/admin/check.php b/html/pages/admin/check.php index a03bf91..2531cca 100755 --- a/html/pages/admin/check.php +++ b/html/pages/admin/check.php @@ -299,6 +299,52 @@ CREATE TABLE `uts_weaponstats` ( ) ENGINE=MyISAM; "; +$create_table['uts_chartdata'] = " +CREATE TABLE `uts_chartdata` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `mid` int(11) NOT NULL, + `chartid` mediumint(9) NOT NULL, + `title` varchar(50) NOT NULL, + `data` blob NOT NULL, + `labels` blob NOT NULL, + `categories` blob NOT NULL, + PRIMARY KEY (`id`), + KEY `mid` (`mid`), + KEY `mid_2` (`mid`) +) ENGINE=MyISAM; +"; + +$create_table['uts_charttypes'] = " +CREATE TABLE `uts_charttypes` ( + `id` mediumint(9) NOT NULL, + `category` varchar(25) NOT NULL, + `type` varchar(50) NOT NULL, + `color` varchar(10) NOT NULL, + `layout` text NOT NULL, + `charttype` varchar(15) NOT NULL, + `columns` int(11) NOT NULL DEFAULT '1', + PRIMARY KEY (`id`) +) ENGINE=MyISAM; +"; + +INSERT INTO `uts_charttypes` (`id`, `category`, `type`, `color`, `layout`, `charttype`, `columns`) VALUES +(90, 'Frags Team', 'teamScore', 'team', 'title: {\ntext: ''Battle for #1''\n},\ncredits: {\nenabled: false\n}, \nlegend: {\nenabled: false\n}, \nxAxis: {\ntitle: '''',\nmin: 0\n}, \nyAxis: {\ntitle: '''',\nmin: 0\n},\nplotOptions : {\n line : {\n stickyTracking : false\n }\n}', 'line', 1), +(92, 'Frags Team', 'teamNormal', 'team', 'title: {\ntext: ''Spread vs #2 team''\n},\ncredits: {\nenabled: false\n}, \nlegend: {\nenabled: false\n}, \nxAxis: {\ntitle: '''',\nmin: 0\n}, \nyAxis: {\ntitle: '''' \n},\nplotOptions : {\n line : {\n stickyTracking : false\n }\n}', 'line', 1), +(91, 'Frags Team', 'teamDeriv', 'team', ' title : {\n text : ''Battle for #1''\n },\n credits : {\n enabled : false\n },\n legend : {\n enabled : true\n },\n xAxis : {\n title : '''',\n min : 0\n },\n yAxis: [{\n \n title: {\n text: ''score''\n },\n min: 0,\n floor: 0,\n opposite: true\n },{\n title: {\n text: ''frags per min''\n },\n min: 0,\n floor: 0\n }],\n plotOptions : {\n column : {\n stacking : ''normal'',\n pointPadding : 0,\n groupPadding : 0,\n borderWidth : 0,\n shadow : false,\nenableMouseTracking: false\n },line: { stickyTracking: false }\n }', 'linecolumn', 1), +(93, 'Top fraggers', 'playerScore', 'player', 'title: {\ntext: ''Battle for #1''\n},\ncredits: {\nenabled: false\n}, \nlegend: {\nenabled: true\n}, \nxAxis: {\ntitle: '''',\nmin: 0\n}, \nyAxis: {\ntitle: '''',\nmin: 0\n},\nplotOptions : {\n line : {\n stickyTracking : false\n }\n}', 'line', 1), +(94, 'Top fraggers', 'playerDeriv', 'player', 'title : {\n text : ''Battle for #1''\n },\n credits : {\n enabled : false\n },\n legend : {\n enabled : true\n },\n xAxis : {\n title : '''',\n min : 0\n },\n yAxis: [{\n \n title: {\n text: ''score''\n },allowDecimals : false,\n tickPositioner: function () {\n\n var maxDeviation = round_up(Math.max(Math.abs(this.dataMax), Math.abs(this.dataMin)),3);\n var thirdMaxDeviation = Math.ceil(maxDeviation / 3);\n\n return [-thirdMaxDeviation , 0, thirdMaxDeviation , 2*thirdMaxDeviation , maxDeviation];\n },\n \n \n opposite: true\n },{\n title: {\n text: ''frags per min''\n },allowDecimals : false, tickPositioner: function () {\n\n\n var maxDeviation = round_up(Math.max(Math.abs(this.dataMax), Math.abs(this.dataMin)),3);\n var thirdMaxDeviation = Math.ceil(maxDeviation / 3);\n\n return [-thirdMaxDeviation , 0, thirdMaxDeviation , 2*thirdMaxDeviation , maxDeviation];\n } \n }],\n plotOptions : {\n column : {\n stacking : ''normal'',\n pointPadding : 0,\n groupPadding : 0,\n borderWidth : 0,\n shadow : false,\nenableMouseTracking: false\n },line: { stickyTracking: false }\n }', 'linecolumn', 1), +(95, 'Top fraggers', 'playerNormal', 'player', 'title: {\ntext: ''Spread vs #2''\n},\ncredits: {\nenabled: false\n}, \nlegend: {\nenabled: true\n}, \nxAxis: {\ntitle: '''',\nmin: 0\n}, \nyAxis: {\ntitle: '''' \n},\nplotOptions : {\n line : {\n stickyTracking : false\n }\n}', 'line', 1), +(96, 'Frags #5-8', 'playerScore5', 'player', 'title: {\ntext: ''Battle for #5''\n},\ncredits: {\nenabled: false\n}, \nlegend: {\nenabled: true\n}, \nxAxis: {\ntitle: '''',\nmin: 0\n}, \nyAxis: {\ntitle: '''',\nmin: 0\n},\nplotOptions : {\n line : {\n stickyTracking : false\n }\n}', 'line', 1), +(97, 'Frags #5-8', 'playerNormal5', 'player', 'title: {\ntext: ''Spread vs #5''\n},\ncredits: {\nenabled: false\n}, \nlegend: {\nenabled: true\n}, \nxAxis: {\ntitle: '''',\nmin: 0\n}, \nyAxis: {\ntitle: '''' \n}', 'line', 1), +(10, 'CTF Score', 'teamScore', 'team', 'title : {\n text : ''CTF Team Score''\n },\n\ntooltip: {\n\n positioner: function () {\n return { x: 10, y: 10 };\n },\nformatter:function() {\n\nif(this.point.tooltipdata === ''undefined'' || this.point.tooltipdata == null ) {\n return Math.floor(this.x)+''min ''+Math.round((this.x-Math.floor(this.x))*60)+''sec<br><span style="color: '' + this.series.color + ''">●</span> ''+this.series.name+'' : ''+this.y;\n} else {\nreturn Math.floor(this.x)+''min ''+Math.round((this.x-Math.floor(this.x))*60)+''sec<br><span style="color: '' + this.series.color + ''">●</span> ''+this.series.name+'' : ''+this.y+''<br>''+this.point.tooltipdata;\n}\n}\n\n},\n credits : {\n enabled : false\n },\n legend : {\n enabled : false\n },\n xAxis : {\n title : '''',\n min : 0\n },\n yAxis: [{\n \n title: {\n text: ''score''\n },\n min: 0,\n floor: 0,\n allowDecimals: false,\n opposite: true\n }, {\n title: {\n text: ''grabs per min''\n },\n min: 0,\n allowDecimals: false,\n floor: 0\n }],\n plotOptions : {\n column : {\n pointPlacement: ''between'',\n pointPadding : 0,\npointRange: 1, groupPadding : 0.2,\n borderWidth : 0,\n shadow : false,\nenableMouseTracking: false\n },line: { stickyTracking: false }\n }', 'linestepcolumn', 2), +(11, 'CTF Grabs', 'teamBreakdown', 'player', '\n title : {\n text : ''Grab conversion''\n },\n credits : {\n enabled : false\n },\n legend : {\n enabled : true\n },\n xAxis : {\n title : '''',\ncategories: [''Red'',''Blue'']\n },\n yAxis: {\n \n title: '''',allowDecimals: false,\n reversedStacks: false,stackLabels: {\n enabled: true }\n },\n plotOptions : {\n bar : { \n stacking : ''normal'', borderWidth : 0\n }\n }', 'bar', 2), +(100, 'Items', 'Team Pickups', 'team', '\n credits : {\n enabled : false\n },\n title: {\n text: ''''\n },\n \n pane: {\n size: ''100%''\n },\n\n plotOptions: {\n series: {\n fillOpacity: 0.4\n }\n },\nxAxis: {\n tickmarkPlacement: ''on'',\n lineWidth: 0\n },\n\n yAxis: {\n labels: {enabled:false},\n tickPixelInterval: 25,\n tickPositions: [0,25,50,75,100],\n gridLineInterpolation: ''polygon'',lineWidth: 0\n },\ntooltip: { \nvalueSuffix: '' %'' }', 'radar', 1), +(101, 'Items', 'Player Pickups', 'player', ' credits : {\n enabled : false\n },\n title: {\n text: ''''\n },\n \n pane: {\n size: ''100%''\n },\n\n plotOptions: {\n series: {\n fillOpacity: 0.4\n }\n },\nxAxis: {\n tickmarkPlacement: ''on'',\n lineWidth: 0\n },\n\n yAxis: {\n labels: {enabled:false},\n tickPixelInterval: 25,\n ickPositions: [0,25,50,75,100],\n gridLineInterpolation: ''polygon'',lineWidth: 0\n },\ntooltip: { \nvalueSuffix: '' %'' }', 'radar', 1), +(102, 'Items', 'ampRuns', 'team', 'title : {\n text : ''Amp runs net points''\n },\n credits : {\n enabled : false\n },\n legend : {\n enabled : false\n },\n xAxis : {\n title : '''',\n tickPosition: ''inside'',\n labels: {\n align: ''left'',\n overflow: false,\n x:5,\n y:3,\n style: { whiteSpace: ''nowrap'' }\n }\n },\n yAxis : {\n\n title : '''',\n allowDecimals : false,\n reversedStacks : false,\n tickPositioner: function () {\nvar maxDeviation = round_up(Math.max(Math.abs(this.dataMax), Math.abs(this.dataMin)),6);\n var thirdMaxDeviation = Math.ceil(maxDeviation / 3);\n\n return [-maxDeviation,-2*thirdMaxDeviation,-thirdMaxDeviation , 0, thirdMaxDeviation , 2*thirdMaxDeviation , maxDeviation];\n },\n stackLabels : {\n enabled : false\n }\n },\n plotOptions : {\n bar : {\n stacking : ''normal'',\n borderWidth : 0,\n pointPadding: 0.1,\n groupPadding: 0.1\n }\n },\n\ntooltip: {\nformatter:function() {\n return this.x+''<br><span style="color: '' + this.point.color + ''">●</span>''+this.series.name+ '' : ''+this.y;}\n\n}', 'bar', 1), +(20, 'Domination', 'teamScore', 'team', 'title: {\ntext: ''Score''\n},\ncredits: {\nenabled: false\n}, \nlegend: {\nenabled: false\n}, \nxAxis: {\ntitle: '''',\nmin: 0\n}, \nyAxis: {\ntitle: '''',\nmin: 0\n},\nplotOptions : {\n line : {\n stickyTracking : false\n }\n}', 'line', 1), +(21, 'Domination', 'teamDeriv', 'team', ' title : {\n text : ''Score''\n },\n credits : {\n enabled : false\n },\n legend : {\n enabled : true\n },\n xAxis : {\n title : '''',\n min : 0\n },\n yAxis: [{\n \n title: {\n text: ''Dom Score''\n },\n min: 0,\n floor: 0,\n opposite: true\n },{\n title: {\n text: ''net dom points per min''\n },\n min: 0,\n floor: 0\n }],\n plotOptions : {\n column : {\n stacking : ''normal'',\npointPlacement: ''between'', pointPadding : 0,\npointRange: 1, groupPadding : 0.2, borderWidth : 0, shadow : false,\nenableMouseTracking: false\n },line: { stickyTracking: false }\n }', 'linecolumn', 1); + + foreach ($create_table as $table => $query) { echo ' <tr> diff --git a/html/pages/credits.php b/html/pages/credits.php index a123ac4..4f8f4c2 100755 --- a/html/pages/credits.php +++ b/html/pages/credits.php @@ -19,6 +19,10 @@ All original pages are W3C <a href="http://validator.w3.org/check?uri=referer" t <p><a name="changelog"></a><b>Change Log</b></p>
<blockquote><p>
<dl>
+ <dt>4.3.0 (4/1/2018 by killerEye, imported by Monk)</dt>
+ <dd>Added:<br>
+ Graphs of specific stats for CTF, DOM and DM game types.<br><br></dd>
+
<dt>beta 4.2.8 (23/7/2011 by Rork)</dt>
<dd>Bug Fixes:<br>
Fixed explain rankings (reported by Letylove49)<br>
diff --git a/html/pages/match_info.php b/html/pages/match_info.php index 7645077..31edc2d 100755 --- a/html/pages/match_info.php +++ b/html/pages/match_info.php @@ -11,6 +11,7 @@ echo ' </tbody></table>
<br>';
include("pages/match_info_server.php");
+include("pages/match_info_charts.php");
$GLOBALS['gid'] = $gid;
$_GLOBALS['gid'] = $gid;
@@ -23,18 +24,18 @@ switch($real_gamename) { case "Assault (insta)":
include("pages/match_info_ass.php");
break;
-
+
case "Capture the Flag":
case "Capture the Flag (insta)":
include("pages/match_info_ctf.php");
teamstats($mid, 'Match Summary');
break;
-
+
case "Domination":
case "Domination (insta)":
teamstats($mid, 'Match Summary', 'dom_cp', 'Dom Pts');
break;
-
+
case "JailBreak":
case "JailBreak (insta)":
teamstats($mid, 'Match Summary', 'ass_obj', 'Team Releases');
@@ -43,6 +44,13 @@ switch($real_gamename) { case "Bunny Track":
include("pages/match_info_bt.php");
break;
+
+ case "Tournament DeathMatch":
+ case "Tournament Team Game":
+ case "Tournament DeathMatch (insta)":
+ case "Tournament Team Game (insta)":
+ teamstats($mid, 'Match Summary');
+ break;
case "Extended Last Man Standing":
case "Extended Last Man Standing (insta)":
@@ -62,6 +70,7 @@ switch($real_gamename) { teamstats($mid, 'Player Summary');
}
}
+
if ($real_gamename == "Assault" or $real_gamename== "Assault (insta)") {
include("pages/match_info_other2.php");
@@ -74,4 +83,4 @@ if ($real_gamename == "Capture the Flag" or $real_gamename== "Capture the Flag ( include("pages/match_report.php");
}
-?>
+?>
\ No newline at end of file diff --git a/html/pages/match_info_charts.php b/html/pages/match_info_charts.php new file mode 100644 index 0000000..a6170e7 --- /dev/null +++ b/html/pages/match_info_charts.php @@ -0,0 +1,85 @@ +<?php + +include_once 'includes/renderer-general-output.php'; + +global $renderer_heigth; +global $renderer_width; + +$mid = mysql_real_escape_string($mid); +$prevCategory = ""; +$chartOutput = ""; +$prevRenderedChart = ""; + +// get all charts for this match +$charts = mysql_query("SELECT d.* , t.charttype, t.category, t.type, t.color, t.layout,t.columns +FROM uts_chartdata d +JOIN uts_charttypes t ON d.chartid = t.id +WHERE d.mid = $mid +ORDER BY d.id ASC") or die(mysql_error()); + +$chartCount = mysql_num_rows($charts); + +if($chartCount >0) { + $i = 0; + + // cycle over charts + while ($chart = mysql_fetch_array($charts)) { + + // retrieve both generic as the specific data + $category = $chart['category']; + $type = $chart['type']; + $color = $chart['color']; + $layout = $chart['layout']; + $charttype = $chart['charttype']; + $columns = $chart['columns']; + $title = $chart['title']; + $data = unserialize(gzdecode($chart['data'])); + $labels = unserialize(gzdecode($chart['labels'])); + $categories = unserialize(gzdecode($chart['categories'])); + + // append previous chart - this is done to ensure proper outlining (can only know in +1 round) + $chartOutput .= $prevRenderedChart; + + // print a new section if we're now in a different category + if($category != $prevCategory) { + + if(strlen($prevCategory)>0) + $chartOutput .= renderFootBlock(); + + $chartOutput .= renderHeaderBlock($category); + $prevCategory = $category; + + } else { + if($i>1 && $i%2 == 0) + $chartOutput .= "</td></tr><tr><td>"; + else + $chartOutput .= "</td><td>"; + } + + $prevRenderedChart = renderChart($mid."-".$i,$layout,$color,$title,$data,$labels,$categories,$renderer_width*$columns,$renderer_heigth,$charttype); + + $i++; + } + + // finishing up + $chartOutput .= $prevRenderedChart; + $chartOutput .= renderFootBlock(); + + echo " + <script type='text/javascript'> + function toggle_visibility(id) { + var e = document.getElementById(id); + if(e.style.display != 'none') + e.style.display = 'none'; + else + e.style.display = ''; + } + </script> + "; + + echo $chartOutput; +} + + + +?>
\ No newline at end of file diff --git a/html/pages/match_info_server.php b/html/pages/match_info_server.php index fb92456..b3c6f40 100755 --- a/html/pages/match_info_server.php +++ b/html/pages/match_info_server.php @@ -81,7 +81,11 @@ if (file_exists($mappic)) { $mappic = ("images/maps/blank.jpg");
}
- $myurl = urlencode($mapname);
+$myurl = urlencode($mapname);
+
+$mapnameToPrint = $matchinfo['mapname'];
+if($mapnameToPrint == "Untitled")
+ $mapnameToPrint = $mapname;
echo'
<tr>
@@ -94,7 +98,7 @@ if (file_exists($mappic)) { <td class="dark" align="center">Match Type</td>
<td class="grey" align="center">'.$gamename.'</td>
<td class="dark" align="center">Map Name</td>
- <td class="greyhuman" align="center"><a class="grey" href="./?p=minfo&map='.$myurl.'">'.$matchinfo[mapname].'</a></td>
+ <td class="greyhuman" align="center"><a class="grey" href="./?p=minfo&map='.$myurl.'">'.$mapnameToPrint.'</a></td>
</tr>
<tr>
<td class="dark" align="center">Server Info</td>
@@ -111,4 +115,15 @@ if (file_exists($mappic)) { </tr>
</tbody></table>
<br>';
+
+
+// Get Summary Info
+$teamscore = small_query("SELECT SUM(t0score + t1score + t2score + t3score) AS result FROM uts_match WHERE id = $mid");
+$playerscore = small_query("SELECT SUM(gamescore) AS result FROM uts_player WHERE matchid = $mid");
+$fragcount = small_query("SELECT SUM(frags) AS result FROM uts_match WHERE id = $mid");
+$killcount = small_query("SELECT SUM(kills) AS result FROM uts_match WHERE id = $mid");
+$deathcount = small_query("SELECT SUM(deaths) AS result FROM uts_match WHERE id = $mid");
+$suicidecount = small_query("SELECT SUM(suicides) AS result FROM uts_match WHERE id = $mid");
+
+
?>
|