forked from pyecharts/pyecharts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for version 2.0.8 (pyecharts#2393)
version 2.0.8
- Loading branch information
1 parent
8ef2ae3
commit 0fbbcf9
Showing
17 changed files
with
470 additions
and
7 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
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,77 @@ | ||
from ... import options as opts | ||
from ... import types | ||
from ...charts.basic_charts.geo import GeoChartBase | ||
from ...commons.utils import OrderedSet, JsCode | ||
from ...exceptions import NonexistentCoordinatesException | ||
from ...globals import ChartType | ||
|
||
GMAP_API = "https://maps.googleapis.com/maps/api/js?key={}" | ||
|
||
|
||
class GMap(GeoChartBase): | ||
""" | ||
<<< GMap(Google Map) coordinate system >>> | ||
Support scatter plot, line. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
init_opts: types.Init = opts.InitOpts(), | ||
is_ignore_nonexistent_coord: bool = False, | ||
render_opts: types.RenderInit = opts.RenderOpts(), | ||
): | ||
super().__init__(init_opts=init_opts, render_opts=render_opts) | ||
self.js_dependencies.add("gmap") | ||
self._is_geo_chart = True | ||
self._coordinate_system: types.Optional[str] = "gmap" | ||
self.gmap_js_functions: OrderedSet = OrderedSet() | ||
self._is_ignore_nonexistent_coord = is_ignore_nonexistent_coord | ||
|
||
def _feed_data(self, data_pair: types.Sequence, type_: str) -> types.Sequence: | ||
result = [] | ||
type_list = [ChartType.LINES, ChartType.CUSTOM] | ||
if type_ in type_list: | ||
result = data_pair | ||
else: | ||
for n, v in data_pair: | ||
try: | ||
lng, lat = self.get_coordinate(n) | ||
result.append({"name": n, "value": [lng, lat, v]}) | ||
except TypeError as err: | ||
if self._is_ignore_nonexistent_coord is not True: | ||
raise NonexistentCoordinatesException(err, (n, v)) | ||
return result | ||
|
||
def add_schema( | ||
self, | ||
gmap_ak: str, | ||
center: types.Sequence, | ||
zoom: types.Union[types.Numeric, str] = None, | ||
is_render_on_map: bool = True, | ||
z_index: types.Optional[int] = None, | ||
is_roam: bool = True, | ||
): | ||
self.js_dependencies.add(GMAP_API.format(gmap_ak)) | ||
self.options.update( | ||
gmap={ | ||
"center": center, | ||
"zoom": zoom, | ||
"renderOnMoving": is_render_on_map, | ||
"echartsLayerZIndex": z_index, | ||
"roam": is_roam | ||
} | ||
) | ||
return self | ||
|
||
def add_control_panel( | ||
self, | ||
is_add_traffic_layer: bool = False, | ||
): | ||
if is_add_traffic_layer: | ||
self.gmap_js_functions.add( | ||
"var trafficLayer = new google.maps.TrafficLayer(); " | ||
"trafficLayer.setMap(gmap);" | ||
) | ||
|
||
return self |
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,66 @@ | ||
from ... import options as opts | ||
from ... import types | ||
from ...charts.basic_charts.geo import GeoChartBase | ||
from ...commons.utils import OrderedSet, JsCode | ||
from ...exceptions import NonexistentCoordinatesException | ||
from ...globals import ChartType | ||
|
||
|
||
class LMap(GeoChartBase): | ||
""" | ||
<<< LMap(leaflet) coordinate system >>> | ||
Support scatter plot, line. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
init_opts: types.Init = opts.InitOpts(), | ||
is_ignore_nonexistent_coord: bool = False, | ||
render_opts: types.RenderInit = opts.RenderOpts(), | ||
): | ||
super().__init__(init_opts=init_opts, render_opts=render_opts) | ||
self.js_dependencies.add("lmap-css") | ||
self.js_dependencies.add("lmap-src") | ||
self.js_dependencies.add("lmap") | ||
self._is_geo_chart = True | ||
self._coordinate_system: types.Optional[str] = "lmap" | ||
self.lmap_js_functions: OrderedSet = OrderedSet() | ||
self._is_ignore_nonexistent_coord = is_ignore_nonexistent_coord | ||
|
||
def _feed_data(self, data_pair: types.Sequence, type_: str) -> types.Sequence: | ||
result = [] | ||
type_list = [ChartType.LINES, ChartType.CUSTOM] | ||
if type_ in type_list: | ||
result = data_pair | ||
else: | ||
for n, v in data_pair: | ||
try: | ||
lng, lat = self.get_coordinate(n) | ||
result.append({"name": n, "value": [lng, lat, v]}) | ||
except TypeError as err: | ||
if self._is_ignore_nonexistent_coord is not True: | ||
raise NonexistentCoordinatesException(err, (n, v)) | ||
return result | ||
|
||
def add_schema( | ||
self, | ||
center: types.Sequence, | ||
zoom: types.Union[types.Numeric, str] = None, | ||
is_enable_resize: bool = True, | ||
is_render_on_map: bool = True, | ||
is_layer_interactive: bool = True, | ||
is_large: bool = False, | ||
): | ||
self.options.update( | ||
lmap={ | ||
"center": center, | ||
"zoom": zoom, | ||
"resizeEnable": is_enable_resize, | ||
"renderOnMoving": is_render_on_map, | ||
"echartsLayerInteractive": is_layer_interactive, | ||
"largeMode": is_large, | ||
} | ||
) | ||
|
||
return self |
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
Oops, something went wrong.