{"id":138823,"date":"2021-04-20T10:43:04","date_gmt":"2021-04-20T10:43:04","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/sb-chart-block\/"},"modified":"2025-04-18T09:15:26","modified_gmt":"2025-04-18T09:15:26","slug":"sb-chart-block","status":"publish","type":"plugin","link":"https:\/\/twd.wordpress.org\/plugins\/sb-chart-block\/","author":7443420,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.3.1","stable_tag":"1.3.1","tested":"6.8.5","requires":"5.6.0","requires_php":"7.2.0","requires_plugins":null,"header_name":"SB Chart block","header_author":"bobbingwide","header_description":"Displays a Chart for CSV content","assets_banners_color":"fbdcdc","last_updated":"2025-04-18 09:15:26","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/www.oik-plugins.com\/oik-plugins\/sb-chart-block","header_author_uri":"https:\/\/www.bobbingwide.com\/about-bobbing-wide","rating":5,"author_block_rating":5,"active_installs":300,"downloads":7635,"num_ratings":1,"support_threads":0,"support_threads_resolved":0,"author_block_count":2,"sections":["description","installation","faq","changelog"],"tags":{"0.3.0":{"tag":"0.3.0","author":"bobbingwide","date":"2021-04-20 10:43:26"},"0.4.1":{"tag":"0.4.1","author":"bobbingwide","date":"2021-10-06 08:26:10"},"1.0.0":{"tag":"1.0.0","author":"bobbingwide","date":"2022-02-24 18:18:25"},"1.1.0":{"tag":"1.1.0","author":"bobbingwide","date":"2022-08-19 16:06:09"},"1.2.2":{"tag":"1.2.2","author":"bobbingwide","date":"2023-02-19 17:11:32"},"1.2.3":{"tag":"1.2.3","author":"bobbingwide","date":"2023-02-23 08:57:29"},"1.2.4":{"tag":"1.2.4","author":"bobbingwide","date":"2023-08-10 08:40:32"},"1.2.5":{"tag":"1.2.5","author":"bobbingwide","date":"2023-10-20 09:34:33"},"1.2.6":{"tag":"1.2.6","author":"bobbingwide","date":"2024-05-16 10:22:07"},"1.3.1":{"tag":"1.3.1","author":"bobbingwide","date":"2025-04-18 09:15:26"}},"upgrade_notice":{"1.3.1":"<p>Update for support for PHP 8.4 and a minor security fix<\/p>"},"ratings":{"1":0,"2":0,"3":0,"4":0,"5":1},"assets_icons":{"icon-256x256.jpg":{"filename":"icon-256x256.jpg","revision":2518242,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":2519069,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":{"oik-sb\/chart":{"apiVersion":3,"name":"oik-sb\/chart","title":"Chart","category":"widgets","icon":"chart-line","keywords":["Chart","Line","Bar","Horizontal bar","Pie"],"description":"Displays a chart for CSV content.","textdomain":"sb-chart-block","supports":{"html":false,"align":false,"typography":{"fontSize":false}},"attributes":{"type":{"type":"string","default":"line"},"content":{"type":"string","default":""},"theme":{"type":"string","default":"Chart"},"stacked":{"type":"boolean","default":false},"fill":{"type":"boolean","default":false},"height":{"type":"integer","default":null},"beginYAxisAt0":{"type":"boolean","default":false},"opacity":{"type":"number","default":0.8},"time":{"type":"boolean","default":false},"timeunit":{"type":"string","default":"day"},"barThickness":{"type":"integer","default":null},"tension":{"type":"number","default":0},"labelsFontSize":{"type":"number","default":12},"xTicksFontSize":{"type":"number","default":12},"yTicksFontSize":{"type":"number","default":12},"y1TicksFontSize":{"type":"number","default":12},"backgroundColors":{"type":"string","default":""},"borderColors":{"type":"string","default":""},"yAxes":{"type":"string","default":""}},"editorScript":"oik-sb-chart-editor-script","editorStyle":"file:.\/build\/index.css","style":"file:.\/build\/style-index.css"}},"tagged_versions":["0.3.0","0.4.1","1.0.0","1.1.0","1.2.2","1.2.3","1.2.4","1.2.5","1.2.6","1.3.1"],"block_files":["\/tags\/1.3.1\/.\/build\/index.css","\/tags\/1.3.1\/.\/build\/style-index.css"],"assets_screenshots":{"screenshot-1.jpg":{"filename":"screenshot-1.jpg","revision":2518242,"resolution":"1","location":"assets","locale":""},"screenshot-2.jpg":{"filename":"screenshot-2.jpg","revision":2518242,"resolution":"2","location":"assets","locale":""},"screenshot-3.jpg":{"filename":"screenshot-3.jpg","revision":2518242,"resolution":"3","location":"assets","locale":""},"screenshot-4.jpg":{"filename":"screenshot-4.jpg","revision":2518242,"resolution":"4","location":"assets","locale":""},"screenshot-5.jpg":{"filename":"screenshot-5.jpg","revision":2518242,"resolution":"5","location":"assets","locale":""}},"screenshots":{"1":"Line chart - Gutenberg theme colors","2":"Bar chart - Chart theme colors","3":"Horizontal bar chart - Tertiary theme colors","4":"Pie chart - Visualizer theme colors","5":"Chart type toolbar selection"},"jetpack_post_was_ever_published":false},"plugin_section":[172757],"plugin_tags":[17088,1220,241005,17086,17072],"plugin_category":[],"plugin_contributors":[79761],"plugin_business_model":[],"class_list":["post-138823","plugin","type-plugin","status-publish","hentry","plugin_section-block","plugin_tags-bar-chart","plugin_tags-block","plugin_tags-horizontal-bar-chart","plugin_tags-line-chart","plugin_tags-pie-chart","plugin_contributors-bobbingwide","plugin_committers-bobbingwide"],"banners":{"banner":"https:\/\/ps.w.org\/sb-chart-block\/assets\/banner-772x250.jpg?rev=2519069","banner_2x":false,"banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/sb-chart-block\/assets\/icon-256x256.jpg?rev=2518242","icon_2x":"https:\/\/ps.w.org\/sb-chart-block\/assets\/icon-256x256.jpg?rev=2518242","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/sb-chart-block\/assets\/screenshot-1.jpg?rev=2518242","caption":"Line chart - Gutenberg theme colors"},{"src":"https:\/\/ps.w.org\/sb-chart-block\/assets\/screenshot-2.jpg?rev=2518242","caption":"Bar chart - Chart theme colors"},{"src":"https:\/\/ps.w.org\/sb-chart-block\/assets\/screenshot-3.jpg?rev=2518242","caption":"Horizontal bar chart - Tertiary theme colors"},{"src":"https:\/\/ps.w.org\/sb-chart-block\/assets\/screenshot-4.jpg?rev=2518242","caption":"Pie chart - Visualizer theme colors"},{"src":"https:\/\/ps.w.org\/sb-chart-block\/assets\/screenshot-5.jpg?rev=2518242","caption":"Chart type toolbar selection"}],"raw_content":"<!--section=description-->\n<p>Use the Chart block ( oik-sb\/chart ) to display a chart.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the plugin files to the <code>\/wp-content\/plugins\/sb-chart-block<\/code> directory, or install the plugin through the WordPress plugins screen directly.<\/li>\n<li>Activate the plugin through the 'Plugins' screen in WordPress<\/li>\n<\/ol>\n\n<p>OR with the authority to install plugins<\/p>\n\n<ol>\n<li>In the block editor, open the block inserter.<\/li>\n<li>Search for the block by typing 'Chart'.<\/li>\n<li>Click on the 'Add block' button for the SB Chart block.<\/li>\n<li>The SB Chart block plugin will be installed and activated.<\/li>\n<li>And the block will be inserted into your content.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='what%20types%20of%20chart%20can%20i%20display%3F'><h3>What types of chart can I display?<\/h3><\/dt>\n<dd><p>So far...<\/p>\n\n<ul>\n<li>Line and stacked line, with optional fill<\/li>\n<li>Bar and stacked bar<\/li>\n<li>Horizontal bar and stacked horizontal bar<\/li>\n<li>Pie<\/li>\n<\/ul><\/dd>\n<dt id='how%20do%20i%20choose%20the%20chart%20colors%3F'><h3>How do I choose the chart colors?<\/h3><\/dt>\n<dd><p>There are 6 predefined color palettes:\nchoose the color palette from a drop down list.<\/p>\n\n<p>Use the Background color overrides and border color overrides fields to set custom color values.<\/p><\/dd>\n<dt id='what%20options%20are%20there%3F'><h3>What options are there?<\/h3><\/dt>\n<dd><p>Options to control the chart display are:<\/p>\n\n<ul>\n<li>Stacked - Toggle on to stack line or bar charts<\/li>\n<li>Begin Y axis at 0 toggle<\/li>\n<li>Fill toggle for line charts<\/li>\n<li>Time line toggle for a date based axis, with selectable Time unit (stepSize)<\/li>\n<li>Y-axes for multi axis charts<\/li>\n<li>Color palette dropdown<\/li>\n<li>Background color overrides. Enter comma separated hex codes.<\/li>\n<li>Border color overrides. Enter comma separated hex codes.<\/li>\n<li>Opacity - set the opacity of the background colours.<\/li>\n<li>Height of the chart, in pixels<\/li>\n<li>Bar thickness in pixels<\/li>\n<li>Tension - for curved line charts<\/li>\n<li>Legend font size<\/li>\n<li>X-axis font size<\/li>\n<\/ul><\/dd>\n<dt id='what%20chart%20script%20does%20it%20use%3F'><h3>What Chart script does it use?<\/h3><\/dt>\n<dd><p>v1.2.6 delivers <a href=\"https:\/\/www.jsdelivr.com\/package\/npm\/chart.js?path=dist\">chartjs v4.4.2<\/a>\nand <a href=\"https:\/\/github.com\/chartjs\/chartjs-adapter-date-fns\">chartjs-adapter-date-fns v3.0.0<\/a><\/p><\/dd>\n<dt id='what%20do%20i%20need%20to%20search%20for%20to%20find%20the%20block%3F'><h3>What do I need to search for to find the block?<\/h3><\/dt>\n<dd><p>Chart or SB Chart<\/p><\/dd>\n<dt id='what%20if%20my%20first%20language%20is%20not%20english%3F'><h3>What if my first language is not English?<\/h3><\/dt>\n<dd><p>If your first language is not English then you could try:<\/p>\n\n<ul>\n<li>French - graphique<\/li>\n<li>German - Diagramm<\/li>\n<li>Dutch - grafiek<\/li>\n<li>Italian - grafico<\/li>\n<li>Spanish - gr\u00e1fico<\/li>\n<\/ul><\/dd>\n<dt id='do%20i%20need%20to%20build%20this%20block%3F'><h3>Do I need to build this block?<\/h3><\/dt>\n<dd><p>No. The plugin is delivered with the production version of the block.\nIf you do wish to modify the code then you can find instructions in the src folder.<\/p><\/dd>\n<dt id='are%20there%20shortcodes%20available%3F'><h3>Are there shortcodes available?<\/h3><\/dt>\n<dd><p>Charts can be embedded with the shortcode <code>chartjs<\/code>. The general syntax is as follows:<\/p>\n\n<pre><code>[chartjs attribute=\"attribute value\"]CSV content[\/chartjs]\n<\/code><\/pre>\n\n<p>Several attributes can be added at the same time. Example:<\/p>\n\n<pre><code>[chartjs attribute1=\"attribute1 value\" attribute2=\"attribute2 value\"]CSV content[\/chartjs]\n<\/code><\/pre>\n\n<p>Here's the list of supported attributes:<\/p>\n\n<ul>\n<li><code>backgroundColors<\/code> (string): list of custom background colors (separated by comma) to use for datasets. For example, if there are 3 datasets (<code>d1<\/code>, <code>d2<\/code> and <code>d3<\/code>) and we want <code>d1<\/code> to use the color <code>#0000FF<\/code>, <code>d2<\/code> to use <code>#FFFF00<\/code> and <code>d3<\/code> to use <code>#008000<\/code>, the value of the attribute must be <code>#0000FF,#FFFF00,#008000<\/code>. If some colors are missing (ex.: <code>#0000FF,,#008000<\/code>), default colors from the theme (set with the attribute <code>theme<\/code>) are used as fallback (<code>#0000FF,second theme color,#008000<\/code>); default is no custom colors used<\/li>\n<li><code>barThickness<\/code> (int): thickness (in pixels) of a bar in bar charts; default is the default Chart.js thickness<\/li>\n<li><code>beginYAxisAt0<\/code> (bool): make sure the Y axis begins at 0; default is <code>false<\/code><\/li>\n<li><code>borderColors<\/code> (string): list of custom border colors (separated by comma) to use for datasets. See the description of the attribute <code>backgroundColors<\/code> for more details; default is the value of the attribute <code>backgroundColors<\/code><\/li>\n<li><code>class<\/code> (string): class or classes to be added to the chart container; default is an empty string<\/li>\n<li><code>fill<\/code> (bool): fill the area under the line; default is <code>false<\/code><\/li>\n<li><code>height<\/code> (int): chart height (in pixels); default is the default Chart.js height<\/li>\n<li><code>indexAxis<\/code> (string): axis to use as index; choices are <code>x<\/code>, <code>y<\/code>; note that <code>y<\/code> is automatically used for horizontal bar charts; default is <code>x<\/code><\/li>\n<li><code>max<\/code> (float): maximum value for Y axes; default is no maximum value<\/li>\n<li><code>opacity<\/code> (float): opacity to apply to the lines or bars; it must be between <code>0<\/code> and <code>1<\/code>; default is <code>0.8<\/code><\/li>\n<li><code>showLine<\/code> (bool): show (draw) lines; default is <code>true<\/code><\/li>\n<li><code>stacked<\/code> (bool): enable stacking for line\/bar charts; default is <code>false<\/code><\/li>\n<li><code>tension<\/code> (float): add Bezier curve tension to lines; when set to <code>0<\/code>, lines are straight; default is <code>0<\/code><\/li>\n<li><code>theme<\/code> (string): theme used for the chart colors; choices are <code>Chart<\/code>, <code>Gutenberg<\/code>, <code>Rainbow<\/code>, <code>Tertiary<\/code>, <code>Visualizer<\/code>, <code>Wordpress<\/code>; default is <code>Chart<\/code><\/li>\n<li><code>time<\/code> (bool): add support for time line on the X axis; default is <code>false<\/code><\/li>\n<li><code>timeUnit<\/code> (string): time unit to use if time line is enabled; choices are <code>year<\/code>, <code>quarter<\/code>, <code>month<\/code>, <code>week<\/code>, <code>day<\/code>, <code>hour<\/code>, <code>minute<\/code>, <code>second<\/code>, <code>millisecond<\/code>; default is <code>hour<\/code><\/li>\n<li><code>type<\/code> (string): type of chart; choices are <code>bar<\/code>, <code>horizontalbar<\/code>, <code>line<\/code>, <code>pie<\/code>; default is <code>line<\/code><\/li>\n<li><code>yAxes<\/code> (string): list of Y axes to which the datasets are bound. It allows to enable multi-axis charts. For example, if there are 3 datasets (<code>d1<\/code>, <code>d2<\/code> and <code>d3<\/code>) and we want <code>d1<\/code> to use the first Y axis, and <code>d2<\/code> and <code>d3<\/code> to use the second Y axis, the attribute value must be <code>y,y1,y1<\/code>; default is an empty string, so multi-axis feature is disabled and all datasets are automatically bound to the first (and only) Y axis <code>y<\/code><\/li>\n<\/ul>\n\n<p>Here's a fully functional example:<\/p>\n\n<pre><code>[chartjs backgroundColors=\"#008000\" fill=\"true\" opacity=\"0.35\" tension=\"0.2\" theme=\"Visualizer\" time=\"true\" timeUnit=\"month\" yAxes=\"y,y1\"]Year,Sales,Expenses\n2020-08,5421.32,1151.21\n2021-02,4823.99,887.23\n2021-03,4945.32,958.00\n2021-10,7086.65,1854.35\n2022-05,7385.21,2009.01\n[\/chartjs]\n<\/code><\/pre>\n\n<p>Here's the result:<\/p>\n\n<p><\/p><\/dd>\n<dt id='are%20there%20hooks%20available%20for%20developers%3F'><h3>Are there hooks available for developers?<\/h3><\/dt>\n<dd><p>The following filter hooks are available:<\/p>\n\n<ul>\n<li><code>sb_chart_block_content<\/code>: filter allowing to manipulate the content before it's processed<\/li>\n<li><code>sb_chart_block_options<\/code>: filter allowing to add custom Chart.js options<\/li>\n<\/ul>\n\n<p>For example, to customize the legend, use the <code>sb_chart_block_options<\/code> filter in your <code>functions.php<\/code> theme file as follows:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>function customize_legend($options, $atts, $series) {\n    $custom_options = to_array($options);<\/p>\n\n<pre><code>$custom_options['plugins']['legend']['labels']['font']['size'] = 16;\n$custom_options['plugins']['legend']['labels']['color'] = '#0000FF';\n\nreturn json_decode(json_encode($custom_options));\n<\/code><\/pre>\n\n<p>}\nadd_filter('sb_chart_block_options', 'customize_legend', 10, 3);<\/p>\n\n<p>function to_array($data) {\n    $array = [];<\/p>\n\n<pre><code>if (is_array($data) || is_object($data)) {\n    foreach ($data as $key =&gt; $value) {\n        $array[$key] = (is_array($value) || is_object($value)) ? to_array($value) : $value;\n    }\n} else {\n    $array[] = $data;\n}\n\nreturn $array;\n<\/code><\/pre>\n\n<p>}\n    `<\/p>\n\n<p>Here's another way (without array conversion):<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>function customize_legend($options, $atts, $series) {\n    if (!isset($options-&gt;plugins)) $options-&gt;plugins = new stdClass();\n    if (!isset($options-&gt;plugins-&gt;legend)) $options-&gt;plugins-&gt;legend = new stdClass();\n    if (!isset($options-&gt;plugins-&gt;legend-&gt;labels)) $options-&gt;plugins-&gt;legend-&gt;labels = new stdClass();\n    if (!isset($options-&gt;plugins-&gt;legend-&gt;labels-&gt;font)) $options-&gt;plugins-&gt;legend-&gt;labels-&gt;font = new stdClass();<\/p>\n\n<pre><code>$options-&gt;plugins-&gt;legend-&gt;labels-&gt;font-&gt;size = 16;\n$options-&gt;plugins-&gt;legend-&gt;labels-&gt;color = '#0000FF';\n\nreturn $options;\n<\/code><\/pre>\n\n<p>}\nadd_filter('sb_chart_block_options', 'customize_legend', 10, 3);\n    `<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.3.1<\/h4>\n\n<ul>\n<li>Changed: Run esc_attr() against the classNames attribute. Props: Peter Thaleikis (Wordfence)  #38<\/li>\n<li>Changed: Support PHP 8.4's str_getcsv() changes #38<\/li>\n<li>Tested: With WordPress 6.8 and WordPress Multisite<\/li>\n<li>Tested: With PHP 8.3 and PHP 8.4<\/li>\n<li>Tested: With PHPUnit 9.6<\/li>\n<\/ul>","raw_excerpt":"Displays a Chart for CSV content.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/138823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=138823"}],"author":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/bobbingwide"}],"wp:attachment":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=138823"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=138823"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=138823"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=138823"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=138823"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=138823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}