Extension talk:Gchart4mw

From MediaWiki.org
Jump to navigation Jump to search

Getting Data From Templates[edit]

Many thanks for this extension. I would love to generate Google Charts from data held in wiki templates/pages. e.g.

<pie title="Bundestagswahl 2005" 3d="3d" size="300x150" xlabel="xlabel">

{{:ChartData/Bundestagswahl}}

</pie>

--86.138.17.210 23:21, 26 January 2009 (UTC)


Security Issues[edit]

This is a great wiki extension for public wikis. However, if your wiki is intranet based you may be sending info out that is sensitive (because Google renders the image from a url that is not secured). So at the very least you are sharing your data with Google and also with any one who picks up the communication.

Even with this draw back this is still a useful extension for internal wikis, it just needs to be clear that the data being charted is heading out on the internet. I modified gchart4mw.php to include a warning label. Here is the changed code:


// -----------------------------------------------------------------------------
function gfLinesRender( $input, $args, $parser ) {
  global $gchartWikiDefaults;
  global $gchartLinesDefaults;

  gfChartInit ();
  gfArgsParseCommon ($gchartWikiDefaults);
  gfArgsParseCommon ($gchartLinesDefaults);
  gfArgsParseCommon ($args);

  $retval = '';

  // Insert a dislamer caption
  $retval = '<table class="image"><caption align="bottom"><font size = "1">Image rendered By Google. Do not use proprietary or confidential data.</font></caption><tr><td>';

  $retval = $retval . gfArgsRenderCommon();
  $retval = $retval . gfArgsRenderLine();
  $retval = $retval . gfInputParseCSV($input,"line");
  $retval = $retval . '">';

  // Finish Insert caption
  $retval = $retval . '</td></tr></table>';

  return $retval;
}

function gfBarsRender( $input, $args, $parser ) {
  global $gchartWikiDefaults;
  global $gchartBarsDefaults;

  gfChartInit ();
  gfArgsParseCommon ($gchartWikiDefaults);
  gfArgsParseCommon ($gchartBarsDefaults);
  gfArgsParseCommon ($args);

  $retval = '';

  // Insert a dislamer caption
  $retval = '<table class="image"><caption align="bottom"><font size = "1">Image rendered By Google. Do not use proprietary or confidential data.</font></caption><tr><td>';

  $retval = $retval . gfArgsRenderCommon();
  $retval = $retval . gfArgsRenderBars();
  $retval = $retval . gfInputParseCSV($input,"bars");
  $retval = $retval . '">';

  // Finish Insert caption
  $retval = $retval . '</td></tr></table>';

  return $retval;
}

function gfPieRender( $input, $args, $parser ) {
  global $gchartWikiDefaults;
  global $gchartPieDefaults;

  gfChartInit ();
  gfArgsParseCommon ($gchartWikiDefaults);
  gfArgsParseCommon ($gchartPieDefaults);
  gfArgsParseCommon ($args);

  $retval = '';

  // Insert a dislamer caption
  $retval = '<table class="image"><caption align="bottom"><font size = "1">Image rendered By Google. Do not use proprietary or confidential data.</font></caption><tr><td>';

  $retval = $retval . gfArgsRenderCommon();
  $retval = $retval . gfArgsRenderPie();
  $retval = $retval . gfInputParseCSV($input,"pie");
  $retval = $retval . '">';

  // Finish Insert caption
  $retval = $retval . '</td></tr></table>';

This will render the image looking like this:
PieWithWarning.jpg


Dear Vaccano,

you are right! All data of the charts is being transmitted to google. And altough it is scaled to a value between 0 and 100 before sending, it might be a security concern for sensitive data.

If you don´t mind I would like to add a disclaimer like yours to the next release of this extension - maybe configurable with a parameter in LocalSettings.php?

sincerely

--Lef73 20:23, 23 January 2008 (UTC)

Sounds great to me! I look forward to using your updated version. --Vaccano 19:15, 28 January 2008 (UTC)

Horizontal bug[edit]

When you flip the bar chart to be horizontal, it seems to flip the array of the items displayed. For instance:

<bars title="Stuff" ymin=0 ylabel=2 xlabel horizontal>
Cars, 3
Cucumbers, 7
Iglos, 2
</bars>

This will draw a chart where the numbers show up in the right order, but the names are flipped (Iglos come first, followed by cucumbers and then cars, rather than the other way around).

Horizontal bug: Fix[edit]

Version gchart4mw.php of 2008-01-05 shows a wrong order of labels in case of a Horizontal Bar. This can be easily fixed however by applying underneath fix to gchart4mw.php.

Replace this code:

if ($type == "pie") {
    if ($hasxlabel) {
      $rslt = $rslt . "&chl=" . $xlabel;
    }
  } else {    
    if (($hasxlabel) && ($hasylabel)) {
      if ($ishorizontal)
        $rslt = $rslt . "&chxt=x,y";
      else
        $rslt = $rslt . "&chxt=y,x";
      $rslt = $rslt . "&chxl=0:|" . $ylabel . "|1:|" . $xlabel;
  }

With this:

if ($type == "pie") {
    if ($hasxlabel) {
      $rslt = $rslt . "&chl=" . $xlabel;
    }
  } else {    
    if (($hasxlabel) && ($hasylabel)) {
      if ($ishorizontal) {
        $rslt = $rslt . "&chxt=x,y";
        $xlabel = implode('|', array_reverse(explode('|', $xlabel)));
      }
      else
        $rslt = $rslt . "&chxt=y,x";
      $rslt = $rslt . "&chxl=0:|" . $ylabel . "|1:|" . $xlabel;
  }

The key to the solution is reversing the labels in case of a horizontal bar, this happens in the extra line of code:

        $xlabel = implode('|', array_reverse(explode('|', $xlabel)));

Note: The post of this fix can be deleted when this problem is fixed in a new distributed version of gchart4mw.php.

Conlict with other extension.[edit]

It conflicts with Extension:RSS. RSS readers stops working if both extensions are installed --OsvaldoGago 15:00, 29 January 2010 (UTC)

Set and get value to chart[edit]

i'm using combination of runphp and gchart4mw.


$num = 20;

printf("<pie 3d title='Bug List' size=300x150 xlabel>

Open,$num

Fixed,20

Close,91

</pie>

");


now the problem is, i'm getting string of "$num" instead of 20 in the pie tag. have any solution for this problem?

Google Code Shutting Down[edit]

Hello, As you are likely aware, Google is shutting down their Google Code service in January of 2016. This extension appears to house its code with Google Code and is at risk to creating broken links and confusion of users in the near future.

I’m helping to let folks know about this coming update and provide some helpful links to make this migration easy. I hope you’ll take a moment and migrate your extension to a new hosting solution.

For extensions that have a compatible license, you can request developer access to the MediaWiki source repositories for extensions and get a new repository created for you. Alternatively, you may also export your code to other popular repositories such as Github and Bitbucket. Google has provided tools to help with this migration.

Ckoerner (talk) 17:17, 7 July 2015 (UTC)