Адаптация D3 к PowerBI D3 Visual - PullRequest
1 голос
/ 13 мая 2019

Я пытаюсь адаптировать некоторый код, чтобы он работал в PowerBI. Хотя я почти уверен, что знаю, в чем проблема (функция), я не могу ее понять.

Я следовал этому уроку https://www.mssqltips.com/sqlservertip/5273/how-to-render-d3js-custom-charts-in-power-bi-desktop/

-added pbi.height and pbi.width
-removed .append("svg") from svg var
-tried messing with the function by adding pbi.dsv
-i have a pbi object with 2 columns and 2 values
-i also have the css in place

Оригинальный код: https://codepen.io/herudea/pen/YpEeRW

var width = pbi.width,
    height = pbi.height,
    twoPi = 2 * Math.PI,
    progress = 0,
    allocated = "completed",
    total = "total",
    formatPercent = d3.format(".0%");

var arc = d3.svg.arc()
    .startAngle(0)
    .innerRadius(58)
    .outerRadius(66);

var svg = d3.select("#docsChart")
    .attr("width", width)
    .attr("height", height)
  .append("g")
    .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

var meter = svg.append("g")
    .attr("class", "funds-allocated-meter");

meter.append("path")
    .attr("class", "background")
    .attr("d", arc.endAngle(twoPi));

var foreground = meter.append("path")
    .attr("class", "foreground");

var percentComplete = meter.append("text")
    .attr("text-anchor", "middle")
    .attr("class", "percent-complete")
    .attr("dy", "0em");

var description = meter.append("text")
    .attr("text-anchor", "middle")
    .attr("class", "description")
    .attr("dy", "2.3em")
    .text("Total Complete");

var i = d3.interpolate(progress, allocated / total);

 d3.transition().duration(1000).tween("progress", function() {
  return   function(t) {
    progress = i(t);
    foreground.attr("d", arc.endAngle(twoPi * progress));
    percentComplete.text(formatPercent(progress));
  };
});

Я ожидаю, что рабочий датчик будет основан на созданном объекте pbi.

...