diff --git a/README.md b/README.md
index a8948b8..18011ee 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,71 @@
-# Template: SolidJS Library
+# μPlot Solid
-Template for [SolidJS](https://www.solidjs.com/) library package. Bundling of the library is managed by [tsup](https://tsup.egoist.dev/).
+Solid wrapper around [μPlot](https://github.com/leeoniya/uPlot?tab=readme-ov-file#-%CE%BCplot) which is a small, fast and performant 2D canvas based chart for time series, lines, areas, ohlc & bars. It exposes the μPlot API in a fully typed, declarative JSX format and does the work to make the μPlot experience as reactive as possible.
-Other things configured include:
+Once a μPlot instance is made, the component will **not** recreate a new instance even if the `data` or `size` of the chart updates reactively. However, it will create a new chart instance if any other options are reactively updated when using it (e.g. `series`, `hooks`, `plugins`, etc.).
-- Bun (for dependency management and running scripts)
-- TypeScript
-- ESLint / Prettier
-- Solid Testing Library + Vitest (for testing)
-- GitHub Actions (for all CI/CD)
+## Installing
+
+```bash
+npm install uplot uplot-solid
+pnpm add uplot uplot-solid
+yarn add uplot uplot-solid
+bun add uplot uplot-solid
+```
+
+## Overview
+
+If you are new to μPlot, here is a quick breakdown of some things using a simple example plot:
+
+```tsx
+
+```
+
+The above is the minimum of what you need to get a chart on screen given you have filled in the data. The expected format of `data` is a 2D array where the first array is the dataset for the x-series of the plot. The `series` list follows the same ordering being a list of config objects where the first object applies to the x-series and the rest to the y-series. μPlot supports a single x-series and all the y-series share the same x-series data. There are many more fields within the series struct that you can configure to tailor the display of the series data to your liking.
+
+Here are some other key options within the API to familiarize yourself with:
+
+- `hooks`: An object structure exposing key events that occur within μPlot. Every event hook accepts an **array of callbacks** allowing you to have discrete units of work that occur within a single event.
+- `plugins`: A **plugin** is used to extend or modify the behavior of the chart by injecting custom functionality. You can hook into the various lifecycle events (the very same ones exposed from the `hooks` property) and add custom behavior, such as drawing on the canvas, adding custom controls, tooltips, interactions, or integrating with external libraries.
+
+### Why Use Plugins Instead of Hooks?
+
+In a nutshell, separation of concerns. Here are some points:
+
+- **Customization**: Add custom drawings (like annotations, lines, or custom tooltips).
+- **Modularity**: Keep the core logic of the chart clean and separate from specific custom behavior.
+- **Reusability**: Create reusable plugins that can be applied across multiple uPlot instances with consistent functionality.
+- **Extensibility**: Augment the chart with additional features (e.g., zoom controls, data overlays).
+
+### Demos
+
+Be sure to check out the [μPlot demos](https://leeoniya.github.io/uPlot/demos/index.html) to see the many kinds of different charts you can create. The code for the demos can be found [here](https://github.com/leeoniya/uPlot/tree/master/demos).
+
+Over time, I will try to add example demos using this library to showcase some simple and more complex examples (e.g. creating custom tooltips either via `plugins` or using Solid directly)
## Getting Started
diff --git a/bun.lockb b/bun.lockb
index c25dc32..4b02299 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/package.json b/package.json
index 75fa323..3e2485d 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,24 @@
{
- "name": "template-solidjs-library",
- "version": "0.0.0",
- "description": "Template for SolidJS library using tsup for bundling. Configured with Bun, NVM, TypeScript, ESLint, Prettier, Vitest, and GHA",
+ "name": "uplot-solid",
+ "version": "1.0.0",
+ "description": "Solid wrapper for μPlot",
"type": "module",
+ "author": "Daniel Sanchez ",
+ "license": "MIT",
+ "homepage": "https://github.com/thedanchez/uplot-solid#readme",
+ "bugs": {
+ "url": "https://github.com/thedanchez/uplot-solid/issues"
+ },
+ "files": [
+ "dist"
+ ],
+ "keywords": [
+ "uPlot",
+ "Solid",
+ "SolidJS",
+ "charts",
+ "plot"
+ ],
"scripts": {
"build": "tsup",
"build:watch": "tsup --watch",
@@ -17,7 +33,6 @@
"test:cov": "vitest run --coverage",
"typecheck": "tsc --noEmit"
},
- "license": "MIT",
"devDependencies": {
"@solidjs/testing-library": "^0.8.10",
"@testing-library/jest-dom": "^6.5.0",
@@ -25,19 +40,35 @@
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vitest/coverage-istanbul": "^2.1.1",
+ "esbuild-css-modules-plugin": "^3.1.2",
"eslint": "^8.57.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-solid": "^0.14.3",
"jsdom": "^25.0.1",
"prettier": "^3.3.3",
+ "solid-js": "^1.9.1",
"tsup": "^8.3.0",
"tsup-preset-solid": "^2.2.0",
"typescript": "^5.6.2",
+ "uplot": "^1.6.31",
"vite": "^5.4.8",
"vite-plugin-solid": "^2.10.2",
"vitest": "^2.1.1"
},
"peerDependencies": {
- "solid-js": ">=1.8.0"
- }
+ "solid-js": ">=1.8.0",
+ "uplot": ">=1.6.31"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "browser": {},
+ "exports": {
+ "solid": "./dist/index.jsx",
+ "import": {
+ "types": "./dist/index.d.ts",
+ "default": "./dist/index.js"
+ }
+ },
+ "typesVersions": {}
}
diff --git a/playground/App.tsx b/playground/App.tsx
index 0bbca41..4b866cf 100644
--- a/playground/App.tsx
+++ b/playground/App.tsx
@@ -1,61 +1,99 @@
-import { createSignal, For } from "solid-js";
-import { createStore } from "solid-js/store";
+import { createSignal } from "solid-js";
-type Todo = { id: number; text: string; completed: boolean };
+import UplotSolid from "../dist";
+import fakeData from "./resource/uplot_fake_data.json";
+
+const isNil = (value: unknown): value is null | undefined => value === null || value === undefined;
export const App = () => {
- let input!: HTMLInputElement;
+ const [size, setSize] = createSignal({ width: 1000, height: 300 });
+ const [position, setPosition] = createSignal({ left: 0, top: 0 });
+ const [content, setContent] = createSignal("");
- const [count, setCount] = createSignal(0);
- const [todos, setTodos] = createStore([]);
+ const alignedData = [fakeData.time, fakeData.y_series_1, fakeData.y_series_2] as uPlot.AlignedData;
- const addTodo = (text: string) => {
- setTodos(todos.length, { id: todos.length, text, completed: false });
- };
+ return (
+