Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/app/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export class ExportTemplate extends Action {

export class SaveExportTemplatePropertyName extends Action {
constructor(
public objectId: string,
public propertyName: string,
public value: string
) {
Expand Down
138 changes: 69 additions & 69 deletions src/app/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ class TextOnPath extends React.PureComponent<{
this.props.align == "start"
? "0%"
: this.props.align == "middle"
? "50%"
: "100%"
? "50%"
: "100%"
}
>
{this.props.text}
Expand All @@ -236,7 +236,7 @@ function renderEndSVGArrow(element: Graphics.Path) {
arrowElement = (
<path
key={`DA-${element.key}`}
d="M 5 0 L 10 5 L 5 10 L 0 5 z"
d={`M ${element.endArrowSize / 2} 0 L ${element.endArrowSize} ${element.endArrowSize / 2} L ${element.endArrowSize / 2} ${element.endArrowSize} L 0 ${element.endArrowSize / 2} z`}
fill={renderColor(
element.style.strokeColor,
element.style.colorFilter
Expand All @@ -248,9 +248,9 @@ function renderEndSVGArrow(element: Graphics.Path) {
arrowElement = (
<circle
key={`OA-${element.key}`}
cx="5"
cy="5"
r="5"
cx={element.endArrowSize / 2}
cy={element.endArrowSize / 2}
r={element.endArrowSize / 2}
fill={renderColor(
element.style.strokeColor,
element.style.colorFilter
Expand All @@ -263,7 +263,7 @@ function renderEndSVGArrow(element: Graphics.Path) {
arrowElement = (
<path
key={`A-${element.key}`}
d="M 0 0 L 10 5 L 0 10 z"
d={`M 0 0 L ${element.endArrowSize} ${element.endArrowSize / 2} L 0 ${element.endArrowSize} z`}
fill={renderColor(
element.style.strokeColor,
element.style.colorFilter
Expand All @@ -276,12 +276,12 @@ function renderEndSVGArrow(element: Graphics.Path) {
<marker
key={`marker-${element.key}`}
id={element.style.endArrowColorId}
viewBox="0 0 10 10"
refX="9"
refY="5"
viewBox={`0 0 ${element.endArrowSize} ${element.endArrowSize}`}
refX={element.endArrowSize / 2}
refY={element.endArrowSize / 2}
markerUnits="strokeWidth"
markerWidth="10"
markerHeight="10"
markerWidth={element.endArrowSize}
markerHeight={element.endArrowSize}
orient="auto"
>
{arrowElement}
Expand All @@ -298,7 +298,7 @@ function renderStartSVGArrow(element: Graphics.Path) {
arrowElement = (
<path
key={`DA-${element.key}-E`}
d="M 5 0 L 10 5 L 5 10 L 0 5 z"
d={`M ${element.beginArrowSize / 2} 0 L ${element.beginArrowSize} ${element.beginArrowSize / 2} L ${element.beginArrowSize / 2} ${element.beginArrowSize} L 0 ${element.beginArrowSize / 2} z`}
fill={renderColor(
element.style.strokeColor,
element.style.colorFilter
Expand All @@ -310,9 +310,9 @@ function renderStartSVGArrow(element: Graphics.Path) {
arrowElement = (
<circle
key={`OA-${element.key}-E`}
cx="5"
cy="5"
r="5"
cx={element.beginArrowSize / 2}
cy={element.beginArrowSize / 2}
r={element.beginArrowSize / 2}
fill={renderColor(
element.style.strokeColor,
element.style.colorFilter
Expand All @@ -325,7 +325,7 @@ function renderStartSVGArrow(element: Graphics.Path) {
arrowElement = (
<path
key={`A-${element.key}-E`}
d="M 10 0 L 10 10 L 0 5 z"
d={`M ${element.beginArrowSize} 0 L ${element.beginArrowSize} ${element.beginArrowSize} L 0 ${element.beginArrowSize / 2} z`}
fill={renderColor(
element.style.strokeColor,
element.style.colorFilter
Expand All @@ -339,12 +339,12 @@ function renderStartSVGArrow(element: Graphics.Path) {
<marker
key={`marker-${element.key}-E`}
id={element.style.startArrowColorId}
viewBox="0 0 10 10"
refX="1"
refY="5"
viewBox={`0 0 ${element.beginArrowSize} ${element.beginArrowSize}`}
refX={element.beginArrowSize / 2}
refY={element.beginArrowSize / 2}
markerUnits="strokeWidth"
markerWidth="10"
markerHeight="10"
markerWidth={element.beginArrowSize}
markerHeight={element.beginArrowSize}
orient="auto"
>
{arrowElement}
Expand Down Expand Up @@ -552,8 +552,8 @@ export function renderGraphicalElementSVG(
<g key={`g-${element.key || options.key}`}>
<defs key={`defs-${element.key || options.key}`}>
{rect.style.fillColor == null &&
rect.style.fillStartColor &&
rect.style.fillStopColor ? (
rect.style.fillStartColor &&
rect.style.fillStopColor ? (
<linearGradient
key={`gradient-${gradientID}`}
id={gradientID}
Expand Down Expand Up @@ -632,8 +632,8 @@ export function renderGraphicalElementSVG(
<g key={`g-${element.key || options.key}`}>
<defs key={`defs-${element.key || options.key}`}>
{ellipse.style.fillColor == null &&
ellipse.style.fillStartColor &&
ellipse.style.fillStopColor ? (
ellipse.style.fillStartColor &&
ellipse.style.fillStopColor ? (
<linearGradient
key={`gradient-${gradientID}`}
id={gradientID}
Expand Down Expand Up @@ -722,15 +722,15 @@ export function renderGraphicalElementSVG(
// if gradient color was set, override color value by ID of gradient
if (
path.style.fillColor == null &&
path.style.fillStartColor != null &&
path.style.fillStopColor != null
path.style.fillStartColor != null &&
path.style.fillStopColor != null
) {
style.fill = `url(#${gradientID})`;
}
if (
path.style.strokeColor != null &&
path.style.fillStartColor != null &&
path.style.fillStopColor != null
path.style.fillStartColor != null &&
path.style.fillStopColor != null
) {
style.stroke = `url(#${gradientID})`;
}
Expand All @@ -739,33 +739,33 @@ export function renderGraphicalElementSVG(
<g key={`g-${element.key || options.key}`}>
<defs key={`defs-${element.key || options.key}`}>
{
path.style.fillStartColor &&
path.style.fillStopColor ? (
<linearGradient
// gradientUnits="userSpaceOnUse"
key={`gradient-${gradientID}`}
id={gradientID}
x1={`${rotation.x1}%`}
y1={`${rotation.y1}%`}
x2={`${rotation.x2}%`}
y2={`${rotation.y2}%`}
>
<stop
offset="0%"
style={{
stopColor: renderColor(path.style.fillStartColor),
stopOpacity: 1,
}}
/>
<stop
offset="100%"
style={{
stopColor: renderColor(path.style.fillStopColor),
stopOpacity: 1,
}}
/>
</linearGradient>
) : null}
path.style.fillStartColor &&
path.style.fillStopColor ? (
<linearGradient
// gradientUnits="userSpaceOnUse"
key={`gradient-${gradientID}`}
id={gradientID}
x1={`${rotation.x1}%`}
y1={`${rotation.y1}%`}
x2={`${rotation.x2}%`}
y2={`${rotation.y2}%`}
>
<stop
offset="0%"
style={{
stopColor: renderColor(path.style.fillStartColor),
stopOpacity: 1,
}}
/>
<stop
offset="100%"
style={{
stopColor: renderColor(path.style.fillStopColor),
stopOpacity: 1,
}}
/>
</linearGradient>
) : null}
</defs>
<path
data-key={element.key || options.key}
Expand Down Expand Up @@ -891,18 +891,18 @@ export function renderGraphicalElementSVG(
const component = element as Graphics.ChartContainerElement;
const subSelection = options.selection
? {
isSelected: (table: string, rowIndices: number[]) => {
// Get parent row indices from component row indices
const parentRowIndices = rowIndices.map(
(x) => component.selectable.rowIndices[x]
);
// Query the selection with parent row indices
return options.selection.isSelected(
component.selectable.plotSegment.table,
parentRowIndices
);
},
}
isSelected: (table: string, rowIndices: number[]) => {
// Get parent row indices from component row indices
const parentRowIndices = rowIndices.map(
(x) => component.selectable.rowIndices[x]
);
// Query the selection with parent row indices
return options.selection.isSelected(
component.selectable.plotSegment.table,
parentRowIndices
);
},
}
: null;

const convertEventHandler = (
Expand Down
21 changes: 11 additions & 10 deletions src/app/stores/action_handlers/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from "../../application";
import { ChartTemplate, Dataset, Specification } from "../../../container";
import { TableType } from "../../../core/dataset";
import { renderLocalSVG } from "../../views/canvas/chart_display";

declare let CHARTICULATOR_PACKAGE: {
version: string;
Expand All @@ -32,16 +33,19 @@ declare let CHARTICULATOR_PACKAGE: {
/** Handlers for document-level actions such as Load, Save, Import, Export, Undo/Redo, Reset */
// eslint-disable-next-line
export default function (REG: ActionHandlerRegistry<AppStore, Actions.Action>) {
REG.add(Actions.SaveExportTemplatePropertyName, function (action) {
this.setPropertyExportName(action.propertyName, action.value);
});

// eslint-disable-next-line
REG.add(Actions.Export, function (action) {
(async () => {
// Export as vector graphics
if (action.type == "svg") {
const svg = await this.renderLocalSVG();
const svg = await renderLocalSVG();
const blob = new Blob([svg], { type: "image/svg;charset=utf-8" });
if (this.onExportTemplateCallback != null) {
if (this.onExportTemplateCallback(action.type, blob))
{
if (this.onExportTemplateCallback(action.type, blob)) {
return;
}
}
Expand All @@ -51,7 +55,7 @@ export default function (REG: ActionHandlerRegistry<AppStore, Actions.Action>) {
if (action.type == "png" || action.type == "jpeg") {
const svgDataURL = stringToDataURL(
"image/svg+xml",
await this.renderLocalSVG()
await renderLocalSVG()
);
renderDataURLToPNG(svgDataURL, {
mode: "scale",
Expand All @@ -60,8 +64,7 @@ export default function (REG: ActionHandlerRegistry<AppStore, Actions.Action>) {
}).then((png) => {
png.toBlob((blob) => {
if (this.onExportTemplateCallback != null) {
if (this.onExportTemplateCallback(action.type, blob))
{
if (this.onExportTemplateCallback(action.type, blob)) {
return;
}
}
Expand Down Expand Up @@ -124,8 +127,7 @@ export default function (REG: ActionHandlerRegistry<AppStore, Actions.Action>) {
const blob = new Blob([htmlString]);

if (this.onExportTemplateCallback != null) {
if (this.onExportTemplateCallback(action.type, blob))
{
if (this.onExportTemplateCallback(action.type, blob)) {
return;
}
}
Expand All @@ -148,8 +150,7 @@ export default function (REG: ActionHandlerRegistry<AppStore, Actions.Action>) {
});
if (this.onExportTemplateCallback != null) {
this.emit(AppStore.EVENT_EXPORT_TEMPLATE, base64);
if (this.onExportTemplateCallback("json", blob))
{
if (this.onExportTemplateCallback("json", blob)) {
return;
}
}
Expand Down
12 changes: 0 additions & 12 deletions src/app/stores/action_handlers/exports.ts

This file was deleted.

Loading
Loading