How to set the PlatformStateContext datetime range

Within a custom visualization, I am using a 3rd party charting library for a chart. With the PlatformStateContext component, I’m able to control the window of time being shown in this chart.

Similar to the built-in chart types, I would like to provide zoom functionality where the user can use this chart to control the time-range for the other charts on the dashboard.

I don’t see a way to do this. Anyone have any ideas how this can be achieved?

From the new relic doc PlatformStateContext provides only read access to the platform URL state variables and it may not be possible to explicitly set a time . While new relic community gets back with better solutions if any , one way to solve this could be to create a custom Time picker and replacing the one provided by new relic. This can be done with Nerdlet config apis . We need to write the function for generating the since clause from the timestamps from the time picker as well, which should be straightforward . The only advantage would be that now time picker is in our complete control.

Sample code for that would be :

      timePicker: false,
      actionControls: true,
      actionControlButtons: [
          label: "Time picker", // Label of the action control button.
          type: "PRIMARY", // Type of the action
          iconType: '', // Name of the icon to display.
          hint: 'Open my custom time picker', // Text used for the action control button's tooltip.
          onClick: () => {}, // Callback fired any time the user clicks button, render time picker on click of this buton

Thank you Vijay, that’s a good idea. However, I’m building a custom visualization that is intended to be used within existing dashboards and I don’t think that this solution will work in that case.

Your suggestion did make me think of another possible workaround. Perhaps I can allow the user to make a selection of time within the graph and then simply redirect them to the same dashboard page, but substitute the new time range values in the url parameters. Thank you for your helpful idea.

@dustin.pauze Sounds like you were working on another solution based on this idea. Would love to hear what you did to resolve :slight_smile:

This topic was automatically closed after 365 days. New replies are no longer allowed.