Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson committed May 25, 2023
1 parent ace1856 commit 668421c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
44 changes: 34 additions & 10 deletions docs/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Taxonium is now available as a React component. There are a few different ways y

## Basic HTML

```
```js
<body>
<div id="root"></div>

Expand All @@ -18,13 +18,38 @@ Taxonium is now available as a React component. There are a few different ways y
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>

<!-- Include Taxonium Component -->
<script src="https://unpkg.com/taxonium-component@0.0.0/dist/taxonium-component.umd.js"></script>
<script src="https://unpkg.com/taxonium-component"></script>
<script>
const MyComponent = TaxoniumComponent.Taxonium;
const nwk = `((A:0.1,B:0.2):0.3,(C:0.4,D:0.5):0.6);`;

const metadata_text =
`Node,Name,Species
A,Bob,Cow
B,Jim,Cow
C,Joe,Fish
D,John,Fish`;

// Metadata is optional
const metadata = {
filename: "test.csv",
data: metadata_text,
status: "loaded",
filetype: "meta_csv",
};

const sourceData = {
status: "loaded",
filename: "test.nwk",
data: nwk,
filetype: "nwk",
metadata: metadata,
};
</script>

<script>
ReactDOM.render(
React.createElement(MyComponent, { backendUrl: 'https://api.cov2tree.org'}),
React.createElement(Taxonium, { sourceData: sourceData}),
document.getElementById('root')
);
</script>
Expand All @@ -47,7 +72,7 @@ yarn add taxonium-component

### Import and use Taxonium Component in your React jsx

```
```js
import Taxonium from 'taxonium-component';

const App = () => {
Expand All @@ -65,24 +90,23 @@ In either case the following properties are available.
| ---------- | --------------------- | ------- | -------------------------------------------------------------- |
| backendUrl | string | None | (Optional) a backend to connect to |
| sourceData | Javascript dictionary | None | (Optional) Tree / metadata to load locally (see section below) |
| configDict | Javascript dictionary | None | (Optional) configuration |
| configDict | Javascript dictionary | None | (Optional) configuration (see [advanced](./advanced.md)) |

## sourceData

The `sourceData` property allows you to load a tree and metadata directly into the component.

Examples:

```
```js
sourceData: {
status: "url_supplied",
filename:
"https://cov2tree.nyc3.cdn.digitaloceanspaces.com/ncbi/special_filtered.jsonl.gz",
filetype: "jsonl",
}
```

```
```js
sourceData: {
status: "loaded",
filename: "test.nwk",
Expand Down
4 changes: 1 addition & 3 deletions taxonium_component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ If you're working with basic HTML, you can include the Taxonium component using
</script>

<script>
const MyComponent = TaxoniumComponent.Taxonium;
ReactDOM.render(
React.createElement(MyComponent, { sourceData: sourceData}),
React.createElement(Taxonium, { sourceData: sourceData}),
document.getElementById('root')
);
</script>
Expand Down

1 comment on commit 668421c

@vercel
Copy link

@vercel vercel bot commented on 668421c May 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.