Skip to content

Commit

Permalink
quarto
Browse files Browse the repository at this point in the history
  • Loading branch information
christophsax committed Nov 3, 2024
1 parent 8ab314e commit ecb6b91
Show file tree
Hide file tree
Showing 29 changed files with 6,286 additions and 123 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.Rproj.user
.DS_Store
.DS_Store
/.quarto/
17 changes: 17 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
project:
type: website
output-dir: docs

website:
title: "quarto"
navbar:
left:
- href: index.qmd
text: Home
- about.qmd

format:
html:
theme: cosmo
css: styles.css
toc: true
9 changes: 9 additions & 0 deletions about.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "About"
---

About this site

```{r}
1 + 1
```
2 changes: 2 additions & 0 deletions api/deploy.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# update API on connect
rsconnect::deployAPI(api = "api", appName = "sgods")
58 changes: 58 additions & 0 deletions data-explorer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// JavaScript code for handling interactivity

// Fetch data when the dataset selection changes
document.getElementById('dataset').addEventListener('change', fetchData);

// Fetch data when the page loads
window.onload = fetchData;

// Function to fetch data from the API and render it
function fetchData() {
var dataset = document.getElementById('dataset').value;
var url = `https://connect.cynkra.com/sgods-api/data?dataset=${dataset}&format=json`;

fetch(url)
.then(response => response.json())
.then(data => {
renderTable(data);
})
.catch(error => {
console.error('Error fetching data:', error);
document.getElementById('dataTable').innerHTML = '<p>Failed to fetch data.</p>';
});
}

function renderTable(data) {
if (!Array.isArray(data) || data.length === 0) {
$('#dataTable').html('<p>No data available.</p>');
return;
}

// Destroy existing table if it exists
if ($.fn.DataTable.isDataTable('#dataTable table')) {
$('#dataTable table').DataTable().destroy();
}

// Clear the dataTable div
$('#dataTable').empty();

// Create table element
var table = $('<table id="dataTableTable" class="display" width="100%"></table>');
$('#dataTable').append(table);

// Initialize DataTable
$('#dataTableTable').DataTable({
data: data,
columns: Object.keys(data[0]).map(function(key) {
return { title: key, data: key };
})
});
}

// Handle data download
document.getElementById('downloadButton').addEventListener('click', function() {
var dataset = document.getElementById('dataset').value;
var format = document.getElementById('format').value;
var url = `https://connect.cynkra.com/sgods-api/data?dataset=${dataset}&format=${format}`;
window.location.href = url;
});
Loading

0 comments on commit ecb6b91

Please sign in to comment.