vtex / shoreline

Design System for the VTEX Admin, previously called Admin UI
https://shoreline.vtex.com
15 stars 0 forks source link

Feature/charts package #1648

Open natanfernandes opened 3 weeks ago

natanfernandes commented 3 weeks ago

Summary

The @vtex/shoreline-charts library wraps echarts in a react component with consistent theming.

Default styles

@vtex/shoreline-charts will contains default styles for all chart, in order to get a easy setup for a chart, in this PR we've a demo with the Bar chart. For the default styles we have variants, which is a pre-defined attributes on theme in addition to a pre-defined values to the series itself, but the user is free to edit and customize the chart as your own.

Installation

pnpm add @vtex/shoreline @vtex/shoreline-charts echarts

Examples

Simple chart setup

<Chart 
  option={{
    xAxis: {
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    series: {
      data: [1, 2, 3, 4, 5, 6, 7]
    }
  }} 
  type="bar" 
  style={{
    height: 550
  }} 
/>

Captura de Tela 2024-06-11 às 16 20 11

Variant chart

<Chart 
  option={{
    xAxis: {
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
   series: [{
      data: [1, 2, 3, 4, 5, 6, 7]
    }, {
      data: [1, 4, 2, 1, 4, 3, 5]
    }]
  }} 
  type="bar" 
  variant="horizontal"
  style={{
    height: 550
  }} 
/>

Captura de Tela 2024-06-11 às 16 22 38

vercel[bot] commented 3 weeks ago

Deployment failed with the following error:

You don't have permission to create a Preview Deployment for this project.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

matheusps commented 3 weeks ago

An API question: What will happen to the variant property when you add another chart (type)? Every chart type will have an "horizontal" variant?

natanfernandes commented 3 weeks ago

An API question: What will happen to the variant property when you add another chart (type)? Every chart type will have an "horizontal" variant?

After implement the variant this case come to my mind, at this moment, just bar has the horizontal variant, the first solution that i thought was when the type hasnt the variant, return the default. Second solution is create the variant type according to the type variants, like bar.horizontal or something but seems to be more complex

natanfernandes commented 2 weeks ago

I moved the type and variant props to chartConfig, by this we can validate the variant according to the type

matheusps commented 2 weeks ago

Updating the status, @beatrizmilhomem and @davicostalf are checking the design part of the PR.