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

Add Point Styling in Quadrant Chart #4995

Closed
omervk opened this issue Oct 29, 2023 · 3 comments · Fixed by #5173
Closed

Add Point Styling in Quadrant Chart #4995

omervk opened this issue Oct 29, 2023 · 3 comments · Fixed by #5173

Comments

@omervk
Copy link

omervk commented Oct 29, 2023

Proposal

Mermaid.js should add point styling to individual points to allow for more (color, radius, border color, etc.) dimensions of information.

For instance, each point may represent a task located on the Urgent/Important quadrant chart. Adding more styling could allow color to indicate whether something is already in progress, while radius could indicate the size of the task.

Example:
image

Example

Alternative 1

Borrowing from flowchart:

quadrantChart
    %% ...
    "Point A": [0.8, 0.45]
    style "Point A" fill: #f9f, stroke: #333, stroke-width: 4px

The only difficulty here would be that points do not have ids and therefore names would be used.

Alternative 2

quadrantChart
    %% ...
    "Point A": [0.8, 0.45, 12] color: #f9f, border-color: #333, border-width: 4px

The extra variable is size, as it describes a dimension in the building of the point, rather than a style. Does not have the issue of having to reference the point by id and is backwards compatible (size defaults to 5).

Screenshots

No response

@omervk omervk added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Oct 29, 2023
@sidharthv96 sidharthv96 added Contributor needed Status: Approved Is ready to be worked on Good first issue! Area: Development feature Graph: XY XY Chart and removed Status: Triage Needs to be verified, categorized, etc labels Nov 2, 2023
@sidharthv96
Copy link
Member

I'm not a fan of including the size within the [ ].
Keeping it as part of the style section seems to be a cleaner choice.

    "Point A": [0.8, 0.45] color: #f9f, border-color: #333, border-width: 4px, size: 12

But, now if someone wants to add the same styling to multiple points, there will be repetition.
I guess that's why classdefs were added in flowcharts.
So we should try to adopt stuff from https://mermaid.js.org/syntax/flowchart.html#styling-a-node to keep things consistent.

@JingyuMarcelLee
Copy link
Contributor

Hi, I am new to Mermaid, and this seems like a good first issue to start. Can I work on this issue if no one is working on it? I will add the size as part of the style section see if it works with the classdef.

@jgreywolf jgreywolf added include and removed include labels Nov 16, 2023
@JingyuMarcelLee
Copy link
Contributor

I'm still struggling with the Jison parsing and refactoring. My first goal was to just include the direct definition next to the point statement just as shown in the comment earlier without thinking about the class def. One problem is that the author of QuadrantChart has defined the QuadrantPointType by implementing the Point interface defined in /packages/mermaid/src/types.ts.

export interface QuadrantPointType extends Point {
  fill: string;
  radius: number;
  text: QuadrantTextType;
}

For now, it shouldn't be a problem, but it could be an issue in the future if I want to include other style definitions like border-color. One solution could be using similar ways how flowchart adds styled vertices. Not sure if this would be an overkill for this issue though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants