Skip to content

Instantly share code, notes, and snippets.

@volodymyrlut
Created May 18, 2015 09:36
Show Gist options
  • Save volodymyrlut/ea3ff6c0fa6fc1cf61ef to your computer and use it in GitHub Desktop.
Save volodymyrlut/ea3ff6c0fa6fc1cf61ef to your computer and use it in GitHub Desktop.
ChartVisualisation.prototype.composePowerProfileData = function(){
var dataset = this._self.dataset.power;
var labels_length = dataset.length;
var shadow_data = [], labels = [];
labels[0] = "1 m";
shadow_data[0] = 0;
for (var i = 1; i < labels_length; i++){
if (((dataset[i]!==0)&&(dataset[i+1]==0))&&(i%60 == true)){
labels.push(this._dataHelpers.convertSeconds(i));
} else {
labels.push('');
}
shadow_data.push((dataset[i] > 0) ? dataset[i] : shadow_data[i-1]);
}
var datasets = {
label: "Power",
fillColor: "transparent",
strokeColor: "#5ACD78",
pointColor: "#5ACD78",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "#5ACD78",
data: shadow_data
};
return lineChartData = {
labels: labels,
datasets: datasets,
};
};
ChartVisualisation.prototype.drawPowerProfile = function(){
var powerProfileData = this.composePowerProfileData();
console.log(powerProfileData);
var ctx1 = $('#chart1').get(0).getContext("2d");
var options = {
responsive: true,
animation: false,
scaleShowGridLines: false,
pointDot : false,
showTooltips: false,
customTooltips: false,
scaleStartValue: 0,
beginAtZero: true,
scaleBeginAtZero: true,
bezierCurve: false
};
window.myLine1 = new Chart(ctx1).Line(powerProfileData, options);
console.log(window.myLine1);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment