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 an option to plot simple bar charts in a generated column #75

Open
tdwright opened this issue Apr 17, 2022 · 1 comment · Fixed by #76
Open

Add an option to plot simple bar charts in a generated column #75

tdwright opened this issue Apr 17, 2022 · 1 comment · Fixed by #76
Assignees

Comments

@tdwright
Copy link
Owner

For numeric columns, it would be cool to be able to visualize these as a simple bar chart in a new column.

For instance:

╭─────────┬────────┬────────────────────────────────────────────────────────────╮
│         │        │                                                            │
│ Name    │ Radius │ Radius chart                                               │
│         │        │                                                            │
├─────────┼────────┼────────────────────────────────────────────────────────────┤
│         │        │                                                            │
│ Mercury │ 2439   │ ##                                                         │
│         │        │                                                            │
│ Venus   │ 6052   │ #####                                                      │
│         │        │                                                            │
│ Earth   │ 6371   │ #####                                                      │
│         │        │                                                            │
│ Mars    │ 3389   │ ##                                                         │
│         │        │                                                            │
│ Jupiter │ 69911  │ ########################################################## │
│         │        │                                                            │
│ Saturn  │ 58232  │ ################################################           │
│         │        │                                                            │
│ Uranus  │ 25362  │ #####################                                      │
│         │        │                                                            │
│ Neptune │ 24622  │ ####################                                       │
│         │        │                                                            │
╰─────────┴────────┴────────────────────────────────────────────────────────────╯

This gives a nice quick visual representation of the data in the column. The above example can be achieved with existing functionality by doing something like:

table.Columns.AddGeneratedColumn<int, string>(
	d => {
		var normalized = d / 2400;
		return new string('#', normalized);
	},
	"Radius chart",
	table.Columns["Diameter"]
);

But, since the scope of the lambda here is limited to data from individual rows, we have no way of automagically scaling the chart to an appropriate scale. In the above example, I've hard coded the fact that each unit of width of the bars corresponds to 2400km, but this is not ideal.

In a proper implementation, there would be a quick way of adding a chart column that didn't need the lambda writing out, nor any prior knowledge of the correct scale.

In terms of API design, I imagine users would want the ability to:

  1. override scale
  2. set the bar character
  3. define overall width.

NB: 1 and 3 may not be compatible - what's the most intuitive way of handling this?

@tdwright
Copy link
Owner Author

Another question - should we enforce a particular LongStringBehaviour for the generated column?

@tdwright tdwright linked a pull request Apr 18, 2022 that will close this issue
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.

1 participant