author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年08月03日 09:32:23 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年08月03日 09:32:23 +0200 |
commit | 7980634816359aac92c4338ea7b48ec983bb650c (patch) | |
tree | ca67e1af0d72556f4d38af3a0bf8ab9210272f69 /agg-plot/lua-plot.cpp | |
parent | 757911578dd111b05db7686c574d28f7ea63b437 (diff) | |
parent | 23e5174f22419bf6c5cf7a52c412c4ec3641a1e8 (diff) | |
download | gsl-shell-7980634816359aac92c4338ea7b48ec983bb650c.tar.gz |
-rw-r--r-- | agg-plot/lua-plot.cpp | 34 |
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index fc2ad1f5..9f6ce209 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -65,6 +65,8 @@ static int plot_clear (lua_State *L); static int plot_save_svg (lua_State *L); static int plot_xlab_angle_set (lua_State *L); static int plot_xlab_angle_get (lua_State *L); +static int plot_xlab_format (lua_State *L); +static int plot_ylab_format (lua_State *L); static int plot_ylab_angle_set (lua_State *L); static int plot_ylab_angle_get (lua_State *L); static int plot_set_categories (lua_State *L); @@ -133,6 +135,8 @@ static const struct luaL_Reg plot_properties_set[] = { {"ytitle", plot_ytitle_set }, {"xlab_angle", plot_xlab_angle_set }, {"ylab_angle", plot_ylab_angle_set }, + {"xlab_format", plot_xlab_format }, + {"ylab_format", plot_ylab_format }, {"units", plot_units_set }, {"sync", plot_sync_mode_set }, {"pad", plot_pad_mode_set }, @@ -374,6 +378,36 @@ plot_axis_label_angle_get (lua_State *L, sg_plot::axis_e axis) return 1; } +static int +plot_axis_label_format (lua_State *L, sg_plot::axis_e axis) +{ + sg_plot *p = object_check<sg_plot>(L, 1, GS_PLOT); + const char* fmt = luaL_optstring(L, 2, NULL); + + AGG_LOCK(); + bool success = p->enable_label_format(axis, fmt); + AGG_UNLOCK(); + + if (success) + plot_update_raw (L, p, 1); + else + luaL_error(L, "got invalid label format: %s", fmt); + + return 0; +} + +int +plot_xlab_format (lua_State* L) +{ + return plot_axis_label_format(L, sg_plot::x_axis); +} + +int +plot_ylab_format (lua_State* L) +{ + return plot_axis_label_format(L, sg_plot::y_axis); +} + int plot_xlab_angle_set(lua_State *L) { |