Make Activity Graphs translate their legend properly
This commit is contained in:
parent
a74fb36b10
commit
70cbab8f2d
|
@ -90,6 +90,16 @@ public class ActivityIndex {
|
|||
return getGroups(null);
|
||||
}
|
||||
|
||||
public static String[] getDefaultGroupLangKeys() {
|
||||
return new String[]{
|
||||
HtmlLang.INDEX_VERY_ACTIVE.getKey(),
|
||||
HtmlLang.INDEX_ACTIVE.getKey(),
|
||||
HtmlLang.INDEX_REGULAR.getKey(),
|
||||
HtmlLang.INDEX_IRREGULAR.getKey(),
|
||||
HtmlLang.INDEX_INACTIVE.getKey()
|
||||
};
|
||||
}
|
||||
|
||||
public static String[] getGroups(Locale locale) {
|
||||
if (locale == null) {
|
||||
return new String[]{
|
||||
|
|
|
@ -489,7 +489,7 @@ public class GraphJSONCreator {
|
|||
Integer unknown = joinAddresses.get(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP);
|
||||
if (unknown != null) {
|
||||
joinAddresses.remove(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP);
|
||||
joinAddresses.put(locale.getString(GenericLang.UNKNOWN).toLowerCase(), unknown);
|
||||
joinAddresses.put(GenericLang.UNKNOWN.getKey(), unknown);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class PieGraphFactory {
|
|||
|
||||
public Pie activityPie(Map<String, Integer> activityData) {
|
||||
String[] colors = theme.getPieColors(ThemeVal.GRAPH_ACTIVITY_PIE);
|
||||
return new ActivityPie(activityData, colors, ActivityIndex.getGroups(locale));
|
||||
return new ActivityPie(activityData, colors, ActivityIndex.getDefaultGroupLangKeys());
|
||||
}
|
||||
|
||||
public Pie serverPreferencePie(Map<ServerUUID, String> serverNames, Map<ServerUUID, WorldTimes> serverWorldTimes) {
|
||||
|
|
|
@ -53,6 +53,6 @@ public class StackGraphFactory {
|
|||
|
||||
public StackGraph activityStackGraph(DateMap<Map<String, Integer>> activityData) {
|
||||
String[] colors = theme.getPieColors(ThemeVal.GRAPH_ACTIVITY_PIE);
|
||||
return new ActivityStackGraph(activityData, colors, dayFormatter, ActivityIndex.getGroups(locale));
|
||||
return new ActivityStackGraph(activityData, colors, dayFormatter, ActivityIndex.getDefaultGroupLangKeys());
|
||||
}
|
||||
}
|
|
@ -101,7 +101,7 @@ const PlayerListCard = ({data, title, justList, orderBy}) => {
|
|||
data: rows,
|
||||
order: [[orderBy !== undefined ? orderBy : 5, "desc"]]
|
||||
});
|
||||
}, [data, orderBy, t, formatDecimals, decimalFormat]);
|
||||
}, [data, orderBy, t, decimalFormat]);
|
||||
|
||||
const rowKeyFunction = useCallback((row, column) => {
|
||||
return row.uuid + "-" + (column ? JSON.stringify(column.data) : '');
|
||||
|
|
|
@ -6,6 +6,23 @@ import Highcharts from "highcharts/highstock";
|
|||
import {withReducedSaturation} from "../../util/colors";
|
||||
import Accessibility from "highcharts/modules/accessibility";
|
||||
|
||||
export const getTranslateLabelForActivityGroup = value => {
|
||||
switch (value) {
|
||||
case "Very Active":
|
||||
return 'html.label.veryActive'
|
||||
case "Active":
|
||||
return 'html.label.active'
|
||||
case "Regular":
|
||||
return 'html.label.indexRegular'
|
||||
case "Irregular":
|
||||
return 'html.label.irregular'
|
||||
case "Inactive":
|
||||
return 'html.label.indexInactive'
|
||||
default:
|
||||
return 'plugin.generic.unknown'
|
||||
}
|
||||
}
|
||||
|
||||
const PlayerbaseGraph = ({data}) => {
|
||||
const {t} = useTranslation()
|
||||
const {nightModeEnabled, graphTheming} = useTheme();
|
||||
|
@ -23,7 +40,12 @@ const PlayerbaseGraph = ({data}) => {
|
|||
Highcharts.setOptions(graphTheming);
|
||||
|
||||
const labels = data?.activity_labels;
|
||||
const series = data?.activity_series;
|
||||
const series = data?.activity_series.map(dataSet => {
|
||||
return {
|
||||
...dataSet,
|
||||
name: t(dataSet.name)
|
||||
}
|
||||
});
|
||||
|
||||
Highcharts.chart(id, {
|
||||
chart: {
|
||||
|
|
|
@ -5,9 +5,10 @@ import {withReducedSaturation} from "../../util/colors";
|
|||
import Scrollable from "../Scrollable";
|
||||
|
||||
const GroupRow = ({group, color}) => {
|
||||
const {t} = useTranslation();
|
||||
return (
|
||||
<tr>
|
||||
<td style={{color}}>{group.name}</td>
|
||||
<td style={{color}}>{t(group.name)}</td>
|
||||
<td>{group.y}</td>
|
||||
</tr>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue