<commit_before>import React from 'react';
import { Config } from 'vega-lite';
import { VegaLite, VisualizationSpec } from 'react-vega';

export const defaultConfig = {
  autosize: {
    type: 'fit' as const,
    contains: 'padding' as const,
  },
  background: '#0000',
  padding: 0,
  view: {
    stroke: null,
  },
  axis: {
    domainColor: 'gray',
    labelColor: '#e9e8e7',
    tickColor: 'gray',
  },
};

export interface Props {
  spec: VisualizationSpec,
  data: any,
  config?: Config,
  width?: number,
  height?: number,
  renderer?: "canvas" | "svg",
}

export function formatTime(field: string = 'datum.timestamp') {
  return `if(${field} / 1000 >= 60, toString(floor(${field} / 60000)) + 'm ', '') + toString(floor(${field} / 1000) % 60) + 's'`;
}


export default function BaseChart(props: Props) {
  const prp = {
    config: defaultConfig,
    renderer: "canvas" as const,
    ...props,
  };

  return (
    <VegaLite
      theme="dark"
      tooltip={{theme: 'dark'}}
      actions={false}
      {...prp}
    />
  );
}<commit_msg>BaseChart now sets data on the spec manually<commit_after>import React from 'react';
import { Config } from 'vega-lite';
import { VegaLite, VisualizationSpec } from 'react-vega';

export const defaultConfig = {
  autosize: {
    type: 'fit' as const,
    contains: 'padding' as const,
  },
  background: '#0000',
  padding: 0,
  view: {
    stroke: null,
  },
  axis: {
    domainColor: 'gray',
    labelColor: '#e9e8e7',
    tickColor: 'gray',
  },
};

export interface Props {
  spec: VisualizationSpec,
  data: any,
  config?: Config,
  width?: number,
  height?: number,
  renderer?: "canvas" | "svg",
}

export function formatTime(field: string = 'datum.timestamp') {
  return `if(${field} / 1000 >= 60, toString(floor(${field} / 60000)) + 'm ', '') + toString(floor(${field} / 1000) % 60) + 's'`;
}


export default function BaseChart(props: Props) {
  const prp = {
    config: defaultConfig,
    renderer: "canvas" as const,
    ...props,
    spec: {
      ...props.spec,
      datasets: props.data,
    },
    data: undefined
  };

  return (
    <VegaLite
      theme="dark"
      tooltip={{theme: 'dark'}}
      actions={false}
      {...prp}
    />
  );
}
{'fraction_non_alphanumeric': 0.16839729119638827, 'fraction_numerical': 0.022573363431151242, 'mean_word_length': 3.0217785843920146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6520997', 'n_tokens_mistral': 815, 'n_tokens_neox': 776, 'n_words': 197}