Skip to content

Commit

Permalink
add livereload to grunt
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenebelov committed May 15, 2014
1 parent 4b910a1 commit e14a5e6
Show file tree
Hide file tree
Showing 15 changed files with 8,606 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
158 changes: 158 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
module.exports = function(grunt) {

"use strict";

// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

grunt.initConfig({

config: {
// Configurable paths
app: 'example',
dist: 'dist'
},

meta: {
pkg: grunt.file.readJSON("package.json"),
srcFiles: [
"src/template.js",
"src/template-extensions.js"
]
},
watch: {
scripts: {
files: ["src/**/*.js", "example/index.html", "example/*.js"],
tasks: ["jshint"]
},
js: {
files: ['<%= config.app %>/scripts/{,*/}*.js'],
// tasks: ['concat'],
options: {
livereload: true
}
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= config.app %>/{,*/}*.html',
'<%= config.app %>/views/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'<%= config.app %>/images/{,*/}*'
]
}
},
connect: {
options: {
port: 9000,
livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: [
'.tmp',
'<%= config.app %>'
]
}
},
test: {
options: {
port: 9001,
base: [
'.tmp',
'test',
'<%= config.app %>'
]
}
},
dist: {
options: {
open: true,
base: '<%= config.dist %>',
livereload: false
}
}
},
jshint: {
options: {
curly: true,
undef: true
},
chart: {
options: {
browser: true,
globals: {
d3: true
}
},
files: {
src: "<%= meta.srcFiles %>"
}
},
grunt: {
options: {
node: true
},
files: {
src: ["Gruntfile.js"]
}
}
},
concat: {
options: {
banner: "/*! <%= meta.pkg.name %> - v<%= meta.pkg.version %>\n" +
" * License: <%= meta.pkg.license %>\n" +
" * Date: <%= grunt.template.today('yyyy-mm-dd') %>\n" +
" */\n"
},
dist: {
files: {
"dist/d3.chart.template.js": "<%= meta.srcFiles %>"
}
},
release: {
files: {
"d3.chart.template.js": "<%= meta.srcFiles %>"
}
}
},
uglify: {
options: {
// Preserve banner
preserveComments: "some"
},
dist: {
files: {
"dist/d3.chart.template.min.js": "dist/d3.chart.template.js"
}
},
release: {
files: {
"d3.chart.template.min.js": "dist/d3.chart.template.js"
}
}
}
});

grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-watch");

grunt.registerTask("work", function(target) {
grunt.task.run([
'connect:livereload',
'watch'
]);
});
grunt.registerTask("default", ["jshint", "concat:dist", "uglify:dist"]);
grunt.registerTask("release", ["jshint", "concat", "uglify"]);
};
120 changes: 114 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,116 @@
d3-experiments
==============
## d3.chart.template

experiments with d3.js and SVG in JavaScript
To get your chart published on the d3.chart [website](http://misoproject.com/d3-chart/charts.html) there are only two requirements:

useful links: <br>
http://habrahabr.ru/post/189838/ <br>
http://habrahabr.ru/post/181766/
* You must name your repo in the following format: `d3.chart.*`. For example: `d3.chart.barchart` or `d3.chart.my-epic-chart`.
* You must have a `package.json` in your repo that declares the version of d3.chart that your chart utilizes like so:

```json
{
"d3.chart": {
"version" : "0.0.1"
}
}
```

### Template Structure

This template comes with a few helpful files:

* A `Gruntfile.js` containing code linting, watching & building tasks that may be useful during development and release.
* A `package.json` file containing some basic placeholder info that you can replace with your chart's details.
* An `example` folder which might be useful to try out your chart while you develop and to release alongside
your chart for others to see how your chart can be utilized.


#### Using Grunt

1. You will need to use grunt > 0.4 to build your chart distribution files.
2. Run `npm install` to obtain the appropriate grunt tasks. Do not check in the `node_modules` folder - it is listed in the `.gitignore` file.

Some useful grunt commands:

* `grunt watch` will watch for file changes and run the js files through linting to check for syntax errors and warnings.
* `grunt` will build your chart into a single file if you've split them up.

### Suggested Guidelines:

* Please maintain your `package.json` with the appropriate versioning and dependencies.

* Please consider licensing your charts under the MIT Expat license or any other BSD-style license.

* Please try to document your code & API

* Please provide some example usage for your chart, either in the examples folder or in this readme.

* Consider defining what API your chart exposes - this includes
* getters/setters and any other methods that are available on the chart instance.
* any events that the chart broadcasts alongside the arguments that will be passed to the callbacks.

Thank you for using d3.chart!
- The Miso Project Team.

---------

## Readme Template:

# Chart name...

Chart description...

### Sample Use

Please provide sample use of your chart here.

### API

Sample API Documentation:

#### `<instance>.highlight(value)`

**Description:**

Allows the highlighting of a specific value

**Parameters:**

* `value` - The value to highlight.

**Uses:**

Example:

```javascript
var chart = d3.select("#vis")
.append("svg")
.chart("MyEpicChart")
.higlight(12);
```

### Events

Sample Event Documentation:

#### `brush`

**Description:**

Broadcast when a circle on the chart is being mousedover

**Arguments:**

* `value` - The value corresponding to the circle being mousedover.

**Uses:**

Example:

```javascript
var chart = d3.select("#vis")
.append("svg")
.chart("MyEpicChart");

chart.on("brush", function(value) {
// handle event...
});
```
12 changes: 12 additions & 0 deletions d3.chart.template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*! d3.chart.template - v0.0.1
* License: MIT Expat
* Date: 2013-05-27
*/
d3.chart("TemplateChart", {
initialize: function() {

}
});
d3.chart("TemplateChart").extend("ExtendedTemplateChart", {

});
5 changes: 5 additions & 0 deletions d3.chart.template.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*! d3.chart.template - v0.0.1
* License: MIT Expat
* Date: 2013-05-27
*/
d3.chart("TemplateChart",{initialize:function(){}}),d3.chart("TemplateChart").extend("ExtendedTemplateChart",{});
1 change: 1 addition & 0 deletions dist/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

12 changes: 12 additions & 0 deletions dist/d3.chart.template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*! d3.chart.template - v0.0.1
* License: MIT Expat
* Date: 2014-05-15
*/
d3.chart("TemplateChart", {
initialize: function() {

}
});
d3.chart("TemplateChart").extend("ExtendedTemplateChart", {

});
5 changes: 5 additions & 0 deletions dist/d3.chart.template.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*! d3.chart.template - v0.0.1
* License: MIT Expat
* Date: 2014-05-15
*/
d3.chart("TemplateChart",{initialize:function(){}}),d3.chart("TemplateChart").extend("ExtendedTemplateChart",{});
3 changes: 3 additions & 0 deletions example/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(function() {
// YOUR SAMPLE CHART USAGE GOES HERE.
}());
17 changes: 17 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>D3.chart Boilerplate Example</title>
<script src="lib/d3.v3.js"></script>
<script src="lib/d3.chart.js"></script>

<script src="../src/template.js"></script>
<script src="../src/template-extensions.js"></script>

</head>
<body>
<div id="vis">Map ololol 1212312</div>
<script src="example.js"></script>
</body>
</html>
Loading

0 comments on commit e14a5e6

Please sign in to comment.