Permalink
Browse files

Merge remote-tracking branch 'origin/master' (fixes #695)

# Conflicts:
#	dist/metricsgraphics.min.js
  • Loading branch information...
1 parent aca3532 commit 8a73ca2abb8cc193924903ad2d98856b3b8b044d @almossawi almossawi committed Aug 18, 2016
Showing with 141 additions and 27 deletions.
  1. +20 −10 dist/metricsgraphics.js
  2. +9 −2 dist/metricsgraphics.min.js
  3. +89 −2 examples/charts/axes.htm
  4. +2 −2 examples/charts/experimental.htm
  5. +1 −1 index.js
  6. +17 −7 src/js/charts/bar.js
  7. +3 −3 src/js/charts/line.js
@@ -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);
}
}
@@ -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);
});
}
@@ -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();
@@ -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);
}
@@ -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,
Oops, something went wrong.
@@ -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'>
@@ -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'>
@@ -370,7 +371,6 @@
height:550,
width:300,
left:100,
- right:40,
target: '#bar-categorical-group'
})
View
@@ -1 +1 @@
-module.exports = require('./dist/metricsgraphics');
+module.exports = require('./dist/metricsgraphics')
View
@@ -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);
});
}
@@ -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();
@@ -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);
}
@@ -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,
@@ -531,9 +531,9 @@
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);
}
}

0 comments on commit 8a73ca2

Please sign in to comment.