Giter Club home page Giter Club logo

Comments (13)

jhvanderven avatar jhvanderven commented on May 17, 2024 1

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.

emeeks avatar emeeks commented on May 17, 2024

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.

darthmall avatar darthmall commented on May 17, 2024

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.

emeeks avatar emeeks commented on May 17, 2024

Much appreciated.

from semiotic.

emeeks avatar emeeks commented on May 17, 2024

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.

Ribesg avatar Ribesg commented on May 17, 2024

Note that react-dimensions is no longer under active development

from semiotic.

emeeks avatar emeeks commented on May 17, 2024

Oh. Any suggestions on a good replacement for a responsive HOC like that?

from semiotic.

emeeks avatar emeeks commented on May 17, 2024

Nevermind, it's pretty clear react-resize-detector rules the world.

from semiotic.

emeeks avatar emeeks commented on May 17, 2024

@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.

darthmall avatar darthmall commented on May 17, 2024

from semiotic.

darthmall avatar darthmall commented on May 17, 2024

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.

darthmall avatar darthmall commented on May 17, 2024

@jhvanderven Thanks. Providing an initial size did the trick. It resizes with the window now.

from semiotic.

emeeks avatar emeeks commented on May 17, 2024

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)

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.