CYD-UI
A C++ library for building native graphic user interfaces
Loading...
Searching...
No Matches
plot_series.cppm
Go to the documentation of this file.
1//
2// Created by castle on 8/13/24.
3//
4
6
7import std;
8import fabric.linalg;
9import reflect;
10
11using la = with_precision<double>;
12
13export namespace charts {
15 std::size_t data_len = 0;
16 la::scalar *x_data = nullptr;
17 la::scalar *y_data = nullptr;
18
19 public:
20 data_series_t() = default;
21
22 template <std::size_t DATA_LEN>
23 data_series_t(la::vec<DATA_LEN>& x, la::vec<DATA_LEN>& y)
24 : data_len(DATA_LEN), x_data(x.data.data()), y_data(y.data.data()) { }
25
26 std::size_t size() const {
27 if (x_data == nullptr || y_data == nullptr) {
28 return 0;
29 }
30 return data_len;
31 }
32
33 la::vec<2> operator[](std::size_t index) const {
34 return {x_data[index], y_data[index]};
35 }
36
38 return *this;
39 }
40 };
41 bool operator==(const data_series_t& lhs, const data_series_t& rhs) {
42 return refl::deep_eq(lhs, rhs);
43 }
44}
data_series_t(la::vec< DATA_LEN > &x, la::vec< DATA_LEN > &y)
std::size_t size() const
la::vec< 2 > operator[](std::size_t index) const
data_series_t & test()
bool operator==(const data_series_t &lhs, const data_series_t &rhs)
with_precision< double > la
Definition plot.cppm:19