Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow xaxis column to be set. Allow suppression of invalid data columns #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions jquery.highchartTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@
var ths = $('thead th', table);
var columns = [];
var vlines = [];
var skippedColumns = 0;
//var skippedColumns = 0;
var graphIsStacked = false;

// RdB allow xaxis column to be nominated as a number, starting at 0.
var xIndexTh = $table.data('graph-xaxis') || 0;
var indexSeries = 0;

ths.each(function(indexTh, th) {
var $th = $(th);
var columnScale = $th.data('graph-value-scale');
Expand All @@ -107,15 +112,15 @@
}

var isColumnSkipped = $th.data('graph-skip') == 1;
if (isColumnSkipped)
{
skippedColumns = skippedColumns + 1;
}
//if (isColumnSkipped)
//{
// skippedColumns = skippedColumns + 1;
//}

var thGraphConfig = {
libelle: $th.text(),
skip: isColumnSkipped,
indexTd: indexTh - skippedColumns - 1,
indexTd: isColumnSkipped || indexTh === xIndexTh ? -1 : indexSeries++, // RdB
color: $th.data('graph-color'),
visible: !$th.data('graph-hidden'),
yAxis: typeof yaxis != 'undefined' ? yaxis : 0,
Expand All @@ -142,7 +147,7 @@

var series = [];
$(columns).each(function(indexColumn, column) {
if(indexColumn!=0 && !column.skip) {
if(indexColumn!==xIndexTh && !column.skip) { // RdB

var serieConfig = {
name: column.libelle + (column.unit ? ' (' + column.unit + ')' : ''),
Expand Down Expand Up @@ -209,7 +214,7 @@
return;
}
var $td = $(td);
if (indexTd==0) {
if (indexTd==xIndexTh) { // RdB
cellValue = $td.text();
xValues.push(cellValue);
} else {
Expand Down Expand Up @@ -265,6 +270,25 @@

});

// RdB remove series that have invalid data cells.
if ($table.data('graph-suppress-invalid-series') == 1) {
for (var seriesIndex = 0; seriesIndex < series.length;) {
var isValid = true;
var data = series[seriesIndex].data;
for (var d = 0; d < data.length; d++) {
if (data[d] == null || isNaN(data[d].y)) {
// Invalid data cell, remove serie.
isValid = false;
series.splice(seriesIndex, 1);
break;
}
}
if (isValid) {
seriesIndex++;
}
}
}

var yAxisConfig = [];
var yAxisNum;
for (yAxisNum=1 ; yAxisNum <= nbYaxis ; yAxisNum++) {
Expand Down