Skip to content

Commit

Permalink
Fixed bug that can occur if nested arrays/dicts are passed to columnd…
Browse files Browse the repository at this point in the history
…atasource
  • Loading branch information
Chris committed Sep 27, 2018
1 parent 4f5a233 commit 237e7c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
24 changes: 20 additions & 4 deletions chartify/_core/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,16 @@ def line(self,
for color_value, color in zip(color_values, colors):

if color_column is None: # Single line
sliced_data = data_frame[[x_column, y_column]]
sliced_data = data_frame
else:
sliced_data = data_frame[data_frame[color_column] ==
color_value]
# Filter to only relevant columns.
sliced_data = (
sliced_data[
[col for col in sliced_data.columns
if col in (
x_column, y_column, color_column)]])

cast_data = self._cast_datetime_axis(sliced_data, x_column)

Expand Down Expand Up @@ -402,7 +408,12 @@ def scatter(self,
else:
sliced_data = data_frame[data_frame[color_column] ==
color_value]

# Filter to only relevant columns.
sliced_data = (
sliced_data[
[col for col in sliced_data.columns
if col in (
x_column, y_column, size_column, color_column)]])
cast_data = self._cast_datetime_axis(sliced_data, x_column)

source = self._named_column_data_source(
Expand Down Expand Up @@ -476,11 +487,16 @@ def text(self,
for color_value, color in zip(color_values, colors):

if color_column is None: # Single series
sliced_data = data_frame[[x_column, y_column, text_column]]
sliced_data = data_frame
else:
sliced_data = data_frame[data_frame[color_column] ==
color_value]
sliced_data = sliced_data[[x_column, y_column, text_column]]
# Filter to only relevant columns.
sliced_data = (
sliced_data[
[col for col in sliced_data.columns
if col in (
x_column, y_column, text_column, color_column)]])
cast_data = self._cast_datetime_axis(sliced_data, x_column)

source = self._named_column_data_source(
Expand Down
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-e .
pip==10.0.0
pip==18.0.0
wheel==0.31.1
setuptools==40.3.0
twine==1.11.0
Expand All @@ -10,6 +10,7 @@ coverage==4.1
Sphinx==1.7.7
commonmark==0.5.4
recommonmark==0.4.0
prompt-toolkit==1.0.15

pytest==3.2.3
pytest-cov==2.5.1
Expand Down

0 comments on commit 237e7c8

Please sign in to comment.