Skip to content

Instantly share code, notes, and snippets.

@ESeufert
Last active December 16, 2015 18:49
Show Gist options
  • Save ESeufert/5480375 to your computer and use it in GitHub Desktop.
Save ESeufert/5480375 to your computer and use it in GitHub Desktop.
<html>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<head>
<title>Comparison -- Mobile Handset Manufacturers and Platforms, Q1 2013 and Q1 2013</title>
<link href="http://nvd3.org/src/nv.d3.css" rel="stylesheet">
<link href="http://nvd3.org/css/common.css" rel="stylesheet">
<link href="http://nvd3.org/css/syntax.css" rel="stylesheet">
<script type="text/javascript" src="http://d3js.org/d3.v2.js"></script>
<script type="text/javascript" src="http://nvd3.org/nv.d3.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"></script>
<script>
nv.addGraph(function() {
var data =
[
{
key: "Other",
values:
[
{ x : "Q1 2012", y : 37.7 },
{ x : "Q1 2013", y : 36.4 }
]
},
{
key: "Samsung",
values:
[
{ x : "Q1 2012", y : 28.8 },
{ x : "Q1 2013", y : 32.7 }
]
},
{
key: "Apple",
values:
[
{ x : "Q1 2012", y : 23 },
{ x : "Q1 2013", y : 17.3 }
]
},
{
key: "LG",
values:
[
{ x : "Q1 2012", y : 3.2 },
{ x : "Q1 2013", y : 4.8 }
]
},
{
key: "Huawei",
values:
[
{ x : "Q1 2012", y : 3.3 },
{ x : "Q1 2013", y : 4.6 }
]
},
{
key: "ZTE",
values:
[
{ x : "Q1 2012", y : 4 },
{ x : "Q1 2013", y : 4.2 }
]
}
];
var chart = nv.models.multiBarChart();
d3.select('#chart1 svg').datum(data)
.transition().duration(500).call(chart);
});
nv.addGraph(function() {
var data =
[
{
"key" : "Global Smartphone Shipment Marketshare by Manufacturer, Q1 2013",
"values" :
[
{
"label" : "Other" ,
"value" : 36.4
},
{
"label" : "Samsung" ,
"value" : 32.7
},
{
"label" : "Apple" ,
"value" : 17.3
},
{
"label" : "LG" ,
"value" : 4.8
},
{
"label" : "Huawei" ,
"value" : 4.6
},
{
"label" : "ZTE" ,
"value" : 4.2
}
]
}
];
var chart = nv.models.pieChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.showLabels(true);
d3.select("#chart2 svg")
.datum(data)
.transition().duration(1200)
.call(chart);
return chart;
});
nv.addGraph(function() {
var data =
[
{
"key" : "Global Smartphone Shipment Marketshare Delta, Q1 2012 vs. Q1 2013",
"values" :
[
{
"label" : "Other" ,
"value" : -1.3
},
{
"label" : "Samsung" ,
"value" : 3.9
},
{
"label" : "Apple" ,
"value" : -5.7
},
{
"label" : "LG" ,
"value" : 1.6
},
{
"label" : "Huawei" ,
"value" : 1.3
},
{
"label" : "ZTE" ,
"value" : 0.2
}
]
}
];
var chart = nv.models.discreteBarChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.staggerLabels(true)
.tooltips(true)
.showValues(true);
d3.select('#chart3 svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
nv.addGraph(function() {
var data =
[
{
"key" : "Global Mobile Operating System Marketshare, Q1 2013",
"values" :
[
{
"label" : "Android" ,
"value" : 49.3
},
{
"label" : "iOS" ,
"value" : 43.7
},
{
"label" : "Windows" ,
"value" : 5.6
},
{
"label" : "RIM" ,
"value" : 0.9
},
{
"label" : "Other" ,
"value" : 0.5
}
]
}
];
var chart = nv.models.pieChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.showLabels(true);
d3.select("#chart4 svg")
.datum(data)
.transition().duration(1200)
.call(chart);
return chart;
});
nv.addGraph(function() {
var data =
[
{
"key" : "Global Mobile Operating System Marketshare Delta, Q1 2012 vs. Q1 2013",
"values" :
[
{
"label" : "Android" ,
"value" : 1.4
},
{
"label" : "iOS" ,
"value" : -0.9
},
{
"label" : "Windows" ,
"value" : 1.9
},
{
"label" : "RIM" ,
"value" : -1.7
},
{
"label" : "Other" ,
"value" : -0.6
}
]
}
];
var chart = nv.models.discreteBarChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.staggerLabels(true)
.tooltips(true)
.showValues(true);
d3.select('#chart5 svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
</script>
</head>
<body>
<h3>Global Smartphone Shipment Marketshare by Manufacturer</h3>
<div id="chart1" style="width:500px; height:300px;">
<svg></svg>
</div>
<h3>Global Smartphone Shipment Marketshare Delta, Q1 2012 vs. Q1 2013</h3>
<div id="chart3" style="width:500px; height:300px;">
<svg></svg>
</div>
<h3>Global Mobile Phone Operating System Marketshare, Q1 2013</h3>
<div id="chart4" style="width:500px; height:300px;">
<svg></svg>
</div>
<h3>Global Mobile Phone Operating System Marketshare Delta, Q1 2012 vs. Q1 2013</h3>
<div id="chart5" style="width:500px; height:300px;">
<svg></svg>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment