Comments (13)
Hi,
This is working for me, but only in the x-direction. I am using this inside a 'react-grid-layout'.
import React, { Component } from "react";
import { ResponsiveXYFrame, XYFrame, ORFrame, NetworkFrame } from "semiotic";
const testData = [
{
id: "linedata-l",
color: "#ff0000",
data: [{ px: 1, py: 250 }, { px: 14, py: 250 }]
},
{
id: "linedata-h",
color: "#ff0000",
data: [{ px: 1, py: 1250 }, { px: 14, py: 1250 }]
},
{
id: "linedata-1",
color: "#00a2ce",
data: [
{ py: 500, px: 1 },
{ py: 700, px: 2 },
{ py: null, px: 3 },
{ py: null, px: 4 },
{ py: 200, px: 5 },
{ py: 300, px: 6 },
{ py: 500, px: 7 },
{ py: 500, px: 8 },
{ py: 700, px: 9 },
{ py: null, px: 10 },
{ py: null, px: 11 },
{ py: 200, px: 12 },
{ py: 300, px: 13 },
{ py: 500, px: 14 }
]
},
{
id: "linedata-2",
color: "#4d430c",
data: [
{ py: 100, px: 1 },
{ py: 700, px: 2 },
{ py: 800, px: 3 },
{ py: 600, px: 4 },
{ py: 0, px: 5 },
{ py: 0, px: 6 },
{ py: 0, px: 7 },
{ py: 100, px: 8 },
{ py: 700, px: 9 },
{ py: 800, px: 10 },
{ py: 600, px: 12 },
{ py: 30, px: 13 },
{ py: 50, px: 13.5 },
{ py: 100, px: 14 }
]
},
{
id: "linedata-3",
color: "#b3331d",
data: [
{ py: 1000, px: 1 },
{ py: 800, px: 2 },
{ py: 200, px: 3 },
{ py: 300, px: 4 },
{ py: 300, px: 5 },
{ py: 400, px: 6 },
{ py: 1300, px: 7 },
{ py: 1300, px: 8 },
{ py: 1250, px: 9 },
{ py: 1200, px: 10 },
{ py: 1000, px: 10.5 },
{ py: 900, px: 12 },
{ py: 800, px: 14 }
]
},
{
id: "linedata-4",
color: "#b6a756",
data: [
{ py: 600, px: 1 },
{ py: 700, px: 2 },
{ py: 300, px: 3 },
{ py: 500, px: 4 },
{ py: 600, px: 5 },
{ py: 600, px: 6 },
{ py: 600, px: 7 }
]
}
];
<ResponsiveXYFrame
responsiveWidth="true"
responsiveHeight="true"
size={[
gridWidth,
300
]}
lines={testData}
lineDataAccessor={"data"}
lineStyle={d => ({
fill: d.color,
fillOpacity: 0.5,
stroke: d.color,
strokeWidth: "3px"
})}
defined={d => d.py !== null}
xAccessor={"px"}
yAccessor={"py"}
margin={{ top: 60, bottom: 65, left: 60, right: 20 }}
axes={[
{ orient: "left", tickFormat: d => d },
{ orient: "bottom", tickFormat: d => d }
]}
/>
It seems to need an initial size.
from semiotic.
I can add in the ability to pass containerStyle
would that be enough? I know react-dimensions
has some hiccups with CSS (at least in my experience) so any suggestions are welcome.
from semiotic.
I'm not sure, I've never used react-dimensions
before, that's just what their error message suggests. I'll try to run a couple of more experiments this week to see if I can narrow down what's going wrong.
from semiotic.
Much appreciated.
from semiotic.
After reviewing react-dimensions
implementation of containerStyle my recommendation would be for those folks using Semiotic in a place where they want responsive charts and it falls into the containerStyle
process for react-dimensions
that they build their own HOC (in other words wrap a div that you pass containerStyle
to and then pass its dynamic width and height props immediately down to the Frame in Semiotic). I'm going to circle back to this issue later because this isn't optimal and I need to invest a bit more time in figuring out the best responsive chart approach.
from semiotic.
Note that react-dimensions is no longer under active development
from semiotic.
Oh. Any suggestions on a good replacement for a responsive HOC like that?
from semiotic.
Nevermind, it's pretty clear react-resize-detector
rules the world.
from semiotic.
@darthmall Could you try 1.1.3 and see if that helps. I've moved responsive frames over to using react-resize-detector
and it's been better with everything I've checked.
from semiotic.
from semiotic.
I am still not able to get this working, so maybe I'm doing something wrong. I'm getting TypeError: undefined is not an object (evaluating 'props.size[1]')
from line 60 of ResponsiveFrame.js
.
Here's my test app:
import React from "react";
import ReactDOM from "react-dom";
import {ResponsiveXYFrame} from "semiotic";
import "./style.css";
const main = document.body.appendChild(document.createElement("main"));
const numPoints = 100;
const data = new Array(numPoints);
for (let i = 0; i < numPoints; i++) {
data[i] = [Math.random(), Math.random()];
}
ReactDOM.render(
<figure>
<ResponsiveXYFrame
responsiveWidth={true}
responsiveHeight={true}
points={data}
xAccessor={d => d[0]}
yAccessor={d => d[1]}
axes={[
{orient: "left"},
{orient: "bottom"}
]}
/>
</figure>,
main
);
And the corresponding CSS:
html {
box-sizing: border-box;
}
*, *:after, *:before {
box-sizing: inherit;
}
main {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.responsive-container {
width: 100%;
height: 100%;
}
figure {
margin: 0;
padding: 20px;
width: 100%;
height: 100%;
}
from semiotic.
@jhvanderven Thanks. Providing an initial size did the trick. It resizes with the window now.
from semiotic.
Oh, yes, sorry about that, I'll make sure to make that optional since it is for all other frames. I just forgot to do that for responsive frames... you know, where it actually makes sense.
from semiotic.
Related Issues (20)
- Use Vercel to deploy developer documentation for latest HOT 2
- Decide whether to consolidate semiotic and semiotic-docs repo HOT 8
- Check if auto-external plugin can warn us about import errors
- Add to contributing doc when to upgrade dependencies.
- Run typescript checks in CI
- Add documentation issues from archived repo
- oSort with connectors causes issues in OrdinalFrame
- Create changelog for 2.0 HOT 2
- Add Migration Guide for 1.0 users
- Replace element-resize-event HOT 5
- Sorting in OrdinalFrame Doesn't Work With Dynamic Column Width
- Frames' space allocation behavior can be generalized
- Bundled size quite large HOT 3
- Canvas Rendering Doesn't Initially Render HOT 3
- Remove redundant attribute [Was: class and className entries] HOT 1
- Transition tooltip position HOT 1
- More position options for the legend HOT 3
- How to use with nteract?
- Ability to specify width in terms of percentage
- Some of the website pages are fully blank
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semiotic.