javascript highchart照片幻灯片 [英] javascript highchart photo slide
问题描述
我使用javascript库highchart创建一个可视化图表。 Ive用一些假数据创建了我的图表。我想知道如何使用图表数据触发图像幻灯片。因此,如果我将鼠标悬停在图表中某个点的数据上,相应的图像将水平滑动到页面中心。这里是我的一些JavaScript代码到目前为止。
I'm creating a visual chart using the javascript library highchart. Ive created my chart with some fake data. I want to know how to use the chart data to trigger an image slide. So if i hover on the data on a certain point in the chart, a corresponding image will slide horizontally to the center of the page. Here is some of my javascript code so far.
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="width:100%; height:400px;"></div>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
title: {
text: 'Dive Log',
x: -20 //center
},
subtitle: {
text: 'example',
x: -20
},
xAxis: {
title: {
text: 'Time',
categories: ['5', '10', '15', '20', '25', '30',
'35', '40', '45', '50', '55', '1 hr']
}
},
yAxis: {
title: {
text: 'Depth in Meters'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '°C'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [ {
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}],
});
});
</script>
推荐答案
您可以使用events.mouseOver和events .MouseOut在您的系列点上:
http:// api。 highcharts.com/highcharts#plotOptions.series.point.events.mouseOver
http://api.highcharts.com/highcharts#plotOptions.series.point.events.mouseOut
You can do it by using events.mouseOver and events.MouseOut on your series points: http://api.highcharts.com/highcharts#plotOptions.series.point.events.mouseOver http://api.highcharts.com/highcharts#plotOptions.series.point.events.mouseOut
在其回呼函式中您可以触发幻灯片到您的图片:
Inside its callback function you can trigger 'slide' to your image:
events: {
mouseOver: function () {
$(".img1").trigger("slideIn");
},
mouseOut: function () {
$(".img1").trigger("slideOut");
},
}
选项,例如:
$('.img1').on("slideIn", function () {
$(this).animate({
opacity: 1,
left: 155
});
});
$('.img1').on("slideOut", function () {
$(this).animate({
opacity: 0,
left: -550
});
});
例如:
http://jsfiddle.net/izothep/gf48mmfa/4/
这篇关于javascript highchart照片幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!