Giter Site home page Giter Site logo

Comments (8)

jszuminski avatar jszuminski commented on June 26, 2024

@istvanherbak thanks for reporting!

I will investigate this issue this week and try to propose a sensible solution.

from node-export-server.

jszuminski avatar jszuminski commented on June 26, 2024

@istvanherbak it is not a bug - by default, we do not include the highcharts.css file which results in a 'black image'.

Here's a Vanilla JS demo showing the issue: https://jsfiddle.net/BlackLabel/hzf7b5Lm/

The simplest solution to this problem is just including the highcharts.css file as a resource. Here's a code snippet:

{
"export": {
"options": {
"chart": {
"styledMode": true,
"type": "column"
},
"title": {
"text": "Styling axes (Raw CSS with the default CSS file)"
},
"yAxis": [{
"className": "highcharts-color-0",
"title": {
"text": "Primary axis"
}
}, {
"className": "highcharts-color-1",
"opposite": true,
"title": {
"text": "Secondary axis"
}
}],
"plotOptions": {
"column": {
"borderRadius": 5
}
},
"series": [{
"data": [1, 3, 2, 4]
}, {
"data": [324, 124, 547, 221],
"yAxis": 1
}]
}
},
"customCode": {
"allowCodeExecution": true,
"allowFileResources": true,
"resources": {
"css": "@import 'https://code.highcharts.com/css/highcharts.css'; .highcharts-yaxis .highcharts-axis-line { stroke-width: 2px; } .highcharts-color-0 { fill: #f7a35c; stroke: #f7a35c; } .highcharts-axis.highcharts-color-0 .highcharts-axis-line { stroke: #f7a35c; } .highcharts-axis.highcharts-color-0 text { fill: #f7a35c; } .highcharts-color-1 { fill: #90ed7d; stroke: #90ed7d; } .highcharts-axis.highcharts-color-1 .highcharts-axis-line { stroke: #90ed7d; } .highcharts-axis.highcharts-color-1 text { fill: #90ed7d; } #renderer-callback-label .highcharts-label-box { fill: #90ed7d;}"
}
}
}

from node-export-server.

istvanherbak avatar istvanherbak commented on June 26, 2024

I am using the v3 branch as a server. I tried to make it work, but no luck.

Here is the request body
{
"type": "svg",
"constr": "chart",
"width": 0,
"height": 0,
"resources":{
"css":"@import 'https://code.highcharts.com/css/highcharts.css'"
},
"infile": {
"chart": {
"styledMode": true
},
"series": [
{
"data": [
1,
3,
2,
4
]
},
{
"data": [
324,
124,
547,
221
]
}
]
}
}

from node-export-server.

jszuminski avatar jszuminski commented on June 26, 2024

@istvanherbak by default, allowCodeExecution is disabled; thus, the resources are not loaded.

Please follow the code snippet that I've listed in my post above (where the allowCodeExecution, allowResources are set to true). If you follow the same way of configuration (putting it in customCode), everything should work.

from node-export-server.

istvanherbak avatar istvanherbak commented on June 26, 2024

Sorry but something still does not add up.

{
"type": "svg",
"constr": "chart",
"width": 0,
"height": 0,
"customCode": {
"allowFileResources": true,
"allowCodeExecution": true,
"resources": {
"css": "@import 'https://code.highcharts.com/css/highcharts.css'"
}
},
"infile": {
"chart": {
"styledMode": true
},
"series": [
{
"data": [
1,
3,
2,
4
]
},
{
"data": [
324,
124,
547,
221
]
}
]
}
}

This is invalid json, gives me

TypeError: Cannot create property 'allowFileResources' on boolean 'false'
   at mergeConfigOptions (file:///C:/Temp/HighCharts3/src/node-export-server/lib/config.js:198:24)
   at mergeConfigOptions (file:///C:/Temp/HighCharts3/src/node-export-server/lib/config.js:202:11)
   at mergeConfigOptions (file:///C:/Temp/HighCharts3/src/node-export-server/lib/config.js:202:11)
   at exportHandler (file:///C:/Temp/HighCharts3/src/node-export-server/lib/server/routes/export.js:215:19)
   at Layer.handle [as handle_request] (C:\Temp\HighCharts3\src\node-export-server\node_modules\express\lib\router\layer.js:95:5)
   at next (C:\Temp\HighCharts3\src\node-export-server\node_modules\express\lib\router\route.js:144:13)
   at Route.dispatch (C:\Temp\HighCharts3\src\node-export-server\node_modules\express\lib\router\route.js:114:3)
   at Layer.handle [as handle_request] (C:\Temp\HighCharts3\src\node-export-server\node_modules\express\lib\router\layer.js:95:5)
   at C:\Temp\HighCharts3\src\node-export-server\node_modules\express\lib\router\index.js:284:15
   at Function.process_params (C:\Temp\HighCharts3\src\node-export-server\node_modules\express\lib\router\index.js:346:12)

If i use

{
"type": "svg",
"constr": "chart",
"width": 0,
"height": 0,
"allowFileResources": true,
"allowCodeExecution": true,
"resources": {
"css": "@import 'https://code.highcharts.com/css/highcharts.css'"
},
"infile": {
"chart": {
"styledMode": true
},
"series": [
{
"data": [
1,
3,
2,
4
]
},
{
"data": [
324,
124,
547,
221
]
}
]
}
}

Then it is still black.

Thanks

Also allowFileResources becomes false always when using server.

from node-export-server.

jszuminski avatar jszuminski commented on June 26, 2024

Which CLI command are you using? Could you please share the reproduction steps of this error?

from node-export-server.

istvanherbak avatar istvanherbak commented on June 26, 2024

Start a server with
node bin\cli.js --host localhost --port 8701 --allowCodeExecution true --logLevel 4

Use the attached file to send over to the server. See chart is fine as png.
test.json

Change the "type" to svg and send over againhave black square

Hope it helps
Thanks

from node-export-server.

istvanherbak avatar istvanherbak commented on June 26, 2024

Hi,
Sorry for reopening, but it is still not working. I am using server mode and the import does nothing with the highcharts.css.

Any other possible workarounds?

Thanks

from node-export-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.