tra('Chart'), 'documentation' => 'PluginChart', 'description' => tra('Display a chart from TikiSheet.'), 'prefs' => [ 'feature_sheet', 'wikiplugin_chart' ], 'iconname' => 'chart', 'body' => tra('Chart caption.'), 'introduced' => 2, 'params' => [ 'id' => [ 'required' => true, 'name' => tra('Spreadsheet ID'), 'description' => tra('Data sheet ID'), 'since' => '2.0', 'filter' => 'digits', 'profile_reference' => 'sheet', ], 'type' => [ 'required' => true, 'name' => tra('Chart Type'), 'description' => tra('Specify a valid chart type'), 'accepted' => 'BarStackGraphic | MultibarGraphic | MultilineGraphic | PieChartGraphic', 'since' => '2.0', 'filter' => 'word', ], 'width' => [ 'required' => true, 'name' => tra('Chart Width'), 'description' => tra('Width in pixels.'), 'since' => '2.0', 'filter' => 'digits', ], 'height' => [ 'required' => true, 'name' => tra('Chart Height'), 'description' => tra('Height in pixels.'), 'since' => '2.0', 'filter' => 'digits', ], 'value' => [ 'required' => false, 'name' => tra('Value series'), 'description' => tra('Required for pie charts'), 'since' => '2.0', 'filter' => 'text', ], 'x' => [ 'required' => false, 'name' => tra('Independent series'), 'description' => tra('Required for types other than pie chart'), 'since' => '2.0', 'filter' => 'text', ], 'y0' => [ 'required' => false, 'name' => tra('Dependent series'), 'description' => tra('Required for types other than pie chart'), 'since' => '2.0', 'filter' => 'text', ], 'y1' => [ 'required' => false, 'name' => tra('Dependent series'), 'description' => tra('Description needed'), 'since' => '2.0', 'filter' => 'text', ], 'y2' => [ 'required' => false, 'name' => tra('Dependent series'), 'description' => tra('Description needed'), 'since' => '2.0', 'filter' => 'text', ], 'y3' => [ 'required' => false, 'name' => tra('Dependent series'), 'description' => tra('Description needed'), 'since' => '2.0', 'filter' => 'text', ], 'y4' => [ 'required' => false, 'name' => tra('Dependent series'), 'description' => tra('Description needed'), 'since' => '2.0', 'filter' => 'text', ], 'color' => [ 'required' => false, 'name' => tra('Colors'), 'description' => tra('List of colors to use.'), 'since' => '2.0', 'filter' => 'text', ], 'style' => [ 'required' => false, 'name' => tra('Styles'), 'description' => tra('List of styles to use.'), 'since' => '2.0', 'filter' => 'text', ], 'label' => [ 'required' => false, 'name' => tra('Labels'), 'description' => tra('Labels for the series or values in the legend.'), 'since' => '2.0', 'filter' => 'text', ], ], ]; } function wikiplugin_chart($data, $params) { extract($params, EXTR_SKIP); if (! isset($id)) { return ("missing id parameter for plugin
"); } if (! isset($type)) { return ("missing type parameter for plugin
"); } $params = [ "sheetId" => $id, "graphic" => $type, "title" => $data ]; switch ($type) { case 'PieChartGraphic': if (! isset($value)) { return "missing value parameter for plugin
"; } $params['series[value]'] = $value; break; default: $params['independant'] = isset($independant) ? $independant : 'horizontal'; $params['horizontal'] = isset($horizontal) ? $horizontal : 'bottom'; $params['vertical'] = isset($vertical) ? $vertical : 'left'; if (! isset($x)) { return "missing x parameter for plugin
"; } $params['series[x]'] = $x; for ($i = 0; isset(${'y' . $i}); $i++) { $params['series[y' . $i . ']'] = ${'y' . $i}; } break; } $params['series[color]'] = isset($color) ? $color : ''; $params['series[style]'] = isset($style) ? $style : ''; $params['series[label]'] = isset($label) ? $label : ''; if (function_exists('imagepng')) { if (! isset($width)) { return "missing width parameter for plugin
"; } if (! isset($height)) { return "missing height parameter for plugin
"; } $params['width'] = $width; $params['height'] = $height; $disp = ''; } elseif (function_exists('image_jpeg')) { if (! isset($width)) { return "missing width parameter for plugin
"; } if (! isset($height)) { return "missing height parameter for plugin
"; } $params['width'] = $width; $params['height'] = $height; $disp = ''; } elseif (function_exists('pdf_new')) { $disp = tra("Chart as PDF"); } elseif (function_exists('ps_new')) { $disp = tra("Chart as PostScript"); } else { return "no valid renderer for plugin
"; } if (function_exists('pdf_new')) { $params['format'] = isset($format) ? $format : 'A4'; $params['orientation'] = isset($orientation) ? $orientation : 'landscape'; $disp = '' . $disp . ''; } elseif (function_exists('ps_new')) { $params['format'] = isset($format) ? $format : 'A4'; $params['orientation'] = isset($orientation) ? $orientation : 'landscape'; $disp = '' . $disp . ''; } return $disp; } function _wikiplugin_chart_uri($params, $renderer) { $params['renderer'] = $renderer; $array = []; foreach ($params as $key => $value) { $array[] = rawurlencode($key) . '=' . rawurlencode($value); } return 'tiki-graph_sheet.php?' . implode('&', $array); }