@@ -29,20 +29,6 @@ const getColor = () => {
29
29
const hist_points = [ 'min' , 'p50' , 'p75' , 'p90' , 'p99' , 'p99_9' , 'max' ]
30
30
const hist_labels = [ 'min' , '50%' , '75%' , '90%' , '99%' , '99.9%' , 'max' ]
31
31
32
- const makeChartJSDataset = ( benchDataEntry ) => {
33
- const label = benchDataEntry . name
34
- const data = hist_points . map ( ( p ) => benchDataEntry . histogram . json [ p ] )
35
- return {
36
- label,
37
- data,
38
- fill : false ,
39
- borderWidth : 1 ,
40
- pointRadius : 2.5 ,
41
- pointBackgroundColor : 'white' ,
42
- borderColor : getColor ( ) ,
43
- }
44
- }
45
-
46
32
const benchmarkEntryToTableValue = ( item ) => {
47
33
return {
48
34
name : item . name ,
@@ -689,7 +675,7 @@ app.component('DataTable', {
689
675
} )
690
676
691
677
// Options for our hdr-histogram-style line chart, factored out for re-use:
692
- const makeLatencyLineChartOptions = ( otherPlugins , enable_crosshair_zoom = true ) => {
678
+ const makeLatencyLineChartOptions = ( minDataPoint , maxDataPoint , otherPlugins , enable_crosshair_zoom = true ) => {
693
679
return {
694
680
tooltips : {
695
681
mode : 'interpolate' ,
@@ -765,6 +751,8 @@ const makeLatencyLineChartOptions = (otherPlugins, enable_crosshair_zoom = true)
765
751
labelString : 'Response Time (ms)' ,
766
752
} ,
767
753
ticks : {
754
+ min : minDataPoint ,
755
+ max : maxDataPoint ,
768
756
maxTicksLimit : 10 ,
769
757
padding : 5 ,
770
758
fontSize : 12 ,
@@ -800,18 +788,42 @@ app.component('LatencyLineChart', {
800
788
</div>
801
789
` ,
802
790
setup ( props ) {
791
+ // Collect these so we can properly scale our axes as tight as possible to data
792
+ // (maybe new versions of chart.js make this less painful)
793
+ var minDataPoint = Number . MAX_SAFE_INTEGER
794
+ var maxDataPoint = Number . MIN_SAFE_INTEGER
795
+ const makeDataset = ( benchDataEntry ) => {
796
+ minDataPoint = Math . min ( minDataPoint , benchDataEntry . histogram . json [ 'min' ] )
797
+ maxDataPoint = Math . max ( maxDataPoint , benchDataEntry . histogram . json [ 'max' ] )
798
+ const label = benchDataEntry . name
799
+ const data = hist_points . map ( ( p ) => benchDataEntry . histogram . json [ p ] )
800
+ return {
801
+ label,
802
+ data,
803
+ fill : false ,
804
+ borderWidth : 1 ,
805
+ pointRadius : 2.5 ,
806
+ pointBackgroundColor : 'white' ,
807
+ borderColor : getColor ( ) ,
808
+ // Smooth lines, but monotone (no misleading up/down "swooping" to fit data points)
809
+ cubicInterpolationMode : 'monotone' ,
810
+ // tension: 0.4, //... I'm not convinced this actually does anything...
811
+ }
812
+ }
813
+
803
814
const chartElem = ref ( null )
804
815
onMounted ( ( ) => {
805
816
const ctx = chartElem . value . getContext ( '2d' )
817
+ const datasets = props . benchData . map ( makeDataset )
806
818
const myChart = new Chart ( ctx , {
807
819
responsive : true ,
808
820
maintainAspectRatio : false ,
809
821
type : 'line' ,
810
822
data : {
811
823
labels : hist_labels ,
812
- datasets : props . benchData . map ( makeChartJSDataset ) ,
824
+ datasets,
813
825
} ,
814
- options : makeLatencyLineChartOptions ( { } ) ,
826
+ options : makeLatencyLineChartOptions ( minDataPoint , maxDataPoint , { } ) ,
815
827
} )
816
828
} )
817
829
@@ -846,7 +858,13 @@ app.component('MultiLatencyLineChart', {
846
858
setup ( props ) {
847
859
const chartElem = ref ( null )
848
860
onMounted ( ( ) => {
861
+ // Collect these so we can properly scale our axes as tight as possible to data
862
+ // (maybe new versions of chart.js make this less painful)
863
+ var minDataPoint = Number . MAX_SAFE_INTEGER
864
+ var maxDataPoint = Number . MIN_SAFE_INTEGER
849
865
const makeDataset = ( benchDataEntry , ix ) => {
866
+ minDataPoint = Math . min ( minDataPoint , benchDataEntry [ 'min' ] )
867
+ maxDataPoint = Math . max ( maxDataPoint , benchDataEntry [ 'max' ] )
850
868
const label = benchDataEntry . name
851
869
const data = hist_points . map ( ( p ) => benchDataEntry [ p ] )
852
870
return {
@@ -857,8 +875,10 @@ app.component('MultiLatencyLineChart', {
857
875
pointRadius : 0 , // disable points, which looks cluttered
858
876
// This is a heatmap-style red to blue color scheme which lets us show
859
877
// the results "fading back in time":
860
- borderColor : redToBlue ( ix , props . benchData . length )
878
+ borderColor : redToBlue ( ix , props . benchData . length ) ,
861
879
// pointBackgroundColor: 'white',
880
+ // Smooth lines, but monotone (no misleading up/down "swooping" to fit data points)
881
+ cubicInterpolationMode : 'monotone' ,
862
882
}
863
883
}
864
884
// Options to allow zooming: https://www.chartjs.org/chartjs-plugin-zoom/
@@ -875,16 +895,17 @@ app.component('MultiLatencyLineChart', {
875
895
}
876
896
877
897
const ctx = chartElem . value . getContext ( '2d' )
898
+ const datasets = props . benchData . map ( makeDataset )
878
899
const myChart = new Chart ( ctx , {
879
900
responsive : true ,
880
901
maintainAspectRatio : false ,
881
902
type : 'line' ,
882
903
data : {
883
904
labels : hist_labels ,
884
- datasets : props . benchData . map ( makeDataset ) ,
905
+ datasets,
885
906
} ,
886
907
// NOTE: this isn't really compatible with crosshair.zoom, so we disable that here:
887
- options : makeLatencyLineChartOptions ( zoomOptions , false ) ,
908
+ options : makeLatencyLineChartOptions ( minDataPoint , maxDataPoint , zoomOptions , false ) ,
888
909
// options: makeLatencyLineChartOptions({colorschemes: { scheme: "brewer.RdYlBu11" }}),
889
910
} )
890
911
} )
0 commit comments