In the code below I have a pointFormatterfor a tooltip. What I'd like to do is to, for some points, completely hide the tooltip. I have tried returning null or false in these cases, however, an empty tooltip still appears. Is it possible to completely hide a tooltip when using pointFormatter? I've seen that with other formatters it is posisblet return null or false but this doesn't seem to be the case here.
tooltip: {
useHTML: true,
borderWidth: 0,
backgroundColor: "rgba(37,37,37,0.95)",
style: {
padding: 10
},
headerFormat: "",
pointFormatter: function () {
if(this.hrr_num === 16){
return null;
}
return self.getToolTip(parseInt(this.hrr_num));
},
followPointer: false,
shadow: false,
shape: "square",
hideDelay: 0
}
There are several *formatter Functions in the Tooltip Object. The one you are looking for is just called formatter. If you return false in this function then the tooltip will not be displayed at all. This should do the trick:
tooltip: {
[...]
formatter: function () {
if (this.point.hr_num === 16) {
return false;
}
return self.getToolTip(parseInt(this.point.hr_num));
},
[...]
}
Related
I want to disable all action when clicking a legend item.
So far i managed to disable the column hide/appear animation by doing this
events: {
legendItemClick: function(){return false}
}
or in Android:
events = HIEvents().apply {
legendItemClick = HIFunction("function() { return false; }")
}
but now when i click on of the legends items it just gets highlighted while the others go into the background like this
You need to disable inactive and hover states:
series: [{
...,
states: {
inactive: {
enabled: false
},
hover: {
enabled: false
}
}
}]
Live demo: http://jsfiddle.net/BlackLabel/7s1bkw8v/
API Reference: https://api.highcharts.com/highcharts/series.pie.states
I am using react and chart.js.
I have a Line chart, and I would love to have a highlight on one of the series when the mouse is hovering the according legend.
I found some help but it looks like the code is only working for previous version of chart.js.
Here is the current code I am using, that doesn't work for what I want :
<Line
data={data}
options={{maintainAspectRatio: false,
responsive: true,
interaction: {
mode: "index",
intersect: true,
},
plugins: {
tooltips: {
mode: "nearest",
intersect: false,
},
hover:
{
mode: "nearest",
intersect: true,
},
datalabels: {
display: false,
color: "black",
},
title: {
display: true,
text: "Limit"
},
legend: {
onHover: function(event, legendItem, legend) {
console.log('allo')
var me = this;
var options = me.options || {};
var hoverOptions = options.hover || {mode: 'nearest'};
var index = legendItem.datasetIndex;
var ci = legend.chart;
for (var i=0; i < ci.$datalabels._datasets.length-1; i++) {
var elements = ci.getDatasetMeta(i).data; ci.updateHoverStyle(elements, hoverOptions.mode, false) ; // <<<--- turn off higlight
}
var elements = ci.getDatasetMeta(index).data;
ci.updateHoverStyle(elements, hoverOptions.mode, true) // <<-- Turn on
ci.render();
},
display: true,
position: "right",
}
},
}}
/>
Goal would be to have something like that :
The JSFiddle will clearly allow you to understand the problem.
I want the endpoints to be binded to the elements inside each container which are draggable but only the endpoints drawn first are correct. The second time the draw function is called, the positions are incorrect and the dragging is not synced.
I have a guess that the problem lie with the CSS position but I can't find it.
jsPlumb.ready(function() {
$(".scroll-box").draggable({
drag: function() {
jsPlumb.repaintEverything();
//jsPlumb.repaint($(this));
}
});
// jsPlumb.draggable($(".scroll-box"));
drawEndPoints("in-leaf", "Right");
drawEndPoints("out-leaf", "Left");
});
function drawEndPoints(classname, endpointposition) {
var endpointOptions = {
isSource: true,
isTarget: true,
endpoint: ["Dot", {
radius: 10
}],
style: {
fillStyle: 'blue'
},
maxConnections: -1,
connector: "Straight",
connectorStyle: {
lineWidth: 2,
strokeStyle: 'black'
},
scope: "blackline",
dropOptions: {
drop: function(e, ui) {
alert('drop!');
}
}
};
jsPlumb.addEndpoint($("." + classname), {
anchor: endpointposition
}, endpointOptions);
//jsPlumb.repaintEverything();
}
You are missing the jsPlumb.setContainer($("body"));
https://jsfiddle.net/mkaran/mLthybzo/
https://jsplumbtoolkit.com/community/doc/home
EDIT: a fiddle with your example https://jsfiddle.net/mkaran/aof6mq34/
I've been using jVectorMap quite successfully-- it's a wonderful package for displaying interactive maps!
In this case, I only want some regions to be selectable, and there doesn't seem to be an option to set regions active/inactive. So instead, I set "regionsSelectable=false", and then set "selectedRegions" to the ones I want active.
This works fine (showing the correct hover attributes, etc. for "active" regions only)-- with one exception, in iOS. There, it takes two "clicks" (touches) for the "onRegionClick" handler to get invoked. On the first click, the "selectedHover" attributes are set correctly, but "handleRegion" never gets called. A second click, and "handleRegion" is called.
Initialization code looks like:
map = new jvm.WorldMap({
container: $('#mapdiv'),
map: 'world_mill_en',
regionsSelectable: false,
regionStyle: {
initial: { fill: '#0086d0' },
hover: { "fill-opacity": 1.0 },
selected: { fill: '#003a6a' },
selectedHover: { fill: '#ff7a00' }
},
onRegionClick: handleRegion,
selectedRegions:["CN","RU","US"],
...
});
function handleRegion(e,cc) {
alert("cc="+cc);
...
}
What is needed is either a way to "activate" only a few regions, or a way around this two-click problem.
I know this is a bit outdated question, but here is a hack around iOS issue for others like me who bumped to this question while searching for some hack around this.
As you already noted, iPad/iPhone are emulating hover with first "tap" .. and click with second "tap".
So to fix this ackward behavior we will do following (example on fiddle)
var lastCode = "";
var iOS = /(iPad|iPhone|iPod)/g.test( navigator.userAgent );
$('#world-map').vectorMap({
map: 'world_mill_en',
backgroundColor: 'green',
normalizeFunction: 'polynomial',
regionsSelectable: true,
regionsSelectableOne: true,
zoomOnScroll: true,
zoomButtons: true,
regionStyle: {
initial: {
fill: "white",
"fill-opacity": 1,
stroke: "none",
"stroke-width": 0,
"stroke-opacity": 1
},
hover: {
fill: "white",
"fill-opacity": 1
},
selected: {
fill: "#EC6602",
"fill-opacity": 1
},
selectedHover: {
fill: "#EC6602",
"fill-opacity": 1
}
},
onRegionClick: function(e, country){
if (lastCode && lastCode == country) {
e.preventDefault();
return;
}
var map = $("#world-map").vectorMap("get", "mapObject");
$("#world-map").vectorMap("set", "focus", country);
map.setScale(2);
if(country=="US" || country=="RU") {
map.setScale(1);
}
lastCode = country;
},
onRegionLabelShow: function (e, el, country) {
if (iOS) {
e.preventDefault();
var map = $("#world-map").vectorMap("get", "mapObject");
if (lastCode) {
map.regions[lastCode].element.setSelected(false);
}
map.regions[country].element.setSelected(true);
$("#world-map").vectorMap("set", "focus", country);
map.setScale(2);
if(country=="US" || country=="RU") {
map.setScale(1);
}
lastCode = country;
}
},
markers: [{
latLng: [37.7833, -122.4167],
name: 'San Francisco'
}]
});
In short words, we are overwriting onRegionLabelShow functionality with custom behavior (only for the iOS devices). Basically we are preventing the tooltip from showing and instead of that we are selecting the hovered (tapped) ccountry, focusing it and storing it's code in global variable.
On second tap we are detecting if the country has changed by comparing current code with last value and in that case un-selecting previously selected country and selecting new one.
It should be fairly easy to adapt the resolution to your needs.
actually, you should check onRegionTipShow:
...
handleIOSClick = function (e, el, code) {
if (istouch) {
var mapObject = $(map).vectorMap('get', 'mapObject');
map.regions[code].element.setSelected(true);
e.preventDefault();
}
},
CreateMap = function () {
if (typeof $(map) !== 'undefined'){
$(map).width(700);
$(map).height(400);
mapObject = $(map).vectorMap({
map: 'us_lcc_en',
onRegionClick: regionClicked,
onRegionTipShow: handleIOSClick,
backgroundColor: "inherit",
regionStyle: {
initial: {
fill: '#477294'
}
}
});
}
},
...
I'm using qtip ( http://craigsworks.com/projects/qtip/ ) to make tooltips. Now I need to show tooltips when the button is pressed and hide tooltips for example when 3 seconds have passed. My current code is not working, tooltips will sometimes go away and sometimes stay...
var self = $("#email");
self.qtip({
content: error,
tip: true,
position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle' } },
style: 'error',
show: { when: false, ready: true },
hide: { when: { event: 'mousemove' }, delay: 2000, effect: function () { self.qtip("destroy"); } }
});
#newbie, but a response, is to tidy the code and that maybe that's the problem. eg replacing the name of the variable "self" by "this".
$("#email").qtip( {
content: error,
tip: true,
position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle' } },
style: 'error',
show: { when: false, ready: true },
hide: { when: { event: 'mousemove' },
delay: 2000,
effect: function() { $(this).qtip("destroy"); }
}
});