Can anyone tell me why this javascript chart always shows 3 bars, event when species_cnt = 1
var _settings = function() {
var ls_timestrata = {dialog.Object}.getValue('TIMESTRATA');
var ls_tribe = {dialog.Object}.getValue('TRIBE');
if (ls_timestrata == 'Day'){
var ls_title = 'Cumlative Catch by Date Landed';
}
if (ls_timestrata == 'Week'){
var ls_title = 'Cumlative Catch by Management Week';
}
if (ls_timestrata == 'Month'){
var ls_title = 'Cumlative Catch by Month Landed';
}
if (ls_timestrata == 'Year'){
var ls_title = 'Comparative Catch by Year';
}
var ls_list = {dialog.Object}.getValue('SPECIES');
var li_speccnt = ls_list.length;
alert('species cnt = ' + li_speccnt + ' inside chart');
if(li_speccnt = 1) {
var s1 = {dialog.object}._dataSeriesData.species1.num_units;
var data = A5.makeArrayOfArrays(s1);
}
if(li_speccnt = 2) {
var s1 = {dialog.object}._dataSeriesData.species1.num_units;
var s2 = {dialog.object}._dataSeriesData.species2.num_units;
var data = A5.makeArrayOfArrays(s1,s2);
}
if(li_speccnt = 3) {
var s1 = {dialog.object}._dataSeriesData.species1.num_units;
var s2 = {dialog.object}._dataSeriesData.species2.num_units;
var s3 = {dialog.object}._dataSeriesData.species3.num_units;
var data = A5.makeArrayOfArrays(s1,s2,s3);
}
// var numspecies =
// var s1 = {dialog.object}._dataSeriesData.species1.num_units;
// var s2 = {dialog.object}._dataSeriesData.species2.num_units;
// var s3 = {dialog.object}._dataSeriesData.species3.num_units;
// var data = A5.makeArrayOfArrays(s1,s2,s3);
//create a data array that looks like this
//[[4,8,13],[5,2,21], [8,4,21],....
tooltips = RGraph.SVG.arrayLinearize(data);
//create an array that looks like this:
//[4,8,13,5,2,21,8,4,21,....
for(var i = 0; i < tooltips.length; i++) {
tooltips[i] = 'Value: ' + tooltips[i];
}
var settings = {
id: '{chartDiv}',
data: data,
options: {
strokestyle: 'rgba(0,0,0,)',
colors: [
'#f78181',
'#b4e3b4',
'#a2a2e1'
],
gutterTop: 40,
gutterLeft: 55,
gutterBottom: 10,
xaxisLabels: {dialog.object}._dataSeriesData.species1.timestrata,
xaxisColor: '#ddd',
xaxisTickmarks: 0,
xaxisTextAngle: 70,
yaxisColor: '#ddd',
yaxisUnitsPost: '',
yaxisTickmarks: 0,
tooltips: tooltips,
shadow: false,
backgroundGridColor: '#eee',
title: ls_title,
titleSubtitle: 'with tooltips',
hmargin: 7,
attribution: false
}
};
return settings;
} // end of _settings
var _onTooltip = function (obj) {
var tooltip = RGraph.SVG.REG.get('tooltip');
idx = RGraph.SVG.sequentialIndexToGrouped(tooltip.__index__, obj.data);
colors = ['red','green','blue'];
tooltip.style.borderColor = colors[idx[1]];
}
var _chart = new RGraph.SVG.Bar(_settings()).wave().on('tooltip',_onTooltip);
// Some CSS that gets used for the tooltips
RGraph.SVG.tooltips.style.fontSize = '105%';
RGraph.SVG.tooltips.style.fontFamily = 'Arial, sans-serif';
RGraph.SVG.tooltips.style.fontWeight = 'bold';
RGraph.SVG.tooltips.style.paddingRight = '10px';
RGraph.SVG.tooltips.style.paddingLeft = '10px';
RGraph.SVG.tooltips.style.paddingTop = '10px';
RGraph.SVG.tooltips.style.paddingBottom = '10px';
RGraph.SVG.tooltips.style.textAlign = 'center';
RGraph.SVG.tooltips.style.backgroundColor = 'white';
RGraph.SVG.tooltips.style.border = '3px black solid';
RGraph.SVG.tooltips.style.borderWidth = '3px';
{dialog.object}._jsCharts['{chartName}'] = {};
{dialog.object}._jsCharts['{chartName}'].settings = [_settings];
{dialog.object}._jsCharts['{chartName}'].object = [_chart];
if(typeof {dialog.object}._jsCharts['{chartName}'] == 'undefined') {dialog.object}._jsCharts['{chartName}'] = {};
{dialog.object}._jsCharts['{chartName}'].dataSeries = ['species1.num_units','species2.num_units','species3.num_units','species1.timestrata'];
{dialog.object}._jsCharts['{chartName}'].drawMethod = ['wave']
{dialog.object}._jsCharts['{chartName}'].drawMethodArgument = ['']
var _settings = function() {
var ls_timestrata = {dialog.Object}.getValue('TIMESTRATA');
var ls_tribe = {dialog.Object}.getValue('TRIBE');
if (ls_timestrata == 'Day'){
var ls_title = 'Cumlative Catch by Date Landed';
}
if (ls_timestrata == 'Week'){
var ls_title = 'Cumlative Catch by Management Week';
}
if (ls_timestrata == 'Month'){
var ls_title = 'Cumlative Catch by Month Landed';
}
if (ls_timestrata == 'Year'){
var ls_title = 'Comparative Catch by Year';
}
var ls_list = {dialog.Object}.getValue('SPECIES');
var li_speccnt = ls_list.length;
alert('species cnt = ' + li_speccnt + ' inside chart');
if(li_speccnt = 1) {
var s1 = {dialog.object}._dataSeriesData.species1.num_units;
var data = A5.makeArrayOfArrays(s1);
}
if(li_speccnt = 2) {
var s1 = {dialog.object}._dataSeriesData.species1.num_units;
var s2 = {dialog.object}._dataSeriesData.species2.num_units;
var data = A5.makeArrayOfArrays(s1,s2);
}
if(li_speccnt = 3) {
var s1 = {dialog.object}._dataSeriesData.species1.num_units;
var s2 = {dialog.object}._dataSeriesData.species2.num_units;
var s3 = {dialog.object}._dataSeriesData.species3.num_units;
var data = A5.makeArrayOfArrays(s1,s2,s3);
}
// var numspecies =
// var s1 = {dialog.object}._dataSeriesData.species1.num_units;
// var s2 = {dialog.object}._dataSeriesData.species2.num_units;
// var s3 = {dialog.object}._dataSeriesData.species3.num_units;
// var data = A5.makeArrayOfArrays(s1,s2,s3);
//create a data array that looks like this
//[[4,8,13],[5,2,21], [8,4,21],....
tooltips = RGraph.SVG.arrayLinearize(data);
//create an array that looks like this:
//[4,8,13,5,2,21,8,4,21,....
for(var i = 0; i < tooltips.length; i++) {
tooltips[i] = 'Value: ' + tooltips[i];
}
var settings = {
id: '{chartDiv}',
data: data,
options: {
strokestyle: 'rgba(0,0,0,)',
colors: [
'#f78181',
'#b4e3b4',
'#a2a2e1'
],
gutterTop: 40,
gutterLeft: 55,
gutterBottom: 10,
xaxisLabels: {dialog.object}._dataSeriesData.species1.timestrata,
xaxisColor: '#ddd',
xaxisTickmarks: 0,
xaxisTextAngle: 70,
yaxisColor: '#ddd',
yaxisUnitsPost: '',
yaxisTickmarks: 0,
tooltips: tooltips,
shadow: false,
backgroundGridColor: '#eee',
title: ls_title,
titleSubtitle: 'with tooltips',
hmargin: 7,
attribution: false
}
};
return settings;
} // end of _settings
var _onTooltip = function (obj) {
var tooltip = RGraph.SVG.REG.get('tooltip');
idx = RGraph.SVG.sequentialIndexToGrouped(tooltip.__index__, obj.data);
colors = ['red','green','blue'];
tooltip.style.borderColor = colors[idx[1]];
}
var _chart = new RGraph.SVG.Bar(_settings()).wave().on('tooltip',_onTooltip);
// Some CSS that gets used for the tooltips
RGraph.SVG.tooltips.style.fontSize = '105%';
RGraph.SVG.tooltips.style.fontFamily = 'Arial, sans-serif';
RGraph.SVG.tooltips.style.fontWeight = 'bold';
RGraph.SVG.tooltips.style.paddingRight = '10px';
RGraph.SVG.tooltips.style.paddingLeft = '10px';
RGraph.SVG.tooltips.style.paddingTop = '10px';
RGraph.SVG.tooltips.style.paddingBottom = '10px';
RGraph.SVG.tooltips.style.textAlign = 'center';
RGraph.SVG.tooltips.style.backgroundColor = 'white';
RGraph.SVG.tooltips.style.border = '3px black solid';
RGraph.SVG.tooltips.style.borderWidth = '3px';
{dialog.object}._jsCharts['{chartName}'] = {};
{dialog.object}._jsCharts['{chartName}'].settings = [_settings];
{dialog.object}._jsCharts['{chartName}'].object = [_chart];
if(typeof {dialog.object}._jsCharts['{chartName}'] == 'undefined') {dialog.object}._jsCharts['{chartName}'] = {};
{dialog.object}._jsCharts['{chartName}'].dataSeries = ['species1.num_units','species2.num_units','species3.num_units','species1.timestrata'];
{dialog.object}._jsCharts['{chartName}'].drawMethod = ['wave']
{dialog.object}._jsCharts['{chartName}'].drawMethodArgument = ['']
Comment