Scrounger / ioBroker.vis-materialdesign

ioBroker Material Design Widgets are based on Google's material design guidelines. The adapter uses different libraries.
https://forum.iobroker.net/topic/42185/test-adapter-material-design-widgets-v0-5-x
MIT License
59 stars 38 forks source link

[JSON Chart]: datalabel_override does not work #152

Closed Kazuyakisho closed 3 years ago

Kazuyakisho commented 3 years ago

It seems that the datalabel override doesn't work in JSON Chart or I misunterstood that.

To reproduce, try overriding [line, bar]chart data labels with datalabel_override: array[string] (like in documentation)

What I wanted to try is replacing the datalabels (are for the correct calculation of points I guess) with own datalabels: As an example I want to have an empty string if datalabel equals '0'.

 graphs.push(
    {
      data: sqlDurationSec.map(total => mapSecToDecSeconds(total)), <--- length = 7
      type: 'line',
      color: '#44739e',
      legendText: 'Gesamt',
      line_pointSizeHover: 5,
      line_pointSize: 3,
      line_Tension: 0.1,     
      yAxis_show: true,
      yAxis_gridLines_show: false,
      yAxis_gridLines_ticks_length: 5,
      yAxis_position: 'right',
      yAxis_appendix: ' h',
      yAxis_zeroLineWidth: 0.1,
      yAxis_zeroLineColor: 'black',
      yAxis_id: 0,
      yAxis_min: 0,
      yAxis_max: 15,
      yAxis_maxSteps: 10,
      barIsStacked: true,     
      displayOrder: 0,
      yAxis_title_text: 'Gesamtstunden',
      tooltip_AppendText: ' h',
      tooltip_MinDigits: 2,
      datalabel_backgroundColor: '',
      datalabel_color: '#44739e',
      datalabel_offset: -30,
      datalabel_fontFamily: 'RobotoCondensed-Medium',
      datalabel_fontSize: 10,
      datalabel_borderRadius: 6,
      datalabel_override: ['T','E','S','T','I','N','G'], <--- TEST with strings doesnt work 
      use_gradient_color: true,
      gradient_color: color_graph_all_verlauf,
      use_line_gradient_fill_color: true,
      line_gradient_fill_color: getGradientColors(5,20,color_graph_all_verlauf ).getGradientWithOpacity(40),
     }

If it works on your site, than maybe I have error in my code. KR

Scrounger commented 3 years ago

Please test the current github version, i made a bug fix

Kazuyakisho commented 3 years ago

Really good. Very fast and it works.

Thank you very much. Top. :)

Kazuyakisho commented 3 years ago

That was a little bit to hasty. :)

There is another problem. The chart is hanging respectively it can not be updated automatically while the data labels has been overwritten.

Scrounger commented 3 years ago

Can't repoduce this. Need more detailed informations.

Activate the debug mode (common -> debug), reload the runtime (F5), wait for change or trigger change of the json data manual. After this copy the complete consolen log (F12, mode debug!) and paste it here.

Additional i need the json string before and after updating the data.

Kazuyakisho commented 3 years ago

Graphs: graphs

Console Log: console.log

After the error "Uncaught TypeError: Cannot read property 'call' of undefined in lib.min.js:4 comes up, the charts are no longer willing to update. That is happen while hovering over the overrided data labels. And after reload will F5 it is working normally. See in Video:

here a little video - rename the file to error.webm error.zip

JSON Strings: JSON Strings.txt

Scrounger commented 3 years ago

Wie wäre es mit ner anderen Sprache ;-)

Ok der Fehler kommt vom Tooltip. Bitte teste nochmal folgendes:

Kazuyakisho commented 3 years ago

Na dann machen wir dit so. :D

Jap, Tooltip öffnet nicht. Und zudem interessant: Die Fehlermeldung kommt ÜBERALL wo ein Tooltip erwartet wird (CHART 1). Ich habe die Datalabels auch nur im LINE-Chart überschrieben und der Fehler wird überall geworfen, ob ich nun initial auf eine der BARS gehe oder auf LINE.

CHART 2 (ohne datalabe_overrides). Reagiert dann ebenfalls nicht auf Updates aber schmeißt auch keine Fehler.

Und vielleicht habe ich es auch vorher übersehen, aber hier kommt jetzt noch nen Array Error lib.min.js:4 Uncaught TypeError: Cannot read property 'length' of undefined Hier nochmal die Log. error.log

Scrounger commented 3 years ago

Teste bitte die aktuelle version von github. Upload vis adapter nicht vergessen.

Kazuyakisho commented 3 years ago

Hi. Jetzt musste ich erstmal nachschlagen, was du mit Upload VIS adapter meinst. oO

Habe VIS upgeloaded und die aktuelleste Version geladen, aber leider kein Erfolg oder ich mache irgendwas falsch. Adapter -> GitHub -> vis-materialdesign auswählen ... dann wird dieses Kommando ausgeführt. ./iobroker url "https://github.com/Scrounger/ioBroker.vis-materialdesign/tarball/master" vis-materialdesign Ist doch richtig oder?

Screenshot from 2021-03-11 13-09-48

Scrounger commented 3 years ago

Habe VIS upgeloaded und die aktuelleste Version geladen, aber leider kein Erfolg oder ich mache irgendwas falsch. Adapter -> GitHub -> vis-materialdesign auswählen ... dann wird dieses Kommando ausgeführt. ./iobroker url "https://github.com/Scrounger/ioBroker.vis-materialdesign/tarball/master" vis-materialdesign Ist doch richtig oder?

Ja korrekt. VIS Adapter upload geht so: upload

Bist du dir sicher das dein Skript nicht irgendwas falsch macht. Ich kann das nicht reproduzieren und hab es mit deinem json getestet, funktioniert einwandfrei.

Schalt nochmal den debug modus an, runtime neu laden, chart updaten und dann das ganze log posten

Kazuyakisho commented 3 years ago

Hääää. Nanu. Es läuft jetzt. Ich habe den debug modus erstmal ausgestellt und TADA es geht. Wenn ich den Debug Modus jetzt wieder einschalte geht's auch. Top.

Aber überhaupt mal ein riesen Danke schön. Es ist echt schnike, was du da hingezimmert hast. :+1: :+1: :+1: Na dann gebe ich dir mal nen Kaffee aus ;)

Kazuyakisho commented 3 years ago

Jup. Läuft alles perfekt. Dann schließe ick mal das Ticket.

Scrounger commented 3 years ago

Hääää. Nanu. Es läuft jetzt.

Ok komisch, aber wenns läuft dann läufts 😁

Aber überhaupt mal ein riesen Danke schön. Es ist echt schnike, was du da hingezimmert hast. 👍 👍 👍 Na dann gebe ich dir mal nen Kaffee aus ;)

Danke, Kaffee werd ich mir schmecken lassen!