No, this is a not supported and forbbed appraoch to use Views.
1. WordPress generally does not allow ShortCodes to be used as HTML, CSS or JS values
2. Toolset adds some magic to make that possible here and there (nested ShortCodes, and so on)
3. Still, we are bound to the platform we produce the Plugin for, and that is WordPress
4. Views, bottom line, is a Data Renderer and not a Data Provider.
We wrap every View output in a certain, default HTML.
That HTML will destroy your chart, since the value Views returns is not a "raw" value.
There is one possible workaround, but that is on your own risk, and there are limits to it.
1. Sometimes we need to populate values in as example Select Boxes (JSON) or of 2rd Party ShortCodes like “Chart Generators”.
This is also your case here.
2. This snippet allows you to output a given Views Loop without default HTML wrapped around the results.
3. The following snippet produces a clean View output, or as clean as we can:
add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
function prefix_clean_view_output( $out, $id ) {
if ( $id == '375' ) {
$start = strpos( $out, '<!-- wpv-loop-start -->' );
if (
$start !== false
&& strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
) {
$start = $start + strlen( '<!-- wpv-loop-start -->' );
$out = substr( $out , $start );
$end = strrpos( $out, '<!-- wpv-loop-end -->' );
$out = substr( $out, 0, $end );
}
}
return $out;
}
4. Use a Views Loop similar to the one in the screenshot
5. Step by step:
- It hooks early in the View output.
- Priority 5 is mandatory as we already do some other cleaning at priority 10.
- It only affects a View with an ID of 375, adjust acordingly if needed.
- It only affects Views with actual results: if the View matches no result, the same “No items found” or whatever you have between the wpv-no-items-found shortcode applies.
- It returns only what is between the HTML comments <!– wpv-loop-start –> and <!– wpv-loop-end –> , excluding them. Only content between those HTML comments is returned, as is.
- Notice that, with this applied to a given View ID:
-- Pagination, specially AJAX pagination, will not work.
-- Parametric search, specially AJAXed parametric search, will not work.
-- Other future features will not work either.
So this is to be used if and only if you know what you are doing and you are going to use the View output as source for anything else.
Also notice that this only clears the View structure.
Building as example JSON inside a View output is wrong because we can not address quoting problems.
Please use this with caution, considering the side effects and responsibly.
==> We have a feature filed for a View Data Provider, but that is not yet defined and has no ETA or green light from the developers at all.
I will add your voice to the Internal issue tracker.
Thanks!