Giter Site home page Giter Site logo

Comments (2)

xuefei1313 avatar xuefei1313 commented on May 22, 2024

The design of this function is support discrete legend bind a glabol scale, followed Grammar Design.

/** spec */
export type IDiscreteLegendSpec = {
  // ...others
  /**
   * scaleName must match the id of the scale configured in **scales**
   */
  scaleName?: string;
  /**
   * After the legend is bound to the scale, the dimension associated with the series data and the legend can be configured through field.
   * If the field is not configured, the first item of fields in the domain of scale is used by default
   * If the domain of the scale is not dependent on data statistics, series.getSeriesField() is used by default
   */
  field?: string;
}

example spec:

const spec = {
    type: 'scatter',
    data: {
      id: 'lineData',
      values: [
        { type: 'Nail polish', country: 'Africa', value: -4229, shape: 'A' },
        { type: 'Nail polish', country: 'EU', value: -4376, shape: 'A' },
        { type: 'Eyebrow pencil', country: 'Africa', value: -3932, shape: 'A' },
        { type: 'Eyebrow pencil', country: 'EU', value: -3987, shape: 'A' },
        { type: 'Nail polish', country: 'Africa', value: -4229, shape: 'B' },
        { type: 'Nail polish', country: 'EU', value: -4376, shape: 'B' },
        { type: 'Eyebrow pencil', country: 'Africa', value: -3932, shape: 'B' },
        { type: 'Eyebrow pencil', country: 'EU', value: -3987, shape: 'B' }
      ]
    },
    title: {
      visible: true,
      text: 'Stacked line chart'
    },
    stack: true,
    xField: 'type',
    yField: 'value',
    seriesField: 'country',
    point: {
      style: {
        fillOpacity: 1,
        symbolType: {
          scale: 'shapeScale',
          field: 'shape'
        }
      },
      state: {
        custom_unSelected: {
          fillOpacity: 0.5
        }
      }
    },
    scales: [
      {
        id: 'shapeScale',
        type: 'ordinal',
        domain: [
          {
            dataId: 'lineData',
            fields: ['shape']
          }
        ],
        range: ['triangle', 'diamond']
      }
    ],
    legends: [
      {
        visible: true,
        position: 'middle',
        orient: 'bottom',
        offsetX: -100,
        item: {
          shape: {
            style: {
              symbolType: 'circle'
            }
          }
        }
      },
      {
        visible: true,
        position: 'middle',
        orient: 'bottom',
        scaleName: 'shapeScale',
        item: {
          shape: {
            style: {
              fill: 'red'
            }
          }
        }
      }
    ],
    region: [{}],
    axes: [
      {
        orient: 'bottom',
        visible: false
      },
      {
        orient: 'bottom',
        visible: true,
        seriesIndex: [],
        type: 'linear',
        min: 0,
        max: 100
      }
    ]
  }

from vchart.

xuefei1313 avatar xuefei1313 commented on May 22, 2024

image

from vchart.

Related Issues (20)

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.