Skip to content

Commit

Permalink
Further updates to flot histogram implementation - added legend and t…
Browse files Browse the repository at this point in the history
…ry to map colours more intelligently
  • Loading branch information
timlinux committed Nov 22, 2011
1 parent 200c44e commit fa4686a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
7 changes: 4 additions & 3 deletions resources/html/chart.html
Expand Up @@ -20,13 +20,14 @@
yaxis : { zoomRange: null, panRange: null },
xaxis : { zoomRange: null, panRange: null },
zoom : { interactive : true },
pan : { interactive : true }
pan : { interactive : true },
legend : { show : true }
};
$.plot($("#chart"), d, options);
}
function addSeries( theSeries )
function addSeries( theSeries, theBand, theColor )
{
d.push( { data: theSeries } );
d.push( { data: theSeries, label: "Band " + theBand, color: theColor } );
replot();
//alert( theSeries );
}
Expand Down
18 changes: 16 additions & 2 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -1884,7 +1884,10 @@ void QgsRasterLayerProperties::refreshHistogram()
//
//now draw actual graphs
//

int myRedBand = mRasterLayer->bandNumber( cboRed->currentText() );
int myGreenBand = mRasterLayer->bandNumber( cboGreen->currentText() );
int myBlueBand = mRasterLayer->bandNumber( cboBlue->currentText() );
int myGrayBand = mRasterLayer->bandNumber( cboGray->currentText() );
for ( int myIteratorInt = 1;
myIteratorInt <= myBandCountInt;
++myIteratorInt )
Expand All @@ -1903,7 +1906,18 @@ void QgsRasterLayerProperties::refreshHistogram()
mySeriesJS += QString("[%1,%2]").arg(myBin).arg(myBinValue);
myFirst = false;
}
mySeriesJS += "]);";
QString myColor = "";
if ( myIteratorInt == myRedBand )
myColor = "#FF0000";
else if ( myIteratorInt == myGreenBand )
myColor = "#00FF00";
else if ( myIteratorInt == myBlueBand )
myColor = "#0000FF";
else if ( myIteratorInt == myGrayBand )
myColor = "#FCFCFC";
else
myColor = "#F0C1D1";
mySeriesJS += QString("], %1, '%2');").arg(myIteratorInt).arg( myColor );
//QgsDebugMsg( mySeriesJS );
mWebPlot->page()->mainFrame()->evaluateJavaScript( mySeriesJS );
}
Expand Down

0 comments on commit fa4686a

Please sign in to comment.