smalltalkpharoroassal

Graph-ET x-axis labels


I drew a bar diagram for my benchmarks in Graph-ET on Pharo. Does anybody know how to add the labels to x-axis? I want to write the name of the benchmark under the each of bars.


Solution

  • Open a workspace, and type the following:

    | chart |
    
    chart := GETDiagramBuilder new.
    chart verticalBarDiagram 
        models: ($a to: $z); 
        y: #asInteger;
        regularAxis;
        height: 200.
    
    chart open.
    
    "We use the same model elements"
    ($a to: $z) do: [ :value | 
        | bar label |
        "We define a label, and add it to the view"
        label := ROLabel elementOn: value asString.
        chart rawView add: label.
    
        "We get the bar, the gray element that grows up"
        bar := chart rawView elementFromModel: value.
    
        "Move the label below its corresponding bar"
        ROConstraint move: label below: bar ].
    
    "Inserting high level labels"
    chart rawView add: ((ROLabel red elementOn: 'Chart about my life') translateBy: 200 @ 0).
    chart rawView add: ((ROLabel elementOn: 'Happiness') translateBy: -30 @ -40).
    chart rawView add: ((ROLabel elementOn: 'Passing days') translateBy: 650 @ 210)
    

    This is what you get with the code above