#load "helpers.uce" COMPONENT(Request& context) { DValue asset_props; asset_props["css"]["0"] = "themes/common/css/gauges.css"; asset_props["js"]["0"] = "components/gauges/common.js"; print(component("../theme/assets", asset_props, context)); String gauge_id = first(context.props["id"].to_string(), "needlegauge-" + std::to_string((u64)time())); String style = context.props["style"].to_string(); String title = context.props["title"].to_string(); String subtitle = context.props["subtitle"].to_string(); f64 size = float_val(first(context.props["size"].to_string(), "200")); DValue scale = context.props["scale"]; f64 scale_angle_start = float_val(first(scale["angle_start"].to_string(), std::to_string(-gauge_pi()))); f64 scale_angle_end = float_val(first(scale["angle_end"].to_string(), "0")); f64 img_height = float_val(first(context.props["img_height"].to_string(), std::to_string(size * std::max(cos(scale_angle_start), cos(scale_angle_end))))); <>

"; } for(f64 v = min_value; v <= max_value + 0.0001; v += label_interval) { f64 angle = angle_start + ((v - min_value) / vrange) * (angle_end - angle_start); f64 x1 = size / 2.0 + cos(angle) * size * 0.35; f64 y1 = size / 2.0 + sin(angle) * size * 0.35; f64 x2 = size / 2.0 + cos(angle) * size * 0.41; f64 y2 = size / 2.0 + sin(angle) * size * 0.41; ticks_html += ""; f64 lx = size / 2.0 + cos(angle) * size * 0.45; f64 ly = size / 2.0 + sin(angle) * size * 0.45; String label_value = std::to_string((s64)round(v)); ticks_html += "" + html_escape(label_value) + ""; } String segments_html = ""; if(merged["color"].get_type_name() == "array") { merged["color"].each([&](DValue range, String key) { f64 range_from = std::max(float_val(first(range["from"].to_string(), std::to_string(min_value))), min_value); f64 range_to = std::min(float_val(first(range["to"].to_string(), std::to_string(max_value))), max_value); f64 angle_from = angle_start + ((range_from - min_value) / vrange) * (angle_end - angle_start); f64 angle_to = angle_start + ((range_to - min_value) / vrange) * (angle_end - angle_start); segments_html += gauge_circle_segment_svg(size / 2.0, size / 2.0, size * 0.4, angle_from, angle_to, first(range["color"].to_string(), "rgba(120,120,120,0.5)"), 8.0, "rgba(0,0,0,0)", "opacity:0.25"); }); } else { segments_html = gauge_circle_segment_svg(size / 2.0, size / 2.0, size * 0.4, angle_start, angle_end, tick_color, 8.0, "rgba(0,0,0,0)", "opacity:0.25"); } ?>
}