FusionCharts Suite XT provides a configure
function that allows you to change the text of the chart status messages that appear throughout the life cycle of the chart.
Shown below is a list of messages that can be set across charts
Attribute Name (message type) | What it does? | Default Value |
---|---|---|
LoadingText (For JavaScript charts only) | Sets a custom message when chart is loading. | Loading Chart. Please Wait. |
XMLLoadingText | Sets a custom message when chart data is loading. | Retrieving Data. Please Wait. |
ParsingDataText | Sets a custom message when data is being parsed by chart. | Reading Data. Please Wait. |
ChartNoDataText | Sets a custom message when the chart has retrieved data which does not contain any data for chart to plot or the data does not conform to the data structure required by the chart type. | No data to display. |
RenderingChartText | Sets a custom message when the chart is being drawn. | Rendering Chart. Please Wait. |
LoadDataErrorText | Sets a custom message when there is error in loading the chart data from the data URL provided as datasource.This may happen when the URL is invalid or inaccessible. | Error in loading data. |
InvalidXMLText | Sets a custom message when the data which is sent to the chart is invalid as per XML validation rules. | Invalid data. |
Using the configure() function to set custom messages
The following snippet shows you how to set the loading text of the chart
<script type="text/javascript"> var myChart = new FusionCharts( // Constructor code goes here ); myChart.configure("ChartNoDataText", "There are no sales for the previous year."); myChart.render("chartContainer");
In the above code we have created a Column2D chart and provided blank data to the chart. But, before rendering the chart we also called configure()
and passed the message type - ChartNoDataText
. ChartNoDataText
sets a custom message when data is not enough to be plotted on the chart. As the second parameter of the function, we pass the custom message that is to be shown in this situation and the message text.
When you run this chart, you will get the custom message instead of the normal message.
Hiding the message
To hide a chart message please provide a blank space as the custom message. For example, if you wish to disable the chart loading message.
<script type="text/javascript"> var myChart = new FusionCharts( // Constructor code goes here ); myChart.configure("ChartNoDataText", " "); myChart.render("chartContainer");
Setting Multiple Messages
It is very easy again to set multiple messages. You can opt to call configure()
function multiple times and set one message at a time as shown here
<script type="text/javascript"> var myChart = new FusionCharts( // Constructor code goes here ); myChart.configure( "ChartNoDataText", "There are no sales for the previous year."); myChart.configure( "InvalidXMLText", "Please validate data"); myChart.render("chartContainer");
Alternatively you can also set multiple messages in a JSON object and pass it to the configure()
method. Here each message type will be property name and the custom message will be the respective value.
<script type="text/javascript"> var myChart = new FusionCharts( // Constructor code goes here ); myChart.configure({ "ChartNoDataText" : "Please select a record above" , "InvalidXMLText" : "Please validate data" }); myChart.render("chartContainer");