-
Notifications
You must be signed in to change notification settings - Fork 132
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
Support basic charts #1663
Comments
Related: I did a brief search and it seems like having integration with mermaid would be nice (Gitlab has native support for mermaid.js syntax). It supports pie chart, among other things. Also, it seems like we were trying to integrate it (in #1079 @crphang will you be continuing on it?) |
Thanks for looking into this @tlylt A higher priority for me is to add support for more charts such as pie, line, bar, histogram etc.
Unlikely, as he hasn't been active for quite a while now. |
For supporting basic charts, I am thinking we can support multiple javascript charting libraries like chart.js, in the same fashion as this markdown-it plugin:
I will need to test out the plugin to see if we can use it as is or make our own with a similar workflow. |
@tlylt I will not be working on it. Go ahead 💪 ! |
A lot of these external libraries require that you provide options as a json configuration object, from my very brief scan of chart.js this seems to be the case as well. E.g. for the Ergo also to keep in mind: if you see any rather complex-to-use configuration options (that have use cases in markbind) that ought to be extracted, you could consider whether we need to abstract over it.
We currently already have the above lower level ways of importing data from json / csv files.
❗ ❗ From an author perspective, I'm not sure if this is enough or some abstraction should be done over this particular part (supplying data). For example, We can also consider starting out with this usage (i.e. the author needs to know how to supply the
https://markbind.org/devdocs/devGuide/writingPlugins.html#tag-behaviour You could use this ^ to define your own "special tags". Its what we're using for inline It follows the same parsing rules as We should avoid mixing triple backticks syntax as its use case is well established for code blocks already. |
Fully agree. We can start with this kind of support first and add more user-friendly syntax for more common chart types later. |
Recent update: GitHub now has native support for Mermaid: https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/ Perhaps it's mentioned somewhere but I can't really find it...why did we settle on creating custom HTML tags like <puml> instead of putting it as part of the code fence?
|
@tlylt Isn't the purpose of fenced code feature is to show syntax-highlighted code? If we use the same syntax for embedding diagrams, how do you distinguish between the two features? But yes, given that neither puml nor mermaid has syntax highlighting support as of now, seems like it can work, and I'm OK to support the same for the sake of compatibility. |
In any case, given GitHub already supports mermaid, I think we'd better start supporting it too :-p |
hmm I see your point now... indeed if someone wants to just show the raw puml/mermaid code with syntax highlight support (may not be available at the moment), I guess there is no way to do it if we use code fence. The only workaround is to not specify the language info. |
Relevant PR: #968
Yup, but for syntax highlighting. At the time of this PR (2 years back) ^, ```mermaid was never really "standard". My personal 2 cents today as well still is that markdown code blocks shouldn't be used to generate anything other than code blocks, its mixing use cases and syntaxes that have nothing to do with each other semantically. Also, not quite commonmark compliant in that triple backticks/tildes should generate fenced code blocks.
Another smaller point raised (in the pr) was that specifying In any case since github has started supporting this syntax, I agree we should support it as well (or at least the option of it). We can create a simple markdown plugin addition to replicate this functionality quite easily (i.e. transform ```puml to |
Looking through some of the javascript charting libraries, I realised that it is currently possible to create charts by writing some HTML/javascript code in a
There is a caveat that for inline HTML elements, it will be wrapped with a So for example, chartjs, the steps are:
So
Seems like "rare" things are already possible
@ang-zeyu sorry I don't quite get what you mean by "markdown plugins", what's the difference between this and the current kind of plugins?
I agree with the points mentioned. I think I am trying to be careful about what we decide to abstract such that the abstraction is useful, maintainable, and not leaky. Working on charts/visualizations in my other projects, I realized that people have varied needs & diverse requirements in terms of what a chart should look like for their use case(which is why charting libraries have a huge list of configurable options). Therefore, I would think that it is quite hard for someone to skip reading/referring to the official documentation of a charting library in order to find what's the correct syntax/options to use. I guess at least for a start, this is what I propose:
Elaboration on pt 3:
Example syntax:
|
an extension here, more specifically maybe something like this to allow our plugins to tap into markdown-it's own plugin system (for keeping everything isolated within markbind-plugin-plantuml.js as a plugin):
|
To confirm, do you mean to allow users to create a plugin that we pass the markdown content as input and the plugin can work on the transformation of the markdown content before we process the markdown (so somewhere after Prerender and before markdown rendering)?
Still don't quite get what you mean by isolating 😅. As in creating the functionality of the markbind-plugin-plantuml.js as a markdownIt plugin (compatible and usable for anybody using markdownIt) and then internally, the markbind-plugin-plantuml.js can plug the plugin into our markdownIt instance so that it alters how Markdown parsing is done? |
Nope, nothing so complex 😅. I'm referring to tapping into markdown-it's own plugin system, the same one you were exploring in #1685. Isolating as in for cohesion / code quality (a little odd for MarkBind's own plugin code to be littered all over its files)
Just one syntax / suggestion to tap into their plugin system, feel free to explore others! update: simple solution here #1940 (comment) |
I can help to bring this feature into markbind |
@SPWwj we are somewhat conflicted about this feature. On the one hand that's how Github implemented it, and it would be nice to be consistent with them. On the other hand, three back ticks followed by |
Agree, this syntax is most intuitive.
However, I'm uncertain about the necessity of this limitation. |
Pls see the conversation above and answers given by Zeyu. #1663 (comment) |
Suggestions: Provide support (likely through a third-party plugin) to add basic charts (e.g., bar/line/pie ... charts) using text sources (or csv files), similar to how we support basic UML diagrams.
(Updating the description to include the TODO from the attempt in #2052
(Updating the description to include conclusions/TODOs from the discussions below, see #1663 (comment))
<pie-chart>data = [1,2,3]</pie-chart>
.Elaboration on the last point:
Example syntax:
The text was updated successfully, but these errors were encountered: