-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
jelly.line().container('#jelly-container') | ||
.data([ | ||
{category:'AAA', x: 1000, y: 10},{category:'AAA', x: 2000, y: 20}, | ||
{category:'AAA', x: 3000, y: 30},{category:'AAA', x: 4000, y: 40}, | ||
{category:'AAA', x: 1000, y: 50},{category:'AAA', x: 2000, y: 30}, | ||
{category:'AAA', x: 3000, y: 40},{category:'AAA', x: 4000, y: 100}, | ||
{category:'BBB', x: 1000, y: 80},{category:'BBB', x: 2000, y: 60}, | ||
{category:'BBB', x: 3000, y: 50},{category:'BBB', x: 4000, y: 70}, | ||
{category:'BBB', x: 1000, y: 20},{category:'BBB', x: 2000, y: 60}, | ||
{category:'BBB', x: 3000, y: 50},{category:'BBB', x: 4000, y: 60} | ||
]).dimensions([ | ||
{ | ||
field: 'x', | ||
order: 'ascending' | ||
}, { | ||
field: 'category', | ||
order: 'descending' | ||
}]) | ||
.measures({field:'y', op:'mean'}) | ||
.stacked(true) | ||
.point(true) | ||
.shape('area').areaGradient(true) | ||
.axis('x').axis({"target":"y","titleOrient":"right"}) | ||
.point({'type':'fill'}) | ||
.fixLine(65) | ||
.legend(true) | ||
.multiTooltip(true) | ||
.render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
`.fixLine(50)` generate fixed horizonal line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {attrFunc} from '../../modules/util'; | ||
|
||
const _attrs = { | ||
fixLine: false | ||
} | ||
|
||
const fixLineMixin = Base => { | ||
/** | ||
* adds FitLine features | ||
* @mixin FitLineMixin | ||
*/ | ||
let FitLineMixin = class extends Base { | ||
constructor() { | ||
super(); | ||
this.setAttrs(_attrs); | ||
} | ||
} | ||
/** | ||
* If fixLine is specified value, it draw horizon fixed line. | ||
* @function | ||
* @example | ||
* line.fixLine(50) | ||
* @param {number, boolean} [fixLine=false] If is not false, drawn fixed line. | ||
* @return {fixLine|Line} | ||
*/ | ||
FitLineMixin.prototype.fixLine = attrFunc('fixLine'); | ||
return FitLineMixin; | ||
} | ||
|
||
export default fixLineMixin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {transition} from 'd3'; | ||
import {className} from '../../modules/util'; | ||
|
||
const fixLineColor = '#43cdef'; | ||
export default function() { | ||
const canvas = this.__execs__.canvas; | ||
const scale = this.__execs__.scale; | ||
const fixLineValue = this.fixLine() | ||
const trans = transition().duration(this.transition().duration).delay(this.transition().delay); | ||
let fixLineG = canvas.selectAll(className('fix-line-g', true)); | ||
if (!fixLineValue) { | ||
if (!fixLineG.empty()) canvas.select(className('fix-line-g', true)).remove(); | ||
return; | ||
} | ||
|
||
if (fixLineG.empty()) { | ||
fixLineG = canvas.append('g').attr('class', className('fix-line-g')) | ||
//.attr('clip-path', `url(#${canvas.selectAll(className('canvas-g-clip-path', true)).attr('id')}`); | ||
} | ||
|
||
let xValues = scale.x.domain(); | ||
let yValues = [[fixLineValue,fixLineValue]] | ||
|
||
fixLineG.datum(yValues); | ||
|
||
let fixLine = fixLineG.selectAll(className('fix-line', true)) | ||
.data(d => d); | ||
fixLine.exit().remove(); | ||
let fixLineEnter = fixLine.enter().append('line') | ||
.attr('class', className('fix-line')) | ||
.style('fill', 'none').style('stroke', fixLineColor) | ||
.style('stroke-width', 2) | ||
.attr('opacity', 0.8) | ||
.attr('x1', scale.x(xValues[0])) | ||
.attr('x2', scale.x(xValues[1])) | ||
.attr('y1', d => (d.scale ? d.scale : scale.y).range()[0]) | ||
.attr('y2', d => (d.scale ? d.scale : scale.y).range()[0]); | ||
fixLine = fixLineEnter.merge(fixLine); | ||
fixLine.transition(trans) | ||
.attr('x1', scale.x.range()[0], scale.x(xValues[0])) | ||
.attr('x2', scale.x(xValues[1])) | ||
.attr('y1', d => (d.scale ? d.scale : scale.y)(d[0])) | ||
.attr('y2', d => (d.scale ? d.scale : scale.y)(d[1])); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters