最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Highcharts - How to start x axis from an arbitrary value - Stack Overflow

programmeradmin5浏览0评论

I am using [highcharts][1] to plot a graph between a range of values from data base. I want by X Axis values to start from the user input.

For example, if the user wants the values between range 50 and 100, I want my x axis to start from 50.

The range would be of variable size. The size of the data is large so I can't do something like getting all and using min and max for display.

Thanks in advance.

This is my chart object. I have two input fields for user that I use to query the database and return rows in between.

I use multiple type of graphs. The problem is that I have no idea on how to define the start of X axis as 50 if I am getting data from database between 50 and 100. It shows 50 values but start them from 0 upto 50.

I tried min 10 and so. That do start from that value but skips the first 10 or so values.

The input field has id 'lower' and 'upper'.


var options = {
      chart: {
        renderTo: ctn.attr('id'),
        type: $('#graph_type option:selected').val(),
        zoomType: 'x'
      },
      title: {
        text: $('#graph_title').val()
      },
      subtitle: {
          text: "Graph - " + (graph_no + 1)
      },
      xAxis: {

        title: {
           text: $('#x_label').val()
        }
      },
      yAxis: {
        title: {
          text: $('#y_label').val()
        }
      },

      credits: {
        enabled: false
      },
      series: []
    };

I am using [highcharts][1] to plot a graph between a range of values from data base. I want by X Axis values to start from the user input.

For example, if the user wants the values between range 50 and 100, I want my x axis to start from 50.

The range would be of variable size. The size of the data is large so I can't do something like getting all and using min and max for display.

Thanks in advance.

This is my chart object. I have two input fields for user that I use to query the database and return rows in between.

I use multiple type of graphs. The problem is that I have no idea on how to define the start of X axis as 50 if I am getting data from database between 50 and 100. It shows 50 values but start them from 0 upto 50.

I tried min 10 and so. That do start from that value but skips the first 10 or so values.

The input field has id 'lower' and 'upper'.


var options = {
      chart: {
        renderTo: ctn.attr('id'),
        type: $('#graph_type option:selected').val(),
        zoomType: 'x'
      },
      title: {
        text: $('#graph_title').val()
      },
      subtitle: {
          text: "Graph - " + (graph_no + 1)
      },
      xAxis: {

        title: {
           text: $('#x_label').val()
        }
      },
      yAxis: {
        title: {
          text: $('#y_label').val()
        }
      },

      credits: {
        enabled: false
      },
      series: []
    };
Share Improve this question edited Dec 4, 2012 at 0:55 L Lawliet asked Dec 3, 2012 at 23:47 L LawlietL Lawliet 2,6354 gold badges28 silver badges36 bronze badges 2
  • 1 You should show us what you've already tried. – Nathaniel Ford Commented Dec 4, 2012 at 0:08
  • Like this? see: stackoverflow.com/questions/3947942/… – lbstr Commented Dec 4, 2012 at 0:10
Add a comment  | 

2 Answers 2

Reset to default 12

Thanks everyone for the response. I found the solution. Min max was not actually doing as I wanted it to.

I found the solution.

To start the x axis value from desired value use

plotOptions:
     <your_graph_type>:{
             pointStart: <your_value>
}

I think setting min and max for xAxis will work. Refer this link

and you can say

startOnTick: false, endOnTick:false

For example refer : example

I have values set min of y to 20 and max to 217,

yAxis: {
        min: 20,
        max:217,
        startOnTick: false,
        endOnTick:false
    },

See how ther chart is displayed. I hope this helps.

发布评论

评论列表(0)

  1. 暂无评论