小编MDT*_*MDT的帖子

柱形图:如何在水平轴上显示所有标签

我一直试图在我的图表的水平轴上显示所有标签,但我无法做到这一点!

我尝试使用hAxis.showTextEvery = 1但不起作用

(请参阅https://developers.google.com/chart/interactive/docs/gallery/columnchart).

在此输入图像描述

基本上,我还想显示上图中目前缺少的数字"5","7"和"9".

这里是JavaScript代码,非常感谢.

<script type="text/javascript">
 google.setOnLoadCallback(drawChart1);
 function drawChart1(){
     var data = new google.visualization.DataTable(
     {
        "cols":[
            {"id":"","label":"ratings","type":"number"},
            {"id":"","label":"# of movies","type":"number"}],
            "rows":[
                {"c":[{"v":9},{"v":26}]},
                {"c":[{"v":8},{"v":64}]},
                {"c":[{"v":10},{"v":5}]},
                {"c":[{"v":7},{"v":50}]},
                {"c":[{"v":6},{"v":38}]},
                {"c":[{"v":5},{"v":10}]},
                {"c":[{"v":2},{"v":1}]},
                {"c":[{"v":4},{"v":1}]}
            ]});

     var options = {
        "title":"Rating distribution",
        "vAxis":{"title":"# of movies","minValue":0},
        "hAxis":{"title":"Ratings","maxValue":10},"legend":"none","is3D":true,"width":800,"height":400,"colors":["red"]
     };
     var chart = new google.visualization.ColumnChart(document.getElementById('chart_movies_per_rating'));chart.draw(data, options);
 }
 </script> 
Run Code Online (Sandbox Code Playgroud)

更新: 这是我开发的解决方案,遵循以下答案(再次感谢!). http://jsfiddle.net/mdt86/x8dafm9u/104/

<script type="text/javascript">
google.setOnLoadCallback(drawChart1); 
function drawChart1(){ 
var data = new google.visualization.DataTable( 
     {"cols": 
        [{"id":"","label":"ratings","type":"string"},
        {"id":"","label":"# of movies","type":"number"}], 
             "rows":
             [{"c":[{"v":"0"},{"v":0}]},
             {"c":[{"v":" 1"},{"v":0}]},
             {"c":[{"v":" …
Run Code Online (Sandbox Code Playgroud)

google-visualization

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

如何在分配给问题的标签更改时获取电子邮件通知

每次发布新评论时,我都会收到(电子邮件)通知.

有没有办法在每次更改分配给问题的标签时收到通知?例如,如果用户分配新标签,用户是否删除现有标签等.

谢谢.

github

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

要洗牌的键值(整数,字符串)列表的最佳结构

我需要在Java中实现一个键值列表(类型为Integer-String)的结构,我想要将其洗牌.

基本上,我想做那样的事情.

    public LinkedHashMap<Integer, String> getQuestionOptionsMap(){

    LinkedHashMap<Integer, String>  shuffle = new LinkedHashMap<Integer, String> ();

    if (answer1 != null)
        shuffle.put(new Integer(1), answer1);
    if (answer2 != null)
        shuffle.put(new Integer(2), answer2);
    if (answer3 != null)
        shuffle.put(new Integer(3), answer3);
    if (answer4 != null) 
        shuffle.put(new Integer(4), answer4);

    Collections.shuffle(shuffle);
    return shuffle;
}
Run Code Online (Sandbox Code Playgroud)

但是,HashMap不能被洗牌.

我可以从hashmap中随机获取一个键,然后返回链接的元素,但我确信这不是我问题的最佳解决方案.

有没有更好的方法?

提前致谢.

java shuffle hashtable hashmap linkedhashmap

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

Angular JS:ng-repeat with dynamic ng-model

我有这个工作的是重复多次的代码块,因此会为NG-重复循环是巨大的.例如,我的代码的两个实例如下.

    <div>
        <input type="text" ng-model="searchParamaters.userName" placeholder="User Name"/>
        <i class="fa fa-times" ng-click="resetSearchField(filterParamDisplay[0].param)" ng-show="showParam(filterParamDisplay[0].param)"></i>
    </div>
    <div>
        <input type="text" ng-model="searchParamaters.userEmail" placeholder="User Email"/>
        <i class="fa fa-times" ng-click="resetSearchField(filterParamDisplay[1].param)" ng-show="showParam(filterParamDisplay[1].param)"></i>
    </div>
Run Code Online (Sandbox Code Playgroud)

这是Javascript中的filterParamDisplay数组:

    $scope.filterParamDisplay = [
        {param: 'userName', displayName: 'User Name'},
        {param: 'userEmail', displayName: 'User Email'}
    ];
Run Code Online (Sandbox Code Playgroud)

我一直在尝试将其转换为ng-repeat循环,但到目前为止还没有成功.这就是我编码的内容.

    <div ng-repeat="param in filterParamDisplay">
        <input type="text" ng-model="searchParams[{{param}}]" placeholder="{{param.displayName}}"/>
        <i class="fa fa-times" ng-click="resetSearchField(filterParamDisplay[$index].param)" ng-show="showParam(filterParamDisplay[$index].param)"></i>
    </div>
Run Code Online (Sandbox Code Playgroud)

问题是上面的ng-model变量,以及ng-click和ng-show中的$ index.不确定是否可以这样做,非常感谢任何帮助,谢谢!


更新:感谢所有的答案,使用

     <div ng-repeat="p in filterParamDisplay">
...
   ng-model="searchParams[p]" 
Run Code Online (Sandbox Code Playgroud)

效果很好!

仍然在使用$ index无法正常工作的showParam和resetSearchField函数上挣扎.这是我的代码.

    $scope.searchParams = $state.current.data.defaultSearchParams;

    $scope.resetSearchField = function (searchParam) {
        $scope.searchParams[searchParam] = ''; …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-ng-repeat angular-ngmodel

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

Google 图表:ColumnChart 中的换行标题

我想将 ColumnChart 中的标题分成 2 行(或更多行)。

(请参阅https://developers.google.com/chart/interactive/docs/gallery/columnchart

我尝试使用管道(“|”)符号,如下所示,但它不起作用,“\n”也不起作用。

var options = {"title":"My first line | \n this should be the second line!"};
Run Code Online (Sandbox Code Playgroud)

感谢您的关注!

google-visualization

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

Android:如何在Crouton onDisplayed()上使用回调

我想开始一项新的活动,但仅在我的Crouton展示之后.

我想使用Crouton的onDisplayed()函数 https://github.com/keyboardsurfer/Crouton/blob/master/library/src/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java

然后按如下方式调用我的活动

Intent i = new Intent(this, MyNewActivity.class);
startActivity(i);
finish();
Run Code Online (Sandbox Code Playgroud)

我一直在尝试创建我的回调函数,但到目前为止没有运气...

谢谢!

java android callback android-lifecycle crouton

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