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

Support change background #52

Open
kubitre opened this issue Oct 7, 2021 · 15 comments
Open

Support change background #52

kubitre opened this issue Oct 7, 2021 · 15 comments

Comments

@kubitre
Copy link

kubitre commented Oct 7, 2021

Hello! I want to upgrade your wonderful library so that it allows you to change the background. just pass the background setting (color)(change naming, this color is GridLinesColor):

gridColor: '#dedede', // Color of grid lines

Change as:

gridColor: '#fff', // Color of grid background
gridLinesColor: '#dedede' // Color of grid lines

, and after need add in svg rendering

<rect width="100%" height="100%" fill="url(#horizontalLines)" transform="translate('+ 0 + ', ' + initialValueY + ')" />\n\
<rect width="100%" height="100%" fill="url(#verticalLines)" transform="translate('+ initialValueX + ', ' + 0 + ')" />\n\

following code:

<svg width="'+ canvasWidth + '" height="'+ canvasHeight + '" xmlns="http://www.w3.org/2000/svg">\n\
            <defs>\n\
                <pattern id="horizontalLines" width="' + increment + '" height="' + increment + '" patternUnits="userSpaceOnUse">\n\
                    <path d="M ' + increment + ' 0 L 0 0 0 ' + 0 + '" fill="none" stroke="' + options.gridLinesColor + '" stroke-width="' + options.lineWidth + '" />\n\
                </pattern>\n\
                <pattern id="verticalLines" width="' + increment + '" height="' + increment + '" patternUnits="userSpaceOnUse">\n\
                    <path d="M ' + 0 + ' 0 L 0 0 0 ' + increment + '" fill="none" stroke="' + options.gridLinesColor + '" stroke-width="' + options.lineWidth + '" />\n\
                </pattern>\n\
            </defs>\n\
<rect width="100%" height="100%"  fill="' + options.gridColor + '" />\n\
<rect width="100%" height="100%" fill="url(#horizontalLines)" transform="translate('+ 0 + ', ' + initialValueY + ')" />\n\
<rect width="100%" height="100%" fill="url(#verticalLines)" transform="translate('+ initialValueX + ', ' + 0 + ')" />\n\

This result i showed on attached image:
image

@kubitre
Copy link
Author

kubitre commented Oct 7, 2021

@ugurdogrusoz

@kubitre
Copy link
Author

kubitre commented Oct 7, 2021

@kinimesi @royludo @metincansiper please, asnwer, this is feature

@ugurdogrusoz
Copy link
Contributor

@kubitre Feel free to do a PR to the unstable branch please

@kinimesi
Copy link
Collaborator

kinimesi commented Oct 8, 2021

@kubitre why don't you just set the background color of cytoscape div?

@kubitre
Copy link
Author

kubitre commented Oct 8, 2021

@kinimesi it seems that this option is a crutch =) The point is not to do it well for me, but to everyone who possibly uses this lib. If you change the background through the configuration, besides, this is not a super global change, backward compatible, I see no reason not to support it

@kubitre
Copy link
Author

kubitre commented Oct 8, 2021

@ugurdogrusoz check my pr please

@kinimesi
Copy link
Collaborator

kinimesi commented Oct 8, 2021

@kubitre I'm sorry, but I think it's redundant to have such an option in this extension while the same feature can be achieved by just setting the CSS background color for Cytoscape div

#cy {
  background: #000;
}

Also the default fill option must be none so that it doesn't overlay the Cytoscape canvas in case someone set its background to a different color.

@ugurdogrusoz
Copy link
Contributor

I think @kinimesi is right.

@kubitre
Copy link
Author

kubitre commented Oct 9, 2021

Ok, but this not work
image

@kubitre
Copy link
Author

kubitre commented Oct 9, 2021

all lines are colored as background color of this div

@kubitre
Copy link
Author

kubitre commented Oct 9, 2021

this work if i change alpha level to 0.9, but If you have to bother like that, then this is some kind of game

@kubitre
Copy link
Author

kubitre commented Oct 9, 2021

image

@kubitre
Copy link
Author

kubitre commented Oct 9, 2021

but if i change grid lines color to white for example, i get full fill color as background color of div

@kubitre
Copy link
Author

kubitre commented Oct 9, 2021

ok, this problem i also solve, but the solution is not obvious, the parameter would solve it much better, let me make it so that if the user does not set anything, then the parameter will be substituted as none, as you wrote, then it will just be more obvious to everyone, and there will be no extra z-index manipulation to do

I Solve this by change Z-index at the div to 0, but after i get small artifacts on grid lines on size lines small then 2
image

@canbax
Copy link
Member

canbax commented Feb 14, 2022

@kubitre how do those rectangular white dots appear?

I agree with @kinimesi. The background color of your canvas is not related to this extension. By using CSS, you can set the background color of your canvas. If you set a background color, z-index should also be set. You can play with gridColor option for different colored grid lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants