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

Update Highcharts based on issue 2898236

parent 25b62829
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,36 @@ ...@@ -11,7 +11,36 @@
$('.charts-highchart').once().each(function () { $('.charts-highchart').once().each(function () {
if ($(this).attr('data-chart')) { if ($(this).attr('data-chart')) {
var highcharts = $(this).attr('data-chart'); var highcharts = $(this).attr('data-chart');
$(this).highcharts(JSON.parse(highcharts)); var hc = JSON.parse(highcharts);
if (hc.chart.type === 'pie') {
delete hc.plotOptions.bar;
hc.plotOptions.pie = {
allowPointSelect: true,
cursor: 'pointer',
showInLegend: true,
dataLabels: {
enabled: true,
format: '{point.y:,.0f}'
}
};
hc.legend.enabled = true;
hc.legend.labelFormatter = function () {
var legendIndex = this.index;
return this.series.chart.axes[0].categories[legendIndex];
};
hc.tooltip.formatter = function () {
var sliceIndex = this.point.index;
var sliceName = this.series.chart.axes[0].categories[sliceIndex];
return '' + sliceName +
' : ' + this.y + '';
};
console.log(hc);
}
$(this).highcharts(hc);
} }
}); });
} }
......
...@@ -131,6 +131,8 @@ class ChartsConfigForm extends ConfigFormBase { ...@@ -131,6 +131,8 @@ class ChartsConfigForm extends ConfigFormBase {
// Ensure all defaults are set. // Ensure all defaults are set.
$options = array_merge($this->charts_default_settings(), $defaults); $options = array_merge($this->charts_default_settings(), $defaults);
$form['#attached']['library'][] = ['charts', 'charts.admin'];
// Get a list of available chart libraries. // Get a list of available chart libraries.
$charts_info = $this->charts_info(); $charts_info = $this->charts_info();
$library_options = []; $library_options = [];
...@@ -179,7 +181,7 @@ class ChartsConfigForm extends ConfigFormBase { ...@@ -179,7 +181,7 @@ class ChartsConfigForm extends ConfigFormBase {
// Set data attributes to identify special properties of different types. // Set data attributes to identify special properties of different types.
foreach ($chart_types as $chart_type => $chart_type_info) { foreach ($chart_types as $chart_type => $chart_type_info) {
if (isset($chart_type_info['axis_inverted']) && $chart_type_info['axis_inverted']) { if ($chart_type_info['axis_inverted']) {
$form['type'][$chart_type]['#attributes']['data-axis-inverted'] = TRUE; $form['type'][$chart_type]['#attributes']['data-axis-inverted'] = TRUE;
} }
if ($chart_type_info['axis'] === ChartsInterface::CHARTS_SINGLE_AXIS) { if ($chart_type_info['axis'] === ChartsInterface::CHARTS_SINGLE_AXIS) {
...@@ -483,10 +485,6 @@ class ChartsConfigForm extends ConfigFormBase { ...@@ -483,10 +485,6 @@ class ChartsConfigForm extends ConfigFormBase {
'axis' => ChartsInterface::CHARTS_DUAL_AXIS, 'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
'stacking' => TRUE, 'stacking' => TRUE,
]; ];
$chart_types['donut'] = [
'label' => $this->t('Donut'),
'axis' => ChartsInterface::CHARTS_SINGLE_AXIS,
];
$chart_types['line'] = [ $chart_types['line'] = [
'label' => $this->t('Line'), 'label' => $this->t('Line'),
'axis' => ChartsInterface::CHARTS_DUAL_AXIS, 'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
......
...@@ -117,11 +117,7 @@ class ChartsPluginDisplayChart extends Attachment { ...@@ -117,11 +117,7 @@ class ChartsPluginDisplayChart extends Attachment {
} }
/** /**
* Perform any necessary changes to the form values prior to storage. * {@inheritdoc}
* There is no need for this function to actually store the data.
*
* @param $form
* @param FormStateInterface $form_state
*/ */
public function submitOptionsForm(&$form, FormStateInterface $form_state) { public function submitOptionsForm(&$form, FormStateInterface $form_state) {
// It is very important to call the parent function here: // It is very important to call the parent function here:
...@@ -131,7 +127,7 @@ class ChartsPluginDisplayChart extends Attachment { ...@@ -131,7 +127,7 @@ class ChartsPluginDisplayChart extends Attachment {
case 'displays': case 'displays':
$form_state->setValue($section, array_filter($form_state->getValue($section))); $form_state->setValue($section, array_filter($form_state->getValue($section)));
break; break;
// @todo set isDefaulted to false by default.
case 'inherit_arguments': case 'inherit_arguments':
case 'inherit_exposed_filters': case 'inherit_exposed_filters':
case 'inherit_yaxis': case 'inherit_yaxis':
......
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