1

该图表是黑色的,如附图所示。这是一个 chrome 扩展。当我单击弹出窗口上的检查时,定义了 plottable/d3 元素,因此似乎 plottable 可用于 html可绘图显示黑色

    function drawChart() {

    let xScale = new Plottable.Scales.Linear(),
        yScale = new Plottable.Scales.Linear(),
        xAxis = new Plottable.Axes.Numeric(xScale, "bottom"),
        yAxis = new Plottable.Axes.Numeric(yScale, "left"),
        plot: Plottable.Plots.Line<number> = new Plottable.Plots.Line();
    plot.x(d => d.x, xScale);
    plot.y(d => d.y, yScale);
    let data = [
        { "x": 0, "y": 1 },
        { "x": 1, "y": 2 },
        { "x": 2, "y": 4 },
        { "x": 3, "y": 8 }
    ],
        dataset: Plottable.Dataset = new Plottable.Dataset(data);
    plot.addDataset(dataset);

    let chart: Plottable.Components.Table = new Plottable.Components.Table([
        [yAxis, plot],
        [null, xAxis]
    ]);
    chart.renderTo("svg#VisitorChart");
}


$(document).ready(function() {
    drawChart();
});
4

1 回答 1

4

Plottable.css文件似乎丢失了

包含该文件可以解决问题。

于 2020-02-12T09:45:24.820 回答