Compare commits

...

3 Commits
1.0.6 ... 1.0.9

Author SHA1 Message Date
5170fae311 Se mejora RadialGauge para que al actualizar la data se actualice RadialGauge.
Se sube a version 1.0.9
Se sube a GitHub 1.0.9
Se sube a NPM 1.0.9
2019-12-05 19:30:28 -06:00
c8306d2382 Se vuelve a empaquetar con create react library ya que se coloco el nombre mal.
Se sube a version 1.0.8
Se sube a GitHub 1.0.8
Se sube a NPM 1.0.8
2019-12-05 15:44:46 -06:00
c7ee667af7 Se le agrega export default a index.js
Se sube a version 1.0.7
Se sube a GitHub 1.0.7
Se sube a NPM 1.0.7
2019-12-05 13:38:34 -06:00
9 changed files with 58 additions and 14961 deletions

14930
example/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "chart-2-react-example",
"homepage": "https://aleleba.github.io/chart-2-react",
"name": "chartjs-2-react-example",
"homepage": "https://aleleba.github.io/chartjs-2-react",
"version": "0.0.0",
"license": "MIT",
"private": true,
@ -9,7 +9,7 @@
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-scripts": "^1.1.4",
"chart-2-react": "file:.."
"chartjs-2-react": "file:.."
},
"scripts": {
"start": "react-scripts start",

View File

@ -7,7 +7,7 @@
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<title>chart-2-react</title>
<title>chartjs-2-react</title>
</head>
<body>

View File

@ -1,6 +1,6 @@
{
"short_name": "chart-2-react",
"name": "chart-2-react",
"short_name": "chartjs-2-react",
"name": "chartjs-2-react",
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",

View File

@ -1,13 +1,13 @@
import React, { Component } from 'react'
import { RadialGaugue } from 'chart-2-react'
import { RadialGauge } from 'chartjs-2-react'
export default class App extends Component {
render () {
return (
<div style={{maxWidth: '600px', marginTop: '25px'}}>
<h3 style={{textAlign: 'center'}}>RadialGaugue Component:</h3>
<RadialGaugue />
<h3 style={{textAlign: 'center'}}>RadialGauge Component:</h3>
<RadialGauge />
</div>
)
}

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "chart-2-react",
"name": "chartjs-2-react",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,

View File

@ -1,10 +1,10 @@
{
"name": "chartjs-2-react",
"version": "1.0.6",
"version": "1.0.9",
"description": "Libreria de chart.js para React.js",
"author": "aleleba",
"license": "MIT",
"repository": "aleleba/chart-2-react",
"repository": "aleleba/chartjs-2-react",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",

View File

@ -6,28 +6,31 @@ import 'chartjs-chart-radial-gauge/build/Chart.RadialGauge.umd.min.js';
class RadialGauge extends Component {
componentDidMount(){
constructor(props) {
super(props)
let porcentaje = Math.round(Math.random() * 100),
porcentajeTexto = `${porcentaje} %`
this.state = {
chart: null,
porcentaje,
porcentajeTexto
}
}
componentDidMount() {
var ctx = document.getElementById('chart').getContext('2d');
/*var gradientStroke = ctx.createLinearGradient(500, 0, 100, 0);
gradientStroke.addColorStop(0, "#2A969E");
gradientStroke.addColorStop(1, "#2A969E");*/
//gradientStroke.addColorStop(2, "#f49080");
var config
var randomScalingFactor = function() {
return Math.round(Math.random() * 100);
};
config = {
var config = {
type: 'radialGauge',
data: {
labels: this.props.config ? (this.props.config.data ? (this.props.config.data.labels || ["Porcentaje"]) : ["Porcentaje"]) : ["Porcentaje"],
datasets: [
{
data: this.props.config ? ((this.props.config.data) ? (this.props.config.data.datasets !== undefined ? [this.props.config.data.datasets.data] : [randomScalingFactor()]) : [randomScalingFactor()]) : [randomScalingFactor()],
data: this.props.config ? ((this.props.config.data) ? (this.props.config.data.datasets !== undefined ? [this.props.config.data.datasets.data] : [this.state.porcentaje]) : [this.state.porcentaje]) : [this.state.porcentaje],
backgroundColor: this.props.config ? ( this.props.config.data ? (((this.props.config.data.datasets !== undefined) && (this.props.config.data.datasets.backgroundColor)) ? this.props.config.data.datasets.backgroundColor : '#2A969E') : '#2A969E') : '#2A969E',
borderWidth: this.props.config ? ( this.props.config.data ? (((this.props.config.data.datasets !== undefined) && (this.props.config.data.datasets.borderWidth)) ? this.props.config.data.datasets.borderWidth : 0) : 0) : 0,
label: this.props.config ? ( this.props.config.data ? (((this.props.config.data.datasets !== undefined) && (this.props.config.data.datasets.label)) ? this.props.config.data.datasets.label : "Porcentaje") : "Porcentaje") : "Porcentaje"
@ -87,15 +90,31 @@ class RadialGauge extends Component {
}
};
new Chart(ctx, config);
this.setState({
chart: new Chart(ctx, config)
})
}
render() {
return (
<canvas id="chart" />
)
if (this.state.chart !== null) {
this.props.config ? ((this.props.config.data) ? (this.props.config.data.datasets !== undefined ? (this.state.chart.data.datasets[0].data[0] = this.props.config.data.datasets.data) : [this.state.porcentaje]) : [this.state.porcentaje]) : [this.state.porcentaje]
//this.state.chart.data.datasets[0].data[0] = this.props.config.data.datasets.data)
this.props.config ? ((this.props.config.options) ? (this.props.config.options.centerArea !== undefined ? (this.state.chart.options.centerArea.text = this.props.config.options.centerArea.text) : null) : null) : null
//this.state.chart.options.centerArea.text = this.props.config.options.centerArea.text
this.state.chart.update();
return <canvas id="chart" />
} else {
return <canvas id="chart" />
}
}
}

View File

@ -1,3 +1,5 @@
import RadialGaugue from './RadialGauge.jsx';
import RadialGauge from './RadialGauge.jsx';
export { RadialGaugue }
export { RadialGauge }
export default { RadialGauge }