Home Forums Chart Support Chart Graph not showing dates

Chart Graph not showing dates

Viewing 10 posts - 1 through 10 (of 10 total)
  • #40025

    Hi,

    I have given link for database, php code and image of graph.

    I do not get date (month and year) in the graph on X axis.

    Kindly guide.

    Link is as follows-

    https://drive.google.com/drive/folders/1fBxfdXfWvWy2ojbs7W2wciB2Ss02kslc?usp=share_link

    Regards

    Giant

    #40036

    Giant,

    It looks like the sample provided by you is restricted and requires permission. Can you please make the image / sample public so that we can access it?

    Google Drive Access

    If the Google Drive link shared contains an image, can you kindly create a sample project with a sample database reproducing the issue you are facing & share it with us so that we can look into the code / chart-options being used, understand the scenario better and help you out?


    Adithya Menon
    Team CanvasJS

    #40134
    #41288

    Giant,

    It looks like some of the tables needed to run your SQL Query are missing. Can you kindly create a sample project along with a sample database (adding the necessary tables to your database) reproducing the issue you are facing & share it with us so that we can help you out?


    Adithya Menon
    Team CanvasJS

    #41292

    Hi

    I have added on the missing table in the drive.

    https://drive.google.com/drive/folders/1fBxfdXfWvWy2ojbs7W2wciB2Ss02kslc?usp=share_link

    Kindly review and hope to get a resolution.

    Warm Regards

    Giant

    #41370

    Giant,

    Since you are using PHP date, you will have to convert the date to a JavaScript timestamp. To convert PHP date to JavaScript timestamp, first, you need to convert PHP date to PHP timestamp using strtotime and then convert PHP timestamp to JavaScript timestamp by multiplying PHP timestamp by 1000. Also, you will have to convert the y-values to numerical format using (int) since y property only accepts numbers.

    Kindly refer to the code-snippet below for the changes that will have to be made to your code,

    array_push($dataPoints1, array("x" => strtotime(date($resultRows['exp_dt'])) * 1000, "y" => (int) $resultRows['iamt']));
    array_push($dataPoints2, array("x" => strtotime(date($resultRows['exp_dt'])) * 1000, "y" => (int) $resultRows['eamt']));


    Adithya Menon
    Team CanvasJS

    #41373

    Hi Adithya,

    Thanks a lot.

    I have made changes as you suggested and now it’s showing results as expected.

    Thanks once again Adithya.

    Warm Regards

    Giant

    #41469

    Hi Adithya,

    I saw the date, month, and year in the graph and I was thrilled with the result.

    But when I actually compared with the query result I found that expenses have values for say July and August but there is no income then these values(jul,aug) are not reflected in the graph.

    So although the query result is correct the graph is not showing all values since income is zero for those months. ( check image ).

    https://drive.google.com/drive/folders/1fBxfdXfWvWy2ojbs7W2wciB2Ss02kslc?usp=share_link

    I have also attached .php for your reference.

    I hope to get the resolution for this issue, Sir.

    Warm Regards

    Giant

    #41597

    Giant,

    It looks like you are trying to use a condition to check if the income data is not null and then adding both the income and expense datapoints. The query provides the result as null, however, to show 0 on the chart, you can remove the if condition if($resultRows['iamt']!=null) { ... } and use (int) to typecast null value as 0, as shown in the code-snippet below,

    foreach ($result as $resultRows) {
       array_push($dataPoints1, array("x" => strtotime(date($resultRows['exp_dt'])) * 1000, "y" => (int) $resultRows['iamt']));
       array_push($dataPoints2, array("x" => strtotime(date($resultRows['exp_dt'])) * 1000, "y" => (int) $resultRows['eamt']));
    }


    Adithya Menon
    Team CanvasJS

    #41735

    Hi this is Gulshan
    Well, In the chart graph, right-click the category axis, and then click Format Axis. In the Format Axis dialog box, select Axis Options on the left. Under Axis Type, make sure the Date axis is selected.

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

You must be logged in to reply to this topic.