You are here

function easychart_admin in Easychart 7.2

Same name and namespace in other branches
  1. 7 easychart.module \easychart_admin()
1 string reference to 'easychart_admin'
easychart_menu in ./easychart.module

File

./easychart.module, line 457
Easychart module file.

Code

function easychart_admin($form, $form_state) {
  if (!isset($form_state['storage']['confirm'])) {
    $form = array();
    $form['highchart_ui_options'] = array(
      '#type' => 'textarea',
      '#title' => t('Available UI options'),
      '#default_value' => variable_get('highchart_ui_options', '
      {
        "panels": [
          {
            "panelTitle": "Chart settings",
            "pane": [
              {
                "title": "Chart type and interaction",
                "options": [{"name":"chart.type","defaults":"column"},"chart.inverted","chart.zoomType"]
              },
              {
                "title": "Size and margins",
                "options": ["chart.width","chart.height","chart.spacingTop","chart.spacingRight","chart.spacingBottom","chart.spacingLeft"]
              }
            ]
          },
          {
            "panelTitle": "Colors and borders",
            "pane": [
              {
                "title": "default colors",
                "options":["colors"]
              },
              {
                "title": "Chart area",
                "options": ["chart.backgroundColor","chart.borderWidth","chart.borderRadius","chart.borderColor"]
              },
              {
                "title": "Plot area",
                "options": ["chart.plotBackgroundColor","chart.plotBackgroundImage","chart.plotBorderWidth","chart.plotBorderColor"]
              }
            ]
          },
          {
            "panelTitle": "Titles",
            "pane": [
              {
                "title":"Titles",
                "options": ["title.text","subtitle.text","yAxis.title.text","xAxis.title.text"]
              },
              {
                "title":"Title advanced",
                "options": ["title.style"]
              }
            ]
          },
          {
            "panelTitle": "Axes",
            "pane": [
              {
                "title":"Axes setup",
                "options": []
              },
              {
                "title":"X axis",
                "options": [{"name":"xAxis.type","defaults":"category"},"xAxis.min","xAxis.opposite","xAxis.reversed","xAxis.tickInterval","xAxis.labels.format","xAxis.labels.rotation","xAxis.labels.align"]
              },
              {
                "title":"Value axis",
                "options": ["yAxis.type","yAxis.min","yAxis.opposite","yAxis.reversed","yAxis.labels.format","yAxis.labels.rotation"]
              }
            ]
          },
          {
            "panelTitle": "Legend",
            "pane": [
              {
                "title":"General",
                "options": ["legend.enabled","legend.layout"]
              },
              {
                "title":"Placement",
                "options": ["legend.align","legend.verticalAlign"]
              },
              {
                "title":"Color and border",
                "options": []
              }
            ]
          },
          {
            "panelTitle": "Tooltip",
            "pane": [
              {
                "title":"General",
                "options": ["tooltip.headerFormat","tooltip.pointFormat","tooltip.valuePrefix","tooltip.valueSuffix"]
              },
              {
                "title":"Color and border",
                "options": []
              }
            ]
          },
          {
            "panelTitle": "Exporting",
            "pane": [
              {
                "title":"Exporting",
                "options": ["exporting.enabled"]
              }
            ]
          }
        ]
      }
      '),
      '#description' => t("These Highcharts options will be configurable in the Easychart interface when creating/editing a chart. See !url for all available options.", array(
        '!url' => l('http://api.highcharts.com/highcharts', 'http://api.highcharts.com/highcharts', array(
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
      )),
      '#required' => TRUE,
      '#rows' => 15,
    );
    $form['global_highchart_options'] = array(
      '#type' => 'textarea',
      '#title' => t('Global Options'),
      '#default_value' => variable_get('global_highchart_options', ""),
      '#description' => t("Warning: these options will be applied to all Highcharts based charts on this website."),
      '#rows' => 10,
    );

    // Add the reset button.
    $form['actions']['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset to defaults'),
      '#submit' => array(
        'easychart_admin_submit',
      ),
      '#limit_validation_errors' => array(),
      '#weight' => 100,
    );
  }
  else {
    return confirm_form($form, t('Are you sure you want to reset the options to their default values?'), current_path());
  }
  return system_settings_form($form);
}