Example #1
0
 public function init()
 {
     $meta = $this->getMeta();
     if (!empty($meta)) {
         DatawrapperVisualization::register($this, $meta);
     }
 }
Example #2
0
 public function init()
 {
     $meta = $this->getMeta();
     $datasets = $this->getDemoDataSets();
     $demo_hook = DatawrapperHooks::GET_DEMO_DATASETS;
     if (!empty($meta)) {
         DatawrapperVisualization::register($this, $meta);
     }
     if (!empty($datasets)) {
         $first_element = reset($datasets);
         if (is_array($first_element)) {
             foreach ($datasets as $key => $dataset) {
                 DatawrapperHooks::register($demo_hook, function () use($dataset) {
                     return $dataset;
                 });
             }
         } else {
             DatawrapperHooks::register($demo_hook, function () use($datasets) {
                 return $datasets;
             });
         }
     }
 }
Example #3
0
<?php

DatawrapperVisualization::register($plugin, array('id' => 'bar-chart', 'title' => __('bar chart'), 'version' => '1.3.2', 'extends' => 'raphael-chart', 'order' => 995, 'dimensions' => 1, 'axes' => array('labels' => array('accepts' => array('text', 'date')), 'bars' => array('accepts' => array('number'), 'multiple' => true)), 'options' => array('base-color' => array('type' => 'base-color', 'label' => __('base-color')), 'sort-values' => array('type' => 'checkbox', 'label' => __('sort-bars')), 'reverse-order' => array('type' => 'checkbox', 'label' => __('reverse-order')), 'negative-color' => array('type' => 'checkbox', 'label' => __('negative-values'), 'depends-on' => array('chart.min_value[columns]' => '<0')), 'absolute-scale' => array('type' => 'checkbox', 'label' => __('same-scale')), 'filter-missing-values' => array('type' => 'checkbox', 'default' => true, 'label' => __('filter-missing'))), 'libraries' => array()));
Example #4
0
 public function init()
 {
     DatawrapperVisualization::register($this, $this->getMeta_Simple());
     DatawrapperVisualization::register($this, $this->getMeta_Grouped());
     DatawrapperVisualization::register($this, $this->getMeta_Stacked());
 }
Example #5
0
<?php

$asset_domain = $GLOBALS['dw_config']['asset_domain'];
$asset_url = '//' . $asset_domain . '/';
DatawrapperVisualization::register($plugin, array("id" => "raphael-chart", "libraries" => array(array("local" => "vendor/d3-light.min.js", "cdn" => !empty($asset_domain) ? $asset_url . "vendor/d3-light/3.1.8/d3-light.min.js" : null), array("local" => "vendor/chroma.min.js", "cdn" => !empty($asset_domain) ? $asset_url . "vendor/chroma-js/0.5.4/chroma.min.js" : null), array("local" => "vendor/raphael-2.1.2.min.js", "cdn" => !empty($asset_domain) ? $asset_url . "vendor/raphael-js/2.1.2/raphael-min.js" : null))));
Example #6
0
<?php

DatawrapperVisualization::register($plugin, array('title' => __('Line Chart'), 'id' => 'line-chart', 'extends' => 'raphael-chart', 'dimensions' => 2, 'order' => 40, 'axes' => array('x' => array('accepts' => array('text', 'date')), 'y1' => array('accepts' => array('number'), 'multiple' => true), 'y2' => array('accepts' => array('number'), 'multiple' => true, 'optional' => true)), 'options' => array('base-color' => array('type' => 'base-color', 'label' => __('Base color')), 'sep-labeling' => array('type' => 'separator', 'label' => __('Customize labeling'), 'depends-on' => array('chart.min_columns[y1]' => 2)), 'direct-labeling' => array('type' => 'checkbox', 'label' => __('Direct labeling'), 'default' => false, 'depends-on' => array('chart.min_columns[y1]' => 2, 'chart.max_columns[y2]' => 0), 'help' => __('Show the labels right nearby the line ends instead of a separate legend')), 'legend-position' => array('type' => 'radio-left', 'label' => __('Legend position'), 'default' => 'right', 'depends-on' => array('direct-labeling' => false, 'chart.min_columns[y1]' => 2), 'options' => array(array('value' => 'right', 'label' => __('right')), array('value' => 'top', 'label' => __('top')), array('value' => 'inside', 'label' => __('inside left')), array('value' => 'inside-right', 'label' => __('inside right')))), 'sep-lines' => array('type' => 'separator', 'label' => __('Customize lines')), 'show-grid' => array('type' => 'checkbox', 'hidden' => true, 'label' => __('Show grid'), 'default' => false), 'connect-missing-values' => array('type' => 'checkbox', 'label' => __('Connect lines between missing values')), 'fill-between' => array('type' => 'checkbox', 'label' => __('Fill area between lines'), 'default' => false, 'depends-on' => array('chart.min_columns[y1]' => 2, 'chart.max_columns[y1]' => 2, 'chart.max_columns[y2]' => 0)), 'fill-below' => array('type' => 'checkbox', 'label' => __('Fill area below line'), 'defaut' => false, 'depends-on' => array('chart.min_columns[y1]' => 1, 'chart.max_columns[y1]' => 1, 'chart.max_columns[y2]' => 0)), 'banking' => array('type' => 'linechart-banking', 'label' => __('Suggest aspect ratio that banks average line slopes to 45°'), 'help' => __('Adjust the chart height so that the lines are banked to 45° (on average). Can help to avoid exaggerating and understating of slopes.')), 'line-mode' => array('type' => 'radio-left', 'label' => __('Line interpolation'), 'options' => array(array('label' => __('Straight'), 'value' => 'straight'), array('label' => __('Curved'), 'value' => 'curved'), array('label' => __('Stepped'), 'value' => 'stepped')), 'default' => 'straight'), 'sep-y-axis' => array('type' => 'separator', 'label' => __('Customize y-axis')), 'custom-range-y' => array('type' => 'custom-range', 'label' => __('Custom range'), 'help' => __('This feature allows you to explicitely extend the y axis to custom values. Swap min/max to invert the axis.')), 'scale-y1' => array('type' => 'radio-left', 'label' => __('Scale (y-axis)'), 'options' => array(array('label' => __('linear'), 'value' => 'linear'), array('label' => __('logarithmic'), 'value' => 'log')), 'default' => 'linear', 'depends-on' => array('chart.min_value[y1]' => '>0', 'chart.magnitude_range[y1]' => '>3')), 'user-change-scale' => array('type' => 'checkbox', 'label' => __('Let user change scale'), 'default' => false, 'depends-on' => array('chart.min_value[y1]' => '>0', 'chart.magnitude_range[y1]' => '>3')), 'annotate-time-axis' => array('type' => 'textarea', 'label' => __('Annotate x axis') . ':', 'placeholder' => 'from,to,text', 'width' => '180px')), 'locale' => array('tooManyLinesToLabel' => __('Your chart contains <b>more lines than we can label</b>, so automatic labeling is turned off. To fix this <ul><li>filter some columns in the data table in the previous step, or</li><li>use direct labeling and the highlight feature to label the lines that are important to your story.</li></ul>'), 'useLogarithmicScale' => __('Use logarithmic scale'), 'couldNotParseAllDates' => str_replace('%s', 'http://blog.datawrapper.de/2013/cleaning-your-data-in-datawrapper/', __('Some of the <b>dates in your x-axis could not be parsed</b>, hence the line chart cannot display a proper date axis. To fix this<ul><li>return to the previous step and clean your date column.</li><li><a href="%s">Read more about how to do this.</a></li></ul>')))));
global $app;
DatawrapperHooks::register(DatawrapperHooks::VIS_OPTION_CONTROLS, function ($o, $k) use($app, $plugin) {
    $env = array('option' => $o, 'key' => $k);
    $app->render('plugins/' . $plugin->getName() . '/banking.twig', $env);
});
$plugin->declareAssets(array('banking.js'), "|/chart/[^/]+/visualize|");
Example #7
0
<?php

DatawrapperVisualization::register($plugin, array('id' => 'election-donut-chart', 'title' => __('Election Donut'), 'extends' => 'donut-chart', 'dimensions' => 1, 'order' => 60, 'axes' => array('labels' => array('accepts' => array('text', 'date')), 'slices' => array('accepts' => array('number'), 'multiple' => true)), 'options' => array('base-color' => array('type' => 'base-color', 'label' => __('Base color')), 'sort-values' => array('type' => 'checkbox', 'label' => __('Sort by size'), 'default' => true))));
Example #8
0
 function init()
 {
     DatawrapperVisualization::register($this, $this->getMeta_PieChart());
     DatawrapperVisualization::register($this, $this->getMeta_DonutChart());
 }
Example #9
0
<?php

DatawrapperVisualization::register($plugin, array('id' => 'pie-chart', 'title' => __('Pie chart'), 'extends' => 'raphael-chart', 'author' => array('name' => 'gka', 'email' => '*****@*****.**'), 'order' => 50, 'dimensions' => 1, 'axes' => array('labels' => array('accepts' => array('text', 'date')), 'slices' => array('accepts' => array('number'), 'multiple' => true)), 'color-by' => 'row', 'options' => array('base-color' => array('type' => 'base-color', 'label' => __('Base color')), 'group-slice-after' => array('type' => 'number', 'label' => __('Maximum amount of slices'), 'default' => '5', 'depends-on' => array('chart.min_row_num' => 3), 'min' => 2, 'max' => 100)), 'locale' => array('other' => __('other'), 'cannotShowNegativeValues' => __('Pie charts are intended to show part-of-whole relations, and thus they <b>cannot be used to display negative numbers</b>. Please consider using a different chart type instead (eg. a bar chart).'), 'noMoreThanFiveSlices' => __('Your data contains <b>more values than can be shown in a pie chart</b>, so we grouped %count slices into the slice named <i>"others"</i>.<p>Why not use a bar chart to allow better comparison of values?</p>')), 'libraries' => array()));
DatawrapperVisualization::register($plugin, array('id' => 'donut-chart', 'title' => __('Donut chart'), 'version' => '1.3.0', 'extends' => 'pie-chart', 'author' => array('name' => 'gka', 'email' => '*****@*****.**'), 'order' => 60, 'dimensions' => 1, 'axes' => array('labels' => array('accepts' => array('text', 'date')), 'slices' => array('accepts' => array('number'), 'multiple' => true)), 'options' => array('base-color' => array('type' => 'base-color', 'label' => __('Base color')), 'show-total' => array('type' => 'checkbox', 'label' => __('Show total value in center'), 'default' => true), 'custom-total' => array('type' => 'checkbox', 'label' => __('Use custom total value instead of sum'), 'default' => false, 'depends-on' => array('show-total' => true, 'chart.max_row_num' => 1)), 'custom-total-value' => array('type' => 'text', 'label' => __('Custom total value'), 'depends-on' => array('show-total' => true, 'custom-total' => true)), 'group-slice-after' => array('type' => 'number', 'label' => __('Maximum amount of slices'), 'default' => '5', 'depends-on' => array('chart.min_row_num' => 3), 'min' => 2, 'max' => 100))));
Example #10
0
<?php

DatawrapperVisualization::register($plugin, array('id' => 'bar-chart', 'title' => __('Bar Chart'), 'version' => '1.3.2', 'extends' => 'raphael-chart', 'order' => 5, 'dimensions' => 1, 'axes' => array('labels' => array('accepts' => array('text', 'date')), 'bars' => array('accepts' => array('number'), 'multiple' => true)), 'options' => array('base-color' => array('type' => 'base-color', 'label' => __('Base color')), 'sort-values' => array('type' => 'checkbox', 'label' => __('Autmatically sort bars')), 'reverse-order' => array('type' => 'checkbox', 'label' => __('Reverse order')), 'negative-color' => array('type' => 'checkbox', 'label' => __('Use different color for negative values'), 'depends-on' => array('chart.min_value[columns]' => '<0')), 'absolute-scale' => array('type' => 'checkbox', 'label' => __('Use the same scale for all columns')), 'filter-missing-values' => array('type' => 'checkbox', 'default' => true, 'label' => __('Filter missing values'))), 'libraries' => array()));