How to use the @vx/mock-data.appleStock.filter function in @vx/mock-data

To help you get started, we’ve selected a few @vx/mock-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github williaster / data-ui / packages / demo / examples / 01-xy-chart / data.js View on Github external
cityTemperature,
  appleStock,
  genRandomNormalPoints,
  letterFrequency,
  genStats,
} from '@vx/mock-data';
import { theme } from '@data-ui/xy-chart';

export const timeSeriesData = appleStock
  .filter((d, i) => i % 120 === 0)
  .map(d => ({
    x: new Date(d.date),
    y: d.close,
  }));

export const appleStockData = appleStock
  .filter((d, i) => i % 10 === 0)
  .map(d => ({
    x: new Date(d.date),
    y: d.close,
  }));

export const categoricalData = letterFrequency.map(d => ({
  x: d.letter,
  y: d.frequency,
}));

// stacked data
export const groupKeys = Object.keys(cityTemperature[0]).filter(attr => attr !== 'date');
export const stackedData = cityTemperature.slice(0, 12).map(d => ({
  // convert all keys to numbers
  ...groupKeys.reduce((obj, key) => ({ ...obj, [key]: Number(d[key]) }), {}),