Craft 2 Class Reference

Class ChartHelper

Package
craft.app.helpers
Namespace
Craft
Inheritance
class ChartHelper
Since
2.6
Source Code
craft/app/helpers/ChartHelper.php

Class ChartHelper

Public Methods
Method Description Defined By
getCurrencyFormat() Returns the D3 currency format based on Yii's currency format ChartHelper
getDateRanges() Returns the predefined date ranges with their label, start date and end date. ChartHelper
getDecimalFormat() Returns the D3 decimal format based on Yii's decimal format ChartHelper
getFormats() Returns the short date, decimal, percent and currency D3 formats based on Craft's locale settings ChartHelper
getPercentFormat() Returns the D3 percent format based on Yii's percent format ChartHelper
getRunChartDataFromQuery() Returns the data for a run chart, based on a given DB query, start/end dates, and the desired time interval unit. ChartHelper
getRunChartIntervalUnit() Returns the interval unit that should be used in a run chart, based on the given start and end dates. ChartHelper
getShortDateFormats() Returns the D3 short date formats based on Yii's short date format ChartHelper

Method Details

getCurrencyFormat() public static method #

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

public static array getCurrencyFormat()
Returns array

getDateRanges() public static method #

Returns the predefined date ranges with their label, start date and end date.

public static array getDateRanges()
Returns array

getDecimalFormat() public static method #

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

public static array getDecimalFormat()
Returns array

getFormats() public static method #

Returns the short date, decimal, percent and currency D3 formats based on Craft's locale settings

public static array getFormats()
Returns array

getPercentFormat() public static method #

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

public static array getPercentFormat()
Returns array

getRunChartDataFromQuery() public static method #

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:

public static array getRunChartDataFromQuery(DbCommand $query, DateTime $startDate, DateTime $endDate, string $dateColumn, array|null $options = array (
))
$query DbCommand The DB query that should be used
$startDate DateTime The start of the time duration to select (inclusive)
$endDate DateTime The end of the time duratio to select (exclusive)
$dateColumn string The column that represents the date
$options array / null Any customizations that should be made over the default options
Returns array

getRunChartIntervalUnit() public static method #

Returns the interval unit that should be used in a run chart, based on the given start and end dates.

public static string getRunChartIntervalUnit(DateTime $startDate, DateTime $endDate)
$startDate DateTime
$endDate DateTime
Returns string The unit that the chart should use ('hour', 'day', 'month', or 'year')

getShortDateFormats() public static method #

Returns the D3 short date formats based on Yii's short date format

public static array getShortDateFormats()
Returns array