Skip to content

Commit

Permalink
Use rollup to manage builds (#2)
Browse files Browse the repository at this point in the history
Use rollup to generate esmodule and commonjs builds. In addition this PR updates the github actions to regenerate the builds and publish them to github pages. The documentation and README were also updated.
  • Loading branch information
jkanche committed Oct 25, 2023
1 parent 9cb705a commit 9ec2fc1
Show file tree
Hide file tree
Showing 13 changed files with 2,268 additions and 30 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
on:
push:
branches:
- main
on: [push]


name: Build documentation
Expand Down Expand Up @@ -29,11 +26,11 @@ jobs:
- name: Run JSDoc
run: npm run jsdoc

# - name: create builds
# run: yarn build
- name: create builds
run: npm run build

# - name: copy build to app
# run: cp -r dist/* app
- name: copy build to app
run: cp -r dist/* app

- name: copy docs to app
run: cp -r docs/built/* app/docs
Expand All @@ -42,6 +39,7 @@ jobs:
run: cp -r assets app/docs

- name: GH Pages Deployment
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
on: [push]

# on: [push]

name: Build and publish to NPM

jobs:
Expand All @@ -16,10 +14,10 @@ jobs:
registry-url: https://registry.npmjs.org/

- name: install dependencies
run: yarn install
run: npm install --include-dev

# - name: create builds
# run: yarn build
- name: create builds
run: npm run build

- name: Publish to NPM
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
.DS_Store
node_modules
dist
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app/*
assets/*
test/*
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=false
registry="https://registry.npmjs.org"
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
## Ridges.js

A JavaScript library to make ridge plots.
> A JavaScript library for generating ridgeline plots, providing options for both **horizontal** and **vertical** layouts.
This library combines the features of box plots and ridgeline plots into a unified visualization for each group. To use this library effectively, your input data should include summarized metrics.

![](assets/demo.png)

Install the package from [npm](https://www.npmjs.com/package/ridges.js),

```bash
npm install ridges.js
```

The library offers both horizontal and vertical layouts for creating ridge plots. To get started, choose your preferred layout and then instantiate a new visualization object. Customize the visualization state by configuring properties such as titles, selected metrics, the number of ticks, and more. Next, input your data, and render the plot in your desired dimensions!
To begin using Ridges.js, follow these steps:

1. Choose your preferred layout, either horizontal or vertical.
2. Instantiate a new visualization object.
3. Customize the visualization by configuring properties such as titles, selected metrics, the number of ticks, and more.
4. Provide your data.
5. Render the plot in your desired dimensions.

Here's an example:

```js
import { VerticalRidgePlot, HorizontalRidgePlot } from "ridges.js";
Expand All @@ -27,5 +39,22 @@ vridge.setInput(data);
vridge.render(300, 500);
```

### Data model

The data object is expected to contain **groups** as keys, and each `group` should have metrics for visualizing the boxes and ridges. Here's an example:

```js
const data = {
january: {
min: 1,
max: 20,
mean: 10,
median: 5,
quantiles: [1, 5, 9, 10], // box plot metrics
values: [1, 2, 5, 20, 15, 18], // for the histogram
}
}
```

Check out more examples in the [app directory](./app/)!

10 changes: 5 additions & 5 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<meta name="keywords" content="ridge plots, JavaScript">
<meta name="author" content="Jayaram Kancherla">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-color.v1.min.js"></script>
<script src="https://d3js.org/d3.v7.min.js"></script>
<!-- <script src="https://d3js.org/d3-color.v1.min.js"></script>
<script src="https://d3js.org/d3-interpolate.v1.min.js"></script>
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
<script src="https://d3js.org/d3-array.v3.min.js"></script>
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>-->
<!-- <script src="https://d3js.org/d3-array.v7.min.js"></script> -->
</head>

<body>
Expand All @@ -21,7 +21,7 @@ <H2>A simple ridgeline plot</H2>
<div class="ridgeline-horizontal"></div>

<script type="module">
import { VerticalRidgePlot, HorizontalRidgePlot } from "./src/index.js";
import { VerticalRidgePlot, HorizontalRidgePlot } from "./index.js";
import { data } from "./data.js";

console.log(data);
Expand Down
Binary file modified assets/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9ec2fc1

Please sign in to comment.