mirror of
https://github.com/gwm17/implot.git
synced 2024-11-13 22:48:50 -05:00
invert ImPlotAxisFlags
This commit is contained in:
parent
2dcdfc519a
commit
be6e1c2d2e
37
implot.cpp
37
implot.cpp
|
@ -31,6 +31,7 @@ Below is a change-log of API breaking changes only. If you are using one of the
|
|||
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all implot files.
|
||||
You can read releases logs https://github.com/epezent/implot/releases for more details.
|
||||
|
||||
- 2020/09/06 (0.7) - Several flags under ImPlotFlags and ImPlotAxisFlags were inverted so that the default flagset is simply 0. This more closely matches ImGui's style.
|
||||
- 2020/08/28 (0.5) - ImPlotMarker_ can no longer be combined with bitwise OR, |. This features caused unecessary slow-down, and almost no one used it.
|
||||
- 2020/08/25 (0.5) - ImPlotAxisFlags_Scientific was removed. Logarithmic axes automatically uses scientific notation.
|
||||
- 2020/08/17 (0.5) - PlotText was changed so that text is centered horizontally and vertically about the desired point.
|
||||
|
@ -1120,14 +1121,14 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
|||
// canvas bb
|
||||
gp.BB_Canvas = ImRect(gp.BB_Frame.Min + gp.Style.PlotPadding, gp.BB_Frame.Max - gp.Style.PlotPadding);
|
||||
|
||||
gp.RenderX = (ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_GridLines) ||
|
||||
ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickMarks) ||
|
||||
ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels));
|
||||
gp.RenderX = (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoGridLines) ||
|
||||
!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoTickMarks) ||
|
||||
!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoTickLabels));
|
||||
for (int i = 0; i < IMPLOT_Y_AXES; i++) {
|
||||
gp.RenderY[i] = gp.Y[i].Present &&
|
||||
(ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_GridLines) ||
|
||||
ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickMarks) ||
|
||||
ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickLabels));
|
||||
(!ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_NoGridLines) ||
|
||||
!ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_NoTickMarks) ||
|
||||
!ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_NoTickLabels));
|
||||
}
|
||||
|
||||
// plot bb
|
||||
|
@ -1488,7 +1489,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
|||
}
|
||||
|
||||
// render grid
|
||||
if (ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_GridLines)) {
|
||||
if (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoGridLines)) {
|
||||
float density = gp.XTicks.Size / gp.BB_Plot.GetWidth();
|
||||
ImVec4 col_min = ImGui::ColorConvertU32ToFloat4(gp.Col_X.Minor);
|
||||
col_min.w *= ImClamp(ImRemap(density, 0.1f, 0.2f, 1.0f, 0.0f), 0.0f, 1.0f);
|
||||
|
@ -1505,7 +1506,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
|||
}
|
||||
|
||||
for (int i = 0; i < IMPLOT_Y_AXES; i++) {
|
||||
if (gp.Y[i].Present && ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_GridLines)) {
|
||||
if (gp.Y[i].Present && !ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_NoGridLines)) {
|
||||
float density = gp.YTicks[i].Size / gp.BB_Plot.GetHeight();
|
||||
ImVec4 col_min = ImGui::ColorConvertU32ToFloat4(gp.Col_Y[i].Minor);
|
||||
col_min.w *= ImClamp(ImRemap(density, 0.1f, 0.2f, 1.0f, 0.0f), 0.0f, 1.0f);
|
||||
|
@ -1543,7 +1544,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
|||
|
||||
// render tick labels
|
||||
ImGui::PushClipRect(gp.BB_Frame.Min, gp.BB_Frame.Max, true);
|
||||
if (ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels)) {
|
||||
if (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoTickLabels)) {
|
||||
for (int t = 0; t < gp.XTicks.Size; t++) {
|
||||
ImPlotTick *xt = &gp.XTicks.Ticks[t];
|
||||
if (xt->ShowLabel && xt->PixelPos >= gp.BB_Plot.Min.x - 1 && xt->PixelPos <= gp.BB_Plot.Max.x + 1)
|
||||
|
@ -1552,7 +1553,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
|||
}
|
||||
}
|
||||
for (int i = 0; i < IMPLOT_Y_AXES; i++) {
|
||||
if (gp.Y[i].Present && ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickLabels)) {
|
||||
if (gp.Y[i].Present && !ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_NoTickLabels)) {
|
||||
for (int t = 0; t < gp.YTicks[i].Size; t++) {
|
||||
const float x_start = gp.YAxisReference[i] + (i == 0 ? (-gp.Style.LabelPadding.x - gp.YTicks[i].Ticks[t].LabelSize.x) : gp.Style.LabelPadding.x);
|
||||
ImPlotTick *yt = &gp.YTicks[i].Ticks[t];
|
||||
|
@ -1608,9 +1609,9 @@ inline void ShowAxisContextMenu(ImPlotAxisState& state, bool time_allowed) {
|
|||
bool total_lock = state.HasRange && state.RangeCond == ImGuiCond_Always;
|
||||
bool logscale = ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_LogScale);
|
||||
bool timescale = ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_Time);
|
||||
bool grid = ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_GridLines);
|
||||
bool ticks = ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_TickMarks);
|
||||
bool labels = ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_TickLabels);
|
||||
bool grid = !ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_NoGridLines);
|
||||
bool ticks = !ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_NoTickMarks);
|
||||
bool labels = !ImHasFlag(state.Axis->Flags, ImPlotAxisFlags_NoTickLabels);
|
||||
double drag_speed = (state.Axis->Range.Size() <= DBL_EPSILON) ? DBL_EPSILON * 1.0e+13 : 0.01 * state.Axis->Range.Size(); // recover from almost equal axis limits.
|
||||
|
||||
BeginDisabledControls(total_lock);
|
||||
|
@ -1655,11 +1656,11 @@ inline void ShowAxisContextMenu(ImPlotAxisState& state, bool time_allowed) {
|
|||
|
||||
ImGui::Separator();
|
||||
if (ImGui::Checkbox("Grid Lines", &grid))
|
||||
ImFlipFlag(state.Axis->Flags, ImPlotAxisFlags_GridLines);
|
||||
ImFlipFlag(state.Axis->Flags, ImPlotAxisFlags_NoGridLines);
|
||||
if (ImGui::Checkbox("Tick Marks", &ticks))
|
||||
ImFlipFlag(state.Axis->Flags, ImPlotAxisFlags_TickMarks);
|
||||
ImFlipFlag(state.Axis->Flags, ImPlotAxisFlags_NoTickMarks);
|
||||
if (ImGui::Checkbox("Labels", &labels))
|
||||
ImFlipFlag(state.Axis->Flags, ImPlotAxisFlags_TickLabels);
|
||||
ImFlipFlag(state.Axis->Flags, ImPlotAxisFlags_NoTickLabels);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1756,7 +1757,7 @@ void EndPlot() {
|
|||
|
||||
// render ticks
|
||||
PushPlotClipRect();
|
||||
if (ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickMarks)) {
|
||||
if (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoTickMarks)) {
|
||||
for (int t = 0; t < gp.XTicks.Size; t++) {
|
||||
ImPlotTick *xt = &gp.XTicks.Ticks[t];
|
||||
if (xt->Level == 0)
|
||||
|
@ -1775,7 +1776,7 @@ void EndPlot() {
|
|||
axis_count++;
|
||||
|
||||
float x_start = gp.YAxisReference[i];
|
||||
if (ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickMarks)) {
|
||||
if (!ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_NoTickMarks)) {
|
||||
float direction = (i == 0) ? 1.0f : -1.0f;
|
||||
bool no_major = axis_count >= 3;
|
||||
for (int t = 0; t < gp.YTicks[i].Size; t++) {
|
||||
|
|
42
implot.h
42
implot.h
|
@ -55,30 +55,32 @@ typedef int ImPlotColormap; // -> enum ImPlotColormap_
|
|||
enum ImPlotFlags_ {
|
||||
ImPlotFlags_None = 0, // default
|
||||
ImPlotFlags_NoLegend = 1 << 0, // the top-left legend will not be displayed
|
||||
ImPlotFlags_NoMenus = 1 << 1, // the user will be able to open context menus with double-right click
|
||||
ImPlotFlags_NoBoxSelect = 1 << 2, // the user will be able to box-select with right-mouse
|
||||
ImPlotFlags_NoMenus = 1 << 1, // the user will not be able to open context menus with double-right click
|
||||
ImPlotFlags_NoBoxSelect = 1 << 2, // the user will not be able to box-select with right-mouse
|
||||
ImPlotFlags_NoMousePos = 1 << 3, // the mouse position, in plot coordinates, will not be displayed in the bottom-right
|
||||
ImPlotFlags_NoHighlight = 1 << 4, // plot items will be highlighted when their legend entry is hovered
|
||||
ImPlotFlags_NoHighlight = 1 << 4, // plot items will not be highlighted when their legend entry is hovered
|
||||
ImPlotFlags_NoChild = 1 << 5, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||
ImPlotFlags_YAxis2 = 1 << 6, // enable a 2nd y-axis
|
||||
ImPlotFlags_YAxis3 = 1 << 7, // enable a 3rd y-axis
|
||||
ImPlotFlags_YAxis2 = 1 << 6, // enable a 2nd y-axis on the right side
|
||||
ImPlotFlags_YAxis3 = 1 << 7, // enable a 3rd y-axis on the right side
|
||||
ImPlotFlags_Query = 1 << 8, // the user will be able to draw query rects with middle-mouse
|
||||
ImPlotFlags_Crosshairs = 1 << 9, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||
ImPlotFlags_AntiAliased = 1 << 10 // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_AntiAliased = 1 << 10, // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
||||
};
|
||||
|
||||
// Options for plot axes (X and Y).
|
||||
enum ImPlotAxisFlags_ {
|
||||
ImPlotAxisFlags_GridLines = 1 << 0, // grid lines will be displayed
|
||||
ImPlotAxisFlags_TickMarks = 1 << 1, // tick marks will be displayed for each grid line
|
||||
ImPlotAxisFlags_TickLabels = 1 << 2, // text labels will be displayed for each grid line
|
||||
ImPlotAxisFlags_Invert = 1 << 3, // the axis will be inverted
|
||||
ImPlotAxisFlags_LockMin = 1 << 4, // the axis minimum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_LockMax = 1 << 5, // the axis maximum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_LogScale = 1 << 6, // a logartithmic (base 10) axis scale will be used
|
||||
ImPlotAxisFlags_Time = 1 << 7, // axis will display data/time formatted labels
|
||||
ImPlotAxisFlags_Default = ImPlotAxisFlags_GridLines | ImPlotAxisFlags_TickMarks | ImPlotAxisFlags_TickLabels,
|
||||
ImPlotAxisFlags_Auxiliary = ImPlotAxisFlags_TickMarks | ImPlotAxisFlags_TickLabels,
|
||||
ImPlotAxisFlags_None = 0, // default
|
||||
ImPlotAxisFlags_NoGridLines = 1 << 0, // no grid lines will be displayed
|
||||
ImPlotAxisFlags_NoTickMarks = 1 << 1, // no tick marks will be displayed
|
||||
ImPlotAxisFlags_NoTickLabels = 1 << 2, // no text labels will be displayed
|
||||
ImPlotAxisFlags_LogScale = 1 << 3, // a logartithmic (base 10) axis scale will be used (mutually exclusive with ImPlotAxisFlags_Time)
|
||||
ImPlotAxisFlags_Time = 1 << 4, // axis will display date/time formatted labels (mutually exclusive with ImPlotAxisFlags_LogScale)
|
||||
ImPlotAxisFlags_Invert = 1 << 5, // the axis will be inverted
|
||||
ImPlotAxisFlags_LockMin = 1 << 6, // the axis minimum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_LockMax = 1 << 7, // the axis maximum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_Lock = ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax,
|
||||
ImPlotAxisFlags_NoTicks = ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks | ImPlotAxisFlags_NoTickLabels
|
||||
};
|
||||
|
||||
// Plot styling colors.
|
||||
|
@ -283,10 +285,10 @@ bool BeginPlot(const char* title_id,
|
|||
const char* y_label = NULL,
|
||||
const ImVec2& size = ImVec2(-1,0),
|
||||
ImPlotFlags flags = ImPlotFlags_None,
|
||||
ImPlotAxisFlags x_flags = ImPlotAxisFlags_Default,
|
||||
ImPlotAxisFlags y_flags = ImPlotAxisFlags_Default,
|
||||
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_Auxiliary,
|
||||
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_Auxiliary);
|
||||
ImPlotAxisFlags x_flags = ImPlotAxisFlags_None,
|
||||
ImPlotAxisFlags y_flags = ImPlotAxisFlags_None,
|
||||
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_NoGridLines,
|
||||
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_NoGridLines);
|
||||
|
||||
// Only call EndPlot() if BeginPlot() returns true! Typically called at the end
|
||||
// of an if statement conditioned on BeginPlot().
|
||||
|
|
|
@ -346,8 +346,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImPlot::SetNextPlotTicksX(positions, 10, labels);
|
||||
}
|
||||
if (ImPlot::BeginPlot("Bar Plot", horz ? "Score" : "Student", horz ? "Student" : "Score",
|
||||
ImVec2(-1,0), 0, ImPlotAxisFlags_Default,
|
||||
horz ? ImPlotAxisFlags_Default | ImPlotAxisFlags_Invert : ImPlotAxisFlags_Default))
|
||||
ImVec2(-1,0), 0, 0, horz ? ImPlotAxisFlags_Invert : 0))
|
||||
{
|
||||
if (horz) {
|
||||
ImPlot::PlotBarsH("Midterm Exam", midtm, 10, 0.2f, -0.2f);
|
||||
|
@ -426,7 +425,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
}
|
||||
|
||||
ImPlot::SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
||||
if (ImPlot::BeginPlot("##Pie1", NULL, NULL, ImVec2(250,250), ImPlotFlags_NoMousePos | ImPlotFlags_NoMousePos, 0, 0)) {
|
||||
if (ImPlot::BeginPlot("##Pie1", NULL, NULL, ImVec2(250,250), ImPlotFlags_NoMousePos, ImPlotAxisFlags_NoTicks, ImPlotAxisFlags_NoTicks)) {
|
||||
ImPlot::PlotPieChart(labels1, data1, 4, 0.5f, 0.5f, 0.4f, normalize, "%.2f");
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
@ -438,7 +437,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
|
||||
ImPlot::PushColormap(ImPlotColormap_Pastel);
|
||||
ImPlot::SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
||||
if (ImPlot::BeginPlot("##Pie2", NULL, NULL, ImVec2(250,250), ImPlotFlags_NoMousePos | ImPlotFlags_NoMousePos, 0, 0)) {
|
||||
if (ImPlot::BeginPlot("##Pie2", NULL, NULL, ImVec2(250,250), ImPlotFlags_NoMousePos, ImPlotAxisFlags_NoTicks, ImPlotAxisFlags_NoTicks)) {
|
||||
ImPlot::PlotPieChart(labels2, data2, 5, 0.5f, 0.5f, 0.4f, true, "%.0f", 180);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
@ -470,12 +469,12 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImGui::LabelText("##Colormap Index", "%s", ImPlot::GetColormapName(map));
|
||||
ImGui::SetNextItemWidth(225);
|
||||
ImGui::DragFloatRange2("Min / Max",&scale_min, &scale_max, 0.01f, -20, 20);
|
||||
static ImPlotAxisFlags axes_flags = ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax | ImPlotAxisFlags_TickLabels;
|
||||
static ImPlotAxisFlags axes_flags = ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks;
|
||||
|
||||
ImPlot::PushColormap(map);
|
||||
SetNextPlotTicksX(0 + 1.0/14.0, 1 - 1.0/14.0, 7, xlabels);
|
||||
SetNextPlotTicksY(1 - 1.0/14.0, 0 + 1.0/14.0, 7, ylabels);
|
||||
if (ImPlot::BeginPlot("##Heatmap1",NULL,NULL,ImVec2(225,225),ImPlotFlags_NoLegend,axes_flags,axes_flags)) {
|
||||
if (ImPlot::BeginPlot("##Heatmap1",NULL,NULL,ImVec2(225,225),ImPlotFlags_NoLegend|ImPlotFlags_NoMousePos,axes_flags,axes_flags)) {
|
||||
ImPlot::PlotHeatmap("heat",values1[0],7,7,scale_min,scale_max);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
@ -488,7 +487,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
static ImVec4 gray[2] = {ImVec4(0,0,0,1), ImVec4(1,1,1,1)};
|
||||
ImPlot::PushColormap(gray, 2);
|
||||
ImPlot::SetNextPlotLimits(-1,1,-1,1);
|
||||
if (ImPlot::BeginPlot("##Heatmap2",NULL,NULL,ImVec2(225,225),0,0,0)) {
|
||||
if (ImPlot::BeginPlot("##Heatmap2",NULL,NULL,ImVec2(225,225),0,ImPlotAxisFlags_NoTicks,ImPlotAxisFlags_NoTicks)) {
|
||||
ImPlot::PlotHeatmap("heat1",values2,100,100,0,1,NULL);
|
||||
ImPlot::PlotHeatmap("heat2",values2,100,100,0,1,NULL, ImPlotPoint(-1,-1), ImPlotPoint(0,0));
|
||||
ImPlot::EndPlot();
|
||||
|
@ -514,7 +513,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
rdata1.Span = history;
|
||||
rdata2.Span = history;
|
||||
|
||||
static ImPlotAxisFlags rt_axis = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_TickLabels;
|
||||
static ImPlotAxisFlags rt_axis = ImPlotAxisFlags_NoTickLabels;
|
||||
ImPlot::SetNextPlotLimitsX(t - history, t, ImGuiCond_Always);
|
||||
if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1,150), 0, rt_axis, rt_axis | ImPlotAxisFlags_LockMin)) {
|
||||
ImPlot::PlotShaded("Data 1", &sdata1.Data[0].x, &sdata1.Data[0].y, sdata1.Data.size(), 0, sdata1.Offset, 2 * sizeof(t_float));
|
||||
|
@ -583,7 +582,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImGui::BulletText("Open the plot context menu (double right click) to change scales.");
|
||||
|
||||
ImPlot::SetNextPlotLimits(0.1, 100, 0, 10);
|
||||
if (ImPlot::BeginPlot("Log Plot", NULL, NULL, ImVec2(-1,0), 0, ImPlotAxisFlags_Default | ImPlotAxisFlags_LogScale )) {
|
||||
if (ImPlot::BeginPlot("Log Plot", NULL, NULL, ImVec2(-1,0), 0, ImPlotAxisFlags_LogScale )) {
|
||||
ImPlot::PlotLine("f(x) = x", xs, xs, 1001);
|
||||
ImPlot::PlotLine("f(x) = sin(x)+1", xs, ys1, 1001);
|
||||
ImPlot::PlotLine("f(x) = log(x)", xs, ys2, 1001);
|
||||
|
@ -595,7 +594,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
static double min = 1577836800; // 01/01/2020 @ 12:00:00am (UTC)
|
||||
static double max = 1609459200; // 01/01/2021 @ 12:00:00am (UTC)
|
||||
ImPlot::SetNextPlotLimits(min,max,0,1);
|
||||
if (ImPlot::BeginPlot("##Time", "UTC Time", "Y-Axis", ImVec2(-1,0), 0, ImPlotAxisFlags_Default | ImPlotAxisFlags_Time)) {
|
||||
if (ImPlot::BeginPlot("##Time", "UTC Time", "Y-Axis", ImVec2(-1,0), 0, ImPlotAxisFlags_Time)) {
|
||||
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
@ -655,7 +654,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImGui::BulletText("The query rect can be dragged after it's created.");
|
||||
ImGui::Unindent();
|
||||
|
||||
if (ImPlot::BeginPlot("##Drawing", NULL, NULL, ImVec2(-1,0), ImPlotFlags_Query, ImPlotAxisFlags_GridLines, ImPlotAxisFlags_GridLines)) {
|
||||
if (ImPlot::BeginPlot("##Drawing", NULL, NULL, ImVec2(-1,0), ImPlotFlags_Query)) {
|
||||
if (ImPlot::IsPlotHovered() && ImGui::IsMouseClicked(0) && ImGui::GetIO().KeyCtrl) {
|
||||
ImPlotPoint pt = ImPlot::GetPlotMousePos();
|
||||
data.push_back(t_float2((t_float)pt.x, (t_float)pt.y));
|
||||
|
@ -706,7 +705,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
}
|
||||
ImGui::BulletText("Query the first plot to render a subview in the second plot (see above for controls).");
|
||||
ImPlot::SetNextPlotLimits(0,0.01,-1,1);
|
||||
ImPlotAxisFlags flags = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_TickLabels;
|
||||
ImPlotAxisFlags flags = ImPlotAxisFlags_NoTickLabels;
|
||||
ImPlotLimits query;
|
||||
if (ImPlot::BeginPlot("##View1",NULL,NULL,ImVec2(-1,150), ImPlotFlags_Query, flags, flags)) {
|
||||
ImPlot::PlotLine("Signal 1", x_data, y_data1, 512);
|
||||
|
@ -1135,7 +1134,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImGui::SameLine(); ImGui::ColorEdit4("##Bull", &bullCol.x, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::SameLine(); ImGui::ColorEdit4("##Bear", &bearCol.x, ImGuiColorEditFlags_NoInputs);
|
||||
ImPlot::SetNextPlotLimits(1546300800, 1571961600, 1250, 1600);
|
||||
if (ImPlot::BeginPlot("Candlestick Chart","Day","USD",ImVec2(-1,-1),0,ImPlotAxisFlags_Default | ImPlotAxisFlags_Time)) {
|
||||
if (ImPlot::BeginPlot("Candlestick Chart","Day","USD",ImVec2(-1,-1),0,ImPlotAxisFlags_Time)) {
|
||||
MyImPlot::PlotCandlestick("GOOGL",dates, opens, closes, lows, highs, 218, tooltip, 0.25f, bullCol, bearCol);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
@ -1175,7 +1174,7 @@ ImPlotPoint Spiral(void*, int idx) {
|
|||
void Sparkline(const char* id, const float* values, int count, float min_v, float max_v, int offset, const ImVec4& col, const ImVec2& size) {
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_PlotPadding, ImVec2(0,0));
|
||||
ImPlot::SetNextPlotLimits(0, count - 1, min_v, max_v, ImGuiCond_Always);
|
||||
if (ImPlot::BeginPlot(id,0,0,size,ImPlotFlags_NoChild,0,0,0,0)) {
|
||||
if (ImPlot::BeginPlot(id,0,0,size,ImPlotFlags_CanvasOnly|ImPlotFlags_NoChild,ImPlotAxisFlags_NoTicks,ImPlotAxisFlags_NoTicks)) {
|
||||
ImPlot::PushStyleColor(ImPlotCol_Line, col);
|
||||
ImPlot::PlotLine(id, values, count, offset);
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f);
|
||||
|
|
|
@ -297,7 +297,7 @@ struct ImPlotAxis
|
|||
bool HoveredTot;
|
||||
|
||||
ImPlotAxis() {
|
||||
Flags = PreviousFlags = ImPlotAxisFlags_Default;
|
||||
Flags = PreviousFlags = ImPlotAxisFlags_None;
|
||||
Range.Min = 0;
|
||||
Range.Max = 1;
|
||||
Dragging = false;
|
||||
|
@ -374,7 +374,7 @@ struct ImPlotAxisState
|
|||
HasRange = has_range;
|
||||
RangeCond = range_cond;
|
||||
Present = present;
|
||||
HasLabels = ImHasFlag(Axis->Flags, ImPlotAxisFlags_TickLabels);
|
||||
HasLabels = !ImHasFlag(Axis->Flags, ImPlotAxisFlags_NoTickLabels);
|
||||
Invert = ImHasFlag(Axis->Flags, ImPlotAxisFlags_Invert);
|
||||
LockMin = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMin) || (HasRange && RangeCond == ImGuiCond_Always);
|
||||
LockMax = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMax) || (HasRange && RangeCond == ImGuiCond_Always);
|
||||
|
|
Loading…
Reference in New Issue
Block a user