Permalink
Browse files

Issue #649

  • Loading branch information...
1 parent b9e956d commit a62495b930d8016275fbfbae2944f03d9b78ee5d @almossawi almossawi committed Jul 8, 2016
View
@@ -5,8 +5,7 @@
"dist/metricsgraphics.css"
],
"dependencies": {
- "jquery": ">=1.11.1",
- "d3": ">=3.4.8"
+ "d3": ">=4"
},
"ignore": [
".DS_Store",
@@ -86,6 +86,12 @@ text.mg-barplot-group-label {
font-size: 1.2rem;
}
+.mg-header .mg-warning {
+ fill: #ccc;
+ font-family: FontAwesome;
+ font-size: 1.2rem;
+}
+
.mg-points circle {
opacity: 0.65;
}
@@ -897,7 +897,7 @@ function chart_title(args) {
.text(args.title);
//show and activate the description icon if we have a description
- if (args.show_tooltips && args.description) {
+ if (args.show_tooltips && args.description && typeof jQuery !== 'undefined') {
chartTitle.append('tspan')
.attr('class', 'mg-chart-description')
.attr('dx', '0.3em')
@@ -931,6 +931,8 @@ function chart_title(args) {
}
}, 120);
});
+ } else if (args.show_tooltips && args.description && typeof jQuery === 'undefined') {
+ args.error = 'In order to enable tooltips, please make sure you include jQuery.';
}
}
@@ -7671,15 +7673,17 @@ function scaffold(args) {
// call this to add a warning icon to a graph and log an error to the console
function error(args) {
- console.log('ERROR : ', args.target, ' : ', args.error);
+ console.error('ERROR : ', args.target, ' : ', args.error);
d3.select(args.target).select('.mg-chart-title')
- .append('i')
- .attr('class', 'fa fa-x fa-exclamation-circle warning');
+ .append('tspan')
+ .attr('class', 'fa fa-x fa-exclamation-circle mg-warning')
+ .attr('dx', '0.3em')
+ .text('\uf06a');
}
function internal_error(args) {
- console.log('INTERNAL ERROR : ', args.target, ' : ', args.internal_error);
+ console.error('INTERNAL ERROR : ', args.target, ' : ', args.internal_error);
}
MG.error = error;
Oops, something went wrong.
@@ -22,7 +22,7 @@
<link href='../dist/metricsgraphics.css' rel='stylesheet' type='text/css'>
<link href='css/metricsgraphics-demo.css' rel='stylesheet' type='text/css'>
- <script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
+
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="js/lib/ace.js" charset="utf-8"></script>
@@ -224,7 +224,7 @@
+ 'MG.data_graphic({\n'
+ ' title: "UFO Sightings",\n'
+ ' description: "Yearly UFO sightings from 1945 to 2010.",\n'
- + ' data: JSON.parse($(\'.data textarea\').val()),\n'
+ + ' data: JSON.parse(document.querySelector(\'.data textarea\').value),\n'
+ ' markers: [{\'year\': 1964, \'label\': \'"The Creeping Terror" released\'}],\n'
+ ' width: 400,\n'
+ ' height: 250,\n'
@@ -236,14 +236,15 @@
var editor = ace.edit("editor");
editor.getSession().setMode("ace/mode/javascript");
editor.setValue(default_call);
- editor.gotoLine(1);editor.setHighlightActiveLine(false);
+ editor.gotoLine(1);
+ editor.setHighlightActiveLine(false);
d3.json('data/ufo-sightings.json', function(data) {
- $('.data textarea').val(JSON.stringify(data, null, 2));
+ document.querySelector('.data textarea').value = JSON.stringify(data, null, 2);
eval(editor.getValue());
})
- $('.update').on('click', function() {
+ d3.select('.update').on('click', function() {
eval(editor.getValue());
})
</script>
View
@@ -33,7 +33,6 @@
},
"homepage": "http://metricsgraphicsjs.org",
"dependencies": {
- "jquery": ">=1.11.1",
"d3": ">=4"
},
"devDependencies": {
@@ -20,7 +20,7 @@ function chart_title(args) {
.text(args.title);
//show and activate the description icon if we have a description
- if (args.show_tooltips && args.description) {
+ if (args.show_tooltips && args.description && typeof jQuery !== 'undefined') {
chartTitle.append('tspan')
.attr('class', 'mg-chart-description')
.attr('dx', '0.3em')
@@ -54,6 +54,8 @@ function chart_title(args) {
}
}, 120);
});
+ } else if (args.show_tooltips && args.description && typeof jQuery === 'undefined') {
+ args.error = 'In order to enable tooltips, please make sure you include jQuery.';
}
}
View
@@ -1,14 +1,16 @@
// call this to add a warning icon to a graph and log an error to the console
function error(args) {
- console.log('ERROR : ', args.target, ' : ', args.error);
+ console.error('ERROR : ', args.target, ' : ', args.error);
d3.select(args.target).select('.mg-chart-title')
- .append('i')
- .attr('class', 'fa fa-x fa-exclamation-circle warning');
+ .append('tspan')
+ .attr('class', 'fa fa-x fa-exclamation-circle mg-warning')
+ .attr('dx', '0.3em')
+ .text('\uf06a');
}
function internal_error(args) {
- console.log('INTERNAL ERROR : ', args.target, ' : ', args.internal_error);
+ console.error('INTERNAL ERROR : ', args.target, ' : ', args.internal_error);
}
MG.error = error;
@@ -74,7 +74,7 @@ test('When an error is set, we get an exclamation icon', function() {
};
MG.data_graphic(params);
- ok(document.querySelector('.mg-chart-title .warning'), 'Error icon exists');
+ ok(document.querySelector('.mg-chart-title .mg-warning'), 'Error icon exists');
});
test('Chart title is not duplicated on redraw', function() {

0 comments on commit a62495b

Please sign in to comment.