Implement plot's multi level labels - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/lua-plot.cpp
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2013年01月30日 18:16:12 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2013年02月03日 22:30:35 +0100
commita366fbb4d0ede381163976dc46d39ab4a1e9fdba (patch)
tree95e1e5beb1e77bb31fc6c1a843409081c10bae45 /agg-plot/lua-plot.cpp
parent44b1bffb2220da2220aee2588143e11026e10083 (diff)
downloadgsl-shell-a366fbb4d0ede381163976dc46d39ab4a1e9fdba.tar.gz
Implement plot's multi level labels
Preliminary implementation.
Diffstat (limited to 'agg-plot/lua-plot.cpp')
-rw-r--r--agg-plot/lua-plot.cpp 40
1 files changed, 40 insertions, 0 deletions
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp
index 42961d46..7194a0b3 100644
--- a/agg-plot/lua-plot.cpp
+++ b/agg-plot/lua-plot.cpp
@@ -70,6 +70,7 @@ static int plot_ylab_angle_get (lua_State *L);
static int plot_set_categories (lua_State *L);
static int plot_set_legend (lua_State *L);
static int plot_get_legend (lua_State *L);
+static int plot_xaxis_hol_set (lua_State *L);
static int plot_sync_mode_get (lua_State *L);
static int plot_sync_mode_set (lua_State *L);
@@ -109,6 +110,7 @@ static const struct luaL_Reg plot_methods[] = {
{"set_categories", plot_set_categories},
{"set_legend", plot_set_legend},
{"get_legend", plot_get_legend},
+ {"set_hol", plot_xaxis_hol_set},
{NULL, NULL}
};
@@ -467,6 +469,44 @@ plot_units_get (lua_State *L)
return plot_bool_property_get(L, &sg_plot::use_units);
}
+int plot_xaxis_hol_set (lua_State *L)
+{
+ sg_plot *p = object_check<sg_plot>(L, 1, GS_PLOT);
+ double delta = lua_tonumber(L, 2);
+
+ if (!lua_istable(L, 3))
+ return luaL_error(L, "expect labels table specification");
+
+ ptr_list<factor_labels>* hol = p->get_xaxis_hol();
+ bool create_hol = (hol == 0);
+ if (create_hol)
+ hol = new ptr_list<factor_labels>();
+
+ factor_labels* fl = new factor_labels(delta);
+ int n = lua_objlen(L, 3);
+ for (int k = 1; k <= n; k += 2)
+ {
+ lua_rawgeti(L, 3, k);
+ int idx = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_rawgeti(L, 3, k + 1);
+ const char* str = lua_tostring(L, -1);
+ fl->add_mark(idx, str);
+ lua_pop(L, 1);
+
+ if (!str)
+ break;
+ }
+
+ hol->add(fl);
+
+ if (create_hol)
+ p->set_xaxis_hol(hol);
+
+ return 0;
+}
+
void
plot_update_raw (lua_State *L, sg_plot *p, int plot_index)
{
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月13日 14:01:24 +0000

AltStyle によって変換されたページ (->オリジナル) /