aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-01-28 11:20:13 +0100
committerSamuel Fadel <samuelfadel@gmail.com>2016-01-28 11:20:13 +0100
commitaad000e85e83fd297efec70c187b1d2246c145b3 (patch)
tree5d54a80ba07b8f3294d87ee899ccfe05070489a3
parentd263e31988925e462f9c76fb52b9fb43c7b0fde7 (diff)
BarChart: bugfix related to brushing & no. of elems.
-rw-r--r--barchart.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/barchart.cpp b/barchart.cpp
index 195b706..1aacfdb 100644
--- a/barchart.cpp
+++ b/barchart.cpp
@@ -37,7 +37,6 @@ BarChart::BarChart(QQuickItem *parent)
setClip(true);
setFlag(QQuickItem::ItemHasContents);
//setAcceptedMouseButtons(Qt::LeftButton);
- setAcceptHoverEvents(true);
}
BarChart::~BarChart()
@@ -55,6 +54,7 @@ void BarChart::setValues(const arma::vec &values)
m_originalIndices.resize(m_values.n_elem);
m_currentIndices.resize(m_values.n_elem);
+ setAcceptHoverEvents(m_values.n_elem > 0);
if (m_values.n_elem > 0) {
m_scale.setDomain(m_values.min(), m_values.max());
m_colorScale.setExtents(m_values.min(), m_values.max());
@@ -105,6 +105,10 @@ void BarChart::brushItem(int item)
m_brushedItem = item;
emit itemBrushed(m_brushedItem);
} else {
+ if (m_values.n_elem == 0 || item > m_values.n_elem - 1) {
+ return;
+ }
+
m_brushedItem = m_currentIndices[item];
emit itemBrushed(m_originalIndices[m_brushedItem]);
}