Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
diff(vnode) {
let {data, identifier} = vnode.attrs;
let newData = data.filter(datum => !this.dataKeys.has(datum[identifier]));
this.dataKeys = new Set(data.map(datum => datum[identifier]));
this.instance
// .width(offsetWidth)
// .height(offsetHeight + (heightOffset || 0))
.change('embedded', vega.changeset()
.insert(newData)
.remove(datum => !this.dataKeys.has(datum[identifier])))
.run();
}
private bindData() {
const {data, spec} = this.props;
if (data && isNamedData(spec.data)) {
this.view.change(spec.data.name,
vega.changeset()
.remove(() => true) // remove previous data
.insert(data.values)
);
}
}
if (
dataIsAnAppendOfPrev(
prevData,
prevNumRows,
prevNumCols,
data,
numRows,
numCols
)
) {
if (prevNumRows < numRows) {
this.vegaView.insert(name, getDataArray(data, prevNumRows))
}
} else {
// Clean the dataset and insert from scratch.
const cs = vega
.changeset()
.remove(vega.truthy)
.insert(getDataArray(data))
this.vegaView.change(name, cs)
logMessage(
`Had to clear the ${name} dataset before inserting data through Vega view.`
)
}
}
async constructView() {
let { spec, data } = this.props
const loader = vega.loader()
const logLevel = vega.Warn
const renderer = 'svg'
spec = vl.compile(spec).spec
const runtime = vega.parse(spec)
const view = new vega.View(runtime, {
loader,
logLevel,
renderer
}).initialize()
view.change('source', vega.changeset().insert(data))
const svgString: string = await view.toSVG()
const blob = new Blob([svgString], { type: 'image/svg+xml' })
const url = window.URL.createObjectURL(blob)
this.image = url
view.finalize()
this.props.onRender && this.props.onRender(blob)
}
checkLoadedFlag(data, $this) {
if($this.vegaLoading) {
window.setTimeout($this.checkLoadedFlag, 100, data, $this);
} else {
if($this.vegaLoading){
debugger;
}
if (!data || !data.values) {
debugger;
}
var newData = data.values.slice();
var changeSet = vega.changeset();
if(data.progress != null){
var progress = parseFloat(data.progress);
if(parseInt(progress*100, 10) >= 100){
document.getElementById('progress_bar').style.width = parseInt(progress*100)+"%";
setTimeout(function(){
document.getElementById('progress_bar').style.opacity = "0.0";
}, 1000);
}else{
document.getElementById('progress_bar').style.width = parseInt(progress*100)+"%";
}
}
var prevData = $this.vegaView.data("source_2");
for(var y = 0; y < newData.length; y++ ){
data (data) {
this.options.data = data;
this.view.change('source_0', changeset().remove(() => true).insert(this.options.data)).run();
}
}