add timestamp toggle in chart options (Table Viz) (#439)

* add timestamp toggle in chart options (Table Viz)

* refactor timestamp choices

* fix build error
This commit is contained in:
Siddharth Gupta
2016-05-10 09:22:32 -07:00
committed by Maxime Beauchemin
parent c5fcbc0709
commit a75d6bc52c
3 changed files with 30 additions and 10 deletions

View File

@@ -17,6 +17,15 @@ from caravel import app
config = app.config
TIMESTAMP_CHOICES = [
('smart_date', 'Adaptative formating'),
("%m/%d/%Y", '"%m/%d/%Y" | 01/14/2019'),
("%Y-%m-%d", '"%Y-%m-%d" | 2019-01-14'),
("%Y-%m-%d %H:%M:%S",
'"%Y-%m-%d %H:%M:%S" | 2019-01-14 01:32:10'),
("%H:%M:%S", '"%H:%M:%S" | 01:32:10'),
]
class BetterBooleanField(BooleanField):
@@ -430,17 +439,15 @@ class FormFactory(object):
'compare_suffix': TextField(
'Comparison suffix',
description="Suffix to apply after the percentage display"),
'table_timestamp_format': FreeFormSelectField(
'Table Timestamp Format',
default='smart_date',
choices=TIMESTAMP_CHOICES,
description="Timestamp Format"),
'x_axis_format': FreeFormSelectField(
'X axis format',
default='smart_date',
choices=[
('smart_date', 'Adaptative formating'),
("%m/%d/%Y", '"%m/%d/%Y" | 01/14/2019'),
("%Y-%m-%d", '"%Y-%m-%d" | 2019-01-14'),
("%Y-%m-%d %H:%M:%S",
'"%Y-%m-%d %H:%M:%S" | 2019-01-14 01:32:10'),
("%H:%M:%S", '"%H:%M:%S" | 01:32:10'),
],
choices=TIMESTAMP_CHOICES,
description="D3 format syntax for y axis "
"https://github.com/mbostock/\n"
"d3/wiki/Formatting"),