-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from dsten/split-stuff
Restructure package, datascience.py -> table.py, and stub map widget
- Loading branch information
Showing
7 changed files
with
81 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .table import * | ||
from .maps import * |
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,4 @@ | ||
from .loader import * | ||
from .maps import * | ||
|
||
init_js() |
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,13 @@ | ||
// Registers the Backbone view for the Polymap widget, although for now this is | ||
// a dummy view until we can get everything hooked up properly. | ||
// TODO(sam): Make this actually do things. | ||
|
||
require(["widgets/js/widget", "widgets/js/manager"], function(widget, manager) { | ||
var TestWidgetView = widget.DOMWidgetView.extend({ | ||
render: function() { | ||
this.$el.text("Hello world!"); | ||
} | ||
}); | ||
|
||
manager.WidgetManager.register_widget_view('TestWidgetView', TestWidgetView); | ||
}); |
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,13 @@ | ||
from IPython.display import display_javascript | ||
|
||
__maps_js_has_initialized__ = False | ||
|
||
# Uses a hack to load the Javascript needed to render the map. Becaose of this, | ||
# calls to draw_map cannot be in the same cell as the import statement. | ||
# | ||
# Maybe it's a good idea to put this login in a line magic? | ||
def init_js(): | ||
global __maps_js_has_initialized__ | ||
if not __maps_js_has_initialized__: | ||
# Keep in sync with the the data_files variable in setup.py | ||
display_javascript("IPython.load_extensions('datascience_js/maps')") |
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,34 @@ | ||
from IPython.html import widgets # Widget definitions | ||
from IPython.utils.traitlets import Unicode | ||
|
||
""" | ||
This file contains the Python backend to draw maps with overlaid polygons. | ||
TODO(sam): Actually make this draw maps | ||
""" | ||
|
||
class TestWidget(widgets.DOMWidget): | ||
_view_name = Unicode('TestWidgetView', sync=True) | ||
_view_module = Unicode('maps', sync=True) | ||
|
||
|
||
def draw_map(center, zoom, points=[], regions=[]): | ||
"""Draw a map with center & zoom containing all points and | ||
regions that displays points as circles and regions as polygons. | ||
center -- lat-long pair at the center of the map | ||
zoom -- zoom level | ||
points -- a sequence of MapPoints | ||
regions -- a sequence of MapRegions | ||
""" | ||
# Some magic to get javascript to display the map | ||
|
||
class MapPoint: | ||
"""A circle https://developers.google.com/maps/documentation/javascript/shapes#circles""" | ||
def __init__(self, center, radius, strokeColor, strokeOpacity, strokeWeight, fillColor, fillOpacity): | ||
pass | ||
|
||
class MapRegion: | ||
"""A polygon https://developers.google.com/maps/documentation/javascript/shapes#polygons""" | ||
def __init__(self, paths, strokeColor, strokeOpacity, strokeWeight, fillColor, fillOpacity): | ||
"""paths -- a list of lat-long pairs or a list of list of lat-long pairs""" | ||
pass |
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