Skip to content

This project provides a simple drop-in replacement for the Google Charts API text formula rendering functionality

Notifications You must be signed in to change notification settings

matiasbenedetto/google-apis-charts-dropin-replacement-for-formulas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Charts API Text Formula Replacement

This project provides a simple drop-in replacement for the Google Charts API text formula rendering functionality. It allows you to replace the Google Charts domain with your own domain while maintaining the exact same functionality and URL structure.

Features

  • Direct replacement for https://chart.googleapis.com/chart?cht=tx URLs
  • No client-side JavaScript required
  • Server-side rendering using MathJax
  • Preserves all URL parameters and styling options
  • Support for both SVG and PNG output formats
  • Simple status page with usage examples

How it Works

This solution works by setting up a server that handles the same URL pattern as the Google Charts API. You simply need to replace the domain in your image URLs from chart.googleapis.com to your own domain, and everything else works exactly the same.

For example, change:

https://chart.googleapis.com/chart?cht=tx&chl=f(x) = \sum_{n=0}^{\infty} a_n x^n

To:

https://google-charts-formulas.vercel.app/chart?cht=tx&chl=f(x) = \sum_{n=0}^{\infty} a_n x^n

The server handles the request and generates an image of the formula (SVG or PNG), just like the Google Charts API does.

Result:

example formula

Image formats

SVG format is used by default. For PNG format, add the &format=png parameter to the URL. Example:

https://google-charts-formulas.vercel.app/chart?cht=tx&chl=f(x) = \sum_{n=0}^{\infty} a_n x^n&format=png

Usage

This is a drop-in replacement for the Google Charts API text formula rendering. To use it just replace the old chart google apis url https://chart.googleapis.com/chart with this https://google-charts-formulas.vercel.app. The old formulas broken becuase of the deprecation of the google service will work again.

Example:

Original Google Charts URL:

https://chart.googleapis.com/chart?cht=tx&chl=f(x) = \sum_{n=0}^{\infty} a_n x^n

Replacement URL:

https://google-charts-formulas.vercel.app/chart?cht=tx&chl=f(x) = \sum_{n=0}^{\infty} a_n x^n

Graphic charts:

This project is not related to graphic charts, just to text formulas. If you need to render graphic charts, you can use this project that covers that: https://quickchart.io/

Inspiration

I was taking a mathematics course and found all the formulas broken because of the discontinuation of Google Charts' service. This project was born to fix the text formulas that were broken and provide a drop-in replacement for the Google Charts API text formula rendering functionality.

Development

Prerequisites

  • Node.js (version 20)
  • npm

Install and run

  1. Clone this repository or download the files
  2. Install dependencies:
npm install
  1. Start the server:
npm run dev

The server will run on port 3000 by default. You can change this by setting the PORT environment variable.

About

This project provides a simple drop-in replacement for the Google Charts API text formula rendering functionality

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published