Okay
  Public Ticket #2635346
Filter rows from charts?
Closed

Comments

  •  4
    Daniel Lewis started the conversation

    I have a JSON data API I'm pulling into WPDT and rendering in a chart. I know I can filter the table so it omits rows based on certain matches (in my case, any row with a 0 value). But that filter in the table settings seems to have no effect on the chart, which still displays the 0 values.

    So how can I apply these same filters to my chart for data that shifts rows every day?

  •  2,572
    Aleksandar replied

    Hello Daniel

    For charts to follow table filtering, you first need to enable that option in the chart wizard, and then you need to place both the chart and the table on the same page.

    Only then will you be able to filter the chart. 

    Now, there is a way to simply hide the table using CSS, leaving only the chart and the filters. Anyone who knows CSS will be able to still display the table if they were to inspect the page, and simply change the properties.

    Since you need to show the filters, a simple CSS like this would not be useful, because it'd hide the filters too:

    .wpdt-c .wpDataTables.wpDataTablesWrapper {
    display: none !important;
    }
    

    So, instead you would first need to disable the following in table settings:

    "Show X entries" drop-down; "Info Block" from Display tab:

    2852344743.png

    "Enable main search block" from Sorting and Filtering tab:

    3844294247.png

    And "Table Tools" from Table Tools tab:

    6988162559.png

    Then, you can hide the table, leaving the filters above the chart like this:

    <style>
    .wpdt-c .wpDataTablesWrapper table {
    display: none !important;
    }
    </style>
    [wpdatatable id=1]
    [wpdatachart id=1]
    

    And that's it. This is how you'd create a page where you'd have Chart #1 dependent on wpDataTable #1 so it follows filtering, and the table hidden using CSS.

    The screenshots are from an older version of wpDataTables, but they are still valid.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables