Skip to content

Commit

Permalink
fix: Resolve import path errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-s-snyder committed May 12, 2024
1 parent 28b51be commit 28d8e8c
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/handlers/select.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { path } from 'd3-path';
import { select, selectAll } from 'd3-selection';
import { LINK_TYPES } from '../parsers/link-parsers.js';
import { LINK_TYPES } from '../parsers/linking/link-parser.js';
// import { parseTransform } from '../parsers/attribute-parsers';
import {
DataAttr, LegendRole, MarkRole, OpacityField, Path, RoleProperty,
DataAttr, LegendRole, MarkRole, OpacityField, RoleProperty,
SelectOpacity, tableIndexField, tableMarkField, UnselectOpacity
} from '../state/constants.js';
// import { Transform } from '../util/transform';
Expand Down Expand Up @@ -55,7 +55,7 @@ function drawAggregates(id, selected, xAxis) {
.classed('AGGREGATE_LAYER', true)
.attr('fill', window.getComputedStyle(marks[i]).fill);

if (marks[i].tagName === Path) {
if (marks[i].tagName === 'path') {
const x = marks[i].contour[0].x; //, y = marks[i].contour[0].y;
// if (marks[i].globalPosition.translate.y) {
// var y = marks[i].globalPosition.translate.y - marks[i].globalPosition.translate.y / 2;
Expand Down
2 changes: 1 addition & 1 deletion src/hydrate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { coordinate } from './orchestration/coordinator.js';
import { parseDataset } from './parsers/dataset-parser.js';
import { parseDataset } from './parsers/data/dataset-parser.js';

export async function hydrate(svg, options = {}) {
if (!svg) return;
Expand Down
18 changes: 3 additions & 15 deletions src/orchestration/coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,21 @@ import { applySelections, selectPoint } from '../handlers/select.js';
// import { sort } from '../handlers/sort.js';
// import { annotate } from '../handlers/annotate.js';

import { deconstructChart } from '../parsers/parser-engine.js';
import { inferMarkAttributes } from '../parsers/attribute-parsers.js';
// import { createMenu } from '../toolbar/menu.js';
import { parseDataFromMarks } from '../parsers/dataset-parser.js';
import { inspect } from './inspect.js';
import { getRootNodes, link, walkQueryPath } from '../parsers/link-parsers.js';
import { getRootNodes, link, walkQueryPath } from '../parsers/linking/link-parser.js';
import { isMetaKey } from '../util/util.js';
import { pointer } from 'd3-selection';
// import { zoom } from '../handlers/zoom.js';
import { brushEnd, brushMove, brushStart } from '../handlers/brush.js';
import { generateBrushPredicates } from '../handlers/query.js';
import { parseChart } from '../parsers/engine/parser-engine.js';

export function coordinate(svg, extState) {
const states = svg.map(d => initialize(inspect(d)));
const states = svg.map(d => parseChart(inspect(d)));
link(states, extState);
// createMenu(states);
states.forEach(d => coordinateInteractions(d));

function initialize(state) {
// state.svg.style.cursor = 'crosshair';
// Infer view information
deconstructChart(state);
// highlight(state);
inferMarkAttributes(state);
state.data = parseDataFromMarks(state.svgMarks);
return state;
}
// console.log(extState);
// function highlight(state) {
// state.xAxis.ticks.forEach(d => select(d.label).style('color', '#e15759'));
Expand Down
2 changes: 1 addition & 1 deletion src/orchestration/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Transform } from '../util/transform.js';
import { ViewState } from '../state/view-state.js';
import { parseTransform } from '../parsers/attribute-parsers.js';
import { parseTransform } from '../parsers/data/attribute-parser.js';
import * as parser from 'svg-path-parser';
import { SVGToScreen, containsLines } from '../util/util.js';
import { select } from 'd3-selection';
Expand Down
14 changes: 7 additions & 7 deletions src/parsers/data/attribute-parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { timeFormat, timeParse } from 'd3-time-format';
import { CategoricalColorLegend, DataAttr, Line, OpacityField, Polyline, Rect, SelectOpacity } from '../state/constants.js';
import { Transform } from '../util/transform.js';
import { invertBand } from './legend-parsers.js';
import { CategoricalColorLegend, DataAttr, OpacityField, SelectOpacity } from '../../state/constants.js';
import { Transform } from '../../util/transform.js';
import { invertBand } from '../structures/legend-parser.js';

export function parseTransform(element, transforms = new Transform()) {
if (!element.transform) return;
Expand All @@ -26,14 +26,14 @@ export function inferMarkAttributes(state) {

// }

state.svgMarks = state.svgMarks.filter(d => d.type !== Line);
state.svgMarks = state.svgMarks.filter(d => d.type !== 'line');
// console.log(state.xAxis.scale.domain(), state.yAxis.scale.domain())
for (let i = 0; i < state.svgMarks.length; ++i) {
const mark = state.svgMarks[i]; const svgRect = state.svg._getBBox();
const markRect = mark._getBBox();

if (mark.type === Line) continue;
if (mark.type === Polyline) {
if (mark.type === 'line') continue;
if (mark.type === 'polyline') {
const points = mark.getAttribute('points').split(' ').map(d => d.split(',').map(e => Number(e)));
mark[DataAttr] = [];

Expand Down Expand Up @@ -63,7 +63,7 @@ export function inferMarkAttributes(state) {

const markX = state.xAxis.ordinal.length
? i
: state.yAxis.ordinal.length || mark.type === Rect
: state.yAxis.ordinal.length || mark.type === 'rect'
? markRect.right - svgRect.left
: markRect.centerX - svgRect.left;
const markY = state.yAxis.ordinal.length
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/data/dataset-parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loadCSV, loadJSON, table } from 'arquero';
import { map, range } from 'd3-array';
import { DataAttr, tableIndexField, tableMarkField } from '../state/constants.js';
import { DataState } from '../state/data-state.js';
import { DataAttr, tableIndexField, tableMarkField } from '../../state/constants.js';
import { DataState } from '../../state/data-state.js';

export async function parseDataset(options) {
if (!options || !Object.keys(options).length) return { };
Expand Down
8 changes: 8 additions & 0 deletions src/parsers/engine/parser-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { collectCandidateMarkGroups } from './parser-helpers.js';
import { inferLegends } from '../structures/legend-parser.js';
import { inferMarks } from '../structures/mark-parser.js';
import { inferTitles } from '../structures/text-parser.js';
import { inferMarkAttributes } from '../data/attribute-parser.js';
import { parseDataFromMarks } from '../data/dataset-parser.js';
// import { selectAll } from 'd3-selection';

export function parseChart(state) {
Expand All @@ -19,4 +21,10 @@ export function parseChart(state) {
candidateTextMarkGroups = candidateTextMarkGroups.filter(d => !legends.map(l => l.text).includes(d.marks));
inferMarks(state);
inferTitles(state, candidateTextMarkGroups.map(d => d.marks).flat());

// Infer data.
inferMarkAttributes(state);
state.data = parseDataFromMarks(state.svgMarks);

return state;
}
4 changes: 2 additions & 2 deletions src/parsers/linking/link-parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { escape, op, query, table } from 'arquero';
import { range } from 'd3-array';
import { generateQuery } from '../handlers/query.js';
import { SizeLegend, tableGroupIndexField, tableIndexField, tableMarkField } from '../state/constants.js';
import { generateQuery } from '../../handlers/query.js';
import { SizeLegend, tableGroupIndexField, tableIndexField, tableMarkField } from '../../state/constants.js';

const epsilon = 2;
export const AGGREGATIONS = {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/structures/axis-parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { max, min } from 'd3-array';
import { CenterX, CenterY, OrphanTickRole, RoleProperty, Tick, horizAlign } from '../../state/constants.js';
import { sortByViewPos } from '../../util/util.js';
import { getFormatVal } from '../data/attribute-parsers.js';
import { getFormatVal } from '../data/attribute-parser.js';
import { pairGroups } from '../engine/parser-helpers.js';
import { scaleBand, scaleLinear, scaleTime } from 'd3-scale';
import { axisBottom, axisLeft } from '../../_d3/axis.js';
Expand Down
2 changes: 1 addition & 1 deletion src/state/data-state.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LINK_TYPES } from '../parsers/link-parsers.js';
import { LINK_TYPES } from '../parsers/linking/link-parser.js';

export class DataState {
constructor(table) {
Expand Down
6 changes: 3 additions & 3 deletions src/util/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Right, Left, Top, CenterX, CenterY } from '../state/constants.js';
import { CenterX, CenterY } from '../state/constants.js';
import { sum } from 'd3-array';
import { path } from 'd3-path';

Expand All @@ -17,8 +17,8 @@ export function copyElement(element) {

export function computeCenterPos(element, orient) {
const clientRect = element._getBBox();
const offset = orient === Right || orient === Left ? clientRect.width / 2 : clientRect.height / 2;
return clientRect[orient] + (orient === Left || orient === Top ? offset : -offset);
const offset = orient === 'right' || orient === 'left' ? clientRect.width / 2 : clientRect.height / 2;
return clientRect[orient] + (orient === 'left' || orient === 'top' ? offset : -offset);
}

export function flattenRGB(rgb) {
Expand Down

0 comments on commit 28d8e8c

Please sign in to comment.