KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Solutions KX Dashboards – Dynamically update Type of X-Axis (Number/DateTime) and using Min/Max values

  • KX Dashboards – Dynamically update Type of X-Axis (Number/DateTime) and using Min/Max values

    Posted by ksorvats on July 5, 2021 at 12:00 am

    Hello, is it possible in KX Dashboards to dynamically change axes from Int (Number) to dateTime?

    I am looking into dynamically changing the type of the x-axis of one of my canvas charts, (from Number to Datetime) and vice versa with min/max values working correctly when populated from viewstates. For simplicity assume my output table has 3 columns: index, dateColumn, data and that the user chooses from a dropdown list widget if they want Number or Datetime type for x-axis.

    So the cases are the user chooses to see their data on:

    • a number x-axis of type integer ‘i’ (which gets the index position of the each row of the table – easy).
    • a Date/Time x-axis of type timestamp ‘p’ (which has the datetime on each row of the table in the format “YYYY-MM-DD hh:mm:ss:SSSSSSSSS”

     

    Case 1: Number type: When its a number, I have a separate query which takes my min/max points of the graph and expands (or contracts) the graph (given a span range from a user). This works on percentages, for example the user passes 10 as input into a text box, then the query gets the min/max values and does min-0.1*min and max+0.1*max. Then maps the output onto viewstates (call them min_x andmax_x) which are then populating the Canvas Chart’s RANGE/Use MinMax/min and max values. It all works well for the numbers!

     

    Case 2: Datetime type: When its a Datetime type however, it seems to be buggy, it sets the minimum to be 1970 (I am guessing ‘zero’ in terms of date/time?) and the max to be the current date. When I check the min/max viewstates I can see that they are correctly poopulated with the first Datetime shown in the table’s column dateColumn and the last one to be the last entry of the column (as expected). I have even tried manipulating the column in the table and casting to “d” (for date only) to “t” (for time only) and even to “Z” (for date/time) but the canvas chart still keeps being buggy…

     

    Please use as references the images attached – notice, in my case it should be the case where both graphs should be exactly identical, with the exception of the x-axis, one showing numbers for the indeces of the points on the table, the other one the date/time which corresponds to those points timestamps.

     

    My question is, why could this be happening? Format of Datetime Type not matching my format from the output of the query? Or could it be min/max values for Date/time not being liked by the dashboard?

     

    Many thanks,

    SK

    ksorvats replied 8 months ago 2 Members · 3 Replies
  • 3 Replies
  • dfallon

    Member
    July 20, 2021 at 12:00 am

    Hi SK,

    Here is an example format with the sample data set; try this with your time data column and map the outputs to your view states:

     

    mint: exec min time from dfxQuote; 
    maxt: exec max time from dfxQuote; 
    buffer: "n"$((maxt-mint) * 0.01); 
    `min`max`buffer`bufferMin`bufferMax!(mint;maxt;buffer; mint-buffer; maxt+ buffer)

     

    Thanks,

    Declan

  • ksorvats

    Member
    July 22, 2021 at 12:00 am

    Hi Declan,

    Thanks for the reply. I found out what my issue was in the end. I had the Type of my graph being Time (which was wrong as it would never render any of my Date/Time/Datetime viewstates as Time parameters) and then changed to Category  and it seems to have fixed the issue.

    Super non-intuitive but literally changing that dropdown to Category plotted all my points linearly as I wanted them.

    Thanks again for the reply.

     

    SK

  • dfallon

    Member
    July 22, 2021 at 12:00 am

    Hi SK,

    While Category will display your time points, it won’t account for missing time periods / non-sequential time data as the Time option supports.  Glad to hear the suggested solution worked.

    Thanks,
    Declan

Log in to reply.