Home Forums Chart Support Excluding Date on X Axis when no data

Excluding Date on X Axis when no data

Viewing 7 posts - 1 through 7 (of 7 total)
  • #12530

    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

    gtsafas,

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


    Sunil Urs

    #12543

    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

    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

    gtsafas,

    You can use interval and intervalType to show axis labels at specific interval.

    Axis with interval and interval type

    #17744

    Hi, can you explain what to set interval or intervalType to achieve this? I’m also trying to have the chart not display days that have blank data.

    #17755

    @limitedgoods,

    When we use the x-values for dataPoint, axis labels are not shown for dataPoint but at every interval of the axis. In your case, as you are trying to display axis label at specified dataPoint you can use label property in dataPoint instead of x-value as shown in the code snippet below –

    [
      { label: CanvasJS.formatDate(new Date(2012, 03, 1),"M/D"), y: 26 },
      { label: CanvasJS.formatDate(new Date(2012, 03, 5),"M/D"), y: 38 }
    ]

    Please take a look at this JSFiddle for a working example.

    Chart with date time axis

    ___________
    Indranil Deo
    Team CanvasJS

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

You must be logged in to reply to this topic.