Skip to content

Commit f73c4e6

Browse files
author
samueldelesque
committed
remove scss dependencies
1 parent f937bc4 commit f73c4e6

File tree

9 files changed

+124
-126
lines changed

9 files changed

+124
-126
lines changed

components/charts/area/area.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, {Component} from 'react'
22
import ReactDOM from 'react-dom'
33
import moment from 'moment'
4-
54
import Chart from '../chart/chart'
65

76
/*
87
* - x axis is always time.
98
* - data is given as [{time: TIMESTAMP, value: VALUE, label: LABEL}]
9+
* - TIMESTAMP is in UNIX_MS
1010
* - @TODO:
1111
• multiple lines as [[{time: TIMESTAMP, value: VALUE}, ...], [{time: TIMESTAMP, value: VALUE}, ...] ...])
1212
*
@@ -147,8 +147,8 @@ export default class Area extends Component{
147147
return data.map((point, index) => {
148148
if(index === 0 || index === data.length - 1) return
149149
if(data[index+1]) followingTime = data[index+1].time
150-
if(!point.label) point.label = point.label
151150
else followingTime = point.time + intervalLength
151+
if(!point.label) point.label = label
152152

153153
let xBase = (point.time - xMin) * xScale,
154154
key = 'point_' + index + '_tooltip',
@@ -338,11 +338,12 @@ export default class Area extends Component{
338338
this.activeWidth = this.props.width
339339
this.activeHeight = this.props.height - 50 // add 50 px in the bottom for the labels
340340

341-
// Let's ensure all data has a timeStamp, and set it in ms if time is in seconds
341+
// Let's ensure all data has a timeStamp
342342
data.forEach((point,index)=>{
343343
if(!point.time){
344344
data[index].time = index
345345
}
346+
data[index].time = parseFloat(data[index].time)
346347
})
347348

348349
// let xMax = this.props.data.length - 1

components/charts/bar-metric/bar-metric.jsx

+40-6
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,65 @@
11
import React from 'react'
2-
import './bar-metric.scss'
32

43
export default class Bar extends React.Component{
54
static defaultProps = {
65
metricName: 'points',
76
value: 0,
87
percent: 100,
8+
metricPadding: 15,
9+
metricColor: '#777',
10+
barWidth: 70,
11+
barHeight: 7,
12+
barRailColor: '#ddd',
13+
barColor: '#408AE5',
914
label: 'N/A'
1015
}
1116

1217
static propTypes = {
1318
metricName: React.PropTypes.string,
1419
value: React.PropTypes.number,
1520
percent: React.PropTypes.number,
21+
barWidth: React.PropTypes.number,
22+
barHeight: React.PropTypes.number,
23+
metricPadding: React.PropTypes.number,
1624
label: React.PropTypes.string,
25+
metricColor: React.PropTypes.string,
26+
barColor: React.PropTypes.string,
27+
barRailColor: React.PropTypes.string,
1728
}
1829

1930
render(){
2031
return (
21-
<div className="bar-metric clearfix" key={`bar-metric.${Math.random()}`}>
22-
<div className="label">{this.props.label}</div>
32+
<div>
33+
<div style={{fontSize: 13, textTransform: 'uppercase'}}>{this.props.label}</div>
2334
<div className="bar-row">
24-
<div className="bar-container">
25-
<div className="bar-completed" style={{width: parseFloat(this.props.percent) + '%'}}></div>
35+
<div style={{
36+
backgroundColor: this.props.barRailColor,
37+
width: this.props.barWidth + '%',
38+
height: this.props.barHeight,
39+
marginTop:4,
40+
display: 'inline-block',
41+
position: 'relative'}}>
42+
<div style={{
43+
width: this.props.percent + '%',
44+
height: this.props.barHeight,
45+
position: 'absolute',
46+
backgroundColor: this.props.barColor,
47+
top: 0,
48+
left: 0,
49+
bottom: 0,
50+
transition: 'all .5s'}}></div>
51+
</div>
52+
<div style={{
53+
width: 100 - this.props.barWidth + '%',
54+
paddingLeft: this.props.metricPadding,
55+
fontSize: 13,
56+
display: 'inline-block',
57+
color: this.props.metricColor,
58+
textAlign: 'right'}}>
59+
{(this.props.value ? this.props.value + " " : "") + this.props.metricName}
2660
</div>
27-
<div className="metric">{(this.props.value ? this.props.value + " " : "") + this.props.metricName}</div>
2861
</div>
62+
<br style={{display: 'table',clear: 'both'}}/>
2963
</div>
3064
)
3165
}

components/charts/bar-metric/bar-metric.scss

-38
This file was deleted.

components/demo/demo-data.jsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export default class demoData {
55

66
constructor(settings){
77
this.settings = Object.assign({
8-
startDate: moment(),
9-
endDate: moment(),
8+
startDate: Date.now(),
9+
endDate: Date.now(),
1010
maxPoints: 31
1111
}, settings)
1212

13-
this.settings.startDate = moment(this.settings.startDate)
14-
this.settings.endDate = moment(this.settings.endDate)
13+
this.settings.startDate = moment(parseInt(this.settings.startDate))
14+
this.settings.endDate = moment(parseInt(this.settings.endDate))
1515
}
1616

1717
cleanGraphData(data = []){
@@ -20,7 +20,7 @@ export default class demoData {
2020
data.forEach((point, i)=>{if(!point.time)data[i].time = point.id || 0;results.push(point)})
2121

2222
// Convert unix time to ms unix time
23-
results.forEach((point, i)=>{if(results[i].format !== 'x'){results[i].time = parseFloat(point.time) * 1000;results[i].format = 'x'}})
23+
// results.forEach((point, i)=>{if(results[i].format !== 'x'){results[i].time = parseFloat(point.time) * 1000;results[i].format = 'x'}})
2424

2525
// Remove data which is out of range
2626
let s = parseFloat(this.settings.startDate.format('x')),
@@ -53,9 +53,9 @@ export default class demoData {
5353
}
5454

5555
// FIXTURES
56-
function genGraphData(startDate, endDate, intervalLength=86400){
56+
function genGraphData(startDate, endDate, intervalLength=86400000){
5757
let range = Math.abs(moment(startDate).diff(moment(endDate), 'days'))
58-
let views = [], value = 3000, steps = range / 7, growth = [1,-1,1,-2,2,3,5], startTime = parseInt(moment(startDate).format('X'))
58+
let views = [], value = 3000, steps = range / 7, growth = [1,-1,1,-2,2,3,5], startTime = parseInt(moment(startDate).format('x'))
5959
for(let i = 0;i<range;i++){
6060
let val = Math.abs(value + (1000 * growth[Math.floor(i/steps)]) + Math.round(Math.random() * 3000))
6161
views.push({time: startTime + i * intervalLength, value: val, label: '{{value}} cats online'})

components/demo/demo.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export default class Demo extends React.Component {
4040

4141
updateInput(){
4242
let settings = {
43-
startDate: this.state.startDate.format(),
44-
endDate: this.state.endDate.format(),
43+
startDate: this.state.startDate.format('x'),
44+
endDate: this.state.endDate.format('x'),
4545
maxPoints: this.state.maxPoints
4646
}
4747
let data = new DemoData(settings)

demo/demo.js

+68-67
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-simple-charts/react-simple-charts.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-simple-charts/react-simple-charts.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-simple-charts",
3-
"version": "0.0.15",
3+
"version": "0.0.18",
44
"description": "",
55
"scripts": {
66
"build:webpack": "NODE_ENV=production webpack --config webpack.config.prod.js",

0 commit comments

Comments
 (0)