Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Wie aus einem Array eine Tabelle und Balkengrafik machen?

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Wie aus einem Array eine Tabelle und Balkengrafik machen?

    This topic has been deleted. Only users with topic management privileges can see it.
    • BertDerKleine
      BertDerKleine last edited by

      Zwei Fragen noch:
      Beide beziehen sich auf ein aus dem Netz auslesbaren Datensatz, der ein JSON ausliefert:
      https://api.energy-charts.info/price?bzn=DE-LU
      Im Prinzip handelt es sich einfach um eine "Tabelle" mit zwei Spalten und 24 Zeilen, in der für jeweils eine Stunde ein Preis angegeben ist.

      1. In VIS Tabelle darstellen
        Was wäre der bequemste Weg, um die Daten visuell wirklich als Tabelle darzustellen, am besten von Links nach rechts die Zeiten mit 24 Spalten und zwei zeilen?

      2. In VIS Werte als Balkendiagram darstellen
        Was wäre des beste Weg, wenn ich es nicht als Text in einer Tabelle sehen will, sondern als Grafik mit 24 Balken?

      M 1 Reply Last reply Reply Quote 0
      • M
        MCU @BertDerKleine last edited by MCU

        @bertderkleine Beispiel zu 1)
        History für den verwenten DP anlegen hier:
        cd39ad0b-4f56-43ce-9834-1322c47684fe-image.png

        34d2a701-86b4-4f50-a568-f5180d7c94e8-image.png
        BILD passt nicht zum xml! Im xml ist die history mit eingebaut!

        Muss man dann 1x am Tag laufen lassen. nachts um 02.15 Uhr?

        <block xmlns="https://developers.google.com/blockly/xml" type="http_get" id="WubA_q?t^rOVN1Qzf(Ud" x="113" y="-62">
          <field name="TIMEOUT">2000</field>
          <field name="UNIT">ms</field>
          <field name="TYPE">text</field>
          <value name="URL">
            <shadow type="text" id="4n@aW9Eu_!6v]UX7vbJm">
              <field name="TEXT">https://api.energy-charts.info/price?bzn=DE-LU</field>
            </shadow>
          </value>
          <statement name="STATEMENT">
            <block type="variables_set" id="q(GI;H3H-6Gil%ZUUD`l">
              <field name="VAR" id="s{f!+[6b0uoiRp2^:zs2">dataObj</field>
              <value name="VALUE">
                <block type="convert_json2object" id="/zI_a;?wL~s8b7-7=p^%">
                  <value name="VALUE">
                    <block type="http_response" id="O8b*b@wX2,l!5gn1vi@8">
                      <field name="ATTR">response.data</field>
                    </block>
                  </value>
                </block>
              </value>
              <next>
                <block type="variables_set" id="pP_KB8dY8EAJ6}SH|N!^">
                  <field name="VAR" id="hw`M0@4ZK75sNU-wQ2mf">hours</field>
                  <value name="VALUE">
                    <block type="convert_jsonata" id="9f:nExdLo|@_S*bTX%jU">
                      <value name="EXPRESSION">
                        <shadow type="text" id="T{/k0+_i)?BrRa+ctWj9">
                          <field name="TEXT">unix_seconds</field>
                        </shadow>
                      </value>
                      <value name="TARGET">
                        <block type="variables_get" id="`wjbX)ltT92Z|_L]jG?^">
                          <field name="VAR" id="s{f!+[6b0uoiRp2^:zs2">dataObj</field>
                        </block>
                      </value>
                    </block>
                  </value>
                  <next>
                    <block type="variables_set" id="#H~JJ{T%hi(L,{bVPy2m">
                      <field name="VAR" id="}FsWP+@#u}VQ4b8/)[:2">prices</field>
                      <value name="VALUE">
                        <block type="convert_jsonata" id="+%.|9$bdl_L,c;*u*Z]B">
                          <value name="EXPRESSION">
                            <shadow type="text" id="ahs)t9X?Lc2;)Lf%:9rC">
                              <field name="TEXT">price</field>
                            </shadow>
                          </value>
                          <value name="TARGET">
                            <block type="variables_get" id="p![zq{K(pdd4RjP-I_$r">
                              <field name="VAR" id="s{f!+[6b0uoiRp2^:zs2">dataObj</field>
                            </block>
                          </value>
                        </block>
                      </value>
                      <next>
                        <block type="variables_set" id="Ufji]:CBub6Yx.p`pN]f">
                          <field name="VAR" id="-~EO+XWJ9wY?!@R]0*O0">jsonArr</field>
                          <value name="VALUE">
                            <block type="lists_create_with" id="sC8Q#FVhcGi4,I7=}+E+">
                              <mutation items="0"></mutation>
                            </block>
                          </value>
                          <next>
                            <block type="controls_forEach" id="n26vmw#_)b5{trnAGfc7">
                              <field name="VAR" id="=Qe9w_-NZI=gDuyX-(P5">i</field>
                              <value name="LIST">
                                <block type="variables_get" id="sm~GA,g2oL+3!l9jYTl5">
                                  <field name="VAR" id="hw`M0@4ZK75sNU-wQ2mf">hours</field>
                                </block>
                              </value>
                              <statement name="DO">
                                <block type="variables_set" id="5}~g_j@kMkiDr0]9HKsW">
                                  <field name="VAR" id="p7{GR]:*s^iRm(nY{IvA">jsonObj</field>
                                  <value name="VALUE">
                                    <block type="object_new" id="ISQw{,1JAT4![hq_-M=m"></block>
                                  </value>
                                  <next>
                                    <block type="object_set_attr" id=";Gya@c}:d(ZAI`A%-jC+">
                                      <field name="ATTR">time</field>
                                      <value name="OBJECT">
                                        <block type="variables_get" id="9Mz7qy+`}dhOQzk7#[g#">
                                          <field name="VAR" id="p7{GR]:*s^iRm(nY{IvA">jsonObj</field>
                                        </block>
                                      </value>
                                      <value name="VALUE">
                                        <shadow type="text" id=")(n@S]MtpbL2|Sinc,X7">
                                          <field name="TEXT">value</field>
                                        </shadow>
                                        <block type="convert_from_date" id="Rfw_YWIq_Gw_qVT!BMzK">
                                          <mutation xmlns="http://www.w3.org/1999/xhtml" format="true" language="false"></mutation>
                                          <field name="OPTION">custom</field>
                                          <field name="FORMAT">JJJJ.MM.TT SS:mm</field>
                                          <value name="VALUE">
                                            <block type="math_arithmetic" id="gP9fa|N|L-pF(vr])T.)">
                                              <field name="OP">MULTIPLY</field>
                                              <value name="A">
                                                <shadow type="math_number" id="z-jQmlOX2PAXg4RGdxz%">
                                                  <field name="NUM">1</field>
                                                </shadow>
                                                <block type="variables_get" id="DiGj~c~W_f0}BIMRilb}">
                                                  <field name="VAR" id="=Qe9w_-NZI=gDuyX-(P5">i</field>
                                                </block>
                                              </value>
                                              <value name="B">
                                                <shadow type="math_number" id="K[q*QXm49MYKtM=^3Bc#">
                                                  <field name="NUM">1000</field>
                                                </shadow>
                                              </value>
                                            </block>
                                          </value>
                                        </block>
                                      </value>
                                      <next>
                                        <block type="variables_set" id="WoCf2a]I:C!mMl]5db$8">
                                          <field name="VAR" id="7yD2B-Fh1eiNM4@%(o#L">index</field>
                                          <value name="VALUE">
                                            <block type="lists_indexOf" id="mi8o*!].|#Mra~*L42pS">
                                              <field name="END">FIRST</field>
                                              <value name="VALUE">
                                                <block type="variables_get" id="TMcw]-Im7Qc`b]%S[TtL">
                                                  <field name="VAR" id="hw`M0@4ZK75sNU-wQ2mf">hours</field>
                                                </block>
                                              </value>
                                              <value name="FIND">
                                                <block type="variables_get" id="7/mmHa?[x:#!1xS$g{fZ">
                                                  <field name="VAR" id="=Qe9w_-NZI=gDuyX-(P5">i</field>
                                                </block>
                                              </value>
                                            </block>
                                          </value>
                                          <next>
                                            <block type="object_set_attr" id="GJ|V8v!Z:d)lU4YMK?+.">
                                              <field name="ATTR">price</field>
                                              <value name="OBJECT">
                                                <block type="variables_get" id="Y?qxVFM~FfK(%rJfZ8?4">
                                                  <field name="VAR" id="p7{GR]:*s^iRm(nY{IvA">jsonObj</field>
                                                </block>
                                              </value>
                                              <value name="VALUE">
                                                <shadow type="text" id=")(n@S]MtpbL2|Sinc,X7">
                                                  <field name="TEXT">value</field>
                                                </shadow>
                                                <block type="lists_getIndex" id="_vy%IV*TmroOP-ingTl]">
                                                  <mutation statement="false" at="true"></mutation>
                                                  <field name="MODE">GET</field>
                                                  <field name="WHERE">FROM_START</field>
                                                  <value name="VALUE">
                                                    <block type="variables_get" id="Y$l|0JcFGeGyvVuRM/WA">
                                                      <field name="VAR" id="}FsWP+@#u}VQ4b8/)[:2">prices</field>
                                                    </block>
                                                  </value>
                                                  <value name="AT">
                                                    <block type="variables_get" id="wp^p=VsN6+N$7=sU3rw1">
                                                      <field name="VAR" id="7yD2B-Fh1eiNM4@%(o#L">index</field>
                                                    </block>
                                                  </value>
                                                </block>
                                              </value>
                                              <next>
                                                <block type="debug" id="1fXlv.R`oXW1BIX)M;*." disabled-reasons="MANUALLY_DISABLED">
                                                  <field name="Severity">info</field>
                                                  <value name="TEXT">
                                                    <shadow type="text" id="#pSP=w|D(c$3Bc9eebs6">
                                                      <field name="TEXT">test</field>
                                                    </shadow>
                                                    <block type="variables_get" id="4SW_o82zc$9Q_[Vb+B%~">
                                                      <field name="VAR" id="p7{GR]:*s^iRm(nY{IvA">jsonObj</field>
                                                    </block>
                                                  </value>
                                                  <next>
                                                    <block type="variables_set" id="a.c=E|.h$wUjC.J^}7Z$">
                                                      <field name="VAR" id="jfV6^g`UsKLujK;PHL/W">stateObj</field>
                                                      <value name="VALUE">
                                                        <block type="object_new" id="N;!Ww6QA@n%g?w^F^}-L"></block>
                                                      </value>
                                                      <next>
                                                        <block type="object_set_attr" id=",%tBt=kGnMNY|bp_!kh7">
                                                          <field name="ATTR">ts</field>
                                                          <value name="OBJECT">
                                                            <block type="variables_get" id="1DJ?Qi*+VLV^un;Eu={W">
                                                              <field name="VAR" id="jfV6^g`UsKLujK;PHL/W">stateObj</field>
                                                            </block>
                                                          </value>
                                                          <value name="VALUE">
                                                            <shadow type="text" id="XzylIx4bS8xB.XgY_Kt(">
                                                              <field name="TEXT">value</field>
                                                            </shadow>
                                                            <block type="math_arithmetic" id="8wgh#GuDMg1WU2bOTpoP">
                                                              <field name="OP">MULTIPLY</field>
                                                              <value name="A">
                                                                <shadow type="math_number" id="z-jQmlOX2PAXg4RGdxz%">
                                                                  <field name="NUM">1</field>
                                                                </shadow>
                                                                <block type="variables_get" id="ojk6B+s6pV1T?#1X)0Os">
                                                                  <field name="VAR" id="=Qe9w_-NZI=gDuyX-(P5">i</field>
                                                                </block>
                                                              </value>
                                                              <value name="B">
                                                                <shadow type="math_number" id="8ARPoQj#;4K44B)#)Bou">
                                                                  <field name="NUM">1000</field>
                                                                </shadow>
                                                              </value>
                                                            </block>
                                                          </value>
                                                          <next>
                                                            <block type="object_set_attr" id=")U%21t7I9U*(c__RNT[=">
                                                              <field name="ATTR">val</field>
                                                              <value name="OBJECT">
                                                                <block type="variables_get" id="3X5P!lZ1|t8kLnwg,w4^">
                                                                  <field name="VAR" id="jfV6^g`UsKLujK;PHL/W">stateObj</field>
                                                                </block>
                                                              </value>
                                                              <value name="VALUE">
                                                                <shadow type="text" id="XzylIx4bS8xB.XgY_Kt(">
                                                                  <field name="TEXT">value</field>
                                                                </shadow>
                                                                <block type="lists_getIndex" id="S-Qly;Ry*Nc{Q2UX*?RZ">
                                                                  <mutation statement="false" at="true"></mutation>
                                                                  <field name="MODE">GET</field>
                                                                  <field name="WHERE">FROM_START</field>
                                                                  <value name="VALUE">
                                                                    <block type="variables_get" id="oj7h_e5hu)XV!1.oT=4d">
                                                                      <field name="VAR" id="}FsWP+@#u}VQ4b8/)[:2">prices</field>
                                                                    </block>
                                                                  </value>
                                                                  <value name="AT">
                                                                    <block type="variables_get" id="`^l(!S1VHNq1SK/bL=u$">
                                                                      <field name="VAR" id="7yD2B-Fh1eiNM4@%(o#L">index</field>
                                                                    </block>
                                                                  </value>
                                                                </block>
                                                              </value>
                                                              <next>
                                                                <block type="sendto_custom" id="0FheG9#v?h8VK`A4gi8l">
                                                                  <mutation xmlns="http://www.w3.org/1999/xhtml" items="id,state"></mutation>
                                                                  <field name="INSTANCE">history.0</field>
                                                                  <field name="COMMAND">storeState</field>
                                                                  <field name="LOG"></field>
                                                                  <field name="WITH_STATEMENT">FALSE</field>
                                                                  <value name="ARG0">
                                                                    <shadow type="text" id="2S33q,Osc00],b?TvJ!_">
                                                                      <field name="TEXT">0_userdata.0.TEST.Liste</field>
                                                                    </shadow>
                                                                  </value>
                                                                  <value name="ARG1">
                                                                    <shadow type="text" id="m4yjk`fQkP^ktB27|_=f">
                                                                      <field name="TEXT"></field>
                                                                    </shadow>
                                                                    <block type="variables_get" id="4z2RRH(}DDHVe?citK`9">
                                                                      <field name="VAR" id="jfV6^g`UsKLujK;PHL/W">stateObj</field>
                                                                    </block>
                                                                  </value>
                                                                  <next>
                                                                    <block type="lists_setIndex" id="`DNvt75jK}w1q{:maX][">
                                                                      <mutation at="false"></mutation>
                                                                      <field name="MODE">INSERT</field>
                                                                      <field name="WHERE">LAST</field>
                                                                      <value name="LIST">
                                                                        <block type="variables_get" id="L0}f1xt(EQPGbUL,PQz=">
                                                                          <field name="VAR" id="-~EO+XWJ9wY?!@R]0*O0">jsonArr</field>
                                                                        </block>
                                                                      </value>
                                                                      <value name="TO">
                                                                        <block type="variables_get" id="fC%H$s`7M:IlEv`tip?7">
                                                                          <field name="VAR" id="p7{GR]:*s^iRm(nY{IvA">jsonObj</field>
                                                                        </block>
                                                                      </value>
                                                                    </block>
                                                                  </next>
                                                                </block>
                                                              </next>
                                                            </block>
                                                          </next>
                                                        </block>
                                                      </next>
                                                    </block>
                                                  </next>
                                                </block>
                                              </next>
                                            </block>
                                          </next>
                                        </block>
                                      </next>
                                    </block>
                                  </next>
                                </block>
                              </statement>
                              <next>
                                <block type="debug" id="K_qdH~gw%dG#qfG;5xJw" disabled-reasons="MANUALLY_DISABLED">
                                  <field name="Severity">info</field>
                                  <value name="TEXT">
                                    <shadow type="text" id="w8H|}@7vFQ3~Hef1#s+{">
                                      <field name="TEXT">test</field>
                                    </shadow>
                                    <block type="variables_get" id="u`_,D/K8E5enHcI3PWn$">
                                      <field name="VAR" id="-~EO+XWJ9wY?!@R]0*O0">jsonArr</field>
                                    </block>
                                  </value>
                                  <next>
                                    <block type="control" id="mc%$a]6G7qobV=)]SDR(" disabled-reasons="MANUALLY_DISABLED">
                                      <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                      <field name="OID">0_userdata.0.TEST.Liste</field>
                                      <field name="WITH_DELAY">FALSE</field>
                                      <value name="VALUE">
                                        <block type="convert_object2json" id="e4;%Ua.FJ-=H8@|[!9iV">
                                          <field name="PRETTIFY">FALSE</field>
                                          <value name="VALUE">
                                            <block type="variables_get" id="`!a!zwUKn4!huvf9i/I(">
                                              <field name="VAR" id="-~EO+XWJ9wY?!@R]0*O0">jsonArr</field>
                                            </block>
                                          </value>
                                        </block>
                                      </value>
                                    </block>
                                  </next>
                                </block>
                              </next>
                            </block>
                          </next>
                        </block>
                      </next>
                    </block>
                  </next>
                </block>
              </next>
            </block>
          </statement>
        </block>
        

        zu 2)
        evtl legt man auch ein Preset in echarts an und wählt bar als Kurvenform aus.
        14fbc3a2-52b0-4cc2-b7c2-ecc8ea0ac674-image.png

        echarts Widget (VIS 2)
        38377e5d-4c83-46fe-853b-da66070108ea-image.png
        Bar scheint dort nicht zu funktionieren?
        b93fc7e2-83e3-490e-8c9a-d891206398b7-image.png

        EDIT: Die Werte werden nicht um 00:00 aktualisiert? Auch um 01:00 keine neue Daten!
        Man muss die Zeit (start, end) mitgeben damit man die Werte erhält.

        paul53 1 Reply Last reply Reply Quote 2
        • paul53
          paul53 @MCU last edited by paul53

          @mcu sagte: history mit eingebaut!

          Man kann an History auch ein Array of states übergeben; etwa so:

          Blockly_temp.JPG

          Anmerkung: Wenn man die Elemente aus korrespondieren Listen auswertet, ist die for-Schleife besser geeignet.

          BertDerKleine 1 Reply Last reply Reply Quote 3
          • BertDerKleine
            BertDerKleine @paul53 last edited by

            @paul53
            @MCU
            Danke!, Muss ich mir anschauen und mal durchdenken.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Support us

            ioBroker
            Community Adapters
            Donate

            501
            Online

            31.9k
            Users

            80.2k
            Topics

            1.3m
            Posts

            3
            4
            150
            Loading More Posts
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes
            Reply
            • Reply as topic
            Log in to reply
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
            The ioBroker Community 2014-2023
            logo