我正在尝试使用Angular 4.0的ng2-charts,我想通过使用chart.js来完成同样的事情:
...
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.bundle.min.js"></script>
...
<canvas id="myChart" width="400" height="400"></canvas>
<script>
var ctx = document.getElementById("myChart").getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'horizontalBar',
// The data for our dataset
data: {
labels: ["example1","example2","example3","example4","example5","example6","example7"],
datasets: [{
label: "My First dataset",
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [0, 10, 5, 2, 20, 30, 45]
},{
label: "My second dataset",
backgroundColor: 'rgb(2, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [3, 10, …
Run Code Online (Sandbox Code Playgroud) 在这一刻我有这样的事情
return this._http.get('https://api.github.com/users/' + this.username + '/repos?client_id=' + this.client_id + '&client_secret=' + this.client_secret)
.map(res => res.json());
Run Code Online (Sandbox Code Playgroud)
获取所选用户的存储库列表(不使用 GraphQL)。
除了使用 GraphQL 之外,如何获取问题列表?这是 GitHub API 文档的示例:
query {
repository(owner:"octocat", name:"Hello-World") {
issues(last:20, states:CLOSED) {
edges {
node {
title
url
labels(first:5) {
edges {
node {
name
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何在 Angular 4 中实现它?