diff --git a/defaults.go b/defaults.go index c87ebbb..f4e91d1 100644 --- a/defaults.go +++ b/defaults.go @@ -55,6 +55,10 @@ const ( // DefaultDateFormat is the default date format. DefaultDateFormat = "2006-01-02" + // DefaultDateHourFormat is the date format for hour timestamp formats. + DefaultDateHourFormat = "01-02 3pm" + // DefaultFloatFormat is the default float format. + DefaultFloatFormat = "%.2f" ) var ( @@ -67,7 +71,7 @@ var ( // DefaultCanvasColor is the default chart canvas color. // It is equivalent to css color:white. DefaultCanvasColor = drawing.Color{R: 255, G: 255, B: 255, A: 255} - // DefaultCanvasStrokColor is the default chart canvas stroke color. + // DefaultCanvasStrokeColor is the default chart canvas stroke color. // It is equivalent to css color:white. DefaultCanvasStrokeColor = drawing.Color{R: 255, G: 255, B: 255, A: 255} // DefaultTextColor is the default chart text color. diff --git a/value_formatter.go b/value_formatter.go index 4a59974..4902125 100644 --- a/value_formatter.go +++ b/value_formatter.go @@ -13,6 +13,11 @@ func TimeValueFormatter(v interface{}) string { return TimeValueFormatterWithFormat(v, DefaultDateFormat) } +// TimeHourValueFormatter is a ValueFormatter for timestamps. +func TimeHourValueFormatter(v interface{}) string { + return TimeValueFormatterWithFormat(v, DefaultDateHourFormat) +} + // TimeValueFormatterWithFormat is a ValueFormatter for timestamps with a given format. func TimeValueFormatterWithFormat(v interface{}, dateFormat string) string { if typed, isTyped := v.(time.Time); isTyped { @@ -29,7 +34,7 @@ func TimeValueFormatterWithFormat(v interface{}, dateFormat string) string { // FloatValueFormatter is a ValueFormatter for float64. func FloatValueFormatter(v interface{}) string { - return FloatValueFormatterWithFormat(v, "%.2f") + return FloatValueFormatterWithFormat(v, DefaultFloatFormat) } // FloatValueFormatterWithFormat is a ValueFormatter for float64 with a given format.