You are here

public static function ChartsDefaultSettings::getFieldsDataProviders in Charts 8.4

Same name and namespace in other branches
  1. 5.0.x src/Settings/ChartsDefaultSettings.php \Drupal\charts\Settings\ChartsDefaultSettings::getFieldsDataProviders()

Field data provider.

Parameters

array $data_providers: Data providers.

array $legacy_value: Legacy value.

Return value

mixed Data providers returned

2 calls to ChartsDefaultSettings::getFieldsDataProviders()
ChartBase::getOptionsFromElementProperties in src/Plugin/chart/Library/ChartBase.php
Gets options properties.
ChartsDefaultSettings::transformLegacySettingsToNew in src/Settings/ChartsDefaultSettings.php
Transforms legacy settings to newer ones.

File

src/Settings/ChartsDefaultSettings.php, line 304

Class

ChartsDefaultSettings
The chart default settings instance.

Namespace

Drupal\charts\Settings

Code

public static function getFieldsDataProviders(array $data_providers, array $legacy_value) {
  $default_weight = 0;
  foreach ($legacy_value as $field_id => $value) {
    if (Color::validateHex($value)) {
      $data_providers[$field_id]['color'] = $value;
    }
    else {
      $data_providers[$field_id]['enabled'] = !empty($value);
    }
    $data_providers[$field_id]['weight'] = $default_weight;
    $default_weight++;
  }
  return $data_providers;
}