├── .gitignore ├── tea.yaml ├── src └── chartingLibraryIntegration.js ├── LICENSE ├── package.json ├── test └── index.test.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories 2 | node_modules/ 3 | dist/ 4 | coverage/ 5 | .cache/ 6 | 7 | # Files 8 | .env 9 | .DS_Store -------------------------------------------------------------------------------- /tea.yaml: -------------------------------------------------------------------------------- 1 | # https://tea.xyz/what-is-this-file 2 | --- 3 | version: 1.0.0 4 | codeOwners: 5 | - '0x9BAac40A197bbb110ae5B2f31342D8d15D734832' 6 | - '0xbB0950cd2d231CcbA506F2DC36DAFcA9bC52496b' 7 | - '0xf118b7584A1f77b2D4397704c71534749316b331' 8 | - '0x1A37E2d6D13674b4ff79B034dEce828DF20f86C3' 9 | - '0xf1e00e72a1B534EdE8AcD02289bab0A83be6409a' 10 | - '0x5441A7ba94b79FAd113E57e2428E3CbdffBE5D15' 11 | - '0x8B97D5d8647208fde30485d1EF8F909313DD2Fbb' 12 | - '0x20DA7B48989cf143E47de142718a2EfBb9C47692' 13 | - '0x4B3940aA12ca60985392934e15E48Acffa6a631E' 14 | - '0xDE59f78B567d26Eee704d417c9e7F204bFAcf29e' 15 | - '0xB58571B098160a2F17Eec13B1437BC957412Bf1f' 16 | - '0xC4C902Ada8DB1dDae5e7641E4c392C1abF0b785A' 17 | quorum: 1 18 | -------------------------------------------------------------------------------- /src/chartingLibraryIntegration.js: -------------------------------------------------------------------------------- 1 | // chartingLibraryIntegration.js 2 | 3 | const Chart = require('chart.js'); 4 | 5 | /** 6 | * Function to integrate Chart.js library into the application. 7 | * @param {string} chartType - Type of chart to be rendered (e.g., 'line', 'bar', 'pie'). 8 | * @param {object} data - Data to be visualized on the chart. 9 | * @param {object} options - Options for configuring the chart (e.g., colors, labels, tooltips). 10 | * @returns {object} - Returns the chart instance. 11 | */ 12 | function integrateChartingLibrary(chartType, data, options) { 13 | // Create chart configuration based on provided type and options 14 | const chartConfig = { 15 | type: chartType, 16 | data: data, 17 | options: options 18 | }; 19 | 20 | // Render the chart on a canvas element 21 | // const ctx = document.createElement('canvas').getContext('2d'); 22 | // const chart = new Chart(ctx, chartConfig); 23 | 24 | // return chart; 25 | 26 | return chartConfig; 27 | } 28 | 29 | module.exports = integrateChartingLibrary; 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 ONE DIONYS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "onedionys-charting-library-integration", 3 | "version": "5.0.0", 4 | "description": "One Dionys (Charting Library Integration) - Functions for integrating graphics libraries such as Chart.js or D3.js into web applications.", 5 | "main": "src/chartingLibraryIntegration.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "mocha" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/onedionys/onedionys-charting-library-integration.git" 15 | }, 16 | "keywords": [ 17 | "onedionys", 18 | "tea", 19 | "package-manager", 20 | "charting-library-integration" 21 | ], 22 | "author": "One Dionys", 23 | "license": "ISC", 24 | "bugs": { 25 | "url": "https://github.com/onedionys/onedionys-charting-library-integration/issues" 26 | }, 27 | "homepage": "https://github.com/onedionys/onedionys-charting-library-integration#readme", 28 | "dependencies": { 29 | "@types/chai": "^4.3.12", 30 | "@types/mocha": "^10.0.6", 31 | "chai": "^5.1.0", 32 | "mocha": "^10.3.0" 33 | }, 34 | "devDependencies": { 35 | "chai": "^5.1.0", 36 | "mocha": "^10.3.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/index.test.js: -------------------------------------------------------------------------------- 1 | // test.js 2 | 3 | const assert = require('assert'); 4 | const integrateChartingLibrary = require('../src/chartingLibraryIntegration'); 5 | 6 | describe('Charting Library Integration', function () { 7 | it('should render a line chart correctly', function () { 8 | const data = [10, 20, 30, 40, 50]; 9 | const options = { title: 'Sample Line Chart' }; 10 | const chart = integrateChartingLibrary('line', data, options); 11 | assert.strictEqual(chart.type, 'line'); 12 | assert.deepStrictEqual(chart.data, data); 13 | assert.deepStrictEqual(chart.options, options); 14 | }); 15 | 16 | it('should render a bar chart correctly', function () { 17 | const data = [50, 40, 30, 20, 10]; 18 | const options = { title: 'Sample Bar Chart' }; 19 | const chart = integrateChartingLibrary('bar', data, options); 20 | assert.strictEqual(chart.type, 'bar'); 21 | assert.deepStrictEqual(chart.data, data); 22 | assert.deepStrictEqual(chart.options, options); 23 | }); 24 | 25 | it('should render a pie chart correctly', function () { 26 | const data = [20, 30, 50]; 27 | const options = { title: 'Sample Pie Chart' }; 28 | const chart = integrateChartingLibrary('pie', data, options); 29 | assert.strictEqual(chart.type, 'pie'); 30 | assert.deepStrictEqual(chart.data, data); 31 | assert.deepStrictEqual(chart.options, options); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
Functions for integrating graphics libraries such as Chart.js or D3.js into web applications. 💖
4 | 5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |