You are here

public function ScatterField::getValue in Charts 8.4

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/field/ScatterField.php \Drupal\charts\Plugin\views\field\ScatterField::getValue()
  2. 5.0.x src/Plugin/views/field/ScatterField.php \Drupal\charts\Plugin\views\field\ScatterField::getValue()

Throws

\Exception

Overrides FieldPluginBase::getValue

File

src/Plugin/views/field/ScatterField.php, line 139
Defines Drupal\charts\Plugin\views\field\ScatterField.

Class

ScatterField
Field handler to provide x and y values for a scatter plot.

Namespace

Drupal\charts\Plugin\views\field

Code

public function getValue(ResultRow $values, $field = NULL) {
  parent::getValue($values, $field);
  $xAxisFieldValue = $this
    ->getFieldValue($values, TRUE);
  $yAxisFieldValue = $this
    ->getFieldValue($values, FALSE);
  $value = Json::encode([
    Json::decode($xAxisFieldValue),
    Json::decode($yAxisFieldValue),
  ]);
  return $value;
}