提问者:小点点

角nvd3图表-散点和线在同一图形


我想创建一个包含点和线的图表,如下图所示。

我尝试了多图表与类型:'线''条形图',它似乎工作。但是当我指定'散点''行'时,没有散点数据显示出来。

有可能使用角度nvd3进行此操作吗?

非常感谢你的帮助。

这是我的柱塞代码:

var app = angular.module('plunker', ['nvd3']);

app.controller('MainCtrl', function($scope) {
 $scope.options = {
    chart: {
        type: 'multiChart',
        height: 450,
        margin : {
            top: 30,
            right: 60,
            bottom: 50,
            left: 70
        },
        color: d3.scale.category10().range(),
        //useInteractiveGuideline: true,
        transitionDuration: 500,
        xAxis: {
            tickFormat: function(d){
                return d3.format(',f')(d);
            }
        },
        yAxis: {
            tickFormat: function(d){
                return d3.format('.02f')(d);
            }
        }
    }
};    

$scope.data = [
    {
        key: 'X',
        type: 'scatter',
        values: [
            { x: 1, y: 125, size: Math.random(), shape: 'circle' },
            { x: 2, y: 125, size: Math.random(), shape: 'circle' },
            { x: 3, y: 140, size: Math.random(), shape: 'circle' }
        ],
        yAxis: 1
    },
    {
        key: 'Y',
        type: 'bar',
        values: [
            {x:1, y:109, label:'C2.1'},
            {x:2, y:102, label:'C2.2'},
            {x:3, y:105, label:'C2.3'}
        ],
        yAxis: 1
    },
    {
        key: 'Z',
        type: 'line',
        values: [
            { x: 1, y: 115 },
            { x: 2, y: 120 },
            { x: 3, y: 130 }
        ],
        yAxis: 1
    }
];
});

共1个答案

匿名用户

您的代码是正确的,可能是您使用的Angular-nvd3si的版本不正确这是一个正在工作的plunker

相关问题