Pico Nano
Posts: 8
Joined: Tue Apr 05, 2022 12:15 pm

How do I send one integer to a chart when I want?

Sun Oct 01, 2023 4:45 pm

Hi,
I am stuck because I don't know how exactly everything works.
I want to send a 32 integer to be charted every minute by the ESP32's timer interrupt.
I don't have and array, or a complicated structure, just a lonely word!
On the ESP32 side I have;

Code: Select all

/
***** Declrations
JSONVar readings;
AsyncWebServer server(80);
AsyncEventSource events("/events");
AsyncWebSocket ws("/ws");

/****
String getTicks(){
  readings["ticks"] = String(Ticks);
  String jsonString = JSON.stringify(readings);
  return jsonString;
}
void initWebSocket() {
  ws.onEvent(onEvent);
  server.addHandler(&ws);
}
// Get Ticks and return JSON object
String getTicks(){
  readings["ticks"] = String(Ticks);
  String jsonString = JSON.stringify(readings);
  return jsonString;
}
/************ under setup
  // Request for the latest sensor readings
  server.on("/ticks", HTTP_GET, [](AsyncWebServerRequest *request){
    String json = getTicks();
    request->send(200, "application/json", json);
    json = String();
  });
  server.addHandler(&events);
  AsyncElegantOTA.begin(&server);
  server.begin();
}
/****From inside the loop

Code: Select all

events.send(String(Ticks).c_str(),"ticks",millis());
X-axis will be date().
I need someone to show me how I can send an integer to a highchart to be displayed as bar graph. I can find a few examples that use an array and deal with Json, but it shouldn't be that evolved.
I don't have enough understanding to decipher the online "manual", with no real examples.
Thanks.

jakub.j
Posts: 866
Joined: Tue Jan 24, 2023 11:14 am

Re: How do I send one integer to a chart when I want?

Tue Oct 03, 2023 6:44 am

Thanks for contacting us with your question!

There are multiple ways to provide data to a bar chart. All of them are listed here: https://api.highcharts.com/highcharts/series.bar.data

I'm not sure, how does your data look like. Please send me a real sample of the data, that you receive from the server.
Than, based on that, I will be able to help you transform it into Highcharts like data format, that will allow you to draw a bar chart.

Best regards
Jakub
Jakub
Highcharts Developer

Return to “Highcharts Usage”