HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div id="scichart-root"></div>
body {
margin: 0;
}
#scichart-root {
width: 100%;
height: 100vh;
}
const {
DataPointSelectionModifier,
FastLineRenderableSeries,
SplineLineRenderableSeries,
IPointMarker,
IPointMetadata,
IPointSeries,
IXyyPointSeries,
LineSeriesDrawingProvider,
MouseWheelZoomModifier,
NumberRange,
NumericAxis,
PointMarkerDrawingProvider,
RenderPassData,
SciChartJsNavyTheme,
SciChartSurface,
EllipsePointMarker,
XyDataSeries,
XyScatterRenderableSeries,
XyyBaseRenderDataTransform,
ZoomExtentsModifier,
ZoomPanModifier,
} = SciChart;
class DashedOrSolidRenderDataTransform extends XyyBaseRenderDataTransform {
protected runTransformInternal(renderPassData: RenderPassData): IPointSeries {
// Guard in case the incoming data is empty
// If you want to do nothing and draw the original data, you don't need to copy it, you can just return renderPassData.pointSeries
if (!renderPassData.pointSeries) {
return this.pointSeries;
}
// It is important to reuse this.pointSeries. Do NOT create a new pointSeries on each transform
const {
xValues: oldX,
yValues: oldY,
indexes: oldI,
resampled,
} = renderPassData.pointSeries;
const { xValues, yValues, y1Values, indexes } = this.pointSeries;
// Clear the target vectors
xValues.clear();
yValues.clear();
y1Values.clear();
indexes.clear();
// indexRange tells the drawing to only use a subset of the data. If data has been resampled, then always use all of it
const iStart = resampled ? 0 : renderPassData.indexRange.min;
const iEnd = resampled ? oldX.size() - 1 : renderPassData.indexRange?.max;
const ds = this.parentSeries.dataSeries as XyDataSeries;
let prevDash = false;
for (let i = iStart; i <= iEnd; i++) {
const index = resampled ? oldI.get(i) : i;
const md = ds.getMetadataAt(index);
xValues.push_back(oldX.get(i));
indexes.push_back(oldI.get(i));
// Add normal point if the current or previous is not dashed
yValues.push_back((!md.dash || !prevDash) ? oldY.get(i) : NaN);
// Add dashed point if the current or previous is dashed
y1Values.push_back(prevDash || md.dash ? oldY.get(i) : NaN);
if (md.dash && !prevDash) {
// Add a break in the normal if the current is dashed but the previous was not
xValues.push_back(oldX.get(i));
yValues.push_back(NaN);
y1Values.push_back(oldY.get(i))
} else if (!md.dash && prevDash) {
// Add a break in the dashed if the current is not dashed but the previous was
xValues.push_back(oldX.get(i));
yValues.push_back(oldY.get(i));
y1Values.push_back(NaN);
}
prevDash = md.dash;
}
// Return the transformed point series
return this.pointSeries;
}
}
class DashDottedLineSeries extends FastLineRenderableSeries {
constructor(wasmContext, options) {
super(wasmContext, options);
this.alternateStrokeDashArray = [3,4];
this.alternateStroke = "Orange";
// Add the new drawingProvider to the series
const dashedDrawingProvider = new LineSeriesDrawingProvider(wasmContext, this, (ps) => ps.y1Values);
this.drawingProviders.push(dashedDrawingProvider);
dashedDrawingProvider.getProperties = (parentSeries) => {
const { stroke, strokeThickness, opacity, isDigitalLine, lineType, drawNaNAs } = parentSeries;
return {
stroke: this.alternateStroke,
strokeThickness,
strokeDashArray: this.alternateStrokeDashArray,
isDigitalLine,
lineType,
drawNaNAs,
containsNaN: true,
};
};
// Create the transform and add it to the series. Pass only the lineDrawingProviders
this.renderDataTransform = new DashedOrSolidRenderDataTransform(this, wasmContext, [this.drawingProviders[0], dashedDrawingProvider]);
}
}
async function simpleSplit(divElementId: string) {
// Create a SciChartSurface with X,Y Axis
const { sciChartSurface, wasmContext } = await SciChartSurface.create(divElementId, {
theme: new SciChartJsNavyTheme() }
);
sciChartSurface.xAxes.add(new NumericAxis(wasmContext));
sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { growBy: new NumberRange(0.1, 0.1)}));
// Create the data. X,Y values are numeric
// dashValues are mapped to metadata (javascript objects)
const xValues = [0,1,2,3,4,5,6];
const yValues = [1,8,3,4,2,3,4];
const metadata = [0,0,0,0,1,1,1].map(num => ({ dash: num }));
const dataSeries = new XyDataSeries(wasmContext, {
xValues,
yValues,
metadata
});
const lineSeries = new DashDottedLineSeries(wasmContext, {
dataSeries,
strokeThickness: 3,
stroke: "SteelBlue",
pointMarker: new EllipsePointMarker(wasmContext, { width: 7, height: 7, strokeThickness:0, fill: "SteelBlue"})
});
sciChartSurface.renderableSeries.add(lineSeries);
}
simpleSplit("scichart-root");
Also see: Tab Triggers