简体   繁体   中英

How to reduce the space between yaxis points with highcharts.js?

I have a page where I can put in two timeintervals and after posting these two timeintervals I get the amount of sold tickets between these two dates.

i get back multiple data depending on how far back I go.

My problem:

If I go as far back as to the first insert of the database. I will get a high value of for example 200 tickets and after that I calculate the difference between each row in the database which gives me a chart like this:

在此处输入图片说明

As you see in the image I would like to reduce the space between the y-axis points in order to see the smaller values better.

In the example above I have a bar that is 160 and other bars that are for example 1 or 2 and I can hardly see them on the chart

Code for this:

buildCharts: function (target, chartData, chartEnum) {

    $(target).highcharts({
        chart: {
            type: 'column',
            height: 300,
        },
        title: {
            text: chartEnum.name
        },
        xAxis: {
            type: 'category'
        },
        yAxis: {
            title: {
                text: chartEnum.text
            }
        },
        series: [{
            name: 'SystemInfo',
            showInLegend: false,
            colorByPoint: false,
            data: chartData,
            turboThreshold: chartData.length + 500

        }],
    });
}

How can I reduce space between y-axis points?

Using the "tickInterval" attribute is the easiest way to go about this (see http://api.highcharts.com/highcharts#xAxis.tickInterval ).

If you wanted to set this based upon the total number of tickets you're viewing (assuming from your question that you can choose the point in time you want to start), what you could do is set that tickInterval based on the length of your series data (for example, if the data more than 100 items, set a tickInterval of 4; otherwise, set a tickInterval of 2 or 1). Do this by creating the chart's options, and then changing the value in the options after you grab your data, but before drawing/redrawing the chart.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM