예제 #1
0
 def line_or_bar_or_geo(ldf, dimension: Clause, measure: Clause):
     dim_type = dimension.data_type
     # If no aggregation function is specified, then default as average
     if measure.aggregation == "":
         measure.set_aggregation("mean")
     if dim_type == "temporal" or dim_type == "oridinal":
         return "line", {"x": dimension, "y": measure}
     else:  # unordered categorical
         # if cardinality large than 5 then sort bars
         if ldf.cardinality[dimension.attribute] > 5:
             dimension.sort = "ascending"
         if utils.like_geo(dimension.get_attr()):
             return "geographical", {"x": dimension, "y": measure}
         return "bar", {"x": measure, "y": dimension}
예제 #2
0
 def line_or_bar_or_geo(ldf, dimension: Clause, measure: Clause):
     dim_type = dimension.data_type
     # If no aggregation function is specified, then default as average
     if measure.aggregation == "":
         measure.set_aggregation("mean")
     if dim_type == "temporal" or dim_type == "oridinal":
         if isinstance(dimension.attribute, pd.Timestamp):
             # If timestamp, use the _repr_ (e.g., TimeStamp('2020-04-05 00.000')--> '2020-04-05')
             attr = str(dimension.attribute._date_repr)
         else:
             attr = dimension.attribute
         if ldf.cardinality[attr] == 1:
             return "bar", {"x": measure, "y": dimension}
         else:
             return "line", {"x": dimension, "y": measure}
     else:  # unordered categorical
         # if cardinality large than 5 then sort bars
         if ldf.cardinality[dimension.attribute] > 5:
             dimension.sort = "ascending"
         if utils.like_geo(dimension.get_attr()):
             return "geographical", {"x": dimension, "y": measure}
         return "bar", {"x": measure, "y": dimension}