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>2012年07月28日 19:46:40 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年07月28日 19:46:40 +0200
commitcf077cb0817f498b8f1bb3a52baf8f89dc919a64 (patch)
tree8a73681aa5c59b60320a5615d6e84048a8daeaf5 /agg-plot/lua-plot.cpp
parentab805c660ead21e4376d8b67efee703420c51d63 (diff)
downloadgsl-shell-cf077cb0817f498b8f1bb3a52baf8f89dc919a64.tar.gz
Add support to specify a format for printing plot axis numbers
Diffstat (limited to 'agg-plot/lua-plot.cpp')
-rw-r--r--agg-plot/lua-plot.cpp 34
1 files changed, 34 insertions, 0 deletions
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp
index 8a6f186a..94c89ceb 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 },
@@ -363,6 +367,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)
{
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月12日 06:35:15 +0000

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