Measure axis - limit tick values

后端 未结 3 1696
孤街浪徒
孤街浪徒 2021-01-26 02:17

I have chart looking like that:

\"Chart\"

I use measure axis for Y:

y = myChart.addMeasureAxis(         


        
相关标签:
3条回答
  • 2021-01-26 02:47

    I'm afraid overriding minimum axis values is a little suboptimal at the moment. There is a workaround but it's a bit of a hack. Basically you just hide the x axis entirely and draw a second chart with no series over the top, hiding the second chart's y axis.

    So after drawing do:

    c2 = new dimple.chart(svg, data);
    c2.addCategoryAxis("x", "Day");
    c2.addMeasureAxis("y", "Value").hidden = true;
    c2.draw();
    

    The two axes meet up nicely and look the way you would want.

    Here is a working example:

    http://jsfiddle.net/87GHM/2/

    0 讨论(0)
  • 2021-01-26 02:50

    I was also stuck in this issue. Couldn't find how lower the number of 'ticks' on the y-axis. The library doesn't expose any method for that. So, I tinkered with the library to suit my needs. So it's a hack ^_^

    Use the commented version of the library i.e dimple.v1.1.4.js

    Find the line ~338

    if (!this.hidden) {
                    switch (this.chart._axisIndex(this, "y")) {
                    case 0:
                        this._draw = d3.svg.axis()
                            .orient("left")
                            .scale(this._scale)
                            .ticks(5);   <<<<<<<<<------ This wasn't there before
                        break;
                    case 1:
                        this._draw = d3.svg.axis()
                            .orient("right")
                            .scale(this._scale);
                        break;
                    default:
                        break;
                    }
                }
    

    Add the ticks(5) or whatever number you want.

    0 讨论(0)
  • 2021-01-26 02:51

    Same results could be reached with just CSS and no JS:

    #your-graph .dimple-axis-x {
      g.tick text {
        opacity: 0;
      }
    
      g.tick:nth-child(10n) text {
        opacity: 1;
      }
    }
    
    0 讨论(0)
提交回复
热议问题