DVUI

formatTick

Parameters

#
self:*Axis
*Axis
gpa:std.mem.Allocator
std.mem.Allocator
tick:f64
f64

Source

Implementation

#
pub fn formatTick(self: *Axis, gpa: std.mem.Allocator, tick: f64) ![]const u8 {
        const tick_format = self.ticks.format orelse
            switch (self.scale) {
                .linear => TickFormating{ .normal = .{} },
                .log => TickFormating{ .scientific_notation = .{} },
            };

        switch (tick_format) {
            .normal => |cfg| {
                return try std.fmt.allocPrint(gpa, "{d:.[1]}", .{ tick, cfg.precision });
            },
            .scientific_notation => |cfg| {
                return try std.fmt.allocPrint(gpa, "{e:.[1]}", .{ tick, cfg.precision });
            },
            .custom => |func| {
                return func(gpa, tick);
            },
        }
    }