ntcharts 0.1.0-arm-linux-musl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +332 -0
- data/ext/ntcharts/barchart.c +215 -0
- data/ext/ntcharts/extconf.rb +70 -0
- data/ext/ntcharts/extension.c +44 -0
- data/ext/ntcharts/extension.h +92 -0
- data/ext/ntcharts/linechart.c +341 -0
- data/ext/ntcharts/sparkline.c +161 -0
- data/ext/ntcharts/streamlinechart.c +183 -0
- data/ext/ntcharts/style.c +77 -0
- data/ext/ntcharts/timeserieslinechart.c +296 -0
- data/ext/ntcharts/wavelinechart.c +248 -0
- data/go/barchart.go +356 -0
- data/go/build/linux_arm/libntcharts.a +0 -0
- data/go/build/linux_arm/libntcharts.h +276 -0
- data/go/go.mod +32 -0
- data/go/go.sum +51 -0
- data/go/linechart.go +441 -0
- data/go/ntcharts.go +279 -0
- data/go/sparkline.go +194 -0
- data/go/streamlinechart.go +234 -0
- data/go/timeserieslinechart.go +354 -0
- data/go/wavelinechart.go +309 -0
- data/lib/ntcharts/3.2/ntcharts.so +0 -0
- data/lib/ntcharts/3.3/ntcharts.so +0 -0
- data/lib/ntcharts/3.4/ntcharts.so +0 -0
- data/lib/ntcharts/4.0/ntcharts.so +0 -0
- data/lib/ntcharts/bar_data.rb +51 -0
- data/lib/ntcharts/version.rb +5 -0
- data/lib/ntcharts.rb +102 -0
- data/ntcharts.gemspec +36 -0
- metadata +91 -0
data/go/sparkline.go
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import "C"
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"github.com/NimbleMarkets/ntcharts/sparkline"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
//export ntcharts_sparkline_new
|
|
11
|
+
func ntcharts_sparkline_new(width C.int, height C.int) C.ulonglong {
|
|
12
|
+
s := sparkline.New(int(width), int(height))
|
|
13
|
+
return C.ulonglong(allocSparkline(&s))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//export ntcharts_sparkline_free
|
|
17
|
+
func ntcharts_sparkline_free(id C.ulonglong) {
|
|
18
|
+
freeSparkline(uint64(id))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//export ntcharts_sparkline_width
|
|
22
|
+
func ntcharts_sparkline_width(id C.ulonglong) C.int {
|
|
23
|
+
s := getSparkline(uint64(id))
|
|
24
|
+
|
|
25
|
+
if s == nil {
|
|
26
|
+
return 0
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return C.int(s.Width())
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//export ntcharts_sparkline_height
|
|
33
|
+
func ntcharts_sparkline_height(id C.ulonglong) C.int {
|
|
34
|
+
s := getSparkline(uint64(id))
|
|
35
|
+
|
|
36
|
+
if s == nil {
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return C.int(s.Height())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//export ntcharts_sparkline_max_value
|
|
44
|
+
func ntcharts_sparkline_max_value(id C.ulonglong) C.double {
|
|
45
|
+
s := getSparkline(uint64(id))
|
|
46
|
+
|
|
47
|
+
if s == nil {
|
|
48
|
+
return 0
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return C.double(s.MaxValue())
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//export ntcharts_sparkline_scale
|
|
55
|
+
func ntcharts_sparkline_scale(id C.ulonglong) C.double {
|
|
56
|
+
s := getSparkline(uint64(id))
|
|
57
|
+
|
|
58
|
+
if s == nil {
|
|
59
|
+
return 0
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return C.double(s.Scale())
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//export ntcharts_sparkline_set_max
|
|
66
|
+
func ntcharts_sparkline_set_max(id C.ulonglong, maxVal C.double) {
|
|
67
|
+
s := getSparkline(uint64(id))
|
|
68
|
+
|
|
69
|
+
if s == nil {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
s.SetMax(float64(maxVal))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//export ntcharts_sparkline_set_style
|
|
77
|
+
func ntcharts_sparkline_set_style(id C.ulonglong, styleID C.ulonglong) {
|
|
78
|
+
s := getSparkline(uint64(id))
|
|
79
|
+
|
|
80
|
+
if s == nil {
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
style, ok := getStyle(uint64(styleID))
|
|
85
|
+
|
|
86
|
+
if ok {
|
|
87
|
+
s.Style = style
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//export ntcharts_sparkline_set_auto_max_value
|
|
92
|
+
func ntcharts_sparkline_set_auto_max_value(id C.ulonglong, autoVal C.int) {
|
|
93
|
+
s := getSparkline(uint64(id))
|
|
94
|
+
|
|
95
|
+
if s == nil {
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
s.AutoMaxValue = autoVal != 0
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//export ntcharts_sparkline_resize
|
|
103
|
+
func ntcharts_sparkline_resize(id C.ulonglong, width C.int, height C.int) {
|
|
104
|
+
s := getSparkline(uint64(id))
|
|
105
|
+
|
|
106
|
+
if s == nil {
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
s.Resize(int(width), int(height))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//export ntcharts_sparkline_clear
|
|
114
|
+
func ntcharts_sparkline_clear(id C.ulonglong) {
|
|
115
|
+
s := getSparkline(uint64(id))
|
|
116
|
+
|
|
117
|
+
if s == nil {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
s.Clear()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//export ntcharts_sparkline_push
|
|
125
|
+
func ntcharts_sparkline_push(id C.ulonglong, value C.double) {
|
|
126
|
+
s := getSparkline(uint64(id))
|
|
127
|
+
|
|
128
|
+
if s == nil {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
s.Push(float64(value))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//export ntcharts_sparkline_push_all
|
|
136
|
+
func ntcharts_sparkline_push_all(id C.ulonglong, valuesJSON *C.char) {
|
|
137
|
+
s := getSparkline(uint64(id))
|
|
138
|
+
|
|
139
|
+
if s == nil {
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
var values []float64
|
|
144
|
+
|
|
145
|
+
if err := json.Unmarshal([]byte(C.GoString(valuesJSON)), &values); err != nil {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
s.PushAll(values)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//export ntcharts_sparkline_draw
|
|
153
|
+
func ntcharts_sparkline_draw(id C.ulonglong) {
|
|
154
|
+
s := getSparkline(uint64(id))
|
|
155
|
+
|
|
156
|
+
if s == nil {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
s.Draw()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//export ntcharts_sparkline_draw_columns_only
|
|
164
|
+
func ntcharts_sparkline_draw_columns_only(id C.ulonglong) {
|
|
165
|
+
s := getSparkline(uint64(id))
|
|
166
|
+
|
|
167
|
+
if s == nil {
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
s.DrawColumnsOnly()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//export ntcharts_sparkline_draw_braille
|
|
175
|
+
func ntcharts_sparkline_draw_braille(id C.ulonglong) {
|
|
176
|
+
s := getSparkline(uint64(id))
|
|
177
|
+
|
|
178
|
+
if s == nil {
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
s.DrawBraille()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//export ntcharts_sparkline_view
|
|
186
|
+
func ntcharts_sparkline_view(id C.ulonglong) *C.char {
|
|
187
|
+
s := getSparkline(uint64(id))
|
|
188
|
+
|
|
189
|
+
if s == nil {
|
|
190
|
+
return C.CString("")
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return C.CString(s.View())
|
|
194
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
*/
|
|
6
|
+
import "C"
|
|
7
|
+
|
|
8
|
+
import (
|
|
9
|
+
"github.com/NimbleMarkets/ntcharts/canvas/runes"
|
|
10
|
+
"github.com/NimbleMarkets/ntcharts/linechart/streamlinechart"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
//export ntcharts_streamlinechart_new
|
|
14
|
+
func ntcharts_streamlinechart_new(width C.int, height C.int) C.ulonglong {
|
|
15
|
+
m := streamlinechart.New(int(width), int(height))
|
|
16
|
+
return C.ulonglong(allocStreamlinechart(&m))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//export ntcharts_streamlinechart_free
|
|
20
|
+
func ntcharts_streamlinechart_free(id C.ulonglong) {
|
|
21
|
+
freeStreamlinechart(uint64(id))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//export ntcharts_streamlinechart_width
|
|
25
|
+
func ntcharts_streamlinechart_width(id C.ulonglong) C.int {
|
|
26
|
+
s := getStreamlinechart(uint64(id))
|
|
27
|
+
|
|
28
|
+
if s == nil {
|
|
29
|
+
return 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return C.int(s.Width())
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//export ntcharts_streamlinechart_height
|
|
36
|
+
func ntcharts_streamlinechart_height(id C.ulonglong) C.int {
|
|
37
|
+
s := getStreamlinechart(uint64(id))
|
|
38
|
+
|
|
39
|
+
if s == nil {
|
|
40
|
+
return 0
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return C.int(s.Height())
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//export ntcharts_streamlinechart_graph_width
|
|
47
|
+
func ntcharts_streamlinechart_graph_width(id C.ulonglong) C.int {
|
|
48
|
+
s := getStreamlinechart(uint64(id))
|
|
49
|
+
|
|
50
|
+
if s == nil {
|
|
51
|
+
return 0
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return C.int(s.GraphWidth())
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//export ntcharts_streamlinechart_graph_height
|
|
58
|
+
func ntcharts_streamlinechart_graph_height(id C.ulonglong) C.int {
|
|
59
|
+
s := getStreamlinechart(uint64(id))
|
|
60
|
+
|
|
61
|
+
if s == nil {
|
|
62
|
+
return 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return C.int(s.GraphHeight())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//export ntcharts_streamlinechart_min_y
|
|
69
|
+
func ntcharts_streamlinechart_min_y(id C.ulonglong) C.double {
|
|
70
|
+
s := getStreamlinechart(uint64(id))
|
|
71
|
+
|
|
72
|
+
if s == nil {
|
|
73
|
+
return 0
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return C.double(s.MinY())
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//export ntcharts_streamlinechart_max_y
|
|
80
|
+
func ntcharts_streamlinechart_max_y(id C.ulonglong) C.double {
|
|
81
|
+
s := getStreamlinechart(uint64(id))
|
|
82
|
+
|
|
83
|
+
if s == nil {
|
|
84
|
+
return 0
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return C.double(s.MaxY())
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//export ntcharts_streamlinechart_set_y_range
|
|
91
|
+
func ntcharts_streamlinechart_set_y_range(id C.ulonglong, minVal C.double, maxVal C.double) {
|
|
92
|
+
s := getStreamlinechart(uint64(id))
|
|
93
|
+
|
|
94
|
+
if s != nil {
|
|
95
|
+
s.SetYRange(float64(minVal), float64(maxVal))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//export ntcharts_streamlinechart_set_view_y_range
|
|
100
|
+
func ntcharts_streamlinechart_set_view_y_range(id C.ulonglong, minVal C.double, maxVal C.double) {
|
|
101
|
+
s := getStreamlinechart(uint64(id))
|
|
102
|
+
|
|
103
|
+
if s != nil {
|
|
104
|
+
s.SetViewYRange(float64(minVal), float64(maxVal))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//export ntcharts_streamlinechart_resize
|
|
109
|
+
func ntcharts_streamlinechart_resize(id C.ulonglong, width C.int, height C.int) {
|
|
110
|
+
s := getStreamlinechart(uint64(id))
|
|
111
|
+
|
|
112
|
+
if s != nil {
|
|
113
|
+
s.Resize(int(width), int(height))
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//export ntcharts_streamlinechart_clear
|
|
118
|
+
func ntcharts_streamlinechart_clear(id C.ulonglong) {
|
|
119
|
+
s := getStreamlinechart(uint64(id))
|
|
120
|
+
|
|
121
|
+
if s != nil {
|
|
122
|
+
s.Clear()
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//export ntcharts_streamlinechart_clear_data
|
|
127
|
+
func ntcharts_streamlinechart_clear_data(id C.ulonglong) {
|
|
128
|
+
s := getStreamlinechart(uint64(id))
|
|
129
|
+
|
|
130
|
+
if s != nil {
|
|
131
|
+
s.ClearAllData()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//export ntcharts_streamlinechart_push
|
|
136
|
+
func ntcharts_streamlinechart_push(id C.ulonglong, value C.double) {
|
|
137
|
+
s := getStreamlinechart(uint64(id))
|
|
138
|
+
|
|
139
|
+
if s != nil {
|
|
140
|
+
s.Push(float64(value))
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//export ntcharts_streamlinechart_set_styles
|
|
145
|
+
func ntcharts_streamlinechart_set_styles(id C.ulonglong, lineStyle C.int, styleID C.ulonglong) {
|
|
146
|
+
s := getStreamlinechart(uint64(id))
|
|
147
|
+
|
|
148
|
+
if s == nil {
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
ls := getStreamLineStyle(int(lineStyle))
|
|
153
|
+
style, ok := getStyle(uint64(styleID))
|
|
154
|
+
|
|
155
|
+
if ok {
|
|
156
|
+
s.SetStyles(ls, style)
|
|
157
|
+
} else {
|
|
158
|
+
s.SetStyles(ls, s.Style)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//export ntcharts_streamlinechart_set_style
|
|
163
|
+
func ntcharts_streamlinechart_set_style(id C.ulonglong, styleID C.ulonglong) {
|
|
164
|
+
s := getStreamlinechart(uint64(id))
|
|
165
|
+
|
|
166
|
+
if s == nil {
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
style, ok := getStyle(uint64(styleID))
|
|
170
|
+
|
|
171
|
+
if ok {
|
|
172
|
+
s.Style = style
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//export ntcharts_streamlinechart_set_axis_style
|
|
177
|
+
func ntcharts_streamlinechart_set_axis_style(id C.ulonglong, styleID C.ulonglong) {
|
|
178
|
+
s := getStreamlinechart(uint64(id))
|
|
179
|
+
|
|
180
|
+
if s == nil {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
style, ok := getStyle(uint64(styleID))
|
|
185
|
+
|
|
186
|
+
if ok {
|
|
187
|
+
s.AxisStyle = style
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//export ntcharts_streamlinechart_set_label_style
|
|
192
|
+
func ntcharts_streamlinechart_set_label_style(id C.ulonglong, styleID C.ulonglong) {
|
|
193
|
+
s := getStreamlinechart(uint64(id))
|
|
194
|
+
|
|
195
|
+
if s == nil {
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
style, ok := getStyle(uint64(styleID))
|
|
199
|
+
|
|
200
|
+
if ok {
|
|
201
|
+
s.LabelStyle = style
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//export ntcharts_streamlinechart_draw
|
|
206
|
+
func ntcharts_streamlinechart_draw(id C.ulonglong) {
|
|
207
|
+
s := getStreamlinechart(uint64(id))
|
|
208
|
+
|
|
209
|
+
if s != nil {
|
|
210
|
+
s.Draw()
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
//export ntcharts_streamlinechart_view
|
|
215
|
+
func ntcharts_streamlinechart_view(id C.ulonglong) *C.char {
|
|
216
|
+
s := getStreamlinechart(uint64(id))
|
|
217
|
+
|
|
218
|
+
if s == nil {
|
|
219
|
+
return C.CString("")
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return C.CString(s.View())
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
func getStreamLineStyle(style int) runes.LineStyle {
|
|
226
|
+
switch style {
|
|
227
|
+
case 0:
|
|
228
|
+
return runes.ThinLineStyle
|
|
229
|
+
case 1:
|
|
230
|
+
return runes.ArcLineStyle
|
|
231
|
+
default:
|
|
232
|
+
return runes.ArcLineStyle
|
|
233
|
+
}
|
|
234
|
+
}
|