Skip to content
Snippets Groups Projects
Commit 69e749d0 authored by Bruno Massa's avatar Bruno Massa
Browse files

Improvements:

* Views integration now uses the same settings form was the Default Settings page.
* It also consider the default settings
parent 3dd923c6
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,10 @@ class charts_plugin_style_chart extends views_plugin_style { ...@@ -17,10 +17,10 @@ class charts_plugin_style_chart extends views_plugin_style {
* Set default options. * Set default options.
*/ */
function options(&$options) { function options(&$options) {
$options['format'] = 'pie2D'; // Get the default chart values
$options['height'] = 200; module_load_include('inc', 'charts');
$options['width'] = 400; $options['charts'] = _charts_settings();
$options['color'] = 'ffffff';
$options['aggregation_field'] = ''; $options['aggregation_field'] = '';
$options['calc_fields'] = array(); $options['calc_fields'] = array();
$options['calc'] = 'COUNT'; $options['calc'] = 'COUNT';
...@@ -33,41 +33,11 @@ class charts_plugin_style_chart extends views_plugin_style { ...@@ -33,41 +33,11 @@ class charts_plugin_style_chart extends views_plugin_style {
function options_form(&$form, &$form_state) { function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state); parent::options_form($form, $form_state);
$form['format'] = array( // Add the Chart Settings form
'#type' => 'select', module_load_include('admin.inc', 'charts');
'#title' => t('Chart format'), $form['charts']['#tree'] = TRUE;
'#options' => array( _charts_settings_form($form['charts'], $this->options['charts']);
'line2D' => t('Line 2D'),
'hbar2D' => t('Horizontal Bar 2D'),
'vbar2D' => t('Vertical Bar 2D'),
'pie2D' => t('Pie 2D'),
'pie3D' => t('Pie 3D'),
'venn' => t('Venn'),
'scatter' => t('Scatter Plot')
),
'#default_value' => $this->options['format'],
);
$form['height'] = array(
'#type' => 'textfield',
'#title' => t('Chart height'),
'#default_value' => $this->options['height'],
'#required' => TRUE, // Google charts breaks if it is empty.
'#description' => t('An integer value, the number of pixels of height for this chart.'),
);
$form['width'] = array(
'#type' => 'textfield',
'#title' => t('Chart width'),
'#default_value' => $this->options['width'],
'#required' => TRUE, // Google charts breaks if it is empty.
'#description' => t('An integer value, the number of pixels of width for this chart.'),
);
$form['color'] = array(
'#type' => 'textfield',
'#title' => t('Background color'),
'#default_value' => $this->options['color'],
'#description' => t('In hexadecimal format (RRGGBB). Do not use the # symbol.'),
'#required' => TRUE, // Google charts breaks if it is empty.
);
$form['show_legend'] = array( $form['show_legend'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Show legend'), '#title' => t('Show legend'),
...@@ -75,6 +45,7 @@ class charts_plugin_style_chart extends views_plugin_style { ...@@ -75,6 +45,7 @@ class charts_plugin_style_chart extends views_plugin_style {
'#description' => t('Display legend next to the chart.'), '#description' => t('Display legend next to the chart.'),
); );
// Views Calc related fields
$form['aggregation_field'] = array( $form['aggregation_field'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Aggregation field'), '#title' => t('Aggregation field'),
...@@ -150,16 +121,10 @@ class charts_plugin_style_chart extends views_plugin_style { ...@@ -150,16 +121,10 @@ class charts_plugin_style_chart extends views_plugin_style {
* Define and display a chart from the grouped values. * Define and display a chart from the grouped values.
*/ */
function render() { function render() {
// Scan all Views data and insert them into a series.
// Get chart settings from options form. // Get chart settings from options form.
$chart = array( foreach ($this->options['charts'] as $index => $value) {
'#type' => $this->options['format'], $chart['#'. $index] = $value;
'#height' => $this->options['height'], }
'#width' => $this->options['width'],
'#color' => $this->options['color'],
'#title' => $this->view->get_title(),
);
// Get values from rows. // Get values from rows.
foreach ($this->calc_fields() as $calc) { foreach ($this->calc_fields() as $calc) {
......
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