This is a simple proof-of-concept example of how one could embed Juttle-powered charts and visualizations in a custom application.
Requires node.js to be installed.
#!/usr/bin/python | |
''' | |
Script to count messages by user posted to a channel for a given date range. | |
Install: | |
# sudo pip install slackclient | |
Also you will need to obtain a slack API token: | |
https://api.slack.com/docs/oauth-test-tokens |
#!/usr/bin/env node | |
// | |
// Script to convert any extendable-base derived classes in the specified | |
// files into proper ES6 classes. | |
// | |
// Along the way it will remove any require() statements for extendable-base | |
// itself, convert any prototype literals into ES6 properties, and add the | |
// appropriate superclass constructor invocations to get the same behavior as | |
// the extendable-base initialize chain. | |
// |
// silly little juttle that compares the twitterati | |
( | |
emit -limit 1 | put name='demmer', tweets=12, followers=33, first_tweet=:2015-06-02:; | |
emit -limit 1 | put name='apurva', tweets=81, followers=71, first_tweet=:2002-06-18:; | |
emit -limit 1 | put name='henri', tweets=121, followers=61, first_tweet=:2007-12-31:; | |
) | |
| put followers_per_day = Duration.get(:now: - first_tweet, "days") | |
| put followers_per_tweet = followers / tweets | |
|( | |
@barchart -title "Followers" -valueField 'followers' -categoryField 'name'; |
// Simple example of using input controls as parameters | |
input message: text -label 'Message to show' -default 'Testing...'; | |
input num_points: dropdown -items [1,2,3,4,5,6,7,8] -label 'Number of points' -default 5; | |
emit -limit num_points | |
| put message="${message} ${count()}" | |
| @tile |
// Prompt for a time duration and a threshold parameter | |
input duration: duration -label 'Time period'; | |
input threshold: number -label 'Max response time (ms)' -default 500; | |
// Use these inputs to filter out only hosts that have experienced high response times | |
// during the specified time period. | |
input host: combobox -juttle "read -demo 'srch_cluster' -last :${duration}: name = 'response_ms' | filter value > ${threshold} | reduce by host" | |
-valueField 'host' -label 'Hosts with response time > ${threshold} ms'; | |
// Once a host is selected, show the response time chart |
// Simple juttle program to show a big metric tile counting down the time until | |
// the launch of playground | |
const launch = :2014-12-10 12:10:14 PST:; | |
function format(value) { | |
var days = Duration.get(value, 'day'); | |
var hours = Duration.get(value, 'hour'); | |
var minutes = Duration.get(value, 'minutes'); | |
var seconds = Duration.get(value, 'seconds'); |
#!/usr/bin/env node | |
// | |
// Converts a git log into a JSON array including the full commit message. | |
// | |
var cp = require('child_process'); | |
var formats = { | |
author: '%an', | |
email: '%ae', |
This gist adapts a wordcloud visualization from http://www.jasondavies.com/wordcloud/ as a Juttle view, adding transitions between batches for updates.
As a silly little showcase, the demonstration program calculates a frequency count of words from Dr Seuss' "The Cat in the Hat" (text pulled from http://paulandlizdavies.com/poems/cat.htm) by splitting the words from each page into separate points, then counting the words by frequency and showing them in the wordcloud and a barchart.
Juttle's powerful join functionality allows you to join your local data with data stored anywhere else. What's more, you can do streaming joins where points are joined as they come in.
Here we're counting the number of server errors triggered by each user_id and joining that data to an external customer data file.