Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throwing an error in charts #46

Closed
mikima opened this issue Jan 7, 2021 · 2 comments
Closed

throwing an error in charts #46

mikima opened this issue Jan 7, 2021 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@mikima
Copy link
Member

mikima commented Jan 7, 2021

Is it possible to throw an error from the chart to RAWGraphs interface? For example, in radar chart you should drop at minimum three dimensions to see something. Would be nice to tell it to the user

@mikima mikima added the question Further information is requested label Jan 7, 2021
@bianchimro
Copy link
Contributor

bianchimro commented Jan 11, 2021

hi @mikima yes, it's possible by just throwing a js error in your render function

throw new Error("Hello error")

that renders like this:

Screenshot 2021-01-11 at 21 54 02

There was a problem showing the error in the frontend, I just fixed it here
https://github.com/rawgraphs/rawgraphs-frontend/commit/9a539ce16c9b794c1675991f94e459b6bc932208
(still needs some styling, but there was a positioning issues and the error was sometimes hidden)

Your specific use case is covered by the dimensions api. When you declare a dimension, you can set minValues and maxValues properties (indipendently) to require/limit the maximum number of values that can be mapped on a multiple dimension.
Like:

export const dimensions = [
  {
    id: 'axes',
    name: 'spokes',
    validTypes: ['number'],
    required: true,
    multiple: true,
    minValues: 2,
    aggregation: true,
    aggregationDefault: {
      number: 'sum',
      string: 'csvDistinct',
      date: 'csvDistinct',
    },
  },
  ...
]

This should the way to do it but:

  • It's not documented (sorry, working on this!)
  • The frontend at the moment does not show this kind of error. This is a mapping error that forbids render, so it's not even shown under the artboard like the error in the screenshot above. We should decide if it should be shown here or in the mapping section.
    Personally, I'd show it in the mapped dimension, that is also much easier to implement at the moment

@mikima
Copy link
Member Author

mikima commented Jan 12, 2021

Great! Thanks

@mikima mikima closed this as completed Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants