Hiding or Displaying FVS Components Through JS

  • Last update:  2023-04-11
  • Overview

    Application scenarios: If you have installed the FVS plugin, you can view this article to learn about functions related to FVS templates.

    Note: Mobile devices are not supported.

    Version

    Report Server Version

    Plugin Version

    Function Change

    V11.0.6

    V1.8.0

    All components   support the setVisible and isVisible interfaces, and the components on the   current page can be hidden or displayed through JS.

    Application Scenarios

    In FVS templates, FVS Carousel Component is usually used to switch and display multiple components, but the style or function of the carousel may not meet requirements in certain scenarios.

    At this point, you can manually hide or display components during preview through JS, as shown in the expected effect in the figure below:

    1.2.gif

    Implementation Method

    You can achieve the effect by setting the JavaScript event in conjunction with the setVisible interface. The JavaScript code is as follows:

    Note:

    1.    Only supports plugins of V1.8.0 and later versions.

    2.    This interface is only valid for components on the current page.

    duchamp.getWidgetByName("component name").setVisible(false); //true means setting it to be visible, false means setting it to be invisible

    Example

    Creating a Template

    Click File > New FVS Report in the top left corner of the designer.

    2.1.png

    Designing Components

    Add FVS Title Component to set click events. You can add components that are used to be hidden or displayed at will. In this example, a column chart, a pie chart, and a line chart are added.

    Overlap several charts together, and set the content of the title components to column chart, pie chart, line chart respectively. You can modify the component name in the Component panel.

    Click the button in the lower left corner of the canvas to expand the Widget Layer list.

    2.2第一张.png

    Each component on every page occupies one component layer. When the mouse hovers over the component object,  js隐藏或显示FVS组件 图1.png appears on the left side, indicating that the component is in a visible state. Clicking the icon can switch to js隐藏或显示FVS组件 图2.png , indicating that the component is in an invisible state, and the icon will always be displayed.

    In this example, the pie chart and line chart are set to be invisible.

    2.2第二张.gif

    Setting the JavaScript Event

    1. Select the column chart title, and click Interaction > Click > Add Click Event > JavaScript.

    Enter the event name and the JavaScript:

    duchamp.getWidgetByName("column chart").setVisible(true); //Set the column chart to be visible

    duchamp.getWidgetByName("pie chart").setVisible(false); //Set the pie chart to be invisible

    duchamp.getWidgetByName("line chart").setVisible(false); //Set the line chart to be invisible

    The procedure is as follows:

    2.3.png

    2. Similarly, set JavaScript events for two other title components:

    Pie chart:

    duchamp.getWidgetByName("pie chart").setVisible(true); //Set the pie chart to be visible

    duchamp.getWidgetByName("column chart").setVisible(false); //Set the column chart to be invisible

    duchamp.getWidgetByName("line chart").setVisible(false); //Set the line chart to be invisible

    Line chart:

    duchamp.getWidgetByName("line chart").setVisible(true); //Set the line chart to be visible

    duchamp.getWidgetByName("pie chart").setVisible(false); //Set the pie chart to be invisible

    duchamp.getWidgetByName("column chart").setVisible(false); //Set the column chart to be invisible

    Previewing the Effect

    Click Preview in the upper right corner and the effect is as shown in the section "Expected Effect".

    Template Download

    Click to download the template: Hiding or Displaying FVS Components Through JS.fvs

    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