Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在海图中设置负轴间隔_Javascript_Angular_Highcharts_Angular Highcharts - Fatal编程技术网

Javascript 如何在海图中设置负轴间隔

Javascript 如何在海图中设置负轴间隔,javascript,angular,highcharts,angular-highcharts,Javascript,Angular,Highcharts,Angular Highcharts,我想以不同的方式设置负轴和正轴的间隔,就像我的数据在正轴上有大约4000000的值,在负轴上有-2,-5,-10…等等,这些值都是动态的 除了打勾定位器外,最好的方法是什么?还是用滴答定位器 使用角度的Highcharts可以使用两个y轴,并根据值将序列指定给相应的y轴 yAxis: [{ height: '50%', min: 0 }, { top: '50%', height: '50%', of

我想以不同的方式设置负轴和正轴的间隔,就像我的数据在正轴上有大约4000000的值,在负轴上有-2,-5,-10…等等,这些值都是动态的

除了打勾定位器外,最好的方法是什么?还是用滴答定位器


使用角度的Highcharts

可以使用两个y轴,并根据值将序列指定给相应的y轴

    yAxis: [{
        height: '50%',
        min: 0
    }, {
        top: '50%',
        height: '50%',
        offset: 0,
        max: 0
    }],

    series: [{
        data: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
    }, {
        data: [0, -1, 0, -2, -2, -3, -2, -5, 0, -2],
        yAxis: 1,
    }]

现场演示:

API参考:

我使用的是组合图,四个不同的数据数组串联在一起,每个数组都应该有负值

这是我的图表

这里的代码

export const getAirlinesChartOption=(数据)=>{
让瓦尔;
console.log('data',data)
设tpSegments=data.map((x)=>x.tpSegments);
设amadeusSegments=data.map((x)=>x.amadeusSegments);
设sabreSegments=data.map((x)=>x.sabreSegments);
设lytpSegments=data.map((x)=>x.lytpSegments);
console.log('tpSegments',tpSegments)
console.log('amadeusSegments',amadeusSegments)
console.log('sabreSegments',sabreSegments)
log('lytpSegments',lytpSegments)
常量allValues=[]
tpSegments.map((x,索引)=>{
allValues.push(tpSegments[索引])
allValues.push(数据段[索引])
allValues.push(sabreSegments[索引])
allValues.push(lytpSegments[索引])
})
console.log('allValues',allValues)
const neg=allValues.filter(函数(v){
返回v<0;
}),
pos=所有值。过滤器(功能(v){
返回v>0;
});
设正计数=位置长度;
设negativeCount=neg.length;
设posMax=Math.max(…pos)
设negMax=Math.max(…neg)
控制台日志('pos',pos)
console.log('neg',neg)
console.log('posMax',posMax)
console.log('negMax',negMax)
让sortedPosArray=位置分拣(功能(a,b){
返回a-b;
});
让sortedNegArray=负分拣(功能(a,b){
返回a-b;
});
让tickArray=sortedNegArray.concat(sortedPosArray)
控制台日志('sortedPosArray',sortedPosArray)
控制台日志('sortedNegArray',sortedNegArray)
log('tickArray',tickArray)
console.log('positiveCount',positiveCount)
console.log('negativeCount',negativeCount)
让obj:Highcharts.选项={
学分:{
启用:false,
},
图表:{
键入:“列”,
身高:180,
回流:错误,
},
标题:{
文本:空,
},
图例:{
填充:0,
项目margintop:-15,
项目MarginBottom:-15,
项目悬停样式:{
颜色:#83858e“,
},
项目样式:{
字体大小:“10px”,
颜色:#83858e“,
fontWeight:“轻”,
},
},
xAxis:{
类别:data.map(x=>x.airline),
标签:{
风格:{
颜色:“b6bbc0”,
字体大小:“10px”,
},
},
},
亚克斯:{
gridLineDashStyle:“破折号”,
标签:{
格式化程序:函数(){
如果(this.value>=1000 | | this.value编号(x.tpSegments)),
点宽度:5,
分组填充:0.28,
边界半径:5,
},
{
名称:“1S”,
键入:“列”,
颜色:“5858FA”,
data:data.map(x=>Number(x.sabreSegments)),
点宽度:5,
分组填充:0.28,
边界半径:5,
},
{
名称:“1A”,
键入:“列”,
颜色:“11cdef”,
数据:data.map(x=>Number(x.amadeusSegments)),
点宽度:5,
分组填充:0.28,
边界半径:5,
},
{
键入:“行”,
名称:“LYTP”,
分组:false,
颜色:“000000”,
data:data.map(x=>Number(x.lytpSegments)),
边界半径:5,
点范围:1,
标记:{
符号:“三角形”,
},
},
],
};
返回obj;

};
请参考图表@ppotaczekHi@Ezzah Waseem,感谢您的解释。我认为最好的方法是将数据转换为具有较小差异的值和模拟y轴标签。示例: