aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--barchart.cpp7
-rw-r--r--barchart.h2
2 files changed, 6 insertions, 3 deletions
diff --git a/barchart.cpp b/barchart.cpp
index 65db7d8..ba68843 100644
--- a/barchart.cpp
+++ b/barchart.cpp
@@ -62,10 +62,12 @@ void BarChart::setValues(const arma::vec &values)
if (m_values.n_elem > 0) {
m_scale.setDomain(m_values.min(), m_values.max());
+ // m_originalIndices[i] == the original (datum) index of item i
std::iota(m_originalIndices.begin(), m_originalIndices.end(), 0);
std::sort(m_originalIndices.begin(), m_originalIndices.end(),
[this](int i, int j) { return m_values[i] > m_values[j]; });
+ // m_currentIndices[i] == the displayed position of datum i
int k = 0;
for (auto i: m_originalIndices) {
m_currentIndices[i] = k++;
@@ -115,7 +117,7 @@ void BarChart::brushItem(int item)
{
if (item < 0) {
m_brushedItem = item;
- emit itemBrushed(m_brushedItem);
+ emit itemBrushed(m_brushedItem, 0.0f);
} else {
// safe comparison: we just checked for negative values
if (m_values.n_elem == 0 || item > m_values.n_elem - 1) {
@@ -123,7 +125,8 @@ void BarChart::brushItem(int item)
}
m_brushedItem = m_currentIndices[item];
- emit itemBrushed(m_originalIndices[m_brushedItem]);
+ item = m_originalIndices[m_brushedItem];
+ emit itemBrushed(item, m_values[item]);
}
update();
diff --git a/barchart.h b/barchart.h
index 589b5e5..c5ee1ae 100644
--- a/barchart.h
+++ b/barchart.h
@@ -23,7 +23,7 @@ signals:
void colorScaleChanged(const ColorScale *scale) const;
void selectionChanged(const std::vector<bool> &selection) const;
void selectionInteractivelyChanged(const std::vector<bool> &selection) const;
- void itemBrushed(int item) const;
+ void itemBrushed(int item, float value) const;
void itemInteractivelyBrushed(int item) const;
public slots: