Skip to content
Permalink
Browse files
Further updates to flot histogram implementation - added legend and t…
…ry to map colours more intelligently
  • Loading branch information
timlinux committed Nov 22, 2011
1 parent 200c44e commit fa4686a509b6aae682370abc55120acd2fd27900
Showing with 20 additions and 5 deletions.
  1. +4 −3 resources/html/chart.html
  2. +16 −2 src/app/qgsrasterlayerproperties.cpp
@@ -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 );
}
@@ -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 )
@@ -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 );
}

0 comments on commit fa4686a

Please sign in to comment.