ChartHelper
- Type
- Class
- Namespace
- Craft
- Inherits
- Craft\ChartHelper
- Since
- 2.6
Class ChartHelper
See also http://craftcms.com
View source (opens new window)
# Public Methods
| Method | Description |
|---|---|
| getCurrencyFormat() | Returns the D3 currency format based on Yii's currency format |
| getDateRanges() | Returns the predefined date ranges with their label, start date and end date. |
| getDecimalFormat() | Returns the D3 decimal format based on Yii's decimal format |
| getFormats() | Returns the short date, decimal, percent and currency D3 formats based on Craft's locale settings |
| getPercentFormat() | Returns the D3 percent format based on Yii's percent format |
| getRunChartDataFromQuery() | Returns the data for a run chart, based on a given DB query, start/end dates, and the desired time interval unit. |
| getRunChartIntervalUnit() | Returns the interval unit that should be used in a run chart, based on the given start and end dates. |
| getShortDateFormats() | Returns the D3 short date formats based on Yii's short date format |
# getCurrencyFormat()
Returns the D3 currency format based on Yii's currency format
View source (opens new window)
Returns
Signature
public static array getCurrencyFormat ( )
# getDateRanges()
Returns the predefined date ranges with their label, start date and end date.
View source (opens new window)
Returns
Signature
public static array getDateRanges ( )
# getDecimalFormat()
Signature
public static array getDecimalFormat ( )
# getFormats()
Returns the short date, decimal, percent and currency D3 formats based on Craft's locale settings
View source (opens new window)
Returns
Signature
public static array getFormats ( )
# getPercentFormat()
Signature
public static array getPercentFormat ( )
# getRunChartDataFromQuery()
Returns the data for a run chart, based on a given DB query, start/end dates, and the desired time interval unit.
The query’s SELECT clause should already be set to a column aliased as value.
The $options array can override the following defaults:
intervalUnit- The time interval unit to use ('hour', 'day', 'month', or 'year'). By default, a unit will be decided automatically based on the start/end date duration.categoryLabel- The label to use for the chart categories (times). Defaults to "Date".valueLabel- The label to use for the chart values. Defaults to "Value".valueType- The type of values that are being plotted ('number', 'currency', 'percent', 'time'). Defaults to 'number'.
View source (opens new window)
Arguments
$query(Craft\DbCommand) – The DB query that should be used$startDate(Craft\DateTime) – The start of the time duration to select (inclusive)$endDate(Craft\DateTime) – The end of the time duratio to select (exclusive)$dateColumn(string (opens new window)) – The column that represents the date$options(array (opens new window), null (opens new window)) – Any customizations that should be made over the default options
Returns
Signature
public static array getRunChartDataFromQuery ( Craft\DbCommand $query, Craft\DateTime $startDate, Craft\DateTime $endDate, $dateColumn, $options = [] )
# getRunChartIntervalUnit()
Returns the interval unit that should be used in a run chart, based on the given start and end dates.
View source (opens new window)
Arguments
$startDate(Craft\DateTime)$endDate(Craft\DateTime)
Returns
string (opens new window) – The unit that the chart should use ('hour', 'day', 'month', or 'year')
Signature
public static string getRunChartIntervalUnit ( Craft\DateTime $startDate, Craft\DateTime $endDate )
# getShortDateFormats()
Returns the D3 short date formats based on Yii's short date format
View source (opens new window)
Returns
Signature
public static array getShortDateFormats ( )