Reference / Data & charts handle 3 methods, 2 fields
DataView Viewport-aware downsampled projection of a DataHandle. Created by h:view(options) .
Obtained from DataHandle:viewAccepted by PlotArea:line , PlotArea:points , PlotArea:areaThe examples on this page start from:
lua
local lines = { "t,v" }
for t = 1 , 1000 do
lines[#lines + 1 ] = t .. "," .. math.sin (t / 50 )
end
local wave = datumhue .bytes (table.concat (lines, "\n" )):csv ()
local view =
wave:view ({ x_column = "t" , y_column = "v" , pixel_width = 100 })
Fields 2
Field Type Access Description pixel_widthinteger read/write X-axis downsampling pixel budget. Assigning re-downsamples. pixel_heightinteger read/write Y-axis downsampling pixel budget. Assigning re-downsamples.
Methods 3
DataView: set_rangemethod Update the viewport range; omitted keys are left unchanged.
Example
view:set_range ({ x_min = 100 , x_max = 200 })
local range = view:range ()
print (range.x_min, range.x_max) options data.SetRangeOptions options 4 keys, 4 inherited Omitted keys keep their current value.
Key Type Description From data.RangeBounds x_min number | string Lower x bound: a number, or "auto" to fit the data. x_max number | string Upper x bound: a number, or "auto". y_min number | string Lower y bound: a number, or "auto". y_max number | string Upper y bound: a number, or "auto".
DataView: rangemethod suspends DataView:range () -> table
Effective viewport range {x_min, x_max, y_min, y_max} with resolved auto values. Raises if the view was removed.
Example
local range = view:range ()
print (range.x_min, range.x_max)
DataView: removemethod DataView:remove ()
Remove the DataView and free its resources.