![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@billboard.js/react
Advanced tools
Readme
React component for billboard.js
# Install billboard.js together if you don't have it already
$ npm install billboard.js @billboard.js/react
ℹ️ The component will create a
<div>
element and append it to the parent element andbindto
option is not supported in this case.
import React, {useEffect, useRef} from "react";
// import billboard.js
import bb, {line} from "billboard.js";
import "billboard.js/dist/billboard.css"; // default css
// import react wrapper
import BillboardJS, {IChart} from "@billboard.js/react";
// const BillboardJS = require("@billboard.js/react"); // for CJS
function App() {
// to get the instance, create ref and pass it to the component
const chartComponent = useRef<IChart>(null);
const options = {
data: {
columns: [
["data1", 300, 350, 300]
],
type: line()
}
};
useEffect(() => {
// get the instance from ref
const chart = chartComponent.current?.instance;
// call APIs
if (chart) {
chart.load( ... );
}
}, []);
return <BillboardJS
bb={bb}
options={options}
ref={chartComponent}
/* The values will be specified to the bound element as inlined styles */
style={{
width: "500px",
...
}}
/* When class name doesn't contains `bb`,
then you also need to update the default CSS to be rendered correctly. */
className={"bb my-classname"}
/>;
}
props
passed to the componentWhen the options are passed to the "chart" component.
// index.tsx
import App from "./App.tsx";
const options = {
data: {
columns: [
["data1", 300, 350, 300]
],
type: "bar"
}
};
<App {...options} />
// or
// <App data={
// columns: [
// ["data1", 300, 350, 300]
// ],
// type: "bar"
// } />
// App.tsx
import * as Chart from "billboard.js";
import "billboard.js/dist/billboard.css"; // default css
import BillboardJS, {IChart, IChartOptions} from "../src/index";
export function App(props: IChartOptions) {
const chartComponent = useRef<IChart>(null);
// when chart "type" is passed from props, chart types need to be initialized separately.
// in this scenario, can't be "tree-shaken" only used chart type modules.
Chart[props.data.type]();
useEffect(() => {
const chart = chartComponent.current?.instance;
if (chart) {
chart.load( ... );
}
}, []);
return <BillboardJS
bb={Chart.bb}
options={props}
ref={chartComponent}
/>;
}
// chart options
interface IChartOptions;
// @billboard.js/react props
interface IProp extends Pick<HTMLProps<HTMLDivElement>, "className" | "style"> {
bb: typeof bb;
options: ChartOptions;
}
// Chart instance
interface IChart {
instance: Chart;
}
FAQs
React component for billboard.js
The npm package @billboard.js/react receives a total of 587 weekly downloads. As such, @billboard.js/react popularity was classified as not popular.
We found that @billboard.js/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.