From 6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 13 Jul 2018 19:06:45 +0200 Subject: Fixed many permissions and began admin interface --- .../morris.js/spec/lib/area/area_spec.coffee | 60 ++++++ .../morris.js/spec/lib/bar/bar_spec.coffee | 127 +++++++++++++ .../morris.js/spec/lib/bar/colours.coffee | 36 ++++ .../morris.js/spec/lib/commas_spec.coffee | 38 ++++ .../morris.js/spec/lib/donut/donut_spec.coffee | 76 ++++++++ .../spec/lib/grid/auto_grid_lines_spec.coffee | 25 +++ .../morris.js/spec/lib/grid/set_data_spec.coffee | 208 ++++++++++++++++++++ .../spec/lib/grid/y_label_format_spec.coffee | 15 ++ .../morris.js/spec/lib/hover_spec.coffee | 64 +++++++ .../morris.js/spec/lib/label_series_spec.coffee | 186 ++++++++++++++++++ .../morris.js/spec/lib/line/line_spec.coffee | 211 +++++++++++++++++++++ .../morris.js/spec/lib/pad_spec.coffee | 17 ++ .../morris.js/spec/lib/parse_time_spec.coffee | 35 ++++ public/bower_components/morris.js/spec/specs.html | 34 ++++ .../morris.js/spec/support/placeholder.coffee | 6 + .../morris.js/spec/viz/examples.js | 56 ++++++ .../morris.js/spec/viz/exemplary/area0.png | Bin 0 -> 18402 bytes .../morris.js/spec/viz/exemplary/bar0.png | Bin 0 -> 6936 bytes .../morris.js/spec/viz/exemplary/line0.png | Bin 0 -> 22812 bytes .../morris.js/spec/viz/exemplary/stacked_bar0.png | Bin 0 -> 5859 bytes public/bower_components/morris.js/spec/viz/run.sh | 32 ++++ .../bower_components/morris.js/spec/viz/test.html | 34 ++++ .../morris.js/spec/viz/visual_specs.js | 66 +++++++ 23 files changed, 1326 insertions(+) create mode 100644 public/bower_components/morris.js/spec/lib/area/area_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/bar/bar_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/bar/colours.coffee create mode 100644 public/bower_components/morris.js/spec/lib/commas_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/donut/donut_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/grid/auto_grid_lines_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/grid/set_data_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/grid/y_label_format_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/hover_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/label_series_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/line/line_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/pad_spec.coffee create mode 100644 public/bower_components/morris.js/spec/lib/parse_time_spec.coffee create mode 100644 public/bower_components/morris.js/spec/specs.html create mode 100644 public/bower_components/morris.js/spec/support/placeholder.coffee create mode 100644 public/bower_components/morris.js/spec/viz/examples.js create mode 100644 public/bower_components/morris.js/spec/viz/exemplary/area0.png create mode 100644 public/bower_components/morris.js/spec/viz/exemplary/bar0.png create mode 100644 public/bower_components/morris.js/spec/viz/exemplary/line0.png create mode 100644 public/bower_components/morris.js/spec/viz/exemplary/stacked_bar0.png create mode 100755 public/bower_components/morris.js/spec/viz/run.sh create mode 100644 public/bower_components/morris.js/spec/viz/test.html create mode 100644 public/bower_components/morris.js/spec/viz/visual_specs.js (limited to 'public/bower_components/morris.js/spec') diff --git a/public/bower_components/morris.js/spec/lib/area/area_spec.coffee b/public/bower_components/morris.js/spec/lib/area/area_spec.coffee new file mode 100644 index 0000000..fa36b2e --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/area/area_spec.coffee @@ -0,0 +1,60 @@ +describe 'Morris.Area', -> + + describe 'svg structure', -> + defaults = + element: 'graph' + data: [{x: '2012 Q1', y: 1}, {x: '2012 Q2', y: 1}] + lineColors: [ '#0b62a4', '#7a92a3'] + gridLineColor: '#aaa' + xkey: 'x' + ykeys: ['y'] + labels: ['Y'] + + it 'should contain a line path for each line', -> + chart = Morris.Area $.extend {}, defaults + $('#graph').find("path[stroke='#0b62a4']").size().should.equal 1 + + it 'should contain a path with stroke-width 0 for each line', -> + chart = Morris.Area $.extend {}, defaults + $('#graph').find("path[stroke='#0b62a4']").size().should.equal 1 + + it 'should contain 5 grid lines', -> + chart = Morris.Area $.extend {}, defaults + $('#graph').find("path[stroke='#aaaaaa']").size().should.equal 5 + + it 'should contain 9 text elements', -> + chart = Morris.Area $.extend {}, defaults + $('#graph').find("text").size().should.equal 9 + + describe 'svg attributes', -> + defaults = + element: 'graph' + data: [{x: '2012 Q1', y: 1}, {x: '2012 Q2', y: 1}] + xkey: 'x' + ykeys: ['y'] + labels: ['Y'] + lineColors: [ '#0b62a4', '#7a92a3'] + lineWidth: 3 + pointWidths: [5] + pointStrokeColors: ['#ffffff'] + gridLineColor: '#aaa' + gridStrokeWidth: 0.5 + gridTextColor: '#888' + gridTextSize: 12 + + it 'should not be cumulative if behaveLikeLine', -> + chart = Morris.Area $.extend {}, defaults, behaveLikeLine: true + chart.cumulative.should.equal false + + it 'should have a line with transparent fill if behaveLikeLine', -> + chart = Morris.Area $.extend {}, defaults, behaveLikeLine: true + $('#graph').find("path[fill-opacity='0.8']").size().should.equal 1 + + it 'should not have a line with transparent fill', -> + chart = Morris.Area $.extend {}, defaults + $('#graph').find("path[fill-opacity='0.8']").size().should.equal 0 + + it 'should have a line with the fill of a modified line color', -> + chart = Morris.Area $.extend {}, defaults + $('#graph').find("path[fill='#0b62a4']").size().should.equal 0 + $('#graph').find("path[fill='#7a92a3']").size().should.equal 0 diff --git a/public/bower_components/morris.js/spec/lib/bar/bar_spec.coffee b/public/bower_components/morris.js/spec/lib/bar/bar_spec.coffee new file mode 100644 index 0000000..c647c53 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/bar/bar_spec.coffee @@ -0,0 +1,127 @@ +describe 'Morris.Bar', -> + describe 'when using vertical grid', -> + defaults = + element: 'graph' + data: [{x: 'foo', y: 2, z: 3}, {x: 'bar', y: 4, z: 6}] + xkey: 'x' + ykeys: ['y', 'z'] + labels: ['Y', 'Z'] + barColors: [ '#0b62a4', '#7a92a3'] + gridLineColor: '#aaa' + gridStrokeWidth: 0.5 + gridTextColor: '#888' + gridTextSize: 12 + verticalGridCondition: (index) -> index % 2 + verticalGridColor: '#888888' + verticalGridOpacity: '0.2' + + describe 'svg structure', -> + it 'should contain extra rectangles for vertical grid', -> + $('#graph').css('height', '250px').css('width', '800px') + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect").size().should.equal 6 + + describe 'svg attributes', -> + it 'should have to bars with verticalGrid.color', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect[fill='#{defaults.verticalGridColor}']").size().should.equal 2 + it 'should have to bars with verticalGrid.color', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect[fill-opacity='#{defaults.verticalGridOpacity}']").size().should.equal 2 + + describe 'svg structure', -> + defaults = + element: 'graph' + data: [{x: 'foo', y: 2, z: 3}, {x: 'bar', y: 4, z: 6}] + xkey: 'x' + ykeys: ['y', 'z'] + labels: ['Y', 'Z'] + + it 'should contain a rect for each bar', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect").size().should.equal 4 + + it 'should contain 5 grid lines', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("path").size().should.equal 5 + + it 'should contain 7 text elements', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("text").size().should.equal 7 + + describe 'svg attributes', -> + defaults = + element: 'graph' + data: [{x: 'foo', y: 2, z: 3}, {x: 'bar', y: 4, z: 6}] + xkey: 'x' + ykeys: ['y', 'z'] + labels: ['Y', 'Z'] + barColors: [ '#0b62a4', '#7a92a3'] + gridLineColor: '#aaa' + gridStrokeWidth: 0.5 + gridTextColor: '#888' + gridTextSize: 12 + + it 'should have a bar with the first default color', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect[fill='#0b62a4']").size().should.equal 2 + + it 'should have a bar with no stroke', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect[stroke='none']").size().should.equal 4 + + it 'should have text with configured fill color', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("text[fill='#888888']").size().should.equal 7 + + it 'should have text with configured font size', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("text[font-size='12px']").size().should.equal 7 + + describe 'when setting bar radius', -> + describe 'svg structure', -> + defaults = + element: 'graph' + data: [{x: 'foo', y: 2, z: 3}, {x: 'bar', y: 4, z: 6}] + xkey: 'x' + ykeys: ['y', 'z'] + labels: ['Y', 'Z'] + barRadius: [5, 5, 0, 0] + + it 'should contain a path for each bar', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("path").size().should.equal 9 + + it 'should use rects if radius is too big', -> + delete defaults.barStyle + chart = Morris.Bar $.extend {}, defaults, + barRadius: [300, 300, 0, 0] + $('#graph').find("rect").size().should.equal 4 + + describe 'barSize option', -> + describe 'svg attributes', -> + defaults = + element: 'graph' + barSize: 20 + data: [ + {x: '2011 Q1', y: 3, z: 2, a: 3} + {x: '2011 Q2', y: 2, z: null, a: 1} + {x: '2011 Q3', y: 0, z: 2, a: 4} + {x: '2011 Q4', y: 2, z: 4, a: 3} + ], + xkey: 'x' + ykeys: ['y', 'z', 'a'] + labels: ['Y', 'Z', 'A'] + + it 'should calc the width if too narrow for barSize', -> + $('#graph').width('200px') + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect").filter((i) -> + parseFloat($(@).attr('width'), 10) < 10 + ).size().should.equal 11 + + it 'should set width to @options.barSize if possible', -> + chart = Morris.Bar $.extend {}, defaults + $('#graph').find("rect[width='#{defaults.barSize}']").size().should.equal 11 + + diff --git a/public/bower_components/morris.js/spec/lib/bar/colours.coffee b/public/bower_components/morris.js/spec/lib/bar/colours.coffee new file mode 100644 index 0000000..ebe5469 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/bar/colours.coffee @@ -0,0 +1,36 @@ +describe 'Morris.Bar#colorFor', -> + + defaults = + element: 'graph' + data: [{x: 'foo', y: 2, z: 3}, {x: 'bar', y: 4, z: 6}] + xkey: 'x' + ykeys: ['y', 'z'] + labels: ['Y', 'Z'] + + it 'should fetch colours from an array', -> + chart = Morris.Bar $.extend {}, defaults, barColors: ['#f00', '#0f0', '#00f'] + chart.colorFor(chart.data[0], 0, 'bar').should.equal '#f00' + chart.colorFor(chart.data[0], 0, 'hover').should.equal '#f00' + chart.colorFor(chart.data[0], 1, 'bar').should.equal '#0f0' + chart.colorFor(chart.data[0], 1, 'hover').should.equal '#0f0' + chart.colorFor(chart.data[0], 2, 'bar').should.equal '#00f' + chart.colorFor(chart.data[0], 2, 'hover').should.equal '#00f' + chart.colorFor(chart.data[0], 3, 'bar').should.equal '#f00' + chart.colorFor(chart.data[0], 4, 'hover').should.equal '#0f0' + + it 'should defer to a callback', -> + stub = sinon.stub().returns '#f00' + chart = Morris.Bar $.extend {}, defaults, barColors: stub + stub.reset() + + chart.colorFor(chart.data[0], 0, 'bar') + stub.should.have.been.calledWith( + {x:0, y:2, label:'foo'}, + {index:0, key:'y', label:'Y'}, + 'bar') + + chart.colorFor(chart.data[0], 1, 'hover') + stub.should.have.been.calledWith( + {x:0, y:3, label:'foo'}, + {index:1, key:'z', label:'Z'}, + 'hover') diff --git a/public/bower_components/morris.js/spec/lib/commas_spec.coffee b/public/bower_components/morris.js/spec/lib/commas_spec.coffee new file mode 100644 index 0000000..9c14887 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/commas_spec.coffee @@ -0,0 +1,38 @@ +describe '#commas', -> + + it 'should insert commas into long numbers', -> + # zero + Morris.commas(0).should.equal("0") + + # positive integers + Morris.commas(1).should.equal("1") + Morris.commas(12).should.equal("12") + Morris.commas(123).should.equal("123") + Morris.commas(1234).should.equal("1,234") + Morris.commas(12345).should.equal("12,345") + Morris.commas(123456).should.equal("123,456") + Morris.commas(1234567).should.equal("1,234,567") + + # negative integers + Morris.commas(-1).should.equal("-1") + Morris.commas(-12).should.equal("-12") + Morris.commas(-123).should.equal("-123") + Morris.commas(-1234).should.equal("-1,234") + Morris.commas(-12345).should.equal("-12,345") + Morris.commas(-123456).should.equal("-123,456") + Morris.commas(-1234567).should.equal("-1,234,567") + + # positive decimals + Morris.commas(1.2).should.equal("1.2") + Morris.commas(12.34).should.equal("12.34") + Morris.commas(123.456).should.equal("123.456") + Morris.commas(1234.56).should.equal("1,234.56") + + # negative decimals + Morris.commas(-1.2).should.equal("-1.2") + Morris.commas(-12.34).should.equal("-12.34") + Morris.commas(-123.456).should.equal("-123.456") + Morris.commas(-1234.56).should.equal("-1,234.56") + + # null + Morris.commas(null).should.equal('-') diff --git a/public/bower_components/morris.js/spec/lib/donut/donut_spec.coffee b/public/bower_components/morris.js/spec/lib/donut/donut_spec.coffee new file mode 100644 index 0000000..d8313f9 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/donut/donut_spec.coffee @@ -0,0 +1,76 @@ +describe 'Morris.Donut', -> + + describe 'svg structure', -> + defaults = + element: 'graph' + data: [ {label: 'Jam', value: 25 }, + {label: 'Frosted', value: 40 }, + {label: 'Custard', value: 25 }, + {label: 'Sugar', value: 10 } ] + formatter: (y) -> "#{y}%" + + it 'should contain 2 paths for each segment', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("path").size().should.equal 8 + + it 'should contain 2 text elements for the label', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("text").size().should.equal 2 + + describe 'svg attributes', -> + defaults = + element: 'graph' + data: [ {label: 'Jam', value: 25 }, + {label: 'Frosted', value: 40 }, + {label: 'Custard', value: 25 }, + {label: 'Sugar', value: 10 } ] + formatter: (y) -> "#{y}%" + colors: [ '#0B62A4', '#3980B5', '#679DC6', '#95BBD7'] + + it 'should have a label with font size 15', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("text[font-size='15px']").size().should.equal 1 + + it 'should have a label with font size 14', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("text[font-size='14px']").size().should.equal 1 + + it 'should have a label with font-weight 800', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("text[font-weight='800']").size().should.equal 1 + + it 'should have 1 paths with fill of first color', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("path[fill='#0b62a4']").size().should.equal 1 + + it 'should have 1 paths with stroke of first color', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("path[stroke='#0b62a4']").size().should.equal 1 + + it 'should have a path with white stroke', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("path[stroke='#ffffff']").size().should.equal 4 + + it 'should have a path with stroke-width 3', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("path[stroke-width='3']").size().should.equal 4 + + it 'should have a path with stroke-width 2', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("path[stroke-width='2']").size().should.equal 4 + + describe 'setData', -> + defaults = + element: 'graph' + data: [ {label: 'One', value: 25 }, {label: "Two", value: 30} ] + colors: ['#ff0000', '#00ff00', '#0000ff'] + + it 'should update the chart', -> + chart = Morris.Donut $.extend {}, defaults + $('#graph').find("path[stroke='#0000ff']").size().should.equal 0 + chart.setData [ + { label: 'One', value: 25 } + { label: 'Two', value: 30 } + { label: 'Three', value: 35 } + ] + $('#graph').find("path[stroke='#0000ff']").size().should.equal 1 diff --git a/public/bower_components/morris.js/spec/lib/grid/auto_grid_lines_spec.coffee b/public/bower_components/morris.js/spec/lib/grid/auto_grid_lines_spec.coffee new file mode 100644 index 0000000..2312fe2 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/grid/auto_grid_lines_spec.coffee @@ -0,0 +1,25 @@ +describe 'Morris.Grid#autoGridLines', -> + + beforeEach -> + @subject = Morris.Grid.prototype.autoGridLines + + it 'should draw at fixed intervals', -> + @subject(0, 4, 5).should.deep.equal [0, 1, 2, 3, 4] + @subject(0, 400, 5).should.deep.equal [0, 100, 200, 300, 400] + + it 'should pick intervals that show significant numbers', -> + @subject(102, 499, 5).should.deep.equal [100, 200, 300, 400, 500] + + it 'should draw zero when it falls within [ymin..ymax]', -> + @subject(-100, 300, 5).should.deep.equal [-100, 0, 100, 200, 300] + @subject(-50, 350, 5).should.deep.equal [-125, 0, 125, 250, 375] + @subject(-400, 400, 5).should.deep.equal [-400, -200, 0, 200, 400] + @subject(100, 500, 5).should.deep.equal [100, 200, 300, 400, 500] + @subject(-500, -100, 5).should.deep.equal [-500, -400, -300, -200, -100] + + it 'should generate decimal labels to 2 significant figures', -> + @subject(0, 1, 5).should.deep.equal [0, 0.25, 0.5, 0.75, 1] + @subject(0.1, 0.5, 5).should.deep.equal [0.1, 0.2, 0.3, 0.4, 0.5] + + it 'should use integer intervals for intervals larger than 1', -> + @subject(0, 9, 5).should.deep.equal [0, 3, 6, 9, 12] diff --git a/public/bower_components/morris.js/spec/lib/grid/set_data_spec.coffee b/public/bower_components/morris.js/spec/lib/grid/set_data_spec.coffee new file mode 100644 index 0000000..50450d7 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/grid/set_data_spec.coffee @@ -0,0 +1,208 @@ +describe 'Morris.Grid#setData', -> + + it 'should not alter user-supplied data', -> + my_data = [{x: 1, y: 1}, {x: 2, y: 2}] + expected_data = [{x: 1, y: 1}, {x: 2, y: 2}] + Morris.Line + element: 'graph' + data: my_data + xkey: 'x' + ykeys: ['y'] + labels: ['dontcare'] + my_data.should.deep.equal expected_data + + describe 'ymin/ymax', -> + beforeEach -> + @defaults = + element: 'graph' + xkey: 'x' + ykeys: ['y', 'z'] + labels: ['y', 'z'] + + it 'should use a user-specified minimum and maximum value', -> + line = Morris.Line $.extend @defaults, + data: [{x: 1, y: 1}] + ymin: 10 + ymax: 20 + line.ymin.should.equal 10 + line.ymax.should.equal 20 + + describe 'auto', -> + + it 'should automatically calculate the minimum and maximum value', -> + line = Morris.Line $.extend @defaults, + data: [{x: 1, y: 10}, {x: 2, y: 15}, {x: 3, y: null}, {x: 4}] + ymin: 'auto' + ymax: 'auto' + line.ymin.should.equal 10 + line.ymax.should.equal 15 + + it 'should automatically calculate the minimum and maximum value given no y data', -> + line = Morris.Line $.extend @defaults, + data: [{x: 1}, {x: 2}, {x: 3}, {x: 4}] + ymin: 'auto' + ymax: 'auto' + line.ymin.should.equal 0 + line.ymax.should.equal 1 + + describe 'auto [n]', -> + + it 'should automatically calculate the minimum and maximum value', -> + line = Morris.Line $.extend @defaults, + data: [{x: 1, y: 10}, {x: 2, y: 15}, {x: 3, y: null}, {x: 4}] + ymin: 'auto 11' + ymax: 'auto 13' + line.ymin.should.equal 10 + line.ymax.should.equal 15 + + it 'should automatically calculate the minimum and maximum value given no data', -> + line = Morris.Line $.extend @defaults, + data: [{x: 1}, {x: 2}, {x: 3}, {x: 4}] + ymin: 'auto 11' + ymax: 'auto 13' + line.ymin.should.equal 11 + line.ymax.should.equal 13 + + it 'should use a user-specified minimum and maximum value', -> + line = Morris.Line $.extend @defaults, + data: [{x: 1, y: 10}, {x: 2, y: 15}, {x: 3, y: null}, {x: 4}] + ymin: 'auto 5' + ymax: 'auto 20' + line.ymin.should.equal 5 + line.ymax.should.equal 20 + + it 'should use a user-specified minimum and maximum value given no data', -> + line = Morris.Line $.extend @defaults, + data: [{x: 1}, {x: 2}, {x: 3}, {x: 4}] + ymin: 'auto 5' + ymax: 'auto 20' + line.ymin.should.equal 5 + line.ymax.should.equal 20 + + describe 'xmin/xmax', -> + + it 'should calculate the horizontal range', -> + line = Morris.Line + element: 'graph' + data: [{x: 2, y: 2}, {x: 1, y: 1}, {x: 4, y: 4}, {x: 3, y: 3}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.xmin.should == 1 + line.xmax.should == 4 + + it "should pad the range if there's only one data point", -> + line = Morris.Line + element: 'graph' + data: [{x: 2, y: 2}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.xmin.should == 1 + line.xmax.should == 3 + + describe 'sorting', -> + + it 'should sort data when parseTime is true', -> + line = Morris.Line + element: 'graph' + data: [ + {x: '2012 Q1', y: 2}, + {x: '2012 Q3', y: 1}, + {x: '2012 Q4', y: 4}, + {x: '2012 Q2', y: 3}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.data.map((row) -> row.label).should.deep.equal ['2012 Q1', '2012 Q2', '2012 Q3', '2012 Q4'] + + it 'should not sort data when parseTime is false', -> + line = Morris.Line + element: 'graph' + data: [{x: 1, y: 2}, {x: 4, y: 1}, {x: 3, y: 4}, {x: 2, y: 3}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + parseTime: false + line.data.map((row) -> row.label).should.deep.equal [1, 4, 3, 2] + + describe 'timestamp data', -> + + it 'should generate default labels for timestamp x-values', -> + d = [ + new Date 2012, 0, 1 + new Date 2012, 0, 2 + new Date 2012, 0, 3 + new Date 2012, 0, 4 + ] + line = Morris.Line + element: 'graph' + data: [ + {x: d[0].getTime(), y: 2}, + {x: d[1].getTime(), y: 1}, + {x: d[2].getTime(), y: 4}, + {x: d[3].getTime(), y: 3}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.data.map((row) -> row.label).should.deep.equal d.map((t) -> t.toString()) + + it 'should use a user-supplied formatter for labels', -> + line = Morris.Line + element: 'graph' + data: [ + {x: new Date(2012, 0, 1).getTime(), y: 2}, + {x: new Date(2012, 0, 2).getTime(), y: 1}, + {x: new Date(2012, 0, 3).getTime(), y: 4}, + {x: new Date(2012, 0, 4).getTime(), y: 3}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + dateFormat: (ts) -> + date = new Date(ts) + "#{date.getFullYear()}-#{date.getMonth()+1}-#{date.getDate()}" + line.data.map((row) -> row.label).should.deep.equal ['2012-1-1', '2012-1-2', '2012-1-3', '2012-1-4'] + + it 'should parse y-values in strings', -> + line = Morris.Line + element: 'graph' + data: [{x: 2, y: '12'}, {x: 1, y: '13.5'}, {x: 4, y: '14'}, {x: 3, y: '16'}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.ymin.should == 12 + line.ymax.should == 16 + line.data.map((row) -> row.y).should.deep.equal [[13.5], [12], [16], [14]] + + it 'should clear the chart when empty data is supplied', -> + line = Morris.Line + element: 'graph', + data: [{x: 2, y: '12'}, {x: 1, y: '13.5'}, {x: 4, y: '14'}, {x: 3, y: '16'}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.data.length.should.equal 4 + line.setData([]) + line.data.length.should.equal 0 + line.setData([{x: 2, y: '12'}, {x: 1, y: '13.5'}, {x: 4, y: '14'}, {x: 3, y: '16'}]) + line.data.length.should.equal 4 + + it 'should be able to add data if the chart is initialised with empty data', -> + line = Morris.Line + element: 'graph', + data: [] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.data.length.should.equal 0 + line.setData([{x: 2, y: '12'}, {x: 1, y: '13.5'}, {x: 4, y: '14'}, {x: 3, y: '16'}]) + line.data.length.should.equal 4 + + it 'should automatically choose significant numbers for y-labels', -> + line = Morris.Line + element: 'graph', + data: [{x: 1, y: 0}, {x: 2, y: 3600}] + xkey: 'x' + ykeys: ['y'] + labels: ['y'] + line.grid.should == [0, 1000, 2000, 3000, 4000] diff --git a/public/bower_components/morris.js/spec/lib/grid/y_label_format_spec.coffee b/public/bower_components/morris.js/spec/lib/grid/y_label_format_spec.coffee new file mode 100644 index 0000000..e074230 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/grid/y_label_format_spec.coffee @@ -0,0 +1,15 @@ +describe 'Morris.Grid#yLabelFormat', -> + + it 'should use custom formatter for y labels', -> + formatter = (label) -> + flabel = parseFloat(label) / 1000 + "#{flabel.toFixed(1)}k" + line = Morris.Line + element: 'graph' + data: [{x: 1, y: 1500}, {x: 2, y: 2500}] + xkey: 'x' + ykeys: ['y'] + labels: ['dontcare'] + preUnits: "$" + yLabelFormat: formatter + line.yLabelFormat(1500).should.equal "1.5k" diff --git a/public/bower_components/morris.js/spec/lib/hover_spec.coffee b/public/bower_components/morris.js/spec/lib/hover_spec.coffee new file mode 100644 index 0000000..868f1a3 --- /dev/null +++ b/public/bower_components/morris.js/spec/lib/hover_spec.coffee @@ -0,0 +1,64 @@ +describe "Morris.Hover", -> + + describe "with dummy content", -> + + beforeEach -> + parent = $('
') + .appendTo($('#test')) + @hover = new Morris.Hover(parent: parent) + @element = $('#test .morris-hover') + + it "should initialise a hidden, empty popup", -> + @element.should.exist + @element.should.be.hidden + @element.should.be.empty + + describe "#show", -> + it "should show the popup", -> + @hover.show() + @element.should.be.visible + + describe "#hide", -> + it "should hide the popup", -> + @hover.show() + @hover.hide() + @element.should.be.hidden + + describe "#html", -> + it "should replace the contents of the element", -> + @hover.html('