From: Alexey Chernobaev Date: Wed, 14 Mar 2018 19:43:43 +0000 (+0300) Subject: histogram y-axes scale fixed X-Git-Tag: submit/tizen/20180620.112952^2^2~58 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=573231403ee2f97b3e20c8a7c13a371f5af6a1e4;p=sdk%2Ftools%2Fheaptrack.git histogram y-axes scale fixed --- diff --git a/src/analyze/gui/histogramwidget.h b/src/analyze/gui/histogramwidget.h index 07c6a21..c05bd13 100644 --- a/src/analyze/gui/histogramwidget.h +++ b/src/analyze/gui/histogramwidget.h @@ -24,7 +24,7 @@ #include //!! for debugging -#define SHOW_TABLES +//#define SHOW_TABLES #ifdef SHOW_TABLES #include diff --git a/src/analyze/gui/histogramwidgetqwtplot.cpp b/src/analyze/gui/histogramwidgetqwtplot.cpp index d6ff744..8d61a22 100644 --- a/src/analyze/gui/histogramwidgetqwtplot.cpp +++ b/src/analyze/gui/histogramwidgetqwtplot.cpp @@ -5,8 +5,6 @@ #include #include -void populate(QwtPlotMultiBarChart *); - HistogramWidgetQwtPlot::HistogramWidgetQwtPlot(QWidget *parent) : QwtPlot(parent), m_barChart(nullptr) @@ -18,52 +16,6 @@ HistogramWidgetQwtPlot::HistogramWidgetQwtPlot(QWidget *parent) setAxisTitle(QwtPlot::xBottom, i18n("Requested Allocation Size")); } -// TODO!! remove test code -static void populate(QwtPlotMultiBarChart *m_barChart) -{ -// static const char *colors[] = { "DarkOrchid", "SteelBlue", "Gold" }; - static const char *colors[] = { "red", "green", "blue" }; - - const int numSamples = 5; - const int numBars = sizeof( colors ) / sizeof( colors[0] ); - - QList titles; - for ( int i = 0; i < numBars; i++ ) - { - QString title("Bar %1"); - titles += title.arg( i ); - } - m_barChart->setBarTitles( titles ); -//!! m_barChart->setLegendIconSize( QSize( 10, 14 ) ); - - for ( int i = 0; i < numBars; i++ ) - { - QwtColumnSymbol *symbol = new QwtColumnSymbol( QwtColumnSymbol::Box ); - symbol->setLineWidth( 2 ); -// symbol->setFrameStyle( QwtColumnSymbol::Raised ); - QColor c(colors[i]); - c.setAlpha(160); - symbol->setPalette(QPalette(c)); - - m_barChart->setSymbol(i, symbol); - } - - QVector< QVector > series; - for ( int i = 0; i < numSamples; i++ ) - { - QVector values; - values.append(200); - values.append(300); - values.append(500); -/* for ( int j = 0; j < numBars; j++ ) - values += ( 2 + qrand() % 8 );*/ - - series += values; - } - - m_barChart->setSamples(series); -} - void HistogramWidgetQwtPlot::rebuild(bool resetZoomAndPan) { detachItems(); @@ -75,7 +27,8 @@ void HistogramWidgetQwtPlot::rebuild(bool resetZoomAndPan) } m_barChart = new QwtPlotMultiBarChart(); - m_barChart->attach(this); + m_barChart->setSpacing(40); // TODO!! use dynamic spacing + m_barChart->setStyle(QwtPlotMultiBarChart::Stacked); int columns = m_model->columnCount(); int rows = m_model->rowCount(); @@ -84,7 +37,6 @@ void HistogramWidgetQwtPlot::rebuild(bool resetZoomAndPan) QVector> series; for (int row = 0; row < rows; ++row) { - QString rowName = m_model->headerData(row, Qt::Vertical).toString(); QVector values; for (int column = 1; column < columns; ++column) @@ -112,4 +64,9 @@ void HistogramWidgetQwtPlot::rebuild(bool resetZoomAndPan) } m_barChart->setSamples(series); + + setAxisAutoScale(QwtPlot::yRight); + m_barChart->setAxes(QwtPlot::xBottom, QwtPlot::yRight); + + m_barChart->attach(this); }