File "Utf8ExampleController.html"
Full Path: /home/analogde/www/Android/FusionChartsFree/Code/RoR/SampleApp/doc/classes/Fusioncharts/Utf8ExampleController.html
File size: 11.1 KB
MIME-type: text/xml
Charset: utf-8
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Fusioncharts::Utf8ExampleController</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Fusioncharts::Utf8ExampleController</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/app/controllers/fusioncharts/utf8_example_controller_rb.html">
app/controllers/fusioncharts/utf8_example_controller.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
<a href="../ApplicationController.html">
ApplicationController
</a>
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<pre>
Contains actions to show the UTF-8 chart examples.
</pre>
<p>
To use FusionCharts with UTF-8 characters, remember the following:
</p>
<ul>
<li>dataURL method has to be used to get the xml.
</li>
<li>Rotated text cannot render UTF-8 characters. For example, UTF-8 characters
in the rotated labels will not be rendered correctly.
</li>
<li>BOM has to present in the xml given as input to the chart.
</li>
</ul>
<p>
Steps to ensure correct UTF-8 output:
</p>
<ul>
<li><meta http-equiv="content-type" content="text/html;
charset=utf-8" /> has to be present in the <head> section of
the page which contains UTF8 characters. Notice that we have included this
in the "common.html.erb" layout, so that it is avialable to all
pages.
</li>
<li>Put this, headers["Content-Type"] = "text/xml;
charset=utf-8" in the action which is the XML provider. ( Here, <a
href="Utf8ExampleController.html#M000025">pie_data_french</a> or <a
href="Utf8ExampleController.html#M000022">pie_data_japanese</a> actions)
</li>
<li>If you are using a xml file for the data, then the file should be saved
with UTF-8 encoding with UTF-8 BOM. It should have the xml declaration
also: <?xml version="1.0" encoding="UTF-8" ?>
</li>
<li>If you are generating xml dynamically, then in the xml provider ( here,
pie_data_japanese.html.erb and pie_data_french.html.erb ), use get_UTF8_BOM
and assign the BOM to the xml as initial value. This function present in
fusioncharts_helper library.
</li>
<li>After placing the BOM in the xml string, append the xml declaration:
<?xml version=‘1.0’ encoding=‘UTF-8’?>.
Finally, append the actual chart xml.
</li>
<li>For using data from database, the default character set of the database
should be UTF-8. This can be done using the sql command:
</li>
</ul>
<p>
ALTER DATABASE DEFAULT CHARACTER SET = utf8;
</p>
<pre>
The default charset of the table containing the UTF characters should be UTF-8. This can be done by adding "DEFAULT CHARSET=utf8;" at the end of the table definition.
In the config/database.yml file the setting for encoding should be: encoding: UTF8
For more details on UTF specific code, please see the view where the code resides.
</pre>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000024">french_dbexample</a>
<a href="#M000023">french_xmlfile_example</a>
<a href="#M000021">japanese_dbexample</a>
<a href="#M000020">japanese_xmlfile_example</a>
<a href="#M000025">pie_data_french</a>
<a href="#M000022">pie_data_japanese</a>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000024" class="method-detail">
<a name="M000024"></a>
<div class="method-heading">
<a href="Utf8ExampleController.src/M000024.html" target="Code" class="method-signature"
onclick="popupCode('Utf8ExampleController.src/M000024.html');return false;">
<span class="method-name">french_dbexample</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
In this example, we show how to use UTF8 characters in FusionCharts by
connecting to a database and using dataURL method. Here, the XML data for
the chart is generated in <a
href="Utf8ExampleController.html#M000025">pie_data_french</a> function. The
function itself does not contain any specific code to handle UTF8
characters. NOTE: It‘s necessary to encode the dataURL if
you‘ve added parameters to it.
</p>
</div>
</div>
<div id="method-M000023" class="method-detail">
<a name="M000023"></a>
<div class="method-heading">
<a href="Utf8ExampleController.src/M000023.html" target="Code" class="method-signature"
onclick="popupCode('Utf8ExampleController.src/M000023.html');return false;">
<span class="method-name">french_xmlfile_example</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
This is an example showing French characters on the chart. Here,
we‘ve used a pre-defined FrenchData.xml (contained in /Data/ folder)
This action uses the dataURL method of FusionCharts. A view with the same
name french_xmlfile_example.html.erb is present and it is this view, which
gets rendered with the layout "common". render_chart function
from the helper is invoked to render the chart. The function itself has no
code, all the work is done in the view.
</p>
<pre>
For more details on UTF specific code, please see the view where the code resides.
</pre>
</div>
</div>
<div id="method-M000021" class="method-detail">
<a name="M000021"></a>
<div class="method-heading">
<a href="Utf8ExampleController.src/M000021.html" target="Code" class="method-signature"
onclick="popupCode('Utf8ExampleController.src/M000021.html');return false;">
<span class="method-name">japanese_dbexample</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
In this example, we show how to use UTF8 characters in FusionCharts by
connecting to a database and using dataURL method. Here, the XML data for
the chart is generated in <a
href="Utf8ExampleController.html#M000022">pie_data_japanese</a> function.
The function itself does not contain any specific code to handle UTF8
characters. NOTE: It‘s necessary to encode the dataURL if
you‘ve added parameters to it.
</p>
</div>
</div>
<div id="method-M000020" class="method-detail">
<a name="M000020"></a>
<div class="method-heading">
<a href="Utf8ExampleController.src/M000020.html" target="Code" class="method-signature"
onclick="popupCode('Utf8ExampleController.src/M000020.html');return false;">
<span class="method-name">japanese_xmlfile_example</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
This is an example showing Japanese characters on the chart. Here,
we‘ve used a pre-defined JapaneseData.xml (contained in /Data/
folder) This action uses the dataURL method of FusionCharts. A view with
the same name japanese_xmlfile_example.html.erb is present and it is this
view, which gets rendered with the layout "common". render_chart
function from the helper is invoked to render the chart. The function
itself has no code, all the work is done in the view.
</p>
</div>
</div>
<div id="method-M000025" class="method-detail">
<a name="M000025"></a>
<div class="method-heading">
<a href="Utf8ExampleController.src/M000025.html" target="Code" class="method-signature"
onclick="popupCode('Utf8ExampleController.src/M000025.html');return false;">
<span class="method-name">pie_data_french</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Generates the xml with each factory‘s name and total output quantity.
Factory name in french is obtained from <a
href="FrenchFactoryMaster.html">FrenchFactoryMaster</a>. Content-type for
its view is set to text/xml and char-set to UTF-8.
</p>
</div>
</div>
<div id="method-M000022" class="method-detail">
<a name="M000022"></a>
<div class="method-heading">
<a href="Utf8ExampleController.src/M000022.html" target="Code" class="method-signature"
onclick="popupCode('Utf8ExampleController.src/M000022.html');return false;">
<span class="method-name">pie_data_japanese</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Generates the xml with each factory‘s name and total output quantity.
Factory name in japanese is obtained from <a
href="JapaneseFactoryMaster.html">JapaneseFactoryMaster</a>. Content-type
for its view is set to text/xml and char-set to UTF-8.
</p>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>