Rows n’ Columns Docs
Visit HomepagePricing
  • Introduction
  • License
  • Demos
  • Getting started
    • Installation
    • Spreadsheet state
    • Headless UI
    • Imperative Spreadsheet API
    • Examples
  • ⚙️Configuration
    • Features
      • Data validation
      • Formula evaluation
      • Real-time data
      • Cell editors
      • Cell renderer
      • Structured Cell Renderer
      • Theming
      • Styling
      • Context menu
      • Localisation
      • Undo/Redo
      • Conditional formatting
      • Named ranges
      • Structured references
        • Schema based tables and columns
        • Calculated columns
      • Basic filter or Excel AutoFilter
      • Charts
      • Embedded content
      • Calculate on-demand
      • Drag and Drop
      • Pivoting and Grouping (Coming soon)
      • Tokenizer
      • Lazy loading/Infinite scrolling
      • OpenAI/Chat GPT Integration
      • Search
      • Formula protection
      • Autofill
      • Export canvas as image
    • Components
      • Canvas Grid
      • Toolbar
      • Sheet Tabs
      • Sheet Switcher
      • Sheet Status
      • Range Selector
      • Formula Input
      • Selection Input
      • SheetSearch
      • NamedRangeEditor
      • DeleteSheetConfirmation
      • TableEditor
      • Cell Format Editor
      • Conditional Format Editor
      • Data Validation Editor
      • Insert Link Editor
      • Insert Image Editor
    • API
      • Cell Data
      • Sheets
      • SpreadsheetProvider
      • useSpreadsheet
      • Modules
      • SheetCell
    • Using Spreadsheet with NextJS
    • Keyboard shortcuts
  • Collaboration
    • Real time collaboration
    • Yjs Collaboration
    • Supabase realtime Collaboration
  • Charts
    • Charts
    • Custom charts
  • Excel and Google sheets
    • CSV
    • Excel
    • Google sheets (Coming soon)
  • Functions
    • Named functions
    • Array formulas
  • Data persistence
    • Server side data persistence
    • React Query integration
  • Specifications
    • Browser support
    • Third party licenses
  • Support
    • Contact support
    • Report bugs
    • Feature requests
Powered by GitBook
On this page

Was this helpful?

  1. Charts

Custom charts

Spreadsheet 2 is agnostic of chart renderer. We maintain a schema for the chart, but you can choose to use any chart libraries out ther

import { Suspense, lazy } from "react"
import { CircularLoader, Separator } from "@rowsncolumns/ui";
import { useSubscribeToSheet } from "@rowsncolumns/spreadsheet-state";


const ChartComponent = ({ chart } : ChartComponentProps) => {

  const updateChart = () => {
  }

  // Subscribe to datarange
  useSubscribeToSheet(chart.chartId, chart.spec.dataRange, updateChart);

  // Render chart
  
}

const MySpreadsheet = () => {
  return (
    <CanvasGrid
      charts={[
        {
          chartId: 1,
          position: {
            sheetId: 1,
            overlayPosition: {
              anchorCell: {
                rowIndex: 8,
                columnIndex: 11,
              },
              heightPixels: 200,
              widthPixels: 300,
              offsetXPixels: 10,
              offsetYPixels: 10,
            },
          },
          spec: {
            title: "My chart",
            basicChart: {
              chartType: "BAR",
              series: [
                {
                  series: {
                    sourceRange: {
                      sources: [
                        {
                          startRowIndex: 1,
                          endRowIndex: 10,
                          startColumnIndex: 2,
                          endColumnIndex: 10,
                        },
                      ],
                    },
                  },
                },
              ],
              domains: [
                {
                  domain: {
                    sourceRange: {
                      sources: [
                        {
                          startRowIndex: 1,
                          endRowIndex: 10,
                          startColumnIndex: 2,
                          endColumnIndex: 10,
                        },
                      ],
                    },
                  },
                },
              ],
            },
          },
        },
      ]}
      
      getChartComponent={(props: ChartComponentProps) => (
        <Suspense fallback={<CircularLoader />}>
          <ChartComponent
            {...props}
            sheetData={sheetData}
          />
        </Suspense>
      )}
    />
  )
}

const App = () => (
  <SpreadsheetProvider>
    <MySpreadsheet />
  </SpreadsheetProvider>
);
PreviousChartsNextCSV

Last updated 7 days ago

Was this helpful?