Skip to content
Snippets Groups Projects
Commit b725f6b8 authored by Daniel Cothran's avatar Daniel Cothran
Browse files

2913786: Google Charts - how to pass library-specific options via the API

parent 78eb4049
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,8 @@ use Drupal\charts\Util\Util;
use Drupal\charts_google\Settings\Google\GoogleOptions;
use Drupal\charts_google\Settings\Google\ChartType;
use Drupal\charts_google\Settings\Google\ChartArea;
use Drupal\charts_google\Settings\Google\HorizontalAxis;
use Drupal\charts_google\Settings\Google\VerticalAxis;
class GoogleChartsRender implements ChartsRenderInterface {
......@@ -60,48 +62,232 @@ class GoogleChartsRender implements ChartsRenderInterface {
*/
private function charts_google_create_charts_options($options, $seriesData = [], $attachmentDisplayOptions = []) {
$noAttachmentDisplays = count($attachmentDisplayOptions) === 0;
$chartSelected = [];
$seriesTypes = [];
$firstVaxis = ['minValue' => 0, 'title' => $options['yaxis_title']];
$secondVaxis = ['minValue' => 0];
$firstVaxis = new VerticalAxis();
if (isset($options['yaxis_min'])) {
$firstVaxis->setMinValue($options['yaxis_min']);
}
if (isset($options['yaxis_view_min'])) {
$firstVaxis->setViewWindowValue('min', $options['yaxis_view_min']);
}
if (isset($options['yaxis_view_max'])) {
$firstVaxis->setViewWindowValue('max', $options['yaxis_view_max']);
}
if (isset($options['yaxis_max'])) {
$firstVaxis->setMaxValue($options['yaxis_max']);
}
// A format string for numeric or date axis labels.
if (isset($options['yaxis_title'])) {
$firstVaxis->setTitle($options['yaxis_title']);
}
if (isset($options['yaxis_title_color'])) {
$firstVaxis->setTitleTextStyleValue('color', $options['yaxis_title_color']);
}
if (isset($options['yaxis_title_font'])) {
$firstVaxis->setTitleTextStyleValue('fontName', $options['yaxis_title_font']);
}
if (isset($options['yaxis_title_size'])) {
$firstVaxis->setTitleTextStyleValue('fontSize', $options['yaxis_title_size']);
}
if (isset($options['yaxis_title_bold'])) {
$firstVaxis->setTitleTextStyleValue('bold', $options['yaxis_title_bold']);
}
if (isset($options['yaxis_title_italic'])) {
$firstVaxis->setTitleTextStyleValue('italic', $options['yaxis_title_italic']);
}
// Axis title position.
if (isset($options['yaxis_title_position'])) {
$firstVaxis->setTextPosition($options['yaxis_title_position']);
}
if (isset($options['yaxis_baseline'])) {
$firstVaxis->setBaseline($options['yaxis_baseline']);
}
if (isset($options['yaxis_baseline_color'])) {
$firstVaxis->setBaselineColor($options['yaxis_baseline_color']);
}
if (isset($options['yaxis_direction'])) {
$firstVaxis->setDirection($options['yaxis_direction']);
}
// A format string for numeric or date axis labels.
if (isset($options['yaxis_format'])) {
$firstVaxis->setFormat($options['yaxis_format']);
}
if (isset($options['yaxis_view_window_mode'])) {
$firstVaxis->setViewWindowMode($options['yaxis_view_window_mode']);
}
$firstHaxis = new HorizontalAxis();
if (isset($options['xaxis_min'])) {
$firstHaxis->setMinValue($options['xaxis_min']);
}
if (isset($options['xaxis_view_min'])) {
$firstHaxis->setViewWindowValue('min', $options['xaxis_view_min']);
}
if (isset($options['xaxis_view_max'])) {
$firstHaxis->setViewWindowValue('max', $options['xaxis_view_max']);
}
if (isset($options['xaxis_max'])) {
$firstHaxis->setMaxValue($options['xaxis_max']);
}
// A format string for numeric or date axis labels.
if (isset($options['xaxis_title'])) {
$firstHaxis->setTitle($options['xaxis_title']);
}
if (isset($options['xaxis_title_color'])) {
$firstHaxis->setTitleTextStyleValue('color', $options['xaxis_title_color']);
}
if (isset($options['xaxis_title_font'])) {
$firstHaxis->setTitleTextStyleValue('fontName', $options['xaxis_title_font']);
}
if (isset($options['xaxis_title_size'])) {
$firstHaxis->setTitleTextStyleValue('fontSize', $options['xaxis_title_size']);
}
if (isset($options['xaxis_title_bold'])) {
$firstHaxis->setTitleTextStyleValue('bold', $options['xaxis_title_bold']);
}
if (isset($options['xaxis_title_italic'])) {
$firstHaxis->setTitleTextStyleValue('italic', $options['xaxis_title_italic']);
}
// Axis title position.
if (isset($options['xaxis_title_position'])) {
$firstHaxis->setTextPosition($options['xaxis_title_position']);
}
if (isset($options['xaxis_baseline'])) {
$firstHaxis->setBaseline($options['xaxis_baseline']);
}
if (isset($options['xaxis_baseline_color'])) {
$firstHaxis->setBaselineColor($options['xaxis_baseline_color']);
}
if (isset($options['xaxis_direction'])) {
$firstHaxis->setDirection($options['xaxis_direction']);
}
// A format string for numeric or date axis labels.
if (isset($options['xaxis_format'])) {
$firstHaxis->setFormat($options['xaxis_format']);
}
if (isset($options['xaxis_view_window_mode'])) {
$firstHaxis->setViewWindowMode($options['xaxis_view_window_mode']);
}
$vAxes = [];
$hAxes = [];
array_push($vAxes, $firstVaxis);
//sets secondary axis from the first attachment only
array_push($hAxes, $firstHaxis);
// Sets secondary axis from the first attachment only.
if (!$noAttachmentDisplays && $attachmentDisplayOptions[0]['inherit_yaxis'] == 0) {
$secondVaxis['title'] = $attachmentDisplayOptions[0]['style']['options']['yaxis_title'];
$secondVaxis = new VerticalAxis();
$secondVaxis->setTitle($attachmentDisplayOptions[0]['style']['options']['yaxis_title']);
array_push($vAxes, $secondVaxis);
}
array_push($chartSelected, $options['type']);
// @todo: make sure this works for more than one attachment.
for ($i = 0; $i < count($attachmentDisplayOptions); $i++) {
$attachmentChartType = $attachmentDisplayOptions[$i]['style']['options']['type'];
if ($attachmentChartType == 'column')
if ($attachmentChartType == 'column') {
$attachmentChartType = 'bars';
}
if ($attachmentDisplayOptions[$i]['inherit_yaxis'] == 0 && $i == 0) {
$seriesTypes[$i+1] = ['type' => $attachmentChartType, 'targetAxisIndex' => 1];
} else
$seriesTypes[$i+1] = ['type' => $attachmentChartType];
$seriesTypes[$i + 1] = [
'type' => $attachmentChartType,
'targetAxisIndex' => 1
];
}
else {
$seriesTypes[$i + 1] = ['type' => $attachmentChartType];
}
array_push($chartSelected, $attachmentChartType);
}
$chartSelected = array_unique($chartSelected);
$googleOptions = new GoogleOptions();
if (count($chartSelected) > 1) {
$parentChartType = $options['type'];
if ($parentChartType == 'column')
if ($parentChartType == 'column') {
$parentChartType = 'bars';
}
$googleOptions->seriesType = $parentChartType;
$googleOptions->series = $seriesTypes;
}
$googleOptions->setTitle($options['title']);
$googleOptions->vAxes = $vAxes;
if (in_array('donut',$chartSelected)) {
if (isset($options['subtitle'])) {
$googleOptions->setSubTitle($options['subtitle']);
}
$googleOptions->setVAxes($vAxes);
$googleOptions->setHAxes($hAxes);
if (in_array('donut', $chartSelected)) {
$googleOptions->pieHole = '0.5';
}
$chartArea = new ChartArea();
$chartArea->setWidth(400);
// Chart Area width.
if (isset($options['chart_area']['width'])) {
$chartArea->setWidth($options['chart_area']['width']);
}
// Chart Area height.
if (isset($options['chart_area']['height'])) {
$chartArea->setHeight($options['chart_area']['height']);
}
// Chart Area padding top.
if (isset($options['chart_area']['top'])) {
$chartArea->setPaddingTop($options['chart_area']['top']);
}
// Chart Area padding left.
if (isset($options['chart_area']['left'])) {
$chartArea->setPaddingLeft($options['chart_area']['left']);
}
$seriesColors = [];
for ($i = 0; $i < count($seriesData); $i++) {
......@@ -110,6 +296,42 @@ class GoogleChartsRender implements ChartsRenderInterface {
}
$googleOptions->setColors($seriesColors);
// Width of the chart, in pixels.
if (isset($options['width'])) {
$googleOptions->setWidth($options['width']);
}
// Height of the chart, in pixels.
if (isset($options['height'])) {
$googleOptions->setHeight($options['height']);
}
// 'legend' can be a string (for position) or an array with legend
// properties: [position: 'top', textStyle: [color: 'blue', fontSize: 16]]
if (isset($options['legend'])) {
$googleOptions->setLegend($options['legend']);
}
// Set legend position.
if (isset($options['legend_position'])) {
if(empty($options['legend_position'])) {
$options['legend_position'] = 'none';
$googleOptions->setLegend($options['legend_position']);
} else {
$googleOptions->setLegendProperty('position', $options['legend_position']);
}
}
// Where to place the chart title, compared to the chart area.
if (isset($options['title_position'])) {
$googleOptions->setTitlePosition($options['title_position']);
}
// Where to place the axis titles, compared to the chart area
if (isset($options['axis_titles_position'])) {
$googleOptions->setAxisTitlesPosition($options['axis_titles_position']);
}
return $googleOptions;
}
......@@ -118,7 +340,6 @@ class GoogleChartsRender implements ChartsRenderInterface {
* @return ChartType
*/
private function charts_google_create_chart_type($options) {
$googleChartType = new ChartType();
$googleChartType->setChartType($options['type']);
......
......@@ -2,10 +2,36 @@
namespace Drupal\charts_google\Settings\Google;
/**
* Class ChartArea.
*
* @package Drupal\charts_google\Settings\Google
*/
class ChartArea implements \JsonSerializable {
/**
* Chart area width.
*/
private $width;
/**
* Chart area height.
*/
private $height;
/**
* How far to draw the chart from the top border.
*/
private $top;
/**
* How far to draw the chart from the left border.
*/
private $left;
/**
* Gets the chart area width.
*
* @return mixed
*/
public function getWidth() {
......@@ -13,12 +39,68 @@ class ChartArea implements \JsonSerializable {
}
/**
* Sets the chart area width.
*
* @param mixed $width
*/
public function setWidth($width) {
$this->width = $width;
}
/**
* Gets the chart area height.
*
* @return mixed
*/
public function getHeight() {
return $this->height;
}
/**
* Sets the chart area height.
*
* @param mixed $height
*/
public function setHeight($height) {
$this->height = $height;
}
/**
* Gets how far to draw the chart from the top border.
*
* @return mixed
*/
public function getPaddingTop() {
return $this->top;
}
/**
* Sets how far to draw the chart from the top border.
*
* @param mixed $top
*/
public function setPaddingTop($top) {
$this->top = $top;
}
/**
* Gets how far to draw the chart from the left border.
*
* @return mixed
*/
public function getPaddingLeft() {
return $this->left;
}
/**
* Sets how far to draw the chart from the left border.
*
* @param mixed $left
*/
public function setPaddingLeft($left) {
$this->left = $left;
}
/**
* @return array
*/
......
......@@ -2,14 +2,75 @@
namespace Drupal\charts_google\Settings\Google;
/**
* Class GoogleOptions.
*
* @package Drupal\charts_google\Settings\Google
*/
class GoogleOptions implements \JsonSerializable {
/**
* For Material Charts, this option specifies the title.
*/
private $title;
/**
* For Material Charts, this option specifies the subtitle.
*/
private $subTitle;
/**
* Where to place the chart title, compared to the chart area.
*/
private $titlePosition;
/**
* Where to place the axis titles, compared to the chart area.
*/
private $axisTitlesPosition;
/**
* An array with members to configure the placement and size of the chart
* area.
*/
private $chartArea;
private $hAxis;
private $vAxis;
/**
* Specifies properties for individual horizontal axes, if the chart has
* multiple horizontal axes.
*/
private $hAxes;
/**
* An array with members to configure various vertical axis elements.
*/
private $vAxes;
/**
* The colors to use for the chart elements. An array of strings, where each
* element is an HTML color string
*/
private $colors;
/**
* An array with members to configure various aspects of the legend. Or string
* for the position of the legend.
*/
private $legend;
/**
* Width of the chart, in pixels.
*/
private $width;
/**
* Height of the chart, in pixels.
*/
private $height;
/**
* Gets the title of the Material Chart. Only Material Charts support titles.
*
* @return mixed
*/
public function getTitle() {
......@@ -17,13 +78,83 @@ class GoogleOptions implements \JsonSerializable {
}
/**
* @param mixed $title
* Sets the title of the Material Chart. Only Material Charts support titles.
*
* @param string $title
*/
public function setTitle($title) {
$this->title = $title;
}
/**
* Gets the subtitle of the Material Chart. Only Material Charts support
* subtitle.
*
* @return mixed
*/
public function getSubTitle() {
return $this->subTitle;
}
/**
* Sets the subtitle of the Material Chart. Only Material Charts support
* subtitle.
*
* @param string $title
*/
public function setSubTitle($title) {
$this->subTitle = $title;
}
/**
* Gets the position of chart title.
*
* @return mixed
*/
public function getTitlePosition() {
return $this->titlePosition;
}
/**
* Sets the position of chart title.
*
* Supported values:
* - in: Draw the title inside the chart area.
* - out: Draw the title outside the chart area.
* - none: Omit the title.
*
* @param mixed $position
*/
public function setTitlePosition($position) {
$this->titlePosition = $position;
}
/**
* Gets the position of the axis titles.
*
* @return mixed
*/
public function getAxisTitlesPosition() {
return $this->axisTitlesPosition;
}
/**
* Sets the position of the axis titles.
*
* Supported values:
* - in: Draw the axis titles inside the chart area.
* - out: Draw the axis titles outside the chart area.
* - none: Omit the axis titles.
*
* @param mixed $position
*/
public function setAxisTitlesPosition($position) {
$this->axisTitlesPosition = $position;
}
/**
* Gets the chartArea property.
*
* @return mixed
*/
public function getChartArea() {
......@@ -31,6 +162,8 @@ class GoogleOptions implements \JsonSerializable {
}
/**
* Sets the chartArea property.
*
* @param mixed $chartArea
*/
public function setChartArea($chartArea) {
......@@ -38,34 +171,45 @@ class GoogleOptions implements \JsonSerializable {
}
/**
* Gets the horizontal axes.
*
* @return mixed
*/
public function getHAxis() {
return $this->hAxis;
public function getHAxes() {
return $this->hAxes;
}
/**
* @param mixed $hAxis
* Sets the horizontal axes.
*
* @param mixed $hAxes
*/
public function setHAxis($hAxis) {
$this->hAxis = $hAxis;
public function setHAxes($hAxes) {
$this->hAxes = $hAxes;
}
/**
* Gets the vertical axes.
*
* @return mixed
*/
public function getVAxis() {
return $this->vAxis;
public function getVAxes() {
return $this->vAxes;
}
/**
* @param mixed $vAxis
* Sets the vertical axes.
*
* @param mixed $vAxes
*/
public function setVAxis($vAxis) {
$this->vAxis = $vAxis;
public function setVAxes($vAxes) {
$this->vAxes = $vAxes;
}
/**
* Gets the colors to use for the chart elements. An array of strings, where
* each element is an HTML color string.
*
* @return mixed
*/
public function getColors() {
......@@ -73,12 +217,95 @@ class GoogleOptions implements \JsonSerializable {
}
/**
* Sets the colors to use for the chart elements. An array of strings, where
* each element is an HTML color string.
*
* @param mixed $colors
*/
public function setColors($colors) {
$this->colors = $colors;
}
/**
* Gets the Legend properties.
*
* @return mixed
*/
public function getLegend() {
return $this->legend;
}
/**
* Sets the Legend properties.
*
* @param mixed $legend
*/
public function setLegend($legend) {
$this->legend = $legend;
}
/**
* Gets a Legend property.
*
* @param $key
* Property key.
*
* @return mixed
*/
public function getLegendProperty($key) {
return isset($this->legend[$key]) ? $this->legend[$key] : NULL;
}
/**
* Sets a Legend property.
*
* @param $key
* Property key.
* @param $value
* Property value.
*/
public function setLegendProperty($key, $value) {
$this->legend[$key] = $value;
}
/**
* Gets the width of the chart.
*
* @return mixed
*/
public function getWidth() {
return $this->width;
}
/**
* Sets the width of the chart.
*
* @param mixed $width
* Width of the chart, in pixels.
*/
public function setWidth($width) {
$this->width = $width;
}
/**
* Gets the height of the chart.
*
* @return mixed
*/
public function getHeight() {
return $this->height;
}
/**
* Sets the height of the chart.
*
* @param mixed $height
* Height of the chart, in pixels.
*/
public function setHeight($height) {
$this->height = $height;
}
/**
* @return array
*/
......
......@@ -2,11 +2,89 @@
namespace Drupal\charts_google\Settings\Google;
class HorizontalAxis {
/**
* Class HorizontalAxis.
*
* @package Drupal\charts_google\Settings\Google
*
* hAxis options are described here:
* @see https://developers.google.com/chart/interactive/docs/gallery/columnchart#configuration-options
*/
class HorizontalAxis implements \JsonSerializable {
/**
* hAxis property that specifies a title for the horizontal axis.
*/
private $title;
/**
* An array that specifies the horizontal axis title text style.
*/
private $titleTextStyle;
/**
* hAxis property that specifies the baseline for the horizontal axis. If the
* baseline is larger than the highest grid line or smaller than the lowest
* grid line, it will be rounded to the closest gridline.
*/
private $baseline;
/**
* Specifies the color of the baseline for the horizontal axis. Can be any HTML
* color string, for example: 'red' or '#00cc00'.
*/
private $baselineColor;
/**
* The direction in which the values along the horizontal axis grow. Specify -1
* to reverse the order of the values.
*/
private $direction;
/**
* A format string for numeric axis labels.
*/
private $format;
/**
* Position of the horizontal axis text, relative to the chart area.
* Supported values: 'out', 'in', 'none'.
*/
private $textPosition;
/**
* An array that specifies the horizontal axis text style.
*/
private $textStyle;
/**
* Moves the max value of the horizontal axis to the specified value; this will
* be upward in most charts. Ignored if this is set to a value smaller than
* the maximum y-value of the data.
*/
private $maxValue;
/**
* Moves the min value of the horizontal axis to the specified value; this will
* be downward in most charts. Ignored if this is set to a value greater than
* the minimum y-value of the data.
*/
private $minValue = 0;
/**
* Specifies how to scale the horizontal axis to render the values within the
* chart area.
*/
private $viewWindowMode;
/**
* Specifies the cropping range of the horizontal axis.
*/
private $viewWindow;
/**
* Get hAxis property that specifies a title for the horizontal axis.
*
* @return mixed
*/
public function getTitle() {
......@@ -14,24 +92,294 @@ class HorizontalAxis {
}
/**
* @param mixed $title
* Set hAxis property that specifies a title for the horizontal axis.
*
* @param $value
*/
public function setTitle($value) {
$this->title = $value;
}
/**
* Get an array that specifies the horizontal axis title text style.
*
* @return mixed
*/
public function getTitleTextStyle() {
return $this->titleTextStyle;
}
/**
* Set an array that specifies the horizontal axis title text style.
*
* @param mixed $value
*/
public function setTitleTextStyle($value) {
$this->titleTextStyle = $value;
}
/**
* Get an array property that specifies the horizontal axis title text style.
*
* @param string $key
* Machine name of the text style property.
*
* @return mixed
*/
public function getTitleTextStyleValue($key) {
return isset($this->titleTextStyle[$key]) ? $this->titleTextStyle[$key] : NULL;
}
/**
* Set an array property that specifies the horizontal axis title text style.
*
* @param string $key
* Machine name of the text style property.
* @param mixed $value
* Value of the text style property.
*/
public function setTitleTextStyleValue($key, $value) {
$this->titleTextStyle[$key] = $value;
}
/**
* Get hAxis property that specifies the baseline for the horizontal axis.
*
* @return mixed
*/
public function getBaseline() {
return $this->baseline;
}
/**
* Set hAxis property that specifies the baseline for the horizontal axis.
*
* @param mixed $value
*/
public function setBaseline($value) {
$this->baseline = $value;
}
/**
* Get the color of the baseline for the horizontal axis.
*
* @return mixed
*/
public function getBaselineColor() {
return $this->baselineColor;
}
/**
* Set the color of the baseline for the horizontal axis.
*
* @param mixed $value
*/
public function setBaselineColor($value) {
$this->baselineColor = $value;
}
/**
* Get the direction in which the values along the horizontal axis grow.
*
* @return mixed
*/
public function getDirection() {
return $this->direction;
}
/**
* Set the direction in which the values along the horizontal axis grow.
*
* @param mixed $value
*/
public function setDirection($value) {
$this->direction = $value;
}
/**
* Get the format string for numeric axis labels
*
* @return mixed
*/
public function getFormat() {
return $this->format;
}
/**
* Set a format string for numeric axis labels
*
* @param mixed $value
*/
public function setFormat($value) {
$this->format = $value;
}
/**
* Get the position of the horizontal axis text, relative to the chart area.
*
* @return mixed
*/
public function getTextPosition() {
return $this->textPosition;
}
/**
* Set the position of the horizontal axis text, relative to the chart area.
*
* @param mixed $value
*/
public function setTitle($title) {
$this->title = $title;
public function setTextPosition($value) {
$this->textPosition = $value;
}
/**
* @return int
* Get an array that specifies the horizontal axis text style.
*
* @return mixed
*/
public function getTextStyle() {
return $this->textStyle;
}
/**
* Set an array that specifies the horizontal axis text style.
*
* @param mixed $value
*/
public function setTextStyle($value) {
$this->textStyle = $value;
}
/**
* Get an array property that specifies the horizontal axis text style.
*
* @param string $key
* Machine name of the text style property.
*
* @return mixed
*/
public function getTextStyleValue($key) {
return isset($this->textStyle[$key]) ? $this->textStyle[$key] : NULL;
}
/**
* Set an array property that specifies the horizontal axis text style.
*
* @param string $key
* Machine name of the text style property.
* @param mixed $value
* Value of the text style property.
*/
public function setTextStyleValue($key, $value) {
$this->textStyle[$key] = $value;
}
/**
* Get the max value of the horizontal axis.
*
* @return mixed
*/
public function getMaxValue() {
return $this->maxValue;
}
/**
* Set the max value of the horizontal axis.
*
* @param mixed $value
*/
public function setMaxValue($value) {
$this->maxValue = $value;
}
/**
* Get the min value of the horizontal axis.
*
* @return mixed
*/
public function getMinValue() {
return $this->minValue;
}
/**
* @param int $minValue
* Set the min value of the horizontal axis.
*
* @param mixed $value
*/
public function setMinValue($value) {
$this->minValue = $value;
}
/**
* Get the value that specifies how to scale the horizontal axis to render the
* values within the chart area.
*
* @return mixed
*/
public function getViewWindowMode() {
return $this->viewWindowMode;
}
/**
* Set the value that specifies how to scale the horizontal axis to render the
* values within the chart area.
*
* @param mixed $value
*/
public function setViewWindowMode($value) {
$this->viewWindowMode = $value;
}
/**
* Get an array that specifies the cropping range of the horizontal axis.
*
* @return mixed
*/
public function getViewWindow() {
return $this->viewWindow;
}
/**
* Set an array that specifies the cropping range of the horizontal axis.
*
* @param mixed $value
*/
public function setViewWindow($value) {
$this->viewWindow = $value;
}
/**
* Get an array property that specifies the the cropping range of the
* horizontal axis.
*
* @param string $key
* Property key.
*
* @return mixed
*/
public function getViewWindowValue($key) {
return isset($this->viewWindow[$key]) ? $this->viewWindow[$key] : NULL;
}
/**
* Set an array property that specifies the cropping range of the horizontal
* axis.
*
* @param string $key
* Property key.
* @param mixed $value
* Property value.
*/
public function setViewWindowValue($key, $value) {
$this->viewWindow[$key] = $value;
}
/**
* @return array
*/
public function setMinValue($minValue) {
$this->minValue = $minValue;
public function jsonSerialize() {
$vars = get_object_vars($this);
return $vars;
}
}
......@@ -2,7 +2,384 @@
namespace Drupal\charts_google\Settings\Google;
class VerticalAxis {
/**
* Class VerticalAxis.
*
* @package Drupal\charts_google\Settings\Google
*
* vAxis options are described here:
* @see https://developers.google.com/chart/interactive/docs/gallery/columnchart#configuration-options
*/
class VerticalAxis implements \JsonSerializable {
/**
* vAxis property that specifies a title for the vertical axis.
*/
private $title;
/**
* An array that specifies the vertical axis title text style.
*/
private $titleTextStyle;
/**
* vAxis property that specifies the baseline for the vertical axis. If the
* baseline is larger than the highest grid line or smaller than the lowest
* grid line, it will be rounded to the closest gridline.
*/
private $baseline;
/**
* Specifies the color of the baseline for the vertical axis. Can be any HTML
* color string, for example: 'red' or '#00cc00'.
*/
private $baselineColor;
/**
* The direction in which the values along the vertical axis grow. Specify -1
* to reverse the order of the values.
*/
private $direction;
/**
* A format string for numeric axis labels.
*/
private $format;
/**
* Position of the vertical axis text, relative to the chart area.
* Supported values: 'out', 'in', 'none'.
*/
private $textPosition;
/**
* An array that specifies the vertical axis text style.
*/
private $textStyle;
/**
* Moves the max value of the vertical axis to the specified value; this will
* be upward in most charts. Ignored if this is set to a value smaller than
* the maximum y-value of the data.
*/
private $maxValue;
/**
* Moves the min value of the vertical axis to the specified value; this will
* be downward in most charts. Ignored if this is set to a value greater than
* the minimum y-value of the data.
*/
private $minValue = 0;
/**
* Specifies how to scale the vertical axis to render the values within the
* chart area.
*/
private $viewWindowMode;
/**
* Specifies the cropping range of the vertical axis.
*/
private $viewWindow;
/**
* Get vAxis property that specifies a title for the vertical axis.
*
* @return mixed
*/
public function getTitle() {
return $this->title;
}
/**
* Set vAxis property that specifies a title for the vertical axis.
*
* @param $value
*/
public function setTitle($value) {
$this->title = $value;
}
/**
* Get an array that specifies the vertical axis title text style.
*
* @return mixed
*/
public function getTitleTextStyle() {
return $this->titleTextStyle;
}
/**
* Set an array that specifies the vertical axis title text style.
*
* @param mixed $value
*/
public function setTitleTextStyle($value) {
$this->titleTextStyle = $value;
}
/**
* Get an array property that specifies the vertical axis title text style.
*
* @param string $key
* Machine name of the text style property.
*
* @return mixed
*/
public function getTitleTextStyleValue($key) {
return isset($this->titleTextStyle[$key]) ? $this->titleTextStyle[$key] : NULL;
}
/**
* Set an array property that specifies the vertical axis title text style.
*
* @param string $key
* Machine name of the text style property.
* @param mixed $value
* Value of the text style property.
*/
public function setTitleTextStyleValue($key, $value) {
$this->titleTextStyle[$key] = $value;
}
/**
* Get vAxis property that specifies the baseline for the vertical axis.
*
* @return mixed
*/
public function getBaseline() {
return $this->baseline;
}
/**
* Set vAxis property that specifies the baseline for the vertical axis.
*
* @param mixed $value
*/
public function setBaseline($value) {
$this->baseline = $value;
}
/**
* Get the color of the baseline for the vertical axis.
*
* @return mixed
*/
public function getBaselineColor() {
return $this->baselineColor;
}
/**
* Set the color of the baseline for the vertical axis.
*
* @param mixed $value
*/
public function setBaselineColor($value) {
$this->baselineColor = $value;
}
/**
* Get the direction in which the values along the vertical axis grow.
*
* @return mixed
*/
public function getDirection() {
return $this->direction;
}
/**
* Set the direction in which the values along the vertical axis grow.
*
* @param mixed $value
*/
public function setDirection($value) {
$this->direction = $value;
}
/**
* Get the format string for numeric axis labels
*
* @return mixed
*/
public function getFormat() {
return $this->format;
}
/**
* Set a format string for numeric axis labels
*
* @param mixed $value
*/
public function setFormat($value) {
$this->format = $value;
}
/**
* Get the position of the vertical axis text, relative to the chart area.
*
* @return mixed
*/
public function getTextPosition() {
return $this->textPosition;
}
/**
* Set the position of the vertical axis text, relative to the chart area.
*
* @param mixed $value
*/
public function setTextPosition($value) {
$this->textPosition = $value;
}
/**
* Get an array that specifies the vertical axis text style.
*
* @return mixed
*/
public function getTextStyle() {
return $this->textStyle;
}
/**
* Set an array that specifies the vertical axis text style.
*
* @param mixed $value
*/
public function setTextStyle($value) {
$this->textStyle = $value;
}
/**
* Get an array property that specifies the vertical axis text style.
*
* @param string $key
* Machine name of the text style property.
*
* @return mixed
*/
public function getTextStyleValue($key) {
return isset($this->textStyle[$key]) ? $this->textStyle[$key] : NULL;
}
/**
* Set an array property that specifies the vertical axis text style.
*
* @param string $key
* Machine name of the text style property.
* @param mixed $value
* Value of the text style property.
*/
public function setTextStyleValue($key, $value) {
$this->textStyle[$key] = $value;
}
/**
* Get the max value of the vertical axis.
*
* @return mixed
*/
public function getMaxValue() {
return $this->maxValue;
}
/**
* Set the max value of the vertical axis.
*
* @param mixed $value
*/
public function setMaxValue($value) {
$this->maxValue = $value;
}
/**
* Get the min value of the vertical axis.
*
* @return mixed
*/
public function getMinValue() {
return $this->minValue;
}
/**
* Set the min value of the vertical axis.
*
* @param mixed $value
*/
public function setMinValue($value) {
$this->minValue = $value;
}
/**
* Get the value that specifies how to scale the vertical axis to render the
* values within the chart area.
*
* @return mixed
*/
public function getViewWindowMode() {
return $this->viewWindowMode;
}
/**
* Set the value that specifies how to scale the vertical axis to render the
* values within the chart area.
*
* @param mixed $value
*/
public function setViewWindowMode($value) {
$this->viewWindowMode = $value;
}
/**
* Get an array that specifies the cropping range of the vertical axis.
*
* @return mixed
*/
public function getViewWindow() {
return $this->viewWindow;
}
/**
* Set an array that specifies the cropping range of the vertical axis.
*
* @param mixed $value
*/
public function setViewWindow($value) {
$this->viewWindow = $value;
}
/**
* Get an array property that specifies the the cropping range of the
* vertical axis.
*
* @param string $key
* Property key.
*
* @return mixed
*/
public function getViewWindowValue($key) {
return isset($this->viewWindow[$key]) ? $this->viewWindow[$key] : NULL;
}
/**
* Set an array property that specifies the cropping range of the vertical
* axis.
*
* @param string $key
* Property key.
* @param mixed $value
* Property value.
*/
public function setViewWindowValue($key, $value) {
$this->viewWindow[$key] = $value;
}
/**
* @return array
*/
public function jsonSerialize() {
$vars = get_object_vars($this);
return $vars;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment