You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/08/02 12:32:25 UTC

[GitHub] [echarts] mbork edited a comment on issue #13536: The font size problem of the label of the line graph set by echarts rendered by svg

mbork edited a comment on issue #13536:
URL: https://github.com/apache/echarts/issues/13536#issuecomment-890954358


   Hi there,
   
   I think I encountered the same issue, and also found the reason: echarts seems to use the `font` shorthand property, but puts the properties in a wrong order.
   
   Interestingly, it seems to work ok in the browser. However, I am using echarts on the backend, in Node.js, and here things seem to be broken. Here is my code:
   ```js
   const echarts = require('echarts');
   const {JSDOM} = require('jsdom');
   
   const {window} = new JSDOM();
   global.document = window.document;
   global.navigator = window.navigator;
   const root = document.createElement('div');
   
   const chart = echarts.init(root, null, {
       renderer: 'svg',
   	width: 600,
   	height: 400,
   });
   chart.setOption({
   	animation: false,
   	xAxis: {
   		type: 'category',
   		data: [{value: 'a', textStyle: {fontSize: 30}}, 'b'],
   	},
   	yAxis: {type: 'value', min: 0, max: 100},
   	series: {
   		type: 'bar',
   		name: 'data',
   		data: [20, 60],
   	},
   });
   
   console.log(root.querySelector('svg').outerHTML);
   
   chart.dispose();
   ```
   The  `package.json` file looks like this:
   ```json
   {
     "name": "echarts-backend-test",
     "version": "1.0.0",
     "description": "",
     "main": "echarts-backend-test.js",
     "scripts": {
       "test": "echo \"Error: no test specified\" && exit 1"
     },
     "keywords": [],
     "author": "",
     "license": "ISC",
     "dependencies": {
       "echarts": "^5.1.2",
       "jsdom": "^16.6.0"
     }
   }
   ```
   
   When I look into the resulting `svg`, I can see the following attribute on the `text` element:
   ```
   style="font: sans-serif 30px normal normal normal 30px;"
   ```
   which both Firefox and Chromium treat as invalid.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org