I have problems with the scaling of the chart. I have float values that represent € in the range 0,00 to 5,00€ or 6,00 €. I want to put these values in a chart. I multiply the float value by 100 and have the values in cents and the display works. But the Y axis should not be in cents but in €. Can I label one of the Y axes differently? I also determine the maximum value from the data series and set the maximum Y value to be able to display the values well. How can I label the Y axis better?
Anyone an idea?
Hi @werde45, did my post help in any way?
Hi.
yes and now. I understand all your explantions, but im new to C and i never used callbacks. I also skale my chart on maximum values, but today i dont know what to do…
// set bars from statistics
void initStaticsBars() {
debugPrintln("Set statistics");
lv_chart_series_t *ui_chartStatisticWeek_series_1 = lv_chart_add_series(ui_chartStatisticWeek, lv_color_hex(0x044A1F), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_set_ext_y_array(ui_chartStatisticWeek, ui_chartStatisticWeek_series_1, statistics);
}
void setMaxChart() {
// find maximum value from statistics
long maxValueChart = statistics[0];
for (int i = 1; i < statisticaAraySize; i++) {
if (statistics[i] > maxValueChart) {
maxValueChart = statistics[i]; // if element is bigger, set new value as max
}
}
maxValueChart += 10;
debugPrint("maximum value for chart:");
debugPrintln(maxValueChart);
lv_chart_set_range(ui_chartStatisticWeek, LV_CHART_AXIS_PRIMARY_Y, 0, maxValueChart); //set maximum in chart
lv_chart_set_range(ui_chartStatisticWeek, LV_CHART_AXIS_SECONDARY_Y, 0, maxValueChart); //set maximum in chart
}