Skip to content

Commit

Permalink
Chart now supporting empty initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-NRCan committed Sep 29, 2023
1 parent 2fb8d60 commit bafe7f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/chart/chart.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from 'chart.js';
export * from './chart-parser';
export * from './chart-types';
export * from './chart';
7 changes: 3 additions & 4 deletions src/chart/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import { ChartPie } from './charts/chart-pie';
import { ChartLine } from './charts/chart-line';
import styles from './chart.module.css';


console.log("geochart chart.tsx run");

/**
* Main props for the Chart
*/
export interface TypeChartProps<TType extends ChartType, TData extends DefaultDataPoint<TType>, TLabel = string> {
export interface TypeGeoChartChartProps<TType extends ChartType, TData extends DefaultDataPoint<TType>, TLabel = string> {
data?: ChartData<TType, TData, TLabel>;
options?: ChartOptions<TType> | OptionsGeoChart;
plugins?: Plugin<TType>[];
Expand All @@ -24,10 +23,10 @@ export interface TypeChartProps<TType extends ChartType, TData extends DefaultDa
/**
* Create a customized Chart UI
*
* @param {TypeChartProps} props the properties passed to the Chart element
* @param {TypeGeoChartChartProps} props the properties passed to the Chart element
* @returns {JSX.Element} the created Chart element
*/
export function Chart(props: TypeChartProps<ChartType, DefaultDataPoint<ChartType>, string>): JSX.Element {
export function GeoChart(props: TypeGeoChartChartProps<ChartType, DefaultDataPoint<ChartType>, string>): JSX.Element {
// Fetch the cgpv module
const w = window as any;
const cgpv = w['cgpv'];
Expand Down
17 changes: 11 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import App from './App';

// TODO: How can we make the components using this package not care about this file, but keep it here for when we run GeoChart standalone? We don't want to create a chart in a root node when we import this chart package.

// Fetch the cgpv module
const w = window as any;
const cgpv = w['cgpv'];
const { react, createRoot } = cgpv;

console.log("geochart index.tsx run");

const container = createRoot(document.getElementById("root") as HTMLElement);
container.render(
<react.StrictMode>
<App />
</react.StrictMode>
);
const root = document.getElementById("root");
if (root) {
const container = createRoot(document.getElementById("root") as HTMLElement);
container.render(
<react.StrictMode>
<App />
</react.StrictMode>
);
}

0 comments on commit bafe7f2

Please sign in to comment.