Class | Fusioncharts::Utf8ExampleController |
In: |
app/controllers/fusioncharts/utf8_example_controller.rb
|
Parent: | ApplicationController |
Contains actions to show the UTF-8 chart examples.
To use FusionCharts with UTF-8 characters, remember the following:
Steps to ensure correct UTF-8 output:
ALTER DATABASE DEFAULT CHARACTER SET = utf8;
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.
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 pie_data_french 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.
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.
For more details on UTF specific code, please see the view where the code resides.
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 pie_data_japanese 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.
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.
Generates the xml with each factory‘s name and total output quantity. Factory name in french is obtained from FrenchFactoryMaster. Content-type for its view is set to text/xml and char-set to UTF-8.
Generates the xml with each factory‘s name and total output quantity. Factory name in japanese is obtained from JapaneseFactoryMaster. Content-type for its view is set to text/xml and char-set to UTF-8.