@@ -8,7 +8,9 @@ class ChannelMetadata(object):
8
8
Attributes
9
9
----------
10
10
name : str
11
+ The name of the encoding channel
11
12
data : np.array
13
+ The data linked to the channel (temporal data is converted)
12
14
axis : dict
13
15
bin : boolean, None
14
16
field : str
@@ -20,16 +22,17 @@ class ChannelMetadata(object):
20
22
type : str
21
23
"""
22
24
def __init__ (self , channel , alt_chart ):
23
- self .name = channel # Not from Altair
24
- self .data = self ._locate_channel_data (alt_chart ) # Not from Altair
25
- self .axis = alt_chart .to_dict ()['encoding' ][self .name ].get ('axis' , {})
26
- self .bin = alt_chart .to_dict ()['encoding' ][self .name ].get ('bin' , None )
27
- self .field = alt_chart .to_dict ()['encoding' ][self .name ].get ('field' , None )
28
- self .scale = alt_chart .to_dict ()['encoding' ][self .name ].get ('scale' , {})
29
- self .sort = alt_chart .to_dict ()['encoding' ][self .name ].get ('sort' , None )
30
- self .stack = alt_chart .to_dict ()['encoding' ][self .name ].get ('stack' , None )
31
- self .timeUnit = alt_chart .to_dict ()['encoding' ][self .name ].get ('aggregate' , None )
32
- self .title = alt_chart .to_dict ()['encoding' ][self .name ].get ('title' , None )
25
+ chart_dict = alt_chart .to_dict ()
26
+ self .name = channel
27
+ self .data = self ._locate_channel_data (alt_chart )
28
+ self .axis = chart_dict ['encoding' ][self .name ].get ('axis' , {})
29
+ self .bin = chart_dict ['encoding' ][self .name ].get ('bin' , None )
30
+ self .field = chart_dict ['encoding' ][self .name ].get ('field' , None )
31
+ self .scale = chart_dict ['encoding' ][self .name ].get ('scale' , {})
32
+ self .sort = chart_dict ['encoding' ][self .name ].get ('sort' , None )
33
+ self .stack = chart_dict ['encoding' ][self .name ].get ('stack' , None )
34
+ self .timeUnit = chart_dict ['encoding' ][self .name ].get ('aggregate' , None )
35
+ self .title = chart_dict ['encoding' ][self .name ].get ('title' , None )
33
36
self .type = self ._locate_channel_dtype (alt_chart )
34
37
35
38
if self .type == 'temporal' :
@@ -67,6 +70,7 @@ def _locate_channel_data(self, alt_chart):
67
70
68
71
def _locate_channel_dtype (self , alt_chart ):
69
72
"""Locates dtype used for each channel
73
+
70
74
Parameters
71
75
----------
72
76
alt_chart : altair.Chart
0 commit comments