Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' (fixes #695)
Browse files Browse the repository at this point in the history
# Conflicts:
#	dist/metricsgraphics.min.js
  • Loading branch information
almossawi committed Aug 18, 2016
1 parent aca3532 commit 8a73ca2
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 27 deletions.
30 changes: 20 additions & 10 deletions dist/metricsgraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -5028,9 +5028,9 @@ MG.button_layout = function(target) {

function mg_configure_aggregate_rollover(args, svg) {
var rect = svg.selectAll('.mg-rollover-rect rect');
if (args.data.filter(function(d) {
return d.length === 1; }).length > 0) {
rect.on('mouseover')(rect[0][0].__data__, 0);
var rect_first = rect.nodes()[0][0] || rect.nodes()[0];
if (args.data.filter(function(d) { return d.length === 1; }).length > 0) {
rect.on('mouseover')(rect_first.__data__, 0);
}
}

Expand Down Expand Up @@ -6117,20 +6117,24 @@ function mg_color_point_mouseover(args, elem, d) {

// barchart re-write.
function mg_targeted_legend(args) {
var labels;
var plot = '';
if (args.legend_target) {

var div = d3.select(args.legend_target).append('div').classed('mg-bar-target-legend', true);
var labels = args.categorical_variables;

if (args.orientation == 'horizontal') labels = args.scales.Y.domain()
else labels = args.scales.X.domain();

labels.forEach(function(label) {
var outer_span = div.append('span').classed('mg-bar-target-element', true);
outer_span.append('span')
.classed('mg-bar-target-legend-shape', true)
.style('color', args.scales.colorf(label))
.style('color', args.scales.COLOR(label))
.text('\u25FC ');
outer_span.append('span')
.classed('mg-bar-target-legend-text', true)
.text(label)
.text(label);

});
}
Expand All @@ -6139,11 +6143,18 @@ function mg_color_point_mouseover(args, elem, d) {
function legend_on_graph(svg, args) {
// draw each element at the top right
// get labels
var labels = args.scales.Y.domain();

var labels;
if (args.orientation=='horizontal') labels = args.scales.Y.domain()
else labels = args.scales.X.domain();

var lineCount = 0;
var lineHeight = 1.1;
var g = svg.append('g').classed("mg-bar-legend", true);
var textContainer = g.append('text');

//

textContainer
.selectAll('*')
.remove();
Expand Down Expand Up @@ -6567,8 +6578,7 @@ function mg_color_point_mouseover(args, elem, d) {
// return args.scalefns.ygroupf(d) + args.scalefns.yf(d) + args.scales.Y.rangeBand() * 3 / 4
// });
// }

if (args.legend && args.ygroup_accessor && args.color_accessor !== false && args.ygroup_accessor !== args.color_accessor) {
if (args.legend || (args.color_accessor !== null && args.ygroup_accessor !== args.color_accessor)) {
if (!args.legend_target) legend_on_graph(svg, args);
else mg_targeted_legend(args);
}
Expand Down Expand Up @@ -6813,7 +6823,7 @@ function mg_color_point_mouseover(args, elem, d) {
color_accessor: null,
color_type: 'category',
color_domain: null,
legend: true,
legend: false,
legend_target: null,
mouseover_align: 'right',
baseline_accessor: null,
Expand Down
11 changes: 9 additions & 2 deletions dist/metricsgraphics.min.js

Large diffs are not rendered by default.

91 changes: 89 additions & 2 deletions examples/charts/axes.htm
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,95 @@
});
});</code></pre>

</div>
</div>
</div>
</div>










<div class='row trunk-section'>
<div class='col-lg-7 text-center'>
<div class='row'>
<div class='col-lg-6 text-center' id='axis-pos-1'></div>
<div class='col-lg-6 text-center' id='axis-pos-2'></div>
</div>
<div class='row'>
<div class='col-lg-6 text-center' id='axis-pos-3'></div>
<div class='col-lg-6 text-center' id='axis-pos-4'></div>
</div>
</div>
<div class='col-lg-5'>
<div class='data-column'>
<a href='data/fake_users1.json'>data 1</a>,
<a href='data/brief-1.json'>data 2</a>
</div>

<pre><code class='javascript'>d3.json('data/brief-1.json', function(data) {
data = MG.convert.date(data, 'date');
var position = [['left', 'top'],['right', 'top'], ['left', 'bottom'], ['right', 'bottom']];
position.forEach(function(pos,i) {
console.log(pos,i)
var i = i+1;

MG.data_graphic({
title: "Axis Positions: " + pos[0] +', ' + pos[1],
description: "Set <i>x_axis_position: " + pos[1] + "</i> and <i>x_axis_position: " + pos[0] +"</i>.",
x_axis_position: pos[1],
y_axis_position: pos[0],
data: data,
decimals: 0,
left: pos[0] === 'right' ? 20 : 50,
right: pos[0] === 'left' ? 20 : 50,
top: pos[1] === 'bottom' ? 50 : 50,
bottom: pos[1] === 'top' ? 25 : 50,
target: '#axis-pos-'+i,
area: false
});
})
});</code></pre>

</div>
</div>


<script>
d3.json('data/brief-1.json', function(data) {
data = MG.convert.date(data, 'date');
var position = [['left', 'top'],['right', 'top'], ['left', 'bottom'], ['right', 'bottom']];
position.forEach(function(pos,i) {
var i = i+1;

MG.data_graphic({
title: "Axis Positions: " + pos[0] +', ' + pos[1],
description: "Set <i>x_axis_position: " + pos[1] + "</i> and <i>x_axis_position: " + pos[0] +"</i>.",
x_axis_position: pos[1],
y_axis_position: pos[0],
data: data,
decimals: 0,
left: pos[0] === 'right' ? 20 : 50,
right: pos[0] === 'left' ? 20 : 50,
top: pos[1] === 'bottom' ? 50 : 50,
bottom: pos[1] === 'top' ? 25 : 50,
target: '#axis-pos-'+i,
area: false
});
})
});
</script>









<div class='row trunk-section'>
<div class='col-lg-7 text-center'>
Expand Down
4 changes: 2 additions & 2 deletions examples/charts/experimental.htm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
</div>
<div class='row'>
<div class='col-lg-6 text-center' id='point-categorical-group'></div>
<div class='col-lg-6 text-center' id='bar-categorical-group'></div>
<div class='col-lg-6 text-center' id='bar-categorical-group'>
</div>

</div>
<div class='row'>
Expand Down Expand Up @@ -370,7 +371,6 @@
height:550,
width:300,
left:100,
right:40,
target: '#bar-categorical-group'
})

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/metricsgraphics');
module.exports = require('./dist/metricsgraphics')
24 changes: 17 additions & 7 deletions src/js/charts/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,24 @@

// barchart re-write.
function mg_targeted_legend(args) {
var labels;
var plot = '';
if (args.legend_target) {

var div = d3.select(args.legend_target).append('div').classed('mg-bar-target-legend', true);
var labels = args.categorical_variables;

if (args.orientation == 'horizontal') labels = args.scales.Y.domain()
else labels = args.scales.X.domain();

labels.forEach(function(label) {
var outer_span = div.append('span').classed('mg-bar-target-element', true);
outer_span.append('span')
.classed('mg-bar-target-legend-shape', true)
.style('color', args.scales.colorf(label))
.style('color', args.scales.COLOR(label))
.text('\u25FC ');
outer_span.append('span')
.classed('mg-bar-target-legend-text', true)
.text(label)
.text(label);

});
}
Expand All @@ -85,11 +89,18 @@
function legend_on_graph(svg, args) {
// draw each element at the top right
// get labels
var labels = args.scales.Y.domain();

var labels;
if (args.orientation=='horizontal') labels = args.scales.Y.domain()
else labels = args.scales.X.domain();

var lineCount = 0;
var lineHeight = 1.1;
var g = svg.append('g').classed("mg-bar-legend", true);
var textContainer = g.append('text');

//

textContainer
.selectAll('*')
.remove();
Expand Down Expand Up @@ -513,8 +524,7 @@
// return args.scalefns.ygroupf(d) + args.scalefns.yf(d) + args.scales.Y.rangeBand() * 3 / 4
// });
// }

if (args.legend && args.ygroup_accessor && args.color_accessor !== false && args.ygroup_accessor !== args.color_accessor) {
if (args.legend || (args.color_accessor !== null && args.ygroup_accessor !== args.color_accessor)) {
if (!args.legend_target) legend_on_graph(svg, args);
else mg_targeted_legend(args);
}
Expand Down Expand Up @@ -759,7 +769,7 @@
color_accessor: null,
color_type: 'category',
color_domain: null,
legend: true,
legend: false,
legend_target: null,
mouseover_align: 'right',
baseline_accessor: null,
Expand Down
6 changes: 3 additions & 3 deletions src/js/charts/line.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a73ca2

Please sign in to comment.