forked from timwis/vizwit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'timwis/master'
- Loading branch information
Showing
21 changed files
with
407 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>VizWit Editor</title> | ||
|
||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Arimo:400,700,400italic"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> | ||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.9/css/dataTables.bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://api.mapbox.com/mapbox.js/v2.2.1/mapbox.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/backbone.modal/1.1.5/backbone.modal-min.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/backbone.modal/1.1.5/backbone.modal.theme-min.css"> | ||
<link rel="stylesheet" href="styles/main.css"> | ||
<link rel="stylesheet" href="styles/editor.css"> | ||
</head> | ||
<body> | ||
<div class="row"> | ||
<div id="editor" class="split"></div> | ||
<div id="preview" class="split"> | ||
<div class="header-container"> | ||
<div class="container-fluid" id="page-header"></div> | ||
</div> | ||
|
||
<div class="container-fluid"> | ||
<div id="page-content"></div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script src="scripts/vizwit-editor.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
socrata: require('../collections/socrata') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,67 @@ | ||
/* global global */ | ||
var $ = global.jQuery = require('jquery') | ||
var _ = global._ = require('underscore') | ||
var $ = require('jquery') | ||
var _ = require('underscore') | ||
var Backbone = require('backbone') | ||
var deparam = require('node-jquery-deparam') | ||
require('gridstack/dist/gridstack') | ||
|
||
var Header = require('./views/header') | ||
var vizwit = require('./vizwit') | ||
var Gist = require('./collections/gist') | ||
|
||
var vent = _.clone(Backbone.Events) | ||
var fieldsCache = {} | ||
|
||
var params = window.location.search.substr(1) ? deparam(window.location.search.substr(1)) : {} | ||
module.exports = function (config, options) { | ||
options = options || {} | ||
if (!config.version || config.version !== '2') console.error('Wrong config version') | ||
|
||
// If no gist specified, redirect to homepage | ||
var redirect = function () { window.location.replace('http://vizwit.io') } | ||
if (!params.gist) { | ||
redirect() | ||
} | ||
|
||
// Fetch gist | ||
(new Gist(null, {id: params.gist})).fetch({ | ||
success: function (collection, response, options) { | ||
if (!collection.length) return console.error('No files in gist', params.gist) | ||
// Render header | ||
if (config.header) { | ||
var header = new Header(config.header) | ||
$(options.headerSelector).empty().append(header.render().el) | ||
|
||
// If a file was provided, use that one; otherwise use the first file in the gist | ||
var model = params.file && collection.get(params.file) ? collection.get(params.file) : collection.at(0) | ||
var config = JSON.parse(model.get('content')) | ||
// Update <title> tag | ||
if (config.header.title) { | ||
var originalTitle = $('title').text() | ||
$('title').text(config.header.title + ' - ' + originalTitle) | ||
} | ||
} | ||
|
||
if (!config.version || config.version !== '2') return redirect() | ||
var container = $(options.contentSelector) | ||
var heightInterval = 60 // from gridstack.js | ||
var current = {x: null, y: null} | ||
var row | ||
|
||
// Render header | ||
if (config.header) { | ||
var header = new Header(config.header) | ||
$('#page-header').append(header.render().el) | ||
container.empty() | ||
|
||
// Update <title> tag | ||
if (config.header.title) { | ||
var originalTitle = $('title').text() | ||
$('title').text(config.header.title + ' - ' + originalTitle) | ||
} | ||
config.cards.forEach(function (config) { | ||
// If y suggests we're on a new row (including the first item), create a new row | ||
if (config.y !== current.y) { | ||
row = $('<div class="row"></div>') | ||
container.append(row) | ||
current.y = config.y | ||
current.x = 0 | ||
} | ||
|
||
var container = $('#page-content') | ||
var heightInterval = 60 // from gridstack.js | ||
var current = {x: null, y: null} | ||
var row | ||
|
||
config.cards.forEach(function (config) { | ||
// If y suggests we're on a new row (including the first item), create a new row | ||
if (config.y !== current.y) { | ||
row = $('<div class="row"></div>') | ||
container.append(row) | ||
current.y = config.y | ||
current.x = 0 | ||
} | ||
var column = $('<div/>') | ||
|
||
var column = $('<div/>') | ||
// Add width class | ||
column.addClass('col-sm-' + config.width) | ||
|
||
// Add width class | ||
column.addClass('col-sm-' + config.width) | ||
|
||
// If x is not the same as our current x position, add offset class | ||
if (config.x !== current.x) { | ||
column.addClass('col-sm-offset-' + (config.x - current.x)) | ||
} | ||
// Set height of new div | ||
column.css('min-height', config.height * heightInterval) | ||
// If x is not the same as our current x position, add offset class | ||
if (config.x !== current.x) { | ||
column.addClass('col-sm-offset-' + (config.x - current.x)) | ||
} | ||
// Set height of new div | ||
column.css('min-height', config.height * heightInterval) | ||
|
||
// Increment current.x to new starting position | ||
current.x += config.width | ||
// Increment current.x to new starting position | ||
current.x += config.width | ||
|
||
// Add the div to the current row | ||
row.append(column) | ||
// Add the div to the current row | ||
row.append(column) | ||
|
||
// Initialize vizwit on new div | ||
vizwit.init(column, config.vizwit, { | ||
vent: vent, | ||
fieldsCache: fieldsCache | ||
}) | ||
// Initialize vizwit on new div | ||
vizwit.init(column, config.vizwit, { | ||
vent: vent, | ||
fieldsCache: fieldsCache | ||
}) | ||
}, | ||
error: function () { | ||
console.error('Error fetching gist', params.gist) | ||
} | ||
}) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module.exports = { | ||
type: 'pie', | ||
theme: 'light', | ||
titleField: 'label', | ||
valueField: 'value', | ||
pulledField: 'pulled', | ||
innerRadius: '40%', | ||
groupPercent: 1, | ||
balloonFunction: function (item, formattedText) { | ||
var content = '<b>' + item.title + '</b><br>' + | ||
'Total: ' + item.value.toLocaleString() + ' (' + parseFloat(item.percents.toFixed(2)) + '%)' | ||
if (item.dataContext.filteredValue !== undefined) { | ||
content += '<br>Filtered Amount: ' + (+item.dataContext.filteredValue).toLocaleString() | ||
} | ||
return content | ||
}, | ||
labelFunction: function (item, formattedText) { | ||
return item.title.length > 15 ? item.title.substr(0, 15) + '…' : item.title | ||
}, | ||
balloon: {}, | ||
autoMargins: false, | ||
marginTop: 0, | ||
marginBottom: 0, | ||
marginLeft: 0, | ||
marginRight: 0, | ||
pullOutRadius: '10%', | ||
pullOutOnlyOne: true, | ||
labelRadius: 1, | ||
pieAlpha: 0.8, | ||
hideLabelsPercent: 5, | ||
creditsPosition: 'bottom-right', | ||
startDuration: 0, | ||
addClassNames: true, | ||
responsive: { | ||
enabled: true, | ||
addDefaultRules: false, | ||
rules: [ | ||
{ | ||
maxWidth: 450, | ||
overrides: { | ||
pullOutRadius: '10%', | ||
titles: { | ||
enabled: false | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.