Skip to content
Snippets Groups Projects
Commit 47e6f475 authored by Nathan Haug's avatar Nathan Haug
Browse files

Revert "Issue #2203421 by stella: Ignore chart add-ons that don't produce results."

This reverts commit 31a47799.
parent 585ecc91
No related branches found
No related tags found
No related merge requests found
...@@ -103,7 +103,6 @@ function charts_element_info() { ...@@ -103,7 +103,6 @@ function charts_element_info() {
'#max' => NULL, // Integer max value on this axis. '#max' => NULL, // Integer max value on this axis.
'#min' => NULL, // Integer minimum value on this axis. '#min' => NULL, // Integer minimum value on this axis.
'#opposite' => FALSE, // Display axis on opposite normal side. '#opposite' => FALSE, // Display axis on opposite normal side.
'#continuous' => FALSE, // Options: FALSE, TRUE, or 'date'.
); );
$info['chart_xaxis'] = array( $info['chart_xaxis'] = array(
) + $axis_properties; ) + $axis_properties;
...@@ -414,14 +413,6 @@ function charts_cast_element_integer_values(&$element) { ...@@ -414,14 +413,6 @@ function charts_cast_element_integer_values(&$element) {
} }
} }
/**
* Given a date value, attempt to standardize the input.
*/
function charts_convert_date_value($date_string) {
$timezone = new DateTimeZone('UTC');
$date = new DateTime($date_string, $timezone);
return $date->format('U');
}
/** /**
* Output the chart renderable as a string. * Output the chart renderable as a string.
......
...@@ -161,39 +161,6 @@ function _charts_examples_bar_simple() { ...@@ -161,39 +161,6 @@ function _charts_examples_bar_simple() {
return $example; return $example;
} }
function _charts_examples_line() {
$chart = array(
'#type' => 'chart',
'#chart_type' => 'line',
'#title' => t('Line with discrete axis'),
);
// Test with a gap in the data.
$chart['male'] = array(
'#type' => 'chart_data',
'#title' => t('Male'),
'#data' => array(array(0, 0), array(20, 40), array(22, 30), array(36, 30), array(40, 40)),
);
$chart['female'] = array(
'#type' => 'chart_data',
'#title' => t('Female'),
'#data' => array(array(0, 5), array(20, 14), array(22, 16), array(36, 36), array(40, 48)),
);
$example['chart'] = $chart;
return $example;
}
function _charts_examples_line_continuous() {
$example = _charts_examples_line();
$example['chart']['#title'] = t('Line with continuous axis');
$example['chart']['xaxis'] = array(
'#type' => 'chart_xaxis',
'#continuous' => TRUE,
);
return $example;
}
function _charts_examples_line_gap() { function _charts_examples_line_gap() {
$chart = array( $chart = array(
'#type' => 'chart', '#type' => 'chart',
......
...@@ -209,18 +209,6 @@ function charts_settings_form($form, $defaults = array(), $field_options = array ...@@ -209,18 +209,6 @@ function charts_settings_form($form, $defaults = array(), $field_options = array
'#default_value' => $options['xaxis_title'], '#default_value' => $options['xaxis_title'],
'#parents' => array_merge($parents, array('xaxis_title')), '#parents' => array_merge($parents, array('xaxis_title')),
); );
$form['xaxis']['continuous'] = array(
'#title' => t('Axis data type'),
'#type' => 'radios',
'#options' => array(
0 => t('Discrete'),
1 => t('Continuous'),
2 => t('Continuous date')
),
'#default_value' => $options['xaxis_continuous'],
'#description' => t('A continuous axis will space points based on their values. See <a href="https://developers.google.com/chart/interactive/docs/customizing_axes#Discrete_vs_Continuous">these examples</a> that elaborate on the different axis types.'),
'#parents' => array_merge($parents, array('xaxis_continuous')),
);
$form['xaxis']['labels_rotation'] = array( $form['xaxis']['labels_rotation'] = array(
'#title' => t('Labels rotation'), '#title' => t('Labels rotation'),
'#type' => 'select', '#type' => 'select',
...@@ -383,7 +371,6 @@ function charts_default_settings() { ...@@ -383,7 +371,6 @@ function charts_default_settings() {
$defaults['height'] = NULL; $defaults['height'] = NULL;
$defaults['xaxis_title'] = ''; $defaults['xaxis_title'] = '';
$defaults['xaxis_continuous'] = 0;
$defaults['xaxis_labels_rotation'] = 0; $defaults['xaxis_labels_rotation'] = 0;
$defaults['yaxis_title'] = ''; $defaults['yaxis_title'] = '';
......
...@@ -114,17 +114,7 @@ function _charts_google_populate_chart_axes($chart, $chart_definition) { ...@@ -114,17 +114,7 @@ function _charts_google_populate_chart_axes($chart, $chart_definition) {
// In Google, the row column of data is used as labels. // In Google, the row column of data is used as labels.
if ($chart[$key]['#labels'] && $chart[$key]['#type'] === 'chart_xaxis') { if ($chart[$key]['#labels'] && $chart[$key]['#type'] === 'chart_xaxis') {
foreach ($chart[$key]['#labels'] as $label_key => $label) { foreach ($chart[$key]['#labels'] as $label_key => $label) {
if ($chart[$key]['#continuous']) { $chart_definition['data'][$label_key + 1][0] = $label;
if ($chart[$key]['#continuous'] === 'date') {
$chart_definition['data'][$label_key + 1][0] = charts_convert_date_value($label);
}
else {
$chart_definition['data'][$label_key + 1][0] = $label + 0;
}
}
else {
$chart_definition['data'][$label_key + 1][0] = $label;
}
} }
} }
$axis['textStyle']['color'] = $chart[$key]['#labels_color']; $axis['textStyle']['color'] = $chart[$key]['#labels_color'];
......
...@@ -152,14 +152,6 @@ function _charts_highcharts_populate_chart_axes($chart, $chart_definition) { ...@@ -152,14 +152,6 @@ function _charts_highcharts_populate_chart_axes($chart, $chart_definition) {
$axis['min'] = $chart[$key]['#min']; $axis['min'] = $chart[$key]['#min'];
$axis['opposite'] = $chart[$key]['#opposite']; $axis['opposite'] = $chart[$key]['#opposite'];
// Change axis_type to datetime and delete categories when needed.
if ($chart[$key]['#continuous']) {
$axis['categories'] = '';
if ($chart[$key]['#continuous'] === 'date') {
$axis['type'] = 'datetime';
}
}
// Dealing with axis rotation in a reasonable manner is complicated in // Dealing with axis rotation in a reasonable manner is complicated in
// Highcharts. We want the label to be reasonably positioned on the // Highcharts. We want the label to be reasonably positioned on the
// outside of the chart when labels are rotated. // outside of the chart when labels are rotated.
...@@ -214,22 +206,6 @@ function _charts_highcharts_populate_chart_data(&$chart, $chart_definition) { ...@@ -214,22 +206,6 @@ function _charts_highcharts_populate_chart_data(&$chart, $chart_definition) {
$series['yAxis'] = $axis_index; $series['yAxis'] = $axis_index;
} }
// Change data string to number when continuous axis is needed.
foreach (element_children($chart) as $axis_key) {
if ($chart[$axis_key]['#type'] === 'chart_xaxis') {
if (!empty($chart[$axis_key]['#continuous'])) {
foreach ($chart[$axis_key]['#labels'] as $label_index => $label) {
if ($chart[$axis_key]['#continuous'] === 'date') {
$series['data'][$label_index][0] = 'U' . charts_convert_date_value($label);
}
else {
$series['data'][$label_index][0] = $label + 0;
}
}
}
}
}
// Allow data to provide the labels. This will override the axis settings. // Allow data to provide the labels. This will override the axis settings.
if ($chart[$key]['#labels']) { if ($chart[$key]['#labels']) {
foreach ($chart[$key]['#labels'] as $label_index => $label) { foreach ($chart[$key]['#labels'] as $label_index => $label) {
......
...@@ -197,7 +197,6 @@ class charts_plugin_style_chart extends views_plugin_style { ...@@ -197,7 +197,6 @@ class charts_plugin_style_chart extends views_plugin_style {
$chart['xaxis'] = array( $chart['xaxis'] = array(
'#type' => 'chart_xaxis', '#type' => 'chart_xaxis',
'#title' => $this->options['xaxis_title'] ? $this->options['xaxis_title'] : FALSE, '#title' => $this->options['xaxis_title'] ? $this->options['xaxis_title'] : FALSE,
'#continuous' => $this->options['xaxis_continuous'],
'#labels_rotation' => $this->options['xaxis_labels_rotation'], '#labels_rotation' => $this->options['xaxis_labels_rotation'],
); );
$chart['yaxis'] = array( $chart['yaxis'] = array(
...@@ -266,12 +265,6 @@ class charts_plugin_style_chart extends views_plugin_style { ...@@ -266,12 +265,6 @@ class charts_plugin_style_chart extends views_plugin_style {
// Execute the subview and get the result. // Execute the subview and get the result.
$subview->pre_execute(); $subview->pre_execute();
$subview->execute(); $subview->execute();
// If there's no results, don't attach the subview.
if (empty($subview->result)) {
continue;
}
$subchart = $subview->style_plugin->render($subview->result); $subchart = $subview->style_plugin->render($subview->result);
$subview->post_execute(); $subview->post_execute();
unset($subview); unset($subview);
......
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