Community Central
Register
Community Central
(Is nobody here who can help or give an advice?)
m (→‎JavaScript solution: Thanks a lot, that worked.)
 
(10 intermediate revisions by 4 users not shown)
Line 35: Line 35:
   
 
Is nobody here who can help or give an advice? [[User:Spankart|Spankart]] 12:57, 1 January 2008 (UTC)
 
Is nobody here who can help or give an advice? [[User:Spankart|Spankart]] 12:57, 1 January 2008 (UTC)
  +
  +
Why not save the chart and upload it as an image? -- [[User:LordTBT|<font color="Green">LordTBT</font>]] [[User talk:LordTBT|<sup><font color="Green" size="2">Talk!</font></sup>]] 00:57, 5 January 2008 (UTC)
  +
  +
:Because the great thing about this API is that the chart is created dynamically at runtime. This is particularly useful for charts that are updated regularly, but is also very helpful in all other cases (e.g. to customize and reformat the chart). [[User:Spankart|Spankart]] 16:48, 5 January 2008 (UTC)
  +
  +
== JavaScript solution ==
  +
  +
The code: [[User:Ciencia Al Poder/Render Google Charts.js]]. Copy, paste into your [[Special:Mypage/monobook.js]], (or quartz.js, depending on the current skin) save and reload to see here the result.
  +
  +
* [http://chart.apis.google.com/chart?cht=p3&chd=s:hW&chs=250x100&chl=Hello|World This text is shown when hovering the mouse]
  +
  +
* [http://chart.apis.google.com/chart?cht=p3&chd=s:hW&chs=250x100&chl=Hello|World Also <span style="color:red;">''this''</span>]
  +
  +
* <span class="plainlinks nochart">[http://chart.apis.google.com/chart?cht=p3&chd=s:hW&chs=250x100&chl=Hello|World This chart is not rendered]</span>
  +
  +
The chart images cannot be a link. --[[User:Ciencia Al Poder|Ciencia Al Poder]] ([[User talk:Ciencia Al Poder|talk]]) <sup>-[[w:c:es.pokemon|WikiDex]]</sup> 12:48, 5 January 2008 (UTC)
  +
  +
:You're a genius, Ciencia Al Poder! Thank you so much. I copied this into my wiki's [http://spankingart.wikia.com/wiki/MediaWiki:Common.js MediaWiki:Common.js] and it works perfectly. We should make this better known, I'm sure other wikis will find dynamic charts a great add-in too. [[User:Spankart|Spankart]] 16:48, 5 January 2008 (UTC)
  +
  +
: I'd make the script before, but I hadn't read the post, Have in mind that this only work with JavaScript enabled, so specify always a text to the link with a short description. Enjoy! --[[User:Ciencia Al Poder|Ciencia Al Poder]] ([[User talk:Ciencia Al Poder|talk]]) <sup>-[[w:c:es.pokemon|WikiDex]]</sup> 17:00, 5 January 2008 (UTC)
  +
  +
Could you pls. assess pro/cons of the javascript solution? Is it good enough or MW ext. should be written for this? -- [[User:Ppiotr|Nef]] <staff /> ([[User talk:Ppiotr|talk]]) 12:12, 14 January 2008 (UTC)
  +
  +
:: The JavaScript solution is safe: only renders links which url starts with "http://chart.apis.google.com/chart?", so no malicious pages could be rendered, nor "javascript:" uris. It doesn't rely on a server extension, so an update/enable/disable could be done instantaneously without having to wait to wikia techs. You can also specify a link not to be rendered. On the other hand, it's client-side, so it needs JavaScript enabled and adds some load to the browser. A MW extension would be good, but I don't know how many wikis really make use of the google charts. --[[User:Ciencia Al Poder|Ciencia Al Poder]] ([[User talk:Ciencia Al Poder|talk]]) <sup>-[[w:c:es.pokemon|WikiDex]]</sup> 19:30, 14 January 2008 (UTC)
  +
  +
::: I agree, the JS solution is good enough for our wiki, but a MediaWiki extension might be better still. Two other minor disadvantages of the JS solution: a) when the page loads, it initially displays the URL for about 2-3 seconds, then the URL is replaced by the image, which takes up more space, so the entire page is repainted, see [http://spankingart.wikia.com/wiki/Pairings_by_popularity example]; b) so far I wasn't able to put a chart side-by-side to text. I tried to put it into a table but it didn't work this way. [[User:Spankart|Spankart]] 20:24, 14 January 2008 (UTC)
  +
  +
:::: Try to insert it into a <tt>&lt;div style="float:right"&gt;&lt;/div&gt;</tt> --[[User:Ciencia Al Poder|Ciencia Al Poder]] ([[User talk:Ciencia Al Poder|talk]]) <sup>-[[w:c:es.pokemon|WikiDex]]</sup> 21:03, 14 January 2008 (UTC)
  +
  +
::::: Thanks a lot, that worked. [[User:Spankart|Spankart]] 23:18, 15 January 2008 (UTC)

Latest revision as of 23:18, 15 January 2008

Forums: Index Help desk Can't use Google Chart API
Fandom's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.
Archive
Note: This topic has been unedited for 5916 days. It is considered archived - the discussion is over. Information in this thread may be out of date. Do not add to unless it really needs a response.

Image hotlinking is enabled in Wikia (see my earlier posting on this). One area where this feature would be very useful for many wikis is the Google Chart API. However it does not work - probably because MediaWiki doesn't realize that the URL, which doesn't end in a known image extension such as .jpg, .gif or .png, returns an image.

http://chart.apis.google.com/chart?cht=p3&chd=s:hW&chs=250x100&chl=Hello%7CWorld

This line should be replaced by a chart, but it isn't. Does anyone know a way to make it work? Spankart 08:39, 8 December 2007 (UTC)


You really think hotlinking is enable ?

http://synaptique.ca/zimages/valid-css2-blue.png

http://synapse032.synaptique.ca/ima/minis/synapse032_image_014_mini.jpg

TulipVorlax 01:35, 9 December 2007 (UTC)
P.S: Thoses are on my personnal hosting wich i am paying for. Each image link to the page where they actually are. — TulipVorlax 01:37, 9 December 2007 (UTC)

http://www.furrysoft.de/screenshots/tigger/plugins/SmileyTicker.png

Yes. See the smiley for example, or the Google logo on Forum:Image hotlinking. You need to remove the square brackets to make an image hotlink instead of a normal external link. Now back to my original question: Does anyone know a way to make using the Google Chart API work in Wikia? For example, can I do it with some JavaScript, e.g. via an HTML <img> tag? Example (which doesn't work because you can't use the <img> tag directly in wiki source:

<img src="http://chart.apis.google.com/chart?chs=200x125&chd=s:helloWorld&cht=lc&chxt=x,y&chxl=0:%7CMar%7CApr%7CMay%7CJune%7CJuly%7C1:%7C%7C50+Kb"alt="Sample chart" />

Spankart 01:26, 10 December 2007 (UTC)
Hey, the part « you need to »... is, well you think i dont know how to use wiki code ? Sorry but i think i know better than you. External images can be hotlinked like you're saying should also be able to be put in a link like this :

http://www.furrysoft.de/screenshots/tigger/plugins/SmileyTicker.png

You can do JS on a wikia where you have admin right. You simply go to Mediawiki:Common.js. — TulipVorlax 08:28, 10 December 2007 (UTC)

By the way, i really dont know why some images are blocked while some others aren't. But i know one thing; Wikia is working on a way to let local communities decide wich domain name to permit and wich to blocked. Or at least i think they are... I dont remember where i've read this... — TulipVorlax 08:33, 10 December 2007 (UTC)

I'm sure you know wiki syntax better than me, TulipVorlax. I didn't know I could put a hotlinked image into a link. I do have admin rights in my wiki, but I don't know much about JS or CSS and so, unfortunately, I can't figure out how to solve the problem myself. I hope some wiki guru may be able to help. Spankart 09:48, 10 December 2007 (UTC)

Is nobody here who can help or give an advice? Spankart 12:57, 1 January 2008 (UTC)

Why not save the chart and upload it as an image? -- LordTBT Talk! 00:57, 5 January 2008 (UTC)

Because the great thing about this API is that the chart is created dynamically at runtime. This is particularly useful for charts that are updated regularly, but is also very helpful in all other cases (e.g. to customize and reformat the chart). Spankart 16:48, 5 January 2008 (UTC)

JavaScript solution

The code: User:Ciencia Al Poder/Render Google Charts.js. Copy, paste into your Special:Mypage/monobook.js, (or quartz.js, depending on the current skin) save and reload to see here the result.

The chart images cannot be a link. --Ciencia Al Poder (talk) -WikiDex 12:48, 5 January 2008 (UTC)

You're a genius, Ciencia Al Poder! Thank you so much. I copied this into my wiki's MediaWiki:Common.js and it works perfectly. We should make this better known, I'm sure other wikis will find dynamic charts a great add-in too. Spankart 16:48, 5 January 2008 (UTC)
I'd make the script before, but I hadn't read the post, Have in mind that this only work with JavaScript enabled, so specify always a text to the link with a short description. Enjoy! --Ciencia Al Poder (talk) -WikiDex 17:00, 5 January 2008 (UTC)

Could you pls. assess pro/cons of the javascript solution? Is it good enough or MW ext. should be written for this? -- Nef (talk) 12:12, 14 January 2008 (UTC)

The JavaScript solution is safe: only renders links which url starts with "http://chart.apis.google.com/chart?", so no malicious pages could be rendered, nor "javascript:" uris. It doesn't rely on a server extension, so an update/enable/disable could be done instantaneously without having to wait to wikia techs. You can also specify a link not to be rendered. On the other hand, it's client-side, so it needs JavaScript enabled and adds some load to the browser. A MW extension would be good, but I don't know how many wikis really make use of the google charts. --Ciencia Al Poder (talk) -WikiDex 19:30, 14 January 2008 (UTC)
I agree, the JS solution is good enough for our wiki, but a MediaWiki extension might be better still. Two other minor disadvantages of the JS solution: a) when the page loads, it initially displays the URL for about 2-3 seconds, then the URL is replaced by the image, which takes up more space, so the entire page is repainted, see example; b) so far I wasn't able to put a chart side-by-side to text. I tried to put it into a table but it didn't work this way. Spankart 20:24, 14 January 2008 (UTC)
Try to insert it into a <div style="float:right"></div> --Ciencia Al Poder (talk) -WikiDex 21:03, 14 January 2008 (UTC)
Thanks a lot, that worked. Spankart 23:18, 15 January 2008 (UTC)