tweak karma graph output for many data points

if there's a ton of data points, the graph starts looking real gross,
so do a couple things to make the display of that a bit simpler so
there's less noise and distracting lines and whatnot
This commit is contained in:
Brian S. Stephan 2016-03-30 17:57:00 -05:00
parent 3e9302c89c
commit 08da8ea9f3
1 changed files with 18 additions and 2 deletions

View File

@ -13,6 +13,17 @@
<script type="text/javascript">
Chart.defaults.global.responsive = true;
Chart.defaults.global.maintainAspectRatio = true;
Chart.types.Line.extend({name : "AltLine",
initialize : function(data) {
Chart.types.Line.prototype.initialize.apply(this, arguments);
this.scale.draw = function() {
if (this.display && (this.xLabelRotation > 90)) {
this.endPoint = this.height - 5;
}
Chart.Scale.prototype.draw.apply(this, arguments);
};
}
});
var ctx = $("#karma_history").get(0).getContext("2d");
var data = {
labels: ["EPOCH", {% for x in entry.history %}"{{ x.0 }}", {% endfor %}],
@ -29,8 +40,13 @@
}
]
};
var myLineChart = new Chart(ctx).Line(data, {
pointDot: false
var myLineChart = new Chart(ctx).AltLine(data, {
pointDot: false,
{% if entry.history|length > 100 %}
showTooltips: false,
scaleShowVerticalLines: false,
{% endif %}
tooltipEvents: ["click"]
});
</script>
{% endblock %}