I have the following barchart for which I'm trying to turn the hover tooltip off:
= bar_chart [["", current_admin.company.progress_to_target_this_month]], colors: [current_admin.company.progress_bar_colour]
From their homepage, I can make an initializer file which I've done:
config/initializers/chartkick.rb
Chartkick.options = {
height: '300px',
colors: ['#b00', '#666'],
discrete: true,
library: {
pointSize: 0,
vAxis: {
points: false,
legend: false,
discrete: true
},
hAxis: {
points: false,
legend: false,
discrete: true,
textPosition: 'none'
},
tooltips: {
enabled: false
}
},
options: {
tooltips: {
enabled: false
}
},
tooltips: {
enabled: false
}
}
The options regarding vaxis and haxis all work, however I can't get anything to do with tooltips working. I've tried every variety of inserting tooltips: { enabled: false } that I can think of with no joy.
If anyone has any advise it would be greatly appreciated
As of summer 2017 custom tooltips are not supported in chartkick.js. There are two open issues about this on the GitHub repository:
Add support for custom tooltips #86
Piechart with chart.js custom tooltips #85
If you don't need any other pointer-events for the chart, then you can just set pointer-events: none for the div, which contains the chart.
Related
I have a pretty busy chart that I need to clean up the overlapping datalabels on. I have tried all of the Highcharts options and previous forum answers I can find without much success. Here is my code on JSfiddle:
http://jsfiddle.net/cs4djfut/4/
plotOptions: {
column: { dataLabels: { allowOverlap: true, crop: false, overflow: 'none', enabled: true, formatter: function () { return this.series.name; } }, } },
Tried a function to change the datalabel position but it only worked on the fist datalabel.
this may seem a noob's question but when I try to use setExtremes or showResetZoom on my xAxis, I get this in the console:
Uncaught TypeError: copt.xAxis.setExtremes is not a function
However my xAxis is correctly defined and works perfectly on plenty of other functions. I've copy-pasted code from several jsfiddler examples, but no way...
Here is my code:
Abs_ChartOptions= {
chart: {
zoomType: 'xy',
resetZoomButton: {
position: {
verticalAlign: 'top',
y: -50
},
}
},
title: { text: ''},
xAxis:{
type: 'datetime',
labels: { format: '{value: %d/%m/%Y}'},
tickInterval: 24*36e5, //24h
title:{ text: 'Date'},
crosshair: true,
},
yAxis: [{
title: { text: ''},
alternateGridColor: '#FDFFD5',
crosshair: true
}],
series: []
}
And on call site, after defining the series and the xMin/xMax values(which are correctly set on their way):
copt= clone(Abs_ChartOptions);
copt.xAxis.setExtremes(xMin,xMax);
copt.showResetZoom();
I've tried using directly Abs_ChartOptions instead of a clone, same issue.
NB: Using copt.xAxis.min= xMin; copt.xAxis.max= xMax; works fine for zooming, but I don't get the "reset zoom" buttton.
What did I miss? Is there some extra module needed or whatever ?
Thx in advance
You need to call both methods on a chart instance, not on the options configuration object.
const Abs_ChartOptions = {
...
};
const chart = Highcharts.chart('container', Abs_ChartOptions);
chart.xAxis[0].setExtremes(1, 3);
chart.showResetZoom();
Live demo: http://jsfiddle.net/BlackLabel/e81nj64v/
API Reference: https://api.highcharts.com/class-reference/Highcharts.Chart
I can get rid of all animations with this
plotOptions: {
series: {
enableMouseTracking: true
But I want tooltips. But I don't want any other mouseover effects. I tried this suggestion:
plotOptions: {
series: {
allowPointSelect: false,
states: {
hover: {
enabled: false
},
inactive: {
enabled: false
},
select: {
enabled: false
}
}
}
},
But it has no effect on animations. My series are still faded if I mouseover an area with null data.
To sum up:
when styledmode is turn on, and you loading default CSS file, you need to add following code to the CSS:
inactive { opacity: 1 }
when styledmode is disabled (by default), you don't need to add the default CSS file, but to achieve that use options provided by API:
plotOptions: {
series: {
states: {
hover: {
enabled: false
},
inactive: {
enabled: false
}
}
}
}
here's the demo : online demo
the datalabel is too long to display , i want it just inside the bubble and the overflowed text displayed as "ACDE..."
I can suggest two solutions for this case.
set the overflow to ellipsis and set some width for the dataLabel:
Demo: https://jsfiddle.net/BlackLabel/ye5s7m6g/1/
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: "{point.name}",
style: {
textOverflow: 'ellipsis',
width: 45
}
}
}
},
API: https://api.highcharts.com/highcharts/series.bubble.dataLabels.style
enable textPath feature in the dataLabels:
Demo: https://jsfiddle.net/BlackLabel/0srgnvxd/1/
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: "{point.name}",
textPath: {
enabled: true
}
}
}
},
API: https://api.highcharts.com/highcharts/series.bubble.dataLabels.textPath.enabled
I need to disable the hover attribute of legend items because I am using Highcharts on mobile platforms. Sadly, making a legendItemClick event does not solve the problem as hovering still occurs.
I was encouraged to see that this issue came up on the old support site for highcharts back in 2011. The thread can be found here. I was particularly glad to see the last jfiddle example and the function declared in it.
Unfortunately, the only thing that worked for me was the workaround of changing the setHoverStyle to null. This isn't great though since the hover action still fires and makes navigating the legend and chart unresponsive. The rest of the suggestions in the above thread resulted in the chart not being rendered.
Granted, it might be because I had a difficult time translating the example to my purposes - honestly, I do not know where to call the function and everywhere I have tried has failed. My JavaScript file is set up along the lines of
var chartDefinition = {
chart: {
renderTo: 'chart_content',
type: 'column'
},
colors: [
'#619ED6',
'#6BA547',
'#F7D027',
'#E48F1B',
'#B77EA3',
'#E64345',
'#60CEED',
'#9CF168',
'#F7EA4A',
'#FBC543',
'#FFC9ED',
'#E6696E'
],
title: {
text: ''
},
...
column: {
shadow: false,
borderWidth: 1,
events: {
click: function() { return false; },
legendItemClick: function() { return false; }
},
dataLabels: {
enabled: false,
color: '#222',
style: {
fontFamily: 'sans-serif',
fontSize: '13px',
fontWeight: 'bold'
}
}
}
},
series: []
};
Listing and setting the various highcharts attributes.
Does anyone know how to disable this hover attribute or where the proper place would be to call the function?
There are a few solutions to implement this. There's no built-in option to change that (as of 06.2022).
Try to disable mouseover for legendGroup, not legendItem.
Demo: http://jsfiddle.net/Cp7xh/10/
Disable pointer-events in CSS:
.highcharts-legend {
pointer-events: none;
}
Demo: http://jsfiddle.net/BlackLabel/ebrodhk4/
A plugin that prevents Highcharts Core from adding events:
Plugin:
(function(H) {
H.wrap(
H.Legend.prototype,
'init',
function(proceed, chart, options) {
if (options.enableMouseTracking === false) {
this.setItemEvents = false;
}
proceed.apply(this, [chart, options]);
}
);
})(Highcharts);
Usage:
legend: {
enableMouseTracking: false,
itemStyle: {
cursor: 'auto'
}
},
Demo: https://jsfiddle.net/BlackLabel/ogqv2sya/