Home forums Using CanvasJS Excluding Date on X Axis when no data

This topic contains 4 replies, has 3 voices, and was last updated by  Vishwas R 2 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #12530

    gtsafas
    Participant

    Hi,

    I am loading a data set that uses date for its x axis. I am seeing a few gaps in the chart, upon inspection it seems that there is an X axis entry being generated for a Date that is not in my data. Is there a way to turn this off?

    #12537

    Sunil Urs
    Keymaster

    gtsafas,

    Can you please share a screenshot / jsfiddle so that we can understand the issue better?


    Sunil Urs

    #12543

    gtsafas
    Participant

    Hi Sunil,

    I am not allowed to share screenshots and jsfiddle is blocked here. Let me try to explain better.

    Assuming the following is true,
    1) I have a stacked column graph
    2) My x-axis is a date
    3) I have data for Jan 1st, Jan 3rd, Jan 4th

    When my graph is rendered it is showing me along the x-axis labels

    Jan 1st, Jan 2nd, Jan 3rd, Jan 4th

    I do not have any data for Jan 2nd and I dont see it being passed anywhere on my side. Additionally, if I mouse over the gap that Jan 2nd creates I dont get a tooltip, so that leans me even more towards the fact that I am not causing this.

    If you guys have an email we can correspond over it, I can share SS there.

    Thanks for any help

    #12549

    gtsafas
    Participant

    I modified one of your demos below. See how there is only 3/1 and 3/5. I only want to see 3/1 and 3/5 on the x axis. I cant seem to find a setting to do that.

    <!DOCTYPE HTML>
    <html>
    <head>
      <script type="text/javascript">
      window.onload = function () {
        var chart = new CanvasJS.Chart("chartContainer",
        {
          title:{
            text: "Date time axis with interval 3 months"
          },
          axisX:{
            interval: 0,
            intervalType: "day"
          },
          data: [
          {
            type: "line",
            dataPoints: [//array
            {
             x: new Date(2012, 03, 1),
             y: 26,
           },
           {
             x: new Date(2012, 03, 5),
             y: 38
           }
        
           ]
         }
         ]
       });
    
        chart.render();
      }
      </script>
      <script type="text/javascript" src="/assets/script/canvasjs.min.js"></script>
    </head>
    <body>
      <div id="chartContainer" style="height: 300px; width: 100%;">
      </div>
    </body>
    </html>
    #12550

    Vishwas R
    Keymaster

    gtsafas,

    You can use interval and intervalType to achieve this.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.