This repository was archived by the owner on Nov 25, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +87
-7
lines changed Expand file tree Collapse file tree 2 files changed +87
-7
lines changed Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html >
3+
4+ < head >
5+ < title > Box Plot Chart</ title >
6+ < script src ="../node_modules/chart.js/dist/Chart.bundle.js "> </ script >
7+ < script src ="../build/Chart.BoxPlot.js " type ="text/javascript "> </ script >
8+ < script src ="./utils.js "> </ script >
9+ < style >
10+ canvas {
11+ -moz-user-select : none;
12+ -webkit-user-select : none;
13+ -ms-user-select : none;
14+ }
15+ </ style >
16+ </ head >
17+
18+ < body >
19+ < div id ="container " style ="width: 75%; ">
20+ < canvas id ="canvas "> </ canvas >
21+ </ div >
22+ < script >
23+ const samples = this . Samples . utils ;
24+ var data = {
25+ labels : samples . months ( { count : 7 } ) ,
26+ datasets : [ {
27+ label : 'Box' ,
28+ type : 'boxplot' ,
29+ backgroundColor : 'steelblue' ,
30+ data : samples . boxplots ( { count : 7 } )
31+ } , {
32+ label : 'Bar' ,
33+ type : 'bar' ,
34+ backgroundColor : 'red' ,
35+ data : samples . numbers ( { count : 7 , max : 150 } )
36+ } , {
37+ label : 'Line' ,
38+ type : 'line' ,
39+ data : samples . numbers ( { count : 7 , max : 150 } ) . map ( ( d ) => ( { y : d } ) )
40+ } ]
41+ } ;
42+
43+ window . onload = function ( ) {
44+ var ctx = document . getElementById ( "canvas" ) . getContext ( "2d" ) ;
45+ window . myBar = new Chart ( ctx , {
46+ type : 'boxplot' ,
47+ data : data ,
48+ options : {
49+ responsive : true ,
50+ legend : {
51+ position : 'top' ,
52+ } ,
53+ title : {
54+ display : true ,
55+ text : 'Chart.js Box Plot and Line Chart'
56+ } ,
57+ scales : {
58+ yAxes : [ {
59+ type : 'arrayLinear'
60+ } ]
61+ }
62+ }
63+ } ) ;
64+ } ;
65+ </ script >
66+ </ body >
67+
68+ </ html >
Original file line number Diff line number Diff line change @@ -184,20 +184,32 @@ export function commonDataLimits(extraCallback) {
184184 return ;
185185 }
186186 d . data . forEach ( ( value , j ) => {
187- if ( ! value || meta . data [ j ] . hidden ) {
187+ if ( value == null || meta . data [ j ] . hidden ) {
188188 return ;
189189 }
190+
190191 const stats = asValueStats ( value , minStats , maxStats ) ;
191- if ( ! stats ) {
192- return ;
192+ let minValue ;
193+ let maxValue ;
194+
195+ if ( stats ) {
196+ minValue = stats [ minStats ] ;
197+ maxValue = stats [ maxStats ] ;
198+ } else {
199+ // if stats are not available use the plain value
200+ const parsed = + this . getRightValue ( value ) ;
201+ if ( isNaN ( parsed ) ) {
202+ return ;
203+ }
204+ minValue = maxValue = parsed ;
193205 }
194206
195- if ( this . min === null || stats [ minStats ] < this . min ) {
196- this . min = stats [ minStats ] ;
207+ if ( this . min === null || minValue < this . min ) {
208+ this . min = minValue ;
197209 }
198210
199- if ( this . max === null || stats [ maxStats ] > this . max ) {
200- this . max = stats [ maxStats ] ;
211+ if ( this . max === null || maxValue > this . max ) {
212+ this . max = maxValue ;
201213 }
202214
203215 if ( extraCallback ) {
You can’t perform that action at this time.
0 commit comments