2021.07.05 03:33 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:
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
2021.07.20 07:35 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
2021.07.20 07:35 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
2021.07.22 07:42 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
2021.07.22 08:50 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
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.