FVANCOP / ChartNew.js

MIT License
420 stars 143 forks source link

Superscript for html Canvas? (e.g. 2 ^ 3) #521

Closed tasoskakour closed 6 years ago

tasoskakour commented 6 years ago

First of all, congratulations to this wonderful work!

I want to show a number raised to a power in the yLabelAxis. For example I want to show 10^3 with the '3' positioned as the power. I see that sup is not supported from canvas. 10<sup>3</sup>

Is it possible to do this?

FVANCOP commented 6 years ago

Hi,

I've checked on the web, but apparently special characters (like ² and ³) cannot be displayed on Canvas and tags are not allowed in canvas text. I've no simple solution for you... Working with the add-ins "shapesInChart" could be a bypass but not really easy to use for such a request.

Perhaps someone else will have a solution...

François

https://github.com/FVANCOP/ChartNew.js/wiki/900_050_Shapes-Text-Images_In_Chart

markosko commented 6 years ago

idiotic thing maybe but String.fromCharCode(253) wouldnt works 253 is power of 2 and its part of extended ascii table

markosko commented 6 years ago

okey sorry so for power of 2 or 3 can be done with "\u00B2" for 2 and "\u00B3" for 3 for others you can only check out unicode table for bigger power of x image

EDIT: Actual using is for example - xAxisLabel:"power of \u00B2"

FVANCOP commented 6 years ago

@markosko - Nice to know and really interesting ! Thanks a lot. I will update the sample function_x2.html :-)

@others : Following link will give a complete liste of all available power chars. https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

Example : \u207D\u207F\u207A\u2075\u207E <=> (n+5) in "superscript".

Other link with a complete list of all unicode chars... https://unicode-table.com/en/#control-character

tasoskakour commented 6 years ago

Thanks a lot!,