Hi,
for a Masterproject i want to implement some new plots (or traces) in plotly.js (Voronoi Treemap, Sunburst et cetera).
To begin with something i created a new minimal trace named “scalarempty” that will plot, as soon it works, an static image inside the graph area, which can be zoomed. This failed.
For this i have done the following:
- lib/index-cartesian.js → add require(‘./scalarempty’);
- lib/index.js → add require(‘./scalarempty’);
- lib/scalarempty.js added: module.exports = require(‘…/src/traces/scalarempty’);
- In traces/scalarempty:
- added calc.js (empty function)
- added attirbutes.js (content: module.exports = {}
- added defaults.js (empty function)
- added Index.js:
//index.js content:
‘use strict’;
var scalarempty = {};
scalarempty.attributes = require(‘./attributes’);
scalarempty.supplyDefaults = require(‘./defaults’);
scalarempty.calc = require(‘./calc’);
scalarempty.plot = require(‘./plot’);
scalarempty.moduleType = ‘trace’;
scalarempty.name = ‘scalarempty’;
scalarempty.basePlotModule = require(‘…/…/plots/cartesian’);
scalarempty.categories = [‘cartesian’, ‘symbols’];
scalarempty.meta = {
description: [
‘Not descripted yet.’
].join(’ ')
};
module.exports = scalarempty;
- added plot.js:
content of scalarempty/plot.js
module.exports = function plot(gd, plotinfo, cdscatter, transitionOpts, makeOnCompleteCallback) {
}
With this i managed to trigger a breakpoint in scalarempty/plot.js in a testplot.
I tried to add the following to plot.js:
var scatterlayer = plotinfo.plot.select('g.scatterlayer');
scatterlayer.selectAll(‘g.trace’).each(function(d, i) {
d.append(“svg:image”)
.attr(“xlink:href”, “C:/Repos/plotly.js/Cat.png”)
.attr(“width”, 30)
.attr(“height”, 30)
.attr(“x”, 10)
.attr(“y”, 10)
.attr(“preserveAspectRatio”,“none”);
This does not work because the function in each is never entered.
At this point i am overwhelmed by the complexity of the sourcecode “example” traces “bar” and “scatter”.
I would appreciate any tipps how to generate a new minimal trace. Is there any sourcecode documentation i did not found?
I hope this is the right spot to ask.
Thanks