Compare commits

...

16 Commits

Author SHA1 Message Date
rozetko 8264719c82 Merge pull request 'Right y-axis fixes' (#51) from right-y-axis-fixes into main 4 months ago
rozetko 0029d22c4e 0.6.26 4 months ago
rozetko 4f28c5dc13 state: new `getYScaleByOrientation` function 4 months ago
rozetko 2abf246a85 right y-axis: render label 4 months ago
rozetko 839bd12d69 Merge pull request '0.6.25' (#50) from bump-version-to-0.6.25 into main 4 months ago
rozetko 1bfe7f6649 0.6.25 4 months ago
rozetko 95343168d9 Merge pull request 'fix autorange for right y-axis' (#49) from fix-autorange-for-right-y-axis into main 4 months ago
rozetko 2b6fa90af5 fix autorange for right y-axis 4 months ago
Coin de Gamma e841792c34 Merge pull request 'mouse over event type and it's calling' (#44) from onmouseover-event-callback-#42 into main 6 months ago
rozetko c546284e70 Merge pull request 'replace todo with comment' (#40) from styles-use-todo into main 6 months ago
glitch4347 e36148772f mouse over event type and it's calling 6 months ago
glitch4347 90af9810a3 update comment 6 months ago
glitch4347 e24bee024b replace todo with comment 6 months ago
Coin de Gamma bc1e06e515 Merge pull request '0.6.24' (#37) from 0.6.24 into main 8 months ago
glitch4347 eea338db16 0.6.24 8 months ago
Coin de Gamma 63bf4ca931 Merge pull request 'rm abstact keyword and methods' (#36) from bad-abstract-onmouseclick-#35 into main 8 months ago
  1. 2
      package.json
  2. 6
      src/VueChartwerkPodMixin.ts
  3. 24
      src/index.ts
  4. 6
      src/models/options.ts
  5. 1
      src/models/series.ts
  6. 15
      src/models/state.ts
  7. 1
      src/types.ts

2
package.json

@ -1,6 +1,6 @@
{
"name": "@chartwerk/core",
"version": "0.6.23",
"version": "0.6.26",
"description": "Chartwerk core",
"main": "dist/index.js",
"types": "dist/index.d.ts",

6
src/VueChartwerkPodMixin.ts

@ -63,6 +63,9 @@ export default {
if(has(this.$listeners, 'zoomOut')) {
this.options.events.zoomOut = this.zoomOut.bind(this);
}
if(has(this.$listeners, 'mouseOver')) {
this.options.events.mouseOver = this.mouseOver.bind(this);
}
if(has(this.$listeners, 'mouseMove')) {
this.options.events.mouseMove = this.mouseMove.bind(this);
}
@ -97,6 +100,9 @@ export default {
zoomOut(centers) {
this.$emit('zoomOut', centers);
},
mouseOver() {
this.$emit('mouseOver');
},
mouseMove(evt) {
this.$emit('mouseMove', evt);
},

24
src/index.ts

@ -79,7 +79,8 @@ class ChartwerkPod<T extends Serie, O extends Options> {
_series: T[] = [],
_options: O
) {
// TODO: test if it's necessary
// need to call explicitly because option lazyStyleTag
// in webpack style-loader
styles.use();
this.options = new CoreOptions(_options);
@ -115,6 +116,7 @@ class ChartwerkPod<T extends Serie, O extends Options> {
this.renderLegend();
this.renderYLabel();
this.renderY1Label();
this.renderXLabel();
this.options.callbackRenderEnd();
@ -508,8 +510,8 @@ class ChartwerkPod<T extends Serie, O extends Options> {
return;
}
this.chartContainer.append('text')
.attr('y', 0 - this.margin.left)
.attr('x', 0 - (this.height / 2))
.attr('y', -this.margin.left)
.attr('x', -(this.height / 2))
.attr('dy', '1em')
.attr('class', 'y-axis-label')
.attr('transform', 'rotate(-90)')
@ -519,6 +521,22 @@ class ChartwerkPod<T extends Serie, O extends Options> {
.text(this.options.axis.y.label);
}
protected renderY1Label(): void {
if(this.options.axis.y1?.label === undefined) {
return;
}
this.chartContainer.append('text')
.attr('y', -this.width - this.margin.right)
.attr('x', (this.height / 2))
.attr('dy', '1em')
.attr('class', 'y-axis-label')
.attr('transform', 'rotate(90)')
.style('text-anchor', 'middle')
.style('font-size', '14px')
.style('fill', 'currentColor')
.text(this.options.axis.y1.label);
}
protected renderXLabel(): void {
if(this.options.axis.x.label === undefined) {
return;

6
src/models/options.ts

@ -226,6 +226,12 @@ export class CoreOptions<O extends Options> {
}
}
callbackMouseOver(): void {
if(has(this._options.events, 'mouseOver')) {
this._options.events.mouseOver();
}
}
callbackMouseMove(event): void {
if(has(this._options.events, 'mouseMove')) {
this._options.events.mouseMove(event);

1
src/models/series.ts

@ -35,6 +35,7 @@ export class CoreSeries<T extends Serie> {
_series: Array<T> = [];
constructor(series: T[], private _podDefaults?: Partial<T>) {
// TODO: create separate Serie class, and store instances in this._series
this.setSeries(series);
}

15
src/models/state.ts

@ -1,4 +1,4 @@
import { Serie, Options } from '../types';
import { Serie, Options, yAxisOrientation } from '../types';
import { CoreSeries } from './series';
import { CoreOptions } from './options';
@ -89,6 +89,15 @@ export class PodState<T extends Serie, O extends Options> {
this._transform = { x: 0, y: 0, k: 1 };
}
getYScaleByOrientation(orientation?: yAxisOrientation): d3.ScaleLinear<number, number> {
// TODO: we set defaults in Series class, so we don't expect `undefined` here
// we can remove this check when we implement Serie class (see TODO in `series.ts`)
if(orientation === undefined) {
return this._yScale;
}
return orientation === yAxisOrientation.LEFT ? this._yScale : this._y1Scale;
}
get yScale(): d3.ScaleLinear<number, number> {
return this._yScale;
}
@ -187,7 +196,7 @@ export class PodState<T extends Serie, O extends Options> {
if(this.coreOptions.axis.y1.range !== undefined) {
return min(this.coreOptions.axis.y1.range);
}
return this.coreSeries.minValueY;
return this.coreSeries.minValueY1;
}
public getMaxValueY1(): number {
@ -197,7 +206,7 @@ export class PodState<T extends Serie, O extends Options> {
if(this.coreOptions.axis.y1.range !== undefined) {
return max(this.coreOptions.axis.y1.range);
}
return this.coreSeries.maxValueY;
return this.coreSeries.maxValueY1;
}
// getters for correct transform

1
src/types.ts

@ -20,6 +20,7 @@ export type Events = {
panning?: (event: { ranges: AxisRange[], d3Event: any }) => void,
panningEnd?: (range: AxisRange[]) => void,
zoomOut?: (centers: {x: number, y: number}) => void,
mouseOver?: () => void,
mouseMove?: (evt: any) => void,
mouseClick?: (evt: any) => void,
mouseOut?: () => void,

Loading…
Cancel
Save