diff --git a/altair/vegalite/v3/api.py b/altair/vegalite/v3/api.py index f8ec4a191..84cd23b76 100644 --- a/altair/vegalite/v3/api.py +++ b/altair/vegalite/v3/api.py @@ -537,7 +537,9 @@ def properties(self, **kwargs): # For backward compatibility with old selection interface. setattr(copy, key, {val.name: val.selection}) else: - self.validate_property(key, val) + # Don't validate data, because it hasn't been processed. + if key != 'data': + self.validate_property(key, val) setattr(copy, key, val) return copy diff --git a/altair/vegalite/v3/tests/test_api.py b/altair/vegalite/v3/tests/test_api.py index 296fe437f..426a85559 100644 --- a/altair/vegalite/v3/tests/test_api.py +++ b/altair/vegalite/v3/tests/test_api.py @@ -640,3 +640,11 @@ def test_repeat(): assert 'columns' not in dct2 assert dct2['spec']['encoding']['x']['field'] == {'repeat': 'row'} assert dct2['spec']['encoding']['y']['field'] == {'repeat': 'column'} + + +def test_data_property(): + data = pd.DataFrame({'x': [1, 2, 3], 'y': list('ABC')}) + chart1 = alt.Chart(data).mark_point() + chart2 = alt.Chart().mark_point().properties(data=data) + + assert chart1.to_dict() == chart2.to_dict() \ No newline at end of file