Last active
January 25, 2016 07:19
-
-
Save suneric1/76fce1d465fe89d236f0 to your computer and use it in GitHub Desktop.
Week2: Two Charts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Model | SalesIn2014 | |
|---|---|---|
| 1/2 Series | 6621 | |
| 3 Series | 87451 | |
| 4 Series | 35583 | |
| 5 Series | 47187 | |
| 6 Series | 7757 | |
| 7 Series | 8648 | |
| X1 | 20217 | |
| X3 | 31029 | |
| X5 | 40933 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Model | SalesIn2015 | |
|---|---|---|
| 1/2 Series | 10877 | |
| 3 Series | 89265 | |
| 4 Series | 40481 | |
| 5 Series | 41177 | |
| 6 Series | 6685 | |
| 7 Series | 8026 | |
| X1 | 12651 | |
| X3 | 28798 | |
| X5 | 48747 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Model | 1/2 Series | 3 Series | 4 Series | 5 Series | 6 Series | 7 Series | X1 | X3 | X5 | |
|---|---|---|---|---|---|---|---|---|---|---|
| SalesIn2014 | 6621 | 87451 | 35583 | 47187 | 7757 | 8648 | 20217 | 31029 | 40933 | |
| SalesIn2015 | 10877 | 89265 | 40481 | 41177 | 6685 | 8026 | 12651 | 28798 | 48747 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
| <title>Week2: Two Charts</title> | |
| <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js"></script> | |
| <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> | |
| <script type="text/javascript" src="https://code.highcharts.com/modules/data.js"></script> | |
| <style> | |
| .hide{ | |
| display: none; | |
| } | |
| .btn{ | |
| margin: auto; | |
| margin-top: 100px; | |
| font-size: 14px; | |
| padding: 14px; | |
| cursor: pointer; | |
| border: none; | |
| color: white; | |
| background-color: #1696d2; | |
| display: block; | |
| line-height: 12px; | |
| text-transform: uppercase; | |
| text-align: center; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="container" style="width: 400px; height: 600px; margin: 0 auto"></div> | |
| <button id="changeYear" class="btn y2014">Show 2015</button> | |
| <div id="container2" style="width: 400px; height: 500px; margin: 0 auto"></div> | |
| <div id="container3" class="hide" style="width: 400px; height: 500px; margin: 0 auto"></div> | |
| </body> | |
| <script type="text/javascript"> | |
| $(function () { | |
| $.get('bmw_data_slope.csv', function(csv) { | |
| $('#container').highcharts({ | |
| chart: { | |
| renderTo:'container', | |
| defaultSeriesType:'line', | |
| marginTop:100 | |
| }, | |
| data: { | |
| csv: csv | |
| }, | |
| title:{ | |
| text:'BMW Sales Change of Different Models<br/>2014 and 2015' | |
| }, | |
| legend:{ | |
| enabled:false | |
| }, | |
| tooltip: { | |
| formatter: function() { | |
| return this.series.name + ': ' + this.y; | |
| } | |
| }, | |
| xAxis: { | |
| opposite:true, | |
| lineColor:'#999', | |
| title:{ | |
| text:'' | |
| }, | |
| labels:{ | |
| style:{ | |
| fontWeight:'bold' | |
| } | |
| } | |
| }, | |
| yAxis: { | |
| gridLineWidth:0, | |
| labels:{ | |
| enabled:true, | |
| style:{ | |
| fontWeight:'bold' | |
| } | |
| }, | |
| title:{ | |
| text:'', | |
| } | |
| }, | |
| plotOptions: { | |
| line:{ | |
| lineWidth:2, | |
| shadow:false, | |
| color:'#666', | |
| marker:{ | |
| radius:2, | |
| symbol: 'circle' | |
| }, | |
| dataLabels:{ | |
| color:'#666', | |
| enabled:true, | |
| align:'right', | |
| x:-5, | |
| y:5, | |
| formatter:function(){ | |
| if(this.x == 0){ | |
| return this.series.name; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| }); | |
| }); | |
| $(function () { | |
| $.get('bmw_data_2014.csv', function(csv) { | |
| $('#container2').highcharts({ | |
| chart: { | |
| renderTo:'container2', | |
| defaultSeriesType:'bar', | |
| marginTop:100 | |
| }, | |
| data: { | |
| csv: csv | |
| }, | |
| title:{ | |
| text:'BMW Sales of Different Models<br/>2014' | |
| }, | |
| legend:{ | |
| enabled:false | |
| }, | |
| tooltip: { | |
| formatter: function() { | |
| return 'Sales in 2014: ' + this.y; | |
| } | |
| }, | |
| xAxis: { | |
| title:{ | |
| text:'' | |
| }, | |
| labels:{ | |
| style:{ | |
| fontWeight:'bold' | |
| } | |
| } | |
| }, | |
| yAxis: { | |
| gridLineWidth:1, | |
| labels:{ | |
| enabled:true, | |
| style:{ | |
| fontWeight:'bold' | |
| } | |
| }, | |
| title:{ | |
| text:'', | |
| } | |
| } | |
| }); | |
| }); | |
| }); | |
| $(function () { | |
| $.get('bmw_data_2015.csv', function(csv) { | |
| $('#container3').highcharts({ | |
| chart: { | |
| renderTo:'container3', | |
| defaultSeriesType:'bar', | |
| marginTop:100 | |
| }, | |
| data: { | |
| csv: csv | |
| }, | |
| title:{ | |
| text:'BMW Sales of Different Models<br/>2015' | |
| }, | |
| legend:{ | |
| enabled:false | |
| }, | |
| tooltip: { | |
| formatter: function() { | |
| return 'Sales in 2015: ' + this.y; | |
| } | |
| }, | |
| xAxis: { | |
| title:{ | |
| text:'' | |
| }, | |
| labels:{ | |
| style:{ | |
| fontWeight:'bold' | |
| } | |
| } | |
| }, | |
| yAxis: { | |
| gridLineWidth:1, | |
| labels:{ | |
| enabled:true, | |
| style:{ | |
| fontWeight:'bold' | |
| } | |
| }, | |
| title:{ | |
| text:'', | |
| } | |
| } | |
| }); | |
| }); | |
| }); | |
| $("#changeYear").click(function() { | |
| console.log("hi"); | |
| if($("#container2").hasClass("hide")){ | |
| $("#container2").removeClass("hide"); | |
| $("#container3").addClass("hide"); | |
| $("#changeYear").html("Show 2015"); | |
| } | |
| else{ | |
| $("#container2").addClass("hide"); | |
| $("#container3").removeClass("hide"); | |
| $("#changeYear").html("Show 2014"); | |
| } | |
| }); | |
| </script> | |
| </html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment