tooltip on the pie working. Now only on the query results chart.
This commit is contained in:
62
js/pMap.js
62
js/pMap.js
@@ -24,7 +24,7 @@
|
|||||||
var pMap_ImageID = "";
|
var pMap_ImageID = "";
|
||||||
var pMap_MouseX = 0;
|
var pMap_MouseX = 0;
|
||||||
var pMap_MouseY = 0;
|
var pMap_MouseY = 0;
|
||||||
var pMap_CurrentMap = -1;
|
var pMap_CurrentKey = -1;
|
||||||
var pMap_URL = "";
|
var pMap_URL = "";
|
||||||
var pMap_Tries = 0;
|
var pMap_Tries = 0;
|
||||||
var pMap_MaxTries = 5;
|
var pMap_MaxTries = 5;
|
||||||
@@ -49,22 +49,58 @@
|
|||||||
pMap_MouseX -= document.getElementById(pMap_ImageID).offsetLeft;
|
pMap_MouseX -= document.getElementById(pMap_ImageID).offsetLeft;
|
||||||
pMap_MouseY -= document.getElementById(pMap_ImageID).offsetTop;
|
pMap_MouseY -= document.getElementById(pMap_ImageID).offsetTop;
|
||||||
|
|
||||||
/* Check if we are flying over a map zone */
|
/* Check if we are flying over a map zone
|
||||||
|
* Lets use the following method to check if a given
|
||||||
|
* point is in any convex polygon.
|
||||||
|
* http://www.programmingforums.org/post168124-3.html
|
||||||
|
*/
|
||||||
Found = false;
|
Found = false;
|
||||||
for (Map in pMap_ImageMap)
|
for (Key in pMap_ImageMap)
|
||||||
{
|
{
|
||||||
Values = pMap_ImageMap[Map].split(",");
|
Values = Key.split("--");
|
||||||
if ( pMap_MouseX>=Values[0] && pMap_MouseX<=Values[2])
|
SeriesName = Values[0];
|
||||||
|
SeriesValue = Values[1];
|
||||||
|
SignSum = 0;
|
||||||
|
for (i = 0; i <= pMap_ImageMap[Key].length - 1; i++)
|
||||||
{
|
{
|
||||||
if ( pMap_MouseY>=Values[1] && pMap_MouseY<=Values[3] )
|
if (i == pMap_ImageMap[Key].length - 1)
|
||||||
{
|
{
|
||||||
Found = true;
|
index1 = i;
|
||||||
if ( pMap_CurrentMap != Map )
|
index2 = 0;
|
||||||
{ overlib(Values[5], CAPTION, Values[4], WIDTH, 80); pMap_CurrentMap = Map; }
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
index1 = i;
|
||||||
|
index2 = i+1;
|
||||||
|
}
|
||||||
|
result = getDeterminant(
|
||||||
|
pMap_ImageMap[Key][index1][0],
|
||||||
|
pMap_ImageMap[Key][index1][1],
|
||||||
|
pMap_ImageMap[Key][index2][0],
|
||||||
|
pMap_ImageMap[Key][index2][1],
|
||||||
|
pMap_MouseX,
|
||||||
|
pMap_MouseY
|
||||||
|
);
|
||||||
|
if (result > 0) { SignSum += 1; } else { SignSum += -1; }
|
||||||
|
}
|
||||||
|
//console.log(Key+": "+SignSum);
|
||||||
|
if (Math.abs(SignSum) == pMap_ImageMap[Key].length)
|
||||||
|
{
|
||||||
|
Found = true;
|
||||||
|
if ( pMap_CurrentKey != Key )
|
||||||
|
{ overlib(SeriesValue, CAPTION, SeriesName, WIDTH, 80); pMap_CurrentKey = Key; }
|
||||||
}
|
}
|
||||||
if ( !Found && pMap_CurrentMap != -1 ) { nd(); pMap_CurrentMap = -1; }
|
|
||||||
}
|
}
|
||||||
|
if ( !Found && pMap_CurrentKey != -1 ) { nd(); pMap_CurrentKey = -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadImageMap(ID, map) { pMap_ImageID = ID, pMap_ImageMap = map.split("-"); }
|
function getDeterminant(X1, Y1, X2, Y2, X3, Y3)
|
||||||
|
{
|
||||||
|
return (X2*Y3 - X3*Y2) - (X1*Y3 - X3*Y1) + (X1*Y2 - X2*Y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function LoadImageMap(ID, map)
|
||||||
|
{
|
||||||
|
pMap_ImageID = ID;
|
||||||
|
pMap_ImageMap = JSON.parse(map);
|
||||||
|
}
|
||||||
|
@@ -2748,6 +2748,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add points to Image Map.
|
||||||
|
* The center point abd the first, middle and last of the arc is taken.
|
||||||
|
*/
|
||||||
|
foreach ($TopPlots as $key => $PointArr)
|
||||||
|
{
|
||||||
|
// last point of the arc
|
||||||
|
$this->addPointToImageMap($PointArr[count($PointArr)-4],$PointArr[count($PointArr)-3],$Data[$key][$DataDescription['Values'][1]],$Data[$key][$DataDescription['Values'][0]],"Pie");
|
||||||
|
|
||||||
|
// the point at the middle
|
||||||
|
$this->addPointToImageMap($PointArr[0],$PointArr[1],$Data[$key][$DataDescription['Values'][1]],$Data[$key][$DataDescription['Values'][0]],"Pie");
|
||||||
|
|
||||||
|
// firs point in the arc
|
||||||
|
$this->addPointToImageMap($PointArr[2],$PointArr[3],$Data[$key][$DataDescription['Values'][1]],$Data[$key][$DataDescription['Values'][0]],"Pie");
|
||||||
|
|
||||||
|
// point in the middle of the arc
|
||||||
|
$middle = count($PointArr)/2;
|
||||||
|
$this->addPointToImageMap($PointArr[$middle + ($middle % 2)],$PointArr[$middle + ($middle % 2)+1],$Data[$key][$DataDescription['Values'][1]],$Data[$key][$DataDescription['Values'][0]],"Pie");
|
||||||
|
}
|
||||||
|
|
||||||
/* Draw Top polygons */
|
/* Draw Top polygons */
|
||||||
for($Key=count($iValues)-1;$Key>=0;$Key--)
|
for($Key=count($iValues)-1;$Key>=0;$Key--)
|
||||||
{
|
{
|
||||||
@@ -3371,9 +3390,17 @@
|
|||||||
/* Add a box into the image map */
|
/* Add a box into the image map */
|
||||||
function addToImageMap($X1,$Y1,$X2,$Y2,$SerieName,$Value,$CallerFunction)
|
function addToImageMap($X1,$Y1,$X2,$Y2,$SerieName,$Value,$CallerFunction)
|
||||||
{
|
{
|
||||||
if ( $this->MapFunction == NULL || $this->MapFunction == $CallerFunction )
|
$this->addPointToImageMap($X1,$Y1,$SerieName,$Value,$CallerFunction);
|
||||||
|
$this->addPointToImageMap($X2,$Y1,$SerieName,$Value,$CallerFunction);
|
||||||
|
$this->addPointToImageMap($X2,$Y2,$SerieName,$Value,$CallerFunction);
|
||||||
|
$this->addPointToImageMap($X1,$Y2,$SerieName,$Value,$CallerFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPointToImageMap($X1,$Y1,$SerieName,$Value,$CallerFunction)
|
||||||
|
{
|
||||||
|
if ( $this->MapFunction == NULL || $this->MapFunction == $CallerFunction)
|
||||||
{
|
{
|
||||||
$this->ImageMap[] = round($X1).",".round($Y1).",".round($X2).",".round($Y2).",".$SerieName.",".$Value;
|
$this->ImageMap["$SerieName--$Value"][] = array(round($X1), round($Y1));
|
||||||
$this->MapFunction = $CallerFunction;
|
$this->MapFunction = $CallerFunction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -137,7 +137,7 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
$returnData = '<img id="chart" src="data:image/png;base64,'.$this->imageEncoded.'" OnMouseMove="getMousePosition(event);" OnMouseOut="nd();"/>';
|
$returnData = '<img id="chart" src="data:image/png;base64,'.$this->imageEncoded.'" OnMouseMove="getMousePosition(event);" OnMouseOut="nd();"/>';
|
||||||
$returnData .= '
|
$returnData .= '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
LoadImageMap("chart", "'.implode("-", $this->getImageMap()).'");
|
LoadImageMap("chart", \''.json_encode($this->getImageMap()).'\');
|
||||||
</script>
|
</script>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user