Giter Club home page Giter Club logo

layerchart's Introduction

LayerChart

npm

A large collection of composable Svelte chart components to build a wide range of visualizations

  • Cartesian (Bar, Area, Stack, Scatter)
  • Radial (Pie, Arc, Sunburst)
  • Hierarchy (Pack, Tree, Treemap, Sunburst)
  • Graph (Sankey)
  • Geo (Choropleth, Spike, Bubble, Point, Globe)

Interactions

  • Tooltip, Highlights, Pan/Zoom

SVG

  • Basic (Arc, Circle, Group, Line, Spline, Text)
  • Gradients and Patterns
  • ClipPath
  • Multi-line text

Others

  • Legends including ColorRamps

See also the companion library Svelte UX for a large collection of components, actions, stores, and utilities to build highly interactive applications.

Contributing

Install dependencies

pnpm i

Run dev server for layerchart package

cd packages/svelte-ux
pnpm dev

Add changeset to include change in changelog and determine next version

pnpm changeset

layerchart's People

Contributors

dit7ya avatar github-actions[bot] avatar itsonlyjames avatar mattlangeman avatar techniq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

layerchart's Issues

Sorting issues in Tooltip examples

Issue

Incorrect sorting of data on examples similar to Single Date / Time Example

item 10 getting put between item 1 and item 2

Details

Almost surely caused by the same Layer Cake sorting change mentioned in issue #54

Solution?

Quickest fix is changing the examples to include:

yDomain={[...new Set(timeSeries.map((d) => d.name))]}

Hierarchy / Graph charts

Hierarchy

Bar Chart features / examples


Examples

Supported Charts

Basic

Hierarchy

Time

Interaction

  • Pan / Zoom
  • Brush

Statistics / Analytics

Other

See also

Bump / Parallel Coordinates

Radial / spiral charts

  • Radar chart
  • Radial line / area charts
  • Radial bar charts
  • Radial bar chart (around)
  • Gauge
  • Spiral

Examples

Radar chart

Radial line / area charts

Radial bar charts

Radial bar chart (around)

Gauge

Spiral

Gradient components

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" class="shape">
  <defs>
    <linearGradient id="header-shape-gradient" x2="0.35" y2="1">
        <stop offset="0%" stop-color="var(--color-stop)" />
        <stop offset="30%" stop-color="var(--color-stop)" />
        <stop offset="100%" stop-color="var(--color-bot)" />
      </linearGradient>
  </defs>
  <g>
    <polygon class="gradient-bg" points="0,0 100,0 0,66" />
  </g>
</svg>
.shape {
  width:500px;
  height:200px;
}

.shape .gradient-bg {
  fill: url(#header-shape-gradient) #fff;
}

#header-shape-gradient {
  --color-stop: #f12c06;
  --color-bot: #faed34;
}

Legends / Color Ramps

Tooltip / Highlight improvements

Tooltip / Selection

HighlightLine

  • Improve handling of scaleBand() on y
  • Support showing crosshairs (2 lines per point)
  • Support handling different axis/scale (see above)
  • Add slot overrides for points and lines

HighlightRect

  • Support showing x-axis (current), y-axis, or containing box based on values within xScale/yScale (see "both" scale above)

HighlightLabel

New Text component - Simplify, fix styled, support path, etc

Currently Text is a partial port of Text from visx, although it might be overkill unless multiline is needed, and currently needs improved to handle styled text, etc (measurement needs to be down offscreen).

I recently learned of alignment-baseline and dominant-baseline which appears to align vertically, although I'm currently uncertain the uses for each (need to read up more) and the browser support in Safari / Firefox compared to Chrome.

I setup a REPL to feel things out, and there is also an observable notebook with more ideas including support for multiline. When testing the notebook in Safari and Firefox, I noticed some differences and unsupported features.

Features

Road to v1

Component cleanup

  • Axis
    • Integrate getMajorTicks() / getMinorTicks()
    • Show 2 rows (years below months)
  • Area (context, data prop, pathData)
  • AreaStack (context)
    • Support data prop
  • Bars (context)
    • Support data prop?
  • ConnectedPoints
    • Remove (support by Link or Points?)
  • Labels
    • Consolidate with Points (at least reuse implementation)
  • Link (data prop only)
    • Support ConnectedPoints use case?
  • Path (context, data prop)
    • Rename to LinePath or Spline (since there is already a Line primitive). Used for line charts
  • Points
    • Consolidate with Labels (at least reuse implementation)
    • Support ConnectedPoints use case?
  • Path (context, data prop)
  • Pie (context, data prop)
  • Threshold (context, data prop)
  • Tooltip
    • Support pinning to side (go along axis, etc)
    • Rename animate to tweened or motion
  • Consider consolidating ClipPathUse into ClipPath
  • Remove color prop (use rScale and fill / stroke / class / style?
  • Consider renaming all tweened props to motion

Examples

Improvements

Docs

  • Add description, features, and related to all components
  • Move all TODO's to issues / cleanup
  • Document which components support SVG, Canvas, etc
  • Document how components use data
    • data via context
    • data prop
    • other (pathData, etc)
  • Add home page / getting started
  • Document principals
    • Where does the component read it's data from (context, data prop, other)?
    • Does the component work in SVG coordinates, data values, or both?
  • Customizing (theme support, etc)
    • Colors
    • Frame
    • Props passed to underlying components (ex. Axis with grid, rule, etc)

Tree

Annotations / Links

Label positioning

Treemap

  • Remove selected prop
  • Improve zoomable nested
    • Apply extent ratio? const extentRatio = ($extents.y1 - $extents.y0) / $height;

Arc / Pie Labels

Animate scales / axis / grid

[Tooltip] Improve docs / add more examples

Extracted from #45 (comment)

With TooltipContext / Tooltip, there are basically 3 ways to position:

  • By default, TooltipContext will use the mouse/pointer position, and Tooltip will apply an offset by default (mostly to not cover up the point you are interested in)
  • In TooltipContext, you can opt into snapping the position to the closest data point's X and/or Y
  • In Tooltip, you can specify explicit top / left positions, overwriting/ignoring what is set in the TooltipContext. This was a recent addition we made for the Sparkline example, but I'd like to add more examples to show what kind of use cases this supports
    • A fixed tooltip in the top left (or any corner) by specifying values for both props (ex. <Tooltip top={8} left={8} />)
    • Only specifying a fixed top such as this visx example or these Observable plot examples which would use 2 instances of <Tooltip>, one with a fixed top and one with a fixed left.

Examples

Geo v2

Continued work of original Geo PR, as well as additional examples / features from the original issue.

Tooltip issue with localPoint when chart has left padding

Main Issue

I noticed an issue with the Tooltip when a chart has left padding. The Tooltip has issues picking the correct data point.

Issue Details

When TooltipContext gets the localPoint, the localX value is never below the value of the left padding for the chart.

const point = localPoint(referenceNode, event);
const localX = point?.x ?? 0;
const localY = point?.y ?? 0;

This means it does not get the proper xValueAtPoint.

const xValueAtPoint = scaleInvert($xScale, localX);

Solution?

I don't know whether it is as simple as subtracting the left padding to setting localX.

Screen Recordings

Line Chart example that has left: 16. Not super noticeable.
tooltip-line-chart-left-padding-16

Line Chart example with left: 32. Very noticeable.
tooltip-line-chart-left-padding-32

Line Chart example with left: 0. Removes the issue.
tooltip-line-chart-left-padding-0

Tooltip Interactions example left: 36 Very noticeable.
tooltip-scatterplot-left-padding-36

Tooltip Interactions example left: 0 Removes the issue.
tooltip-scatterplot-left-padding-0

localX value when left: 32
localX-of-TooltipContext

Theme / styling with settings()

  • Use classes like Svelte UX to pass class to underlying components
  • Add createTheme() support
  • Add .ComponentName classes
  • Remove color prop (use rScale and fill / stroke / class / style?
    • Bars
    • Points
    • Pie
    • Link
    • Highlight
  • Support design tokens (css variables) (see Svelte UX issue)
    • Should wait till the Svelte UX issue is resolved
  • Remove all use of var(--color-xxx-xxx). Default to fill-accent-500 when possible (or possibly class="[--color:theme(colors.blue.500)]"
  • Use const { format } = settings() / $format instead of formatNumber() / formatDate() directly

Gnatt / Timeline

Pack

Pan/Zoom/Draggable

TODO

References

image

Statistics

Geography Map

Use cases

Examples

Other libraries

Reference

Globe (3D)

Brush / Scrubbing


Examples

Calendar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.