Skip to content

Commit

Permalink
API version 1.2 (#34)
Browse files Browse the repository at this point in the history
Update examples to API version 1.2
  • Loading branch information
objerke authored Jun 23, 2021
1 parent 66e722a commit 7be343f
Show file tree
Hide file tree
Showing 30 changed files with 6,518 additions and 6,407 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ export declare interface DataViewRow {
* e.g. as a {@link ModProperty} or {@link AnalysisProperty}.
* @version 1.1
*
* @param useStableId - When true, the id will be a (longer) stable id guarranteed to be the same over time.
* @param useStableId - When true, the id will be a (longer) stable id guaranteed to be the same over time.
* @param omitAxisNames - Axis names to omit when creating the identifier. Can be used to group multiple elements split by these axes, for example to create animation effects in one data view.
*/
elementId(useStableId?: boolean, omitAxisNames?: string[]): string;
Expand Down Expand Up @@ -1404,6 +1404,14 @@ export declare interface RenderContext {
* Gets the image pixel ratio that shall be used when rendering rasterized images and/or using a canvas element.
*/
imagePixelRatio: number;
/**
* Gets a value indicating whether the Spotfire UI is in editing mode.
*
* When this value is true the Spotfire UI displays authoring UI elements, such as axis selectors.
* This property can be used to hide controls not meant for consumers of the analysis.
* @version 1.2
*/
isEditing: boolean;
/**
* Gets information about the currently used theme.
*/
Expand Down
10 changes: 8 additions & 2 deletions examples/js-areachart-d3/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export async function render(state, mod, dataView, windowSize, chartType, rounde
state.preventRender = dragSelectActive;
};

const styling = mod.getRenderContext().styling;
const context = mod.getRenderContext();
const styling = context.styling;
const { tooltip, popout } = mod.controls;
const { radioButton, checkbox } = popout.components;
const { section } = popout;
Expand Down Expand Up @@ -94,7 +95,7 @@ export async function render(state, mod, dataView, windowSize, chartType, rounde
} else {
mod.controls.errorOverlay.hide("rowCount");
}

const colorHierarchy = await dataView.hierarchy("Color");
const xHierarchy = await dataView.hierarchy("X");

Expand Down Expand Up @@ -824,7 +825,12 @@ export async function render(state, mod, dataView, windowSize, chartType, rounde
* @type {HTMLElement}
*/
const labelContainer = document.querySelector(".x-axis-label-container");
labelContainer.classList.toggle("editable", context.isEditing);
labelContainer.onclick = (e) => {
if (!context.isEditing) {
return;
}

tooltip.hide();
popout.show(
{
Expand Down
3 changes: 3 additions & 0 deletions examples/js-areachart-d3/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ body,

.x-axis-label-container {
position: absolute;
}

.editable {
cursor: pointer;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/js-areachart-d3/static/mod-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "1.1",
"apiVersion": "1.2",
"version": "1.1.0",
"name": "Area Chart",
"id": "spotfire-area-chart-mod",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ export declare interface DataViewRow {
* e.g. as a {@link ModProperty} or {@link AnalysisProperty}.
* @version 1.1
*
* @param useStableId - When true, the id will be a (longer) stable id guarranteed to be the same over time.
* @param useStableId - When true, the id will be a (longer) stable id guaranteed to be the same over time.
* @param omitAxisNames - Axis names to omit when creating the identifier. Can be used to group multiple elements split by these axes, for example to create animation effects in one data view.
*/
elementId(useStableId?: boolean, omitAxisNames?: string[]): string;
Expand Down Expand Up @@ -1404,6 +1404,14 @@ export declare interface RenderContext {
* Gets the image pixel ratio that shall be used when rendering rasterized images and/or using a canvas element.
*/
imagePixelRatio: number;
/**
* Gets a value indicating whether the Spotfire UI is in editing mode.
*
* When this value is true the Spotfire UI displays authoring UI elements, such as axis selectors.
* This property can be used to hide controls not meant for consumers of the analysis.
* @version 1.2
*/
isEditing: boolean;
/**
* Gets information about the currently used theme.
*/
Expand Down
4 changes: 4 additions & 0 deletions examples/js-dev-barchart-googlecharts/src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ html, body, #mod-container {
}

svg text {
cursor: default;
}

.editable svg text {
cursor: pointer;
}
6 changes: 6 additions & 0 deletions examples/js-dev-barchart-googlecharts/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Spotfire.initialize(async (mod) => {

const context = mod.getRenderContext();

document.body.classList.toggle("editable", context.isEditing);

/**
* Initiate the read loop
*/
Expand Down Expand Up @@ -230,6 +232,10 @@ Spotfire.initialize(async (mod) => {
const { radioButton } = popout.components;

function showPopout(e) {
if (!context.isEditing) {
return;
}

popout.show(
{
x: e.x,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "1.1",
"apiVersion": "1.2",
"version": "1.0",
"name": "BarChart example using googlecharts",
"id": "basic-barchart-googlecharts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ export declare interface DataViewRow {
* e.g. as a {@link ModProperty} or {@link AnalysisProperty}.
* @version 1.1
*
* @param useStableId - When true, the id will be a (longer) stable id guarranteed to be the same over time.
* @param useStableId - When true, the id will be a (longer) stable id guaranteed to be the same over time.
* @param omitAxisNames - Axis names to omit when creating the identifier. Can be used to group multiple elements split by these axes, for example to create animation effects in one data view.
*/
elementId(useStableId?: boolean, omitAxisNames?: string[]): string;
Expand Down Expand Up @@ -1404,6 +1404,14 @@ export declare interface RenderContext {
* Gets the image pixel ratio that shall be used when rendering rasterized images and/or using a canvas element.
*/
imagePixelRatio: number;
/**
* Gets a value indicating whether the Spotfire UI is in editing mode.
*
* When this value is true the Spotfire UI displays authoring UI elements, such as axis selectors.
* This property can be used to hide controls not meant for consumers of the analysis.
* @version 1.2
*/
isEditing: boolean;
/**
* Gets information about the currently used theme.
*/
Expand Down
8 changes: 8 additions & 0 deletions examples/js-dev-barchart/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ Spotfire.initialize(async (mod) => {
};

yScaleDiv.onclick = function (e) {
if (!context.isEditing) {
return;
}

mod.controls.tooltip.hide();
let factory = mod.controls.popout.components;
let section = mod.controls.popout.section;
Expand Down Expand Up @@ -240,6 +244,10 @@ Spotfire.initialize(async (mod) => {
}

xScaleDiv.onclick = function (e) {
if (!context.isEditing) {
return;
}

let factory = mod.controls.popout.components;
let section = mod.controls.popout.section;
let box = xScaleDiv.getBoundingClientRect();
Expand Down
2 changes: 1 addition & 1 deletion examples/js-dev-barchart/src/mod-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "1.1",
"apiVersion": "1.2",
"version": "1.0",
"name": "Bar Chart",
"id": "js-dev-barchart",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ export declare interface DataViewRow {
* e.g. as a {@link ModProperty} or {@link AnalysisProperty}.
* @version 1.1
*
* @param useStableId - When true, the id will be a (longer) stable id guarranteed to be the same over time.
* @param useStableId - When true, the id will be a (longer) stable id guaranteed to be the same over time.
* @param omitAxisNames - Axis names to omit when creating the identifier. Can be used to group multiple elements split by these axes, for example to create animation effects in one data view.
*/
elementId(useStableId?: boolean, omitAxisNames?: string[]): string;
Expand Down Expand Up @@ -1404,6 +1404,14 @@ export declare interface RenderContext {
* Gets the image pixel ratio that shall be used when rendering rasterized images and/or using a canvas element.
*/
imagePixelRatio: number;
/**
* Gets a value indicating whether the Spotfire UI is in editing mode.
*
* When this value is true the Spotfire UI displays authoring UI elements, such as axis selectors.
* This property can be used to hide controls not meant for consumers of the analysis.
* @version 1.2
*/
isEditing: boolean;
/**
* Gets information about the currently used theme.
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/js-dev-circular-treemap/src/mod-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "1.1",
"apiVersion": "1.2",
"version": "1.0",
"name": "Circular Treemap",
"id": "js-dev-circular-treemap",
Expand Down
Loading

0 comments on commit 7be343f

Please sign in to comment.