I think I have a working solution for this. Chris, hopefully you can
help out and consider adding this to future builds.
I am pretty sure the getNeighborPoint function in the jqplot core is
the crucial function that basically defines whether or not your mouse
is close enough to a "neighboring" data point to justify showing /
hiding the highlighter tooltip.
That function basically compares your cursors x and y positions to
every point's x and y positions and then if your cursor is within some
"threshold," the neighbor object is populated and returned from that
funciton. So, if you just modify how the comparison is done for bar
charts, the neighboring point can be returned when your cursor is
further down / over on the bar's body.
The original getNeighborPoint function is...
function getNeighborPoint(plot, x, y) {
var ret = null;
var s, i, d0, d, j, r, k;
var threshold, t;
for (var k=plot.seriesStack.length-1; k>-1; k--) {
i = plot.seriesStack[k];
s = plot.series[i];
r = s.renderer;
if (s.show) {
t = s.markerRenderer.size/2+s.neighborThreshold;
threshold = (t > 0) ? t : 0;
for (var j=0; j<s.gridData.length; j++) {
p = s.gridData[j];
// neighbor looks different to OHLC chart.
if (r.constructor == $.jqplot.OHLCRenderer) {
if (r.candleStick) {
var yp = s._yaxis.series_u2p;
if (x >= p[0]-r._bodyWidth/2 && x <=
p[0]+r._bodyWidth/2 && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3]))
{
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
// if an open hi low close chart
else if (!r.hlc){
var yp = s._yaxis.series_u2p;
if (x >= p[0]-r._tickLength && x <=
p[0]+r._tickLength && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3]))
{
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
// a hi low close chart
else {
var yp = s._yaxis.series_u2p;
if (x >= p[0]-r._tickLength && x <=
p[0]+r._tickLength && y >= yp(s.data[j][1]) && y <= yp(s.data[j][2]))
{
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
}
else {
d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) *
(y-
p[1]) );
if (d <= threshold && (d <= d0 || d0 == null)) {
d0 = d;
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
}
}
}
return ret;
}
I modified the function to first check that the series is actually
being rendered as a bar, then, if it is, depending on whether it is a
vertical bar or horizontal, I allow for the neighbor object to be
returned if the cursor is over the entire bar instead of just the
apex. Here is the function with my changes.
function getNeighborPoint(plot, x, y) {
var ret = null;
var s, i, d0, d, j, r, k;
var threshold, t;
for (var k=plot.seriesStack.length-1; k>-1; k--) {
i = plot.seriesStack[k];
s = plot.series[i];
r = s.renderer;
if (s.show) {
t = s.markerRenderer.size/2+s.neighborThreshold;
threshold = (t > 0) ? t : 0;
for (var j=0; j<s.gridData.length; j++) {
p = s.gridData[j];
// neighbor looks different to OHLC chart.
if (r.constructor == $.jqplot.OHLCRenderer) {
if (r.candleStick) {
var yp = s._yaxis.series_u2p;
if (x >= p[0]-r._bodyWidth/2 && x <=
p[0]+r._bodyWidth/2 && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3]))
{
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
// if an open hi low close chart
else if (!r.hlc){
var yp = s._yaxis.series_u2p;
if (x >= p[0]-r._tickLength && x <=
p[0]+r._tickLength && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3]))
{
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
// a hi low close chart
else {
var yp = s._yaxis.series_u2p;
if (x >= p[0]-r._tickLength && x <=
p[0]+r._tickLength && y >= yp(s.data[j][1]) && y <= yp(s.data[j][2]))
{
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
}
else {
d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) *
(y-
p[1]) );
// check if this is a bar chart and what kind
(i.e., vertical / horizontal)
// if a bar chart, redefine the distance variable
to such that mousing over the entire bar will return the neighbor
object
if (r.constructor == $.jqplot.BarRenderer) {
if (s.barDirection == 'vertical') {
if ((p[1]+threshold) <= y) {
d = Math.abs( x-p[0] );
}
} else {
if ((p[0]+threshold) <= x) {
d = Math.abs( y-p[1] );
}
}
}
if (d <= threshold && (d <= d0 || d0 == null)) {
d0 = d;
return {seriesIndex: i, pointIndex:j,
gridData:p, data:s.data[j]};
}
}
}
}
}
return ret;
}
On Apr 27, 7:59 am, "
trull...@googlemail.com"