我使用的是anuglar-nvd3,无法找到有关API的任何文档。我现在面临的问题是如何设置最大值和最大值? xAxis和yAxis上的最小值。
换句话说,无论数据如何,轴的最小值为-1,最大值为1。
Plunker:http://plnkr.co/edit/LKt3UJe5PnJOf8uQEwxr?p=preview
代码:
var app = angular.module('plunker', ['nvd3']);
app.controller('MainCtrl', function($scope) {
$scope.options = {
chart: {
type: 'scatterChart',
height: 450,
color: d3.scale.category10().range(),
scatter: {
onlyCircles: false
},
showDistX: true,
showDistY: true,
tooltipContent: function(key) {
return '<h3>' + key + '</h3>';
},
duration: 350,
xAxis: {
scale: [0,5],
axisLabel: 'X Axis',
tickFormat: function(d){
return d3.format('.02f')(d);
}
},
yAxis: {
axisLabel: 'Y Axis',
tickFormat: function(d){
return d3.format('.02f')(d);
},
axisLabelDistance: -5
},
zoom: {
//NOTE: All attributes below are optional
enabled: false,
scaleExtent: [1, 10],
useFixedDomain: false,
useNiceScale: false,
horizontalOff: false,
verticalOff: false,
unzoomEventType: 'dblclick.zoom'
},
margin: {
top: 100,
right: 100,
left: 100,
bottom: 100
}
}
};
$scope.data = [
{
"key":"static",
"color":"#fff",
"values":[
{
"x":-1,
"y":-1,
"size":0.0000001,
"shape":"circle",
"series":0
},
{
"x":1,
"y":1,
"size":0.0000001,
"shape":"circle",
"series":0
}
]
},
{
"key":"Group 0",
"color":"#1f77b4",
"values":[
{
"x":-0.5,
"y":-0.5,
"size":0.5,
"shape":"circle",
"series":0
}
]
},
{
"key":"Group 1",
"color":"#ff7f0e",
"values":[
{
"x":-0.5,
"y":0.5,
"size":0.5,
"shape":"circle",
"series":0
}
]
},
{
"key":"Group 2",
"color":"#2ca02c",
"values":[
{
"x":0.5,
"y":-0.5,
"size":0.5,
"shape":"circle",
"series":0
}
]
},
{
"key":"Group 3",
"color":"#d62728",
"values":[
{
"x":0.5,
"y":0.5,
"size":0.5,
"shape":"circle",
"series":0
}
]
}
];
});
答案 0 :(得分:0)
你试过吗
forceY: [-1, 1],
forceX: [-1, 1],