Skip to content

Instantly share code, notes, and snippets.

@mrvicadai
Last active August 29, 2015 14:11
Show Gist options
  • Save mrvicadai/523c237ea60373e0e8af to your computer and use it in GitHub Desktop.
Save mrvicadai/523c237ea60373e0e8af to your computer and use it in GitHub Desktop.
Jut Chart Party
function get_level(value) {
if (value < 25) {return "success";}
if (value < 50) {return "warning";}
if (value < 75) {return "error";}
return "nothing";
}
sub data1() {
emitter -limit 1000 -hz 10
}
sub data2() {
emitter -limit 300 -hz 3
}
sub data3() {
emitter -limit 100 -hz 1
}
sub src(cate, coefficient) {
data1 |
put category = cate |
put value = Math.random() * coefficient
}
sub src2() {
data3 |
put category = "Category" + count() |
put value = Math.random() * 100 |
put level = get_level(value) |
@tile -display.levelField level
}
sub evnts() {
data2 |
put title="event" |
put type="event" |
put event_type="git"
}
// Barchart
data3 |
put cate = "Category" + count() |
batch 3 |
put val = Math.random() |
@barchart -o {
title: 'Batched Live Barchart',
display: {
resetCategories: 1
},
xScale: {
label: "Custom Cateogry"
},
yScales: {
primary: {
label: 'Custom Value',
tickFormat: '.2f',
scaling: 'linear',
minValue: 'auto',
maxValue: 'auto',
displayOnAxis: 'yAxes.right'
}
},
valueField: 'val',
categoryField: 'cate',
tooltip: {
nameField: cate,
valueField: val,
valueFormat: '.2f'
}
};
// Timechart + Events
(
src -cate "smaug" -coefficient 10;
src -cate "sauron" -coefficient 20;
src -cate "saruman" -coefficient 1;
) |
@timechart -o {
keyField: category,
name: overlay
yScales: {
secondary: {}
}
series: [
{
label : 'smaug',
color : 'red',
name : 'smaug'
},
{
label : 'sauron',
color : 'green',
name : 'sauron'
},
{
label : 'saruman',
color : 'white',
name : 'saruman',
yScale : 'secondary'
}
]
};
evnts |
@events -o {
display: {
typeField: 'event_type',
},
nameField : 'title',
timeField : 'time',
messageField : 'title'
on : 'overlay'
};
// Logger
data2 |
put cate = "Category" + count() |
put val = Math.random() * 1000 |
@logger -o {
title: "Live Logger",
display: {
height: 16,
prefix: '[JSON] ',
style: 'pretty'
}
};
// Table
data1 |
put cate = "Category" + count() |
batch 2 |
put val = Math.random() * 1000 |
@table -o {
title: "Live Table",
display: {
limit: 2,
update: 'replace'
}
};
// Piechart
data3 |
put cate = "Category" + count() |
batch 2 |
put val = Math.random() * 1000 |
@piechart -o {
title: "Live Table",
display: {
radiusInner: 30
},
categoryField: 'cate',
valueField: 'val'
};
// Tile
src2;
src2;
src2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment