[apps/stats] Series name in the box banner

This commit is contained in:
Léa Saviot
2018-05-25 16:48:25 +02:00
parent d5e75e2598
commit e7f074667a
3 changed files with 13 additions and 5 deletions

View File

@@ -3,18 +3,19 @@
namespace Statistics {
BoxBannerView::BoxBannerView() :
m_seriesName(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
m_calculationName(KDText::FontSize::Small, I18n::Message::Minimum, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
m_calculationValue(KDText::FontSize::Small, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle)
{
}
TextView * BoxBannerView::textViewAtIndex(int index) const {
const TextView * textViews[2] = {&m_calculationName, &m_calculationValue};
const TextView * textViews[3] = {&m_seriesName, &m_calculationName, &m_calculationValue};
return (TextView *)textViews[index];
}
MessageTextView * BoxBannerView::messageTextViewAtIndex(int index) const {
return index == 0 ? (MessageTextView *)&m_calculationName : nullptr;
return index == 1 ? (MessageTextView *)&m_calculationName : nullptr;
}
}

View File

@@ -11,9 +11,10 @@ class BoxBannerView : public Shared::BannerView {
public:
BoxBannerView();
private:
int numberOfSubviews() const override { return 2; }
int numberOfSubviews() const override { return 3; }
TextView * textViewAtIndex(int i) const override;
MessageTextView * messageTextViewAtIndex(int i) const override;
BufferTextView m_seriesName;
MessageTextView m_calculationName;
BufferTextView m_calculationValue;
};

View File

@@ -38,9 +38,15 @@ void BoxController::reloadBannerView() {
int selectedQuantile = (int)m_view.dataViewAtIndex(selectedSeries())->selectedQuantile();
// Set series name
char seriesChar = '0' + selectedSeries() + 1;
char bufferName[] = {'V', seriesChar, '/', 'N', seriesChar, 0};
m_view.editableBannerView()->setLegendAtIndex(bufferName, 0);
// Set calculation name
I18n::Message calculationName[5] = {I18n::Message::Minimum, I18n::Message::FirstQuartile, I18n::Message::Median, I18n::Message::ThirdQuartile, I18n::Message::Maximum};
m_view.editableBannerView()->setMessageAtIndex(calculationName[selectedQuantile], 0);
m_view.editableBannerView()->setMessageAtIndex(calculationName[selectedQuantile], 1);
// Set calculation result
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
@@ -48,7 +54,7 @@ void BoxController::reloadBannerView() {
&Store::maxValue};
double calculation = (m_store->*calculationMethods[selectedQuantile])(selectedSeries());
PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
m_view.editableBannerView()->setLegendAtIndex(buffer, 1);
m_view.editableBannerView()->setLegendAtIndex(buffer, 2);
}
}