##// END OF EJS Templates
fixes graph y axis problem
marcink -
r1430:9d19456c beta
parent child Browse files
Show More
@@ -452,43 +452,33 b''
452 function getDataAccordingToRanges(ranges) {
452 function getDataAccordingToRanges(ranges) {
453
453
454 var data = [];
454 var data = [];
455 var new_dataset = {};
455 var keys = [];
456 var keys = [];
457 var max_commits = 0;
456 for(var key in dataset){
458 for(var key in dataset){
457 var push = false;
458
459
459 //method1 slow !!
460 //*
461 for(var ds in dataset[key].data){
460 for(var ds in dataset[key].data){
462 commit_data = dataset[key].data[ds];
461 commit_data = dataset[key].data[ds];
463 if (commit_data.time >= ranges.xaxis.from && commit_data.time <= ranges.xaxis.to){
462 if (commit_data.time >= ranges.xaxis.from && commit_data.time <= ranges.xaxis.to){
464 push = true;
463
465 break;
464 if(new_dataset[key] === undefined){
465 new_dataset[key] = {data:[],schema:["commits"],label:key};
466 }
467 new_dataset[key].data.push(commit_data);
466 }
468 }
467 }
469 }
468 //*/
470 if (new_dataset[key] !== undefined){
469
471 data.push(new_dataset[key]);
470 /*//method2 sorted commit data !!!
472 }
471
472 var first_commit = dataset[key].data[0].time;
473 var last_commit = dataset[key].data[dataset[key].data.length-1].time;
474
475 if (first_commit >= ranges.xaxis.from && last_commit <= ranges.xaxis.to){
476 push = true;
477 }
478 //*/
479
480 if(push){
481 data.push(dataset[key]);
482 }
483 }
473 }
484 if(data.length >= 1){
474
485 return data;
475 if (data.length > 0){
486 }
476 return data;
477 }
487 else{
478 else{
488 //just return dummy data for graph to plot itself
479 //just return dummy data for graph to plot itself
489 return [getDummyData('')];
480 return [getDummyData('')];
490 }
481 }
491
492 }
482 }
493
483
494 /**
484 /**
@@ -537,7 +527,7 b''
537 //resubscribe plothover
527 //resubscribe plothover
538 plot.subscribe("plothover", plothover);
528 plot.subscribe("plothover", plothover);
539
529
540 // don't fire event on the overview to prevent eternal loop
530 // don't fire event on the overview to prevent eternal loop
541 overview.setSelection(cur_ranges, true);
531 overview.setSelection(cur_ranges, true);
542
532
543 }
533 }
@@ -549,7 +539,7 b''
549 */
539 */
550 function plotselected(ranges,cur_data) {
540 function plotselected(ranges,cur_data) {
551 //updates the data for new plot
541 //updates the data for new plot
552 data = getDataAccordingToRanges(ranges);
542 var data = getDataAccordingToRanges(ranges);
553 generateCheckboxes(data);
543 generateCheckboxes(data);
554
544
555 var new_options = YAHOO.lang.merge(plot_options, {
545 var new_options = YAHOO.lang.merge(plot_options, {
@@ -559,13 +549,8 b''
559 mode:"time",
549 mode:"time",
560 timeformat: "%d/%m",
550 timeformat: "%d/%m",
561 },
551 },
562 yaxis: {
563 min: ranges.yaxis.from,
564 max: ranges.yaxis.to,
565 },
566
567 });
552 });
568 // do the zooming
553 // do the zooming
569 plot = YAHOO.widget.Flot(plotContainer, data, new_options);
554 plot = YAHOO.widget.Flot(plotContainer, data, new_options);
570
555
571 plot.subscribe("plotselected", plotselected);
556 plot.subscribe("plotselected", plotselected);
@@ -576,7 +561,7 b''
576 // don't fire event on the overview to prevent eternal loop
561 // don't fire event on the overview to prevent eternal loop
577 overview.setSelection(ranges, true);
562 overview.setSelection(ranges, true);
578
563
579 //resubscribe choiced
564 //resubscribe choiced
580 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, ranges]);
565 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, ranges]);
581 }
566 }
582
567
@@ -644,25 +629,25 b''
644 * MAIN EXECUTION
629 * MAIN EXECUTION
645 */
630 */
646
631
647 var data = getDataAccordingToRanges(initial_ranges);
632 var data = getDataAccordingToRanges(initial_ranges);
648 generateCheckboxes(data);
633 generateCheckboxes(data);
649
634
650 //main plot
635 //main plot
651 var plot = YAHOO.widget.Flot(plotContainer,data,plot_options);
636 var plot = YAHOO.widget.Flot(plotContainer,data,plot_options);
652
637
653 //overview
638 //overview
654 var overview = YAHOO.widget.Flot(overviewContainer, overview_dataset, overview_options);
639 var overview = YAHOO.widget.Flot(overviewContainer,
640 overview_dataset, overview_options);
655
641
656 //show initial selection on overview
642 //show initial selection on overview
657 overview.setSelection(initial_ranges);
643 overview.setSelection(initial_ranges);
658
644
659 plot.subscribe("plotselected", plotselected);
645 plot.subscribe("plotselected", plotselected);
646 plot.subscribe("plothover", plothover)
660
647
661 overview.subscribe("plotselected", function (ranges) {
648 overview.subscribe("plotselected", function (ranges) {
662 plot.setSelection(ranges);
649 plot.setSelection(ranges);
663 });
650 });
664
665 plot.subscribe("plothover", plothover);
666
651
667 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, initial_ranges]);
652 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, initial_ranges]);
668 }
653 }
General Comments 0
You need to be logged in to leave comments. Login now