This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository echart.
View the commit online.
commit 5c255ce5faaa06513ca29fccf8a496b0ed4ad167
Author: Vincent Torri <[email protected]>
AuthorDate: Fri May 15 09:55:26 2026 +0200
add horizontal bars
---
src/bin/echart_main.c | 1 +
src/lib/echart_bar.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
src/lib/echart_bar.h | 4 ++++
3 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/src/bin/echart_main.c b/src/bin/echart_main.c
index 5cb2f86..859fce9 100644
--- a/src/bin/echart_main.c
+++ b/src/bin/echart_main.c
@@ -104,6 +104,7 @@ elm_main(int argc, char **argv)
evas_object_show(o);
#else
o = echart_bar_add(evas_object_evas_get(win));
+ echart_bar_horizontal_set(o, 1);
evas_object_move(o, 0, 0);
evas_object_resize(o, w * elm_config_scale_get(), h * elm_config_scale_get());
int nd = 3;
diff --git a/src/lib/echart_bar.c b/src/lib/echart_bar.c
index 098b735..a048d07 100644
--- a/src/lib/echart_bar.c
+++ b/src/lib/echart_bar.c
@@ -13,7 +13,7 @@
* Local *
*============================================================================*/
-#define X_VG(x) (w) * ((x) - xmin) / (xmax - xmin)
+#define X_VG(x) (w) * ((x) - sd->ymin) / (sd->ymax - sd->ymin)
#define Y_VG(y) (h) * (sd->ymax - (y)) / (sd->ymax - sd->ymin)
typedef struct Data Data;
@@ -43,6 +43,7 @@ struct Chart_Bar
double group_width; /* % between 0 and 100 */
double ymin;
double ymax;
+ unsigned int is_horizontal : 1;
};
static Evas_Smart *_bar_smart = NULL;
@@ -70,6 +71,7 @@ _bar_smart_add(Evas_Object *obj)
/* data */
sd->group_width = 61.8;
+ sd->is_horizontal = 0;
evas_object_smart_data_set(obj, sd);
@@ -202,21 +204,34 @@ _bar_smart_calculate(Evas_Object *obj)
for (int j = 0; j < sd->nbr_series; j++)
{
+ Evas_Vg_Shape *bar;
double *d;
double y = j * (bw + 1);
d = sd->data[j].values;
+ bar = sd->data[j].bars;
for (int i = 0; i < sd->nbr_values; i++)
{
double x = i * (gw + sw) + y;
- evas_vg_shape_append_move_to(sd->data[j].bars, (x), Y_VG(0));
- evas_vg_shape_append_line_to(sd->data[j].bars, (x + bw), Y_VG(0));
- evas_vg_shape_append_line_to(sd->data[j].bars, (x + bw), Y_VG(d[i]));
- evas_vg_shape_append_line_to(sd->data[j].bars, (x), Y_VG(d[i]));
+ if (sd->is_horizontal)
+ {
+ evas_vg_shape_append_move_to(bar, X_VG(0), x);
+ evas_vg_shape_append_line_to(bar, X_VG(0), (x + bw));
+ evas_vg_shape_append_line_to(bar, X_VG(d[i]), (x + bw));
+ evas_vg_shape_append_line_to(bar, X_VG(d[i]), x);
+ }
+ else
+ {
+ evas_vg_shape_append_move_to(bar, x, Y_VG(0));
+ evas_vg_shape_append_line_to(bar, (x + bw), Y_VG(0));
+ evas_vg_shape_append_line_to(bar, (x + bw), Y_VG(d[i]));
+ evas_vg_shape_append_line_to(bar, x, Y_VG(d[i]));
+ }
}
- evas_vg_node_color_set(sd->data[j].bars, sd->data[j].r, sd->data[j].g, sd->data[j].b, 255);
+ evas_vg_node_color_set(bar,
+ sd->data[j].r, sd->data[j].g, sd->data[j].b, 255);
}
}
@@ -336,6 +351,28 @@ echart_bar_data_append(Evas_Object *obj, double *values, int nbr_values)
evas_object_smart_changed(obj);
}
+ECH_API void echart_bar_horizontal_set(Evas_Object *obj, int on)
+{
+ Chart_Bar *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+
+ sd->is_horizontal = !!on;
+
+ evas_object_smart_changed(obj);
+}
+
+ECH_API int echart_bar_horizontal_get(Evas_Object *obj)
+{
+ Chart_Bar *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(sd, 0);
+
+ return sd->is_horizontal;
+}
+
ECH_API int
echart_bar_nbr_series_get(Evas_Object *obj)
{
diff --git a/src/lib/echart_bar.h b/src/lib/echart_bar.h
index 3da0a93..fa8bfcc 100644
--- a/src/lib/echart_bar.h
+++ b/src/lib/echart_bar.h
@@ -12,6 +12,10 @@ ECH_API Evas_Object *echart_bar_add(Evas *evas);
ECH_API void echart_bar_data_append(Evas_Object *obj, double *values, int nbr_vamues);
+ECH_API void echart_bar_horizontal_set(Evas_Object *obj, int on);
+
+ECH_API int echart_bar_horizontal_get(Evas_Object *obj);
+
ECH_API int echart_bar_nbr_series_get(Evas_Object *obj);
ECH_API int echart_bar_nbr_values_get(Evas_Object *obj);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.