### Install Development Tools Source: https://github.com/groundhoggwp/groundhogg/blob/master/README.md Run this command to install PHPCS and register the necessary coding standards for the project. ```bash composer install ``` -------------------------------- ### Example Series Configuration Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Demonstrates how to enable and configure lines and points for data series. This example shows filled lines with a specific color and unfilled points. ```javascript var options = { series: { lines: { show: true, fill: true, fillColor: "rgba(255, 255, 255, 0.8)" }, points: { show: true, fill: false } } }; ``` -------------------------------- ### Example Series Object with Label and Data Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md A minimal example of a series object, specifying a label for the legend and the data points. ```javascript { label: "y = 3", data: [[0, 3], [10, 3]] } ``` -------------------------------- ### Simple Line Plot Example Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/README.md A minimal example demonstrating how to draw a simple line graph from (0,0) to (1,1) with a maximum y-axis value of 1. ```javascript $.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } }); ``` -------------------------------- ### Example Raw Data Points Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md An example of raw data points for a Flot series. Ensure all coordinate values are numeric. ```javascript [ [1, 3], [2, 14.01], [3.5, 3.14] ] ``` -------------------------------- ### Markings Array Example Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md An example of how to define markings for the grid using an array of objects. Each object specifies a range and color for a marking, such as a horizontal line. ```javascript markings: [ { xaxis: { from: 0, to: 2 }, yaxis: { from: 10, to: 10 }, color: "#bb0000" }, ... ] ``` -------------------------------- ### Validate PHP_CodeSniffer Installation Source: https://github.com/groundhoggwp/groundhogg/blob/master/README.md This command lists the installed coding standards, including WordPress standards, confirming that PHPCS is correctly set up and can find them. ```bash vendor\bin\phpcs -i ``` -------------------------------- ### Example Data Specification with Multiple Series Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Demonstrates how to define multiple data series, each with a label and its own set of data points. ```javascript [ { label: "Foo", data: [ [10, 1], [17, -14], [30, 5] ] }, { label: "Bar", data: [ [11, 13], [19, 11], [30, -7] ] } ] ``` -------------------------------- ### Ruby Time Conversion Example for Flot Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/NEWS.md This snippet provides an example of time conversion using Ruby, relevant for Flot's time-mode plugin. ```ruby require 'time' # Convert a Unix timestamp to a human-readable date and time puts Time.at(1337100000).strftime('%Y-%m-%d %H:%M:%S') # Convert a date string to a Unix timestamp puts Time.parse('2012-05-15 10:00:00').to_i ``` -------------------------------- ### Complete Debug Plugin Example Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/PLUGINS.md A comprehensive example of a Flot plugin that provides debugging information. It uses options to control the debug level and hooks into 'processOptions' and 'processDatapoints'. The plugin is wrapped in an anonymous function for scope protection. ```javascript (function ($) { function init(plot) { var debugLevel = 1; function checkDebugEnabled(plot, options) { if (options.debug) { debugLevel = options.debug; plot.hooks.processDatapoints.push(alertSeries); } } function alertSeries(plot, series, datapoints) { var msg = "series " + series.label; if (debugLevel > 1) { msg += " with " + series.data.length + " points"; alert(msg); } } plot.hooks.processOptions.push(checkDebugEnabled); } var options = { debug: 0 }; $.plot.plugins.push({ init: init, options: options, name: "simpledebug", version: "0.1" }); })(jQuery); ``` -------------------------------- ### Series-Specific Options Example Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/PLUGINS.md An example of how to define options that are specific to each series within a Flot plot. These options are placed under the 'series' key in the main options object and can provide default values. ```javascript var options = { series: { downsample: { algorithm: null, maxpoints: 1000 } } } ``` -------------------------------- ### Example of Markings Configuration in Flot Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/NEWS.md Markings are now specified as ranges on the axes. This example shows how to define markings for the x-axis. Horizontal or vertical lines can be drawn by setting 'from' and 'to' to the same coordinate. ```javascript { xaxis: { from: 0, to: 10 } } ``` -------------------------------- ### Verify WPCS Configuration Source: https://github.com/groundhoggwp/groundhogg/blob/master/README.md Check if the WordPress Coding Standards (WPCS) are correctly configured and installed. This ensures the development environment is set up properly. ```bash composer run wpcs:doctor ``` -------------------------------- ### Default Color Theme Example Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Illustrates how to define a default color theme for data series using an array of color strings. Flot will generate additional colors if more series exist than colors provided. ```javascript colors: ["#d18b2c", "#dba255", "#919733"] ``` -------------------------------- ### JavaScript Logarithmic Axis Transformation Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Example of how to implement a logarithmic scale for an axis by providing transform and inverseTransform functions. Ensure the transform function is monotone. ```javascript xaxis: { transform: function (v) { return Math.log(v); }, inverseTransform: function (v) { return Math.exp(v); } } ``` -------------------------------- ### Single Site Cron Processing Source: https://github.com/groundhoggwp/groundhogg/blob/master/gh-cron.txt Executes the Groundhogg event queue directly for single-site installations. This is the default behavior when not in a multisite configuration. ```php \Groundhogg\event_queue()->run_queue(); ``` -------------------------------- ### Specify Gradient Colors and Opacity for Series Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Control the appearance of series gradients by specifying opacity and brightness for individual colors. This example shows a series where colors fade out. ```javascript { colors: [{ opacity: 0.8 }, { brightness: 0.6, opacity: 0.8 } ] } ``` -------------------------------- ### Direct Cron Execution Header Setup Source: https://github.com/groundhoggwp/groundhogg/blob/master/gh-cron.txt Configures HTTP headers to prevent caching and ensure the request doesn't block, optimizing direct cron job execution. ```php ignore_user_abort( true ); /* Don't make the request block till we finish, if possible. */ if ( ! headers_sent() ) { header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); } ``` -------------------------------- ### Basic Flot Plot Initialization Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Example of initializing a Flot plot with a simple series. The 'datapoint', 'dataIndex', and 'series' properties in event handlers will correspond to this data structure. ```javascript $.plot($("#placeholder"), [ { label: "Foo", data: [[0, 10], [7, 3]] } ], ...); ``` -------------------------------- ### Basic Plugin Structure Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/PLUGINS.md A minimal example of a Flot plugin. It defines an initialization function and adds it to the $.plot.plugins array. The plugin adds a 'coolstring' attribute to the plot object. ```javascript function myCoolPluginInit(plot) { plot.coolstring = "Hello!"; }; $.plot.plugins.push({ init: myCoolPluginInit, options: { ... } }); // if $.plot is called, it will return a plot object with the // attribute "coolstring" ``` -------------------------------- ### Multisite Cron Processing Source: https://github.com/groundhoggwp/groundhogg/blob/master/gh-cron.txt Handles cron processing for multisite installations by creating and executing multiple requests to each subsite's cron endpoint. This improves performance and efficiency. ```php if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) || defined( 'DOING_GH_CRON' ) ) { die(); } /** * Tell WordPress we are doing the CRON task. * * Keep for compatibility * * @var bool */ define( 'DOING_CRON', true ); /** * Special const for Groundhogg compat * * @var bool */ define( 'DOING_GH_CRON', true ); define( 'QM_DISABLED', true ); /** * How many concurrent requests you can make, too many might DDOS your server so be careful */ define( 'GH_MS_CRON_CONCURRENCY', 5 ); // This makes it so that it is not required to set up individual cron jobs for each subsite. if ( is_multisite() && is_main_site() && ! \Groundhogg\get_url_var( 'process_queue' ) ) { $requests = []; /** * Build a multi request object (faster and better performance + callbacks) for each sub site * * @var $blog WP_Site */ foreach ( get_sites() as $blog ) { $request = [ 'type' => 'GET', 'url' => $blog->siteurl . '/gh-cron.php?process_queue=1', ]; $requests[] = $request; } while ( ! empty( $requests ) ) { Requests::request_multiple( array_splice( $requests, 0, GH_MS_CRON_CONCURRENCY ) ); } } // Single site do the cron else { \Groundhogg\event_queue()->run_queue(); } die(); ``` -------------------------------- ### Specify Gradient Colors for Grid Background Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Define a gradient for the grid background by providing an array of colors to the 'colors' property within 'grid.backgroundColor'. This example creates a gradient from black to gray. ```javascript grid: { backgroundColor: { colors: ["#000", "#999"] } } ``` -------------------------------- ### Custom Suffix Formatter for Ticks Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md An example of a custom tick formatter function that appends units like 'B', 'kB', or 'MB' based on the tick value. This provides more human-readable labels for large numbers. ```javascript function suffixFormatter(val, axis) { if (val > 1000000) return (val / 1000000).toFixed(axis.tickDecimals) + " MB"; else if (val > 1000) return (val / 1000).toFixed(axis.tickDecimals) + " kB"; else return val.toFixed(axis.tickDecimals) + " B"; } ``` -------------------------------- ### Multiply Y Coordinates Data Transformation in Flot Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md A simple data transformation example for the processDatapoints hook that multiplies all y coordinates by 2. Ensure datapoints remain in a valid condition after modification. ```javascript function multiply(plot, series, datapoints) { var points = datapoints.points, ps = datapoints.pointsize; for (var i = 0; i < points.length; i += ps) points[i + 1] *= 2; } ``` -------------------------------- ### Initialize WordPress Environment Source: https://github.com/groundhoggwp/groundhogg/blob/master/gh-cron.txt Ensures the WordPress environment is set up before proceeding. This is crucial for accessing WordPress functions and constants. ```php if ( ! defined( 'ABSPATH' ) ) { /** Set up WordPress environment */ require_once( __DIR__ . '/wp-load.php' ); } ``` -------------------------------- ### Using the Debug Plugin Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/PLUGINS.md Demonstrates how to include and enable the 'simpledebug' plugin when initializing a Flot chart. The 'debug' option is set to 2 to activate the plugin and control the output level. ```javascript $.plot($("#placeholder"), [...], { debug: 2 }); ``` -------------------------------- ### Get JavaScript Timestamp Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Use `(new Date()).getTime()` to get the current time as a JavaScript timestamp (milliseconds since epoch). This is crucial for time series data in Flot. ```javascript alert((new Date()).getTime()) ``` -------------------------------- ### Initialize a Flot Plot Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Use this to create a new plot. The placeholder must have width and height set. Consider using a dedicated div for the plot. ```javascript var plot = $.plot(placeholder, data, options) ``` -------------------------------- ### Configure PhpStorm for PHP_CodeSniffer Source: https://github.com/groundhoggwp/groundhogg/blob/master/README.md Instructions for setting up PhpStorm to automatically detect and use the project's PHP_CodeSniffer configuration for code inspections. ```php vendor\bin\phpcs ``` -------------------------------- ### Get Plot Dimensions Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Retrieve the width and height of the plotting area within the grid. This excludes space for labels and margins. ```javascript width() ``` ```javascript height() ``` -------------------------------- ### Get Javascript Timestamp in .NET Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md This C# function converts a DateTime object to a Javascript-compatible timestamp (milliseconds since epoch). ```csharp public static int GetJavascriptTimestamp(System.DateTime input) { System.TimeSpan span = new System.TimeSpan(System.DateTime.Parse("1/1/1970").Ticks); System.DateTime time = input.Subtract(span); return (long)(time.Ticks / 10000); } ``` -------------------------------- ### Plot Offset API Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Get the offset of the plot grid within the canvas. This is useful for positioning elements relative to the plot area. ```APIDOC ## GET /plot/offset ### Description Gets the offset of the grid within the canvas. Returns an object with distances from the canvas edges. ### Method GET ### Endpoint /plot/offset ### Parameters None ### Request Example None ### Response #### Success Response (200) - **offset** (object) - An object containing 'left', 'right', 'top', and 'bottom' distances. #### Response Example ```json { "offset": { "left": 50, "right": 20, "top": 30, "bottom": 40 } } ``` ``` -------------------------------- ### Get Plot Offset Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Returns the offset of the plotting area relative to the document. Useful for calculating mouse positions within the plot. ```javascript offset() ``` -------------------------------- ### Custom Tick Formatter Function in Flot Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Implement a custom 'tickFormatter' function to control how tick values are displayed. This example formats dates as DD/MM. ```javascript tickFormatter: function (val, axis) { var d = new Date(val); return d.getUTCDate() + "/" + (d.getUTCMonth() + 1); } ``` -------------------------------- ### Get Plot Axes Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Retrieves an object containing all axes. Provides access to axis properties like ticks, and transformation functions (p2c, c2p). ```javascript getAxes() ``` -------------------------------- ### Get Data Point Offset Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Calculates the offset of a data point within the placeholder div, based on its data coordinates. Can specify axes for multi-axis plots. ```javascript pointOffset({ x: xpos, y: ypos }) ``` ```javascript pointOffset({ x: xpos, y: ypos, xaxis: 2, yaxis: 3 }) ``` -------------------------------- ### Run WPCS Inspections on a Specific File Source: https://github.com/groundhoggwp/groundhogg/blob/master/README.md This command runs WPCS inspections on a specified PHP file and reports any violations found according to the WordPress standard. ```bash vendor\bin\phpcs -sp --standard=WordPress admin\events\events-page.php ``` -------------------------------- ### Robust Plugin Initialization Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/PLUGINS.md This pattern wraps plugin code in an immediately invoked anonymous function to prevent global scope pollution. It also accepts the '$' as an argument to ensure compatibility with different jQuery bindings. ```javascript (function ($) { // plugin definition // ... })(jQuery); ``` -------------------------------- ### Custom Tick Generator Function Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Define a function for the 'ticks' option to generate ticks dynamically based on axis properties. This example generates ticks at intervals of pi. ```javascript function piTickGenerator(axis) { var res = [], i = Math.floor(axis.min / Math.PI); do { var v = i * Math.PI; res.push([v, i + "\u03c0"]); ++i; } while (v < axis.max); return res; } ``` -------------------------------- ### Configure PhpStorm File Watcher for Auto-fixing Source: https://github.com/groundhoggwp/groundhogg/blob/master/README.md Set up a PhpStorm File Watcher to automatically run phpcbf on file save, ensuring code is auto-fixed as you work. ```php vendor\bin\phpcbf ``` -------------------------------- ### Lint PHP Code Source: https://github.com/groundhoggwp/groundhogg/blob/master/README.md Execute this command to check your PHP code against the defined coding standards and identify any violations. ```bash composer run lint:php ``` -------------------------------- ### Get Plot Data Series Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Returns an array of the current data series in a normalized format. Useful for inspecting series properties like color and data points. ```javascript var series = plot.getData(); for (var i = 0; i < series.length; ++i) alert(series[i].color); ``` -------------------------------- ### Grid Configuration Options Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Defines the structure for grid configuration, including visibility, colors, margins, borders, and markings. Use this to control the visual appearance of the plot grid. ```javascript grid: { show: boolean aboveData: boolean color: color backgroundColor: color/gradient or null margin: number or margin object labelMargin: number axisMargin: number markings: array of markings or (fn: axes -> array of markings) borderWidth: number or object with "top", "right", "bottom" and "left" properties with different widths borderColor: color or null or object with "top", "right", "bottom" and "left" properties with different colors minBorderMargin: number or null clickable: boolean hoverable: boolean autoHighlight: boolean mouseActiveRadius: number } interaction: { redrawOverlayInterval: number or -1 } ``` -------------------------------- ### Plot Function Usage Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Demonstrates how to initialize a Flot plot using the $.plot() function, either directly or via jQuery chaining. ```APIDOC ## Plot Function Usage ### Description Initializes a Flot plot on a given placeholder element with specified data and options. ### Method `$.plot(placeholder, data, options)` or `$(placeholder).plot(data, options)` ### Endpoint N/A (JavaScript function) ### Parameters - **placeholder** (jQuery object or DOM element or jQuery expression) - The element where the plot will be rendered. It must have its width and height set. - **data** (Array) - An array of data series to plot. - **options** (Object) - An object containing various plot configuration options. ### Request Example ```javascript // Direct usage var plot = $.plot(placeholder, data, options); // jQuery chaining var plot = $("#placeholder").plot(data, options).data("plot"); ``` ### Response - **plot object** (Object) - An object representing the plot instance, which has methods for interacting with the plot. ``` -------------------------------- ### Correct Spacing in JavaScript Loops Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/CONTRIBUTING.md Demonstrates the correct spacing for loop definitions and array/object indices in JavaScript, adhering to Flot's style guidelines. ```javascript for ( var i = 0; i < data.length; i++ ) { // This block is wrong! if ( data[ i ] > 1 ) { data[ i ] = 2; } } for (var i = 0; i < data.length; i++) { // This block is correct! if (data[i] > 1) { data[i] = 2; } } ``` -------------------------------- ### Bind Mouse Down Event Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Use this hook to set custom event handlers on the plot's event holder. This example shows how to bind a mousedown event to display mouse coordinates. ```javascript function (plot, eventHolder) { eventHolder.mousedown(function (e) { alert("You pressed the mouse at " + e.pageX + " " + e.pageY); }); } ``` -------------------------------- ### Clickable Grid Event Binding Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Shows how to enable click events on the grid and bind a handler to the 'plotclick' event. This allows for interaction with data points on the plot. ```javascript $.plot($("#placeholder"), [ d ], { grid: { clickable: true } }); $("#placeholder").bind("plotclick", function (event, pos, item) { alert("You clicked at " + pos.x + ", " + pos.y); // axis coordinates for other axes, if present, are in pos.x2, pos.x3, ... // if you need global screen coordinates, they are pos.pageX, pos.pageY if (item) { highlight(item.series, item.datapoint); alert("You clicked a point!"); } }); ``` -------------------------------- ### Custom Legend Label Formatting Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Use a labelFormatter function to customize how series labels appear in the legend, for example, to make them clickable links. Returning null will hide the series from the legend. ```javascript labelFormatter: function(label, series) { // series is the series object for the label return '' + label + ''; } ``` -------------------------------- ### Resize Plot Canvas Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Resizes the drawing canvas to match the placeholder dimensions. Requires setupGrid() and draw() to be called afterwards. ```javascript resize() ``` -------------------------------- ### Convert Time to Timestamp in Ruby Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md In Ruby, multiply the result of `Time.now.to_i` by 1000 to get a JavaScript timestamp. This applies to `Time`, `DateTime`, and `ActiveSupport::TimeWithZone` objects when using the `active_support` gem. ```ruby Time.now.to_i * 1000 # => 1383582043000 # ActiveSupport examples: DateTime.now.to_i * 1000 # => 1383582043000 ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 1000 ``` -------------------------------- ### Basic Plotting Function Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/README.md Use the $.plot function to render a graph in the specified placeholder. This requires data and options objects. ```javascript $.plot($("#placeholder"), data, options); ``` -------------------------------- ### Plot Hooks Overview Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Groundhogg's Plot object provides hooks that can be used to modify the plotting process at various stages. These hooks are functions that get access to internal data structures. ```APIDOC ## Plot Hooks In addition to the public methods, the Plot object also has some hooks that can be used to modify the plotting process. You can install a callback function at various points in the process, the function then gets access to the internal data structures in Flot. Here's an overview of the phases Flot goes through: 1. Plugin initialization, parsing options 2. Constructing the canvases used for drawing 3. Set data: parsing data specification, calculating colors, copying raw data points into internal format, normalizing them, finding max/min for axis auto-scaling 4. Grid setup: calculating axis spacing, ticks, inserting tick labels, the legend 5. Draw: drawing the grid, drawing each of the series in turn 6. Setting up event handling for interactive features 7. Responding to events, if any 8. Shutdown: this mostly happens in case a plot is overwritten Each hook is simply a function which is put in the appropriate array. You can add them through the "hooks" option, and they are also available after the plot is constructed as the "hooks" attribute on the returned plot object, e.g. ```js // define a simple draw hook function hellohook(plot, canvascontext) { alert("hello!"); }; // pass it in, in an array since we might want to specify several var plot = $.plot(placeholder, data, { hooks: { draw: [hellohook] } }); // we can now find it again in plot.hooks.draw[0] unless a plugin // has added other hooks ``` The available hooks are described below. All hook callbacks get the plot object as first parameter. You can find some examples of defined hooks in the plugins bundled with Flot. ``` -------------------------------- ### JavaScript Comment Formatting Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/CONTRIBUTING.md Illustrates the required formatting for JavaScript comments, including jsDoc for headers and // for inline/block comments, with specific spacing requirements. ```javascript var a = 5; // We're going to loop here // TODO: Make this loop faster, better, stronger! for (var x = 0; x < 10; x++) {} ``` -------------------------------- ### Series Options Schema Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Defines the structure for customizing series appearance, including lines, points, and bars. These global options are applied to all series unless overridden individually. ```javascript series: { lines, points, bars: { show: boolean lineWidth: number fill: boolean or number fillColor: null or color/gradient } lines, bars: { zero: boolean } points: { radius: number symbol: "circle" or function } bars: { barWidth: number align: "left", "right" or "center" horizontal: boolean } lines: { steps: boolean } shadowSize: number highlightColor: color or number } colors: [ color1, color2, ... ] ``` -------------------------------- ### Gradient Fill for Bars Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Configure bars to use a gradient fill that makes them gradually disappear from top to bottom. Set 'show: true', 'fill: true', and specify the 'fillColor' with opacity settings. ```javascript bars: { show: true, lineWidth: 0, fill: true, fillColor: { colors: [ { opacity: 0.8 }, { opacity: 0.1 } ] } } ``` -------------------------------- ### Legend Configuration Object Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Defines the structure and available properties for customizing the legend's display and functionality. ```javascript legend: { show: boolean, labelFormatter: null or (fn: string, series object -> string), labelBoxBorderColor: color, noColumns: number, position: "ne" or "nw" or "se" or "sw", margin: number of pixels or [x margin, y margin], backgroundColor: null or color, backgroundOpacity: number between 0 and 1, container: null or jQuery object/DOM element/jQuery expression, sorted: null/false, true, "ascending", "descending", "reverse", or a comparator } ``` -------------------------------- ### Correct JavaScript Conditional Statement Wrapping Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/CONTRIBUTING.md Shows the correct way to write JavaScript conditional statements without arbitrary wrapping, prioritizing readability and adhering to the 80-character limit where appropriate. ```javascript if (a == 1 && // This block is wrong! b == 2 && c == 3) {} if (a == 1 && b == 2 && c == 3) {} // This block is correct! ``` -------------------------------- ### Placeholder Div with Inline Styles Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/README.md Set the width and height of the placeholder div directly using inline styles. This is crucial for Flot to correctly scale the graph. ```html
``` -------------------------------- ### Check Groundhogg Activation Source: https://github.com/groundhoggwp/groundhogg/blob/master/gh-cron.txt Verifies if Groundhogg is active. If not, the script terminates to prevent errors. ```php // Check if Groundhogg is active... if ( ! defined( 'GROUNDHOGG_VERSION' ) ) { die(); } ``` -------------------------------- ### JavaScript Inverse (Reversed) Y-Axis Transformation Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Demonstrates how to reverse the order of values on a y-axis by using a simple negation transform and inverseTransform function. ```javascript yaxis: { transform: function (v) { return -v; }, inverseTransform: function (v) { return -v; } } ``` -------------------------------- ### processOptions Hook Source: https://github.com/groundhoggwp/groundhogg/blob/master/assets/lib/flot/API.md Called after Flot has parsed and merged options. Useful for enabling/disabling other options based on plugin activation. ```APIDOC ## processOptions Hook - processOptions [phase 1] ```function(plot, options)``` Called after Flot has parsed and merged options. Useful in the instance where customizations beyond simple merging of default values is needed. A plugin might use it to detect that it has been enabled and then turn on or off other options. ```