I can't get my XY chart working with database

Great!

A bit of a foreword: I don't know what I'm doing. Will this work? Maybe. Is it a best practice? Definitely not.

You'll need a main datasource and then a sub-datasource for each of the part types/column colors. In the case of the sample you provided (Analyse, No Part_Type, ETALON, and KALIBER)

Those datasources need to be an array of objects like the example that comes with the component in the designer. Here's the script transform I used for the main dataset (Analyse)

def transform(self, value, quality, timestamp):

	ds = value

	data = []
	for row in range(ds.getRowCount()):
		obj = {}
		obj['ID_insert'] = ds.getValueAt(row, 'ID_insert')
		obj['Measure'] = ds.getValueAt(row, 'Measure')
		obj['Different'] = ds.getValueAt(row, 'Different')
		obj['Result_Limit_Max'] = ds.getValueAt(row, 'Result_Limit_Max')
		obj['Result_Limit_Min'] = ds.getValueAt(row, 'Result_Limit_Min')
		obj['Part_Type'] = ds.getValueAt(row, 'Part_Type')
		data.append(obj)
	return data  # Return the array of objects

Then for the sub-sources I did the same thing except made all the measurements None (null) where it didn't match. This is what it looks like for the blank part type in your dataset.

def transform(self, value, quality, timestamp):

	ds = value

	data = []
	for row in range(ds.getRowCount()):
		obj = {}
		obj['ID_insert'] = ds.getValueAt(row, 'ID_insert')
		partType = ds.getValueAt(row, 'Part_Type')
		if partType != None:
			obj['Measure'] = None
			obj['Different'] = None
		else:
			obj['Measure'] = ds.getValueAt(row, 'Measure')
			obj['Different'] = ds.getValueAt(row, 'Different')
		obj['Result_Limit_Max'] = ds.getValueAt(row, 'Result_Limit_Max')
		obj['Result_Limit_Min'] = ds.getValueAt(row, 'Result_Limit_Min')
		obj['Part_Type'] = partType
		data.append(obj)
	return data  # Return the array of objects

Rinse and repeat for KALIBER just replace the if partType != None: with if partType != 'KALIBER': and do the same for your other part types.

prop.datasources should look something like this:

image

xAxes props:

[
  {
    "name": "ID_insert",
    "label": {
      "enabled": true,
      "text": "ID",
      "color": ""
    },
    "inversed": false,
    "visible": true,
    "tooltip": {
      "enabled": true,
      "text": "",
      "cornerRadius": 3,
      "pointerLength": 4,
      "background": {
        "color": "",
        "opacity": 1
      }
    },
    "render": "category",
    "category": {
      "break": {
        "enabled": false,
        "startCategory": "",
        "endCategory": "",
        "size": 0.05
      }
    },
    "date": {
      "baseInterval": {
        "enabled": false,
        "timeUnit": "hour",
        "count": 1,
        "skipEmptyPeriods": false
      },
      "range": {
        "max": "",
        "min": "",
        "useStrict": false
      },
      "break": {
        "enabled": false,
        "startDate": "",
        "endDate": "",
        "size": 0.05
      },
      "inputFormat": "yyyy-MM-dd kk:mm:ss",
      "format": "M/d"
    },
    "value": {
      "range": {
        "max": "",
        "min": "",
        "useStrict": false
      },
      "logarithmic": false,
      "break": {
        "enabled": false,
        "startValue": 0,
        "endValue": 100,
        "size": 0.05
      },
      "format": "#,###.##"
    },
    "appearance": {
      "opposite": false,
      "inside": false,
      "labels": {
        "color": "",
        "opacity": 1,
        "rotation": 0,
        "verticalCenter": "middle",
        "horizontalCenter": "middle"
      },
      "grid": {
        "color": "",
        "opacity": 1,
        "dashArray": "",
        "minDistance": 60,
        "position": 0.5
      },
      "font": {
        "size": "",
        "weight": 500
      }
    }
  }
]

yAxes props:

[
  {
    "name": "Measure",
    "label": {
      "enabled": true,
      "text": "Measure",
      "color": ""
    },
    "inversed": false,
    "visible": true,
    "tooltip": {
      "enabled": true,
      "text": "",
      "cornerRadius": 3,
      "pointerLength": 4,
      "background": {
        "color": "",
        "opacity": 1
      }
    },
    "render": "value",
    "category": {
      "break": {
        "enabled": false,
        "startCategory": "",
        "endCategory": "",
        "size": 0.05
      }
    },
    "date": {
      "baseInterval": {
        "enabled": false,
        "timeUnit": "hour",
        "count": 1,
        "skipEmptyPeriods": false
      },
      "range": {
        "max": "",
        "min": "",
        "useStrict": false
      },
      "break": {
        "enabled": false,
        "startDate": "",
        "endDate": "",
        "size": 0.05
      },
      "inputFormat": "yyyy-MM-dd kk:mm:ss",
      "format": "M/d/yyyy HH:mm:ss"
    },
    "value": {
      "range": {
        "max": 18.5,
        "min": 15.5,
        "useStrict": false
      },
      "logarithmic": false,
      "break": {
        "enabled": false,
        "startValue": 0,
        "endValue": 100,
        "size": 0.05
      },
      "format": "#,###.##"
    },
    "appearance": {
      "opposite": false,
      "inside": false,
      "labels": {
        "color": "",
        "opacity": 1,
        "rotation": 0,
        "verticalCenter": "middle",
        "horizontalCenter": "middle"
      },
      "grid": {
        "color": "",
        "opacity": 1,
        "dashArray": "",
        "minDistance": null,
        "position": 0.5
      },
      "font": {
        "size": "",
        "weight": 500
      }
    }
  }
]

For yAxes.0.value.range.max I used this expression binding:

round(max({this.custom.ds}, "Measure")) + 0.5

and min is:

round(min({this.custom.ds}, "Measure")) - 0.5

And the series props for part type columns (change the data.source to match the name of the part type:

{
  "name": "None",
  "label": {
    "text": ""
  },
  "visible": true,
  "hiddenInLegend": false,
  "defaultState": {
    "visible": true
  },
  "data": {
    "source": "None",
    "x": "ID_insert",
    "y": "Measure"
  },
  "xAxis": "ID_insert",
  "yAxis": "Measure",
  "zIndex": 0,
  "tooltip": {
    "enabled": true,
    "text": "{name}: [bold]{valueY}[/]",
    "cornerRadius": 3,
    "pointerLength": 4,
    "background": {
      "color": "",
      "opacity": 1
    }
  },
  "render": "column",
  "candlestick": {
    "open": {
      "x": "",
      "y": ""
    },
    "high": {
      "x": "",
      "y": ""
    },
    "low": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "fill": {
        "color": "",
        "opacity": 1
      },
      "stroke": {
        "color": "",
        "opacity": 1,
        "width": 1
      },
      "stacked": false,
      "deriveFieldsFromData": {
        "fill": {
          "color": "",
          "opacity": ""
        },
        "stroke": {
          "color": "",
          "opacity": "",
          "width": ""
        }
      },
      "heatRules": {
        "enabled": false,
        "max": "",
        "min": "",
        "dataField": ""
      }
    }
  },
  "column": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "fill": {
        "color": "#00FF00",
        "opacity": 1
      },
      "stroke": {
        "color": "",
        "opacity": 1,
        "width": 1
      },
      "width": null,
      "height": null,
      "stacked": true,
      "deriveFieldsFromData": {
        "fill": {
          "color": "",
          "opacity": ""
        },
        "stroke": {
          "color": "",
          "opacity": "",
          "width": ""
        }
      },
      "heatRules": {
        "enabled": false,
        "max": "",
        "min": "",
        "dataField": ""
      }
    }
  },
  "line": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "connect": true,
      "tensionX": 1,
      "tensionY": 1,
      "minDistance": 0.5,
      "stroke": {
        "width": 3,
        "opacity": 1,
        "color": "",
        "dashArray": ""
      },
      "fill": {
        "color": "",
        "opacity": 0
      },
      "bullets": [
        {
          "enabled": false,
          "render": "circle",
          "width": 10,
          "height": 10,
          "label": {
            "text": "{value}",
            "position": {
              "dx": 0,
              "dy": 0
            }
          },
          "tooltip": {
            "enabled": true,
            "text": "{name}: [bold]{valueY}[/]",
            "cornerRadius": 3,
            "pointerLength": 4,
            "background": {
              "color": "",
              "opacity": 1
            }
          },
          "fill": {
            "color": "",
            "opacity": 1
          },
          "stroke": {
            "color": "",
            "width": 1,
            "opacity": 1
          },
          "rotation": 0,
          "deriveFieldsFromData": {
            "fill": {
              "color": "",
              "opacity": ""
            },
            "stroke": {
              "color": "",
              "opacity": "",
              "width": ""
            },
            "rotation": ""
          },
          "heatRules": {
            "enabled": false,
            "max": 100,
            "min": 2,
            "dataField": ""
          }
        }
      ]
    }
  },
  "stepLine": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "connect": true,
      "tensionX": 1,
      "tensionY": 1,
      "minDistance": 0.5,
      "stroke": {
        "width": 3,
        "opacity": 1,
        "color": "",
        "dashArray": ""
      },
      "fill": {
        "color": "",
        "opacity": 0
      },
      "bullets": [
        {
          "enabled": true,
          "render": "circle",
          "width": 10,
          "height": 10,
          "label": {
            "text": "{value}",
            "position": {
              "dx": 0,
              "dy": 0
            }
          },
          "tooltip": {
            "enabled": true,
            "text": "{name}: [bold]{valueY}[/]",
            "cornerRadius": 3,
            "pointerLength": 4,
            "background": {
              "color": "",
              "opacity": 1
            }
          },
          "fill": {
            "color": "",
            "opacity": 1
          },
          "stroke": {
            "color": "",
            "width": 1,
            "opacity": 1
          },
          "rotation": 0,
          "deriveFieldsFromData": {
            "fill": {
              "color": "",
              "opacity": ""
            },
            "stroke": {
              "color": "",
              "opacity": "",
              "width": ""
            },
            "rotation": ""
          },
          "heatRules": {
            "enabled": false,
            "max": 100,
            "min": 2,
            "dataField": ""
          }
        }
      ]
    }
  }
}

Series props for 'Different':

{
  "name": "Different",
  "label": {
    "text": ""
  },
  "visible": true,
  "hiddenInLegend": false,
  "defaultState": {
    "visible": true
  },
  "data": {
    "source": "Analyse",
    "x": "ID_insert",
    "y": "Different"
  },
  "xAxis": "ID_insert",
  "yAxis": "Measure",
  "zIndex": 0,
  "tooltip": {
    "enabled": true,
    "text": "{name}: [bold]{valueY}[/]",
    "cornerRadius": 3,
    "pointerLength": 4,
    "background": {
      "color": "",
      "opacity": 1
    }
  },
  "render": "column",
  "candlestick": {
    "open": {
      "x": "",
      "y": ""
    },
    "high": {
      "x": "",
      "y": ""
    },
    "low": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "fill": {
        "color": "",
        "opacity": 1
      },
      "stroke": {
        "color": "",
        "opacity": 1,
        "width": 1
      },
      "stacked": false,
      "deriveFieldsFromData": {
        "fill": {
          "color": "",
          "opacity": ""
        },
        "stroke": {
          "color": "",
          "opacity": "",
          "width": ""
        }
      },
      "heatRules": {
        "enabled": false,
        "max": "",
        "min": "",
        "dataField": ""
      }
    }
  },
  "column": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "fill": {
        "color": "#4747FF",
        "opacity": 1
      },
      "stroke": {
        "color": "",
        "opacity": 1,
        "width": 1
      },
      "width": null,
      "height": null,
      "stacked": true,
      "deriveFieldsFromData": {
        "fill": {
          "color": "",
          "opacity": ""
        },
        "stroke": {
          "color": "",
          "opacity": "",
          "width": ""
        }
      },
      "heatRules": {
        "enabled": false,
        "max": "",
        "min": "",
        "dataField": ""
      }
    }
  },
  "line": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "connect": true,
      "tensionX": 1,
      "tensionY": 1,
      "minDistance": 0.5,
      "stroke": {
        "width": 3,
        "opacity": 1,
        "color": "",
        "dashArray": ""
      },
      "fill": {
        "color": "",
        "opacity": 0
      },
      "bullets": [
        {
          "enabled": false,
          "render": "circle",
          "width": 10,
          "height": 10,
          "label": {
            "text": "{value}",
            "position": {
              "dx": 0,
              "dy": 0
            }
          },
          "tooltip": {
            "enabled": true,
            "text": "{name}: [bold]{valueY}[/]",
            "cornerRadius": 3,
            "pointerLength": 4,
            "background": {
              "color": "",
              "opacity": 1
            }
          },
          "fill": {
            "color": "",
            "opacity": 1
          },
          "stroke": {
            "color": "",
            "width": 1,
            "opacity": 1
          },
          "rotation": 0,
          "deriveFieldsFromData": {
            "fill": {
              "color": "",
              "opacity": ""
            },
            "stroke": {
              "color": "",
              "opacity": "",
              "width": ""
            },
            "rotation": ""
          },
          "heatRules": {
            "enabled": false,
            "max": 100,
            "min": 2,
            "dataField": ""
          }
        }
      ]
    }
  },
  "stepLine": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "connect": true,
      "tensionX": 1,
      "tensionY": 1,
      "minDistance": 0.5,
      "stroke": {
        "width": 3,
        "opacity": 1,
        "color": "",
        "dashArray": ""
      },
      "fill": {
        "color": "",
        "opacity": 0
      },
      "bullets": [
        {
          "enabled": true,
          "render": "circle",
          "width": 10,
          "height": 10,
          "label": {
            "text": "{value}",
            "position": {
              "dx": 0,
              "dy": 0
            }
          },
          "tooltip": {
            "enabled": true,
            "text": "{name}: [bold]{valueY}[/]",
            "cornerRadius": 3,
            "pointerLength": 4,
            "background": {
              "color": "",
              "opacity": 1
            }
          },
          "fill": {
            "color": "",
            "opacity": 1
          },
          "stroke": {
            "color": "",
            "width": 1,
            "opacity": 1
          },
          "rotation": 0,
          "deriveFieldsFromData": {
            "fill": {
              "color": "",
              "opacity": ""
            },
            "stroke": {
              "color": "",
              "opacity": "",
              "width": ""
            },
            "rotation": ""
          },
          "heatRules": {
            "enabled": false,
            "max": 100,
            "min": 2,
            "dataField": ""
          }
        }
      ]
    }
  }
}

And finally series props for min (and max would be the same with obvious changes):

{
  "name": "Min",
  "label": {
    "text": "Min"
  },
  "visible": true,
  "hiddenInLegend": false,
  "defaultState": {
    "visible": true
  },
  "data": {
    "source": "Analyse",
    "x": "ID_insert",
    "y": "Result_Limit_Min"
  },
  "xAxis": "ID_insert",
  "yAxis": "Measure",
  "zIndex": 1,
  "tooltip": {
    "enabled": true,
    "text": "{name}: [bold]{valueY}[/]",
    "cornerRadius": 3,
    "pointerLength": 4,
    "background": {
      "color": "",
      "opacity": 1
    }
  },
  "render": "line",
  "candlestick": {
    "open": {
      "x": "",
      "y": ""
    },
    "high": {
      "x": "",
      "y": ""
    },
    "low": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "fill": {
        "color": "",
        "opacity": 1
      },
      "stroke": {
        "color": "",
        "opacity": 1,
        "width": 1
      },
      "stacked": false,
      "deriveFieldsFromData": {
        "fill": {
          "color": "",
          "opacity": ""
        },
        "stroke": {
          "color": "",
          "opacity": "",
          "width": ""
        }
      },
      "heatRules": {
        "enabled": false,
        "max": "",
        "min": "",
        "dataField": ""
      }
    }
  },
  "column": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "fill": {
        "color": "",
        "opacity": 1
      },
      "stroke": {
        "color": "",
        "opacity": 1,
        "width": 1
      },
      "width": null,
      "height": null,
      "stacked": false,
      "deriveFieldsFromData": {
        "fill": {
          "color": "",
          "opacity": ""
        },
        "stroke": {
          "color": "",
          "opacity": "",
          "width": ""
        }
      },
      "heatRules": {
        "enabled": false,
        "max": "",
        "min": "",
        "dataField": ""
      }
    }
  },
  "line": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "connect": true,
      "tensionX": 1,
      "tensionY": 1,
      "minDistance": 0.5,
      "stroke": {
        "width": 2,
        "opacity": 1,
        "color": "#000000",
        "dashArray": ""
      },
      "fill": {
        "color": "",
        "opacity": 0
      },
      "bullets": [
        {
          "enabled": false,
          "render": "circle",
          "width": 10,
          "height": 10,
          "label": {
            "text": "{value}",
            "position": {
              "dx": 0,
              "dy": 0
            }
          },
          "tooltip": {
            "enabled": true,
            "text": "{name}: [bold]{valueY}[/]",
            "cornerRadius": 3,
            "pointerLength": 4,
            "background": {
              "color": "",
              "opacity": 1
            }
          },
          "fill": {
            "color": "",
            "opacity": 1
          },
          "stroke": {
            "color": "",
            "width": 1,
            "opacity": 1
          },
          "rotation": 0,
          "deriveFieldsFromData": {
            "fill": {
              "color": "",
              "opacity": ""
            },
            "stroke": {
              "color": "",
              "opacity": "",
              "width": ""
            },
            "rotation": ""
          },
          "heatRules": {
            "enabled": false,
            "max": 100,
            "min": 2,
            "dataField": ""
          }
        }
      ]
    }
  },
  "stepLine": {
    "open": {
      "x": "",
      "y": ""
    },
    "appearance": {
      "connect": true,
      "tensionX": 1,
      "tensionY": 1,
      "minDistance": 0.5,
      "stroke": {
        "width": 3,
        "opacity": 1,
        "color": "",
        "dashArray": ""
      },
      "fill": {
        "color": "",
        "opacity": 0
      },
      "bullets": [
        {
          "enabled": true,
          "render": "circle",
          "width": 10,
          "height": 10,
          "label": {
            "text": "{value}",
            "position": {
              "dx": 0,
              "dy": 0
            }
          },
          "tooltip": {
            "enabled": true,
            "text": "{name}: [bold]{valueY}[/]",
            "cornerRadius": 3,
            "pointerLength": 4,
            "background": {
              "color": "",
              "opacity": 1
            }
          },
          "fill": {
            "color": "",
            "opacity": 1
          },
          "stroke": {
            "color": "",
            "width": 1,
            "opacity": 1
          },
          "rotation": 0,
          "deriveFieldsFromData": {
            "fill": {
              "color": "",
              "opacity": ""
            },
            "stroke": {
              "color": "",
              "opacity": "",
              "width": ""
            },
            "rotation": ""
          },
          "heatRules": {
            "enabled": false,
            "max": 100,
            "min": 2,
            "dataField": ""
          }
        }
      ]
    }
  }
}

Again, sorry for the false start and delay. I hope you enjoy the rest of your day!

1 Like

@hw79 Thank you for your help.... There was few more things becouse of my query but i made it up...


Thank you again