Skip to content

Conversation

@anhe-odoo
Copy link
Contributor

@anhe-odoo anhe-odoo commented Oct 16, 2025

Task Description

This commit aims to add the possibility for the user to customize the axes scale (linear vs logarithmic type and mix/max values) for linear scale. We also add the possibility to show/hide major and minor gridlines (minor gridlines being only available for linear scale and line/scatter chart (for x axis), while available for bar/line/scatter/combo chart for both y axes.

Related Task

@robodoo
Copy link
Collaborator

robodoo commented Oct 16, 2025

Pull request status dashboard

@anhe-odoo anhe-odoo force-pushed the master-chart-add_scale_customization-anhe branch 2 times, most recently from 59e8688 to 5e593d6 Compare October 20, 2025 08:54
Task Description

This commit aims to add the possibility for the user to customize
the axes scale (linear vs logarithmic type and mix/max values) for
linear scale. We also add the possibility to show/hide major and
minor gridlines (minor gridlines being only available for linear
scale and line/scatter chart (for x axis), while avalaible for
bar/line/scatter/combo chart for both y axes.

Related Task

Task: 5159370
This commit extends the axis customization to date type x scale

Task: 5159370
@anhe-odoo anhe-odoo force-pushed the master-chart-add_scale_customization-anhe branch from 5e593d6 to b807af0 Compare October 21, 2025 14:23
Copy link
Contributor

@hokolomopo hokolomopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋

Scroll scroll

Cool feature! Not what the spec was tho, so let's talk with François sometime 🙂

return undefined;
}
if (this.isTimeAxis) {
const timestamp = this.getTimestampFromInput(input);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should really convert that to a spreadsheet date number (1 is 1/1/0900) - not a js timestamp. If I add a limit then remove the date format, I get an huge value that doesn't make sense (eg. 1756425600000). If you use spreadsheet date numbers, it would make sense even after removing the format.

<div class="d-flex">
<div class="w-50">
<span class="o-section-subtitle my-0">Minimum</span>
<input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #7023 we will avoid using simple inputs, use the new components instead :)

import { LineChartDefinition, LineChartRuntime } from "./line_chart";

export interface ScatterChartDefinition
extends Omit<LineChartDefinition, "type" | "stacked" | "cumulative"> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh ? scatter cahrts are not zoomable ? I did a fix and all for zoomable scatter charts https://www.odoo.com/odoo/2328/tasks/5143146

Why change that? And why in this task ?

readonly min?: number;
readonly max?: number;
readonly scaleType?: AxisScaleType;
readonly grid?: AxisGridDesign;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: probably more clear to have a boolean showMajor/minorGridLine rather than design.grid.major

@@ -0,0 +1,69 @@
import { Chart } from "chart.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are minor grid line really not a default chartjs option ? Idk if it's worth doing a plugin for that, IMO minor grid lines are kinda useless

Comment on lines +859 to +868
await mountChartSidePanel(chartId, model);
await openChartDesignSidePanel(model, env, fixture, chartId);
let definition = model.getters.getChartDefinition(chartId) as LineChartDefinition;
expect(definition.axesDesign?.x?.grid).toEqual({ major: false, minor: false });
setCheckboxValueAndTrigger(".o-axis-grid-major input", true, "change");
await nextTick();
definition = model.getters.getChartDefinition(chartId) as LineChartDefinition;
expect(definition.axesDesign?.x?.grid).toEqual({ major: true, minor: false });
const element = fixture.querySelector(".o-axis-grid-minor input");
expect(element).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. and use toHaveCount

createChart(model, { type: "bar" }, chartId);
await mountSpreadsheet();
expect(spyRegister).toHaveBeenCalledTimes(7);
expect(spyRegister).toHaveBeenCalledTimes(8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to change the 7 to regiustry.getKeys().length or something dynamic instead ? It's a bit annoying having to update the 2 tests each time 🙈

*/
export const timeFormatLuxonCompatible =
/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;
/^((d|dd|m|mm|mmm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|mmm|yyyy|yy|hh|h|ss|a)$/i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test ?

A4: "=DATE(2022,1,3)",
A5: "=DATE(2022,1,4)",
});
setFormat(model, "A2:A5", "m/d/yyyy");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setFormat is useless if you already use DATE formula

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and once again you probably can get away with a single point, and a one-line to create the model

}
);

test("can edit chart time axis limits", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the test to the line_chart_plugin.test.ts file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants