Announcements and New Features #370
Replies: 2 comments
-
Plot Item Flags and More - (v0.14 - 6/18/2022)Plot Item FlagsEach of ImPlot's // Flags for ANY PlotX function
enum ImPlotItemFlags_ {
ImPlotItemFlags_None = 0,
ImPlotItemFlags_NoLegend = 1 << 0, // the item won't have a legend entry displayed
ImPlotItemFlags_NoFit = 1 << 1, // the item won't be considered for plot fits
};
// Flags for PlotLine
enum ImPlotLineFlags_ {
ImPlotLineFlags_None = 0, // default
ImPlotLineFlags_Segments = 1 << 10, // a line segment will be rendered from every two consecutive points
ImPlotLineFlags_Loop = 1 << 11, // the last and first point will be connected to form a closed loop
ImPlotLineFlags_SkipNaN = 1 << 12, // NaNs values will be skipped instead of rendered as missing data
ImPlotLineFlags_NoClip = 1 << 13, // markers (if displayed) on the edge of a plot will not be clipped
};
...
void PlotLine(const char* label_id, const T* xs, const T* ys, int count, ImPlotLineFlags flags=0, int offset=0, int stride=sizeof(T)); As you can see, Here's a complete list of flags available for our current plotters: ImPlotItemFlags_NoLegend // the item won't have a legend entry displayed
ImPlotItemFlags_NoFit // the item won't be considered for plot fits
ImPlotLineFlags_Segments // a line segment will be rendered from every two consecutive points
ImPlotLineFlags_Loop // the last and first point will be connected to form a closed loop
ImPlotLineFlags_SkipNaN // NaNs values will be skipped instead of rendered as missing data
ImPlotLineFlags_NoClip // markers (if displayed) on the edge of a plot will not be clipped
ImPlotScatterFlags_NoClip // markers on the edge of a plot will not be clipped
ImPlotStairsFlags_PreStep // the y value is continued constantly to the left from every x position, i.e. the interval (x[i-1], x[i]] has the value y[i]
ImPlotBarsFlags_Horizontal // bars will be rendered horizontally on the current y-axis
ImPlotBarGroupsFlags_Horizontal // bar groups will be rendered horizontally on the current y-axis
ImPlotBarGroupsFlags_Stacked // items in a group will be stacked on top of each other
ImPlotErrorBarsFlags_Horizontal // error bars will be rendered horizontally on the current y-axis
ImPlotStemsFlags_Horizontal // stems will be rendered horizontally on the current y-axis
ImPlotInfLinesFlags_Horizontal // lines will be rendered horizontally on the current y-axis
ImPlotPieChartFlags_Normalize // force normalization of pie chart values (i.e. always make a full circle if sum < 0)
ImPlotHeatmapFlags_ColMajor // data will be read in column major order
ImPlotHistogramFlags_Horizontal // histogram bars will be rendered horizontally (not supported by PlotHistogram2D)
ImPlotHistogramFlags_Cumulative // each bin will contain its count plus the counts of all previous bins (not supported by PlotHistogram2D)
ImPlotHistogramFlags_Density // counts will be normalized, i.e. the PDF will be visualized, or the CDF will be visualized if Cumulative is also set
ImPlotHistogramFlags_NoOutliers // exclude values outside the specifed histogram range from the count toward normalizing and cumulative counts
ImPlotHistogramFlags_ColMajor // data will be read in column major order (not supported by PlotHistogram)
ImPlotTextFlags_Vertical // text will be rendered vertically SUPER IMPORTANT NOTE: Each Besides that, items flags brings about a few other API breaking changes users should be aware of:
Again, this change will likely cause headaches for some users, but with this new system in place you can expect more plotting options to be added in future updates in a flexible and, importantly, maintainable way. Thanks for understanding. SetupAxisScalePreviously, users could define time and log scales with // Axis scale
enum ImPlotScale_ {
ImPlotScale_Linear = 0, // default linear scale
ImPlotScale_Time, // date/time scale
ImPlotScale_Log10, // base 10 logartithmic scale
ImPlotScale_SymLog, // symmetric log scale
};
// Sets an axis' scale using built-in options.
void SetupAxisScale(ImAxis axis, ImPlotScale scale);
More built-in scales may be added in the future. Until then, you can also now define YOUR OWN scales using // Callback signature for axis transform.
typedef double (*ImPlotTransform)(double value, void* user_data);
// Sets an axis' scale using user supplied forward and inverse transfroms.
void SetupAxisScale(ImAxis axis, ImPlotTransform forward, ImPlotTransform inverse, void* data=NULL); Example: static inline double TransformForward_Sqrt(double v, void*) {
return sqrt(v);
}
static inline double TransformInverse_Sqrt(double v, void*) {
return v*v;
}
...
if (ImPlot::BeginPlot("Sqrt")) {
ImPlot::SetupAxis(ImAxis_X1, "Linear");
ImPlot::SetupAxis(ImAxis_Y1, "Sqrt");
ImPlot::SetupAxisScale(ImAxis_Y1, TransformForward_Sqrt, TransformInverse_Sqrt);
ImPlot::PlotLine(...);
ImPlot::EndPlot();
} New Axis ConstraintsYou can now constrain axes limits so that users can't pan beyond a min or max value, or zoom beyond a min or max width/height. This is nice if you don't want users straying away from displayed data or zooming too far into view. It is demonstrated in the candlestick demo in // Sets an axis' limits constraints.
void SetupAxisLimitsConstraints(ImAxis axis, double v_min, double v_max);
// Sets an axis' zoom constraints.
void SetupAxisZoomConstraints(ImAxis axis, double z_min, double z_max); Misc. Improvements
|
Beta Was this translation helpful? Give feedback.
-
Legend Scrolling - (v0.17 - 8/20/2022)Long legend lists will now be clipped appropriately and can be scrolled with mouse wheel. This functions for both vertical and horizontal legends, inside or outside, and legends belonging to plots or subplots. This does not currently add a physical scroll bar to long legends. I will add this feature later if users absolutely need it. |
Beta Was this translation helpful? Give feedback.
-
Announcements of changes and new features will be posted here. Click
Subscribe
to the right to receive updates!Feel free to comment on announcements, but please do not clutter the main thread with comments.
Previous Announcements:
Announcements and New Features (2021)
Announcements and New Features (2020)
Beta Was this translation helpful? Give feedback.
All reactions