Skip to content

Conversation

@aleadbetter
Copy link
Contributor

Added setAxis function from ImPlot to allow the user to select which axis they are plotting to.

@hazeycode hazeycode requested a review from Copilot August 2, 2025 14:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a setAxis function to allow users to select which axis they are plotting to in the ImPlot wrapper. The implementation provides a simple wrapper around ImPlot's SetAxis functionality.

  • Adds C API wrapper function zguiPlot_SetAxis in the C++ layer
  • Exposes the functionality through a Zig function setAxis in the plot module

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/zplot.cpp Adds C API wrapper function for ImPlot::SetAxis
src/plot.zig Adds Zig wrapper function and extern declaration for setAxis

pub fn setupAxis(axis: Axis, args: SetupAxis) void {
zguiPlot_SetupAxis(axis, if (args.label) |l| l else null, args.flags);
}
extern fn zguiPlot_SetupAxis(axis: Axis, label: ?[*:0]const u8, flags: AxisFlags) void;
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setAxis function lacks documentation. Consider adding a doc comment explaining its purpose, when to use it, and how it affects subsequent plotting operations.

Suggested change
extern fn zguiPlot_SetupAxis(axis: Axis, label: ?[*:0]const u8, flags: AxisFlags) void;
extern fn zguiPlot_SetupAxis(axis: Axis, label: ?[*:0]const u8, flags: AxisFlags) void;
/// Sets the current axis for subsequent plotting operations.
///
/// Call this function to change the active axis (e.g., x1, y2) before issuing plot commands.
/// This affects which axis subsequent plot items will be associated with.
/// Use this when you want to plot data to a specific axis after multiple axes have been set up.

Copilot uses AI. Check for mistakes.
@hazeycode hazeycode merged commit c73edd8 into zig-gamedev:main Aug 2, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants