Statistics: Various fixes (#1814)
This commit is contained in:
parent
97b778be22
commit
075893c37e
@ -371,7 +371,7 @@ const RightHeader: FC<OwnProps & StateProps> = ({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case HeaderContent.Statistics:
|
case HeaderContent.Statistics:
|
||||||
return <h3>{lang('Statistics')}</h3>;
|
return <h3>{lang(isChannel ? 'ChannelStats.Title' : 'GroupStats.Title')}</h3>;
|
||||||
case HeaderContent.SharedMedia:
|
case HeaderContent.SharedMedia:
|
||||||
return <h3>{lang('SharedMedia')}</h3>;
|
return <h3>{lang('SharedMedia')}</h3>;
|
||||||
case HeaderContent.ManageChannelSubscribers:
|
case HeaderContent.ManageChannelSubscribers:
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
.StatisticsRecentMessage {
|
.StatisticsRecentMessage {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-left: 3rem;
|
margin-bottom: 1rem;
|
||||||
|
|
||||||
|
&--with-image {
|
||||||
|
padding-left: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
&__summary {
|
&__summary {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
@ -29,7 +29,12 @@ const StatisticsRecentMessage: FC<OwnProps> = ({ message }) => {
|
|||||||
const isRoundVideo = Boolean(getMessageRoundVideo(message));
|
const isRoundVideo = Boolean(getMessageRoundVideo(message));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p className="StatisticsRecentMessage">
|
<div
|
||||||
|
className={buildClassName(
|
||||||
|
'StatisticsRecentMessage',
|
||||||
|
Boolean(mediaBlobUrl || mediaThumbnail) && 'StatisticsRecentMessage--with-image',
|
||||||
|
)}
|
||||||
|
>
|
||||||
<div className="StatisticsRecentMessage__title">
|
<div className="StatisticsRecentMessage__title">
|
||||||
<div className="StatisticsRecentMessage__summary">
|
<div className="StatisticsRecentMessage__summary">
|
||||||
{renderSummary(lang, message, mediaBlobUrl || mediaThumbnail, isRoundVideo)}
|
{renderSummary(lang, message, mediaBlobUrl || mediaThumbnail, isRoundVideo)}
|
||||||
@ -47,7 +52,7 @@ const StatisticsRecentMessage: FC<OwnProps> = ({ message }) => {
|
|||||||
{message.forwards ? lang('ChannelStats.SharesCount', message.forwards) : 'No shares'}
|
{message.forwards ? lang('ChannelStats.SharesCount', message.forwards) : 'No shares'}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,7 @@ export function createHeader(container, title, zoomOutLabel = 'Zoom out', zoomOu
|
|||||||
|
|
||||||
function _onZoomOut() {
|
function _onZoomOut() {
|
||||||
_titleElement = toggleText(_zoomOutElement, title, 'lovely-chart--header-title', true);
|
_titleElement = toggleText(_zoomOutElement, title, 'lovely-chart--header-title', true);
|
||||||
|
_titleElement.classList.remove('lovely-chart--transition');
|
||||||
|
|
||||||
zoomOutCallback();
|
zoomOutCallback();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,17 +120,17 @@ export function createTooltip(container, data, plotSize, colors, onZoom, onFocus
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldLabelIndex = _clickedOnLabel;
|
|
||||||
|
|
||||||
_clickedOnLabel = null;
|
|
||||||
_onMouseMove(e, true);
|
|
||||||
|
|
||||||
const newLabelIndex = _getLabelIndex();
|
|
||||||
if (newLabelIndex !== oldLabelIndex) {
|
|
||||||
_clickedOnLabel = newLabelIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.isZoomable) {
|
if (data.isZoomable) {
|
||||||
|
const oldLabelIndex = _clickedOnLabel;
|
||||||
|
|
||||||
|
_clickedOnLabel = null;
|
||||||
|
_onMouseMove(e, true);
|
||||||
|
|
||||||
|
const newLabelIndex = _getLabelIndex();
|
||||||
|
if (newLabelIndex !== oldLabelIndex) {
|
||||||
|
_clickedOnLabel = newLabelIndex;
|
||||||
|
}
|
||||||
|
|
||||||
onZoom(newLabelIndex);
|
onZoom(newLabelIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,9 +266,9 @@ export function createTooltip(container, data, plotSize, colors, onZoom, onFocus
|
|||||||
|
|
||||||
const shouldPlaceRight = data.isPie ? angle > Math.PI / 2 : labelIndex < meanLabel;
|
const shouldPlaceRight = data.isPie ? angle > Math.PI / 2 : labelIndex < meanLabel;
|
||||||
|
|
||||||
return shouldPlaceRight
|
const leftOffset = shouldPlaceRight ? _offsetX + BALLOON_OFFSET : _offsetX - (_balloon.offsetWidth + BALLOON_OFFSET);
|
||||||
? _offsetX + BALLOON_OFFSET
|
|
||||||
: _offsetX - (_balloon.offsetWidth + BALLOON_OFFSET);
|
return Math.min(Math.max(0, leftOffset), container.offsetWidth - _balloon.offsetWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getBalloonTopOffset() {
|
function _getBalloonTopOffset() {
|
||||||
|
|||||||
@ -12,6 +12,8 @@ export const PLOT_PIE_RADIUS_FACTOR = 0.9 / 2;
|
|||||||
export const PLOT_PIE_SHIFT = 10;
|
export const PLOT_PIE_SHIFT = 10;
|
||||||
export const PLOT_BARS_WIDTH_SHIFT = 0.5;
|
export const PLOT_BARS_WIDTH_SHIFT = 0.5;
|
||||||
|
|
||||||
|
export const PIE_MINIMUM_VISIBLE_PERCENT = 0.02;
|
||||||
|
|
||||||
export const BALLOON_OFFSET = 20;
|
export const BALLOON_OFFSET = 20;
|
||||||
|
|
||||||
export const AXES_FONT = '300 10px Helvetica, Arial, sans-serif';
|
export const AXES_FONT = '300 10px Helvetica, Arial, sans-serif';
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { getCssColor } from './skin';
|
import { getCssColor } from './skin';
|
||||||
import { mergeArrays } from './utils';
|
import { mergeArrays } from './utils';
|
||||||
import { getPieRadius, getPieTextShift, getPieTextSize } from './formulas';
|
import { getPieRadius, getPieTextShift, getPieTextSize } from './formulas';
|
||||||
import { PLOT_BARS_WIDTH_SHIFT, PLOT_PIE_SHIFT } from './constants';
|
import { PLOT_BARS_WIDTH_SHIFT, PLOT_PIE_SHIFT, PIE_MINIMUM_VISIBLE_PERCENT } from './constants';
|
||||||
import { simplify } from './simplify';
|
import { simplify } from './simplify';
|
||||||
import { toPixels } from './Projection';
|
import { toPixels } from './Projection';
|
||||||
|
|
||||||
@ -243,14 +243,16 @@ function drawDatasetPie(context, points, projection, options) {
|
|||||||
context.lineTo(x + shiftX, y + shiftY);
|
context.lineTo(x + shiftX, y + shiftY);
|
||||||
context.fill();
|
context.fill();
|
||||||
|
|
||||||
context.font = `700 ${getPieTextSize(percent, radius)}px Helvetica, Arial, sans-serif`;
|
if (percent >= PIE_MINIMUM_VISIBLE_PERCENT) {
|
||||||
context.textAlign = 'center';
|
context.font = `700 ${getPieTextSize(percent, radius)}px Helvetica, Arial, sans-serif`;
|
||||||
context.textBaseline = 'middle';
|
context.textAlign = 'center';
|
||||||
context.fillStyle = 'white';
|
context.textBaseline = 'middle';
|
||||||
const textShift = getPieTextShift(percent, radius);
|
context.fillStyle = 'white';
|
||||||
context.fillText(
|
const textShift = getPieTextShift(percent, radius);
|
||||||
`${Math.round(percent * 100)}%`, x + directionX * textShift + shiftX, y + directionY * textShift + shiftY,
|
context.fillText(
|
||||||
);
|
`${Math.round(percent * 100)}%`, x + directionX * textShift + shiftX, y + directionY * textShift + shiftY,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user