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 483ae79cbf61071e6b8293b78041202d806c5221
Author: Vincent Torri <[email protected]>
AuthorDate: Thu Apr 2 16:00:15 2026 +0200

    initial commit
---
 LICENSE                  |   2 +-
 meson.build              |  91 ++++++++++++++
 meson_options.txt        |   6 +
 src/bin/echart_main.c    |  88 ++++++++++++++
 src/bin/meson.build      |  12 ++
 src/lib/Echart.h         |  50 ++++++++
 src/lib/echart_chart.c   | 302 +++++++++++++++++++++++++++++++++++++++++++++++
 src/lib/echart_chart.h   |  66 +++++++++++
 src/lib/echart_color.c   |  85 +++++++++++++
 src/lib/echart_color.h   |  21 ++++
 src/lib/echart_font.h    |  20 ++++
 src/lib/echart_line.c    | 277 +++++++++++++++++++++++++++++++++++++++++++
 src/lib/echart_line.h    |  19 +++
 src/lib/echart_main.c    |  89 ++++++++++++++
 src/lib/echart_main.h    |  64 ++++++++++
 src/lib/echart_private.h |  41 +++++++
 src/lib/meson.build      |  40 +++++++
 17 files changed, 1272 insertions(+), 1 deletion(-)

diff --git a/LICENSE b/LICENSE
index 26b18a2..0853333 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2026 vtorri 
+Copyright (c) 2026 Vincent Torri
 
 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..6e9f006
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,91 @@
+# SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+# SPDX-License-Identifier: BSD-2-Clause
+
+project('echart', 'c',
+  default_options : [
+    'buildtype=debug',
+    'c_std=c99',
+    'warning_level=2',
+    'werror=false',
+  ],
+  meson_version   : '>= 0.60',
+  license         : 'BSD 2 clause',
+  version         : '0.0.1',
+)
+
+v_array = meson.project_version().split('.')
+v_maj = v_array[0]
+v_min = v_array[1]
+v_mic = v_array[2]
+
+# install paths
+dir_prefix = get_option('prefix')
+dir_include = join_paths(dir_prefix, get_option('includedir'))
+dir_pkginclude = join_paths(dir_include, meson.project_name())
+dir_bin = join_paths(dir_prefix, get_option('bindir'))
+dir_lib = join_paths(dir_prefix, get_option('libdir'))
+dir_data = join_paths(dir_prefix, get_option('datadir'))
+dir_pkgdata = join_paths(dir_data, meson.project_name())
+dir_locale = join_paths(dir_prefix, get_option('localedir'))
+
+# host
+
+host_os = host_machine.system()
+bsd = ['bsd', 'freebsd', 'dragonfly', 'netbsd', 'openbsd']
+linux = ['linux']
+sun = ['sunos']
+win32 = ['windows']
+sys_bsd = bsd.contains(host_machine.system())
+sys_linux = linux.contains(host_machine.system())
+sys_sun = sun.contains(host_machine.system())
+sys_windows = win32.contains(host_os)
+
+# binaries
+
+cc = meson.get_compiler('c')
+
+echart_cflags = []
+echart_cflags_try = [
+  '-Wshadow',
+  '-Wdeclaration-after-statement',
+  '-Wstrict-prototypes',
+  '-Werror=pointer-arith',
+  '-Wno-missing-field-initializers',
+]
+
+foreach cf: echart_cflags_try
+  if cc.has_argument(cf) == true
+    echart_cflags += cf
+  endif
+endforeach
+
+if get_option('docs')
+  doxygen = find_program('doxygen', required : false)
+  dot = find_program('dot', required : false)
+endif
+
+# dependencies
+
+efl_req = '>= 1.28'
+echart_deps = dependency('elementary', version : efl_req)
+
+config_dir = [ include_directories('.') ]
+
+# configuration
+
+config_dir = [include_directories('.')]
+config_h = configuration_data()
+config_h.set_quoted('PACKAGE_NAME', meson.project_name())
+config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
+config_h.set('PACKAGE_VMAJ', v_maj)
+config_h.set('PACKAGE_VMIN', v_min)
+config_h.set('PACKAGE_VMIC', v_mic)
+
+subdir('src/lib')
+subdir('src/bin')
+if get_option('docs') and doxygen.found() and dot.found()
+  subdir('doc')
+endif
+
+# use config_h after all subdirs have set values
+configure_file(output : 'config.h', configuration : config_h)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..e1d885b
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,6 @@
+
+option('docs',
+  type: 'boolean',
+  value: false,
+  description: 'Enable building C of documentation (Requires doxygen and dot)'
+)
diff --git a/src/bin/echart_main.c b/src/bin/echart_main.c
new file mode 100644
index 0000000..1918c50
--- /dev/null
+++ b/src/bin/echart_main.c
@@ -0,0 +1,88 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <config.h>
+
+#include <Elementary.h>
+
+#include "Echart.h"
+
+EAPI_MAIN int
+elm_main(int argc, char **argv)
+{
+   Evas_Object *win;
+   Evas_Object *o;
+   double *absciss;
+   double *d;
+   unsigned int num;
+   int w;
+   int h;
+
+   echart_init();
+
+   num = 6;
+   absciss = (double *)calloc(num, sizeof(double));
+   absciss[0] = 1;
+   absciss[1] = 2;
+   absciss[2] = 4;
+   absciss[3] = 5;
+   absciss[4] = 7;
+   absciss[5] = 8;
+
+   d = (double *)calloc(num, sizeof(double));
+   d[0] = 1.5;
+   d[1] = -1.5;
+   d[2] = 2.3;
+   d[3] = 7.9;
+   d[4] = -4.2;
+   d[5] = 8.6;
+
+   w = 200;
+   h = 200;
+
+   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+
+   win = elm_win_util_standard_add("Chart", "Chart example");
+   elm_win_autodel_set(win, EINA_TRUE);
+
+   /* background */
+   o = elm_bg_add(win);
+   evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_object_style_set(o, "grad_vert_focus_title_match");
+   elm_win_resize_object_add(win, o);
+   evas_object_show(o);
+
+   /* chart */
+   /* o = echart_add(evas_object_evas_get(win)); */
+   /* evas_object_move(o, 200, 0); */
+   /* evas_object_resize(o, 200 * elm_config_scale_get(), 200 * elm_config_scale_get()); */
+   /* //echart_bg_color_set(o, 255, 0, 0, 255); */
+   /* echart_title_set(o, "Plot"); */
+   /* echart_title_color_set(o, 255, 0, 0, 255); */
+   /* evas_object_show(o);*/
+
+   /* line */
+   o = echart_line_add(evas_object_evas_get(win));
+   evas_object_move(o, 0, 0);
+   evas_object_resize(o, 200 * elm_config_scale_get(), 200 * elm_config_scale_get());
+   echart_line_data_set(o, d, num);
+   echart_line_color_set(o, 255, 0, 0, 255);
+   echart_line_width_set(o, 3);
+   evas_object_show(o);
+
+   evas_object_resize(win,
+                      w * elm_config_scale_get(),
+                      h * elm_config_scale_get());
+   evas_object_show(win);
+
+   elm_run();
+
+   evas_object_del(o);
+
+   echart_shutdown();
+
+   return 0;
+}
+ELM_MAIN()
diff --git a/src/bin/meson.build b/src/bin/meson.build
new file mode 100644
index 0000000..aecedbb
--- /dev/null
+++ b/src/bin/meson.build
@@ -0,0 +1,12 @@
+# SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+# SPDX-License-Identifier: BSD-2-Clause
+
+echart_bin_src = files([
+  'echart_main.c',
+])
+
+executable('echart', echart_bin_src,
+  dependencies : [ echart_deps, echart_dep ],
+  include_directories : config_dir,
+  install : true,
+)
diff --git a/src/lib/Echart.h b/src/lib/Echart.h
new file mode 100644
index 0000000..866841b
--- /dev/null
+++ b/src/lib/Echart.h
@@ -0,0 +1,50 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+/**
+ * @file
+ *
+ * @brief EFL-base chart library.
+ *
+ * @page echart_main Echart
+ *
+ * Tiny library to display charts.
+ */
+
+#ifndef ECHART_H
+#define ECHART_H
+
+#ifdef ECH_API
+# undef ECH_API
+#endif
+
+#ifndef ECHART_STATIC
+# ifdef _WIN32
+#  ifdef ECHART_BUILD
+#   ifdef DLL_EXPORT
+#    define ECH_API __declspec(dllexport)
+#   else
+#    define ECH_API
+#   endif
+#  else
+#   define ECH_API __declspec(dllimport)
+#  endif
+# elif (defined(__SUNPRO_C)  || defined(__SUNPRO_CC))
+#  define ECH_API __global
+# elif (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
+#  define ECH_API __attribute__ ((visibility("default")))
+# else
+#  define ECH_API
+# endif
+#else
+# define ECH_API
+#endif
+
+#include "echart_main.h"
+#include "echart_color.h"
+#include "echart_line.h"
+#include "echart_chart.h"
+
+#endif
diff --git a/src/lib/echart_chart.c b/src/lib/echart_chart.c
new file mode 100644
index 0000000..edc6814
--- /dev/null
+++ b/src/lib/echart_chart.c
@@ -0,0 +1,302 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <config.h>
+
+#include "Echart.h"
+#include "echart_private.h"
+
+/*============================================================================*
+ *                                  Local                                     *
+ *============================================================================*/
+
+#define COL_TO_A(col_) (((col_) >> 24) & 0xff)
+#define COL_TO_R(col_) (((col_) >> 16) & 0xff)
+#define COL_TO_G(col_) (((col_) >> 8 ) & 0xff)
+#define COL_TO_B(col_) (((col_)      ) & 0xff)
+
+typedef struct Chart Chart;
+
+struct Chart
+{
+   Evas_Object_Smart_Clipped_Data __clipped_data;
+
+   Evas_Object *o_bg;
+   Evas_Object *o_title;
+};
+
+static Evas_Smart *_chart_smart = NULL;
+static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
+
+/* utility functions */
+
+/* Evas_Object smart callbacks */
+
+static void
+_chart_smart_add(Evas_Object *obj)
+{
+   Chart *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = calloc(1, sizeof(Chart));
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   sd->o_bg = evas_object_rectangle_add(evas_object_evas_get(obj));
+
+   evas_object_smart_data_set(obj, sd);
+
+   _parent_sc.add(obj);
+}
+
+static void
+_chart_smart_del(Evas_Object *obj)
+{
+   Chart *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   _parent_sc.del(obj);
+
+   evas_object_del(sd->o_title);
+   evas_object_del(sd->o_bg);
+
+   evas_object_smart_data_set(obj, NULL);
+   memset(sd, 0, sizeof(*sd));
+   free(sd);
+}
+
+static void
+_chart_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+   Chart *sd;
+   Evas_Coord ox;
+   Evas_Coord oy;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
+   if ((x == ox) && (y == oy))
+      return;
+
+   evas_object_move(sd->o_bg, x, y);
+
+   evas_object_smart_changed(obj);
+}
+
+static void
+_chart_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
+{
+   Chart *sd;
+   Evas_Coord ow;
+   Evas_Coord oh;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
+   if ((w == ow) && (h == oh))
+      return;
+
+   evas_object_resize(sd->o_bg, w, h);
+
+   evas_object_smart_changed(obj);
+}
+
+static void
+_chart_smart_show(Evas_Object *obj)
+{
+   Chart *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   if (sd->o_title)
+      evas_object_show(sd->o_title);
+   evas_object_show(sd->o_bg);
+}
+
+static void
+_chart_smart_hide(Evas_Object *obj)
+{
+   Chart *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   if (sd->o_title)
+      evas_object_hide(sd->o_title);
+   evas_object_hide(sd->o_bg);
+}
+
+static void
+_chart_smart_calculate(Evas_Object *obj)
+{
+   Chart *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   if (sd->o_title)
+   {
+      Evas_Coord ox;
+      Evas_Coord oy;
+      Evas_Coord ow;
+      Evas_Coord tw;
+
+      evas_object_geometry_get(sd->o_bg, &ox, &oy, &ow, NULL);
+      evas_object_geometry_get(sd->o_title, NULL, NULL, &tw, NULL);
+      evas_object_move(sd->o_title, ox + (ow - tw) / 2, oy);
+   }
+}
+
+static void
+_chart_smart_init(void)
+{
+   static Evas_Smart_Class sc;
+
+   INF(" * %s", __FUNCTION__);
+
+   evas_object_smart_clipped_smart_set(&_parent_sc);
+   sc           = _parent_sc;
+   sc.name      = "grid";
+   sc.version   = EVAS_SMART_CLASS_VERSION;
+   sc.add       = _chart_smart_add;
+   sc.del       = _chart_smart_del;
+   sc.move      = _chart_smart_move;
+   sc.resize    = _chart_smart_resize;
+   sc.show      = _chart_smart_show;
+   sc.hide      = _chart_smart_hide;
+   sc.calculate = _chart_smart_calculate;
+   _chart_smart = evas_smart_class_new(&sc);
+}
+
+/*============================================================================*
+ *                                 Global                                     *
+ *============================================================================*/
+
+/*============================================================================*
+ *                                   API                                      *
+ *============================================================================*/
+
+ECH_API Evas_Object *
+echart_add(Evas *evas)
+{
+   Evas_Object *obj;
+
+   INF(" * %s", __FUNCTION__);
+
+   if (!_chart_smart) _chart_smart_init();
+   obj = evas_object_smart_add(evas, _chart_smart);
+
+   return obj;
+}
+
+ECH_API void
+echart_bg_color_set(Evas_Object *obj, int r, int g, int b, int a)
+{
+   Chart *sd;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_color_set(sd->o_bg, r, g, b, a);
+}
+
+ECH_API void
+echart_title_set(Evas_Object *obj, const char *title)
+{
+   Chart *sd;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   if (!title || !*title)
+      return;
+
+   if (!sd->o_title)
+   {
+      sd->o_title = evas_object_text_add(evas_object_evas_get(obj));
+      evas_object_text_style_set(sd->o_title, EVAS_TEXT_STYLE_PLAIN);
+      evas_object_color_set(sd->o_title, 0, 0, 0, 255);
+      evas_object_text_font_set(sd->o_title, "Sans:style=Bold", 13*3);
+   }
+
+   evas_object_text_text_set(sd->o_title, title);
+
+   evas_object_smart_changed(obj);
+}
+
+ECH_API const char *echart_title_get(Evas_Object *obj)
+{
+   Chart *sd;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
+
+   return evas_object_text_text_get(sd->o_title);
+}
+
+ECH_API void
+echart_title_color_set(Evas_Object *obj, int r, int g, int b, int a)
+{
+   Chart *sd;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   if (sd->o_title)
+      evas_object_color_set(sd->o_title, r, g, b, a);
+}
+
+ECH_API void
+echart_title_font_set(Evas_Object *obj, const Echart_Font *fs)
+{
+   Chart *sd;
+   Eina_Strbuf *buf;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   if (!fs)
+      return;
+
+   if (!sd->o_title)
+      return;
+
+   buf = eina_strbuf_new();
+   if (!buf)
+      return;
+
+   eina_strbuf_append(buf, fs->name ? fs->name : "Sans");
+   if (fs->bold || fs->italic)
+   {
+      eina_strbuf_append(buf, ":style=");
+      if (!fs->italic)
+         eina_strbuf_append(buf, "Bold");
+      else if (!fs->bold)
+         eina_strbuf_append(buf, "Italic");
+      else
+         eina_strbuf_append(buf, "Bold Italic");
+   }
+
+   evas_object_text_font_set(sd->o_title,
+                             eina_strbuf_string_get(buf),
+                             fs->size);
+}
diff --git a/src/lib/echart_chart.h b/src/lib/echart_chart.h
new file mode 100644
index 0000000..f9d7027
--- /dev/null
+++ b/src/lib/echart_chart.h
@@ -0,0 +1,66 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef ECHART_CHART_H
+#define ECHART_CHART_H
+
+#include <Evas.h>
+
+typedef struct _Echart_Chart Echart_Chart;
+
+typedef struct
+{
+   char *name;
+   unsigned short size;
+   Eina_Bool bold : 1;
+   Eina_Bool italic : 1;
+} Echart_Font;
+
+ECH_API Evas_Object *echart_add(Evas *evas);
+
+ECH_API void echart_bg_color_set(Evas_Object *obj, int r, int g, int b, int a);
+
+ECH_API void echart_title_set(Evas_Object *obj, const char *title);
+ECH_API const char *echart_title_get(Evas_Object *obj);
+ECH_API void echart_title_color_set(Evas_Object *obj, int r, int g, int b, int a);
+ECH_API void echart_title_font_set(Evas_Object *obj, const Echart_Font *fs);
+
+#if 0
+
+
+ECH_API void echart_chart_title_haxis_set(Echart_Chart *chart, const char *title);
+ECH_API const char *echart_chart_title_haxis_get(const Echart_Chart *chart);
+ECH_API void echart_chart_title_haxis_style_set(Echart_Chart *chart,
+                                                const Echart_Font_Style *fs);
+ECH_API Eina_Bool echart_chart_title_haxis_style_get(const Echart_Chart *chart,
+                                                     Echart_Font_Style *fs);
+
+ECH_API void echart_chart_title_vaxis_set(Echart_Chart *chart, const char *title);
+ECH_API const char *echart_chart_title_vaxis_get(const Echart_Chart *chart);
+ECH_API void echart_chart_title_vaxis_style_set(Echart_Chart *chart,
+                                                const Echart_Font_Style *fs);
+ECH_API Eina_Bool echart_chart_title_vaxis_style_get(const Echart_Chart *chart,
+                                                     Echart_Font_Style *fs);
+
+ECH_API void echart_chart_background_color_set(Echart_Chart *chart, unsigned int color);
+ECH_API unsigned int echart_chart_background_color_get(const Echart_Chart *chart);
+
+ECH_API void echart_chart_size_set(Echart_Chart *chart, int width, int height);
+ECH_API void echart_chart_size_get(const Echart_Chart *chart, int *width, int *height);
+
+ECH_API void echart_chart_grid_nbr_set(Echart_Chart *chart, int grid_x_nbr, int grid_y_nbr);
+ECH_API void echart_chart_grid_nbr_get(const Echart_Chart *chart, int *grid_x_nbr, int *grid_y_nbr);
+ECH_API void echart_chart_grid_color_set(Echart_Chart *chart, uint8_t a, uint8_t r, uint8_t g, uint8_t b);
+ECH_API unsigned int echart_chart_grid_color_get(const Echart_Chart *chart);
+ECH_API void echart_chart_sub_grid_nbr_set(Echart_Chart *chart, int grid_x_nbr, int grid_y_nbr);
+ECH_API void echart_chart_sub_grid_nbr_get(const Echart_Chart *chart, int *grid_x_nbr, int *grid_y_nbr);
+ECH_API void echart_chart_sub_grid_color_set(Echart_Chart *chart, uint8_t a, uint8_t r, uint8_t g, uint8_t b);
+ECH_API unsigned int echart_chart_sub_grid_color_get(const Echart_Chart *chart);
+ECH_API void echart_chart_data_set(Echart_Chart *chart, Echart_Data *data);
+ECH_API const Echart_Data *echart_chart_data_get(const Echart_Chart *chart);
+
+#endif
+
+#endif /* ECHART_CHART_H */
diff --git a/src/lib/echart_color.c b/src/lib/echart_color.c
new file mode 100644
index 0000000..329fc79
--- /dev/null
+++ b/src/lib/echart_color.c
@@ -0,0 +1,85 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <config.h>
+
+#include "Echart.h"
+#include "echart_private.h"
+
+/*============================================================================*
+ *                                  Local                                     *
+ *============================================================================*/
+
+static Echart_Color _echart_colors_default[20] =
+{
+   { 0xff3366CC, 0xffc2d1f0 },
+   { 0xffDC3912, 0xfff5c4b8 },
+   { 0xffFF9900, 0xffffe0b3 },
+   { 0xff109618, 0xffb7dfba },
+   { 0xff990099, 0xffe0b3e0 },
+   { 0xff3B3EAC, 0xffb3e0ee },
+   { 0xff0099C6, 0xfff5c7d6 },
+   { 0xffDD4477, 0xffd1e6b3 },
+   { 0xff66AA00, 0xffeac0c0 },
+   { 0xffB82E2E, 0xffc1d0df },
+   { 0xff316395, 0xffe0c7e0 },
+   { 0xff994499, 0xffbde6e0 },
+   { 0xff22AA99, 0xffe6e6b8 },
+   { 0xffAAAA11, 0xffd1c2f0 },
+   { 0xff6633CC, 0xfff7d5b3 },
+   { 0xffE67300, 0xffdcb5b5 },
+   { 0xff8B0707, 0xffd1b7d1 },
+   { 0xff329262, 0xffc2ded0 },
+   { 0xff5574A6, 0xffccd5e4 },
+   { 0xff3B3EAC, 0xffc4c5e6 }
+};
+
+/*============================================================================*
+ *                                 Global                                     *
+ *============================================================================*/
+
+/*============================================================================*
+ *                                   API                                      *
+ *============================================================================*/
+
+ECH_API Echart_Color
+echart_color_get(int i)
+{
+   int nbr;
+
+   if (i < 0)
+   {
+      Echart_Color c = { 0x00000000, 0xffffffff };
+      return c;
+   }
+
+   nbr = (int)(sizeof(_echart_colors_default) / sizeof(Echart_Color));
+
+   return _echart_colors_default[i % nbr];
+}
+
+ECH_API unsigned int
+echart_color_line_get(int i)
+{
+   int nbr;
+
+   if (i < 0)
+      return 0xff000000;
+
+   nbr = (int)(sizeof(_echart_colors_default) / sizeof(Echart_Color));
+   return _echart_colors_default[i % nbr].line;
+}
+
+ECH_API unsigned int
+echart_color_area_get(int i)
+{
+   int nbr;
+
+   if (i < 0)
+      return 0xff000000;
+
+   nbr = (int)(sizeof(_echart_colors_default) / sizeof(Echart_Color));
+   return _echart_colors_default[i % nbr].area;
+}
diff --git a/src/lib/echart_color.h b/src/lib/echart_color.h
new file mode 100644
index 0000000..46a56cb
--- /dev/null
+++ b/src/lib/echart_color.h
@@ -0,0 +1,21 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef ECHART_COLOR_H
+#define ECHART_COLOR_H
+
+typedef struct
+{
+   unsigned int line;
+   unsigned int area;
+} Echart_Color;
+
+ECH_API Echart_Color echart_color_get(int i);
+
+ECH_API unsigned int echart_color_line_get(int i);
+
+ECH_API unsigned int echart_color_area_get(int i);
+
+#endif /* ECHART_COLOR_H */
diff --git a/src/lib/echart_font.h b/src/lib/echart_font.h
new file mode 100644
index 0000000..54c5c97
--- /dev/null
+++ b/src/lib/echart_font.h
@@ -0,0 +1,20 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef ECHART_FONT_H
+#define ECHART_FONT_H
+
+typedef struct
+{
+   char *font_name;
+   int font_size;
+   unsigned int font_color;
+   Eina_Bool bold : 1;
+   Eina_Bool italic : 1;
+} Echart_Font_Style;
+
+
+
+#endif /* ECHART_FONT_H */
diff --git a/src/lib/echart_line.c b/src/lib/echart_line.c
new file mode 100644
index 0000000..8f41cfc
--- /dev/null
+++ b/src/lib/echart_line.c
@@ -0,0 +1,277 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <config.h>
+
+#include "Echart.h"
+#include "echart_private.h"
+
+/*============================================================================*
+ *                                  Local                                     *
+ *============================================================================*/
+
+#define X_VG(x) (w - 1) * ((x) - xmin) / (xmax - xmin)
+#define Y_VG(y) (h - 1) * ((y) - sd->ymin) / (sd->ymax - sd->ymin)
+
+typedef struct Chart_Line Chart_Line;
+
+struct Chart_Line
+{
+   Evas_Object_Smart_Clipped_Data __clipped_data;
+
+   Evas_Object *o_bg;
+   Evas_Object *o_vg;
+   /* Evas_Vg_Node *vg_dot; /\* the dot which appears when mouse is over *\/ */
+
+   /* evas_vg */
+   Evas_Vg_Shape *line;
+
+   /* data */
+   double *data;
+   int num;
+   double ymin;
+   double ymax;
+};
+
+static Evas_Smart *_line_smart = NULL;
+static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
+
+/* Evas_Object smart callbacks */
+
+static void
+_line_smart_add(Evas_Object *obj)
+{
+   Chart_Line *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = calloc(1, sizeof(Chart_Line));
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   sd->o_bg = evas_object_rectangle_add(evas_object_evas_get(obj));
+   evas_object_move(sd->o_bg, 0, 0);
+   sd->o_vg = evas_object_vg_add(evas_object_evas_get(obj));
+
+   /* evas_vg */
+   sd->line = evas_vg_shape_add(sd->o_vg);
+   evas_vg_shape_stroke_width_set(sd->line, 1);
+   evas_vg_shape_stroke_color_set(sd->line, 0, 0, 0, 255);
+
+   evas_object_vg_root_node_set(sd->o_vg, sd->line);
+
+   evas_object_smart_data_set(obj, sd);
+
+   _parent_sc.add(obj);
+}
+
+static void
+_line_smart_del(Evas_Object *obj)
+{
+   Chart_Line *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   _parent_sc.del(obj);
+
+   evas_object_del(sd->o_bg);
+   evas_object_del(sd->o_vg);
+
+   evas_object_smart_data_set(obj, NULL);
+   memset(sd, 0, sizeof(*sd));
+   free(sd);
+}
+
+static void
+_line_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+   Chart_Line *sd;
+   Evas_Coord ox;
+   Evas_Coord oy;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
+   if ((x == ox) && (y == oy))
+      return;
+
+   evas_object_move(sd->o_bg, x, y);
+   evas_object_move(sd->o_vg, x, y);
+
+   evas_object_smart_changed(obj);
+}
+
+static void
+_line_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
+{
+   Chart_Line *sd;
+   Evas_Coord ow;
+   Evas_Coord oh;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
+   if ((w == ow) && (h == oh))
+      return;
+
+   evas_object_resize(sd->o_bg, w, h);
+   evas_object_resize(sd->o_vg, w, h);
+
+   evas_object_smart_changed(obj);
+}
+
+static void
+_line_smart_show(Evas_Object *obj)
+{
+   Chart_Line *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_show(sd->o_bg);
+   evas_object_show(sd->o_vg);
+}
+
+static void
+_line_smart_hide(Evas_Object *obj)
+{
+   Chart_Line *sd;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_hide(sd->o_bg);
+   evas_object_hide(sd->o_vg);
+}
+
+static void
+_line_smart_calculate(Evas_Object *obj)
+{
+   Chart_Line *sd;
+   double *x; /* FIXME */
+   double xmin;
+   double xmax;
+   int w, h;
+
+   INF(" * %s", __FUNCTION__);
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+
+   /* FIXME abscissa */
+   x = malloc(sd->num * sizeof(double));
+   for ( int i = 0; i < sd->num; i++)
+      x[i] =  i;
+   xmin = 0;
+   xmax = sd->num - 1;
+
+   evas_vg_shape_append_move_to(sd->line, X_VG(x[0]), Y_VG(sd->data[0]));
+   for (int i = 1; i < sd->num; i++)
+   {
+      evas_vg_shape_append_line_to(sd->line, X_VG(x[i]), Y_VG(sd->data[i]));
+   }
+}
+
+static void
+_line_smart_init(void)
+{
+   static Evas_Smart_Class sc;
+
+   INF(" * %s", __FUNCTION__);
+
+   evas_object_smart_clipped_smart_set(&_parent_sc);
+   sc           = _parent_sc;
+   sc.name      = "grid";
+   sc.version   = EVAS_SMART_CLASS_VERSION;
+   sc.add       = _line_smart_add;
+   sc.del       = _line_smart_del;
+   sc.move      = _line_smart_move;
+   sc.resize    = _line_smart_resize;
+   sc.show      = _line_smart_show;
+   sc.hide      = _line_smart_hide;
+   sc.calculate = _line_smart_calculate;
+   _line_smart = evas_smart_class_new(&sc);
+}
+
+/*============================================================================*
+ *                                 Global                                     *
+ *============================================================================*/
+
+/*============================================================================*
+ *                                   API                                      *
+ *============================================================================*/
+
+ECH_API Evas_Object *
+echart_line_add(Evas *evas)
+{
+   Evas_Object *obj;
+
+   INF(" * %s", __FUNCTION__);
+
+   if (!_line_smart) _line_smart_init();
+   obj = evas_object_smart_add(evas, _line_smart);
+
+   return obj;
+}
+
+ECH_API void
+echart_line_data_set(Evas_Object *obj, double *data, int num)
+{
+   Chart_Line *sd;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   if (!data || (num <= 0))
+      return;
+
+   sd->data = ""
+   sd->num = num;
+   sd->ymin = sd->data[0];
+   sd->ymax = sd->data[0];
+   for (int i = 1; i < sd->num; i++)
+   {
+      if (sd->data[i] < sd->ymin) sd->ymin = sd->data[i];
+      if (sd->data[i] > sd->ymax) sd->ymax = sd->data[i];
+   }
+
+   evas_object_smart_changed(obj);
+}
+
+ECH_API void
+echart_line_color_set(Evas_Object *obj, int r, int g, int b, int a)
+{
+   Chart_Line *sd;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_vg_shape_stroke_color_set(sd->line, r, g, b, a);
+}
+
+ECH_API void
+echart_line_width_set(Evas_Object *obj, double width)
+{
+   Chart_Line *sd;
+
+   sd = evas_object_smart_data_get(obj);
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+
+   evas_vg_shape_stroke_width_set(sd->line, width);
+}
diff --git a/src/lib/echart_line.h b/src/lib/echart_line.h
new file mode 100644
index 0000000..55e123f
--- /dev/null
+++ b/src/lib/echart_line.h
@@ -0,0 +1,19 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef ECHART_LINE_H
+#define ECHART_LINE_H
+
+#include <Evas.h>
+
+ECH_API Evas_Object *echart_line_add(Evas *evas);
+
+ECH_API void echart_line_data_set(Evas_Object *obj, double *data, int num);
+
+ECH_API void echart_line_color_set(Evas_Object *obj, int r, int g, int b, int a);
+
+ECH_API void echart_line_width_set(Evas_Object *obj, double width);
+
+#endif /* ECHART_LINE_H */
diff --git a/src/lib/echart_main.c b/src/lib/echart_main.c
new file mode 100644
index 0000000..d262815
--- /dev/null
+++ b/src/lib/echart_main.c
@@ -0,0 +1,89 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <config.h>
+
+#include "Echart.h"
+#include "echart_private.h"
+
+/*============================================================================*
+ *                                  Local                                     *
+ *============================================================================*/
+
+static int _echart_init_count = 0;
+
+/*============================================================================*
+ *                                 Global                                     *
+ *============================================================================*/
+
+int echart_log_dom_global = -1;
+
+/*============================================================================*
+ *                                   API                                      *
+ *============================================================================*/
+
+EAPI void
+echart_version(int *vmaj, int *vmin, int *vmic)
+{
+   if (vmaj) *vmaj = PACKAGE_VMAJ;
+   if (vmin) *vmin = PACKAGE_VMIN;
+   if (vmic) *vmic = PACKAGE_VMIC;
+}
+
+EAPI int
+echart_init(void)
+{
+   if (++_echart_init_count != 1)
+      return _echart_init_count;
+
+   if (!eina_init())
+   {
+      fprintf(stderr, "Echart: Could not initialize Eina.\n");
+      return --_echart_init_count;
+   }
+
+   echart_log_dom_global = eina_log_domain_register(PACKAGE_NAME,
+                                                    ECHART_DEFAULT_LOG_COLOR);
+   if (echart_log_dom_global < 0)
+   {
+      EINA_LOG_ERR("Echart: Could not register log domain 'echart'.");
+      goto shutdown_eina;
+   }
+
+   if (!evas_init())
+   {
+      ERR("Could not initialize Evas.");
+      goto unregister_log_domain;
+   }
+
+   return _echart_init_count;
+
+  unregister_log_domain:
+   eina_log_domain_unregister(echart_log_dom_global);
+   echart_log_dom_global = -1;
+  shutdown_eina:
+   eina_shutdown();
+
+   return --_echart_init_count;
+}
+
+EAPI int
+echart_shutdown(void)
+{
+   if (_echart_init_count <= 0)
+   {
+      ERR("Init count not greater than 0 in shutdown.");
+      return 0;
+   }
+   if (--_echart_init_count != 0)
+      return _echart_init_count;
+
+   evas_shutdown();
+   eina_log_domain_unregister(echart_log_dom_global);
+   echart_log_dom_global = -1;
+   eina_shutdown();
+
+   return _echart_init_count;
+}
diff --git a/src/lib/echart_main.h b/src/lib/echart_main.h
new file mode 100644
index 0000000..75c864f
--- /dev/null
+++ b/src/lib/echart_main.h
@@ -0,0 +1,64 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef ECHART_MAIN_H
+#define ECHART_MAIN_H
+
+/**
+ * @file
+ *
+ * @brief The file that provides the init/shutdown functions.
+ *
+ * This header provides the Echart main functions.
+ *
+ */
+
+/**
+ * @brief Retrieve library version.
+ *
+ * @param[out] vmaj Buffer to get major version.
+ * @param[out] vmin Buffer to get minor version.
+ * @param[out] vmic Buffer to get micro version.
+ *
+ * All @p vmaj, @p vmin and @p vmic buffers can be @c NULL.
+ *
+ * To retrieve just the minor version:
+ *
+ * @code
+ * int vmin;
+ * echart_version(NULL, &vmin, NULL);
+ * @endcode
+ */
+ECH_API void echart_version(int *vmaj, int *vmin, int *vmic);
+
+/**
+ * @brief Initializes the Echart library.
+ *
+ * @return The new init count. Will be @c 0 if initialization failed.
+ *
+ * The first time this function is called, it will perform all the internal
+ * initialization required for the library to function properly and increment
+ * the initialization counter. Any subsequent call only increment this counter
+ * and return its new value, so it's safe to call this function more than once.
+ *
+ * @see echart_shutdown()
+ */
+ECH_API int echart_init(void);
+
+/**
+ * @brief Shuts down the Echart library.
+ *
+ * @return The new init count.
+ *
+ * If echart_init() was called more than once for the running application,
+ * echart_shutdown() will decrement the initialization counter and return its
+ * new value, without doing anything else. When the counter reaches 0, all
+ * of the internal elements will be shutdown and any memory used freed.
+ *
+ * @see echart_init()
+ */
+ECH_API int echart_shutdown(void);
+
+#endif
diff --git a/src/lib/echart_private.h b/src/lib/echart_private.h
new file mode 100644
index 0000000..7c68c8c
--- /dev/null
+++ b/src/lib/echart_private.h
@@ -0,0 +1,41 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef ECHART_PRIVATE_H
+#define ECHART_PRIVATE_H
+
+extern int echart_log_dom_global;
+
+#ifdef ECHART_DEFAULT_LOG_COLOR
+# undef ECHART_DEFAULT_LOG_COLOR
+#endif
+#define ECHART_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
+
+#ifdef ERR
+# undef ERR
+#endif
+#define ERR(...)  EINA_LOG_DOM_ERR(echart_log_dom_global, __VA_ARGS__)
+
+#ifdef DBG
+# undef DBG
+#endif
+#define DBG(...)  EINA_LOG_DOM_DBG(echart_log_dom_global, __VA_ARGS__)
+
+#ifdef INF
+# undef INF
+#endif
+#define INF(...)  EINA_LOG_DOM_INFO(echart_log_dom_global, __VA_ARGS__)
+
+#ifdef WRN
+# undef WRN
+#endif
+#define WRN(...)  EINA_LOG_DOM_WARN(echart_log_dom_global, __VA_ARGS__)
+
+#ifdef CRIT
+# undef CRIT
+#endif
+#define CRIT(...) EINA_LOG_DOM_CRIT(echart_log_dom_global, __VA_ARGS__)
+
+#endif
diff --git a/src/lib/meson.build b/src/lib/meson.build
new file mode 100644
index 0000000..4f835b5
--- /dev/null
+++ b/src/lib/meson.build
@@ -0,0 +1,40 @@
+# SPDX-FileCopyrightText: Vincent Torri <[email protected]>
+# SPDX-License-Identifier: BSD-2-Clause
+
+echart_header = files([
+  'Echart.h',
+  'echart_chart.h',
+  'echart_color.h',
+  'echart_main.h',
+  'echart_line.h',
+])
+
+echart_lib_src = files([
+  'echart_chart.c',
+  'echart_color.c',
+  'echart_line.c',
+  'echart_main.c',
+])
+
+config_dir += [ include_directories('.') ]
+
+echart_lib = library('echart', echart_lib_src,
+  c_args : [ echart_cflags, '-DDLL_EXPORT', '-DECHART_BUILD' ],
+  dependencies : echart_deps,
+  gnu_symbol_visibility: 'hidden',
+  include_directories : config_dir,
+  install : true,
+  pic : true,
+  version : meson.project_version()
+)
+
+echart_dep = declare_dependency(
+  compile_args : echart_cflags,
+  include_directories : config_dir,
+  link_with : echart_lib,
+)
+
+install_headers(
+  echart_header,
+  install_dir : dir_pkginclude + '-' + v_maj
+)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to