Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified app/components/.DS_Store
Binary file not shown.
73 changes: 64 additions & 9 deletions app/components/core/TestData.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,74 @@
var React = require('react');
var React = require('react');
var $ = require('jquery');

module.exports = React.createClass({
componentDidMount: function() {
var dataSchema = [['string', 'Topping'] , ['number' , 'Slices']];
var testData = function() {
return function(){
return [['Goats', 5], ['Burrito',3], ['Olives', 1], ['Zucchini', 1], ['Pepperoni',2]];
getCustomOptions: function(){
return {
'backgroundColor': 'text',
'datalessRegionColor': 'text',
'defaultColor': 'text'
'colorAxis1':'text'
'colorAxis2':'text'
}
},
getInitialState: function() {
return {
'backgroundColor': 'ffffff',
'datalessRegionColor': 'ffffff',
'defaultColor': 'ffffff'
'colorAxis1':'ffffff'
'colorAxis2':'ffffff'
}
},


drawChart: function() {
var dt = new window.google.visualization.DataTable(),
dataSchema = this.props.dataSchema,
data = this.props.data,
// options = this.state,
chart = new window.google.visualization.GeoChart(document.getElementById('chart-div'));

var options = {
colorAxis: {colors: ['blue', 'ff07f0', '#0770ff']},
backgroundColor: this.state.
datalessRegionColor: '#f5f5f5',
defaultColor: '#f5f5f5'
}

dataSchema.forEach(function(column){
var type = column[0],
name = column[1];
dt.addColumn(type, name);
})

dt.addRows(data);

// Instantiate and draw our chart, passing in some options.
chart.draw(dt, options);
},
loadGoogleViz: function() {
window.google.load('visualization', '1.0',
{packages:['corechart'],
callback:this.drawChart
});

},
componentDidUpdate: function() {
if(window.google){
this.drawChart();
}
this.props.updateTransformFunction(testData(), dataSchema);
},
componentDidMount: function() {
// Inject google viz jsapi
// This is the method to load external dependencies when the component mounts
// React automagically binds this to method calls on the component so you can use
// this safely in callback functions to refer to component methods
$.getScript("https://www.google.com/jsapi").done(this.loadGoogleViz);
},
render: function() {
return (
<div className='test-data'>
<div>Test Data Injected</div>
<div id='chart-div'>
</div>
)
}
Expand Down