Hello, welcome to a tutorial on how to build custom interactive data visualizations and charts with PrismJS. If you were looking for an online graphing tool, Prism is the right choice.
As of writing, there are seven types of charts that you can create with Prism: area, bar, column, line, pie, scatter and steps. If you need to draw a graph that is not available on Prism’s current list of chart options, fret not. There is actually a “Graph” option that allows you to create custom graphs based on the format provided in the documentation page.
Eli Lopian is the CEO and Co-Founder at Edgybees, a Tel Aviv-based start-up focused on computer vision, augmented reality, and drone technology. Eli has been a developer for over 15 years and has worked with companies such as Microsoft, Intel, and Google. Eli was also the first person to be hired at Wix.com!
In this article we will go over how to make custom interactive, data visualizations with PrismJS. We will make sure that our code is easy to follow and reuse so that we can easily apply it to other projects in the future (and you should too!):
Here’s what we’ll be making:
In this tutorial, we’ll create a custom interactive chart with an intuitive interface that makes it easy to change data and legends, and fine tune the design. We’ll be using the popular data visualization library D3.js for the visualizations and PrismJS for the custom user interface.
PrismJS is a free, open source syntax highlighter, built with modern web standards in mind. It’s used in thousands of websites, including some of those you visit daily. You can download it and host the files on your own server, or hotlink to one of the many CDNs that host it for you.
Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s used in thousands of websites, including some of those you visit daily. You can download it and host the files on your own server, or hotlink to one of the many CDNs that host it for you.
It helps engage your website visitors and keep them interested as they read through your content.
How does Prism work?
PrismJS is a robust, lightweight, and easy-to-use syntax highlighter built with modern web standards in mind. It’s used by thousands of developers every day.
In this blog, I am going to explain how to create a custom interactive chart with PrismJS. Since I am a fan of the ReactJS framework, we will be using the prismjs-react component to achieve our goal.
PrismJS provides a large number of plugins and themes to choose from. Let’s start by creating a simple project with create-react-app.
$ npx create-react-app customPrismJs
Once our project is created, we need to install the prismjs-react package as our dependency for this project:
$ cd customPrismJs && yarn add prismjs react-prism && yarn start
Is it free? Yes! PrismJS is free and open-source software, released under the MIT License.
There are many different code editor and IDE options out there. The one I use is called Visual Studio Code. It’s an open-source editor with a ton of awesome extensions for web development.
You can download it for your platform here.
If you use Sublime Text, Atom or another editor, that’s totally fine too. The tutorial should work just the same.
My project is called prismjs-tutorial but feel free to name yours whatever you like!