diff --git a/src/others/xml/lv_xml_base_types.c b/src/others/xml/lv_xml_base_types.c
index 11f52dd9bc..389a01e474 100644
--- a/src/others/xml/lv_xml_base_types.c
+++ b/src/others/xml/lv_xml_base_types.c
@@ -91,6 +91,8 @@ lv_dir_t lv_xml_dir_to_enum(const char * txt)
if(lv_streq("bottom", txt)) return LV_DIR_BOTTOM;
if(lv_streq("left", txt)) return LV_DIR_LEFT;
if(lv_streq("right", txt)) return LV_DIR_RIGHT;
+ if(lv_streq("hor", txt)) return LV_DIR_HOR;
+ if(lv_streq("ver", txt)) return LV_DIR_VER;
if(lv_streq("all", txt)) return LV_DIR_ALL;
LV_LOG_WARN("%s is an unknown value for dir", txt);
diff --git a/src/others/xml/parsers/lv_xml_chart_parser.c b/src/others/xml/parsers/lv_xml_chart_parser.c
index e368b8ac63..0b06892dc0 100644
--- a/src/others/xml/parsers/lv_xml_chart_parser.c
+++ b/src/others/xml/parsers/lv_xml_chart_parser.c
@@ -114,6 +114,9 @@ void * lv_xml_chart_cursor_create(lv_xml_parser_state_t * state, const char ** a
{
const char * color = lv_xml_get_value_of(attrs, "color");
const char * dir = lv_xml_get_value_of(attrs, "dir");
+ if(color == NULL) color = "0x0000ff";
+ if(dir == NULL) dir = "all";
+
void * item = lv_chart_add_cursor(lv_xml_state_get_parent(state), lv_color_hex(lv_xml_strtol(color, NULL, 16)),
lv_xml_dir_to_enum(dir));
@@ -132,13 +135,8 @@ void lv_xml_chart_cursor_apply(lv_xml_parser_state_t * state, const char ** attr
const char * name = attrs[i];
const char * value = attrs[i + 1];
-
- if(lv_streq("pos", name)) {
- int32_t x = lv_xml_atoi_split(&value, ' ');
- int32_t y = lv_xml_atoi_split(&value, ' ');
- lv_point_t p = {x, y};
- lv_chart_set_cursor_pos(chart, cursor, &p);
- }
+ if(lv_streq("pos_x", name)) lv_chart_set_cursor_pos_x(chart, cursor, lv_xml_atoi(value));
+ if(lv_streq("pos_y", name)) lv_chart_set_cursor_pos_y(chart, cursor, lv_xml_atoi(value));
}
}
@@ -147,7 +145,7 @@ void * lv_xml_chart_axis_create(lv_xml_parser_state_t * state, const char ** att
LV_UNUSED(attrs);
/*Nothing to create*/
- return lv_xml_state_get_parent(state);;
+ return lv_xml_state_get_parent(state);
}
void lv_xml_chart_axis_apply(lv_xml_parser_state_t * state, const char ** attrs)
diff --git a/src/widgets/chart/lv_chart.c b/src/widgets/chart/lv_chart.c
index 458e459c90..70639242cd 100644
--- a/src/widgets/chart/lv_chart.c
+++ b/src/widgets/chart/lv_chart.c
@@ -455,6 +455,26 @@ void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_po
lv_chart_refresh(chart);
}
+void lv_chart_set_cursor_pos_x(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t x)
+{
+ LV_ASSERT_NULL(cursor);
+ LV_UNUSED(chart);
+
+ cursor->pos.x = x;
+ cursor->pos_set = 1;
+ lv_chart_refresh(chart);
+}
+
+void lv_chart_set_cursor_pos_y(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t y)
+{
+ LV_ASSERT_NULL(cursor);
+ LV_UNUSED(chart);
+
+ cursor->pos.y = y;
+ cursor->pos_set = 1;
+ lv_chart_refresh(chart);
+}
+
void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_chart_series_t * ser, uint32_t point_id)
{
LV_ASSERT_NULL(cursor);
diff --git a/src/widgets/chart/lv_chart.h b/src/widgets/chart/lv_chart.h
index 1a154850a5..3f5dc3a710 100644
--- a/src/widgets/chart/lv_chart.h
+++ b/src/widgets/chart/lv_chart.h
@@ -228,6 +228,22 @@ lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * obj, lv_color_t color, lv_di
*/
void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_point_t * pos);
+/**
+ * Set the X coordinate of the cursor with respect to the paddings
+ * @param chart pointer to a chart object
+ * @param cursor pointer to the cursor
+ * @param x the new X coordinate of cursor relative to the chart
+ */
+void lv_chart_set_cursor_pos_x(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t x);
+
+/**
+ * Set the coordinate of the cursor with respect to the paddings
+ * @param chart pointer to a chart object
+ * @param cursor pointer to the cursor
+ * @param y the new Y coordinate of cursor relative to the chart
+ */
+void lv_chart_set_cursor_pos_y(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t y);
+
/**
* Stick the cursor to a point
* @param chart pointer to a chart object
diff --git a/xmls/globals.xml b/xmls/globals.xml
index 9e51c06ae0..fc39d78956 100644
--- a/xmls/globals.xml
+++ b/xmls/globals.xml
@@ -43,6 +43,9 @@
+
+
+
diff --git a/xmls/lv_chart.xml b/xmls/lv_chart.xml
index eb34ed0f6b..1eec502ef1 100644
--- a/xmls/lv_chart.xml
+++ b/xmls/lv_chart.xml
@@ -50,9 +50,8 @@
-
-
-
+
+