我想加载动态数据并显示圆柱图。静态值图表正常工作,但可变数据无法分配给融合图的值字段。

http://jsfiddle.net/qe5ruLqz/8/

<td >
            <fusioncharts id="chartContainer1" width="371" height="400" type="cylinder" datasource={{Bin1Data}}></fusioncharts>
        </td>
  <script>
            var app = angular.module('myApp', ["ng-fusioncharts"]);
        app.controller('myCtrl', function ($scope, $http) {
            $http.get('https://example.com', {
                headers: { 'Authorization': 'Basic abcd==' }
            })
            .then(function (response) {
                $scope.names = response.data;
                $scope.decodedFrame = atob($scope.names.dataFrame);
                $scope.decodedFrameNew = $scope.decodedFrame.substring(4);
                $scope.distanceinFeet = $scope.decodedFrameNew * 12.5 * 2.54;
                $scope.Value = $scope.distanceinFeet / 148;
                $scope.bin1Value = $scope.Value.toFixed(2);
                $scope.names.timestamp = new Date($scope.names.timestamp).toLocaleString(); // Parse the date to a localized string
                 $scope.Bin1Data.chart.value[0].value = $scope.bin1Value;// assigning value to chart
            });

            $scope.Bin1Data = {
                "chart": {
                    "caption": "Tank 2",
                    "lowerLimit": "0",
                    "upperLimit": "100",
                    "showValue": "1",
                    "valueBelowPivot": "1",
                    "theme": "fint",
                    "width": '50%',
                    "height": '50%',
                    "value":  [{
                        "value": 0 //unble to assign values here
                    }]

               }

            };
        });

最佳答案

您提供有问题的小提琴。我的答案是基于小提琴!

您的分配不正确。您应该将数据传递到$scope.Bin1Data.chart.value

我编辑了您的小提琴以传递动态数据。寻找刷新功能和按钮。我认为这是个好主意:

http://jsfiddle.net/yt1q2v5f/

08-17 13:43
查看更多