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 da10827c06fc01b3450fb742ae958a6f21d6909e
Author: Vincent Torri <[email protected]>
AuthorDate: Tue Jun 9 10:22:16 2026 +0200
line: add area
---
src/bin/echart_grid.c | 37 ++++++++++++++++
src/lib/echart_line.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/lib/echart_line.h | 8 ++++
3 files changed, 164 insertions(+), 1 deletion(-)
diff --git a/src/bin/echart_grid.c b/src/bin/echart_grid.c
index 7966964..c313f5c 100644
--- a/src/bin/echart_grid.c
+++ b/src/bin/echart_grid.c
@@ -29,7 +29,9 @@
typedef enum Chart_Type
{
CHART_TYPE_LINE,
+ CHART_TYPE_LINE_AREA,
CHART_TYPE_LINE_CURVED,
+ CHART_TYPE_LINE_CURVED_AREA,
CHART_TYPE_VBAR,
CHART_TYPE_HBAR,
CHART_TYPE_PIE,
@@ -104,6 +106,20 @@ _grid_content_get(void *data,
return o;
}
+ case CHART_TYPE_LINE_AREA:
+ {
+ double d1[6] = { 3.5, 2.5, 4.3, 7.9, 1.2, 8.4 };
+ double d2[6] = { 9.5, 6.7, 2.3, 7.9, 10.2, 1.4 };
+
+ o = echart_line_add(evas_object_evas_get(obj));
+ echart_line_data_append(o, d1, 6);
+ echart_line_data_append(o, d2, 6);
+ echart_line_width_set(o, 3);
+ echart_line_area_set(o, EINA_TRUE);
+ evas_object_show(o);
+
+ return o;
+ }
case CHART_TYPE_LINE_CURVED:
{
double d1[6] = { 3.5, 2.5, 4.3, 7.9, 1.2, 8.4 };
@@ -118,6 +134,21 @@ _grid_content_get(void *data,
return o;
}
+ case CHART_TYPE_LINE_CURVED_AREA:
+ {
+ double d1[6] = { 3.5, 2.5, 4.3, 7.9, 1.2, 8.4 };
+ double d2[6] = { 9.5, 6.7, 2.3, 7.9, 10.2, 1.4 };
+
+ o = echart_line_add(evas_object_evas_get(obj));
+ echart_line_data_append(o, d1, 6);
+ echart_line_data_append(o, d2, 6);
+ echart_line_width_set(o, 3);
+ echart_line_curved_set(o, EINA_TRUE);
+ echart_line_area_set(o, EINA_TRUE);
+ evas_object_show(o);
+
+ return o;
+ }
case CHART_TYPE_VBAR:
{
double d1[3] = { 3, 6, 4 };
@@ -286,9 +317,15 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
it = _item_new(CHART_TYPE_LINE);
elm_gengrid_item_append(grid, gic, it, _grid_sel, NULL);
+ it = _item_new(CHART_TYPE_LINE_AREA);
+ elm_gengrid_item_append(grid, gic, it, _grid_sel, NULL);
+
it = _item_new(CHART_TYPE_LINE_CURVED);
elm_gengrid_item_append(grid, gic, it, _grid_sel, NULL);
+ it = _item_new(CHART_TYPE_LINE_CURVED_AREA);
+ elm_gengrid_item_append(grid, gic, it, _grid_sel, NULL);
+
it = _item_new(CHART_TYPE_VBAR);
elm_gengrid_item_append(grid, gic, it, _grid_sel, NULL);
diff --git a/src/lib/echart_line.c b/src/lib/echart_line.c
index 2b4e0dd..a4a374f 100644
--- a/src/lib/echart_line.c
+++ b/src/lib/echart_line.c
@@ -22,6 +22,7 @@ typedef struct Chart_Line Chart_Line;
struct Data
{
Evas_Vg_Shape *line;
+ Evas_Vg_Shape *area;
double *values;
unsigned char r, g, b;
};
@@ -43,7 +44,9 @@ struct Chart_Line
double width;
double ymin;
double ymax;
+ double opacity;
Eina_Bool is_curved : 1;
+ Eina_Bool has_area : 1;
};
static Evas_Smart *_line_smart = NULL;
@@ -69,6 +72,7 @@ _line_smart_add(Evas_Object *obj)
/* data */
sd->width = 1.0;
+ sd->opacity = 0.3;
evas_object_smart_data_set(obj, sd);
@@ -139,6 +143,7 @@ _line_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
for (int j = 0; j < sd->nbr_series; j++)
{
evas_vg_shape_reset(sd->data[j].line);
+ evas_vg_shape_reset(sd->data[j].area);
}
evas_object_smart_changed(obj);
@@ -199,16 +204,49 @@ _line_smart_calculate(Evas_Object *obj)
for (int j = 0; j < sd->nbr_series; j++)
{
Evas_Vg_Shape *line;
+ Evas_Vg_Shape *area;
double *d;
double dx;
d = sd->data[j].values;
line = sd->data[j].line;
+ area = sd->data[j].area;
if (sd->is_curved)
dx = w / (sd->nbr_values - 1);
if (sd->is_curved)
{
+ if (sd->has_area)
+ {
+ unsigned int c;
+ int r, g, b, alpha;
+
+ evas_vg_shape_append_move_to(area, X_VG(a[0]), Y_VG(d[0]));
+ for (int i = 1; i < sd->nbr_values; i++)
+ {
+ double x = X_VG(a[i]);
+ double y = Y_VG(d[i]);
+ double px = X_VG(a[i - 1]);
+ double py = Y_VG(d[i - 1]);
+ double cx1 = px + dx * 0.4;
+ double cx2 = x - dx * 0.4;
+ evas_vg_shape_append_cubic_to(area, x, y, cx1, py, cx2, y);
+ }
+ evas_vg_shape_append_line_to(area, w - 1, h - 1);
+ evas_vg_shape_append_line_to(area, 0, h - 1);
+ evas_vg_shape_append_close(area);
+
+ alpha = 255 * sd->opacity;
+ c = echart_color_get(j).area;
+ r = (unsigned char)((c >> 16) & 0xff);
+ r = ((r * alpha) >> 8);
+ g = (unsigned char)((c >> 8) & 0xff);
+ g = ((g * alpha) >> 8);
+ b = (unsigned char)((c >> 0) & 0xff);
+ b = ((b * alpha) >> 8);
+ evas_vg_node_color_set(area, r, g, b, alpha);
+ }
+
evas_vg_shape_append_move_to(line, X_VG(a[0]), Y_VG(d[0]));
for (int i = 1; i < sd->nbr_values; i++)
{
@@ -223,6 +261,31 @@ _line_smart_calculate(Evas_Object *obj)
}
else
{
+ if (sd->has_area)
+ {
+ unsigned int c;
+ int r, g, b, alpha;
+
+ evas_vg_shape_append_move_to(area, X_VG(a[0]), Y_VG(d[0]));
+ for (int i = 1; i < sd->nbr_values; i++)
+ {
+ evas_vg_shape_append_line_to(area, X_VG(a[i]), Y_VG(d[i]));
+ }
+ evas_vg_shape_append_line_to(area, w - 1, h - 1);
+ evas_vg_shape_append_line_to(area, 0, h - 1);
+ evas_vg_shape_append_close(area);
+
+ alpha = 255 * sd->opacity;
+ c = echart_color_get(j).area;
+ r = (unsigned char)((c >> 16) & 0xff);
+ r = ((r * alpha) >> 8);
+ g = (unsigned char)((c >> 8) & 0xff);
+ g = ((g * alpha) >> 8);
+ b = (unsigned char)((c >> 0) & 0xff);
+ b = ((b * alpha) >> 8);
+ evas_vg_node_color_set(area, r, g, b, alpha);
+ }
+
evas_vg_shape_append_move_to(line, X_VG(a[0]), Y_VG(d[0]));
for (int i = 1; i < sd->nbr_values; i++)
{
@@ -326,6 +389,7 @@ echart_line_data_append(Evas_Object *obj, double *values, int nbr_values)
sd->data[sd->nbr_series].b = (unsigned char)((c >> 0) & 0xff);
sd->data[sd->nbr_series].line = evas_vg_shape_add(sd->container);
+ sd->data[sd->nbr_series].area = evas_vg_shape_add(sd->container);
sd->nbr_series++;
@@ -379,6 +443,33 @@ echart_line_curved_get(Evas_Object *obj)
return sd->is_curved;
}
+ECH_API void
+echart_line_area_set(Evas_Object *obj, Eina_Bool on)
+{
+ Chart_Line *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+
+ if (sd->has_area == !!on)
+ return;
+
+ sd->has_area = !!on;
+
+ evas_object_smart_changed(obj);
+}
+
+ECH_API Eina_Bool
+echart_line_area_get(Evas_Object *obj)
+{
+ Chart_Line *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(sd, 0);
+
+ return sd->has_area;
+}
+
ECH_API int
echart_line_nbr_series_get(Evas_Object *obj)
{
@@ -421,6 +512,33 @@ echart_line_color_set(Evas_Object *obj, int serie_num, int r, int g, int b, int
evas_object_smart_changed(obj);
}
+ECH_API void
+echart_line_opacity_set(Evas_Object *obj, double opacity)
+{
+ Chart_Line *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+
+ if (opacity < 0.0) opacity = 0.0;
+ if (opacity > 1.0) opacity = 1.0;
+
+ sd->opacity = opacity;
+
+ evas_object_smart_changed(obj);
+}
+
+ECH_API double
+echart_line_opacity_get(Evas_Object *obj)
+{
+ Chart_Line *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(sd, 0.0);
+
+ return sd->opacity;
+}
+
ECH_API void
echart_line_width_set(Evas_Object *obj, double width)
{
@@ -429,7 +547,7 @@ echart_line_width_set(Evas_Object *obj, double width)
sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN(sd);
- if (EINA_FLT_EQ(sd->width, width))
+ if (EINA_DBL_EQ(sd->width, width))
return;
sd->width = width;
diff --git a/src/lib/echart_line.h b/src/lib/echart_line.h
index 24a82b0..b36f6fc 100644
--- a/src/lib/echart_line.h
+++ b/src/lib/echart_line.h
@@ -16,12 +16,20 @@ ECH_API void echart_line_curved_set(Evas_Object *obj, Eina_Bool on);
ECH_API Eina_Bool echart_line_curved_get(Evas_Object *obj);
+ECH_API void echart_line_area_set(Evas_Object *obj, Eina_Bool on);
+
+ECH_API Eina_Bool echart_line_area_get(Evas_Object *obj);
+
ECH_API int echart_line_nbr_series_get(Evas_Object *obj);
ECH_API int echart_line_nbr_values_get(Evas_Object *obj);
ECH_API void echart_line_color_set(Evas_Object *obj, int serie_num, int r, int g, int b, int a);
+ECH_API void echart_line_opacity_set(Evas_Object *obj, double opacity);
+
+ECH_API double echart_line_opacity_get(Evas_Object *obj);
+
ECH_API void echart_line_width_set(Evas_Object *obj, double width);
ECH_API double echart_line_width_get(Evas_Object *obj);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.