Skip to content
Francois Vancoppenolle edited this page Aug 15, 2015 · 4 revisions

Previous Page          Next Page          Table of content

Changing the default value of an option

Each option has a default value; In previous chapter, we have explained how to specify a different value for an option. If you want to change one of the default value to another value, one solution could be to edit the source file ChartNew.js and to change one or more options default value.

Proceeding like this has a big disadvantage : each time that you download an update of the sources, you have to re-apply the changes.

In order to avoid this disadvantage, another solution has been implemented. Create your personnel JS file (that you call for instance “myPersonalDefaultChartNewOptions.js”) with following skeleton and define in this file all the changes that you want to the default values.

Skeleton JS file :

var charJSPersonalDefaultOptions = { 
//Define here the options for which the default value has to be changed in all charts type
}
var charJSPersonalDefaultOptionsLine = { 
// Define here the options for which the default value has to be changed for Line chart
}
var charJSPersonalDefaultOptionsRadar = { 
// Define here the options for which the default value has to be changed for Radar chart
}
var charJSPersonalDefaultOptionsPolarArea = { 
// Define here the options for which the default value has to be changed for PolarArea  chart
}
var charJSPersonalDefaultOptionsPie = { 
// Define here the options for which the default value has to be changed for Pie chart
}
var charJSPersonalDefaultOptionsDoughnut = { 
// Define here the options for which the default value has to be changed for Doughnut chart
}
var charJSPersonalDefaultOptionsBar = { 
// Define here the options for which the default value has to be changed for Bar chart
}
var charJSPersonalDefaultOptionsStackedBar = { 
// Define here the options for which the default value has to be changed for StackedBar chart
}
var charJSPersonalDefaultOptionsHorizontalBar = { 
// Define here the options for which the default value has to be changed for HorizontalBar chart
}
var charJSPersonalDefaultOptionsHorizontalStackedBar = { 
// Define here the options for which the default value has to be changed for HorizontalStackedBar chart
}

Example :

By default, annotations and legend are not active. The default value for options annotateDipslay and legend are set to false. You want to change the default value to “true”; But for Pie chart, you don’t want to display the legend, but you prefer to display the “inGraphData” by setting the option “inGraphDataShow” to true by default. . Do this with following program.

var charJSPersonalDefaultOptions = { 
//Define here the options for which the default value has to be changed in all chart type
annotateDisplay : true,
legend: true
}
var charJSPersonalDefaultOptionsLine = { 
// Define here the options for which the default value has to be changed for Line chart
}
var charJSPersonalDefaultOptionsRadar = { 
// Define here the options for which the default value has to be changed for Radar chart
}
var charJSPersonalDefaultOptionsPolarArea = { 
// Define here the options for which the default value has to be changed for PolarArea  chart
}
var charJSPersonalDefaultOptionsPie = { 
// Define here the options for which the default value has to be changed for Pie chart
legend : false,
inGraphDataShow : true
}
var charJSPersonalDefaultOptionsDoughnut = { 
// Define here the options for which the default value has to be changed for Doughnut chart
}
var charJSPersonalDefaultOptionsBar = { 
// Define here the options for which the default value has to be changed for Bar chart
}
var charJSPersonalDefaultOptionsStackedBar = { 
// Define here the options for which the default value has to be changed for StackedBar chart
}
var charJSPersonalDefaultOptionsHorizontalBar = { 
// Define here the options for which the default value has to be changed for HorizontalBar chart
}
var charJSPersonalDefaultOptionsHorizontalStackedBar = { 
// Define here the options for which the default value has to be changed for HorizontalStackedBar chart
}

To activates those changes, in all programs where you includes “ChartNew.js”, you have to include your personal default options.

Example :

<SCRIPT src='ChartNew.js'></script>
<SCRIPT src= myPersonalDefaultChartNewOptions.js></script>

Previous Page          Next Page          Top of Page

Clone this wiki locally