Understanding useRef and forwardRef in React — A Beginner’s Guide

When working with React, you often hear about useRef and forwardRef . At first, they can feel confusing: “Why do I need refs when I already have props and state?” This article will walk you through the why, how, and when of refs in React — with simple examples, analogies, and real use cases. 1. What is useRef ? Think of useRef as a sticky note inside your component. Whatever you write on it will still be there even after React re-renders your component. function App() { const inputRef = React.useRef<HTMLInputElement>(null); const focusInput = () => { inputRef.current?.focus(); }; return ( <div> <input ref={inputRef} placeholder="Type here..." /> <button onClick={focusInput}>Focus Input</button> </div> ); } useRef creates a box that holds a reference to the <input> DOM element. inputRef.current po...

Highcharts: A 10 minutes overview.

A Norway-based company 'Highsoft' offering charting library written in pure javascript. Its a major addon to web applications requires interactive charts. Currently they're supporting many chart types including line, area, column, bar, pie, scatter, bubble, gauge, spline, areaspline and polar etc.

Already Highcharts is providing a descriptive demo page considering all examples (Highcharts Demos). The pupose of the article only to understand maximum aspects in a view.

Features :

Compatible with all major browsers, it also provides features like DateTime support, Export (PDF/ PNG/ JPG / SVG), Print and Zoomablity etc.

Installation:

Its a single file downloadable from (https://www.highcharts.com/). Also packages through npm and Bower are avalable. We may load file on our domain or use CDN version.

Load files from your own domain (Insert in html head)

<script src = "/js/highcharts.js">

CDN Version (Insert in html head)

<script src = "https://code.highcharts.com/highcharts.js">

Highcharts general elements are worth to understand. Then next step is formatting. It helps to mould highcharts as per our requirement.

Below are few very important queries, while working with Highcharts.

How to format Legend?
How to format x-axes?
How to format y-axes?
How to format column?
How to format tooltip?
How to format y-axes stackLabels?
How to colour the columns?
How to add event on columns?

In below image all questions are answered.
Also view complete example in jsfiddle.

Also we'll discuss other aspects of highcharts soon.

Comments

  1. https://stackoverflow.com/questions/48748550/google-chart-horizontal-scrolling

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Install and Manage PostGIS with a Non-Superuser Role

Leveraging Asynchronous Views in Django REST Framework for High-Performance APIs

Implementing Throttling in Django REST Framework.