Skip to content

Commit

Permalink
feat: Add descendant chart functionality using D3.
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 10, 2024
1 parent f71d2f2 commit 57ef02e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions public/js/filament/widgets/descendant-chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as d3 from 'd3';

async function fetchDescendantData() {
const response = await fetch('/api/descendants');
if (!response.ok) {
throw new Error('Failed to fetch descendant data');
}
return response.json();
}

function processDescendantData(data) {
// Process data to fit D3.js structure
return data; // Placeholder for processed data
}

function renderDescendantChart(data) {
const container = d3.select('#descendant-chart-container');
const width = 960;
const height = 500;

const svg = container.append('svg')
.attr('width', width)
.attr('height', height)
.attr('class', 'shadow-lg');

// Example of creating a chart with D3.js and Tailwind CSS
svg.selectAll('circle')
.data(data)
.enter()
.append('circle')
.attr('cx', (d, i) => i * 100 + 50)
.attr('cy', height / 2)
.attr('r', 40)
.attr('class', 'fill-current text-blue-500');
}

async function initDescendantChart() {
try {
const rawData = await fetchDescendantData();
const data = processDescendantData(rawData);
renderDescendantChart(data);
} catch (error) {
console.error('Error initializing descendant chart:', error);
}
}

initDescendantChart();

0 comments on commit 57ef02e

Please sign in to comment.