This module calculates the distributed weighted average of your plots.
- Include the module in your page after the zingchart library
- Include the module reference in the zingchart.render({}) method.
zingchart.render({
id : 'myChart',
data : myConfig,
height: 400,
width: '100%',
modules: "dwa" // Include the dwa module!
});
There are a couple attributes you can define in your chart configuration for the dwa module.
- dwa (object) - This object can be defined in the root of the chart configuration. Within this object you can define two properties visibleAtFirst and name.
- visibleAtFirst (boolean) - If true this attribute will show the dwa plot when the graph loads. This is the default.
- name (string) - If defined, this name will appear in the legend. The default text is "Weighted Average".
- color (string) - If defined this will set the color of your dwa plot. Otherwise it will default to the standard library color for that plot.
dwa:{
// 'dwa' module is loaded in the render method below.
visibleAtFirst:true, // Default is true
name: "Distributed Weighted Average", // Optional Name
color: '#000' // Optional Color
},
- weight (Number) - If defined, it must be defined within each individual series object. The default weight is 1, in which case the weighted average is an even distribution amongst plots.
series : [
{
values: [35,42,67,89,25,34,67,85],
weight: 0.4 // optional weight
},
{
values: [74,71,89,34,26,73,21,56],
weight: 0.6 // optional weight
}
]