1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flot Examples: Axes tick labels options</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery/jquery.js"></script>
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery-flot/jquery.canvaswrapper.js"></script>
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery-flot/jquery.colorhelpers.js"></script>
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery-flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery-flot/jquery.flot.saturated.js"></script>
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery-flot/jquery.flot.browser.js"></script>
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery-flot/jquery.flot.drawSeries.js"></script>
<script language="javascript" type="text/javascript" src="/usr/share/javascript/jquery-flot/jquery.flot.uiConstants.js"></script>
<style>
fieldset {
display: inline-block;
height: 180px;
}
</style>
<script type="text/javascript">
$(function() {
var index = 10000;
function generate(start, end, fn) {
var res = [];
for (var i = 0; i <= 40; ++i) {
var x = start + i / 40 * (end - start);
res.push([x, fn(x)]);
}
return res;
}
var data = [
{ data: generate(index, 2, function (x) { return Math.cos(x);}), xaxis: 1, yaxis:1, lines: { show: true}}
];
var plot = $.plot("#placeholder", data, {
xaxes: [
{ position: 'bottom' }
],
yaxes: [
{ position: 'left', autoScale: 'none', min: -3, max: 3 }
]
});
function update () {
index += 0.01;
data = [
{ data: generate(index, index + 2, function (x) { return Math.cos(x);}), xaxis: 1, yaxis:1, lines: { show: true}}
];
plot.setData(data);
plot.setupGrid(true);
plot.draw();
window.requestAnimationFrame(update);
}
window.requestAnimationFrame(update);
$('#tickLabels input').on('change', function() {
var val = $('input[name="tickLabels"]:checked', '#tickLabels').val()
var axes = plot.getXAxes().concat(plot.getYAxes());
axes.forEach(function(axis) {
axis.options.showTickLabels = val;
});
});
$('#tickMarks input').on('change', function() {
var val = $('input[name="tickMarks"]:checked', '#tickMarks').val()
var axes = plot.getXAxes().concat(plot.getYAxes());
axes.forEach(function(axis) {
switch(val) {
case 'none':
axis.options.showTicks = false;
break;
case 'major':
axis.options.showTicks = true;
axis.options.showMinorTicks = false;
break;
case 'all':
axis.options.showTicks = true;
axis.options.showMinorTicks = true;
break;
}
});
});
$('#scaling input').on('change', function() {
var val = $('input[name="scaling"]:checked', '#scaling').val()
var y = plot.getAxes().yaxis;
switch (val) {
case 'none':
y.options.autoScale = 'none';
y.options.min = -3;
y.options.max = 3;
y.options.autoScaleMargin = null;
y.options.growOnly = null;
break;
case 'fitLoosely':
y.options.autoScale = 'loose';
y.options.min = undefined;
y.options.max = undefined;
y.options.autoScaleMargin = 0.1;
y.options.growOnly = false;
break;
case 'fitExactly':
y.options.autoScale = 'exact';
y.options.min = undefined;
y.options.max = undefined;
y.options.autoScaleMargin = null;
y.options.growOnly = false;
break;
case 'growLoosely':
y.options.autoScale = 'loose';
y.options.min = -2.0;
y.options.max = 2.0;
y.options.autoScaleMargin = 0.1;
y.options.growOnly = true;
break;
case 'growExactly':
y.options.autoScale = 'exact';
y.options.min = undefined;
y.options.max = undefined;
y.options.autoScaleMargin = null;
y.options.growOnly = true;
break;
}
});
$('#verticalPosition input').on('change', function() {
var val = $('input[name="verticalPosition"]:checked', '#verticalPosition').val()
var axes = plot.getYAxes();
axes.forEach(function(axis) {
axis.options.position = val;
});
});
$('#horizontalPosition input').on('change', function() {
var val = $('input[name="horizontalPosition"]:checked', '#horizontalPosition').val()
var axes = plot.getXAxes();
axes.forEach(function(axis) {
axis.options.position = val;
});
});
});
</script>
</head>
<body>
<div id="header">
<h2>Flot Examples: Axes tick labels options</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder" class="demo-placeholder"></div>
</div>
<fieldset id="tickLabels">
<legend>Axis tick labels options</legend>
<input type="radio" name="tickLabels" value="none" /> none <br />
<input type="radio" name="tickLabels" value="endpoints" /> endpoints <br />
<input type="radio" name="tickLabels" value="major" checked="checked"/> major <br />
<input type="radio" name="tickLabels" value="all" /> all <br />
</fieldset>
<fieldset id="tickMarks">
<legend>Axis tick marks options</legend>
<input type="radio" name="tickMarks" value="none" /> none <br />
<input type="radio" name="tickMarks" value="major" /> major <br />
<input type="radio" name="tickMarks" value="all" checked="checked"/> all <br />
</fieldset>
<fieldset id="scaling">
<legend>Vertical axis autoscaling options</legend>
<input type="radio" name="scaling" value="none" checked="checked" /> None (min = -3, max = 3) <br />
<input type="radio" name="scaling" value="fitLoosely"/> fit loosely <br />
<input type="radio" name="scaling" value="fitExactly" /> fit exactly <br />
<input type="radio" name="scaling" value="growLoosely" /> grow loosely <br />
<input type="radio" name="scaling" value="growExactly" /> grow exactly <br />
</fieldset>
<fieldset id="verticalPosition">
<legend>Vertical axis position options</legend>
<input type="radio" name="verticalPosition" value="right" /> right <br />
<input type="radio" name="verticalPosition" value="left" checked="checked"/> left <br />
</fieldset>
<fieldset id="horizontalPosition">
<legend>Horizontal axis position options</legend>
<input type="radio" name="horizontalPosition" value="top" /> top <br />
<input type="radio" name="horizontalPosition" value="bottom" checked="bottom"/> left <br />
</fieldset>
</div>
</body>
</html>
|