mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
feat: benchmarking (#999)
* feat: add benchmarking dashboard, CI hook on PR, and store lifetime results * refactor: change python env to 3.13 in benchmarks * refactor: add verbosity, use 3.11 for benchmarking * fix: OSError: [Errno 7] Argument list too long * refactor: add debug statements * refactor: remove extraneous -e * refactor: fix tests and linter errors * fix: track main package in coverage * refactor: fix test coverage testing * refactor: fix repo owner name in benchmark on pushing comment * refactor: add asv monkeypatch to docs workflow * refactor: temporarily allow building docs in forks * refactor: use py 3.13 for benchmarking * refactor: run only a single benchmark for PRs to speed them up * refactor: install asv in the docs build workflow * refactor: use hatch docs env to generate benhcmarks in docs CI * refactor: more trying * refactor: move tests * Add benchmark results for 0.137 * Trigger Build * Add benchmark results for 0.138 * refactor: set constant machine name when benchmarking * Add benchmark results for 0.139 * refactor: fix issue with paths too long * Add benchmark results for 0.140 * docs: update comment * refactor: remove test benchmarking data * refactor: fix comment * refactor: allow the benchmark workflow to write to PRs * refactor: use personal access token to set up the PR benchmark bot * refactor: split the benchmark PR flow into two to make it work with PRs from forks * refactor: update deprecated actions/upload-artifact@v3 to v4 * refactor: fix missing directory in benchmarking workflow * refactor: fix triggering of second workflow * refactor: fix workflow finally? * docs: add comments to cut-offs and direct people to benchmarks PR --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
dcd4203eea
commit
f36581ed86
90 changed files with 40817 additions and 443 deletions
140
docs/benchmarks/jquery.flot.axislabels.js
Normal file
140
docs/benchmarks/jquery.flot.axislabels.js
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
CAxis Labels Plugin for flot. :P
|
||||
Copyright (c) 2010 Xuan Luo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
(function ($) {
|
||||
var options = { };
|
||||
|
||||
function init(plot) {
|
||||
// This is kind of a hack. There are no hooks in Flot between
|
||||
// the creation and measuring of the ticks (setTicks, measureTickLabels
|
||||
// in setupGrid() ) and the drawing of the ticks and plot box
|
||||
// (insertAxisLabels in setupGrid() ).
|
||||
//
|
||||
// Therefore, we use a trick where we run the draw routine twice:
|
||||
// the first time to get the tick measurements, so that we can change
|
||||
// them, and then have it draw it again.
|
||||
var secondPass = false;
|
||||
plot.hooks.draw.push(function (plot, ctx) {
|
||||
if (!secondPass) {
|
||||
// MEASURE AND SET OPTIONS
|
||||
$.each(plot.getAxes(), function(axisName, axis) {
|
||||
var opts = axis.options // Flot 0.7
|
||||
|| plot.getOptions()[axisName]; // Flot 0.6
|
||||
if (!opts || !opts.axisLabel)
|
||||
return;
|
||||
|
||||
var w, h;
|
||||
if (opts.axisLabelUseCanvas != false)
|
||||
opts.axisLabelUseCanvas = true;
|
||||
|
||||
if (opts.axisLabelUseCanvas) {
|
||||
// canvas text
|
||||
if (!opts.axisLabelFontSizePixels)
|
||||
opts.axisLabelFontSizePixels = 14;
|
||||
if (!opts.axisLabelFontFamily)
|
||||
opts.axisLabelFontFamily = 'sans-serif';
|
||||
// since we currently always display x as horiz.
|
||||
// and y as vertical, we only care about the height
|
||||
w = opts.axisLabelFontSizePixels;
|
||||
h = opts.axisLabelFontSizePixels;
|
||||
|
||||
} else {
|
||||
// HTML text
|
||||
var elem = $('<div class="axisLabels" style="position:absolute;">' + opts.axisLabel + '</div>');
|
||||
plot.getPlaceholder().append(elem);
|
||||
w = elem.outerWidth(true);
|
||||
h = elem.outerHeight(true);
|
||||
elem.remove();
|
||||
}
|
||||
|
||||
if (axisName.charAt(0) == 'x')
|
||||
axis.labelHeight += h;
|
||||
else
|
||||
axis.labelWidth += w;
|
||||
opts.labelHeight = axis.labelHeight;
|
||||
opts.labelWidth = axis.labelWidth;
|
||||
});
|
||||
// re-draw with new label widths and heights
|
||||
secondPass = true;
|
||||
plot.setupGrid();
|
||||
plot.draw();
|
||||
|
||||
|
||||
} else {
|
||||
// DRAW
|
||||
$.each(plot.getAxes(), function(axisName, axis) {
|
||||
var opts = axis.options // Flot 0.7
|
||||
|| plot.getOptions()[axisName]; // Flot 0.6
|
||||
if (!opts || !opts.axisLabel)
|
||||
return;
|
||||
|
||||
if (opts.axisLabelUseCanvas) {
|
||||
// canvas text
|
||||
var ctx = plot.getCanvas().getContext('2d');
|
||||
ctx.save();
|
||||
ctx.font = opts.axisLabelFontSizePixels + 'px ' +
|
||||
opts.axisLabelFontFamily;
|
||||
var width = ctx.measureText(opts.axisLabel).width;
|
||||
var height = opts.axisLabelFontSizePixels;
|
||||
var x, y;
|
||||
if (axisName.charAt(0) == 'x') {
|
||||
x = plot.getPlotOffset().left + plot.width()/2 - width/2;
|
||||
y = plot.getCanvas().height;
|
||||
} else {
|
||||
x = height * 0.72;
|
||||
y = plot.getPlotOffset().top + plot.height()/2 - width/2;
|
||||
}
|
||||
ctx.translate(x, y);
|
||||
ctx.rotate((axisName.charAt(0) == 'x') ? 0 : -Math.PI/2);
|
||||
ctx.fillText(opts.axisLabel, 0, 0);
|
||||
ctx.restore();
|
||||
|
||||
} else {
|
||||
// HTML text
|
||||
plot.getPlaceholder().find('#' + axisName + 'Label').remove();
|
||||
var elem = $('<div id="' + axisName + 'Label" " class="axisLabels" style="position:absolute;">' + opts.axisLabel + '</div>');
|
||||
if (axisName.charAt(0) == 'x') {
|
||||
elem.css('left', plot.getPlotOffset().left + plot.width()/2 - elem.outerWidth()/2 + 'px');
|
||||
elem.css('bottom', '0px');
|
||||
} else {
|
||||
elem.css('top', plot.getPlotOffset().top + plot.height()/2 - elem.outerHeight()/2 + 'px');
|
||||
elem.css('left', '0px');
|
||||
}
|
||||
plot.getPlaceholder().append(elem);
|
||||
}
|
||||
});
|
||||
secondPass = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'axisLabels',
|
||||
version: '1.0'
|
||||
});
|
||||
})(jQuery);
|
Loading…
Add table
Add a link
Reference in a new issue