chart_view_factory.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "statistics/view/chart_view_factory.h"
  8. #include "statistics/statistics_common.h"
  9. #include "statistics/view/linear_chart_view.h"
  10. #include "statistics/view/bar_chart_view.h"
  11. #include "statistics/view/stack_linear_chart_view.h"
  12. namespace Statistic {
  13. std::unique_ptr<AbstractChartView> CreateChartView(ChartViewType type) {
  14. switch (type) {
  15. case ChartViewType::Linear: {
  16. return std::make_unique<LinearChartView>(false);
  17. } break;
  18. case ChartViewType::Bar: {
  19. return std::make_unique<BarChartView>(false);
  20. } break;
  21. case ChartViewType::StackBar: {
  22. return std::make_unique<BarChartView>(true);
  23. } break;
  24. case ChartViewType::DoubleLinear: {
  25. return std::make_unique<LinearChartView>(true);
  26. } break;
  27. case ChartViewType::StackLinear: {
  28. return std::make_unique<StackLinearChartView>();
  29. } break;
  30. default: Unexpected("Type in Statistic::CreateChartView.");
  31. }
  32. }
  33. } // namespace Statistic