MajaLinder / SEMFIRE

MIT License
4 stars 2 forks source link

Category ticks #145

Closed LIYUHAN22 closed 1 year ago

LIYUHAN22 commented 1 year ago

105 Fix the overlapping issue

The text of the axis can show part of it when the data is too much, and when the mouse is hovering on it, it will show the complete value and words by tooltips.

closes #105

截屏2022-12-05 下午3 47 46 截屏2022-12-05 下午3 48 43 截屏2022-12-05 下午3 50 19
b4rdha commented 1 year ago

Great progress guys! I noticed that there are some changes when I compare to bar chart, it seems like we use the space less rationally see below:
They have a letter below each bar compared to our less frequent tick-ing.

Screenshot 2022-12-05 at 17 14 34

https://github.com/TIBCOSoftware/spotfire-mods/blob/master/catalog/rose-chart/src/roseChart.ts and I tried the same logic, so instead you can wrap in the axis:

function wrap(this: any) {
        var self = d3.select(this);
        let availablePixels = barWidth + padding;

        const fontSize = settings.style.label.size;
        const fontWidth = fontSize * 0.7;

        let label = self.text();
        if (label.length > availablePixels / fontWidth) {
            self.text(label.slice(0, Math.max(1, availablePixels / fontWidth)) + "…"); 
        }
    }

I think it looks better, feel free to add it if you agree.

AstridBer commented 1 year ago

Great progress guys! I noticed that there are some changes when I compare to bar chart, it seems like we use the space less rationally see below: They have a letter below each bar compared to our less frequent tick-ing.

Screenshot 2022-12-05 at 17 14 34
  • I noticed this difference from the rose chart:

https://github.com/TIBCOSoftware/spotfire-mods/blob/master/catalog/rose-chart/src/roseChart.ts and I tried the same logic, so instead you can wrap in the axis:

function wrap(this: any) {
        var self = d3.select(this);
        let availablePixels = barWidth + padding;

        const fontSize = settings.style.label.size;
        const fontWidth = fontSize * 0.7;

        let label = self.text();
        if (label.length > availablePixels / fontWidth) {
            self.text(label.slice(0, Math.max(1, availablePixels / fontWidth)) + "…"); 
        }
    }

I think it looks better, feel free to add it if you agree.

We compared the two methods but don't see a noticable difference in how it displays the labels. We decided to add an if statement so that if the label is small it displays only the first letter without the dots. For now we keep the same method with the small modification.