Chart2/Open Technical Issue in Chart2

From Apache OpenOffice Wiki
Jump to: navigation, search

Notes on diverse technical issues:

Autoscaling of Text relative to Diagram Size

In the old chart implementation, when auto-scaling was on, a resize of a chart OLE object or the resize of the Window of a standalone chart resulted in a resize of the actual font sizes in the model, i.e. the model was changed. In the case of an OLE object this is ok, as this also changes the visual area, which is also a model property. However, resizing a document window should not modify the model.

To overcome this bad design, in the new chart we decided to add a reference size to font sizes in the model. So when auto-scaling should be on for an object, the size of the page (the whole chart, which equals the visual area size) is set as ReferencePageSize along with the font. So if the chart is resized, the view can calculate a new font size by comparing the new size of the page with this reference size and adapt the stored font size. So the font becomes bigger without having to change the model (apart from the fact that a resize of the OLE object modifies the model, because the visual area size is changed). If a font should not be scaled, the reference size is simply set to void. So far this concept is very good. It also solves the problem of getting the exact same font size after resizing the chart to an extreme (e.g. very small) and back to the original size again, which was a mess in the old chart.

However, there are objects where the fonts are supposed to scale with the diagram size rather than the page size, e.g. the axes. The problem here is that the diagram size may be void, which means the view has to calculate it by itself. The actual size of the diagram is therefore not known unless a view is created that does the auto-calculation. So, if you want to enable auto-scaling for an axis in a chart, you would have to set the actual diagram size as reference size at the model axis object. However, you don't know it when the diagram has an auto-size.

In the file-format we should also have the currently visible font size plus a boolean flag saying whether an object should auto-scale or not. So, here we have a similar problem. We would need to have a view that calculates the size of the diagram (if it has auto-size), after a chart was loaded, in order to translate the boolean flag into a fitting diagram reference size. And also for saving, we would need the current diagram size for calculating the currently visible font size.

So, for case that the diagram is auto-sized, to avoid having a view for switching auto-scale on for diagram-dependent font sizes, as well as saving and loading of files we need a solution here.

Solution ideas:

  • In case the diagram is auto-sized, set the page size as reference size. Unless the diagram is resized, the mechanism would then work for resizes of the whole chart like before. The font size written to the file would be the real font size in the model, which is ok. The view would have to use the page size for comparison when it finds out that the diagram's model has no size.
  • What happens if a user resizes the diagram? In this scenario we would need a mechanism that sets the currently calculated auto-size of the diagram (before the resize) as a fixed size to all model objects that use a diagram reference size and have the page size set as reference. Then it has to set the new diagram size at the diagram. This is error prone, as you might forget objects. Also, comparing the current reference size with the page size is also not very elegant.
  • Drop the feature of diagram-related font sizes. Use only the page as reference size. This would simplify things but would break the feature of getting smaller fonts when you resize the diagram inside a chart document. I currently prefer this solution for different reasons.
    • First, we only have one concept: a reference page size, not reference sizes that refer to different objects.
    • Second, we always know the page size, as it is equal to the visual area size of the model. Apart from that an auto-page size wouldn't make much sense. So, we solve this problem.
    • Third, the down-side of doing this is, that resizing the diagram would not scale the fonts at axes, (axis titles?) and data points. But on the other hand, a chart document should layout the chart in a nice way, so that a user should not have the need to resize the diagram. If a user still wants to change the diagram size, he can change the font sizes manually. I think this is a valid compromise, as I think this does not happen too often. Also, for small diagram size changes a non-scaling font doesn't matter too much.
    • It simply does not make sense to set a reference size that is not found at the correspodning object (the diagram) in the model, but can only be obtained by a view. If you replaced your view implementation or you changed the auto-calculation of the view, you will get different results, so it is not reliable.
  • On resize change the model.
    • Setting re-scaled fonts is a bad idea as the old chart showed. You get rounding errors with sometimes drastic results.
    • It would be ok for OLE objects, as they are modified anyway (the visual area size)
    • If we would introduce a stand-alone chart some day, we would have to change the behaviour similar to draw or writer: The chart has a fixed page size and resizes of the window only change the visual area of the document. However, this conflicts with the use of the visual area as page size in the OLE scenario, where we definitely want to have the page size equal to the visual area size.
    • Therefore, this is seems like a bad idea.
  • Do not allow an empty diagram size if there are objects with DiagramReferenceSizes.
    • This is also no good idea, as the diagram would need knowledge about all objects with diagram reference sizes, to behave accordingly on setting the size.
    • When we want auto-resize as default, this would also mean the default would be to have a concrete diagram size, which is not reasonable.

So, summarizing, dropping the feature of fonts scaling with the diagram seems the most appropriate thing to do. Of course we will lose a feature and have to decide if it is ok for users to no longer have this. As I said, I think resizing the diagram to something very much smaller than the one you get with auto-calculation is not a very common or typical scenario.

(article by

Personal tools