Skip to content

Commit

Permalink
serie dots top-bottom axes for two series
Browse files Browse the repository at this point in the history
  • Loading branch information
pdgago committed May 3, 2015
1 parent c9e587e commit 5c23c22
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 9 deletions.
17 changes: 15 additions & 2 deletions charicharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,20 @@ var p_axes = PClass.extend({
.attr('height', 1)
.attr('width', this.opts.fullWidth);

// this._renderXLabel('bottom');
if (this.data.length === 2) {
// Append top line indicator
model.el.append('circle')
.attr('cx', -this.opts.margin.left + 6)
.attr('cy', -11)
.attr('r', 4)
.style('fill', this.data[1].color);

model.el.append('circle')
.attr('cx', -this.opts.margin.left + 5)
.attr('cy', this.opts.height + 12)
.attr('r', 4)
.style('fill', this.data[0].color);
}
},

_renderBottom: function() {
Expand Down Expand Up @@ -599,7 +612,7 @@ var p_axes = PClass.extend({
.attr('class', 'label')
.attr('transform', h_getTranslate(orientation === 'left' ? -this.opts.margin.left :
this.opts.width + this.opts.margin.right, this.opts.yaxis.textMarginTop))
.attr('y', -10)
.attr('y', -12)
.attr('x', 0)
.attr('text-anchor', orientation === 'left' ? 'start' : 'end')
.text(label);
Expand Down
3 changes: 2 additions & 1 deletion charicharts.min.js

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions demo/charicharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,20 @@ var p_axes = PClass.extend({
.attr('height', 1)
.attr('width', this.opts.fullWidth);

// this._renderXLabel('bottom');
if (this.data.length === 2) {
// Append top line indicator
model.el.append('circle')
.attr('cx', -this.opts.margin.left + 6)
.attr('cy', -11)
.attr('r', 4)
.style('fill', this.data[1].color);

model.el.append('circle')
.attr('cx', -this.opts.margin.left + 5)
.attr('cy', this.opts.height + 12)
.attr('r', 4)
.style('fill', this.data[0].color);
}
},

_renderBottom: function() {
Expand Down Expand Up @@ -599,7 +612,7 @@ var p_axes = PClass.extend({
.attr('class', 'label')
.attr('transform', h_getTranslate(orientation === 'left' ? -this.opts.margin.left :
this.opts.width + this.opts.margin.right, this.opts.yaxis.textMarginTop))
.attr('y', -10)
.attr('y', -12)
.attr('x', 0)
.attr('text-anchor', orientation === 'left' ? 'start' : 'end')
.text(label);
Expand Down
4 changes: 2 additions & 2 deletions demo/simple-chart-date.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
var data = [{
id: 1005,
type: 'line',
values: [],
values: getData(10, 100, 200),
dots: true,
unit: 'Euros',
interpolation: 'step',
color: '#444'
},{
id: 10025,
type: 'line',
values: [],
values: getData(10, 100, 200),
dots: true,
unit: 'Euros',
interpolation: 'step',
Expand Down
17 changes: 15 additions & 2 deletions src/parts/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,20 @@ var p_axes = PClass.extend({
.attr('height', 1)
.attr('width', this.opts.fullWidth);

// this._renderXLabel('bottom');
if (this.data.length === 2) {
// Append top line indicator
model.el.append('circle')
.attr('cx', -this.opts.margin.left + 6)
.attr('cy', -11)
.attr('r', 4)
.style('fill', this.data[1].color);

model.el.append('circle')
.attr('cx', -this.opts.margin.left + 5)
.attr('cy', this.opts.height + 12)
.attr('r', 4)
.style('fill', this.data[0].color);
}
},

_renderBottom: function() {
Expand Down Expand Up @@ -202,7 +215,7 @@ var p_axes = PClass.extend({
.attr('class', 'label')
.attr('transform', h_getTranslate(orientation === 'left' ? -this.opts.margin.left :
this.opts.width + this.opts.margin.right, this.opts.yaxis.textMarginTop))
.attr('y', -10)
.attr('y', -12)
.attr('x', 0)
.attr('text-anchor', orientation === 'left' ? 'start' : 'end')
.text(label);
Expand Down

0 comments on commit 5c23c22

Please sign in to comment.