dimple.js无法解决这些问题

时间:2018-03-17 07:44:54

标签: d3.js charts dimple.js

我在dimple js中有一些需求,我无法在任何地方找到任何与我的查询相关的内容。我制作了一个简单的条形图,但值按升序排列,Y轴标签隐藏,值转换为1k,2k。

请帮我解决这3个问题:

  1. 停止按升序排序数据
  2. 缩短Y轴标签
  3. 显示json中的确切值,而不是将其转换为1k,2k

     var data = [
                    {
                        "Service" : "Primary Services" ,
                        "Total Services" : "10065"
                    } ,
                    {
                        "Service" : "PCP" ,
                        "Total Services" : "851"
                    } ,
                    {
                        "Service" : "scientist" ,
                        "Total Services" : "8818"
    
                } ,
                {
                    "Service" : "NP/PA/CNS" ,
                    "Total Services" : "5854"
                } ,
                {
                    "Service" : "FQHC/RHC" ,
                    "Total Services" : "8574"
    
                }
    
            ];
    
    
    var svg = dimple.newSvg("#types-of-services", 500, 300);
    
     var myChart = new dimple.chart(svg, data);
    
    
    
    // Set bounds
    myChart.setBounds(0, 0, "5%", "5%")
    
    myChart.setMargins("75px", "0px", "20px", "50px");
    
    var x = myChart.addMeasureAxis("x", "Total Services");
    
    var y = myChart.addCategoryAxis("y", "Service");
    
     myChart.addSeries(null, dimple.plot.bar);
    
    
    x.fontSize = "12";
    y.fontSize = "12";
    
    x.fontFamily = "Roboto";
    y.fontFamily = "Roboto";
    
    myChart.draw(1700);
    
    x.titleShape.remove();
    
    $(window).on('resize', resize);
    $('.sidebar-control').on('click', resize);
    
    function resize() {
    
    
        myChart.draw(0, true);
    
    
        x.titleShape.remove();
    }
    

1 个答案:

答案 0 :(得分:1)

测量轴将排序,显示为1K,2K等,请改用类别轴...

// var x = myChart.addMeasureAxis("x", "Total Services");
var x = myChart.addCategoryAxis("x", "Total Services");