Skip to content

Commit

Permalink
Embed rc-spider lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Bridge Tools committed Mar 8, 2021
1 parent 01be605 commit 9d09f2b
Show file tree
Hide file tree
Showing 70 changed files with 4,220 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"es6": true
},
"parser": "babel-eslint",
"ignorePatterns": ["public", ".cache", "node_modules"],
"ignorePatterns": ["public", ".cache", "node_modules", "src/libs"],
"rules": {
"strict": 0,
"no-console": 1,
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
public/
.cache/
node_modules/
node_modules/
src/libs/
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"postcss-text-remove-gap": "^1.1.1",
"prismjs": "^1.20.0",
"prop-types": "^15.7.2",
"rc-spider": "git+ssh://[email protected]/intergalactico/spider.git#master",
"react": "^16.8.6",
"react-calendly": "^1.3.0",
"react-children-utilities": "^2.1.6",
Expand Down
2 changes: 1 addition & 1 deletion src/components/PatternJourney/PatternJourney.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from "react";

import styled from "styled-components";

import Spider from "../../libs/rc-spider";
import theme from "../theme";
import data from "./PatternJourney.data.js";
import Spider from "rc-spider";
import FaClose from "react-icons/lib/fa/close";
import breakpoint from "styled-components-breakpoint";

Expand Down
9 changes: 9 additions & 0 deletions src/libs/rc-spider/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*.{js,jsx,css}]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions src/libs/rc-spider/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples/
24 changes: 24 additions & 0 deletions src/libs/rc-spider/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*.iml
*.log
.idea
.ipr
.iws
*~
~*
*.diff
*.patch
*.bak
.DS_Store
Thumbs.db
.project
.*proj
.svn
*.swp
*.swo
*.pyc
*.pyo
node_modules
.cache
*.css
build
coverage
38 changes: 38 additions & 0 deletions src/libs/rc-spider/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
language: node_js

sudo: false

notifications:
email:
- [email protected]

node_js:
- 5.4.1

before_install:
- |
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|examples))/'
then
echo "Only docs were updated, stopping build process."
exit
fi
npm install [email protected] -g
phantomjs --version
script:
- |
if [ "$TEST_TYPE" = test ]; then
npm test
else
npm run $TEST_TYPE
fi
env:
matrix:
- TEST_TYPE=lint
- TEST_TYPE=test
- TEST_TYPE=coverage
- TEST_TYPE=saucelabs


matrix:
allow_failures:
- env: "TEST_TYPE=saucelabs"
21 changes: 21 additions & 0 deletions src/libs/rc-spider/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## v0.0.8
* `network` layout
## v0.0.7
* `mindNode` example add

### v0.0.5
* `Text` element now supported setting `alignment` props (left|center|right) to set text alignment.

* `transform` and `projection` prop on `<Spider />` component will effect whole graph but node only.

* to set `transform` or `projection` prop of node, set `transform` or `projection` prop of `<Node />` component directly,

or set `NodeTransform` or `NodeProjection` attribute of `<Spider />`


### v0.0.4
using tidier drawing algorithm to draw tree

### v0.0.3

tree-layout supported.
100 changes: 100 additions & 0 deletions src/libs/rc-spider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# rc-spider
---

React Spider Component

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![gemnasium deps][gemnasium-image]][gemnasium-url]
[![npm download][download-image]][download-url]

[npm-image]: http://img.shields.io/npm/v/rc-spider.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-spider
[travis-image]: https://img.shields.io/travis/react-component/spider.svg?style=flat-square
[travis-url]: https://travis-ci.org/react-component/spider
[coveralls-image]: https://img.shields.io/coveralls/react-component/spider.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/react-component/spider?branch=master
[gemnasium-image]: http://img.shields.io/gemnasium/react-component/spider.svg?style=flat-square
[gemnasium-url]: https://gemnasium.com/react-component/spider
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/rc-spider.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-spider

## Screenshots

<img src="https://img.alicdn.com/tps/TB1NVsALVXXXXXZaXXXXXXXXXXX-1620-1334.jpg" width="288"/>
<img src="https://os.alipayobjects.com/rmsportal/ivIBcNVOuJHpgPx.png" width="288" />

## Development

```
npm install
npm start
```

## Example

http://localhost:8000/examples/


online example: http://react-component.github.io/spider/


## install


[![rc-spider](https://nodei.co/npm/rc-spider.png)](https://npmjs.org/package/rc-spider)


## Usage

```js
var Spider = require('rc-spider');
var React = require('react');
React.render(<Spider />, container);
```

## API

### props

<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>className</td>
<td>String</td>
<td></td>
<td>additional css class of root dom node</td>
</tr>
</tbody>
</table>


## Test Case

```
npm test
npm run chrome-test
```

## Coverage

```
npm run coverage
```

open coverage/ dir

## License

rc-spider is released under the MIT license.
1 change: 1 addition & 0 deletions src/libs/rc-spider/examples/cluster.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
placeholder
53 changes: 53 additions & 0 deletions src/libs/rc-spider/examples/cluster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'normalize.css';
import Spider from 'rc-spider';
import React from 'react';
import ReactDOM from 'react-dom';

const width = 1280;
const height = 800;
const rx = width / 2;
const ry = height / 2;

const { Node, Circle, Text, Link } = Spider.Shape;

function onClick(d, e) {
console.log('>> onClick', this);
}

function nodeCreator(data) {
return (<Node width="3.5" height="3.5" >
<Circle onClick={onClick} />
<Text transform={data.x < 180 ? null: new Spider.Transform().rotate(180)}
offset={data.x < 180 ? [8, 3] : [-8 , 3]}
alignment={data.x < 180 ? 'left' : 'right'}>
{data.name}
</Text>
</Node>);
}

function projection (d) {
return [d.y, d.x / 180 * Math.PI]
}
function radial (data) {
var d = projection.apply(this, arguments), r = d[0], a = d[1] - Math.PI / 2;
return [ r * Math.cos(a), r * Math.sin(a) ];
}

function linkCreator (data) {
return <Link projection={radial} data={data}/>;
}

const data = new Request('./flare.json');
fetch(data).then(response => response.json())
.then(response => {
const tree = response;
const cluster = Spider.layout.cluster().size([360, ry - 120]);
const data = cluster.data(tree);
ReactDOM.render(<Spider width={width} height={height} dataSource={data}
offset={[rx, ry]}
nodeTransform={d => new Spider.Transform().rotate(d.x - 90).translate(d.y)}
nodeCreator={nodeCreator}
linkCreator={linkCreator}
/>, document.getElementById('__react-content'));
});

Loading

0 comments on commit 9d09f2b

Please sign in to comment.