Skip to content

Resolving custom dashboard variables within queries. #136

Answered by ZuperZee
jmythms asked this question in Q&A
Discussion options

You must be logged in to vote

The Export CSV code doesn't handle query variables, but it can be added by replacing line 73 with query: htmlGraphics.props.replaceVariables(query),

Full new onInit code:

const btn = htmlNode.querySelector('button');

const timeoutLength = 3000;
const defaultButtonText = 'Export to CSV';

const toCsv = (resultsData) => {
  const [
    {
      frames: [
        {
          schema: { fields },
          data: { values },
        },
      ],
    },
  ] = Object.values(resultsData.results);

  if (values.length <= 0) {
    btn.textContent = 'Export failed... (Found no values).';
    console.warn('Got no values');
    return;
  }

  // Ensure time is first
  const orderFieldsAndValues = (values, 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jmythms
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants