1

Prompt

Generate a bar chart of the number of imports for each file in the codegen-backend/app/graph_sitter/core/ directory

You can adjust the data source, sorting, and other parameters to refine your visualization.

2

Review

The assistant will provide a codemod using Plotly to create the bar chart. Here’s an example of what the code might look like:

import plotly.graph_objects as go
import pandas as pd

data = []

# Iterate over all files in the specified directory
for file in codebase.files:
  if file.filepath.startswith("codegen-backend/app/graph_sitter/core/"):
      import_count = len(file.imports)
      data.append({"name": file.name, "frequency": import_count})

df = pd.DataFrame(data)
df = df[df.frequency > 20]
df = df.sort_values(by='frequency', ascending=False)

# Create the bar chart
fig = go.Figure(data=[
  go.Bar(
      x=df['name'],
      y=df['frequency'],
      hovertemplate='<b>File:</b> %{x}<br>' +
                    '<b>Import Count:</b> %{y}<extra></extra>'
  )
])

fig.update_layout(
  title='Import Counts for Files in codegen-backend/app/graph_sitter/core/',
  xaxis_title='File Names',
  yaxis_title='Number of Imports',
  xaxis_tickangle=-45
)

codebase.visualize(fig)

Customize your Plotly charts with fig.update_layout() to modify titles, axes, and other visual elements

3

Interact

Hit Run and view the bar chart in the Output Tab. For more advanced customization options, check out our customize page.