You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the component that will display on Tableu WDC, the route will be enter via WDC on Tableu Desktop app is http://localhost:1337/tableau/wdc
import React, { Component } from 'react';
class TableauWDC extends Component {
submit() {
window.tableau.connectionName = "USGS Earthquake Feed"; // This will be the data source name in Tableau
window.tableau.submit(); // This sends the connector object to Tableau
}
loadJSON(path, success, error) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
if (success)
success(JSON.parse(xhr.responseText));
} else {
if (error)
error(xhr);
}
}
};
xhr.open("GET", path, true);
xhr.send();
}
componentDidMount() {
let isReady = document.getElementById("tableauScript");
isReady && this.setConnect()
}
setConnect() {
var myConnector = window.tableau.makeConnector();
myConnector.getSchema = function (schemaCallback) {
window.tableau.log("getSchema")
var cols = [{
id: "id",
dataType: window.tableau.dataTypeEnum.string
}, {
id: "mag",
alias: "magnitude",
dataType: window.tableau.dataTypeEnum.float
}, {
id: "title",
alias: "title",
dataType: window.tableau.dataTypeEnum.string
}, {
id: "location",
dataType: window.tableau.dataTypeEnum.geometry
}];
var tableSchema = {
id: "earthquakeFeed",
alias: "Earthquakes with magnitude greater than 4.5 in the last seven days",
columns: cols
};
schemaCallback([tableSchema]);
};
// Download the data
myConnector.getData = function (table) {
window.tableau.log("getData")
this.loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson',
function (data) {
var feat = data.features,
tableData = [];
// Iterate over the JSON object
for (var i = 0, len = feat.length; i < len; i++) {
tableData.push({
"id": feat[i].id,
"mag": feat[i].properties.mag,
"title": feat[i].properties.title,
"location": feat[i].geometry
});
}
table.appendRows(tableData);
},
function (xhr) { console.error(xhr); }
);
};
window.tableau.registerConnector(myConnector);
}
render() {
return (
<div style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100%"
}}>
<button onClick={() => this.submit()} className="btn btn-success" >Get Earthquake Data!</button>
</div>
);
}
}
export default TableauWDC;
I keep getting these errors.
A snippet from the error is below here
An error occurred while communicating with Web Data Connector.
The connector has reported an unrecoverable error and cannot proceed. If the connector has reported details of the error, they are displayed in the pane below.
ReferenceError: Can't find variable: Set file: http://localhost:1337/bundle.min.js line: 33098
ReferenceError: Can't find variable: Set file: http://localhost:1337/bundle.min.js line: 33098
Version of React:
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-router": "^3.2.0"
The text was updated successfully, but these errors were encountered:
I attempted to create a react-based WDC this week, ran into similar issues. What I found specifically was that the init message from the Dispatcher was never called from my app. I believe, looking at the bundled code, the dispatcher triggers the init message after the dom has been fully loaded, so it's possible that React stops whatever event the WDC library is listening for.
I couldn't get it to work and ended up ditching it for a non-framework solution.
I keep getting this error ReferenceError: Can't find variable: Set file: http://localhost:1337/bundle.min.js line: 33098
It looks like window.tableau.getSchema() and myConnector.getData() have never been called. I add a log message, but it has never been executed.
Here is my html
Here is the component that will display on Tableu WDC, the route will be enter via WDC on Tableu Desktop app is http://localhost:1337/tableau/wdc
I keep getting these errors.
A snippet from the error is below here
Version of React:
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-router": "^3.2.0"
The text was updated successfully, but these errors were encountered: