Skip to content

Commit 75fea92

Browse files
committedApr 5, 2017
fix tooltip display
1 parent 9adf5e9 commit 75fea92

11 files changed

+528
-473
lines changed
 

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 2.0.3 - 2017-04-05
4+
5+
- Fix tooltip position when we can scroll on the page
6+
37
### 2.0.2 - 2017-03-16
48

59
- Add CTRL+C shortcut to copy tooltip content.

‎dist/circos.js

+461-421
Large diffs are not rendered by default.

‎dist/circos.min.js

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎layout-conf.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./src/layout/conf')

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "circos",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "A d3js library to build circos graphs",
55
"main": "dist/circos.min.js",
66
"scripts": {

‎src/behaviors/tooltip.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
div.tooltip {
1+
div.circos-tooltip {
22
position: absolute;
33
text-align: center;
44
padding: 5px 10px;
55
background: #111111;
66
color: white;
77
border: 0px;
88
pointer-events: none;
9+
z-index: 1000;
910
}

‎src/circos.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import defaultsDeep from 'lodash/defaultsDeep'
22
import forEach from 'lodash/forEach'
33
import isArray from 'lodash/isArray'
4+
import map from 'lodash/map'
45
import {select} from 'd3-selection'
5-
import Layout from './layout'
6+
import Layout from './layout/index'
67
import render from './render'
78
import Text from './tracks/Text'
89
import Highlight from './tracks/Highlight'
@@ -26,10 +27,17 @@ class Core {
2627
this.tracks = {}
2728
this._layout = null
2829
this.conf = defaultsDeep(conf, defaultConf)
29-
this.svg = select(this.conf.container).append('svg')
30-
this.tip = select(this.conf.container).append('div')
31-
.attr('class', 'tooltip')
30+
const container = select(this.conf.container).append('div')
31+
.style('position', 'relative')
32+
this.svg = container.append('svg')
33+
if (select('body').select('.circos-tooltip').empty()) {
34+
this.tip = select('body').append('div')
35+
.attr('class', 'circos-tooltip')
3236
.style('opacity', 0)
37+
} else {
38+
this.tip = select('body').select('.circos-tooltip')
39+
}
40+
3341
this.clipboard = initClipboard(this.conf.container)
3442
}
3543

@@ -44,7 +52,7 @@ class Core {
4452
delete this.tracks[trackIds]
4553
} else if (isArray(trackIds)) {
4654
forEach(trackIds, function (trackId) {
47-
svg.select('.' + trackId).remove()
55+
this.svg.select('.' + trackId).remove()
4856
delete this.tracks[trackId]
4957
})
5058
} else {

‎src/layout/conf.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
export default {
2+
innerRadius: 250,
3+
outerRadius: 300,
4+
cornerRadius: 0,
5+
gap: 0.04, // in radian
6+
opacity: 1,
7+
labels: {
8+
position: 'center',
9+
display: true,
10+
size: 14,
11+
color: '#000',
12+
radialOffset: 20
13+
},
14+
ticks: {
15+
display: true,
16+
color: 'grey',
17+
spacing: 10000000,
18+
labels: true,
19+
labelSpacing: 10,
20+
labelSuffix: '',
21+
labelDenominator: 1,
22+
labelDisplay0: true,
23+
labelSize: 10,
24+
labelColor: '#000',
25+
labelFont: 'default',
26+
majorSpacing: 5,
27+
size: {
28+
minor: 2,
29+
major: 5
30+
}
31+
},
32+
onClick: null,
33+
onMouseOver: null,
34+
zIndex: 100
35+
}

‎src/layout.js ‎src/layout/index.js

+1-35
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,9 @@ import cloneDeep from 'lodash/cloneDeep'
22
import defaultsDeep from 'lodash/defaultsDeep'
33
import reduce from 'lodash/reduce'
44
import forEach from 'lodash/forEach'
5+
import defaultConf from './conf'
56

67
const logger = console
7-
const defaultConf = {
8-
innerRadius: 250,
9-
outerRadius: 300,
10-
cornerRadius: 0,
11-
gap: 0.04, // in radian
12-
opacity: 1,
13-
labels: {
14-
position: 'center',
15-
display: true,
16-
size: 14,
17-
color: '#000',
18-
radialOffset: 20
19-
},
20-
ticks: {
21-
display: true,
22-
color: 'grey',
23-
spacing: 10000000,
24-
labels: true,
25-
labelSpacing: 10,
26-
labelSuffix: '',
27-
labelDenominator: 1,
28-
labelDisplay0: true,
29-
labelSize: 10,
30-
labelColor: '#000',
31-
labelFont: 'default',
32-
majorSpacing: 5,
33-
size: {
34-
minor: 2,
35-
major: 5
36-
}
37-
},
38-
onClick: null,
39-
onMouseOver: null,
40-
zIndex: 100
41-
}
428

439
export default class Layout {
4410
constructor (conf, data) {
File renamed without changes.

‎src/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import forEach from 'lodash/forEach'
22
import sortBy from 'lodash/sortBy'
3-
import renderLayout from './render-layout'
3+
import renderLayout from './layout/render'
44

55
export default function render (ids = [], removeTracks, circos) {
66
const renderAll = ids.length === 0

0 commit comments

Comments
 (0)
Please sign in to comment.