小编ula*_*mir的帖子

Angular-Charts - 饼图,显示每个数据切片内的标签

我正在学习 angular-chart-js 的阶段。我正在尝试使用 angular-chart.js 来绘制饼图。但是我无法找到一种在饼图上显示标签(而不是工具提示)的方法,这些标签描述了每个数据切片。

这是我如何做到的:

angular.module('App').controller('Controller', ['$scope', '$http', '$location', '$window', '$routeParams',
    function($scope, $http, $location, $window) {
        var diskDataJson = {
            "data": [80, 12],
            "labels": [Used space, Free Space],
            "colours": ['#9AB6F0', '#C2D3F6']
        };
    
        $scope.pieDiskData = json;
    }
]);
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<table border="0" width="100%">
  <tr>
    <td style="border-left: 1px solid #0099CC" width="25%">
      <center><span><label ng-bind-html="'load.static.dashboard.system.DUSAGE' | translate"/></span>
      </center>
      <canvas id="pie33" class="chart chart-pie chart-xs ng-isolate-scope" height="120" width="240" data="pieDiskData.data" labels="pieDiskData.labels" colours="pieDiskData.colours" legend="true"></canvas>
    </td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

javascript angularjs chart.js angular-chart

2
推荐指数
1
解决办法
2万
查看次数

摩卡测试模拟功能

我正在测试骨干视图,它具有以下功能:

attachSelect: function(id, route) {
    console.log(id);
    console.log(route);

    this.$(id).select2({
        ajax: {
            url: route,
            dataType: 'json',
            results: function(data) {
                var results = _.map(data, function(item) {
                    return {
                        id: item.id,
                        text: item.title
                    };
                });

                return {
                    results: results
                };
            },
            cache: true
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

我需要重写(模拟)这个功能,看起来像:

attachSelect: function(id, route) {
    console.log(id);
    console.log(route);
}
Run Code Online (Sandbox Code Playgroud)

怎么做 ?

javascript mocha.js backbone.js sinon

2
推荐指数
1
解决办法
8347
查看次数

在地图中使用自定义类作为键

什么方法,如果有的话,做一个自定义类需要为了实现用作一个关键Map

java map

1
推荐指数
1
解决办法
588
查看次数

Javascript - 来自"{"task":"'+ t'"的正则表达式,.*"}"返回整个字符串

我有一个包含JSON任务数组的文件:

目前该文件包含:

[
 {"task":"hey", "checked":"0", "data1":"", "data2":"", "data3":""},
 {"task":"there", "checked":"0", "data1":"jiojoi", "data2":"", "data3":""}
]
Run Code Online (Sandbox Code Playgroud)

我想隔离一个signle任务,所以我使用以下代码:

var taskExp = new RegExp('{"task":"' + taskName + '",.*"}', '');

// Get the task
var task = taskExp.exec(text);
Run Code Online (Sandbox Code Playgroud)

在这种特定情况下,如果taskName = "hey",它返回整个字符串.(2个任务).

如果taskName = "there",没关系.

为什么?提前致谢.

javascript regex json

1
推荐指数
1
解决办法
39
查看次数