Skip to content

Commit 30c088f

Browse files
author
Benjamin Melançon
committed
Add a basic adapter for public Tableau visualizations
1 parent 3efed0e commit 30c088f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/Adapters/Tableau.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Embed\Adapters;
4+
5+
use Embed\Http\Response;
6+
use Embed\Utils;
7+
8+
/**
9+
* Adapter to hardcode the embed code for Tableau public.
10+
*/
11+
class Tableau extends Webpage
12+
{
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public static function DoNotUSEcheck(Response $response)
17+
{
18+
// https://public.tableau.com/views/NAME_OF_VIEW/SubName?:language=en-US&:display_count=n&:origin=viz_share_link
19+
return $response->isValid() && $response->getUrl()->match([
20+
'*.public.tableau.com/views/*/*',
21+
]);
22+
}
23+
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function getCode()
28+
{
29+
$this->width = '100%';
30+
$this->height = '60vh';
31+
32+
// $this->url ends up not being the same one Tableau offers when you
33+
// copy the share link.
34+
$embed_url = $this->response->getStartingUrl() . '&:showVizHome=no&:embed=true';
35+
36+
return Utils::iframe($embed_url);
37+
}
38+
}

0 commit comments

Comments
 (0)