How To Force X-Axis Labels on All Tick Marks in P Chart in Spotfire Statistica Workspace

book

Article ID: KB0138682

calendar_today

Updated On:

Products Versions
Spotfire Statistica 14.4

Description

When attempting to display X-axis labels on every tick mark in a P chart within a Statistica workspace, standard interactive graph options, such as adjusting major units or disabling skip values, do not function as expected.




Using this custom code in a script, 

image.png

image.png

Environment

OS:  Windows

Resolution

 The chart's labels are controlled by Custom Units rather than Major Units, necessitating a modification to the custom script (SBV code). Additionally, the script requires a reference to the STATISTICAGraphics.dll library.

  • Ensure the STATISTICAGraphics.dll library is referenced in your custom script. The typical path is C:\Program Files\Spotfire\Statistica\stl_mgra.dll.

image.png

  • Edit the custom script Sub GraphOptions(oGraph As Graph) within your Statistica workspace. Replace or add the following code to configure the X-axis:
Sub GraphOptions(oGraph As Graph)
    Dim oGraphObj As GraphObject
    Set oGraphObj = oGraph.GraphObject
    Dim oGL As Layout2D
    Set oGL = oGraphObj.Content
    ' With oGL
    ' Dim oAxis_1 As Axis2D
    ' Set oAxis_1 = .Axes.Axis(scgAx2DScaleX, scgAxPosPrimary)
    ' With oAxis_1
    ' .StepSize = 1
    ' .ScaleValuesOrientation = scgScaleValuesDirectionPerpendicular
    ' .Font.Size = 8
    ' End With
    ' End With
    Dim oAxis_1 As Axis2D
    Set oAxis_1 = oGL.Axes.Axis(scgAx2DScaleX, scgAxPosPrimary)
    With oAxis_1
        ' --- Axis: Custom Units -> un-hide EVERY custom label + its tickmark ---
        Dim i As Long
        Dim cv As CustomScaleValue
        For i = 1 To .CustomScaleValues.Count
            Set cv = .CustomScaleValues.Item(i)
            cv.Hidden = False ' show this label
            cv.TickMark = True ' and draw its tickmark
        Next i
        ' --- Axis: Scale Values -> use the custom labels, skip nothing ---
        .DisplayCustomLabels = True
        .SkipValuesState = scgSkipValuesOff
        ' --- Axis: Custom Units -> Display options / Tickmark format ---
        .DisplayCustomTickMark = True
        .CustomTickMark.Type = scgOutside ' Inside / Outside / Crossed
        .CustomTickMark.Size = scgTmSmall ' Small / Medium / Large / Custom
        ' --- Axis: Major Units -> turn the competing auto units off ---
        .DisplayMajorTickMark = False
        ' --- readability: rotate the labels and shrink the font ---
        .ScaleValuesOrientation = scgScaleValuesDirectionPerpendicular
        .Font.Size = 8
    End With
End Sub

 

Attached at the bottom in an example workspace with the custommized script.

Issue/Introduction

Standard graph options do not force X-axis labels on all tick marks in a P chart within a Statistica workspace. This article provides a custom script modification to ensure all custom labels and their corresponding tick marks are displayed.

Attachments

p chart - example.sdm get_app