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

array (opens new window)

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

array (opens new window)

Signature

public static array getDateRanges ( )

# getDecimalFormat()

Returns the D3 decimal format based on Yii's decimal format

View source (opens new window)

Returns

array (opens new window)

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

array (opens new window)

Signature

public static array getFormats ( )

# getPercentFormat()

Returns the D3 percent format based on Yii's percent format

View source (opens new window)

Returns

array (opens new window)

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

Returns

array (opens new window)

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

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

array (opens new window)

Signature

public static array getShortDateFormats ( )