Skip to content

Commit 1dbace8

Browse files
authored
Merge pull request #122 from Makanz/feature/3.0.2
Feature/3.0.2
2 parents 6b54970 + 51c18dc commit 1dbace8

File tree

5 files changed

+89
-4
lines changed

5 files changed

+89
-4
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Chart.js Plugin Trendline — Copilot Instructions
1+
# Chart.js Plugin Trendline — Agent Instructions
22

33
This plugin adds trendline support to Chart.js charts. It fits a linear regression model to datasets and draws trendlines over bar or line charts.
44

CLAUDE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Chart.js plugin that adds linear trendline support to charts. It fits regression models to datasets and draws trendlines over bar, line, and scatter charts.
8+
9+
## Development Commands
10+
11+
- `pnpm run build` - Build the minified plugin using webpack
12+
- `pnpm test` - Run Jest tests for all components
13+
14+
## Architecture
15+
16+
The plugin follows a modular structure:
17+
18+
- **Entry Point**: `src/index.js` - Auto-registers plugin globally and exports for manual registration
19+
- **Core**: `src/core/plugin.js` - Main plugin lifecycle integration with Chart.js hooks (`afterDatasetsDraw`, `beforeInit`)
20+
- **Components**: `src/components/` - Rendering logic for trendlines and labels
21+
- **Utilities**: `src/utils/` - Math calculations (`lineFitter.js`) and drawing helpers (`drawing.js`)
22+
23+
## Key Implementation Details
24+
25+
- Plugin integrates with Chart.js v4+ lifecycle using `afterDatasetsDraw` hook
26+
- Trendlines are drawn after datasets to appear on top
27+
- Dataset ordering is handled via `order` property (0-order datasets draw last)
28+
- Configuration is added to datasets via `trendlineLinear` property
29+
- Supports projection mode, custom styling, and labels with legends
30+
31+
## Testing
32+
33+
All components have corresponding `.test.js` files using Jest. Uses `jest-canvas-mock` for Canvas API mocking.
34+
35+
## Coding Standards
36+
37+
- Use modern JavaScript (ES6+)
38+
- 2-space indentation
39+
- JSDoc for public methods (Google style)
40+
- Descriptive naming without abbreviations
41+
- Ensure Chart.js v4+ compatibility
42+
43+
## Chart Type Support
44+
45+
Currently supports: bar, line, scatter charts

GEMINI.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Chart.js Plugin Trendline — Agent Instructions
2+
3+
This plugin adds trendline support to Chart.js charts. It fits a linear regression model to datasets and draws trendlines over bar or line charts.
4+
5+
## Project Structure
6+
7+
- Root:
8+
- `package.json`, `webpack.config.js`, `example/*.html`
9+
- Source (`src/`):
10+
- `index.js` — Entry point
11+
- `components/` — Rendering logic (`label.js`, `trendline.js`)
12+
- `core/` — Plugin definition (`plugin.js`)
13+
- `utils/` — Math and drawing helpers (`drawing.js`, `lineFitter.js`)
14+
15+
## Coding Guidelines
16+
17+
1. Use modern JavaScript (ES6+)
18+
2. Indent with 2 spaces
19+
3. Use JSDoc for public methods (Google style)
20+
4. Ensure compatibility with Chart.js v4+
21+
5. Name files/functions descriptively (no abbreviations)
22+
23+
## File Notes
24+
25+
- `plugin.js`: Main plugin lifecycle integration
26+
- `trendline.js`: Handles drawing trendlines
27+
- `lineFitter.js`: Performs regression math
28+
- `example/*.html`: Demo charts — manually verify after changes
29+
30+
## Workflow Tips
31+
32+
1. Changes to `plugin.js` should align with Chart.js plugin lifecycle (e.g., `afterDatasetsDraw`)
33+
2. If editing `trendline.js`, test with multiple chart types
34+
3. Validate rendering via example HTMLs after code updates
35+
4. Run linter and formatter before commit (see `.eslintrc.js` if present)
36+
37+
## Restrictions
38+
39+
- Do not modify build config unless changing build behavior
40+
- Do not auto-generate example files

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chartjs-plugin-trendline",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "Trendline for Chart.js",
55
"main": "src/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)