JS Mouse Move to Control the Carousel of Dashboards

  • Last update:December 16, 2020
  • I. Overview

    1.1 Problem description

    When developing dashboards, sometimes we need the carousel effect of multiple dashboards, and we hope to stop the carousel under certain circumstances. If you control the pause and resume of the carousel through buttons, the visual effect of the dashboards will be affected.


    1.2 Solutions

    You can add mouse move in and out effect to a certain component through JavaScript. At the same time, through the JavaScript delay function, the page will be rotated after the specified time. As shown below:

    1606645881287615.gif

    II. Example

    2.1 The first template

    1) New dataset

    Create a new dashboard named Carousel1.frm and create a new dataset ds1:

    SELECT * FROM Sales_Volume

    2) Report block settings

    Drag two report blocks and set them as shown in the figure below:

    1606645906821842.png

    3) Add event

    Select report0 and add a After Initialization event, as shown in the following figure:

    1606645925673338.png

    The JS code is as follows:

    function time() {
        timer = setTimeout(function () {
            window.location.href = FR.cjkEncode("${contextPath}/decision/view/form?viewlet=Carousel2.frm"); //The url of the report to be rotated
        }, 2000); //Carousel interval
    }
    time();
    setTimeout(function () {
        //The component name here should be uppercase
        $("[widgetname=REPORT0]").mouseover(function () {
            clearTimeout(timer);
        })
        $("[widgetname=REPORT0]").mouseleave(function () {
            time();
        })
    })

    Save the dashboard to folder %FR_HOME%\webapps\webroot\WEB-INF\reportlets\.


    2.2 Template 2

    Create another dashboard named Carousel2.frm under the path %FR_HOME%\webapps\webroot\WEB-INF\reportlets\.

    Do the same settings as the first dashboard, but you need to change the URL in the After Initialization event to: "${contextPath}/decision/view/form?viewlet=Carousel1.frm".

    III. Preview

    Save the 2 dashboards and previe either one. The two dashboards are automatically rotated. After the mouse is moved to report0, the rotation terminates.

    1606645954435018.gif

    Note: Mobile terminal is not supported.

    IV. Completed Templates

    Attachment List


    Theme: FineVis Data Visualization
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy