Highcharts对齐绘图点以从y轴开始 [英] Highcharts align plot points to start at y-axis

查看:119
本文介绍了Highcharts对齐绘图点以从y轴开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尽力让图表从图表的绝对左侧开始(偏移,minPadding,startOnTick等)。无论我做什么,我都无法从很远的一边开始。这里是图片的例子:



下面是一个代码示例im JsFiddle,您可以在其中尝试:
http:

以下是一些代码: b

 图表:{
类型:'区域',
高度:'175'
},
图例:false,
plotOptions:{
series:{
events:{
click:function(e){
location.href = e.point.options.url;
}
},
fillColor:{
linearGradient:[0,0,0,300],
stops:[
[0,'rgba (201,241,217,0)'],
[1,'rgba(201,241,217,1)']
]
}
}
},
title:{
text:false
},
xAxis:{
categories:['04 / 17','04 / 17','04 / 17' ,'04 / 18','04 / 19','04 / 19','04 / 20','04 / 20','04 / 21','04 / 21'],
标签: {
align:left
},tickmarkPlacement:'on',
startOnTick:true
},
yAxis:{
title:{
text:false
},
labels:{
formatter:function(){
return'$'+(this.value).formatMoney(0);
},
y:15
},
alternateGridColor:'#f4f8f9',
gridLineColor:'#c4dce2'
},

非常感谢您的帮助!

解决方案 div>

不要使用分类的xAxis,尝试使用或线性或日期时间与labelformatter。
示例:

  xAxis:{
labels:{
formatter:function(){
返回名称[this.value];



其中 names 是类别数组。请参阅: http://jsfiddle.net/9tpao7Lf/


I have tried everything I can to get the chart to start from the absolute left side of the chart (offsets, minPadding, startOnTick, etc.). No matter what I do I can't get it to start from the very far side. Here is picture examples:

Here is a code example im JsFiddle where you can try it: http://jsfiddle.net/agrublev/VDVpu/3/

and here is some of the code:

chart: {
        type: 'area',
        height: '175'
    },
    legend: false,
    plotOptions: {
        series: {
            events: {
                click: function (e) {
                    location.href = e.point.options.url;
                }
            },
            fillColor: {
                linearGradient: [0, 0, 0, 300],
                stops: [
                    [0, 'rgba(201,241,217,0)'],
                    [1, 'rgba(201, 241, 217,1)']
                ]
            }
        }
    },
    title: {
        text: false
    },
    xAxis: {
        categories: ['04/17', '04/17', '04/17', '04/18', '04/19', '04/19', '04/20', '04/20', '04/21', '04/21'],
        labels: {
            align: "left"
        },tickmarkPlacement: 'on',
        startOnTick: true
    },
    yAxis: {
        title: {
            text: false
        },
        labels: {
            formatter: function () {
                return '$' + (this.value).formatMoney(0);
            },
            y: 15
        },
        alternateGridColor: '#f4f8f9',
        gridLineColor: '#c4dce2' 
    },

Would highly appreciate any help!

解决方案

Don't use categorized xAxis, try to use or linear, or datetime, with labelformatter. Example:

xAxis: {
  labels: {
    formatter: function(){
       return names[this.value];
    }
  }
}

where names is array of categories. See: http://jsfiddle.net/9tpao7Lf/

这篇关于Highcharts对齐绘图点以从y轴开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆