javascript highchart image carousel

I am currently working on a visual chart project using the JavaScript library highchart. After setting up my chart with some dummy data, I am looking to incorporate functionality that allows for triggering an image slide based on the chart data. Specifically, when hovering over a certain point in the chart, I want a corresponding image to smoothly slide horizontally towards the center of the page. Below is a snippet of the JavaScript code I have written 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>   

Answer №1

To achieve this effect, you can utilize the events.mouseOver and events.mouseOut functions on your series points in Highcharts. By adding these event listeners to your code, you can trigger animations for your images when the user interacts with the chart:

events: {
    mouseOver: function () {
        $(".img1").trigger("slideIn");
    },
    mouseOut: function () {
        $(".img1").trigger("slideOut");
    },
}

In your jQuery script, you can then define the actions to take place when these triggers are activated. For example:

$('.img1').on("slideIn", function () {
    $(this).animate({
        opacity: 1,
        left: 155
    });
});

$('.img1').on("slideOut", function () {
    $(this).animate({
        opacity: 0,
        left: -550
    });
});

For a visual demonstration of how this works, you can view an example implementation here: http://jsfiddle.net/username/examplelink123/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring properties of nested elements in React

Picture a scenario where a specific element returns: <Component1> <Component2 name="It's my name"/> </Component1> Now, what I want to accomplish is something like this: <Component1 some_property={getComponent2'sN ...

Prevent automatic scrolling by clicking when you reach the bottom

In order to replicate the issue I am experiencing, please click on the down button four times, and then click on the up button. You will observe that you need to click the up button one extra time for it to function properly. How can I detect when it has r ...

Elements displaying outside of block 'a' tag

I have a set of <a> elements that are styled with display:block. These contain various nested <divs>, for example: <a href="#" class="sliderframe"> <div class="container-caption"> <div class="slider ...

What steps should I take to create a plugin for a library if defining it as a peerDependency does not provide a specific implementation for me to work with?

Requirements for My Plugin: I'm currently in the process of developing a new plugin that is dependent on popularLibrary.js. Here are the key points about my plugin: It will not function properly if popularLibrary.js is missing. It is designed to wo ...

Using Ionic framework alongside Ionic View to display a beautiful background image

How can I display a full background image in Ionic 1.2? -hooks -platfroms -plugins -resources -scss -www -css -img -js -lib -templates ... Currently, I have the following HTML structure: <ion-view id="login" hide-nav-bar="true"> ...

What steps are needed to design a search bar similar to Zomato's?

I am looking to create a search bar that resembles the one on . I have managed to make a floating search box on top of my background image. However, I am unsure how to align various input fields and buttons side by side. Below is the current CSS code I am ...

Use Puppeteer and Node.js to repeatedly click a button until it is no longer present, then initiate the next step

Imagine a dynamic web page filled with rows of constantly updated data. The number of rows on the page remains fixed, meaning old rows are replaced and not stored anywhere. To navigate through this page, you need to click on a "load more" button that app ...

Altering the height of cells in a table for HTML emails being sent to Gmail accounts

When attempting to send an HTML email from Outlook 2013 to Gmail, I have encountered a significant gap between the rows. Despite my efforts, I have been unable to adjust the row height. I am seeking advice on how to resolve this issue. Here is the code s ...

jQuery UI Datepicker extending beyond its bounds

My Datepicker is expanding and filling the entire screen. What could be causing this issue? Here is my code: Additionally, how can I change the date format in jQuery to appear as dd-mm-yyyy? https://i.stack.imgur.com/IQzVV.png HTML: <!DOCTYPE html&g ...

Activate the Click in the Span Element with no Matching ID to the Final Segment of the URL

I'm facing an issue with triggering the click event on a specific span that lacks an id attribute. This particular span has an empty ID and doesn't respond when I try to click the back or forward buttons in the browser. All other spans trigger th ...

How does assigning a checkbox's value as 'undefined' result in the addition of ng-invalid?

I'm facing an issue with a checkbox in my Angular project. The checkbox has a false value of undefined, and even though it's not marked as required, the form doesn't validate when I check and uncheck it. This is because the class ng-invalid ...

Unable to load dynamic data in Angular 2 smart table

Currently, I am utilizing Angular 6 along with smart table by visiting this link: . Everything was functioning smoothly, until the moment I attempted to switch from static to dynamic data: The following code works perfectly and displays all the content ...

Performing an AJAX call using jQuery within a PhoneGap application to communicate with a Node JS server

I've searched everywhere online for a practical demonstration of a jQuery AJAX call to a Node JS server, but to no avail. Typically, a jQuery AJAX request to a PHP server follows this format: $("button").click(function() { $.ajax({url: "http://w ...

Add an event listener to a dynamically created div block through jQuery when it is clicked

When the page loads, a dynamic div appears that is visible to the user and in Firebug, but is not available in the page source. The content within this div changes dynamically. I am attempting to bind a click event to this div so that when a user clicks o ...

jQuery fails to fetch information

I am currently working with a straightforward script as shown below: $(function() { var url = theme_directory + '/func/api.php'; $.get( url, function(data) { alert("Data Loaded: " + data); }); }); Here is the code for api ...

After utilizing Geolocation, the input fields in Ionic/Angular JS are failing to update accurately

Currently, I am in the process of developing a new App using Ionic and Angular JS. Specifically, in one of the app tabs, I am utilizing geolocation to populate four fields (street name, street number, latitude, and longitude). Below is the snippet of my c ...

Mastering Jquery mobile for efficient mobile analytical insights

I am on the lookout for a top-notch mobile analytics solution that can seamlessly integrate with Jquery Mobile. I've already explored this specific query: Flurry Analytics vs Google Analytics on the mobile platform However, those recommendations are ...

What is the best way to target all the 'tr' elements within a 'table' using angularJS?

I have developed a customized directive that is targeted at a 'tr' element within a table. <tr row-select > I am looking to eliminate a specific style from all 'tr' elements under that particular table. directiveApp.directiv ...

Using the application router in Next.js to implement getServerSideProps()

I recently delved into utilizing Next.js 13 with the App Router, but encountered some challenges. The structure of my test application is as follows: ---/school ------/app ------/layout.tsx ------/page.tsx ---/src The ./app/page.tsx code snippet is ...

Here is a unique rewrite: "Strategies for effectively passing the data variable in the geturldata function within Vue.js on the HTML side vary

How can I properly pass a variable in the getdataurl function in Vue.js? I need help with passing a variable in getdataurl function in Vue.js. Please provide a clear explanation and include as much detail as possible. I have tried doing some background r ...