Skip to content

Commit

Permalink
Merge pull request #1 from hyperzlib/master
Browse files Browse the repository at this point in the history
fix some problems
  • Loading branch information
redekopmark authored Apr 23, 2022
2 parents f07a107 + ad61f9a commit 81d7568
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 15 deletions.
6 changes: 3 additions & 3 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
"value": ""
},
"PChart4mwPChartPath": {
"value": "/home/ssd_aiowiki/aiowiki.com/w/extensions/pChart4mw/pChart"
"value": "extensions/pChart4mw/pChart"
},
"PChart4mwFontPath": {
"value": "/home/ssd_aiowiki/aiowiki.com/w/extensions/pChart4mw/fonts"
"value": "extensions/pChart4mw/fonts"
},
"PChart4mwDefaultColorSchemeDir": {
"value": "/home/ssd_aiowiki/aiowiki.com/w/extensions/pChart4mw/colorschemes"
"value": "extensions/pChart4mw/colorschemes"
}
},
"manifest_version": 2
Expand Down
Binary file added fonts/NotoSansCJKsc-Regular.otf
Binary file not shown.
2 changes: 1 addition & 1 deletion pChart/pCache.class
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
var $CacheFolder = "Cache/";

/* Create the pCache object */
function pCache($CacheFolder="Cache/")
function __construct($CacheFolder="Cache/")
{
$this->CacheFolder = $CacheFolder;
}
Expand Down
2 changes: 1 addition & 1 deletion pChart/pChart.class
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
var $MapID = NULL;

/* This function create the background picture */
function pChart($XSize,$YSize)
public function __construct($XSize,$YSize)
{
$this->XSize = $XSize;
$this->YSize = $YSize;
Expand Down
2 changes: 1 addition & 1 deletion pChart/pData.class
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
var $Data;
var $DataDescription;

function pData()
function __construct()
{
$this->Data = "";
$this->DataDescription = "";
Expand Down
27 changes: 20 additions & 7 deletions pChart4mw.class.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function parseData( $rawData ) {
}

// Parse the raw data. This raw data is in CSV format, with lines separated by a \n
$rawData = str_replace( ';', "\n", $rawData );
$lines = explode( "\n", $rawData );
$serieNames = array();
$xlabels = false;
Expand Down Expand Up @@ -183,6 +184,18 @@ public function parseData( $rawData ) {
// Match the number of serie names with the number of series
$serieNames = array_pad( $serieNames, $numberColumns, "" );

$serieNamesEmpty = true;
foreach ( $serieNames as $serieName ) {
if ( !empty( $serieName ) ) {
$serieNamesEmpty = false;
break;
}
}
// Remove legend when serie names is empty
if ( $serieNamesEmpty ) {
$this->chartArgs[ "legend" ] = false;
}

// Check whether any data is entered. If not, no further action has to be done
if( $numberRows == 0 || $numberColumns == 0 ) {
$this->pData = $pData;
Expand Down Expand Up @@ -619,17 +632,17 @@ public function getDefaultArgs() {

// Default margin in pixels
"marginX" => 10,
"marginY" => 10,
"marginY" => 20,

// Fontsize used to write text into the chart (labels and legend)
"textsize" => 8,
"textfont" => "tahoma.ttf",
"textsize" => 9,
"textfont" => "NotoSansCJKsc-Regular.otf",

// Default title, color for the title and font size
"title" => "",
"titlecolor" => array( 119, 119, 119 ),
"titlesize" => 10,
"titlefont" => "tahoma.ttf",
"titlesize" => 12,
"titlefont" => "NotoSansCJKsc-Regular.otf",

// Default title for the axes, unit (shown after the number, e.g. 150kg) and format (number, time, date)
"xtitle" => "",
Expand Down Expand Up @@ -771,7 +784,7 @@ public function showChart( $input, $args ) {
// Parse arguments and data
$this->parseData( $input );
$this->parseArgs( $args );
$this->updateDataBasedOnArgs();
$this->updateArgsBasedOnData();

// Draw the graph
$this->drawChart();
Expand Down Expand Up @@ -828,7 +841,7 @@ public function htmlCode( $imgURL = "" ) {
$imgURL = htmlspecialchars($this->getUploadDir() . "/" . $this->filename );
}

return '<p><b><img src="' . $imgURL . '" alt="pChart" /></b></p>';
return '<img src="' . $imgURL . '" alt="pChart" />';
}

// **************************************************************************************
Expand Down
14 changes: 12 additions & 2 deletions pChart4mw.radar.class.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ class pChart4mwRadar extends pChart4mw {
* parse wiki text, expand braces, register link relationships and dependencies etc.
* @returns String HTML code to show the pie chart
*/
public static function render( $input, $args, $parser ) {
public static function render( $input, $args, $parser, $frame = null ) {
foreach( $args as $key => $value ){
if( substr( trim( $value ), 0, 3 ) === '{{{' ){
$args[ $key ] = $parser->recursiveTagParse( $value, $frame );
}
}

// Recursively parse the wikitext
$parsedText = $parser->recursiveTagParse( $input );
$parsedText = $parser->recursiveTagParse( $input, $frame );

// Create the chart
$chart = new pChart4mwRadar();
Expand Down Expand Up @@ -82,6 +88,9 @@ public function parseArgs( $args, $default = false ) {
$this->chartArgs[ "stripecolor" ] = wfPChart4mwhtml2rgb( $args[ "stripecolor" ] );
}

// in order to vertical align center, should disable labels
$this->chartArgs[ "labels" ] = false;

return $this->chartArgs;
}

Expand All @@ -96,6 +105,7 @@ public function getDefaultArgs() {
// Set radar-specific default arguments
$args[ "filled" ] = false;
$args[ "striped" ] = false;
$args[ "labels" ] = false;
$args[ "stripecolor" ] = array( 200, 200, 200 );
$args[ "opacity" ] = 50;

Expand Down

0 comments on commit 81d7568

Please sign in to comment.