Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1002619 // Visitors Chart (LIVE)

JavaX source code [tags: butter use-pretranspiled] - run with: x30.jar - homepage

Libraryless. Click here for Pure Java version (5147L/33K/114K).

!7

static DependentCache<S> imageCache = new(f makeChart_fresh, f unixDay);

answer {
  if "visitors chart" ret standardChart();
  
  if (match("visitors chart *", s, m) || match("visitors chart * days", s, m))
    ret makeChart_fresh(m.psi(0));
}

html {
  ret himg(skipToURL(standardChart()));
}

// 7 days
static S standardChart() {
  ret imageCache!;
}

static S makeChart_fresh() {
  ret makeChart_fresh(7);
}

static S makeChart_fresh(int days) {
  print("Making visitors chart for " + days + " days");
  days = max(1, days);
  exceptionToUser {
    L<S> l = toLinesFullTrim(unSlackSnippet(askSelf("visitors last " + (days+1) + " days")));
    
    new L<Integer> data;
    for (S line : l) {
      O o = safeUnstructure(line);
      int n = toInt(get(o, "cookies"));
      data.add(n);
    }
    
    removeLast(data); // drop today's data - it looks bad
    
    ret chartBase("Visitors last " + days + " days (= cookies)", 0, data);
 // base value = 0
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002619
Snippet name: Visitors Chart (LIVE)
Eternal ID of this version: #1002619/5
Text MD5: 98f3fe87aaf3a497921104488d42de86
Transpilation MD5: 29e634e65d4adbabac994ba2cea25eae
Author: stefan
Category: javax / eleu
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-18 13:09:41
Source code size: 1009 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 642 / 4714
Version history: 4 change(s)
Referenced in: [show references]