import { getTemplateSrv } from ‘@grafana/runtime’;
const templateSrv = getTemplateSrv();
const variablesProtected = templateSrv.getVariables();
const variablesStringfied = JSON.stringify( variablesProtected );
const variables = JSON.parse( variablesStringfied );
This gives you access to all the variables in the visualization plugin