Skip to content
GravityKit
Buy
Sign in
0 items
  • Plugins

    GravityKit All Access

    Our complete Kit of essential tools for extending and enhancing Gravity Formsโ€”everything you need to build powerful web apps and workflows.

    Learn more
    • GravityView

      GravityView

      Bestseller

      Display Gravity Forms entries on the front-end of your site and build powerful web applications.

    • GravityImport

      GravityImport

      Trending

      Import entries from CSV files into Gravity Forms to transfer data, create new forms, or update existing entries.

    • GravityEdit

      GravityEdit

      Quickly edit Gravity Forms entries inline to save time, reduce clicks, and streamline your workflow.

    • GravityCharts

      GravityCharts

      Trending

      Turn Gravity Forms entries into interactive charts and graphs.

    • GravityActions

      GravityActions

      Update multiple Gravity Forms entries at once, send bulk emails, and streamline your workflow.

    • GravityCalendar

      GravityCalendar

      Turn Gravity Forms entries into dynamic calendars to showcase events, schedules, appointments, and more.

    • GravityExport

      GravityExport

      Export Gravity Forms entries to Excel, CSV, or PDF and share them instantly with secure download links.

    • GravityMath

      GravityMath

      Perform advanced calculations on Gravity Forms entries to display totals, averages, or build custom calculators.

    • GravityRevisions

      GravityRevisions

      Track, compare, and restore changes made to Gravity Forms forms and entries with a full version history.

    • GravityMigrate

      GravityMigrate

      Migrate all Gravity Forms data, including forms, entries, Views, feeds, uploads, and more.

    • GravityBoard

      GravityBoard

      Manage projects with collaborative project management. Coordinate with your team and streamline your workflows.

  • Ideal For

    • Nonprofits
    • Startups
    • Education
    • Web Agencies
    • Developers
    • Government iconGovernment
    Explore All Use Cases

    Case studies

    • West Fork Schools
    • Princeton University
    • BrightLeaf Giving
    • Jacksonville Port Authority
    • National Severe Storms Lab
    • Leadpal
    • Mediebruket
    • Dragonfly
    View All Case Studies
  • Resources

    • Blog
    • Case studies
    • Support
    • Live Demos
    • Documentation
    • Developer docs
    • GravityKit Academy
    • GravityKit Live!

    Ultimate guides

    • How to use Gravity Forms
    • Editing Gravity Forms entries
    • Importing Gravity Forms entries
    • Exporting Gravity Forms entries
    • Displaying Gravity Forms entries
    • Gravity Forms conditional logic
    • Gravity Forms calculations
    View More Articles
  • Plugins

    • GravityView

      GravityView

      Bestseller

      Display Gravity Forms entries on the front-end of your site and build powerful web applications.

    • GravityImport

      GravityImport

      Trending

      Import entries from CSV files into Gravity Forms to transfer data, create new forms, or update existing entries.

    • GravityEdit

      GravityEdit

      Quickly edit Gravity Forms entries inline to save time, reduce clicks, and streamline your workflow.

    • GravityCharts

      GravityCharts

      Trending

      Turn Gravity Forms entries into interactive charts and graphs.

    • GravityActions

      GravityActions

      Update multiple Gravity Forms entries at once, send bulk emails, and streamline your workflow.

    • GravityCalendar

      GravityCalendar

      Turn Gravity Forms entries into dynamic calendars to showcase events, schedules, appointments, and more.

    • GravityExport

      GravityExport

      Export Gravity Forms entries to Excel, CSV, or PDF and share them instantly with secure download links.

    • GravityMath

      GravityMath

      Perform advanced calculations on Gravity Forms entries to display totals, averages, or build custom calculators.

    • GravityRevisions

      GravityRevisions

      Track, compare, and restore changes made to Gravity Forms forms and entries with a full version history.

    • GravityMigrate

      GravityMigrate

      Migrate all Gravity Forms data, including forms, entries, Views, feeds, uploads, and more.

    • GravityBoard

      GravityBoard

      Manage projects with collaborative project management. Coordinate with your team and streamline your workflows.

    GravityKit All Access

    Our complete Kit of essential tools for extending and enhancing Gravity Formsโ€”everything you need to build powerful web apps and workflows.

    Learn more
  • Ideal For

    • Nonprofits
    • Startups
    • Education
    • Web Agencies
    • Developers
    • Government iconGovernment
    Explore All Use Cases

    Case studies

    • West Fork Schools
    • Princeton University
    • BrightLeaf Giving
    • Jacksonville Port Authority
    • National Severe Storms Lab
    • Leadpal
    • Mediebruket
    • Dragonfly
    View All Case Studies

    How to build...

    • Property Management
    • Product Catalog
    • Fundraising Dashboard
    • Real Estate Directory
    • Document Library
    • Academic Journal
    • Volunteer Management
    • Meal Tracker
    View All Guides
  • Resources

    • Blog
    • Case studies
    • Support
    • Live Demos
    • Documentation
    • Developer docs
    • GravityKit Academy
    • GravityKit Live!

    ultimate guides

    • How to use Gravity Forms
    • Editing Gravity Forms entries
    • Importing Gravity Forms entries
    • Exporting Gravity Forms entries
    • Displaying Gravity Forms entries
    • Gravity Forms conditional logic
    • Gravity Forms calculations
    View More Articles
  • Pricing
  • About
0 items

Search

Results appear automatically as you type.
Loading results…

results found matching

    Sign in
    Buy

    Docs

    • Docs Home

    Gravity Forms Add-Ons

    • GravityView
    • GravityActions
    • GravityBoard
    • GravityCalendar
    • GravityCharts
    • GravityEdit
    • GravityExport
    • GravityImport
    • GravityMath
    • GravityMigrate
    • GravityRevisions
    • GF Widget for Elementor
    • GF Dynamic Lookup
    • GF Entry Tags
    • GF Event Field
    • GF Zero Spam
    • GravityExport Lite

    GravityView

    • Getting Started
    • View Setup
    • FAQ
    • Pre-Sale
    • Advanced
    • Common Problems
    • Customizing Your Views
    • Edit Entry
    • Entry Approval
    • Filter and Sort Results
    • Gravity Forms
    • Merge Tags
    • Roles and Capabilities
    • Search
    • Shortcodes
    • View Settings
    • WordPress Posts

    General Help

    • Account, Invoices, and Billing
    • License Related
    • Plugins and Settings
    • Contact
    • Docs Home
    • Gravity Forms Add-Ons

      • GravityView
      • GravityActions
      • GravityBoard
      • GravityCalendar
      • GravityCharts
      • GravityEdit
      • GravityExport
      • GravityImport
      • GravityMath
      • GravityMigrate
      • GravityRevisions
      • GF Widget for Elementor
      • GF Dynamic Lookup
      • GF Entry Tags
      • GF Event Field
      • GF Zero Spam
      • GravityExport Lite
    • GravityView

      • Getting Started
      • View Setup
      • FAQ
      • Pre-Sale
      • Advanced
      • Common Problems
      • Customizing Your Views
      • Edit Entry
      • Entry Approval
      • Filter and Sort Results
      • Gravity Forms
      • Merge Tags
      • Roles and Capabilities
      • Search
      • Shortcodes
      • View Settings
      • WordPress Posts
    • General Help

      • Account, Invoices, and Billing
      • License Related
      • Plugins and Settings
    • Contact

    Uncategorized

    • About the `secret` shortcode attribute
    • Adding custom repeat schedules to the Event field
    • Adding GravityKit support emails to your allowlist
    • Bulk Edit Step: What are these fields?
    • Bulk Edit Step: What will happen to my old field data?
    • Fields in GravityExport
    • GravityBoard + GravityView Integration
    • GravityExport download URL shortcode
    • GravityExport Lite: Recipes
    • GravityKit Add-On Shortcodes (a complete reference)
    • How to disable entry creation in Gravity Forms
    • If GravityKit blocks are not visible in the block editor inserter
    • If you see a “This link has expired” or “Are you sure you want to do this?” message when installing a plugin
    • Import Step: Mapping CSV columns to form fields
    • Modifying Chart.js settings with filters
    • Showing fewer overlapping events in GravityCalendar
    • Troubleshooting 403 errors in GravityBoard
    • Home
    • Docs
    • Uncategorized
    • Modifying Chart.js settings with filters

    Modifying Chart.js settings with filters

    Estimated reading: 7 minutes

    Updated on April 24, 2026

    GravityCharts uses Chart.js to render interactive charts. You can customize the Chart.js configuration using WordPress filters to modify chart appearance and behavior beyond the settings available in the GravityCharts interface.

    gk/gravitycharts/chart-library-options ย ย filter #

    Modifies the default Chart.js options that apply to all charts across your site.

    Parameters:

    • $fields ย ย ย (array) – Array of default Chart.js settings
    • $library ย ย ย (string) – Name of the charting library being used (currently “Chart.js”)

    Example:

    Change border settings. See line styling.

    /**
     * Customize borders for all GravityCharts.
     *
     * @param array  $fields  Array of default Chart.js settings.
     * @param string $library Name of the charting library being used.
     *
     * @return array Modified Chart.js settings.
     */
    add_filter( 'gk/gravitycharts/chart-library-options', function( $fields, $library ) {
        if ( empty( $fields ) ) {
            return $fields;
        }
        
        // Modify border appearance
        $fields['borderWidth'] = 2;
        $fields['borderJoinStyle'] = 'bevel';
    
        return $fields;
    }, 10, 2 );

    Example:

    Enable animations and customize timing. See animations.

    /**
     * Enable animations with custom duration and easing.
     *
     * @param array  $fields  Array of default Chart.js settings.
     * @param string $library Name of the charting library being used.
     *
     * @return array Modified Chart.js settings.
     */
    add_filter( 'gk/gravitycharts/chart-library-options', function( $fields, $library ) {
        // Enable animations with custom duration
        $fields['animation'] = [
            'duration' => 1000,
            'easing' => 'easeInOutQuart'
        ];
    
        return $fields;
    }, 10, 2 );

    gk/gravitycharts/api/chart/options ย ย  #

    Modifies the Chart.js options for a specific chart (identified by feed ID). This filter is more targeted and allows you to customize individual charts differently.

    Parameters:

    • $response ย ย ย (array) – The chart options
    • $feed_id ย ย ย (int) – The GravityCharts feed ID

    Example:

    Customize the title and legend for a specific chart by feed ID

    /**
     * Customize title and legend for a specific chart.
     *
     * @param array $response The chart options.
     * @param int   $feed_id  The GravityCharts feed ID.
     *
     * @return array Modified chart options.
     */
    add_filter( 'gk/gravitycharts/api/chart/options', function( $response, $feed_id ) {
        // Only modify chart with feed ID 5
        if ( $feed_id !== 5 ) {
            return $response;
        }
    
        // Add custom title (Chart.js 3.x uses plugins.title)
        $response['plugins']['title'] = [
            'display' => true,
            'text' => 'Custom Chart Title'
        ];
    
        // Customize legend (Chart.js 3.x uses plugins.legend)
        $response['plugins']['legend'] = [
            'display' => true,
            'position' => 'bottom',
            'labels' => [
                'color' => '#333'
            ]
        ];
    
        return $response;
    }, 10, 2 );

    Example:

    Modify tooltips for all charts. See Tooltips.

    /**
     * Customize tooltip appearance and behavior.
     *
     * @param array $response The chart options.
     * @param int   $feed_id  The GravityCharts feed ID.
     *
     * @return array Modified chart options.
     */
    add_filter( 'gk/gravitycharts/api/chart/options', function( $response, $feed_id ) {
        if ( empty( $response ) ) {
            return $response;
        }
    
        // Customize tooltip settings (Chart.js 3.x)
        $response['plugins']['tooltip'] = [
            'enabled' => true,
            'backgroundColor' => 'rgba(0, 0, 0, 0.9)',
            'titleColor' => '#fff',
            'bodyColor' => '#fff',
            'borderColor' => '#666',
            'borderWidth' => 1,
            'cornerRadius' => 6,
            'displayColors' => true,
            'padding' => 12,
            'boxPadding' => 6
        ];
    
        return $response;
    }, 10, 2 );

    gk/gravitycharts/api/chart/data ย  #

    Modifies the chart data (values, labels, datasets) for a specific chart. This filter allows you to customize the actual data being displayed rather than just the visual settings.

    Parameters:

    • $chart_data ย ย ย (array) – The chart data object (contains datasets, labels, etc.)
    • $feed ย ย ย (array) – The GravityCharts feed object
    • $context ย ย ย (string) – The chart context (default ย ย ย or timeline ย ย )
    /**
     * Modify chart data labels and values.
     *
     * @param array  $chart_data The chart data.
     * @param array  $feed       The Feed object.
     * @param string $context    The chart context.
     *
     * @return array Modified chart data.
     */
    add_filter( 'gk/gravitycharts/api/chart/data', function( $chart_data, $feed, $context ) {
        if ( empty( $chart_data ) ) {
            return $chart_data;
        }
    
        // Modify labels
        if ( isset( $chart_data['labels'] ) ) {
            $chart_data['labels'] = array_map( 'strtoupper', $chart_data['labels'] );
        }
    
        // Modify dataset values
        if ( isset( $chart_data['datasets'][0]['data'] ) ) {
            // Add 10 to each value
            $chart_data['datasets'][0]['data'] = array_map( function( $value ) {
                return $value + 10;
            }, $chart_data['datasets'][0]['data'] );
        }
    
        return $chart_data;
    }, 10, 3 );

    Example:

    Add custom dataset to existing chart data

    /**
     * Add a custom dataset to chart data.
     *
     * @param array  $chart_data The chart data.
     * @param array  $feed       The Feed object.
     * @param string $context    The chart context.
     *
     * @return array Modified chart data.
     */
    add_filter( 'gk/gravitycharts/api/chart/data', function( $chart_data, $feed, $context ) {
        if ( empty( $chart_data ) || empty( $chart_data['datasets'] ) ) {
            return $chart_data;
        }
    
        // Only add custom dataset for feed ID 3
        if ( ! isset( $feed['id'] ) || $feed['id'] !== 3 ) {
            return $chart_data;
        }
    
        // Add a trend line dataset
        $chart_data['datasets'][] = [
            'label' => 'Trend Line',
            'data' => [ 5, 10, 15, 20, 25 ], // Your custom data
            'borderColor' => '#ff0000',
            'backgroundColor' => 'transparent',
            'borderDash' => [ 5, 5 ],
            'type' => 'line'
        ];
    
        return $chart_data;
    }, 10, 3 );

    Example:

    Filter data based on conditions

    /**
     * Filter chart data based on value thresholds.
     *
     * @param array  $chart_data The chart data.
     * @param array  $feed       The Feed object.
     * @param string $context    The chart context.
     *
     * @return array Modified chart data.
     */
    add_filter( 'gk/gravitycharts/api/chart/data', function( $chart_data, $feed, $context ) {
        if ( empty( $chart_data ) || ! isset( $chart_data['datasets'][0]['data'] ) ) {
            return $chart_data;
        }
    
        $threshold = 100;
        $filtered_labels = [];
        $filtered_data = [];
    
        // Only include data points above threshold
        foreach ( $chart_data['datasets'][0]['data'] as $index => $value ) {
            if ( $value >= $threshold ) {
                $filtered_labels[] = $chart_data['labels'][ $index ];
                $filtered_data[] = $value;
            }
        }
    
        $chart_data['labels'] = $filtered_labels;
        $chart_data['datasets'][0]['data'] = $filtered_data;
    
        return $chart_data;
    }, 10, 3 );

    Which filter should I use? #

    Use gk/gravitycharts/chart-library-options ย ย when:

    • You want to set defaults for all charts on your site
    • You’re changing global Chart.js behavior (animations, borders, etc.)
    • You want consistent settings across multiple charts

    Use gk/gravitycharts/api/chart/options ย ย when:

    • You need to customize a specific chart differently
    • You’re targeting charts by feed ID
    • You need different settings for different charts

    Use gk/gravitycharts/api/chart/data ย ย when:

    • You need to modify the actual data values or labels
    • You want to add, remove, or filter datasets
    • You’re performing calculations on data values
    • You need to transform data before it’s displayed

    Chart.js Documentation #

    For a complete list of available Chart.js options and configurations, refer to the official Chart.js documentation:

    • Chart.js Documentation
    • Configuration Options
    Still stuck? How can we help?

    How can we help?

    "*" indicates required fields

    This field is for validation purposes and should be left unchanged.
    Replies will go to this email.
    How can we help?*
    My pre-sale question is related to...*
    My WordPress skills are....*
    My Gravity Forms skills are...*
    You will be shown articles from our documentation.
    Vous pouvez nous รฉcrire dans votre langue maternelle si cโ€™est plus facile pour vousโ€”nous nous occuperons de la traduction!
    Puedes escribirnos en tu idioma nativo si te resulta mรกs fรกcil; ยกnosotros nos encargamos de la traducciรณn!
    Sie kรถnnen uns in Ihrer Muttersprache schreiben, wenn das fรผr Sie einfacher ist โ€“ wir kรผmmern uns um die รœbersetzung!
    U kunt ons in uw moedertaal schrijven als dat gemakkelijker voor u is โ€” wij zorgen voor de vertaling!
    Du kan skrive til oss pรฅ ditt morsmรฅl hvis det er enklere for deg โ€” vi tar oss av oversettelsen!
    Du kan skriva till oss pรฅ ditt modersmรฅl om det รคr lรคttare fรถr dig โ€” vi tar hand om รถversรคttningen!
    Vocรช pode nos escrever em seu idioma nativo se for mais fรกcil para vocรช โ€” nรณs cuidaremos da traduรงรฃo!
    Puoi scriverci nella tua lingua madre se ti รจ piรน facile โ€” penseremo noi alla traduzione!
    Please provide as much detail as you're able; this helps us provide you with faster support.
    Drop files here or
    Accepted file types: jpg, jpeg, gif, png, tiff, pdf, bmp, zip, json, csv, xls, xlsx, Max. file size: 256 MB.
      Stay informed?

      Was this page helpful?

      Table Of Contents
      • gk/gravitycharts/chart-library-options ย ย filter
      • gk/gravitycharts/api/chart/options ย ย 
      • gk/gravitycharts/api/chart/data ย 
      • Which filter should I use?
      • Chart.js Documentation
      GravityKit
      • How to Build It
      • Pricing
      • Products
      • Our Team
      • Our Values
      • Work With Us
      • Coupons
      Support
      • Support
      • Contact
      • Documentation
      • Scope of Support
      • Brand Guidelines
      • Privacy Policy
      • Terms of Service (โ€œTermsโ€)
      About Us
      • GravityKit on Mastodon
      • GravityKit on Twitter
      • GravityKit Training Courses
      • GravityKit on Facebook
      • Join our Facebook Group
      • Facebook
      • Twitter
      Get notified of updates.

      Weโ€™re constantly improving GravityKit. Fill out your email below and weโ€™ll notify you anytime major updates drop.

      GravityKit is a Gravity Forms Certified Developer.

      Copyright ยฉ 2026, Katz Web Services, Inc.

      GravityKit and GravityView are registered trademarks of Katz Web Services, Inc.