d3.js,酒窝,在图表上获得标题

时间:2015-10-16 20:58:24

标签: d3.js dimple.js

我正在使用一个酒窝模板但找不到标题的命令。所以我只是为它查找了一个d3命令并将其添加到我的代码中。不幸的是,标题没有显示。有人可以发现我的错误吗?

<html>
<head>
  <script src="http://d3js.org/d3.v3.min.js"></script>
  <script src="http://dimplejs.org/dist/dimple.v2.1.6.min.js"></script>
</head>
<body>
<div id="chartContainer">
  <script type="text/javascript">
    var svg = dimple.newSvg("#chartContainer", 590, 400);
      d3.tsv("bbd3.tsv", function (data) {
        var myChart = new dimple.chart(svg, data);
        myChart.setBounds(75, 30, 490, 330)
        var myAxisx = myChart.addMeasureAxis("x", "HR");

        myAxisx.overrideMin = 35;
        myAxisx.overrideMax = 75;
        myAxisx.title = "averaged Number of Home Runs";
        var myAxisy = myChart.addMeasureAxis("y", "avg");
        myAxisy.overrideMin = 0.23;
        myAxisy.overrideMax = 0.255;
        myAxisy.title = "Batting average in % averaged over all players";            var mySeries = myChart.addSeries( ["handedness"], dimple.plot.bubble);
        mySeries.aggregate = dimple.aggregateMethod.avg;
        myChart.addLegend(180, 10, 360, 20, "left");
        myChart.draw();
        svg.append("text")
        .attr("x", (width / 2))             
        .attr("y", 0 - (margin.top / 2))
        .attr("text-anchor", "middle")  
        .style("font-size", "16px") 
        .style("text-decoration", "underline")  
        .text("Value vs Date Graph");
      });
  </script>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

我看不到您用于放置标题的public class Matrix { private float[][] values; public Matrix(int rows, int columns) { // throw exception if any argument is <= 0 values = new float[rows][columns]; // ... } // ... } margin变量的声明。由于您的图表定义无论如何都是固定大小,您可以将其替换为:

width