Simplify plot demo code
This commit is contained in:
parent
e5ccfedd61
commit
51f6cd9c58
3 changed files with 103 additions and 69 deletions
|
@ -212,22 +212,22 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
||||||
|
|
||||||
return real;
|
return real;
|
||||||
}
|
}
|
||||||
function __wbg_adapter_28(arg0, arg1) {
|
function __wbg_adapter_28(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd845485f87708210(arg0, arg1);
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h47e39678318d6d1a(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_31(arg0, arg1, arg2) {
|
function __wbg_adapter_31(arg0, arg1) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8b92f29baeb1cd03(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h88ec2fdaece42378(arg0, arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_34(arg0, arg1, arg2) {
|
function __wbg_adapter_34(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8b92f29baeb1cd03(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h47e39678318d6d1a(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_37(arg0, arg1) {
|
function __wbg_adapter_37(arg0, arg1) {
|
||||||
try {
|
try {
|
||||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h55081c666035b1eb(retptr, arg0, arg1);
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb7b5e266e17c37f9(retptr, arg0, arg1);
|
||||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||||
if (r1) {
|
if (r1) {
|
||||||
|
@ -345,6 +345,9 @@ async function init(input) {
|
||||||
}
|
}
|
||||||
const imports = {};
|
const imports = {};
|
||||||
imports.wbg = {};
|
imports.wbg = {};
|
||||||
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
||||||
|
takeObject(arg0);
|
||||||
|
};
|
||||||
imports.wbg.__wbg_log_02e20a3c32305fb7 = function(arg0, arg1) {
|
imports.wbg.__wbg_log_02e20a3c32305fb7 = function(arg0, arg1) {
|
||||||
try {
|
try {
|
||||||
console.log(getStringFromWasm0(arg0, arg1));
|
console.log(getStringFromWasm0(arg0, arg1));
|
||||||
|
@ -362,9 +365,6 @@ async function init(input) {
|
||||||
imports.wbg.__wbg_mark_abc7631bdced64f0 = function(arg0, arg1) {
|
imports.wbg.__wbg_mark_abc7631bdced64f0 = function(arg0, arg1) {
|
||||||
performance.mark(getStringFromWasm0(arg0, arg1));
|
performance.mark(getStringFromWasm0(arg0, arg1));
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
||||||
takeObject(arg0);
|
|
||||||
};
|
|
||||||
imports.wbg.__wbg_measure_c528ff64085b7146 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
imports.wbg.__wbg_measure_c528ff64085b7146 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
||||||
try {
|
try {
|
||||||
performance.measure(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
|
performance.measure(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
|
||||||
|
@ -437,6 +437,9 @@ async function init(input) {
|
||||||
const ret = getObject(arg0).createVertexArray();
|
const ret = getObject(arg0).createVertexArray();
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_deleteVertexArray_431b44dad4d908dc = function(arg0, arg1) {
|
||||||
|
getObject(arg0).deleteVertexArray(getObject(arg1));
|
||||||
|
};
|
||||||
imports.wbg.__wbg_texImage2D_40c3695cff5564ad = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
imports.wbg.__wbg_texImage2D_40c3695cff5564ad = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
||||||
getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, getObject(arg9));
|
getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, getObject(arg9));
|
||||||
}, arguments) };
|
}, arguments) };
|
||||||
|
@ -506,6 +509,9 @@ async function init(input) {
|
||||||
const ret = getObject(arg0).createTexture();
|
const ret = getObject(arg0).createTexture();
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_deleteProgram_0d4952ded7ec132a = function(arg0, arg1) {
|
||||||
|
getObject(arg0).deleteProgram(getObject(arg1));
|
||||||
|
};
|
||||||
imports.wbg.__wbg_deleteShader_67c4f4b03b5c074a = function(arg0, arg1) {
|
imports.wbg.__wbg_deleteShader_67c4f4b03b5c074a = function(arg0, arg1) {
|
||||||
getObject(arg0).deleteShader(getObject(arg1));
|
getObject(arg0).deleteShader(getObject(arg1));
|
||||||
};
|
};
|
||||||
|
@ -521,6 +527,9 @@ async function init(input) {
|
||||||
imports.wbg.__wbg_disableVertexAttribArray_4e8dd2973a2f796d = function(arg0, arg1) {
|
imports.wbg.__wbg_disableVertexAttribArray_4e8dd2973a2f796d = function(arg0, arg1) {
|
||||||
getObject(arg0).disableVertexAttribArray(arg1 >>> 0);
|
getObject(arg0).disableVertexAttribArray(arg1 >>> 0);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_drawArrays_aaa2fa80ca85e04c = function(arg0, arg1, arg2, arg3) {
|
||||||
|
getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3);
|
||||||
|
};
|
||||||
imports.wbg.__wbg_drawElements_8f3cfd28610fd46e = function(arg0, arg1, arg2, arg3, arg4) {
|
imports.wbg.__wbg_drawElements_8f3cfd28610fd46e = function(arg0, arg1, arg2, arg3, arg4) {
|
||||||
getObject(arg0).drawElements(arg1 >>> 0, arg2, arg3 >>> 0, arg4);
|
getObject(arg0).drawElements(arg1 >>> 0, arg2, arg3 >>> 0, arg4);
|
||||||
};
|
};
|
||||||
|
@ -600,6 +609,9 @@ async function init(input) {
|
||||||
imports.wbg.__wbg_texParameteri_52fb3e85a6d2c636 = function(arg0, arg1, arg2, arg3) {
|
imports.wbg.__wbg_texParameteri_52fb3e85a6d2c636 = function(arg0, arg1, arg2, arg3) {
|
||||||
getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
|
getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_uniform1f_96a968d4f5cb18de = function(arg0, arg1, arg2) {
|
||||||
|
getObject(arg0).uniform1f(getObject(arg1), arg2);
|
||||||
|
};
|
||||||
imports.wbg.__wbg_uniform1i_a6ce351ee8cef296 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbg_uniform1i_a6ce351ee8cef296 = function(arg0, arg1, arg2) {
|
||||||
getObject(arg0).uniform1i(getObject(arg1), arg2);
|
getObject(arg0).uniform1i(getObject(arg1), arg2);
|
||||||
};
|
};
|
||||||
|
@ -707,6 +719,9 @@ async function init(input) {
|
||||||
const ret = getObject(arg0).createVertexArrayOES();
|
const ret = getObject(arg0).createVertexArrayOES();
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_deleteVertexArrayOES_63dd882282a0485c = function(arg0, arg1) {
|
||||||
|
getObject(arg0).deleteVertexArrayOES(getObject(arg1));
|
||||||
|
};
|
||||||
imports.wbg.__wbg_setvolume_1f2d6904dfdf4626 = function(arg0, arg1) {
|
imports.wbg.__wbg_setvolume_1f2d6904dfdf4626 = function(arg0, arg1) {
|
||||||
getObject(arg0).volume = arg1;
|
getObject(arg0).volume = arg1;
|
||||||
};
|
};
|
||||||
|
@ -1028,6 +1043,9 @@ async function init(input) {
|
||||||
const ret = getObject(arg0).createTexture();
|
const ret = getObject(arg0).createTexture();
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_deleteProgram_61cc7923289d1bbc = function(arg0, arg1) {
|
||||||
|
getObject(arg0).deleteProgram(getObject(arg1));
|
||||||
|
};
|
||||||
imports.wbg.__wbg_deleteShader_e4f5a1da4d9c84c4 = function(arg0, arg1) {
|
imports.wbg.__wbg_deleteShader_e4f5a1da4d9c84c4 = function(arg0, arg1) {
|
||||||
getObject(arg0).deleteShader(getObject(arg1));
|
getObject(arg0).deleteShader(getObject(arg1));
|
||||||
};
|
};
|
||||||
|
@ -1043,6 +1061,9 @@ async function init(input) {
|
||||||
imports.wbg.__wbg_disableVertexAttribArray_aa8458b40dd08914 = function(arg0, arg1) {
|
imports.wbg.__wbg_disableVertexAttribArray_aa8458b40dd08914 = function(arg0, arg1) {
|
||||||
getObject(arg0).disableVertexAttribArray(arg1 >>> 0);
|
getObject(arg0).disableVertexAttribArray(arg1 >>> 0);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_drawArrays_22c88d644a33fd59 = function(arg0, arg1, arg2, arg3) {
|
||||||
|
getObject(arg0).drawArrays(arg1 >>> 0, arg2, arg3);
|
||||||
|
};
|
||||||
imports.wbg.__wbg_drawElements_6e26500a25ecf478 = function(arg0, arg1, arg2, arg3, arg4) {
|
imports.wbg.__wbg_drawElements_6e26500a25ecf478 = function(arg0, arg1, arg2, arg3, arg4) {
|
||||||
getObject(arg0).drawElements(arg1 >>> 0, arg2, arg3 >>> 0, arg4);
|
getObject(arg0).drawElements(arg1 >>> 0, arg2, arg3 >>> 0, arg4);
|
||||||
};
|
};
|
||||||
|
@ -1122,6 +1143,9 @@ async function init(input) {
|
||||||
imports.wbg.__wbg_texParameteri_caec5468f2a850c3 = function(arg0, arg1, arg2, arg3) {
|
imports.wbg.__wbg_texParameteri_caec5468f2a850c3 = function(arg0, arg1, arg2, arg3) {
|
||||||
getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
|
getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_uniform1f_258478814234cf9c = function(arg0, arg1, arg2) {
|
||||||
|
getObject(arg0).uniform1f(getObject(arg1), arg2);
|
||||||
|
};
|
||||||
imports.wbg.__wbg_uniform1i_a0275676828a22b6 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbg_uniform1i_a0275676828a22b6 = function(arg0, arg1, arg2) {
|
||||||
getObject(arg0).uniform1i(getObject(arg1), arg2);
|
getObject(arg0).uniform1i(getObject(arg1), arg2);
|
||||||
};
|
};
|
||||||
|
@ -1513,32 +1537,32 @@ async function init(input) {
|
||||||
const ret = wasm.memory;
|
const ret = wasm.memory;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2293 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper2301 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 850, __wbg_adapter_28);
|
const ret = makeMutClosure(arg0, arg1, 814, __wbg_adapter_28);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2294 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper2302 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 850, __wbg_adapter_31);
|
const ret = makeMutClosure(arg0, arg1, 814, __wbg_adapter_31);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2295 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper2303 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 850, __wbg_adapter_34);
|
const ret = makeMutClosure(arg0, arg1, 814, __wbg_adapter_34);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2304 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper2312 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 850, __wbg_adapter_37);
|
const ret = makeMutClosure(arg0, arg1, 814, __wbg_adapter_37);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2400 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper2545 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeClosure(arg0, arg1, 918, __wbg_adapter_40);
|
const ret = makeClosure(arg0, arg1, 964, __wbg_adapter_40);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2401 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper2546 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeClosure(arg0, arg1, 918, __wbg_adapter_43);
|
const ret = makeClosure(arg0, arg1, 964, __wbg_adapter_43);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2438 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper2583 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 938, __wbg_adapter_46);
|
const ret = makeMutClosure(arg0, arg1, 984, __wbg_adapter_46);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -9,6 +9,8 @@ use plot::{
|
||||||
Values,
|
Values,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
struct LineDemo {
|
struct LineDemo {
|
||||||
animate: bool,
|
animate: bool,
|
||||||
|
@ -145,8 +147,8 @@ impl LineDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for &mut LineDemo {
|
impl LineDemo {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
self.options_ui(ui);
|
self.options_ui(ui);
|
||||||
if self.animate {
|
if self.animate {
|
||||||
ui.ctx().request_repaint();
|
ui.ctx().request_repaint();
|
||||||
|
@ -171,6 +173,8 @@ impl Widget for &mut LineDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
struct MarkerDemo {
|
struct MarkerDemo {
|
||||||
fill_markers: bool,
|
fill_markers: bool,
|
||||||
|
@ -217,10 +221,8 @@ impl MarkerDemo {
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for &mut MarkerDemo {
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.checkbox(&mut self.fill_markers, "Fill");
|
ui.checkbox(&mut self.fill_markers, "Fill");
|
||||||
ui.add(
|
ui.add(
|
||||||
|
@ -248,6 +250,8 @@ impl Widget for &mut MarkerDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Default, PartialEq)]
|
#[derive(Default, PartialEq)]
|
||||||
struct LegendDemo {
|
struct LegendDemo {
|
||||||
config: Legend,
|
config: Legend,
|
||||||
|
@ -263,10 +267,8 @@ impl LegendDemo {
|
||||||
fn cos() -> Line {
|
fn cos() -> Line {
|
||||||
Line::new(Values::from_explicit_callback(move |x| x.cos(), .., 100))
|
Line::new(Values::from_explicit_callback(move |x| x.cos(), .., 100))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for &mut LegendDemo {
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
|
||||||
let LegendDemo { config } = self;
|
let LegendDemo { config } = self;
|
||||||
|
|
||||||
egui::Grid::new("settings").show(ui, |ui| {
|
egui::Grid::new("settings").show(ui, |ui| {
|
||||||
|
@ -311,6 +313,8 @@ impl Widget for &mut LegendDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq, Default)]
|
#[derive(PartialEq, Default)]
|
||||||
struct CustomAxisDemo {}
|
struct CustomAxisDemo {}
|
||||||
|
|
||||||
|
@ -365,10 +369,8 @@ impl CustomAxisDemo {
|
||||||
|
|
||||||
marks
|
marks
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for &mut CustomAxisDemo {
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
|
||||||
const MINS_PER_DAY: f64 = CustomAxisDemo::MINS_PER_DAY;
|
const MINS_PER_DAY: f64 = CustomAxisDemo::MINS_PER_DAY;
|
||||||
const MINS_PER_H: f64 = CustomAxisDemo::MINS_PER_H;
|
const MINS_PER_H: f64 = CustomAxisDemo::MINS_PER_H;
|
||||||
|
|
||||||
|
@ -432,6 +434,8 @@ impl Widget for &mut CustomAxisDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
struct LinkedAxisDemo {
|
struct LinkedAxisDemo {
|
||||||
link_x: bool,
|
link_x: bool,
|
||||||
|
@ -469,10 +473,8 @@ impl LinkedAxisDemo {
|
||||||
plot_ui.line(LinkedAxisDemo::sin());
|
plot_ui.line(LinkedAxisDemo::sin());
|
||||||
plot_ui.line(LinkedAxisDemo::cos());
|
plot_ui.line(LinkedAxisDemo::cos());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for &mut LinkedAxisDemo {
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label("Linked axes:");
|
ui.label("Linked axes:");
|
||||||
ui.checkbox(&mut self.link_x, "X");
|
ui.checkbox(&mut self.link_x, "X");
|
||||||
|
@ -504,13 +506,15 @@ impl Widget for &mut LinkedAxisDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq, Default)]
|
#[derive(PartialEq, Default)]
|
||||||
struct ItemsDemo {
|
struct ItemsDemo {
|
||||||
texture: Option<egui::TextureHandle>,
|
texture: Option<egui::TextureHandle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for &mut ItemsDemo {
|
impl ItemsDemo {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
let n = 100;
|
let n = 100;
|
||||||
let mut sin_values: Vec<_> = (0..=n)
|
let mut sin_values: Vec<_> = (0..=n)
|
||||||
.map(|i| remap(i as f64, 0.0..=n as f64, -TAU..=TAU))
|
.map(|i| remap(i as f64, 0.0..=n as f64, -TAU..=TAU))
|
||||||
|
@ -577,11 +581,13 @@ impl Widget for &mut ItemsDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Default, PartialEq)]
|
#[derive(Default, PartialEq)]
|
||||||
struct InteractionDemo {}
|
struct InteractionDemo {}
|
||||||
|
|
||||||
impl Widget for &mut InteractionDemo {
|
impl InteractionDemo {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
let plot = Plot::new("interaction_demo").height(300.0);
|
let plot = Plot::new("interaction_demo").height(300.0);
|
||||||
|
|
||||||
let InnerResponse {
|
let InnerResponse {
|
||||||
|
@ -626,6 +632,8 @@ impl Widget for &mut InteractionDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
enum Chart {
|
enum Chart {
|
||||||
GaussBars,
|
GaussBars,
|
||||||
|
@ -655,6 +663,25 @@ impl Default for ChartsDemo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChartsDemo {
|
impl ChartsDemo {
|
||||||
|
fn ui(&mut self, ui: &mut Ui) -> Response {
|
||||||
|
ui.label("Type:");
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.selectable_value(&mut self.chart, Chart::GaussBars, "Histogram");
|
||||||
|
ui.selectable_value(&mut self.chart, Chart::StackedBars, "Stacked Bar Chart");
|
||||||
|
ui.selectable_value(&mut self.chart, Chart::BoxPlot, "Box Plot");
|
||||||
|
});
|
||||||
|
ui.label("Orientation:");
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.selectable_value(&mut self.vertical, true, "Vertical");
|
||||||
|
ui.selectable_value(&mut self.vertical, false, "Horizontal");
|
||||||
|
});
|
||||||
|
match self.chart {
|
||||||
|
Chart::GaussBars => self.bar_gauss(ui),
|
||||||
|
Chart::StackedBars => self.bar_stacked(ui),
|
||||||
|
Chart::BoxPlot => self.box_plot(ui),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn bar_gauss(&self, ui: &mut Ui) -> Response {
|
fn bar_gauss(&self, ui: &mut Ui) -> Response {
|
||||||
let mut chart = BarChart::new(
|
let mut chart = BarChart::new(
|
||||||
(-395..=395)
|
(-395..=395)
|
||||||
|
@ -789,26 +816,7 @@ impl ChartsDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for &mut ChartsDemo {
|
// ----------------------------------------------------------------------------
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
|
||||||
ui.label("Type:");
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
ui.selectable_value(&mut self.chart, Chart::GaussBars, "Histogram");
|
|
||||||
ui.selectable_value(&mut self.chart, Chart::StackedBars, "Stacked Bar Chart");
|
|
||||||
ui.selectable_value(&mut self.chart, Chart::BoxPlot, "Box Plot");
|
|
||||||
});
|
|
||||||
ui.label("Orientation:");
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
ui.selectable_value(&mut self.vertical, true, "Vertical");
|
|
||||||
ui.selectable_value(&mut self.vertical, false, "Horizontal");
|
|
||||||
});
|
|
||||||
match self.chart {
|
|
||||||
Chart::GaussBars => self.bar_gauss(ui),
|
|
||||||
Chart::StackedBars => self.bar_stacked(ui),
|
|
||||||
Chart::BoxPlot => self.box_plot(ui),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
enum Panel {
|
enum Panel {
|
||||||
|
@ -828,6 +836,8 @@ impl Default for Panel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq, Default)]
|
#[derive(PartialEq, Default)]
|
||||||
pub struct PlotDemo {
|
pub struct PlotDemo {
|
||||||
line_demo: LineDemo,
|
line_demo: LineDemo,
|
||||||
|
@ -889,28 +899,28 @@ impl super::View for PlotDemo {
|
||||||
|
|
||||||
match self.open_panel {
|
match self.open_panel {
|
||||||
Panel::Lines => {
|
Panel::Lines => {
|
||||||
ui.add(&mut self.line_demo);
|
self.line_demo.ui(ui);
|
||||||
}
|
}
|
||||||
Panel::Markers => {
|
Panel::Markers => {
|
||||||
ui.add(&mut self.marker_demo);
|
self.marker_demo.ui(ui);
|
||||||
}
|
}
|
||||||
Panel::Legend => {
|
Panel::Legend => {
|
||||||
ui.add(&mut self.legend_demo);
|
self.legend_demo.ui(ui);
|
||||||
}
|
}
|
||||||
Panel::Charts => {
|
Panel::Charts => {
|
||||||
ui.add(&mut self.charts_demo);
|
self.charts_demo.ui(ui);
|
||||||
}
|
}
|
||||||
Panel::Items => {
|
Panel::Items => {
|
||||||
ui.add(&mut self.items_demo);
|
self.items_demo.ui(ui);
|
||||||
}
|
}
|
||||||
Panel::Interaction => {
|
Panel::Interaction => {
|
||||||
ui.add(&mut self.interaction_demo);
|
self.interaction_demo.ui(ui);
|
||||||
}
|
}
|
||||||
Panel::CustomAxes => {
|
Panel::CustomAxes => {
|
||||||
ui.add(&mut self.custom_axes_demo);
|
self.custom_axes_demo.ui(ui);
|
||||||
}
|
}
|
||||||
Panel::LinkedAxes => {
|
Panel::LinkedAxes => {
|
||||||
ui.add(&mut self.linked_axes_demo);
|
self.linked_axes_demo.ui(ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue