### Get Scheme Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/architecture.md Demonstrates the step-by-step execution of the getScheme function with a specific input string. It shows the input processing, transformation, lookup, and return value. ```text getScheme('brewer.Paired12') 1. Input is string 2. No backward compat transformation needed 3. Split: category='brewer', name='Paired12' 4. Lookup: Chart.colorschemes['brewer']['Paired12'] 5. Return: ['#a6cee3', '#1f78b4', ...] ``` -------------------------------- ### Install via bower Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Install the plugin using bower for use in your project. ```bash bower install chartjs-plugin-colorschemes --save ``` -------------------------------- ### Install via npm Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Install the plugin using npm for use in your project. ```bash npm install chartjs-plugin-colorschemes --save ``` -------------------------------- ### Install chartjs-plugin-colorschemes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/README.md Shows how to install the plugin using a script tag, npm, or as an ES6 module. ```javascript // Script tag // npm npm install chartjs-plugin-colorschemes // ES6 module import 'chartjs-plugin-colorschemes'; ``` -------------------------------- ### Pie Chart Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Example of applying a colorscheme to a pie chart. ```javascript options: { plugins: { colorschemes: { scheme: 'tableau.Tableau10' } } } ``` -------------------------------- ### Install Node Dependencies Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Before building the project, install the necessary Node.js dependencies using npm. This command should be run from the repository root. ```bash npm install ``` -------------------------------- ### Simple Bar Chart Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md A basic example of applying a colorscheme to a bar chart. ```javascript options: { plugins: { colorschemes: { scheme: 'office.Metro6' } } } ``` -------------------------------- ### HTML Setup with Script Tags Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Demonstrates how to include the Chart.js library and the colorschemes plugin using script tags in an HTML file. This is suitable for simple web pages. ```html
``` -------------------------------- ### Multi-Series Line Chart Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Example of applying a colorscheme with transparency to a multi-series line chart. ```javascript options: { plugins: { colorschemes: { scheme: 'brewer.Set2', fillAlpha: 0.2 } } } ``` -------------------------------- ### Demonstrate Configuration Precedence Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/configuration.md This example shows how per-chart options take precedence over global defaults. Set a global default first, then define a chart-specific option that overrides it. ```javascript // Example: Precedence demonstration // 1. Set global default Chart.defaults.global.plugins.colorschemes = { scheme: 'brewer.Blues9' }; // 2. Per-chart config overrides global const chart = new Chart(ctx, { options: { plugins: { colorschemes: { scheme: 'tableau.Tableau10' // This takes precedence } } } }); ``` -------------------------------- ### Basic Chart Creation with Random Data Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/docs/index.html This example demonstrates how to create a basic line chart with random data and sets up the chart object. ```javascript var ctx = document.getElementById('myChart').getContext('2d'); var chart = new Chart(ctx, { type: 'line', data: { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [1, 2, 3].map(function(i) { return { label: 'Dataset ' + i, data: [0, 0, 0, 0, 0, 0, 0].map(Math.random), fill: false }; }) } }); ``` -------------------------------- ### Plugin Options Usage Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Demonstrates how to apply the ColorSchemesPluginOptions within Chart.js configuration. Shows setting a specific scheme and fill alpha. ```javascript // In Chart.js options const options = { plugins: { colorschemes: { // ColorSchemesPluginOptions shape scheme: 'brewer.YlGn9', fillAlpha: 0.5, reverse: false, override: false, custom: undefined } } }; ``` -------------------------------- ### Color Scheme Naming Convention Examples Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Examples of how color schemes are named, combining category, scheme name, and color count. ```text brewer.YlGn9 // ColorBrewer Yellow-Green, 9 colors office.Aspect6 // Microsoft Office Aspect, 6 colors tableau.Tableau20 // Tableau, 20 colors ``` -------------------------------- ### Color Application Example for Line, Radar, Scatter Charts Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/architecture.md Provides a concrete example of color application for line, radar, and scatter charts, showing how colors are assigned to datasets based on the scheme and fill alpha. ```text scheme = ['#e41a1c', '#377eb8', '#4daf4a'] fillAlpha = 0.5 datasets = [A, B, C, D, E] Colors applied: Dataset A: '#e41a1c' with 50% opacity Dataset B: '#377eb8' with 50% opacity Dataset C: '#4daf4a' with 50% opacity Dataset D: '#e41a1c' with 50% opacity (cycles) Dataset E: '#377eb8' with 50% opacity (cycles) ``` -------------------------------- ### Transparency Examples Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Illustrates different values for the `fillAlpha` option to control the transparency of chart elements. ```javascript fillAlpha: 0.1 // Very transparent fillAlpha: 0.5 // Default (50%) fillAlpha: 0.9 // Mostly opaque fillAlpha: 1.0 // Fully opaque ``` -------------------------------- ### Configure Scheme: ColorBrewer Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/configuration.md Example of setting a ColorBrewer scheme for the colorschemes plugin. Ensure the scheme name is correctly formatted. ```javascript options: { plugins: { colorschemes: { scheme: 'brewer.YlGn9' } } } ``` -------------------------------- ### Dataset Color Storage Lifecycle Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Illustrates the process of storing original dataset colors before applying a scheme and restoring them afterward. Essential for maintaining original chart states. ```javascript // Before applying scheme: dataset.$colorschemes = {}; // After storing original blue color: dataset.$colorschemes = { backgroundColor: 'rgb(0, 0, 255)' }; // Apply scheme color: dataset.backgroundColor = 'rgb(135, 206, 235)'; // light blue from scheme // After update, restore: dataset.backgroundColor = 'rgb(0, 0, 255)'; // original blue delete dataset.$colorschemes; ``` -------------------------------- ### Color Array Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md An example of a valid color array, consisting of lowercase hexadecimal color strings. Ensures correct formatting for color schemes. ```javascript ['#f7fcb9', '#addd8e', '#31a354', '#006837'] ``` -------------------------------- ### Example Color Application for Pie Charts Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/architecture.md Demonstrates how a predefined color scheme is applied to dataset data points, showing the cycling behavior of colors. ```javascript scheme = ['#e41a1c', '#377eb8', '#4daf4a'] dataset.data = [10, 20, 30, 40, 50] Colors applied: Data point 0: '#e41a1c' Data point 1: '#377eb8' Data point 2: '#4daf4a' Data point 3: '#e41a1c' (cycles) Data point 4: '#377eb8' (cycles) ``` -------------------------------- ### ES6 Module Setup Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Shows how to import and use the Chart.js library and the colorschemes plugin within an ES6 module environment. This is recommended for modern JavaScript projects. ```javascript import Chart from 'chart.js'; import 'chartjs-plugin-colorschemes'; const ctx = document.getElementById('myChart').getContext('2d'); const chart = new Chart(ctx, { type: 'line', data: { labels: ['Q1', 'Q2', 'Q3', 'Q4'], datasets: [ { label: 'Product A', data: [12, 19, 8, 15] }, { label: 'Product B', data: [10, 8, 12, 19] } ] }, options: { plugins: { colorschemes: { scheme: 'brewer.YlGn9' } } } }); ``` -------------------------------- ### getScheme Function Examples Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/plugin.colorschemes.md Shows how to use the internal getScheme function to resolve color schemes, either from a direct array of colors or a named scheme string. It also demonstrates the behavior with an invalid scheme. ```javascript // Direct color array getScheme(['#ff0000', '#00ff00', '#0000ff']); // Returns: ['#ff0000', '#00ff00', '#0000ff'] // Named scheme getScheme('brewer.Paired12'); // Returns: [array of 12 colors] // Invalid scheme getScheme('nonexistent.scheme'); // Returns: undefined ``` -------------------------------- ### Chart with Custom Modifier Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Demonstrates applying a colorscheme and using a custom function to add a color. ```javascript options: { plugins: { colorschemes: { scheme: 'brewer.Paired6', custom: function(colors) { colors.push('#000000'); // Add black return colors; } } } } ``` -------------------------------- ### Color Cycling Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/plugin.colorschemes.md Illustrates how colors are repeated when the number of datasets exceeds the available colors in a scheme. The scheme ['red', 'blue', 'green'] is used as an example. ```javascript // Scheme: ['red', 'blue', 'green'] // 5 datasets: uses red, blue, green, red, blue ``` -------------------------------- ### RGBA Color Conversion Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Demonstrates the conversion of a hex color to an RGBA string with a specified alpha value. ```javascript // Input hex: '#7fc97f' // With fillAlpha: 0.5 // Output: 'rgba(127, 201, 127, 0.5)' ``` -------------------------------- ### ColorBrewer Module Export Structure Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Example of named exports for ColorBrewer schemes within the module. ```javascript export var SchemeName = [colors]; export var Another = [colors]; // ... all ColorBrewer schemes ``` -------------------------------- ### Configure Scheme: ES6 Imported Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/configuration.md Example of using an ES6 imported color scheme with the colorschemes plugin. Ensure the scheme is correctly imported from the library. ```javascript import { Blues9 } from 'chartjs-plugin-colorschemes/src/colorschemes/colorschemes.brewer'; options: { plugins: { colorschemes: { scheme: Blues9 } } } ``` -------------------------------- ### Office Module Export Structure Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Example of named exports for Microsoft Office schemes within the module. ```javascript export var Adjacency6 = [colors]; export var Office6 = [colors]; // ... all Office schemes ``` -------------------------------- ### Complex Chart Example with Custom Scheme and Alpha Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Demonstrates a complex bar chart configuration using a named scheme ('brewer.Set2'), custom fill alpha, and a custom color modification function. ```javascript const ctx = document.getElementById('complexChart').getContext('2d'); const chart = new Chart(ctx, { type: 'bar', data: { labels: ['Week 1', 'Week 2', 'Week 3', 'Week 4', 'Week 5'], datasets: [ { label: 'Product A - Sales', data: [12, 19, 15, 25, 22] }, { label: 'Product A - Returns', data: [2, 3, 1, 2, 1] }, { label: 'Product B - Sales', data: [18, 21, 20, 19, 23] }, { label: 'Product B - Returns', data: [1, 2, 2, 1, 2] }, { label: 'Product C - Sales', data: [9, 15, 12, 18, 16] }, { label: 'Product C - Returns', data: [1, 1, 1, 2, 1] } ] }, options: { responsive: true, scales: { yAxes: [{ stacked: false }] }, plugins: { colorschemes: { scheme: 'brewer.Set2', fillAlpha: 0.7, reverse: false, override: false, custom: function(colors) { // Modify colors as needed return colors; } } } } }); ``` -------------------------------- ### Pie Chart with Color Schemes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Generates a pie chart and applies a predefined color scheme for its segments. This example assumes a canvas with the ID 'pieChart'. ```javascript const ctx = document.getElementById('pieChart').getContext('2d'); const chart = new Chart(ctx, { type: 'pie', data: { labels: ['Product A', 'Product B', 'Product C', 'Product D'], datasets: [ { data: [25, 30, 20, 25] } ] }, options: { plugins: { colorschemes: { scheme: 'tableau.Tableau10' } } } }); ``` -------------------------------- ### Custom Color Function Example Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Illustrates how to define a custom function to modify the color array before it's applied to the chart. ```javascript custom: function(colors) { // colors is a shallow copy colors.push('#FF00FF'); // Add custom color return colors; // Must return array } ``` -------------------------------- ### Basic Chart Initialization with Colorschemes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Shows how to apply a color scheme to a chart during initialization by specifying the scheme in the plugin options. ```javascript const chart = new Chart(ctx, { type: 'bar', data: { /* ... */ }, options: { plugins: { colorschemes: { scheme: 'brewer.Paired12' } } } }); ``` -------------------------------- ### Main Module Entry Point Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/main-module.md This snippet shows the main entry point of the plugin, responsible for coordinating plugin registration and exposing color schemes globally. ```javascript // src/index.js import Chart from 'chart.js'; import colorschemes from './colorschemes/index'; import ColorSchemesPlugin from './plugins/plugin.colorschemes'; Chart.colorschemes = colorschemes; export default ColorSchemesPlugin; ``` -------------------------------- ### Build Distribution Files Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Compile the project's source code into distributable files. This is a standard step before deploying or packaging the plugin. ```bash gulp build ``` -------------------------------- ### Build and Watch for Changes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Build the project's distribution files and continuously watch for file changes to trigger automatic rebuilds. This is useful during development to see changes reflected quickly. ```bash gulp build --watch ``` -------------------------------- ### Tableau Module Export Structure Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Example of named exports for Tableau schemes within the module. ```javascript export var Tableau10 = [colors]; export var HueCircle19 = [colors]; // ... all Tableau schemes ``` -------------------------------- ### Run All Tests Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Execute all defined test suites for the project. This command verifies the functionality and stability of the plugin. ```bash gulp test ``` -------------------------------- ### Create Distribution Package Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Generate an archive containing the distribution files and samples of the plugin. This package is typically used for distribution or deployment. ```bash gulp package ``` -------------------------------- ### Create Chart Instance Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/architecture.md Instantiate a new Chart.js chart with the plugin integrated. The plugin is prepared with merged user and global options. ```javascript const chart = new Chart(ctx, config); ``` -------------------------------- ### Using a Direct Color Array Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Shows how to provide an array of custom colors directly to the `scheme` option. ```javascript scheme: ['#FF6B6B', '#4ECDC4', '#45B7D1', '#FFA07A'] ``` -------------------------------- ### Radar Chart with Color Schemes and Alpha Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Configures a radar chart with a specified color scheme and fill alpha. This example uses a canvas with the ID 'radarChart'. ```javascript const ctx = document.getElementById('radarChart').getContext('2d'); const chart = new Chart(ctx, { type: 'radar', data: { labels: ['Speed', 'Accuracy', 'Power', 'Endurance', 'Agility'], datasets: [ { label: 'Player A', data: [80, 85, 75, 90, 88] }, { label: 'Player B', data: [85, 80, 88, 82, 90] } ] }, options: { plugins: { colorschemes: { scheme: 'brewer.Paired6', fillAlpha: 0.4 } } } }); ``` -------------------------------- ### Consumption Patterns for Color Schemes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/types.md Demonstrates different ways to import and use color schemes, including CommonJS and ES6 imports. ```javascript // CommonJS / global Chart.colorschemes.brewer.Paired12 // ES6 named import import { Paired12 } from 'chartjs-plugin-colorschemes/src/colorschemes/colorschemes.brewer'; // ES6 namespace import import * as brewer from 'chartjs-plugin-colorschemes/src/colorschemes/colorschemes.brewer'; const Paired12 = brewer.Paired12; ``` -------------------------------- ### Colorschemes Configuration Options Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Lists the available configuration options for the colorschemes plugin, including scheme, fillAlpha, reverse, override, and custom. ```javascript { scheme: 'brewer.Paired12', // Color scheme name or array of colors fillAlpha: 0.5, // Transparency: 0.0–1.0 reverse: false, // Reverse color order override: false, // Override existing colors custom: undefined // Function to modify colors } ``` -------------------------------- ### Setting Global Defaults (Chart.js 3.x) Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Demonstrates how to set global default colorscheme options for Chart.js version 3.x. ```javascript Chart.defaults.plugins.colorschemes = { scheme: 'brewer.Blues9' }; ``` -------------------------------- ### Setting Global Defaults (Chart.js 2.x) Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Demonstrates how to set global default colorscheme options for Chart.js version 2.x. ```javascript Chart.defaults.global.plugins.colorschemes = { scheme: 'brewer.Blues9' }; ``` -------------------------------- ### Get Scheme Function Flow Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/architecture.md Describes the process of resolving a color scheme based on the input parameter. It handles array inputs, string inputs with backward compatibility, and looks up schemes in Chart.colorschemes. ```text Input: scheme parameter │ ├─ Is array? → Return as-is │ └─ Is string? │ ├─ Apply backward compatibility transforms │ "brewer.Paired1-12" → "brewer.PairedOne12" │ "office.Office2007-2010-6" → "office.OfficeClassic6" │ ├─ Split on '.' → [category, name] │ ├─ Lookup Chart.colorschemes[category][name] │ └─ Return color array or undefined ``` -------------------------------- ### Include via CDN Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Include the plugin directly in your HTML using a CDN link. ```html ``` ```html ``` -------------------------------- ### Override Behavior Explanation Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/quick-reference.md Explains the difference between `override: false` (default) and `override: true` for applying color schemes to datasets. ```plaintext // override: false (default) // Color scheme only applied to datasets with no color settings // override: true // Color scheme applied to ALL datasets, overwriting existing colors ``` -------------------------------- ### Browser Global Usage and Auto-Registration Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/main-module.md Demonstrates how to include the plugin via a script tag in a browser, where it auto-registers and makes Chart.colorschemes globally available. ```html ``` -------------------------------- ### Using ColorBrewer Qualitative Schemes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Apply qualitative color schemes from ColorBrewer, such as Set2, to your charts. ```javascript // ColorBrewer Qualitative { plugins: { colorschemes: { scheme: 'brewer.Set2' } } } ``` -------------------------------- ### Usage in ES6 as Module Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Import the plugin as an ES6 module. No additional configuration is needed after importing. ```javascript import 'chartjs-plugin-colorschemes'; ``` -------------------------------- ### Using Office Schemes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/colorschemes.md Integrate Microsoft Office color schemes into your charts. Use the 'office.' prefix followed by the scheme name. ```javascript const chart = new Chart(ctx, { type: 'line', data: { /* ... */ }, options: { plugins: { colorschemes: { scheme: 'office.Office6' } } } }); ``` -------------------------------- ### Basic Chart.js Bar Chart with Color Scheme Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/plugin.colorschemes.md Demonstrates how to configure a bar chart to use a predefined color scheme ('brewer.Paired12') via the plugin's options. ```javascript const ctx = document.getElementById('myChart').getContext('2d'); const chart = new Chart(ctx, { type: 'bar', data: { labels: ['Q1', 'Q2', 'Q3', 'Q4'], datasets: [ { label: 'Product A', data: [12, 19, 3, 5] }, { label: 'Product B', data: [8, 15, 10, 8] } ] }, options: { plugins: { colorschemes: { scheme: 'brewer.Paired12' } } } }); ``` -------------------------------- ### Accessing Color Schemes Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/main-module.md Demonstrates how to access specific color schemes from the global Chart.colorschemes object after importing the plugin. ```javascript // After importing chartjs-plugin-colorschemes Chart.colorschemes.brewer.Paired12; // Returns: array of 12 hex colors Chart.colorschemes.office.Metro6; // Returns: array of 6 hex colors Chart.colorschemes.tableau.Tableau20; // Returns: array of 20 hex colors ``` -------------------------------- ### Run Tests and Generate Code Coverage Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md Execute all tests and generate a code coverage report. This helps in understanding which parts of the codebase are covered by tests. ```bash gulp test --coverage ``` -------------------------------- ### CommonJS Module Usage Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/main-module.md Shows how to use the plugin in a CommonJS environment by requiring the module and accessing the global Chart.colorschemes object. ```javascript // CommonJS require const plugin = require('chartjs-plugin-colorschemes'); // Chart.colorschemes is now available Chart.colorschemes.brewer.Paired12; ``` -------------------------------- ### Accessing Color Schemes Globally Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/README.md Illustrates how to access the color schemes object provided by the plugin globally after it has been imported. ```javascript Chart.colorschemes // Object with brewer, office, tableau schemes ``` -------------------------------- ### Importing All Schemes from a Category (ES6 Modules) Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Import all schemes from a category (e.g., brewer) using a namespace import and access them via the namespace. ```javascript import Chart from 'chart.js'; import 'chartjs-plugin-colorschemes'; import * as brewer from 'chartjs-plugin-colorschemes/src/colorschemes/colorschemes.brewer'; import * as office from 'chartjs-plugin-colorschemes/src/colorschemes/colorschemes.office'; const chart = new Chart(ctx, { options: { plugins: { colorschemes: { scheme: brewer.YlGn9 } } } }); ``` -------------------------------- ### Using Named Colors (CSS Support) Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Attempt to use named colors directly. This may not work reliably and hex codes are recommended. ```javascript const chart = new Chart(ctx, { type: 'bar', data: { /* ... */ }, options: { plugins: { colorschemes: { scheme: ['red', 'blue', 'green', 'yellow'] // May not work - use hex } } } }); ``` -------------------------------- ### Importing Specific Color Schemes in ES6 Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/README.md For smaller bundle sizes, import only the plugin core and specific color schemes you need. ```javascript // import the plugin core import 'chartjs-plugin-colorschemes/src/plugins/plugin.colorschemes'; // import a particular color scheme import { Aspect6 } from 'chartjs-plugin-colorschemes/src/colorschemes/colorschemes.office'; // ... options: { plugins: { colorschemes: { scheme: Aspect6 } } } //... ``` -------------------------------- ### Using Direct Color Arrays (ES6) Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/api-reference/colorschemes.md Import a specific color scheme array from the library and pass it directly to the plugin options. This allows for programmatic selection of schemes. ```javascript import { Paired12 } from 'chartjs-plugin-colorschemes/src/colorschemes/colorschemes.brewer'; const chart = new Chart(ctx, { type: 'bar', data: { /* ... */ }, options: { plugins: { colorschemes: { scheme: Paired12 } } } }); ``` -------------------------------- ### React Integration with react-chartjs-2 Source: https://github.com/nagix/chartjs-plugin-colorschemes/blob/master/_autodocs/examples.md Demonstrates integrating the color schemes plugin into a React component using react-chartjs-2. The plugin is imported and its configuration is passed via the options prop. ```jsx import React from 'react'; import { Bar } from 'react-chartjs-2'; import 'chartjs-plugin-colorschemes'; export const BarChart = () => { const data = { labels: ['Jan', 'Feb', 'Mar'], datasets: [ { label: 'Sales', data: [12, 19, 3] } ] }; const options = { plugins: { colorschemes: { scheme: 'brewer.Paired12' } } }; return