Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #56 from FormidableLabs/fixLogScaleDefault
Browse files Browse the repository at this point in the history
filter 0 from default x data, clean up demo
  • Loading branch information
Lauren committed Dec 14, 2015
2 parents 3a746f8 + 7c2ad67 commit 286024f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
55 changes: 31 additions & 24 deletions demo/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ReactDOM from "react-dom";
import {VictoryLine} from "../src/index";
import _ from "lodash";
import {VictoryLabel} from "victory-label";
import d3Scale from "d3-scale";

class App extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -48,38 +49,44 @@ class App extends React.Component {
return (
<div className="demo">
<VictoryLine
style={{border: "2px solid black", data: this.state.style}}
style={{parent: {border: "1px solid black", margin: "5px"}, data: this.state.style}}
data={this.state.data}
label={"label\none"}
animate={{velocity: 0.03}}
/>

<VictoryLine style={{border: "2px solid black", data: {stroke: "blue"}}}
y={(x) => Math.sin(2 * Math.PI * x)}
labelComponent={<VictoryLabel>{"label\ntwo"}</VictoryLabel>}
sample={25}
/>
<VictoryLine
style={{parent: {border: "1px solid black", margin: "5px"}, data: {stroke: "blue"}}}
y={(x) => Math.sin(2 * Math.PI * x)}
labelComponent={<VictoryLabel>{"label\ntwo"}</VictoryLabel>}
sample={25}
/>

<VictoryLine style={{border: "2px solid black", data: {stroke: "red"}}}
y={(x) => x * x}
/>
<VictoryLine
style={{parent: {border: "1px solid black", margin: "5px"}, data: {stroke: "red"}}}
y={(x) => x * x}
/>

<VictoryLine style={{border: "2px solid black"}}
data={[
{x: 1, y: 1},
{x: 2, y: 3},
{x: 3, y: 5},
{x: 4, y: 2},
{x: 5, y: null},
{x: 6, y: null},
{x: 7, y: 6},
{x: 8, y: 7},
{x: 9, y: 8},
{x: 10, y: 12}
]}
/>
<VictoryLine
style={{parent: {border: "1px solid black", margin: "5px"}}}
data={[
{x: 1, y: 1},
{x: 2, y: 3},
{x: 3, y: 5},
{x: 4, y: 2},
{x: 5, y: null},
{x: 6, y: null},
{x: 7, y: 6},
{x: 8, y: 7},
{x: 9, y: 8},
{x: 10, y: 12}
]}
/>

<VictoryLine style={{border: "2px solid black"}}/>
<VictoryLine
style={{parent: {border: "1px solid black", margin: "5px"}}}
scale={{x: d3Scale.linear(), y: d3Scale.log()}}
/>
</div>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/victory-line.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ export default class VictoryLine extends React.Component {
const step = _.max(domain) / samples;
// return an array of x values spaced across the domain,
// include the maximum of the domain
return _.union(_.range(_.min(domain), _.max(domain), step), [_.max(domain)]);
const xArray = _.union(_.range(_.min(domain), _.max(domain), step), [_.max(domain)]);
return _.filter(xArray, (x) => x !== 0);
}

returnOrGenerateY(props, x) {
Expand Down

0 comments on commit 286024f

Please sign in to comment.