Hi all,
Hopefully this is an easy one. I've set up a legend with an onclick event but would like the mouse cursor to change to "pointer" when I hover over the labels (see chart screenshot above). Currently it's hard to tell that the labels are links because the mouse cursor doesn't change when I hover over them.
Also how do I add some margin/padding between the legend and chart (space below the legend).
Many thanks!
You can achieve the desired behavior using a combination of the legend onHover config option (to change the pointer style to pointer) and the custom tooltips config option (to change the pointer style back to default).
Here is an example config demonstrating a working solution. I wasn't sure if you were using jQuery or not so I decided not to use it. Feel free to change accordingly.
options: {
legend: {
position: 'top',
labels: {
fontColor: 'rgb(255, 99, 132)'
},
onHover: function(event, legendItem) {
document.getElementById("canvas").style.cursor = 'pointer';
}
},
tooltips: {
custom: function(tooltip) {
if (!tooltip.opacity) {
document.getElementById("canvas").style.cursor = 'default';
return;
}
}
}
}
I found a different way to make this work. This lines up more literally in my mind. Perhaps the framework was updated in the interim since this was initially answered.
// This event fires anytime you mouse over the chart canvas.
onHover: function (event) {
event.target.style.cursor = 'default';
},
responsive: true,
maintainAspectRatio: false,
legend: {
display: true,
position: 'bottom',
onHover: function (event, legendItem) {
// There is only a legendItem when your mouse is positioned over one
if (legendItem) {
event.target.style.cursor = 'pointer';
}
}
}
In case anyone wants to know more, here are the docs for events and the legend.
Faster, without scanning the DOM every time, you find the target under native in the hover event
Tested in version 3.2.1 and 3.3.2 (latest on 2021 jun 22)
options: {
plugins : {
legend: {
labels: {
onHover: function (e) {
e.native.target.style.cursor = 'pointer';
},
onLeave: function (e) {
e.native.target.style.cursor = 'default';
}
}
}
}
}
The accepted answer did not work for me because my tooltips are always visible (position: "nearest"). So I use a timeout to change and revert the cursor style:
onHover: function(event, legendItem) {
document.getElementById("canvas").style.cursor = "pointer";
clearTimeout(hoverTimeout); // global var
hoverTimeout = setTimeout(function() {
document.getElementById("canvas").style.cursor = "default";
}, 100);
}
It's a dirty trick but it works.
Related
I'd like to have an introductory hint in EnjoyHint that the user can move on from by simply pressing "Next". So no arrow to an element. Is this possible?
HTML
<div class="hidden"></div>
JS
var enjoyhint_script_steps = [
{
'click .hidden': '<h2>Introduction</h2><p>This is an introductory sentence, which tells you a bit about everything.</p>',
showSkip: false,
showNext: true,
margin: 0,
onBeforeStart: function () {
document.getElementsByClassName('enjoyhint_svg_wrapper')[0].style.display = 'none';
}
},
{
onBeforeStart: function () {
document.getElmentsByClassName('enjoyhint_svg_wrapper')[0].style.display = 'block';
},
...rest of step 2...
}
...rest of steps...
];
Explanation
<div class="hidden"></div> is an empty element for EnjoyHint to target.
'click .hidden': '...description...' targets the empty element and adds a description.
showSkip: false hides the skip button.
showNext: true shows the next button.
margin: 0 hides the area highlighted by EnjoyHint.
onBeforeStart: function () {...} is used to hide the arrow in the first step and show it in the second step.
var enjoyhint_script_steps = [
{
'next .hidden': '<h2>Introduction</h2><p>This is an introductory sentence, which tells you a bit about everything.</p>',
showSkip: false,
showNext: true,
onBeforeStart: function () {
$('#enjoyhint_arrpw_line').hide();
}
},
{
...rest of step 2...
}
...rest of steps...
];
Explanation
There is a better solution then target to a hidden div, when assigning the 'click' event.
The 'click' event expects the user to click on the highlithed element in order to move on to the next step and when your element is hidden you cannot click on it.
In order to have 'Next' button by default and target the user to click on it you need to use the 'next' event.
The onBeforeStart gives you the option to run any function you want just before this specific hint starts, so you can run:
function () {
$('#enjoyhint_arrpw_line').hide();
}
Inside the onBeforeStart.
When you do it like that you can highlight any element on page without an arrow and have a mandatory 'Next' button.
You can also write it that way if it's more readable:
var enjoyhint_script_steps = [
{
event: 'next',
selector: '.hidden', // or any element you want to highlight
description: '<h2>Introduction</h2><p>This is an introductory sentence, which
tells you a bit about everything.'</p>
showSkip: false,
showNext: true, // not necessary
onBeforeStart: function () {
$('#enjoyhint_arrpw_line').hide();
}
},
{
...rest of step 2...
}
...rest of steps...
];
You can make div class="hidden" and make arrow transparent
let enjoyhint_script_steps = [
{
'click .hidden': '<h2>Hello</h2>',
arrowColor:'transparent'
}
];
I want to use the hide() function of jquery to hide messages that are flashing on a page.
When I load the page, I want to display it for 5 sec then make it disapear.
$('#flash-message').show("clip");
setTimeout(function() {
$("#flash-message").hide("clip", { direction: 'vertical' }, 1000);
}, 5000);
It doesn't do the "animation" if I use a fixed or absolute position and I need to put the message on top of the page with a fixed position.
Is there a work around for that? Thanks for your help
To call events when the page loads use:
$(document).ready(function(){
//code here
});
If you only want to use "clip" try this:
$("#flash-message").hide("clip", {direction: "vertical"}, 5000)
or else try using animate:
$('#flash-message').animate({
opacity: 0.25,
direction: "left",
}, 5000, function() {
$(this).hide();
});
Or something more simple:
$("#flash-message").click(function() {
$("#flash-message").fadeOut("slow");
});
I am trying to figure out how to dynamically change a size of ngDialog that I use for my popups. The dialog fires event when it's been opened:
$scope.$on('ngDialog.opened', function (e, $dialog) {
dialogReady($dialog);
});
I tried all of these:
function dialogReady(caseEditorWindow) {
caseEditorWindow.css({ 'width' : '1350px' });
caseEditorWindow.width(1350);
caseEditorWindow.css('width', '1350px' });
}
Nothing takes any effect.
It only gets sized if I use a class like this:
<style>
.ngdialog.dialogcaseeditor .ngdialog-content
{
width : 1350px;
height: 810px;
margin-top:-100px;
padding-top:10px;
}
</style>
at the time of creating the dialog:
ngDialog.open({
template: 'caseEditor.html',
controller: 'caseEditorController',
className: 'ngdialog-theme-default dialogcaseeditor',
closeByDocument: false,
disableAnimation: true,
scope: $scope
data: row
})
Any idea?
Thanks
var dialog = ngDialog.open(); //always return object {id: 'div attr id'};
$('#'+ dialog.id).css('width', '100px'); //You can get outer div like this
Althrough, not so good using jquery in angular controller, but it works (the only way).
I have two grids side by side.
The left grid has a list of tags the user can select, and the grid on the right is empty so the user can drag the tags he wants there.
The plugin code for both grids is:
viewConfig: {
plugins: [
Ext.create('Ext.grid.plugin.DragDrop', {
ddGroup: 'selectedTags'
})
]
}
So, as I wanted to limit the user to be able to drag only 5 tags, I've added the following code to the grid on the right:
listeners: {
beforedrop: {
fn: function() {
if (grid.getStore().data.items.length > 4) {
dropHandlers.cancelDrop();
}
},
scope: me
}
}
This is working perfectly but what I wanted is to show the NO-DROP icon when the items are dragged over the grid instead of showing the green line as if the action was allowed.
Thanks,
After looking for this solution for a while, I finally figured it out.
You must add two methods to the dropZone in the Target Grid:
notifyOver and onNodeDrop
The solution for my problem would be the code below:
Ext.create('Ext.grid.Panel', {
store: myStore,
columns: [columns],
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop',
dragText: 'Drag and drop to reorganize',
pluginId : 'dragNdrop',
dropZone:{
notifyOver:function(source, e, data){
var store = this.view.ownerCt.getStore();
return store.getCount()<5?this.dropAllowed:this.dropNotAllowed
},
onNodeDrop:function(targetNode,dragZone,e,data){
var sourceStore = dragZone.view.ownerCt.getStore(),
targetStore = this.view.ownerCt.getStore(),
isDropValid = targetStore.getCount()<5;
if(isDropValid){
sourceStore.remove(data.records[0])
targetStore.add(data.records[0]);
}
return isDropValid;
}
}
}
},
height: 200,
width: 400,
renderTo: Ext.getBody()
});
Lopes, you can use column renderer in grid where you can check the items count and display appropriate icon. Code snippet for your reference:
gridCheckboxRenderer: function(value, meta, rec, rowInd, colInd, store){
var cssPrefix = Ext.baseCSSPrefix, cls = [cssPrefix + 'grid-checkheader'];
if (condition == false) {
cls.push(cssPrefix + 'grid-checkheader-checked-disabled');
return '<div class="' + cls.join(' ') + '"> </div>';
}
return '<div class="x-grid-row-checker"> </div>';
}
Hope it helps.
I'm using google map API v3. I want to disable click action on default google landmark/poi. For example, when I zoom to UCLA, the school icon shows up (that's fine) but I don't want user to click and view details of that location. Which API function should I use?
Google has exposed an option for this. See clickableIcons of google.maps.MapOptions in the docs.
Example initialization code:
map = new google.maps.Map(document.getElementById('map'), {
clickableIcons: false
});
add this option to mapOption
clickableIcons: false
this is more options i think you will
draggable: true, // this is for disable the Draggable
disableDefaultUI: true, // this for disable Default UI
fullscreenControl: false, // this is for disable Full Screen
scrollwheel: true, // this is for disable Scroll Wheel
disableDoubleClickZoom: false, // this is for disable Double Click Zoom
draggableCursor:'crosshair',// this is for cursor type
draggingCursor:'move', // this is for dragging cursor type
minZoom: 3, // this is for min zoom for map
maxZoom: 18 , // this is for max zoom for map
//note : max, min zoom it's so important for my design.
zoom: 14, // this is to make default zoom
clickableIcons: false, // this is to disable all labels icons except your custom infowindow or Infobox.
I encountered this same problem.
Google appears to have recently changed their api to make the base map labels "clickable" and there is not yet a simple API call to disable their clickablility.
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/f1ac9ad4da3606fe
I would like to see google add a simple map option like this, but alas it doesn't exist yet
var opts = { clickableLabels:false };
var map = new maps.google.com.map(div,opts);
The following solution works, but because it relies on custom styled map tiles, free maps are limited to (2,500 maps loads per day) - See Google Maps FAQ.
function initialize() {
// For more details see
// http://code.google.com/apis/maps/documentation/javascript/styling.html
var noPOILabels = [
{
featureType: "poi",
elementType: "labels",
stylers: [ { visibility: "off" } ]
}
];
// Create a new StyledMapType object, passing it the array of styles,
// as well as the name to be displayed on the map type control.
var noPOIMapType = new google.maps.StyledMapType(noPOILabels,
{name: "NO POI"});
// Create a map object, and include the MapTypeId to add
// to the map type control.
var mapOptions = {
zoom: 11,
center: new google.maps.LatLng(55.6468, 37.581),
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'no_poi']
}
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
//Associate the styled map with the MapTypeId and set it to display.
map.mapTypes.set('no_poi', noPOIMapType);
map.setMapTypeId('no_poi');
}
This issue has been logged with google at:
http://code.google.com/p/gmaps-api-issues/issues/detail?id=3866
Please star and comment your needs on this issue there.
I understand that the OP wants a solution that persists the labels/icons but suspends the click events. I'm not sure this is possible; please star this issue
However, some of us are drawing shapes sans Drawing Manager and labels/icons are obstructing the additions of new points. If it meets your requirements, you can temporarily remove the icons/labels. I've found that transit, poi, and landscape all need to be toggled:
var map = new google.maps.Map(document.getElementById("map"), {});
map.poi = function(state){
var styles = [
{
"featureType": "transit",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "landscape",
"stylers": [
{ "visibility": "off" }
]
}
];
this.set("styles", (state)? {} : styles );
}
And the usage:
//turn the labels/icons off
map.poi(false);
//turn them back on
map.poi(true);
I understand that this question is old, but maybe this answer will help others:
I'm not sure if this is legal, but I ended up exploring the code and made this:
$("#google-map").on("mousedown",function(){
setTimeout(function(){
disableInfoWindows();
},500);
});
function disableInfoWindows()
{
$(".gm-iw.gm-sm").parent().parent().remove();
$("[style='position: absolute; left: -2px; top: -336px; width: 59px; height: 492px; -webkit-user-select: none; border: 0px; padding: 0px; margin: 0px;']")
.parent()
.parent()
.remove();
}
It worked for me, no infoWindow showing up, while preserving all the icons. Anyone who has an idea enhancing the code is welcome, the infoWindow is showing up just a bit the first time it is about to open, after that first one, it is completely gone.
Yeah, the other solutions work but you can also want to have ability to hide/disable only part of that pins or disable ability to go to details from popups, please see my post here with some tips how you can do that CLICK
Right, to sum up, if you want to "remove" popups, you can just use:
clickableIcons: false
for map options object. But if you want to have a popup, but without "View on Google Maps" label, you can use a hacky CSS trick:
google-map {
.view-link {
display: none !important;
}
}
That was my requirements, and it works!
If you want to define which icons/pins (elements or labels, however you call it) should be visible, you can use this site to generate proper JSON with map settings: https://mapstyle.withgoogle.com/