https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • a

    ambitious-knife-25690

    01/20/2023, 6:35 PM
    is the chart completely hand coded then?
  • h

    happy-agent-4114

    01/20/2023, 6:36 PM
    I stole the right click menu code almost verbatim from the components example site
  • h

    happy-agent-4114

    01/20/2023, 6:36 PM
    Sorta
  • h

    happy-agent-4114

    01/20/2023, 6:36 PM
    it uses chart.js, the backend is node
  • a

    ambitious-knife-25690

    01/20/2023, 6:37 PM
    ahh
  • h

    happy-agent-4114

    01/20/2023, 6:37 PM
    it just took me 221 lines of code to pull database numbers and put them into that chart
  • h

    happy-agent-4114

    01/20/2023, 6:37 PM
    but the way I actually load it is neat
  • h

    happy-agent-4114

    01/20/2023, 6:37 PM
    here's basically every important part:
  • h

    happy-agent-4114

    01/20/2023, 6:38 PM
    Copy code
    hx
    
        //the fun part
        private function loadGraph(graphParams:GraphParams, srvURL:String = "10.65.100.21:8080"):String {
            //unitString is just a stringified list of units
            //which would be easy but I made the units an enum so I could type it stricter
            var unitString:String = Json.stringify([for (unit in graphParams.units) unitNames[EnumValueTools.getIndex(unit)]]);
            //same with yparams
            var yparamString:String = Json.stringify([for (param in graphParams.params) EnumValueTools.getName(param)]);
            //daterange is formatted as YYYYMMDDHHMMYYYYMMDDHHMM which isn't hard to read or understand at all why would you say that
            var dateRange = '${DateTools.format(graphParams.dateStart, '%Y%m%d%H%M')}${DateTools.format(graphParams.dateEnd, "%Y%m%d%H%M")}';
            //parameterize!
            var imgURL:String = 'http://$srvURL/dynamic/chart.jpg?DL=true&units=$unitString&yparams=$yparamString&daterange=$dateRange&sizeX=${graphParams.width}&sizeY=${graphParams.height}';
    
            //reload the graph display
            graphDisplay.resource = imgURL;
            //also return the url in case I want that
            //(i do in exactly one place)
            return imgURL;
        }
  • h

    happy-agent-4114

    01/20/2023, 6:40 PM
    Units is an enum of unit names, params is an enum of parameters
  • a

    ambitious-knife-25690

    01/20/2023, 6:42 PM
    I believe you can serialise a haxe enum so you wouldn't need the name parsing
  • h

    happy-agent-4114

    01/20/2023, 6:43 PM
    I need the name parsing because the unit names on the backend aren't the same as on the frontend
  • h

    happy-agent-4114

    01/20/2023, 6:43 PM
    it's the problem with running db queries on backend
  • h

    happy-agent-4114

    01/20/2023, 6:44 PM
    but yes you can serialize an enum with EnumValueTools.getName
  • h

    happy-agent-4114

    01/20/2023, 6:44 PM
    which I do for the parameters
  • a

    ambitious-knife-25690

    01/20/2023, 6:45 PM
    ahhhh
  • h

    happy-agent-4114

    01/20/2023, 6:45 PM
    also I just realized how important I'm making myself at this company
  • h

    happy-agent-4114

    01/20/2023, 6:45 PM
    nobody knows haxe but me
  • h

    happy-agent-4114

    01/20/2023, 6:45 PM
    oops
  • a

    ambitious-knife-25690

    01/20/2023, 6:46 PM
    😄
  • r

    refined-laptop-39041

    01/20/2023, 6:59 PM
    Kinda random, but I wonder what is faster: string formatting using ``$var`` or StringBuf
  • r

    refined-laptop-39041

    01/20/2023, 6:59 PM
    If it is the latter, maybe it would be better to make a ``getImgURL()`` function seperate
  • r

    refined-laptop-39041

    01/20/2023, 6:59 PM
    Might make the code a lot easier to read
  • b

    bright-gpu-74537

    01/20/2023, 7:01 PM
    i think it would make no practical difference perf wise in this scenario... but i agree with the idea that building the url could be clearer
  • b

    bright-gpu-74537

    01/20/2023, 7:01 PM
    you could also use "core haxe" http ofc 🙂
  • b

    bright-gpu-74537

    01/20/2023, 7:05 PM
    actually, that wouldnt work...
    .resource
    in haxeui uses its own stuff... no mechanism to swap it out
  • r

    refined-laptop-39041

    01/20/2023, 7:11 PM
    @happy-agent-4114 https://try.haxe.org/#adDcd807
  • b

    bright-gpu-74537

    01/20/2023, 7:11 PM
    defo cleaner, esp when you want to start moving params about etc
  • r

    refined-laptop-39041

    01/20/2023, 7:18 PM
    Also easier to document
  • f

    full-journalist-82607

    01/20/2023, 8:25 PM
    Yeah ! Just resolved the bug in tables where I would change columns and things would disappear. In the table view
    Copy code
    haxe
        private override function onDataChanged(data:Dynamic) {
            //var renderers = findComponents(ItemRenderer); OLD
            var renderers = findComponents("table_item_renderer", ItemRenderer); //NOW
            for (r in renderers) {
                r.onDataChanged(data);
            }
    [...]
                  itemRenderer = new CompoundItemRenderer();
                    _tableview.itemRenderer = itemRenderer;
                }
                child.addClass("table_item_renderer");
                itemRenderer.addComponent(child);
    
                return child;
    In fact other item renderers would be integrated in the data update values loop of the table, and it would start hiding all these components. (and for some reason would also bother the vertical layout ) Now this surely won't work if you have a table inside a table lol I have now only two tiny far less important bugs left in the table view for me ( and one that could me) . Quite happy 🙂 I was getting obsessed with this table bug
1...139113921393...1687Latest