Skip to content

React lint warnings #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const dataKeys = {

var updatePoints = function(nextProps, chart, dataKey) {
var name = chart.config.type
var nextProps = nextProps

if (name === 'polarArea' || name === 'pie' || name === 'doughnut') {
nextProps.data.datasets.forEach(function(segment, segmentIndex) {
Expand All @@ -35,7 +34,7 @@ var updatePoints = function(nextProps, chart, dataKey) {
removeData(chart)
nextProps.data.datasets.forEach(function(set, setIndex) {
set.data.forEach(function(val, pointIndex) {
if (typeof(chart.data.datasets[setIndex][dataKey][pointIndex]) == "undefined") {
if (typeof(chart.data.datasets[setIndex][dataKey][pointIndex]) === 'undefined') {
addData(nextProps, chart, setIndex)
} else {
chart.data.datasets[setIndex][dataKey][pointIndex] = val
Expand All @@ -47,7 +46,7 @@ var updatePoints = function(nextProps, chart, dataKey) {
chart.data.datasets.pop()
}
nextProps.data.datasets.forEach(function(set, setIndex) {
if (typeof(chart.data.datasets[setIndex]) == "undefined") {
if (typeof(chart.data.datasets[setIndex]) === 'undefined') {
chart.data.datasets.push(nextProps.data.datasets[setIndex])
} else {
chart.data.datasets[setIndex][dataKey] = set.data
Expand All @@ -58,7 +57,7 @@ var updatePoints = function(nextProps, chart, dataKey) {
chart.data.datasets.pop()
}
nextProps.data.datasets.forEach(function(set, setIndex){
if (typeof(chart.data.datasets[setIndex]) == "undefined") {
if (typeof(chart.data.datasets[setIndex]) === 'undefined') {
chart.data.datasets.push(nextProps.data.datasets[setIndex])
} else {
chart.data.datasets[setIndex] = nextProps.data.datasets[setIndex]
Expand All @@ -71,7 +70,7 @@ var updatePoints = function(nextProps, chart, dataKey) {
}
nextProps.data.datasets.forEach(function(set, setIndex) {
set.data.forEach(function(val, pointIndex) {
if (typeof(chart.data.datasets[setIndex][dataKey][pointIndex]) == "undefined") {
if (typeof(chart.data.datasets[setIndex][dataKey][pointIndex]) === 'undefined') {
addData(nextProps, chart, setIndex)
} else {
chart.data.datasets[setIndex][dataKey][pointIndex] = val
Expand Down Expand Up @@ -125,17 +124,20 @@ export default class Chart extends React.Component {
plugins
} = this.props
if (!isEqual(data.datasets, nextProps.data.datasets) ||
nextProps.redraw == true ||
type != nextProps.type ||
height != nextProps.height ||
width != nextProps.width ||
nextProps.redraw === true ||
type !== nextProps.type ||
height !== nextProps.height ||
width !== nextProps.width ||
!isEqual(options, nextProps.options) ||
!isEqual(plugins, nextProps.plugins)) {

var chart = this.state.chart
if (nextProps.redraw) {
chart.destroy()
this.initializeChart(nextProps)
} else {
return true
}
else {
var dataKey = nextProps.dataKey || dataKeys[chart.config.type]
updatePoints(nextProps, chart, dataKey)
if (chart.scales) {
Expand All @@ -145,6 +147,7 @@ export default class Chart extends React.Component {
return false
}
}
return false
}

handleOnClick = (event) => {
Expand Down Expand Up @@ -190,5 +193,8 @@ export default class Chart extends React.Component {
var ctx = el.getContext("2d")
var chart = new Chart(ctx, {type: nextProps.type, data: nextProps.data, options: nextProps.options || {}, plugins: nextProps.plugins || {}})
this.state.chart = chart;
// this.setState({
// chart: chart
// })
}
}